C H A P T E R 2

Using Network Setup

entityCount = GetHandleSize( (Handle) entityRefs ) / sizeof(CfgEntityRef); for (entityIndex = 0; entityIndex < entityCount; entityIndex++) {

err = MyGetEntityUserVisibleName(dbRef, &(*entityRefs)[entityIndex], userVisibleName);

if (err == noErr) {

printf("%ld) "%#s"\n", entityIndex, userVisibleName);

}

 

}

 

}

 

MyCloseDatabaseAfterReading(dbRef, readArea);

 

}

 

if (entityRefs != nil) {

 

DisposeHandle( (Handle) entityRefs );

assert(MemError() ==

noErr);

 

}

 

if (err != noErr) {

 

printf("Failed with error %ld.\n", err);

 

}

 

}

 

Finding an Active Entity

Currently, only one entity can be active for any given network connection type. This is not a restriction of Network Setup itself, but a limitation in the network protocol stacks. When you look for an active entity for a particular network protocol, you should be aware that, in the future, there may be more than one.

Because of the complexity of this algorithm and because its implementation relies on concepts that haven’t been discussed yet, the steps and sample code for finding an active entity are shown in “Working with Sets” (page 42), later in this chapter.

Reading and Writing Preferences

Once you have an entity reference, reading and writing preferences in the entity is a straightforward exercise. The basic steps are to open the entity, read and

34Reading and Writing Preferences

Page 34
Image 34
Apple Network Setup manual Reading and Writing Preferences, Finding an Active Entity