Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: PowerPC System Software /
Chapter 3 - Code Fragment Manager / Code Fragment Manager Reference
Fragment-Defined Routines /


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.
-->contextIDlongA context ID.
-->closureIDlongA closure ID.
-->connectionIDlongA connection ID.
-->fragLocatorFragmentLocatorA fragment location block.
-->libNamePtrA pointer to fragment's name.
-->reserved4alongReserved.
-->reserved4blongReserved.
-->reserved4clongReserved.
-->reserved4dlongReserved.

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 return noErr if it executes successfully, and some other result code if it does not. If your initialization routine returns any result code other than noErr, the entire load fails and the error fragUserInitProcErr is returned to the code that requested the root load.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
3 JUL 1996