Apple Network Setup Network Card User Manual


 
CHAPTER 2
Using Network Setup
44 Working with Sets
The MyFindActiveSet routine in Listing 2-13 implements the first two steps. It
starts by getting a list of all of the set entities by calling the MyGetEntitiesList
routine (Listing 2-5). Then MyFindActiveSet iterates through all of the set
entities, reading the kOTCfgSetsStructPref preference of each set entity. That
preference maps to the CfgSetsStruct structure, which contains an fFlags
member. One bit of the fFlags member, kOTCfgSetsFlagActiveMask, indicates
whether this set entity is the active set entity. If it is, the routine breaks out of
the loop and returns the set’s entity reference to the caller.
Listing 2-13 Finding the active set entity
static OSStatus MyFindActiveSet(CfgDatabaseRef dbRef,
CfgAreaID area,
CfgEntityRef *activeSet)
{
OSStatus err;
CfgEntityRef **entityRefs;
ItemCount entityCount;
ItemCount entityIndex;
Boolean found;
CfgSetsStruct thisStruct;
assert(dbRef != nil);
assert(area != kInvalidCfgAreaID);
entityRefs = (CfgEntityRef **) NewHandle(0);
err = MemError();
if (err == noErr) {
err = MyGetEntitiesList(dbRef, area,
kOTCfgClassSetOfSettings, kOTCfgTypeSetOfSettings,
entityRefs, nil);
}
if (err == noErr) {
HLock( (Handle) entityRefs ); assert(MemError() ==
noErr);
entityCount = GetHandleSize( (Handle) entityRefs ) / sizeof(CfgEntityRef);
found = false;
for (entityIndex = 0; entityIndex < entityCount; entityIndex++) {
err = MyReadFixedSizePref(dbRef, &(*entityRefs)[entityIndex],