Apple Network Setup manual kCfgClassAnyEntity and kCfgTypeAnyEntity, respectively

Models: Network Setup

1 184
Download 184 pages 5.56 Kb
Page 31
Image 31
kCfgClassAnyEntity and kCfgTypeAnyEntity, respectively.

C H A P T E R 2

Using Network Setup

Getting all entities. Set entityClass and entityType to the wildcard values

kCfgClassAnyEntity and kCfgTypeAnyEntity, respectively.

The entityRefs and entityInfos parameters are handles containing an array of elements of type CfgEntityRef and CfgEntityInfo, respectively. You must create these handles before calling MyGetEntitiesList. You can set entityInfos to NULL if you’re not interested in the information returned in that handle. The MyGetEntitiesList routine resizes the handles appropriately to hold information about each of the entities that it finds.

The MyGetEntitiesList routine calls two key Network Setup functions: OTCfgGetEntitiesCount to count the number of entities of the specified class and type and OTCfgGetEntitiesList to get the actual entity information. The rest of the MyGetEntitiesList routine is just memory management.

Listing 2-5Finding all entities of a particular class and type

static OSStatus MyGetEntitiesList(CfgDatabaseRef dbRef, CfgAreaID area,

OSType entityClass,

OSType entityType,

CfgEntityRef **entityRefs,

CfgEntityInfo **entityInfos)

{

OSStatus err;

ItemCount entityCount;

CfgEntityRef *paramRefs;

CfgEntityInfo *paramInfos;

SInt8 sRefs;

SInt8 sInfos;

assert(dbRef != nil);

assert(area != kInvalidCfgAreaID); assert((entityRefs != nil) (entityInfos != nil)); assert((entityRefs == nil) (*entityRefs != nil)); assert((entityInfos == nil) (*entityInfos != nil));

err = OTCfgGetEntitiesCount(dbRef, area, entityClass, entityType, &entityCount); if ((err == noErr) && (entityRefs != nil)) {

Working with Entities

31

Page 31
Image 31
Apple Network Setup manual kCfgClassAnyEntity and kCfgTypeAnyEntity, respectively, CfgEntityInfo **entityInfos