Infrasctucture CfgAcc Function Reference
CfgAcc
#include "cfgAcc.h"
The config (configuration) access layer allows a running process to get configuration information from external sources which may be changed between accesses.   This allows the config of a running process to be changed dynamically from an external source (like a web page).   The servers cfgCache and crytpoCache cache the configuration and passwords to hard disk and supply information on demand to other processes.  

The cfgCache may be accessed by the function caGetCfg( procName ) and the cryptoCache is accessed using caGetPwds( procName ).

In order to create configuration variables in a 'C' program, place the keyword ~VARS in a commented out line like "//~VARS BROKER Var1 Var2 Var3".   Next you must include a file called "yourCfileVars.c" where "yourCfile" is the name of the current 'C' module with the "Vars" inserted just before the ".c".   The makefile should be modified to run "varCfg.pl" on each ".c" file before compilation.   Then your 'C' code may access any variable name defined on a ~VARS line just as if you had defined it as "char *Var1".   If you are writing a server, call cagGetCfg( ProgNam ) at the beginning of each service request.   This will fetch and load all the defined variables from the cfgCache daemon.   Any variable not defined in cfgCache but defined on a ~VARS line will be left as it was from the compile.   To initialize a ~VARS variable before any calls to caGetCfg(), just load it with the output of strdup() from you init routine.   Since all ~VARS variables are string pointers and the auto load frees any currently allocated string before loading another, this will prevent you from coredumping.   You must define "BROKER" in ~VARS and the config file for this to find the Orb.

To set a config variable using messages you must send a Type 24 message with Code 3, and containing two fields: "cfgKey" (the device name and variable name), and "cfgData" contains the data to be stored for this variable. Device names and variable names are limited to 31 characters.

Two tools have been created to test/access the cfgAcc daemons: ccpwd and ccvar.
ccpwd cfgNam - interactive tool for settting/displaying passwords.
ccvar cfgNam Device:var1=val1,var2=val2 writes or reads config vars.

caGetCfg _caGetCfg caGetPwds

int caGetCfg( char* procName )
Access the cfgCache daemon and return all variables for the named process.
The variables defined using the ~VARS tool will be retrieved and loaded by this comamnd.
The calling process must have an Orb with a cfgCache daemon and "Broker" must be defined.
Returns OK if all went well, else ERR.
You must define "BROKER" in ~VARS and the config file for this to find the Orb.


int _caGetCfg( char* devName, char** vars, int varCnt, vNdx_t* vNdx )
This is the base call for caGetVars.
Fetch the variables for the named process ("devNam") into the variable array "vars".
The argument "varCnt" is the size of the "vars" array and vNdx is a chain of variable index structs.


int caGetPwds( char* procName )
Access the cfgCache daemon and return all passwords in variables for the named process.
The variables are defined using the ~VARS tool will be retrieved and loaded by this comamnd.
The calling process must have an Orb with a cryptoCache daemon and "Broker" must be defined.
Returns OK if all went well, else ERR.