Apple manual Using Network Setup, Listing 2-4 Closing the database after writing, err = noErr

Models: Network Setup

1 184
Download 184 pages 5.56 Kb
Page 29
Image 29
Listing 2-4Closing the database after writing

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 manual Using Network Setup, Listing 2-4 Closing the database after writing, err = noErr