Important: The information in this document is obsolete and should not be used for new development.
Summary of the Code Fragment Manager
C Summary
Constants
/*Gestalt selector and response bits*/ #define gestaltCFMAttr 'cfrg' /*Code Fragment Manager attributes*/ enum { gestaltCFMPresent = 0 /*set if Code Fragment Mgr is present*/ }; #define kPowerPCArch 'pwpc' /*PowerPC instruction set architecture*/ #define kMotorola68KArch 'm68k' /*680x0 instruction set architecture*/ #define kNoLibName ((unsigned char *) 0) #define kNoConnectionID ((ConnectionID) 0) #define kUnresolvedSymbolAddress ((Ptr) 0x0) enum { kLoadLib = 1, /*load fragment*/ kFindLib = 2, /*find fragment*/ kLoadNewCopy = 5 /*load fragment with new copy of data*/ }; enum { kCodeSymbol = 0, /*a code symbol*/ kDataSymbol = 1, /*a data symbol*/ kTVectSymbol = 2 /*a transition vector symbol*/ }; enum { /*selectors for fragment location record*/ kInMem, /*container in memory*/ kOnDiskFlat, /*container in a data fork*/ kOnDiskSegmented /*container in a resource*/ };Data Types
typedef long ConnectionID; /*connection ID number*/ typedef unsigned long LoadFlags; /*a flag long word*/ typedef unsigned char SymClass; /*symbol class*/Fragment Initialization Block
struct InitBlock { long contextID; /*context ID*/ long closureID; /*closure ID*/ long connectionID; /*connection ID*/ FragmentLocator fragLocator; /*fragment location*/ Ptr libName; /*pointer to fragment name*/ long reserved4a; /*reserved*/ long reserved4b; /*reserved*/ long reserved4c; /*reserved*/ long reserved4d; /*reserved*/ }; typedef struct InitBlock InitBlock, *InitBlockPtr;Fragment Location Record
struct FragmentLocator { long where; /*location selector*/ union { MemFragment inMem; /*memory location record*/ DiskFragment onDisk; /*disk location record*/ SegmentedFragment inSegs; /*segment location record*/ } u; }; typedef struct FragmentLocator FragmentLocator, *FragmentLocatorPtr;Memory Location Record
struct MemFragment { Ptr address; /*pointer to start of fragment*/ long length; /*length of fragment*/ Boolean inPlace; /*is data section in place?*/ }; typedef struct MemFragment MemFragment;Disk Location Record
struct DiskFragment { FSSpecPtr fileSpec; /*pointer to FSSpec*/ long offset; /*offset to start of fragment*/ long length; /*length of fragment*/ }; typedef struct DiskFragment DiskFragment;Segment Location Record
struct SegmentedFragment { FSSpecPtr fileSpec; /*pointer to FSSpec*/ OSType rsrcType; /*resource type*/ short rsrcID; /*resource ID*/ }; typedef struct SegmentedFragment SegmentedFragment;Code Fragment Manager Routines
Loading Fragments
OSErr GetDiskFragment (FSSpecPtr fileSpec, long offset, long length, Str63 fragName, LoadFlags findFlags, ConnectionID *connID, Ptr *mainAddr, Str255 errName); OSErr GetMemFragment (Ptr memAddr, long length, Str63 fragName, LoadFlags findFlags, ConnectionID *connID, Ptr *mainAddr, Str255 errName); OSErr GetSharedLibrary (Str63 libName, OSType archType, LoadFlags findFlags, ConnectionID *connID, Ptr *mainAddr, Str255 errName);Unloading Fragments
OSErr CloseConnection(ConnectionID *connID);Finding Symbols
OSErr FindSymbol (ConnectionID connID, Str255 symName, Ptr *symAddr, SymClass *symClass); OSErr CountSymbols (ConnectionID connID, long *symCount); OSErr GetIndSymbol (ConnectionID connID, long symIndex, Str255 symName, Ptr *symAddr, SymClass *symClass);Fragment-Defined Routines
Initializing Fragments
typedef OSErr ConnectionInitializationRoutine (InitBlockPtr initBlkPtr);Terminating Fragments
typedef void ConnectionTerminationRoutine (void);Result Codes
fragNoErr 0 No error paramErr -50 Parameter error fragContextNotFound -2800 Context ID is not valid fragConnectionIDNotFound -2801 Connection ID is not valid fragSymbolNotFound -2802 Symbol was not found in connection fragSectionNotFound -2803 Section was not found fragLibNotFound -2804 Library name not found in fragment registry fragDupRegLibName -2805 Registered name already in use fragFormatUnknown -2806 Fragment container format unknown fragHadUnresolveds -2807 Loaded fragment has unacceptable unresolved symbols fragNoMem -2809 Not enough memory for internal bookkeeping fragNoAddrSpace -2810 Not enough memory in user's address space for section fragNoContextIDs -2811 No more context IDs available fragObjectInitSeqErr -2812 Order error during user initialization function fragImportTooOld -2813 Import library is too old fragImportTooNew -2814 Import library is too new fragInitLoop -2815 Circularity in required initialization order fragInitRtnUsageErr -2816 Boot library has initialization routine fragLibConnErr -2817 Error connecting to library fragMgrInitErr -2818 Error during Code Fragment Manager initialization fragConstErr -2819 Internal inconsistency discovered fragCorruptErr -2820 Fragment container is corrupted fragUserInitProcErr -2821 Initialization procedure did not return noErr
fragAppNotFound -2822 No application found in 'cfrg'
resourcefragArchErr -2823 Fragment targeted for unacceptable architecture fragInvalidFragmentUsage -2824 Fragment is used invalidly