Go to the first, previous, next, last section, table of contents.


setdb

void setdb(char *string)

This function may be used to set or change the database path (see section The Database Path) within a running program. The argument points to a null-terminated string that specifies the desired database path (but see the next paragraph for an exception). The string contains directory names separated by colons (`:') under UNIX or by semicolons (`;') under MS-DOS. An empty component, indicated by an initial or terminal separator, or by two consecutive separators, will be understood to specify the current directory. If the string is empty or NULL, the database path is limited to the current directory.

If string begins with `@', the remaining characters of string are taken as the name of a file from which the DB path is to be read. This file may contain either the DB path, as described in the previous paragraph, or another indirect DB path specification. Indirect DB path specifications may be nested no more than ten levels deep (an arbitrary limit imposed to avoid infinite recursion). Evaluation of indirect DB paths is deferred until getdb is invoked, either explicitly or by the DB library while attempting to open an input file (e.g., using annopen or isigopen). (The features described in this paragraph were first introduced in DB library version 8.0.)

The setdb function does not copy the string itself, which must therefore be kept valid by the caller, nor does it modify the environment variable DB, which will be inherited by any processes spawned from the caller. For portability, as well as efficiency, it is better to use setdb than to manipulate DB directly (via putenv, for example); furthermore, doing the latter is ineffective (within the current process) once the first DB file has been opened. See section getdb, for an example of the use of setdb.


Go to the first, previous, next, last section, table of contents.



George B. Moody (george@hstbme.mit.edu)