Listing 2-2 – Apple Network Setup User Manual

Page 27

Advertising
background image

C H A P T E R 2

Using Network Setup

Opening and Closing the Network Setup Database

27

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-2

Opening 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;

}

Advertising