Listing 2-4 – Apple Network Setup User Manual
Page 29

C H A P T E R 2
Using Network Setup
Opening and Closing the Network Setup Database
29
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
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-4
Closing 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;
}