#include <mplib1/cfg_file.h>
There are a number of miscelleaneous functions which are available.
These can be used
int get_list_flags( const char *list_name );
int set_list_flags( const char *list_name, int new_val );
These two functions allow for the setting and reviewing of the flags
stored against the supplied list. The only value currently of use is
CONFIG_NO_EVAL which forces the list not to cache
the evaluated strings.
int watch_cfg_file( const char *config_name );
int check_cfg_file( int force );
The watch_cfg_file() function takes a string parameter
which specifies a filename which should be monitored. The current
modification timestamp (st_mtime) of the file is noted for later
comparison.
The check_cfg_file() function checks the current modification timestamp of the file specified to watch_cfg_file(). If the file has changed or the force parameter is set then the file is read using the read_config_file macro (which reads into the default list namespace).
int flush_list_evals( const char *list_name );
void flush_item_eval( const char *list_name, const char *item )
When evaluating configuration variables the routines will normally
maintain a copy of the result to speed up any further evaluations of
the variable. These copies are flushed whenever any of the
read functions are called. In case
there is a requirement to flush on demand the above two functions
are provided.
The flush_list_evals() function takes a list name and flushes all evaluation strings for that list.
The flush_item_eval() function takes a list name and an item name and flushes the evaluation for that item.
int dump_private_contents( const char *list_name, FILE *fh );
This function takes the name of a list and a file handle and produces
a listing of the contents similar to the following
List Name: my_config Time: 1996/12/31 13:45:56:78 Item Key: LOG_FILE Value: $LOG_DIR/mylog.log Eval: /var/spool/log/mylog.log Item Key: CURRENCY_DEBUG Value: FALSEwhere evaluations are printed if they exist.
The second function available is
typedef void (*config_disp_t)( const char *, const char *,
const char *, void * );
int report_private_contents( const char *list_name,
config_disp_t disp_func,
void *param );
This function takes the name of a list, a pointer to a reporting function,
and a void * parameter to be passed to that function. The
reporting function is passed four parameters. These are, in order, the item
name, the item value, the evaluation, and the void * parameter
passed to the report_private_contents() function.
Thus, the item details as illustrated above can be produced as follows.
void item_show( const char *item, const char *value,
const char *eval, void *param )
{
FILE *fh = param;
fprintf( fh, "Item Key: %s\n", item );
fprintf( fh, " Value: %s\n", value );
if (eval)
fprintf( fh, " Eval: %s\n", eavl );
return;
}