LAL  7.5.0.1-8083555
UserInput.c File Reference

Prototypes

int XLALRegisterUserVar (void *cvar, const void *cdata, const CHAR *name, UserVarType type, CHAR optchar, UserVarCategory category, const CHAR *help)
 Internal function: Register a user-variable with the module. More...
 
int XLALUserVarPrintUsage (FILE *file)
 Print a one-line usage string. More...
 
int XLALUserVarPrintHelp (FILE *file)
 Print help page. More...
 
static void format_user_var_names (char *s)
 
static void fprint_wrapped (FILE *f, int line_width, const char *prefix, char *text)
 
 DEFN_REGISTER_UVAR (BOOLEAN, BOOLEAN)
 
 DEFN_REGISTER_UVAR (INT4, INT4)
 
 DEFN_REGISTER_UVAR (INT8, INT8)
 
 DEFN_REGISTER_UVAR (UINT4, UINT4)
 
 DEFN_REGISTER_UVAR (UINT8, UINT8)
 
 DEFN_REGISTER_UVAR (REAL8, REAL8)
 
 DEFN_REGISTER_UVAR (RAJ, REAL8)
 
 DEFN_REGISTER_UVAR (DECJ, REAL8)
 
 DEFN_REGISTER_UVAR (EPOCH, LIGOTimeGPS)
 
 DEFN_REGISTER_UVAR (STRING, CHAR *)
 
 DEFN_REGISTER_UVAR (INT4Range, INT4Range)
 
 DEFN_REGISTER_UVAR (REAL8Range, REAL8Range)
 
 DEFN_REGISTER_UVAR (EPOCHRange, LIGOTimeGPSRange)
 
 DEFN_REGISTER_UVAR (RAJRange, REAL8Range)
 
 DEFN_REGISTER_UVAR (DECJRange, REAL8Range)
 
 DEFN_REGISTER_UVAR_AUX_DATA (UserEnum, int, UserChoices)
 
 DEFN_REGISTER_UVAR_AUX_DATA (UserFlag, int, UserChoices)
 
 DEFN_REGISTER_UVAR (INT4Vector, INT4Vector *)
 
 DEFN_REGISTER_UVAR (UINT4Vector, UINT4Vector *)
 
 DEFN_REGISTER_UVAR (REAL8Vector, REAL8Vector *)
 
 DEFN_REGISTER_UVAR (STRINGVector, LALStringVector *)
 
void XLALDestroyUserVars (void)
 Free all memory associated with user-variable linked list. More...
 
int XLALUserVarReadCmdline (BOOLEAN *should_exit, int argc, char *argv[], const LALVCSInfoList vcs_list)
 Parse command-line into UserVariable array. More...
 
int XLALUserVarReadCfgfile (BOOLEAN *should_exit, const CHAR *cfgfile)
 Read config-variables from cfgfile and parse into input-structure. More...
 
int XLALUserVarReadAllInput (BOOLEAN *should_exit, int argc, char *argv[], const LALVCSInfoList vcs_list)
 Put all the pieces together, and basically does everything: print help (if requested), get config-filename from cmd-line (if found), then interpret config-file and then the command-line. More...
 
int XLALUserVarWasSet (const void *cvar)
 Has this user-variable been set by the user? returns 1 (=TRUE) or 0 (=FALSE) on success, error-code otherwise. More...
 
void XLALUserVarCheck (BOOLEAN *should_exit, const int assertion, const CHAR *fmt,...)
 If assertion is false, print the given error message, then the help usage; should_exit is then set to true. More...
 
CHARXLALUserVarGetLog (UserVarLogFormat format)
 Return a log-string representing the complete user-input. More...
 
CHARXLALUserVarGetLogEx (UserVarLogFormat format, const BOOLEAN skip_unset)
 Return a log-string representing the complete user-input. More...
 

Go to the source code of this file.

Data Structures

struct  LALUserVariable
 

Macros

#define TRUE   (1==1)
 
#define FALSE   (1==0)
 
#define DEFN_REGISTER_UVAR(UTYPE, CTYPE)    DEFN_REGISTER_UVAR_AUX_DATA(UTYPE,CTYPE,void)
 
#define DEFN_REGISTER_UVAR_AUX_DATA(UTYPE, CTYPE, DTYPE)
 
#define REGULAR_MAP_ENTRY(UTYPE, DESTRUCTOR, FORMATHELP)
 
#define REGULAR_MAP_ENTRY_AUX_DATA(UTYPE, DESTRUCTOR, DTYPE)
 

Typedefs

typedef void(* destructorT) (void *cvar)
 
typedef int(* parserT) (void *cvar, const char *valstr)
 
typedef char *(* printerT) (const void *cvar)
 
