The ParFile module is used by all of the process modules to read parameters from files. Each process module has its own parameter file format. The ParFile routines can also be used to read parameters from files into test programs, as is done for each of the tests programs supplier with LUTEar.
typedef struct {
|
|||
| BOOLN
|
diagnosticsFlag;
|
/*
Set to TRUE to print diagnostics. */
| |
| int
|
parLineCount;
|
/*
A record of the parameter file lines read. */
| |
| }
ParFile;
|
Syntax
|
BOOLN CheckInit_ParFile(void);
|
| Description
|
This
routine checks that the the module) has been initialised. It prevents attempts
to use uninitailised pointers which will cause the module to crash the
system.
.
|
| Returns
|
TRUE
if the module has been initialised, otherwise it returns FALSE.
|
| Example(s)
|
The
GetPars_ParFile(...) routine.
|
Syntax
|
BOOLN CommentOrBlankLine_ParFile(char *line);
|
| Description
|
This
routine checks if a line read is a comment line or a blank line. A comment
line is any line that begins with a '#', which may also be preceeded by white
space.
|
| Returns
|
TRUE
if the line is a comment or a blank line, otherwise it returns FALSE.
|
| Example(s)
|
The
GetPars_ParFile(...) routine.
|
Syntax
|
BOOLN Free_ParFile(void);
|
| Description
|
This
routine frees the memory space allocated for the global variable parFile. It
should be called after parameter reading has ended.
|
| Returns
|
FALSE
if the ParFile module was not initialised, otherwise it returns TRUE.
|
| Example(s)
|
All
test program ReadParsFromFile(...) routines, and process modules
ReadPars...(...) routines.
|
Syntax
|
char *GetLine_ParFile(char *line, int
maxChars, FILE *fp);
|
| Description
|
This
function reads a line from a file. If the maximum number of characters is
exceeded, then it flushes the rest of the line in the file.
|
| Returns
|
A
pointer to the string stor if successful, otherwise it returns NULL.
|
| Example(s)
|
The
GetPars_ParFile(...) routine.
|
Syntax
|
BOOLN GetPars_ParFile(FILE *fp, char *fmt,
...);
|
| Description
|
This
function reads respective variables from a line in a file. It uses a format
similar to the standard C printf(...) statement. Blank or comment lines
are ignored.
|
| Returns
|
TRUE
if this function succeeeds, otherwise it returns FALSE.
|
| Example(s)
|
All
test program ReadParsFromFile(...) routines, and process modules
ReadPars...(...) routines.
|
Syntax
|
char IdentifyFormat_ParFile(char *fmt);
|
| Description
|
This
subroutine returns a type character as defined by the format string passed as
an argument, e.g. "%d", "%ld", "%s", "%f", "%lf" or "%i". The routine assumes
that only double precision real values are used for real parameters, i.e. the
"l" is ignored.
|
| Returns
|
EOF
if a '%' is not found at the start of the string, and a '\0' if an invalid
character is found.
|
| Example(s)
|
The
GetPars_ParFile(...) routine.
|
Syntax
|
BOOLN Init_ParFile(void);
|
| Description
|
This
routine initialises the parFile data structure. It allocates its memory
dynamically, and sets the respective fields to their default. values.
|
| Returns
|
TRUE
if this function succeeeds, otherwise it returns FALSE.
|
| Example(s)
|
All
test program ReadParsFromFile(...) routines, and process modules
ReadPars...(...) routines.
|