A function identified as deprecated has been superseded and may become unsupported in the future.
Closes a connection to a fragment. (Deprecated in Mac OS X v10.5.)
OSErr CloseConnection ( CFragConnectionID *connID );
A pointer to a connection ID.
A result code. See “Code Fragment Manager Result Codes.”
The CloseConnection
function
closes the connection to a fragment indicated by the connID
parameter. CloseConnection
decrements
the count of existing connections to the specified fragment and,
if the resulting count is 0, calls the fragment’s termination
function and releases the memory occupied by the code and data sections
of the fragment. If the resulting count is not 0, any per-connection
data is released but the code section remains in memory.
When a fragment is unloaded as a result of its final connection having been closed, all libraries that depend on that fragment are also released, provided that their usage counts are also 0.
The Code Fragment Manager automatically closes any connections
that remain open at the time ExitToShell
is
called for your application, so you need to call CloseConnection
only
for fragments you wish to unload before your application terminates.
You can close a connection only to the root of a loading sequence (that is, the fragment whose loading triggered the entire load chain).
CodeFragments.h
Converts a bundle prelocator to a Core Foundation bundle locator. (Deprecated in Mac OS X v10.5.)
OSErr ConvertBundlePreLocator ( CFragSystem7LocatorPtr initBlockLocator );
A pointer to a fragment locator structure.
On input, the structure contains a System 7 locator. On output,
the structure contains a CFragCFBundleLocator
.
A result code. See “Code Fragment Manager Result Codes.”
This function can be used by initialization routines.
CodeFragments.h
Determines how many symbols are exported from a specified fragment. (Deprecated in Mac OS X v10.5.)
OSErr CountSymbols ( CFragConnectionID connID, long *symCount );
A connection ID.
On return, a pointer to the number of exported
symbols in the fragment whose connection ID is connID
.
You can use the value returned in symCount
to
index through all the exported symbols in a particular fragment
(using the GetIndSymbol
function).
A result code. See “Code Fragment Manager Result Codes.”
CodeFragments.h
Searches for a specific exported symbol. (Deprecated in Mac OS X v10.5.)
OSErr FindSymbol ( CFragConnectionID connID, ConstStr255Param symName, Ptr *symAddr, CFragSymbolClass *symClass );
A connection ID.
A symbol name.
On return, a pointer to the address of the
symbol whose name is symName
.
On return, a pointer to the class of the symbol
whose name is symName
.
The currently recognized symbol classes are defined by the “Load Flag, Symbol Class, and Fragment Locator Constants.”
A result code. See “Code Fragment Manager Result Codes.”
The FindSymbol
function
searches the code fragment identified by the connID
parameter for
the symbol whose name is specified by the symName
parameter.
If that symbol is found, FindSymbol
returns
the address of the symbol in the symAddr
parameter
and the class of the symbol in the symClass
parameter.
Because a fragment’s code is normally exported through transition
vectors to that code, the value kCodeSymbol
is
not returned in the PowerPC environment. You can use the other two
constants to distinguish exports that represent code (of class kTVectSymbol
)
from those that represent general data (of class kDataSymbol
).
CodeFragments.h
Locates and possibly also loads a fragment contained in a file’s data fork into your application’s context. (Deprecated in Mac OS X v10.5.)
OSErr GetDiskFragment ( const FSSpec *fileSpec, UInt32 offset, UInt32 length, ConstStr63Param fragName, CFragLoadOptions options, CFragConnectionID *connID, Ptr *mainAddr, Str255 errMessage );
A pointer to a file system specification that identifies the disk-based fragment to load.
The number of bytes from the beginning of the file’s data fork at which the beginning of the fragment is located.
The length (in bytes) of the fragment. Specify
the constant kWholeFork
for this
parameter if the fragment extends to the end-of-file of the data
fork. Specify a nonzero value for the exact length of the fragment.
An optional name of the fragment. (This information is used primarily to allow you to identify the fragment during debugging.
A flag that specifies the operation to perform on the fragment.The Code Fragment Manager recognizes the constants described in “Load Flag, Symbol Class, and Fragment Locator Constants.”
On return, a pointer to the connection ID that identifies the connection to the fragment. You can pass this ID to other Code Fragment Manager functions.
On return, a pointer to the main address of the fragment. The value returned is specific to the fragment itself. Your application can use this parameter for its own purposes.
On return, the name of the fragment that could
not successfully be loaded. This parameter is meaningful only if
the call to GetDiskFragment
fails.
A result
code. See “Code Fragment Manager Result Codes.” The kFindLib
constant
in the loadFlags
parameter
specifies that the Code Fragment Manager search for the specified
fragment. If the fragment is already prepared and connected to your
application, GetDiskFragment
returns fragNoErr
.
If the specified fragment is not found, GetDiskFragment
returns
the result code fragLibNotFound
.
If the specified fragment is found but could not be connected to
your application, the function returns fragLibConnErr
.
Loading involves finding the specified fragment, reading it into memory (if it is not already in memory), and preparing it for execution. The Code Fragment Manager attempts to resolve all symbols imported by the fragment; to do so may involve loading import libraries.
If the fragment loading fails, the Code Fragment Manager returns
an error code. Note, however, that the error encountered is not
always in the fragment you asked to load. Rather, the error might
have occurred while attempting to load an import library that the fragment
you want to load depends on. For this reason, the Code Fragment
Manager also returns, in the errMessage
parameter,
the name of the fragment that caused the load to fail. Although
fragment names are restricted to 63 characters, the errMessage
parameter is
declared as type Str255
;
doing this allows future versions of the Code Fragment Manager to
return a more informative message in the errMessage
parameter.
On Mac OS X, GetDiskFragment
does
not include the folder containing the root fragment (assuming that
it is different from the application fragment) in its search path
for import libraries. For example, say your application used a special
folder to store plugins. If that folder also contained special libraries
for those plugins, then calling GetDiskFragment
to load
a plugin would not find those libraries.
The workaround is to make sure that any import libraries you require are in the Code Fragment Manager's search path (such as by designating an application library subfolder in the code fragment resource, or placing the libraries in the application's container). For more details of how the Code Fragment Manager searches for import libraries, see Mac OS Runtime Architectures.
CodeFragments.h
Gets information about the exported symbols in a fragment. (Deprecated in Mac OS X v10.5.)
OSErr GetIndSymbol ( CFragConnectionID connID, long symIndex, Str255 symName, Ptr *symAddr, CFragSymbolClass *symClass );
A connection ID.
A symbol index. This index is zero-based.
That is, the value of this parameter should be between zero and
the number of symbols -1 (where the number of symbols is determined
by calling the CountSymbols
function).
On return, the name of the indicated symbol.
On return, a pointer to the address of the indicated symbol.
On return, a pointer to the class of the indicated symbol. See “Load Flag, Symbol Class, and Fragment Locator Constants.”
A result code. See “Code Fragment Manager Result Codes.”
If GetIndSymbol
executes
successfully, it returns the symbol’s name, starting address,
and class in the symName
, symAddr
,
and symClass
parameters,
respectively. A fragment’s exported symbols are retrieved in no
predetermined order.
CodeFragments.h
Prepares a memory-based fragment for subsequent execution. (Deprecated in Mac OS X v10.5.)
OSErr GetMemFragment ( void *memAddr, UInt32 length, ConstStr63Param fragName, CFragLoadOptions options, CFragConnectionID *connID, Ptr *mainAddr, Str255 errMessage );
The address of the fragment.
The size, in bytes, of the fragment.
The name of the fragment. (This information is used primarily to allow you to identify the fragment during debugging.
A flag that specifies the operation to perform on the fragment. The Code Fragment Manager recognizes the constants described in “Load Flag, Symbol Class, and Fragment Locator Constants.”
On return, a pointer to the connection ID
that identifies the connection to the fragment. You can pass this
ID to other Code Fragment Manager functions (for example, CloseConnection
).
On return, a pointer to the main address of the fragment. The value returned is specific to the fragment itself.
On return, the name of the fragment that could
not successfully be loaded. This parameter is meaningful only if
the call to GetMemFragment
fails.
A result code. See “Code Fragment Manager Result Codes.”
The GetMemFragment
is
most useful for handling code that is contained in a resource. You can
read the resource data into memory using normal Resource Manager
functions (for example, Get1Resource
)
and then call GetMemFragment
to
complete the processing required to prepare it for use (for example,
to resolve any imports and execute the fragment’s initialization
function).
You must lock the resource-based fragment into memory (for
example, by calling HLock
) before
calling GetMemFragment
.
You must not unlock the memory until you have closed the connection
to the fragment (by calling CloseConnection
).
Loading involves finding the specified fragment, reading it into memory (if it is not already in memory), and preparing it for execution. The Code Fragment Manager attempts to resolve all symbols imported by the fragment; to do so may involve loading import libraries.
If the fragment loading fails, the Code Fragment Manager returns
an error code. Note, however, that the error encountered is not
always in the fragment you asked to load. Rather, the error might
have occurred while attempting to load an import library that the fragment
you want to load depends on. For this reason, the Code Fragment
Manager also returns, in the errMessage
parameter,
the name of the fragment that caused the load to fail. Although
fragment names are restricted to 63 characters, the errMessage
parameter is
declared as type Str255
;
doing this allows future versions of the Code Fragment Manager to
return a more informative message in the errMessage
parameter.
CodeFragments.h
Locates and possibly also loads an import library into your application’s context. (Deprecated in Mac OS X v10.5.)
OSErr GetSharedLibrary ( ConstStr63Param libName, CFragArchitecture archType, CFragLoadOptions options, CFragConnectionID *connID, Ptr *mainAddr, Str255 errMessage );
The name of an import library.
The instruction set architecture of the import
library. For the PowerPC architecture, use the constant kPowerPCArch
.
For the 680x0 architecture, use the constant kMotorola68KArch
.
A flag that specifies the operation to perform on the import library. The Code Fragment Manager recognizes the constants described in “Load Flag, Symbol Class, and Fragment Locator Constants.”
On return, a pointer to the connection ID that identifies the connection to the import library. You can pass this ID to other Code Fragment Manager functions.
On return, a pointer to the main address of the import library. The value returned is specific to the import library itself and is not used by the Code Fragment Manager.
On return, the name of the fragment that could
not successfully be loaded. This parameter is meaningful only if
the call to GetSharedLibrary
fails.
A result code. See “Code Fragment Manager Result Codes.”
The GetSharedLibrary
function
locates the import library named by the libName
parameter
and possibly also loads that import library into your application’s
context. The actions of GetSharedLibrary
depend
on the action flag you pass in the loadFlags
parameter;
pass kFindLib
to get
the connection ID of an existing connection to the specified fragment, kLoadLib
to
load the specified fragment, or kLoadNewCopy
to
load the fragment with a new copy of the fragment’s data section.
The GetSharedLibrary
function
does not resolve any unresolved imports in your application. In
particular, you cannot use it to resolve any weak imports in your
code fragment.
Loading involves finding the specified fragment, reading it into memory (if it is not already in memory), and preparing it for execution. The Code Fragment Manager attempts to resolve all symbols imported by the fragment; to do so may involve loading import libraries.
If the fragment loading fails, the Code Fragment Manager returns
an error code. Note, however, that the error encountered is not
always in the fragment you asked to load. Rather, the error might
have occurred while attempting to load an import library that the fragment
you want to load depends on. For this reason, the Code Fragment
Manager also returns, in the errMessage
parameter,
the name of the fragment that caused the load to fail. Although
fragment names are restricted to 63 characters, the errMessage
parameter is
declared as type Str255
;
doing this allows future versions of the Code Fragment Manager to
return a more informative message in the errMessage
parameter.
CodeFragments.h
© 2003, 2005 Apple Computer, Inc. All Rights Reserved. (Last updated: 2005-07-07)