Using network setup, Opening and closing the network setup database, Opening the database for reading – Apple Network Setup User Manual
Page 25: Chapter 2, Using network setup 2, Opening and closing the network setup database 2

Opening and Closing the Network Setup Database
25
C H A P T E R 2
Using Network Setup
2
Figure 2-0
Listing 2-0
Table 2-0
This chapter explains how to use the Network Setup programming interface to
read and write network preferences. It assumes that you are familiar with basic
Network Setup concepts. If not, you should read Chapter 1, “About Network
Setup,”for important background material. This chapter concentrates on
practical examples of coding with Network Setup.
Opening and Closing the Network Setup Database
2
This section explains how your application should open the Network Setup
database for reading and writing and then discusses how to close the database
and, in the case where the database has been opened for writing, either
committing or discarding your modifications.
Opening the Database for Reading
2
The
MyOpenDatabaseForReading
routine shown in Listing 2-1 shows how to open
the default (or current) area in the Network Setup database for reading. It starts
by calling
OTCfgOpenDatabase
, which returns a database reference (of type
CfgDatabaseRef
) that identifies your application’s connection to the database. It
then calls
OTCfgGetCurrentArea
, which returns an area identifier (of type
CfgAreaID
) that identifies the default area. Finally, it opens the default area for
reading by calling
OTCfgOpenArea
.
The
MyOpenDatabaseForReading
routine returns both the database reference
(
dbRef
) and the default area identifier (
readArea
). You must know these values
in order to read preferences and eventually close the database.