Apple Network Setup User Manual

Page 41

Advertising
background image

C H A P T E R 2

Using Network Setup

Reading and Writing Preferences

41

assert(dbRef != nil);

assert(entity != nil);

prefsTOC = nil;

err = OTCfgOpenPrefs(dbRef, entity, false, &accessID);

if (err == noErr) {

err = OTCfgGetPrefsTOCCount(accessID, &prefsTOCCount);

if (err == noErr) {

prefsTOC = (CfgPrefsHeader *) NewPtr(prefsTOCCount *

sizeof(CfgPrefsHeader));

err = MemError();

}

if (err == noErr) {

err = OTCfgGetPrefsTOC(accessID, &prefsTOCCount, prefsTOC);

}

if (err == noErr) {

for (prefsTOCIndex = 0; prefsTOCIndex < prefsTOCCount; prefsTOCIndex++) {

prefType = prefsTOC[prefsTOCIndex].fType;

prefSize = prefsTOC[prefsTOCIndex].fSize;

printf("type = '%4.4s', size = %ld\n", &prefType, prefSize);

}

}

err2 = OTCfgClosePrefs(accessID);

if (err == noErr) {

err = err2;

}

}

if (prefsTOC != nil) {

DisposePtr( (Ptr) prefsTOC );

assert(MemError() ==

noErr);

}

if (err != noErr) {

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

}

}

Advertising