UserInput.c File Reference

Author:
Reinhard PrixConvenient unified handling of user-input via config-file and/or command-line.
More...

#include "getopt.h"
#include <lal/LALStdio.h>
#include <lal/UserInput.h>
#include <lal/LogPrintf.h>
#include <lal/StringVector.h>

Include dependency graph for UserInput.c:

Go to the source code of this file.

Data Structures

struct  tagLALUserVariable
 Linked list to hold the complete information about the user-variables. More...

Defines

#define TRUE   (1==1)
#define FALSE   (1==0)
#define UVAR_MAXHELPLINE   512
#define UVAR_MAXDEFSTR   100

Typedefs

typedef tagLALUserVariable LALUserVariable
 Linked list to hold the complete information about the user-variables.

Enumerations

enum  UserVarType {
  UVAR_BOOL, UVAR_INT4, UVAR_REAL8, UVAR_STRING,
  UVAR_CSVLIST, UVAR_LAST
}
 Defines the type of a "user-variable": bool, int, real or string. More...

Functions

 NRCSID (USERINPUTC,"$Id: UserInput.c,v 1.47 2008/09/14 13:06:01 reinhard Exp $")
void UvarType2String (LALStatus *status, CHAR **out, LALUserVariable *uvar)
CHARcopy_string_unquoted (const CHAR *in)
 Copy (and allocate) string 'in', possibly with quotes \" or \' removed.
void check_and_mark_as_set (LALUserVariable *varp)
 Mark the user-variable as set, check if it has been set previously and issue a warning if set more than once .
void LALRegisterREALUserVar (LALStatus *status, const CHAR *name, CHAR optchar, UserVarState flag, const CHAR *helpstr, REAL8 *cvar)
void LALRegisterINTUserVar (LALStatus *status, const CHAR *name, CHAR optchar, UserVarState flag, const CHAR *helpstr, INT4 *cvar)
void LALRegisterBOOLUserVar (LALStatus *status, const CHAR *name, CHAR optchar, UserVarState flag, const CHAR *helpstr, BOOLEAN *cvar)
void LALRegisterSTRINGUserVar (LALStatus *status, const CHAR *name, CHAR optchar, UserVarState flag, const CHAR *helpstr, CHAR **cvar)
void LALRegisterLISTUserVar (LALStatus *status, const CHAR *name, CHAR optchar, UserVarState flag, const CHAR *helpstr, LALStringVector **cvar)
void LALDestroyUserVars (LALStatus *status)
 Free all memory associated with user-variable linked list.
void LALUserVarReadCmdline (LALStatus *status, int argc, char *argv[])
 Parse command-line into UserVariable array.
void LALUserVarReadCfgfile (LALStatus *status, const CHAR *cfgfile)
 Read config-variables from cfgfile and parse into input-structure.
void LALUserVarHelpString (LALStatus *status, CHAR **helpstring, const CHAR *progname)
 Assemble all help-info from uvars into a help-string.
void LALUserVarReadAllInput (LALStatus *status, int argc, char *argv[])
 Put all the pieces together, and basically does everything: get config-filename from cmd-line (if found), then interpret config-file and then the command-line.
INT4 LALUserVarWasSet (const void *cvar)
 Has this user-variable been set by the user? return -1 on error, TRUE/FALSE otherwise.
void LALUserVarCheckRequired (LALStatus *status)
 Check that all required user-variables have been set successfully.
void LALGetDebugLevel (LALStatus *status, int argc, char *argv[], CHAR optchar)
 Handle the delicate setting of lalDebuglevel.
void LALUserVarGetLog (LALStatus *status, CHAR **logstr, UserVarLogFormat format)
 Return a log-string representing the complete user-input.
void LALUserVarGetProcParamsTable (LALStatus *status, ProcessParamsTable **out, CHAR *progname)
 Return user log as a process-params table.

Variables

INT4 lalDebugLevel
 DECLARE AND SET GLOBAL DEBUG LEVEL.
char * optarg
int optind
int opterr
int optopt


Detailed Description

Author:
Reinhard PrixConvenient unified handling of user-input via config-file and/or command-line.

Definition in file UserInput.c.


Define Documentation

#define TRUE   (1==1)

Definition at line 39 of file UserInput.c.

#define FALSE   (1==0)

Definition at line 40 of file UserInput.c.

#define UVAR_MAXHELPLINE   512

Definition at line 566 of file UserInput.c.

#define UVAR_MAXDEFSTR   100

Definition at line 567 of file UserInput.c.


Typedef Documentation

typedef struct tagLALUserVariable LALUserVariable

Linked list to hold the complete information about the user-variables.


Enumeration Type Documentation

enum UserVarType

Defines the type of a "user-variable": bool, int, real or string.

Should be used only internally !!

Enumerator:
UVAR_BOOL  boolean
UVAR_INT4  integer
UVAR_REAL8  float
UVAR_STRING  string
UVAR_CSVLIST  list of comma-separated values
UVAR_LAST 

Definition at line 45 of file UserInput.c.


Function Documentation

NRCSID ( USERINPUTC  ,
"$Id: UserInput.  c,
v 1.47 2008/09/14 13:06:01 reinhard Exp $"   
)

