Important: The information in this document is obsolete and should not be used for new development.
ConnectionInitializationRoutine
You can define a fragment initialization routine that is executed by the Code Fragment Manager when the fragment is first loaded into memory and prepared for execution. An initialization routine has the following type definition:
typedef OSErr ConnectionInitializationRoutine (InitBlockPtr initBlkPtr);
- initBlkPtr
- A pointer to a fragment initialization block specifying information about the fragment.
--> contextID long A context ID. --> closureID long A closure ID. --> connectionID long A connection ID. --> fragLocator FragmentLocator A fragment location block. --> libName Ptr A pointer to fragment's name. --> reserved4a long Reserved. --> reserved4b long Reserved. --> reserved4c long Reserved. --> reserved4d long Reserved. DESCRIPTION
A fragment's initialization routine is executed immediately after the fragment has been loaded into memory (if necessary) and prepared for execution, and immediately before the fragment's main routine (if it has one) is executed. The initialization routine is passed a pointer to an initialization block, which contains information about the fragment, such as its location and connection ID. See "Fragment Initialization Block" on page 3-15 for a description of the fields of the initialization block.You can use the initialization routine to perform any tasks that need to be performed before any of the code or data in the fragment is accessed. For example, you might want to open the fragment's resource fork (if it has one). You can determine the location of the fragment's container from the
FragmentLocator
field of the fragment initialization block whose address is passed to your initialization routine.RESULT CODES
Your initialization routine should returnnoErr
if it executes successfully, and some other result code if it does not. If your initialization routine returns any result code other thannoErr
, the entire load fails and the errorfragUserInitProcErr
is returned to the code that requested the root load.