libCfg Documentation


written by David Anderson and Joey Mukherjee -
joey@swri.edu

Table of contents

  1. Overview
  2. Public Routines
    1. CfgInit
    2. CfgTerm
    3. CfgPath
    4. CfgItem

Overview

THIS DOCUMENTATION AND INTERFACE WILL CHANGE SHORTLY
...maybe not much, but at least a little bit...
Reasons for such are the hiding of certain data members which are currently exposed and may not need to be; to offer a cleaner, more consistant interface; and to reduce the number of global variables needed.

libCfg offers the interface into the DB.cfg and the PROJECTS.cfg file. The programmer need not know/care what file he is accessing since the interface to access either file is the same and the contents of both are rolled into one complex opaque data structure.

To use these routines, include "libCfg.h" into the source.

CfgInit

The prototype is as follows:

void CfgInit ();

CfgInit will read the contents of both DB.cfg and PROJECTS.cfg into memory. It returns nothing and accepts no arguments. In case of errors, error messages are printed to the console. The configuration is defined by the file $SDDAS_HOME/config/PROJECTS.cfg and $SDDAS_HOME/DB.cfg ($SDDAS_HOME is an environment variable). If the environment variable SDDAS_CONFIG exists then both configuration files PROJECTS.cfg and DB.cfg will be read from the path defined in this variable. If one of the files does not exist in SDDAS_CONFIG, it will use the one in $SDDAS_HOME/config.

CfgInitSCF

The prototype is as follows:

void CfgInitSCF ();
Same as above, but this routine will also load SCF information into memory along with the config information.

CfgItem

The prototype is as follows:

SDDAS_CHAR *CfgItem (StrHier, SDDAS_CHAR *, SDDAS_INT);

CfgItem takes a StrHier for the source node, a token to look for (i.e. "NetID"), and and element into the array of return values. It will return a pointer to the string value associated with the 'item'. There may be more than one string value, therefore the element number acts as an index into the array of string values.
The string returned is static - do not free it.

CfgPath

The prototype is as follows:

SDDAS_CHAR *CfgPath (StrHier, SDDAS_CHAR *, SDDAS_INT);

This routine is similar to CfgItem; however, it is used only for path names just as RealTimePath, PostTimePath, or DatabasePath. It takes as parameters a source in form of a StrHier, the item to look for (i.e. "RealTimePath"), and which level (i.e. position in the hierarchy) to retrieve. Certain path information is based on the parent name of the source. The number of path names added is dependent upon the level. For example, if the key represents UARS, UARS-1, PEM, MEPS, and MPSA and the item value is "/data" then a level of 0 return "/data/UARS". Similary, a level of 4 returns "/data/UARS/UARS-1/PEM/MEPS/MPSA".
The string returned is static - do not free it.

CfgTerm

The prototype is as follows:

void CfgTerm ();

This routine accepts no arguments and returns nothing. It frees all memory associated with the config routines.