typedef int(* parser_cdataT) (void *cvar, const void *cdata, const char *valstr)
 
typedef char *(* printer_cdataT) (const void *cvar, const void *cdata)
 
typedef char *(* format_help_cdataT) (const void *cdata)
 

Enumerations

enum  UserVarType {
  UVAR_TYPE_START =0 , UVAR_TYPE_BOOLEAN , UVAR_TYPE_INT4 , UVAR_TYPE_INT8 ,
  UVAR_TYPE_UINT4 , UVAR_TYPE_UINT8 , UVAR_TYPE_REAL8 , UVAR_TYPE_EPOCH ,
  UVAR_TYPE_RAJ , UVAR_TYPE_DECJ , UVAR_TYPE_STRING , UVAR_TYPE_INT4Range ,
  UVAR_TYPE_REAL8Range , UVAR_TYPE_EPOCHRange , UVAR_TYPE_RAJRange , UVAR_TYPE_DECJRange ,
  UVAR_TYPE_UserEnum , UVAR_TYPE_UserFlag , UVAR_TYPE_INT4Vector , UVAR_TYPE_UINT4Vector ,
  UVAR_TYPE_REAL8Vector , UVAR_TYPE_STRINGVector , UVAR_TYPE_END
}
 

Variables

struct {
   const char *const   name
 type name More...
 
   destructorT   destructor
 destructor for this variable type, NULL if none required More...
 
   parserT   parser
 parser function to parse string as this type More...
 
   printerT   printer
 'printer' function returning string value for given type More...
 
   const char *const   format_help_str
 help string describing format of user variable More...
 
   parser_cdataT   parser_cdata
 parser function (with auxilliary data) to parse string as this type More...
 
   printer_cdataT   printer_cdata
 'printer' function (with auxilliary data) returning string value for given type More...
 
   format_help_cdataT   format_help_cdata
 function returning describing format of user variable (with auxilliary data) More...
 
UserVarTypeMap [UVAR_TYPE_END]
 
static LALUserVariable UVAR_vars
 
static CHARprogram_path = NULL
 
static CHARprogram_name = NULL
 
const char * lalUserVarHelpBrief = NULL
 An optional brief description of the program, printed after its name as part of the help page. More...
 
const char * lalUserVarHelpDescription = NULL
 An optional longer description of the program, printed in its own section as part of the help page. More...
 
const char * lalUserVarHelpOptionSubsection = NULL
 An optional subsection heading under OPTIONS, under which all subsequently-defined user variables are printed as part of the help page. More...
 

Macro Definition Documentation

◆ TRUE

#define TRUE   (1==1)

Definition at line 48 of file UserInput.c.

◆ FALSE

#define FALSE   (1==0)

Definition at line 49 of file UserInput.c.

◆ DEFN_REGISTER_UVAR

#define DEFN_REGISTER_UVAR (   UTYPE,
  CTYPE 
)     DEFN_REGISTER_UVAR_AUX_DATA(UTYPE,CTYPE,void)

Definition at line 55 of file UserInput.c.

◆ DEFN_REGISTER_UVAR_AUX_DATA

#define DEFN_REGISTER_UVAR_AUX_DATA (   UTYPE,
  CTYPE,
  DTYPE 
)
Value:
int XLALRegister ##UTYPE## UserVar ( CTYPE *cvar, const DTYPE *cdata, const CHAR *name, CHAR optchar, UserVarCategory category, const CHAR *fmt, ... ) \
{ \
char helpstr[2048]; \
va_list ap; \
va_start(ap, fmt); \
vsnprintf(helpstr, sizeof(helpstr), fmt, ap); \
va_end(ap); \
return XLALRegisterUserVar (cvar, (const void*)cdata, name, UVAR_TYPE_ ## UTYPE, optchar, category, helpstr); \
}
const char *const name
type name
Definition: UserInput.c:193
char CHAR
One-byte signed integer, see Headers LAL(Atomic)Datatypes.h for more details.
int XLALRegisterUserVar(void *cvar, const void *cdata, const CHAR *name, UserVarType type, CHAR optchar, UserVarCategory category, const CHAR *help)
Internal function: Register a user-variable with the module.
Definition: UserInput.c:275
UserVarCategory
Mutually-exclusive user variable categories: optional, required, help, developer, ....
Definition: UserInput.h:185

Definition at line 57 of file UserInput.c.

◆ REGULAR_MAP_ENTRY

#define REGULAR_MAP_ENTRY (   UTYPE,
  DESTRUCTOR,
  FORMATHELP 
)
Value:
[UVAR_TYPE_##UTYPE] = { \
.name = #UTYPE, \
.destructor = (destructorT)DESTRUCTOR, \
.parser = (parserT)XLALParseStringValueAs##UTYPE, \
.printer = (printerT)XLALPrintStringValueOf##UTYPE, \
.format_help_str = FORMATHELP, \
}
parserT parser
parser function to parse string as this type
Definition: UserInput.c:195
char *(* printerT)(const void *cvar)
Definition: UserInput.c:154
int(* parserT)(void *cvar, const char *valstr)
Definition: UserInput.c:153
void(* destructorT)(void *cvar)
Definition: UserInput.c:152
const char *const format_help_str
help string describing format of user variable
Definition: UserInput.c:197

