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: Mac OS Runtime Architectures /
Chapter 3 - Programming for the CFM-Based Runtime Architecture / Calling the Code Fragment Manager


Getting Information About Exported Symbols

In cases in which you prepare a fragment programmatically (that is, by calling Code Fragment Manager routines), you can get information about the symbols exported by that fragment by calling the FindSymbol, CountSymbols, and GetIndSymbol functions.

The CountSymbols function returns the total number of symbols exported by a fragment. CountSymbols takes as one of its parameters a connection ID; accordingly, you must already have established a connection to a fragment before you can determine how many symbols it exports.

Given an index ranging from 0 to one less than the total number of exported symbols in a fragment, the GetIndSymbol function returns the name, address, and class of a symbol in that fragment. You can use CountSymbols in combination with GetIndSymbol to get information about all the exported symbols in a fragment. For example, the code in Listing 3-4 prints the names of all the exported symbols in a particular fragment.

Listing 3-4 Finding symbol names

void MyGetSymbolNames (ConnectionID myConnID);
{
   long           myIndex;
   long           myCount;       /*number of exported */
                                 /*symbols in fragment*/
   OSErr          myErr;
   Str255         myName;        /*symbol name*/
   Ptr            myAddr;        /*symbol address*/
   SymClass       myClass;       /*symbol class*/

   myErr = CountSymbols(myConnID, &myCount);
   if (!myErr)
      for (myIndex = 0; myIndex < myCount; myIndex++)
         {
            myErr = GetIndSymbol(myConnID, myIndex, myName, 
                                    &myAddr, &myClass);
            if (!myErr)
               printf("%P", myName);
         }
}
If you already know the name of a particular symbol whose address and class you want to determine, you can use the FindSymbol function. See Inside Macintosh: PowerPC System Software for details.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 MARCH 1997