C H A P T E R 2

Using Network Setup

area, but you can read from both the original area and the writable area to access, respectively, the currently active network settings and your proposed changes to the network settings.

Listing 2-2Opening the database for writing

static OSStatus MyOpenDatabaseForWriting(CfgDatabaseRef *dbRef, CfgAreaID *readArea, CfgAreaID *writeArea)

{

OSStatus err;

assert(dbRef

!=

nil);

assert(writeArea !=

nil);

err = OTCfgOpenDatabase(dbRef); if (err == noErr) {

err = OTCfgGetCurrentArea(*dbRef, readArea); if (err == noErr) {

err = OTCfgBeginAreaModifications(*dbRef, *readArea,

writeArea);

}

if (err != noErr) {

(void) OTCfgCloseDatabase(dbRef);

}

}

if (err != noErr) {

*dbRef

=

nil;

*readArea

=

kInvalidCfgAreaID;

*writeArea =

kInvalidCfgAreaID;

}

return err;

}

Opening and Closing the Network Setup Database

27

Page 27
Image 27
Apple manual Using Network Setup