Definition at line 160 of file UserInput.c.

◆ REGULAR_MAP_ENTRY_AUX_DATA

#define REGULAR_MAP_ENTRY_AUX_DATA (   UTYPE,
  DESTRUCTOR,
  DTYPE 
)
Value:
[UVAR_TYPE_##UTYPE] = { \
.name = #UTYPE, \
.destructor = (destructorT)DESTRUCTOR, \
.parser_cdata = (parser_cdataT)XLALParseStringValueAs##UTYPE, \
.printer_cdata = (printer_cdataT)XLALPrintStringValueOf##UTYPE, \
.format_help_cdata = (format_help_cdataT)XLALFormatHelpStringOf##UTYPE, \
}
char *(* printer_cdataT)(const void *cvar, const void *cdata)
Definition: UserInput.c:156
format_help_cdataT format_help_cdata
function returning describing format of user variable (with auxilliary data)
Definition: UserInput.c:200
int(* parser_cdataT)(void *cvar, const void *cdata, const char *valstr)
Definition: UserInput.c:155
char *(* format_help_cdataT)(const void *cdata)
Definition: UserInput.c:157
parser_cdataT parser_cdata
parser function (with auxilliary data) to parse string as this type
Definition: UserInput.c:198

Definition at line 168 of file UserInput.c.

Typedef Documentation

◆ destructorT

typedef void(* destructorT) (void *cvar)

Definition at line 152 of file UserInput.c.

◆ parserT

typedef int(* parserT) (void *cvar, const char *valstr)

Definition at line 153 of file UserInput.c.

◆ printerT

typedef char*(* printerT) (const void *cvar)

Definition at line 154 of file UserInput.c.

◆ parser_cdataT

typedef int(* parser_cdataT) (void *cvar, const void *cdata, const char *valstr)

Definition at line 155 of file UserInput.c.

◆ printer_cdataT

typedef char*(* printer_cdataT) (const void *cvar, const void *cdata)

Definition at line 156 of file UserInput.c.

◆ format_help_cdataT

typedef char*(* format_help_cdataT) (const void *cdata)

Definition at line 157 of file UserInput.c.

Enumeration Type Documentation

◆ UserVarType

Enumerator
UVAR_TYPE_START 
UVAR_TYPE_BOOLEAN 
UVAR_TYPE_INT4 
UVAR_TYPE_INT8 
UVAR_TYPE_UINT4 
UVAR_TYPE_UINT8 
UVAR_TYPE_REAL8 
UVAR_TYPE_EPOCH 
UVAR_TYPE_RAJ 
UVAR_TYPE_DECJ 
UVAR_TYPE_STRING 
UVAR_TYPE_INT4Range 
UVAR_TYPE_REAL8Range 
UVAR_TYPE_EPOCHRange 
UVAR_TYPE_RAJRange 
UVAR_TYPE_DECJRange 
UVAR_TYPE_UserEnum 
UVAR_TYPE_UserFlag 
UVAR_TYPE_INT4Vector 
UVAR_TYPE_UINT4Vector 
UVAR_TYPE_REAL8Vector 
UVAR_TYPE_STRINGVector 
UVAR_TYPE_END 

Definition at line 71 of file UserInput.c.

Function Documentation

◆ XLALUserVarPrintUsage()

int XLALUserVarPrintUsage ( FILE *  file)

Print a one-line usage string.

Definition at line 729 of file UserInput.c.

◆ XLALUserVarPrintHelp()

int XLALUserVarPrintHelp ( FILE *  file)

Print help page.

Definition at line 875 of file UserInput.c.

◆ format_user_var_names()

void format_user_var_names ( char *  s)
static

Definition at line 769 of file UserInput.c.

◆ fprint_wrapped()

void fprint_wrapped ( FILE *  f,
int  line_width,
const char *  prefix,
char *  text 
)
static

Definition at line 785 of file UserInput.c.

◆ DEFN_REGISTER_UVAR() [1/19]

DEFN_REGISTER_UVAR ( BOOLEAN  ,
BOOLEAN   
)

◆ DEFN_REGISTER_UVAR() [2/19]

DEFN_REGISTER_UVAR ( INT4  ,
INT4   
)

