C H A P T E R 2

Using Network Setup

If commit is false, the routine calls OTCfgAbortAreaModifications to discard the changes made in the writable temporary area. The read area is not changed, and the network protocol stacks continue unaffected.

In contrast to MyCloseDatabaseAfterReading shown in Listing 2-3,MyCloseDatabaseAfterWriting does not always throw away error results. If OTCfgCommitAreaModifications returns an error, the MyCloseDatabaseAfterWriting routine aborts. Your application may respond to this by calling the same routine again, this time with commit set to false.

Listing 2-4Closing the database after writing

static OSStatus MyCloseDatabaseAfterWriting(CfgDatabaseRef dbRef, CfgAreaID readArea, CfgAreaID writeArea, Boolean commit)

{

OSStatus err;

OSStatus junk;

assert(dbRef

!= nil);

assert(readArea

!= kInvalidCfgAreaID);

assert(writeArea != kInvalidCfgAreaID);

if ( commit ) {

 

 

err = OTCfgCommitAreaModifications(dbRef, readArea, writeArea);

} else {

 

 

junk = OTCfgAbortAreaModifications(dbRef, readArea);

 

assert(junk == noErr);

 

err = noErr;

 

}

 

 

if (err

== noErr) {

 

err

= OTCfgCloseDatabase(&dbRef);

}

 

 

return err;

}

Opening and Closing the Network Setup Database

29

Page 29
Image 29
Apple Network Setup manual Listing 2-4Closing the database after writing