Listing 2-6 – Apple Network Setup User Manual

Page 33

Advertising
background image

C H A P T E R 2

Using Network Setup

Working with Entities

33

}

}

return err;

}

The next routine, shown in Listing 2-6, opens the database for reading, gets the
entity references for all of the TCP/IP network connection entities in the default
area (using the

MyGetEntitiesList

routine in Listing 2-5), and prints their

user-visible names. This routine calls a routine,

MyGetEntityUserVisibleName

,

which hasn’t been documented yet. It is shown in Listing 2-9 in the section
“Reading and Writing Preferences” (page 34).

Listing 2-6

Printing the user-visible name for an entity

static void PrintAllTCPEntityNames(void)

{

OSStatus err;

CfgDatabaseRef dbRef;

CfgAreaID readArea;

CfgEntityRef **entityRefs;

ItemCount entityCount;

ItemCount entityIndex;

Str255 userVisibleName;

entityRefs = (CfgEntityRef **) NewHandle(0);

err = MemError();

if (err == noErr) {

err = MyOpenDatabaseForReading(&dbRef, &readArea);

if (err == noErr) {

err = MyGetEntitiesList(dbRef, readArea,

kOTCfgClassNetworkConnection, kOTCfgTypeTCPv4,

entityRefs, nil);

}

if (err == noErr) {

HLock( (Handle) entityRefs );

assert(MemError() ==

noErr);

printf("List of TCP/IP Network Connection Entities\n");

Advertising