void UvarType2String ( LALStatus status,
CHAR **  out,
LALUserVariable uvar 
)

Definition at line 1119 of file UserInput.c.

CHAR * copy_string_unquoted ( const CHAR in  ) 

Copy (and allocate) string 'in', possibly with quotes \" or \' removed.

If quotes are present at the beginning of 'in', they must have a matching quote at the end of string, otherwise an error is printed and return=NULL

Definition at line 1260 of file UserInput.c.

void check_and_mark_as_set ( LALUserVariable varp  ) 

Mark the user-variable as set, check if it has been set previously and issue a warning if set more than once .

..

Definition at line 1311 of file UserInput.c.

void LALRegisterREALUserVar ( LALStatus status,
const CHAR name,
CHAR  optchar,
UserVarState  flag,
const CHAR helpstr,
REAL8 cvar 
)

Definition at line 88 of file UserInput.c.

void LALRegisterINTUserVar ( LALStatus status,
const CHAR name,
CHAR  optchar,
UserVarState  flag,
const CHAR helpstr,
INT4 cvar 
)

Definition at line 99 of file UserInput.c.

void LALRegisterBOOLUserVar ( LALStatus status,
const CHAR name,
CHAR  optchar,
UserVarState  flag,
const CHAR helpstr,
BOOLEAN cvar 
)

Definition at line 110 of file UserInput.c.

void LALRegisterSTRINGUserVar ( LALStatus status,
const CHAR name,
CHAR  optchar,
UserVarState  flag,
const CHAR helpstr,
CHAR **  cvar 
)

Definition at line 121 of file UserInput.c.

void LALRegisterLISTUserVar ( LALStatus status,
const CHAR name,
CHAR  optchar,
UserVarState  flag,
const CHAR helpstr,
LALStringVector **  cvar 
)

Definition at line 132 of file UserInput.c.

void LALDestroyUserVars ( LALStatus status  ) 

Free all memory associated with user-variable linked list.

Definition at line 200 of file UserInput.c.

void LALUserVarReadCmdline ( LALStatus status,
int  argc,
char *  argv[] 
)

Parse command-line into UserVariable array.

Definition at line 248 of file UserInput.c.

void LALUserVarReadCfgfile ( LALStatus status,
const CHAR cfgfile 
)

Read config-variables from cfgfile and parse into input-structure.

An error is reported if the config-file reading fails, but the individual variable-reads are treated as optional

Definition at line 473 of file UserInput.c.

void LALUserVarHelpString ( LALStatus status,
CHAR **  helpstring,
const CHAR progname 
)

Assemble all help-info from uvars into a help-string.

Definition at line 571 of file UserInput.c.

void LALUserVarReadAllInput ( LALStatus status,
int  argc,
char *  argv[] 
)

Put all the pieces together, and basically does everything: get config-filename from cmd-line (if found), then interpret config-file and then the command-line.

Definition at line 767 of file UserInput.c.

INT4 LALUserVarWasSet ( const void *  cvar  ) 

Has this user-variable been set by the user? return -1 on error, TRUE/FALSE otherwise.

Definition at line 858 of file UserInput.c.

void LALUserVarCheckRequired ( LALStatus status  ) 

Check that all required user-variables have been set successfully.

Print error if not

Definition at line 886 of file UserInput.c.

void LALGetDebugLevel ( LALStatus status,
int  argc,
char *  argv[],
CHAR  optchar 
)

Handle the delicate setting of lalDebuglevel.

Note:
*NEVER* call this function after any LALMalloc/LALCalloc/LALRealloc have been used. A change of lalDebugLevel can then lead to inconsistencies in the LAL memory-checker. You should therefore call this function very early on in main(), before any LALMallocs ...

Definition at line 914 of file UserInput.c.

void LALUserVarGetLog ( LALStatus status,
CHAR **  logstr,
UserVarLogFormat  format 
)

Return a log-string representing the complete user-input.

NOTE: we only record user-variables that have been set by the user.

Parameters:
[out] **outstr the string containing the user-input record.
[in] format return as config-file or command-line

Definition at line 970 of file UserInput.c.

void LALUserVarGetProcParamsTable ( LALStatus status,
ProcessParamsTable **  out,
CHAR progname 
)

Return user log as a process-params table.

Parameters:
[out] **procPar the output ProcessParamsTable
[in] *progname name of calling code

Definition at line 1062 of file UserInput.c.


Variable Documentation

INT4 lalDebugLevel

DECLARE AND SET GLOBAL DEBUG LEVEL.

see the section (currently 7.4.1) of the LSD on "Status-reporting objects" for a list of predefined debug levels

Definition at line 62 of file BCVSpinTemplates.c.

char* optarg

Definition at line 176 of file GeneralMeshTest.c.

int optind

Definition at line 149 of file packages/support/src/getopt.c.

int opterr

Definition at line 169 of file packages/support/src/getopt.c.

int optopt

Definition at line 175 of file packages/support/src/getopt.c.


Generated on Tue Oct 7 02:41:34 2008 for LAL by  doxygen 1.5.2