◆ DEFN_REGISTER_UVAR() [3/19]

DEFN_REGISTER_UVAR ( INT8  ,
INT8   
)

◆ DEFN_REGISTER_UVAR() [4/19]

DEFN_REGISTER_UVAR ( UINT4  ,
UINT4   
)

◆ DEFN_REGISTER_UVAR() [5/19]

DEFN_REGISTER_UVAR ( UINT8  ,
UINT8   
)

◆ DEFN_REGISTER_UVAR() [6/19]

DEFN_REGISTER_UVAR ( REAL8  ,
REAL8   
)

◆ DEFN_REGISTER_UVAR() [7/19]

DEFN_REGISTER_UVAR ( RAJ  ,
REAL8   
)

◆ DEFN_REGISTER_UVAR() [8/19]

DEFN_REGISTER_UVAR ( DECJ  ,
REAL8   
)

◆ DEFN_REGISTER_UVAR() [9/19]

DEFN_REGISTER_UVAR ( EPOCH  ,
LIGOTimeGPS   
)

◆ DEFN_REGISTER_UVAR() [10/19]

DEFN_REGISTER_UVAR ( STRING  ,
CHAR  
)

◆ DEFN_REGISTER_UVAR() [11/19]

DEFN_REGISTER_UVAR ( INT4Range  ,
INT4Range   
)

◆ DEFN_REGISTER_UVAR() [12/19]

DEFN_REGISTER_UVAR ( REAL8Range  ,
REAL8Range   
)

◆ DEFN_REGISTER_UVAR() [13/19]

DEFN_REGISTER_UVAR ( EPOCHRange  ,
LIGOTimeGPSRange   
)

◆ DEFN_REGISTER_UVAR() [14/19]

DEFN_REGISTER_UVAR ( RAJRange  ,
REAL8Range   
)

◆ DEFN_REGISTER_UVAR() [15/19]

DEFN_REGISTER_UVAR ( DECJRange  ,
REAL8Range   
)

◆ DEFN_REGISTER_UVAR_AUX_DATA() [1/2]

DEFN_REGISTER_UVAR_AUX_DATA ( UserEnum  ,
int  ,
UserChoices   
)

◆ DEFN_REGISTER_UVAR_AUX_DATA() [2/2]

DEFN_REGISTER_UVAR_AUX_DATA ( UserFlag  ,
int  ,
UserChoices   
)

◆ DEFN_REGISTER_UVAR() [16/19]

DEFN_REGISTER_UVAR ( INT4Vector  ,
INT4Vector  
)

◆ DEFN_REGISTER_UVAR() [17/19]

DEFN_REGISTER_UVAR ( UINT4Vector  ,
UINT4Vector  
)

◆ DEFN_REGISTER_UVAR() [18/19]

DEFN_REGISTER_UVAR ( REAL8Vector  ,
REAL8Vector  
)

◆ DEFN_REGISTER_UVAR() [19/19]

DEFN_REGISTER_UVAR ( STRINGVector  ,
LALStringVector  
)

◆ XLALUserVarCheck()

void XLALUserVarCheck ( BOOLEAN should_exit,
const int  assertion,
const CHAR fmt,
  ... 
)

If assertion is false, print the given error message, then the help usage; should_exit is then set to true.

Definition at line 1206 of file UserInput.c.

Variable Documentation

◆ name

const char* const name

type name

Definition at line 193 of file UserInput.c.

◆ destructor

destructorT destructor

destructor for this variable type, NULL if none required

Definition at line 194 of file UserInput.c.

◆ parser

parserT parser

parser function to parse string as this type

Definition at line 195 of file UserInput.c.

◆ printer

printerT printer

'printer' function returning string value for given type

Definition at line 196 of file UserInput.c.

◆ format_help_str

const char* const format_help_str

help string describing format of user variable

Definition at line 197 of file UserInput.c.

◆ parser_cdata

parser_cdataT parser_cdata

parser function (with auxilliary data) to parse string as this type

Definition at line 198 of file UserInput.c.

◆ printer_cdata

printer_cdataT printer_cdata

'printer' function (with auxilliary data) returning string value for given type

Definition at line 199 of file UserInput.c.

◆ format_help_cdata

format_help_cdataT format_help_cdata

function returning describing format of user variable (with auxilliary data)

Definition at line 200 of file UserInput.c.

◆ 

const { ... } UserVarTypeMap[UVAR_TYPE_END]

◆ UVAR_vars

LALUserVariable UVAR_vars
static

Definition at line 240 of file UserInput.c.

◆ program_path

CHAR* program_path = NULL
static

Definition at line 241 of file UserInput.c.

◆ program_name

CHAR* program_name = NULL
static

Definition at line 242 of file UserInput.c.