Apple Network Setup Network Card User Manual


 
CHAPTER 2
Using Network Setup
Working with Sets 47
*activeEntity = (**entitiesInSet).fElements[entityIndex].fEntityRef;
OTCfgChangeEntityArea(activeEntity, area);
}
if (entitiesInSet != nil) {
DisposeHandle( (Handle) entitiesInSet ); assert(MemError() ==
noErr);
}
return err;
}
The code in Listing 2-15 pulls together the process of finding an active set entity
by finding the active TCP/IP set entity. It opens the database, calls
MyFindFirstActiveEntity (Listing 2-14) with kOTCfgClassNetworkConnection and
kOTCfgTypeTCPv4 as parameters, calls MyGetEntityUserVisibleName (Listing 2-9)
to get and print the entity’s user visible name, and calls
MyCloseDatabaseAfterReading (Listing 2-3) to close the database.
Listing 2-15 Finding the active TCP/IP entity
static void PrintActiveTCPEntity(void)
{
OSStatus err;
CfgDatabaseRef dbRef;
CfgAreaID readArea;
CfgEntityRef activeTCPEntity;
Str255 userVisibleName;
err = MyOpenDatabaseForReading(&dbRef, &readArea);
if (err == noErr) {
err = MyFindFirstActiveEntity(dbRef, readArea,
kOTCfgClassNetworkConnection,
kOTCfgTypeTCPv4,
&activeTCPEntity);
if (err == noErr) {
err = MyGetEntityUserVisibleName(dbRef, &activeTCPEntity, userVisibleName);
}
if (err == noErr) {