URL: http://www.firstbasesoftware.com/man/man3/opendb.htm
Last modified: 12 September 1995
Copyright © by FirstBase Software.
[
Index of Contents] [
FirstBase RDBMS Overview]
fb_opendb(db, mode, ixflag, ixoption)
fb_database *db;
int mode;
int ixflag;
int ixoption;
fb_closedb(db)
fb_database *db;
Fb_opendb and fb_closedb provide mechanisms to open and close an entire database -- including simple and autoindex structures. In other words, the entire database structure is initialized, with all needed file descriptors and structure pointers. Fb_opendb will also provide file name extensions if needed.
The database structure needs to be allocated and the file names need to be in the database structure prior to the fb_opendb call. Typically, these preliminary tasks are done using dballoc(3) and dbargs(3).
The mode reflects desired permissions to the database, with three possibilities -- READ, WRITE, and READWRITE. If a database does not exist, and the mode is WRITE or READWRITE, fb_opendb creates a database and database map, and initializes both.
The other two parameters are for database indexes. Ixflag can take on three values. FB_NOINDEX means that no index will be opened at all. FB_WITHINDEX indicates that only the database index is to be opened. FB_ALLINDEX means that all indexes, including the autoindexes, are to be opened.
Ixoption controls what fb_opendb will do if index errors occur during the database initialization. It also has three possible settings. FB_OPTIONAL_INDEX means that no error messages are produced. FB_MAYBE_OPTIONAL_INDEX will make error messages appear, but control returns to the caller. FB_MUST_INDEX will make fb_opendb die after displaying the error message.
Fb_closedb closes all open file descriptors (databases, indexes, and the database map), and frees up (most) all allocated space.
NOTE: There are allocated areas that fb_closedb does not free up due to the underlying FirstBase structures for handling more than one open database. To free and reset these areas, use free_globals(3) after all the databases have been closed using fb_closedb.
As another example, the following code fragment will set up the database variables and open the database named Phone using an index named Clients:
fb_database *db; ... db = fb_dballoc(); fb_dbargs("Phone", NIL, db); fb_opendb(db, READWRITE, FB_NOINDEX, 0);
fb_database *db; ... db = fb_dballoc(); fb_dbargs("Phone", "Clients", db); fb_opendb(db, READWRITE, FB_WITH_INDEX, FB_MUST_INDEX);