ConfigFile.h File Reference

Author:
Reinhard Prix Header file defining the API for ConfigFile.c.
More...

#include <lal/LALDatatypes.h>
#include <lal/StringInput.h>

Include dependency graph for ConfigFile.h:

Go to the source code of this file.

Data Structures

struct  LALConfigVar
 This structure defines a config-variable to be read in using the general-purpose reading function LALReadConfigVariable(). More...
struct  LALParsedDataFile
 This structure is returned by LALParseDataFile() and holds the contents of an ASCII data-file in a pre-parsed form, namely stripped from all comments ('#', ';'+), spurious whitespaces, and separated into lines (taking into account line-continuation by '\' at the end of lines). More...

Defines

Error codes
#define CONFIGFILEH_ENULL   1
#define CONFIGFILEH_EFILE   2
#define CONFIGFILEH_EVAR   3
#define CONFIGFILEH_EFMT   4
#define CONFIGFILEH_ETOKENS   5
#define CONFIGFILEH_ENONULL   6
#define CONFIGFILEH_EUNKNOWN   8
#define CONFIGFILEH_EMEM   9
#define CONFIGFILEH_EBOOL   10
#define CONFIGFILEH_ESTRING   11
#define CONFIGFILEH_MSGENULL   "Arguments contained an unexpected null pointer."
#define CONFIGFILEH_MSGEFILE   "File error."
#define CONFIGFILEH_MSGEVAR   "Config variable not found."
#define CONFIGFILEH_MSGEFMT   "Config variable not readable using given format-string."
#define CONFIGFILEH_MSGETOKENS   "The input ConfigData seems corrupted."
#define CONFIGFILEH_MSGENONULL   "Output pointer is not NULL"
#define CONFIGFILEH_MSGEUNKNOWN   "Unknown config-file entry found"
#define CONFIGFILEH_MSGEMEM   "Out of memory"
#define CONFIGFILEH_MSGEBOOL   "Illegal BOOLEAN entry"
#define CONFIGFILEH_MSGESTRING   "Malformed quoted string"

Enumerations

enum  ConfigStrictness { CONFIGFILE_IGNORE = 0, CONFIGFILE_WARN, CONFIGFILE_ERROR, CONFIGFILE_LAST }
 Levels of strictness for config-file parsing. More...

Functions

 NRCSID (CONFIGFILEH,"$Id: ConfigFile.h,v 1.11 2005/07/12 13:12:19 reinhard Exp $")
void LALParseDataFile (LALStatus *, LALParsedDataFile **cfgdata, const CHAR *fname)
 Parse an ASCII data-file into a pre-cleaned array of lines.
void LALDestroyParsedDataFile (LALStatus *, LALParsedDataFile **cfgdata)
 Free memory associated with a LALParsedDataFile structure.
void LALReadConfigBOOLVariable (LALStatus *, BOOLEAN *varp, const LALParsedDataFile *cfgdata, const CHAR *varName, BOOLEAN *wasRead)
 Type-specialization of generic reading-function LALReadConfigVariable() to BOOLEAN variables.
void LALReadConfigINT4Variable (LALStatus *, INT4 *varp, const LALParsedDataFile *cfgdata, const CHAR *varName, BOOLEAN *wasRead)
 Type-specialization of generic reading-function LALReadConfigVariable() to INT4 variables.
void LALReadConfigREAL8Variable (LALStatus *, REAL8 *varp, const LALParsedDataFile *cfgdata, const CHAR *varName, BOOLEAN *wasRead)
 Type-specialization of generic reading-function LALReadConfigVariable() to REAL8 variables.
void LALReadConfigSTRINGVariable (LALStatus *, CHAR **varp, const LALParsedDataFile *cfgdata, const CHAR *varName, BOOLEAN *wasRead)
 Type-specialization of generic reading-function LALReadConfigVariable() to STRING variables.
void LALReadConfigSTRINGNVariable (LALStatus *, CHARVector *varp, const LALParsedDataFile *cfgdata, const CHAR *varName, BOOLEAN *wasRead)
 Type-specialization of generic reading-function LALReadConfigVariable() to reading of fixed-length strings.
void LALReadConfigVariable (LALStatus *, void *varp, const LALParsedDataFile *cfgdata, const LALConfigVar *param, BOOLEAN *wasRead)
 Parser for config-file: can read config-variables of the form VARIABLE [=:] VALUE.
void LALCheckConfigReadComplete (LALStatus *, const LALParsedDataFile *cfgdata, ConfigStrictness strict)
 Check if all lines of config-file have been successfully read in and issue a warning or error (depending on strictness) if not.
void LALLowerCaseString (LALStatus *, CHAR *string)
 Helper function: turn a string into lowercase without using locale-functions.


Detailed Description

Author:
Reinhard Prix Header file defining the API for ConfigFile.c.

Date:
Date
2005/07/12 13:12:19

Definition in file ConfigFile.h.


Define Documentation

#define CONFIGFILEH_ENULL   1

Definition at line 64 of file ConfigFile.h.

#define CONFIGFILEH_EFILE   2

Definition at line 65 of file ConfigFile.h.

#define CONFIGFILEH_EVAR   3

Definition at line 66 of file ConfigFile.h.

#define CONFIGFILEH_EFMT   4

Definition at line 67 of file ConfigFile.h.

#define CONFIGFILEH_ETOKENS   5

Definition at line 68 of file ConfigFile.h.

#define CONFIGFILEH_ENONULL   6

Definition at line 69 of file ConfigFile.h.

#define CONFIGFILEH_EUNKNOWN   8

Definition at line 70 of file ConfigFile.h.

#define CONFIGFILEH_EMEM   9

Definition at line 71 of file ConfigFile.h.

#define CONFIGFILEH_EBOOL   10

Definition at line 72 of file ConfigFile.h.

#define CONFIGFILEH_ESTRING   11

Definition at line 73 of file ConfigFile.h.

#define CONFIGFILEH_MSGENULL   "Arguments contained an unexpected null pointer."

Definition at line 75 of file ConfigFile.h.

#define CONFIGFILEH_MSGEFILE   "File error."

Definition at line 76 of file ConfigFile.h.

#define CONFIGFILEH_MSGEVAR   "Config variable not found."

Definition at line 77 of file ConfigFile.h.

#define CONFIGFILEH_MSGEFMT   "Config variable not readable using given format-string."

Definition at line 78 of file ConfigFile.h.

#define CONFIGFILEH_MSGETOKENS   "The input ConfigData seems corrupted."

Definition at line 79 of file ConfigFile.h.

#define CONFIGFILEH_MSGENONULL   "Output pointer is not NULL"

Definition at line 80 of file ConfigFile.h.

#define CONFIGFILEH_MSGEUNKNOWN   "Unknown config-file entry found"

Definition at line 81 of file ConfigFile.h.

#define CONFIGFILEH_MSGEMEM   "Out of memory"

Definition at line 82 of file ConfigFile.h.

#define CONFIGFILEH_MSGEBOOL   "Illegal BOOLEAN entry"

Definition at line 83 of file ConfigFile.h.

#define CONFIGFILEH_MSGESTRING   "Malformed quoted string"

Definition at line 84 of file ConfigFile.h.


Enumeration Type Documentation

enum ConfigStrictness

Levels of strictness for config-file parsing.

Enumerator:
CONFIGFILE_IGNORE  ignore missing config-variable or unparsed config-entries
CONFIGFILE_WARN  issue a warning but don't report an error.

CONFIGFILE_ERROR  issue an error-message and report a LAL-error
CONFIGFILE_LAST 

Definition at line 89 of file ConfigFile.h.


Function Documentation

NRCSID ( CONFIGFILEH  ,
"$Id: ConfigFile.  h,
v 1.11 2005/07/12 13:12:19 reinhard Exp $"   
)

void LALParseDataFile ( LALStatus status,
LALParsedDataFile **  cfgdata,
const CHAR fname 
)

Parse an ASCII data-file into a pre-cleaned array of lines.

The cleaning gets rid of comments ('#', ';'), empty lines, and performs line-continuation if '\' is found at EOL

Parameters:
cfgdata  [out] pre-parsed data-file lines
fname  [in] name of config-file to be read

Definition at line 276 of file ConfigFile.c.

void LALDestroyParsedDataFile ( LALStatus ,
LALParsedDataFile **  cfgdata 
)

Free memory associated with a LALParsedDataFile structure.

Parameters:
cfgdata  [in/out] config-file data

Definition at line 357 of file ConfigFile.c.

void LALReadConfigBOOLVariable ( LALStatus ,
BOOLEAN varp,
const LALParsedDataFile cfgdata,
const CHAR varName,
BOOLEAN wasRead 
)

Type-specialization of generic reading-function LALReadConfigVariable() to BOOLEAN variables.

Parameters:
varp  [out] variable to store result
cfgdata  [in] pre-parsed config-data
varName  [in] variable-name to read
wasRead  [out] did we succeed in reading?

Definition at line 502 of file ConfigFile.c.

void LALReadConfigINT4Variable ( LALStatus ,
INT4 varp,
const LALParsedDataFile cfgdata,
const CHAR varName,
BOOLEAN wasRead 
)

Type-specialization of generic reading-function LALReadConfigVariable() to INT4 variables.

Definition at line 554 of file ConfigFile.c.

void LALReadConfigREAL8Variable ( LALStatus ,
REAL8 varp,
const LALParsedDataFile cfgdata,
const CHAR varName,
BOOLEAN wasRead 
)

Type-specialization of generic reading-function LALReadConfigVariable() to REAL8 variables.

Definition at line 577 of file ConfigFile.c.

void LALReadConfigSTRINGVariable ( LALStatus status,
CHAR **  varp,
const LALParsedDataFile cfgdata,
const CHAR varName,
BOOLEAN wasRead 
)

Type-specialization of generic reading-function LALReadConfigVariable() to STRING variables.

Note:
this means the rest of the line, NOT "%s"! (but excluding comments of course),
Note2: if string is quoted by ", everything within quotes is read,
and the quotes are removed here
Parameters:
varp  [out] string, allocated here!
cfgdata  [in] pre-parsed config-data
varName  [in] variable-name to be read
wasRead  [out] did we succeed in reading?

Definition at line 606 of file ConfigFile.c.

void LALReadConfigSTRINGNVariable ( LALStatus status,
CHARVector varp,
const LALParsedDataFile cfgdata,
const CHAR varName,
BOOLEAN wasRead 
)

Type-specialization of generic reading-function LALReadConfigVariable() to reading of fixed-length strings.

Another variant of string-reading:similar to ReadConfigSTRINGVariable(), but here a fixed-size CHAR-array is used as input, no memory is allocated by the function.

Note:
you have to provide the length of your string-array as input in varp->length (this is basically a wrapper for ReadConfigSTRINGVariable())
Note 2: the behaviour is similar to strncpy, i.e. we silently clip the
string to the right length, BUT we also 0-terminate it properly. No error or warning is generated when clipping occurs!
Note 3: at return, the value varp->length is set to the length of the
string copied
Parameters:
varp  [out] must be allocated!
cfgdata  [in] pre-parsed config-data
varName  [in] variable-name
wasRead  [out] did we succeed in reading?

Definition at line 688 of file ConfigFile.c.

void LALReadConfigVariable ( LALStatus status,
void *  varp,
const LALParsedDataFile cfgdata,
const LALConfigVar param,
BOOLEAN wasRead 
)

Parser for config-file: can read config-variables of the form VARIABLE [=:] VALUE.

Input is a TokenList containing the 'logical' lines of the cleaned config-file

Note:
a special format-string is FMT_STRING, which means read the whole remaining line which is different from "%s"! (reads only one word) In this case, this also does the memory-allocation!
Parameters:
varp  [out] result gets written here!
cfgdata  [in] pre-parsed config-data
param  [in] var-name, fmt-string, strictness
wasRead  [out] did we succeed in reading?

Definition at line 395 of file ConfigFile.c.

void LALCheckConfigReadComplete ( LALStatus ,
const LALParsedDataFile cfgdata,
ConfigStrictness  strict 
)

Check if all lines of config-file have been successfully read in and issue a warning or error (depending on strictness) if not.

Parameters:
cfgdata  [in] config-file data
strict  [in] what to do if unparsed lines

Definition at line 728 of file ConfigFile.c.

void LALLowerCaseString ( LALStatus ,
CHAR string 
)

Helper function: turn a string into lowercase without using locale-functions.

Parameters:
string  [in/out] string to convert

Definition at line 776 of file ConfigFile.c.


Generated on Fri Aug 29 02:49:44 2008 for LAL by  doxygen 1.5.2