Commit 2995ec73 authored by Karl Wette's avatar Karl Wette
Browse files

UserInput: parse help options separately

- Remove registered help variables and UVAR_CATEGORY_HELP
- Pass boolean 'should_exit' to XLALUserVarReadAllInput()
  and other functions, which indicates whether program
  should exit with non-zero status
Original: 4d10e8d97c6a5c89c609b44bd3f1e160be8314c8
parent 83b28628
...@@ -205,6 +205,10 @@ XLALRegisterUserVar ( void *cvar, /**< pointer to the actual C-variabe to link ...@@ -205,6 +205,10 @@ XLALRegisterUserVar ( void *cvar, /**< pointer to the actual C-variabe to link
XLAL_CHECK ( help != NULL, XLAL_EINVAL ); XLAL_CHECK ( help != NULL, XLAL_EINVAL );
XLAL_CHECK ( strlen(help) < sizeof(UVAR_vars.help), XLAL_EINVAL, "User-variable help '%s' is too long", help ); XLAL_CHECK ( strlen(help) < sizeof(UVAR_vars.help), XLAL_EINVAL, "User-variable help '%s' is too long", help );
// check that neither short- nor long-option are used by help
XLAL_CHECK ( strcmp ( name, "help" ) != 0, XLAL_EINVAL, "Long-option name '--%s' is reserved for help!\n", name );
XLAL_CHECK ( optchar != 'h', XLAL_EINVAL, "Short-option '-%c' is reserved for help!\n", optchar );
// find end of uvar-list && check that neither short- nor long-option are taken already // find end of uvar-list && check that neither short- nor long-option are taken already
LALUserVariable *ptr = &UVAR_vars; LALUserVariable *ptr = &UVAR_vars;
while ( ptr->next != NULL ) while ( ptr->next != NULL )
...@@ -214,7 +218,7 @@ XLALRegisterUserVar ( void *cvar, /**< pointer to the actual C-variabe to link ...@@ -214,7 +218,7 @@ XLALRegisterUserVar ( void *cvar, /**< pointer to the actual C-variabe to link
// long-option name taken already? // long-option name taken already?
XLAL_CHECK ( strcmp ( name, ptr->name ) != 0, XLAL_EINVAL, "Long-option name '--%s' already taken!\n", name ); XLAL_CHECK ( strcmp ( name, ptr->name ) != 0, XLAL_EINVAL, "Long-option name '--%s' already taken!\n", name );
// short-option character taken already? // short-option character taken already?
XLAL_CHECK ( (optchar == 0) || (ptr->optchar == 0) || (optchar != ptr->optchar), XLAL_EINVAL, "Short-option '-%c' already taken (by '--%s')!\n", ptr->optchar, ptr->name ); XLAL_CHECK ( (optchar == 0) || (ptr->optchar == 0) || (optchar != ptr->optchar), XLAL_EINVAL, "Short-option '-%c' already taken (by '--%s')!\n", optchar, ptr->name );
} // while ptr->next } // while ptr->next
...@@ -285,13 +289,19 @@ XLALDestroyUserVars ( void ) ...@@ -285,13 +289,19 @@ XLALDestroyUserVars ( void )
/** /**
* Parse command-line into UserVariable array * Parse command-line into UserVariable array
*
* If \p *should_exit is TRUE when this function returns, the
* caller should exit immediately.
*/ */
int int
XLALUserVarReadCmdline ( int argc, char *argv[] ) XLALUserVarReadCmdline ( BOOLEAN *should_exit, int argc, char *argv[] )
{ {
XLAL_CHECK ( should_exit != NULL, XLAL_EFAULT );
XLAL_CHECK ( argv != NULL, XLAL_EINVAL, "Input error, NULL argv[] pointer passed.\n" ); XLAL_CHECK ( argv != NULL, XLAL_EINVAL, "Input error, NULL argv[] pointer passed.\n" );
XLAL_CHECK ( UVAR_vars.next != NULL, XLAL_EINVAL, "Internal error, no UVAR memory allocated. Did you register any user-variables?" ); XLAL_CHECK ( UVAR_vars.next != NULL, XLAL_EINVAL, "Internal error, no UVAR memory allocated. Did you register any user-variables?" );
*should_exit = 0;
LALUserVariable *ptr; LALUserVariable *ptr;
UINT4 pos; UINT4 pos;
...@@ -433,13 +443,19 @@ XLALUserVarReadCmdline ( int argc, char *argv[] ) ...@@ -433,13 +443,19 @@ XLALUserVarReadCmdline ( int argc, char *argv[] )
* Read config-variables from cfgfile and parse into input-structure. * Read config-variables from cfgfile and parse into input-structure.
* An error is reported if the config-file reading fails, but the * An error is reported if the config-file reading fails, but the
* individual variable-reads are treated as optional * individual variable-reads are treated as optional
*
* If \p *should_exit is TRUE when this function returns, the
* caller should exit immediately.
*/ */
int int
XLALUserVarReadCfgfile ( const CHAR *cfgfile ) /**< [in] name of config-file */ XLALUserVarReadCfgfile ( BOOLEAN *should_exit, const CHAR *cfgfile )
{ {
XLAL_CHECK ( should_exit != NULL, XLAL_EFAULT );
XLAL_CHECK ( cfgfile != NULL, XLAL_EINVAL ); XLAL_CHECK ( cfgfile != NULL, XLAL_EINVAL );
XLAL_CHECK ( UVAR_vars.next != NULL, XLAL_EINVAL, "No memory allocated in UVAR_vars.next, did you register any user-variables?\n" ); XLAL_CHECK ( UVAR_vars.next != NULL, XLAL_EINVAL, "No memory allocated in UVAR_vars.next, did you register any user-variables?\n" );
*should_exit = 0;
LALParsedDataFile *cfg = NULL; LALParsedDataFile *cfg = NULL;
XLAL_CHECK ( XLALParseDataFile ( &cfg, cfgfile ) == XLAL_SUCCESS, XLAL_EFUNC ); XLAL_CHECK ( XLALParseDataFile ( &cfg, cfgfile ) == XLAL_SUCCESS, XLAL_EFUNC );
...@@ -556,9 +572,6 @@ XLALUserVarHelpString ( const CHAR *progname ) ...@@ -556,9 +572,6 @@ XLALUserVarHelpString ( const CHAR *progname )
if ( ptr->category == UVAR_CATEGORY_REQUIRED ) { if ( ptr->category == UVAR_CATEGORY_REQUIRED ) {
strcpy (defaultstr, "REQUIRED"); strcpy (defaultstr, "REQUIRED");
} }
else if ( ptr->category == UVAR_CATEGORY_HELP ) {
strcpy ( defaultstr, "");
}
else // write the current default-value into a string else // write the current default-value into a string
{ {
CHAR *valstr; CHAR *valstr;
...@@ -649,19 +662,40 @@ XLALUserVarHelpString ( const CHAR *progname ) ...@@ -649,19 +662,40 @@ XLALUserVarHelpString ( const CHAR *progname )
/** /**
* Put all the pieces together, and basically does everything: * Put all the pieces together, and basically does everything:
* get config-filename from cmd-line (if found), * print help (if requested), get config-filename from cmd-line (if found),
* then interpret config-file and then the command-line * then interpret config-file and then the command-line
*
* If \p *should_exit is TRUE when this function returns, the
* program should exit immediately with a non-zero status.
*/ */
int int
XLALUserVarReadAllInput ( int argc, char *argv[] ) XLALUserVarReadAllInput ( BOOLEAN *should_exit, int argc, char *argv[] )
{ {
XLAL_CHECK ( should_exit != NULL, XLAL_EFAULT );
XLAL_CHECK ( argc > 0, XLAL_EINVAL ); XLAL_CHECK ( argc > 0, XLAL_EINVAL );
XLAL_CHECK ( argv != NULL, XLAL_EINVAL ); XLAL_CHECK ( argv != NULL, XLAL_EINVAL );
XLAL_CHECK ( argv[0] != NULL, XLAL_EINVAL ); XLAL_CHECK ( argv[0] != NULL, XLAL_EINVAL );
XLAL_CHECK ( UVAR_vars.next != NULL, XLAL_EINVAL, "No UVAR memory allocated. Did you register any user-variables?" ); XLAL_CHECK ( UVAR_vars.next != NULL, XLAL_EINVAL, "No UVAR memory allocated. Did you register any user-variables?" );
*should_exit = 0;
program_name = argv[0]; // keep a modul-local pointer to the executable name program_name = argv[0]; // keep a modul-local pointer to the executable name
// ---------- manually parse command-line for help/usage arguments
for ( INT4 i = 1; i < argc; i++ )
{
XLAL_CHECK( argv[i] != NULL, XLAL_EINVAL, "argc = %d, but argv[%d] == NULL!\n", argc, i );
if ( strcmp( argv[i], "-h" ) == 0 || strcmp( argv[i], "--help" ) == 0 || strcmp( argv[i], "-help" ) == 0 )
{
CHAR *helpstring;
XLAL_CHECK ( ( helpstring = XLALUserVarHelpString(argv[0])) != NULL, XLAL_EFUNC );
printf ("\n%s\n", helpstring);
XLALFree (helpstring);
*should_exit = 1;
return XLAL_SUCCESS;
}
}
// ---------- pre-process command-line: have we got a config-file ? // ---------- pre-process command-line: have we got a config-file ?
CHAR* cfgfile_name = NULL; CHAR* cfgfile_name = NULL;
for ( INT4 i = 1; i < argc; i++ ) for ( INT4 i = 1; i < argc; i++ )
...@@ -681,26 +715,24 @@ XLALUserVarReadAllInput ( int argc, char *argv[] ) ...@@ -681,26 +715,24 @@ XLALUserVarReadAllInput ( int argc, char *argv[] )
// ---------- if config-file specified, read from that first // ---------- if config-file specified, read from that first
if ( cfgfile_name != NULL ) if ( cfgfile_name != NULL )
{ {
XLAL_CHECK ( XLALUserVarReadCfgfile ( cfgfile_name ) == XLAL_SUCCESS, XLAL_EFUNC ); XLAL_CHECK ( XLALUserVarReadCfgfile ( should_exit, cfgfile_name ) == XLAL_SUCCESS, XLAL_EFUNC );
if ( *should_exit ) {
return XLAL_SUCCESS;
}
XLALFree (cfgfile_name); XLALFree (cfgfile_name);
} }
// ---------- now parse cmdline: overloads previous config-file settings // ---------- now parse cmdline: overloads previous config-file settings
XLAL_CHECK ( XLALUserVarReadCmdline ( argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC ); XLAL_CHECK ( XLALUserVarReadCmdline ( should_exit, argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC );
if ( *should_exit ) {
return XLAL_SUCCESS;
}
// ---------- handle special options that need some action ---------- // ---------- handle special options that need some action ----------
BOOLEAN skipCheckRequired = FALSE; BOOLEAN skipCheckRequired = FALSE;
LALUserVariable *ptr = &UVAR_vars; LALUserVariable *ptr = &UVAR_vars;
while ( (ptr=ptr->next) != NULL ) while ( (ptr=ptr->next) != NULL )
{ {
if ( (ptr->category == UVAR_CATEGORY_HELP) && ( *((BOOLEAN*)ptr->varp) ) )
{
CHAR *helpstring;
XLAL_CHECK ( ( helpstring = XLALUserVarHelpString(argv[0])) != NULL, XLAL_EFUNC );
printf ("\n%s\n", helpstring);
XLALFree (helpstring);
return XLAL_SUCCESS;
} // if help requested
// check 'special' category, which suppresses the CheckRequired test // check 'special' category, which suppresses the CheckRequired test
if ( (ptr->category == UVAR_CATEGORY_SPECIAL) && ptr->was_set ) { if ( (ptr->category == UVAR_CATEGORY_SPECIAL) && ptr->was_set ) {
...@@ -874,10 +906,10 @@ LALDestroyUserVars (LALStatus *status) ...@@ -874,10 +906,10 @@ LALDestroyUserVars (LALStatus *status)
/** \deprecated use XLALUserVarReadCmdline() instead */ /** \deprecated use XLALUserVarReadCmdline() instead */
void void
LALUserVarReadCmdline (LALStatus *status, int argc, char *argv[]) LALUserVarReadCmdline (LALStatus *status, BOOLEAN *should_exit, int argc, char *argv[])
{ {
INITSTATUS(status); INITSTATUS(status);
if ( XLALUserVarReadCmdline(argc, argv) != XLAL_SUCCESS ) { if ( XLALUserVarReadCmdline(should_exit, argc, argv) != XLAL_SUCCESS ) {
XLALPrintError ("Call to XLALUserVarReadCmdline() failed with code %d\n", xlalErrno ); XLALPrintError ("Call to XLALUserVarReadCmdline() failed with code %d\n", xlalErrno );
ABORT ( status, USERINPUTH_EXLAL, USERINPUTH_MSGEXLAL ); ABORT ( status, USERINPUTH_EXLAL, USERINPUTH_MSGEXLAL );
} }
...@@ -898,10 +930,10 @@ LALUserVarCheckRequired (LALStatus *status) ...@@ -898,10 +930,10 @@ LALUserVarCheckRequired (LALStatus *status)
/** \deprecated use XLALUserVarReadAllInput() instead */ /** \deprecated use XLALUserVarReadAllInput() instead */
void void
LALUserVarReadAllInput (LALStatus *status, int argc, char *argv[]) LALUserVarReadAllInput (LALStatus *status, BOOLEAN *should_exit, int argc, char *argv[])
{ {
INITSTATUS(status); INITSTATUS(status);
if ( XLALUserVarReadAllInput ( argc, argv ) != XLAL_SUCCESS ) { if ( XLALUserVarReadAllInput ( should_exit, argc, argv ) != XLAL_SUCCESS ) {
XLALPrintError ( "XLALUserVarReadAllInput() failed with code %d\n", xlalErrno ); XLALPrintError ( "XLALUserVarReadAllInput() failed with code %d\n", xlalErrno );
ABORT ( status, USERINPUTH_EXLAL, USERINPUTH_MSGEXLAL ); ABORT ( status, USERINPUTH_EXLAL, USERINPUTH_MSGEXLAL );
} }
...@@ -1031,11 +1063,12 @@ LALRegisterLISTUserVar (LALStatus *status, ...@@ -1031,11 +1063,12 @@ LALRegisterLISTUserVar (LALStatus *status,
/** \deprecated use XLALUserVarReadCfgfile() instead */ /** \deprecated use XLALUserVarReadCfgfile() instead */
void void
LALUserVarReadCfgfile (LALStatus *status, LALUserVarReadCfgfile (LALStatus *status,
BOOLEAN *should_exit,
const CHAR *cfgfile) /* name of config-file */ const CHAR *cfgfile) /* name of config-file */
{ {
INITSTATUS(status); INITSTATUS(status);
if ( XLALUserVarReadCfgfile ( cfgfile ) != XLAL_SUCCESS ) { if ( XLALUserVarReadCfgfile ( should_exit, cfgfile ) != XLAL_SUCCESS ) {
ABORT ( status, USERINPUTH_EXLAL, USERINPUTH_MSGEXLAL ); ABORT ( status, USERINPUTH_EXLAL, USERINPUTH_MSGEXLAL );
} }
RETURN (status); RETURN (status);
......
...@@ -163,7 +163,6 @@ typedef enum { ...@@ -163,7 +163,6 @@ typedef enum {
UVAR_CATEGORY_OPTIONAL, ///< optional UVAR_CATEGORY_OPTIONAL, ///< optional
UVAR_CATEGORY_REQUIRED, ///< required UVAR_CATEGORY_REQUIRED, ///< required
UVAR_CATEGORY_HELP, ///< special variable: trigger output of help-string
UVAR_CATEGORY_DEVELOPER, ///< optional and hidden in help-output until lalDebugLevel>=warning UVAR_CATEGORY_DEVELOPER, ///< optional and hidden in help-output until lalDebugLevel>=warning
UVAR_CATEGORY_DEPRECATED, ///< optional and hidden until lalDebugLevel>=info; still supported but output warning if used UVAR_CATEGORY_DEPRECATED, ///< optional and hidden until lalDebugLevel>=info; still supported but output warning if used
UVAR_CATEGORY_DEFUNCT, ///< hidden completely from help output; not supported, will output error + help-string if used UVAR_CATEGORY_DEFUNCT, ///< hidden completely from help output; not supported, will output error + help-string if used
...@@ -174,7 +173,6 @@ typedef enum { ...@@ -174,7 +173,6 @@ typedef enum {
// ***** the following are provided only for backwards compatibility until full transition to new XLAL interface ***** // ***** the following are provided only for backwards compatibility until full transition to new XLAL interface *****
#define UVAR_OPTIONAL UVAR_CATEGORY_OPTIONAL #define UVAR_OPTIONAL UVAR_CATEGORY_OPTIONAL
#define UVAR_REQUIRED UVAR_CATEGORY_REQUIRED #define UVAR_REQUIRED UVAR_CATEGORY_REQUIRED
#define UVAR_HELP UVAR_CATEGORY_HELP
#define UVAR_DEVELOPER UVAR_CATEGORY_DEVELOPER #define UVAR_DEVELOPER UVAR_CATEGORY_DEVELOPER
#define UVAR_SPECIAL UVAR_CATEGORY_SPECIAL #define UVAR_SPECIAL UVAR_CATEGORY_SPECIAL
// ********** // **********
...@@ -192,10 +190,10 @@ typedef enum { ...@@ -192,10 +190,10 @@ typedef enum {
/* Function prototypes */ /* Function prototypes */
void XLALDestroyUserVars( void ); void XLALDestroyUserVars( void );
int XLALUserVarReadCmdline (int argc, char *argv[]); int XLALUserVarReadCmdline( BOOLEAN *should_exit, int argc, char *argv[] );
int XLALUserVarReadCfgfile ( const CHAR *cfgfile ); int XLALUserVarReadCfgfile( BOOLEAN *should_exit, const CHAR *cfgfile );
CHAR *XLALUserVarHelpString ( const CHAR *progname ); CHAR *XLALUserVarHelpString ( const CHAR *progname );
int XLALUserVarReadAllInput ( int argc, char *argv[] ); int XLALUserVarReadAllInput( BOOLEAN *should_exit, int argc, char *argv[] );
int XLALUserVarCheckRequired( void ); int XLALUserVarCheckRequired( void );
int XLALUserVarWasSet (const void *cvar); int XLALUserVarWasSet (const void *cvar);
CHAR * XLALUserVarGetLog ( UserVarLogFormat format ); CHAR * XLALUserVarGetLog ( UserVarLogFormat format );
...@@ -291,9 +289,9 @@ void LALRegisterLISTUserVar (LALStatus *, const CHAR *name, CHAR optchar, UserVa ...@@ -291,9 +289,9 @@ void LALRegisterLISTUserVar (LALStatus *, const CHAR *name, CHAR optchar, UserVa
void LALDestroyUserVars (LALStatus *); void LALDestroyUserVars (LALStatus *);
void LALUserVarReadAllInput(LALStatus *, int argc, char *argv[]); void LALUserVarReadAllInput(LALStatus *, BOOLEAN *should_exit, int argc, char *argv[]);
void LALUserVarReadCmdline (LALStatus *, int argc, char *argv[]); void LALUserVarReadCmdline (LALStatus *, BOOLEAN *should_exit, int argc, char *argv[]);
void LALUserVarReadCfgfile (LALStatus *, const CHAR *cfgfile); void LALUserVarReadCfgfile (LALStatus *, BOOLEAN *should_exit, const CHAR *cfgfile);
void LALUserVarHelpString (LALStatus *, CHAR **helpstring, const CHAR *progname); void LALUserVarHelpString (LALStatus *, CHAR **helpstring, const CHAR *progname);
void LALUserVarCheckRequired (LALStatus *); void LALUserVarCheckRequired (LALStatus *);
......
...@@ -83,7 +83,9 @@ main(int argc, char *argv[]) ...@@ -83,7 +83,9 @@ main(int argc, char *argv[])
XLAL_CHECK ( XLALRegisterUvarMember( longInt, INT8, 0, REQUIRED, "Testing INT8 argument") == XLAL_SUCCESS, XLAL_EFUNC ); XLAL_CHECK ( XLALRegisterUvarMember( longInt, INT8, 0, REQUIRED, "Testing INT8 argument") == XLAL_SUCCESS, XLAL_EFUNC );
/* ---------- now read all input from commandline and config-file ---------- */ /* ---------- now read all input from commandline and config-file ---------- */
XLAL_CHECK ( XLALUserVarReadAllInput ( my_argc, my_argv ) == XLAL_SUCCESS, XLAL_EFUNC ); BOOLEAN should_exit = 0;
XLAL_CHECK ( XLALUserVarReadAllInput ( &should_exit, my_argc, my_argv ) == XLAL_SUCCESS, XLAL_EFUNC );
XLAL_CHECK ( should_exit == 0, XLAL_EFUNC );
/* ---------- test help-string generation */ /* ---------- test help-string generation */
CHAR *helpstr; CHAR *helpstr;
......
...@@ -111,7 +111,6 @@ ...@@ -111,7 +111,6 @@
// local types // local types
typedef struct typedef struct
{ {
BOOLEAN help; /**< Print this help/usage message */
INT4 randSeed; /**< allow user to specify random-number seed for reproducible noise-realizations */ INT4 randSeed; /**< allow user to specify random-number seed for reproducible noise-realizations */
INT4 Nruns; // number of repated timing 'runs' to average over in order to improve variance of result INT4 Nruns; // number of repated timing 'runs' to average over in order to improve variance of result
INT4 inAlign; // alignment of input vectors; default is sizeof(void*), i.e. no particular alignment INT4 inAlign; // alignment of input vectors; default is sizeof(void*), i.e. no particular alignment
...@@ -130,15 +129,15 @@ main ( int argc, char *argv[] ) ...@@ -130,15 +129,15 @@ main ( int argc, char *argv[] )
uvar->Nruns = 1; uvar->Nruns = 1;
uvar->inAlign = uvar->outAlign = sizeof(void*); uvar->inAlign = uvar->outAlign = sizeof(void*);
// ---------- register user-variable ---------- // ---------- register user-variable ----------
XLALRegisterUvarMember( help, BOOLEAN, 'h', HELP , "Print this help/usage message");
XLALRegisterUvarMember( randSeed, INT4, 's', OPTIONAL, "Random-number seed"); XLALRegisterUvarMember( randSeed, INT4, 's', OPTIONAL, "Random-number seed");
XLALRegisterUvarMember( Nruns, INT4, 'r', OPTIONAL, "Number of repeated timing 'runs' to average over (=improves variance)" ); XLALRegisterUvarMember( Nruns, INT4, 'r', OPTIONAL, "Number of repeated timing 'runs' to average over (=improves variance)" );
XLALRegisterUvarMember( inAlign, INT4, 'a', OPTIONAL, "Alignment of input vectors; default is sizeof(void*), i.e. no particular alignment" ); XLALRegisterUvarMember( inAlign, INT4, 'a', OPTIONAL, "Alignment of input vectors; default is sizeof(void*), i.e. no particular alignment" );
XLALRegisterUvarMember( outAlign, INT4, 'b', OPTIONAL, "Alignment of output vectors; default is sizeof(void*), i.e. no particular alignment" ); XLALRegisterUvarMember( outAlign, INT4, 'b', OPTIONAL, "Alignment of output vectors; default is sizeof(void*), i.e. no particular alignment" );
XLAL_CHECK ( XLALUserVarReadAllInput ( argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC ); BOOLEAN should_exit = 0;
if ( uvar->help ) { /* if help was requested, we're done */ XLAL_CHECK( XLALUserVarReadAllInput( &should_exit, argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC );
exit (0); if ( should_exit ) {
exit (1);
} }
srand ( uvar->randSeed ); srand ( uvar->randSeed );
......
...@@ -164,7 +164,6 @@ typedef struct { ...@@ -164,7 +164,6 @@ typedef struct {
* A structure that sores user input variables * A structure that sores user input variables
*/ */
typedef struct { typedef struct {
BOOLEAN help; /**< trigger output of help string */
CHAR *inputdir; /**< directory containing input frame files */ CHAR *inputdir; /**< directory containing input frame files */
CHAR *pattern; /**< the input frame file name pattern */ CHAR *pattern; /**< the input frame file name pattern */
CHAR *outputdir; /**< name of output directory */ CHAR *outputdir; /**< name of output directory */
...@@ -375,7 +374,6 @@ void ReadUserVars(LALStatus *status,int argc,char *argv[],UserInput_t *uvar,CHAR ...@@ -375,7 +374,6 @@ void ReadUserVars(LALStatus *status,int argc,char *argv[],UserInput_t *uvar,CHAR
uvar->goodxenon = 0; uvar->goodxenon = 0;
/* ---------- register all user-variables ---------- */ /* ---------- register all user-variables ---------- */
LALregBOOLUserStruct(status, help, 'h', UVAR_HELP, "Print this message");
LALregSTRINGUserStruct(status,inputdir, 'i', UVAR_REQUIRED, "The input frame directory"); LALregSTRINGUserStruct(status,inputdir, 'i', UVAR_REQUIRED, "The input frame directory");
LALregSTRINGUserStruct(status,pattern, 'p', UVAR_OPTIONAL, "The frame file name pattern"); LALregSTRINGUserStruct(status,pattern, 'p', UVAR_OPTIONAL, "The frame file name pattern");
LALregSTRINGUserStruct(status,outputdir, 'o', UVAR_REQUIRED, "The output frame file directory"); LALregSTRINGUserStruct(status,outputdir, 'o', UVAR_REQUIRED, "The output frame file directory");
...@@ -384,10 +382,9 @@ void ReadUserVars(LALStatus *status,int argc,char *argv[],UserInput_t *uvar,CHAR ...@@ -384,10 +382,9 @@ void ReadUserVars(LALStatus *status,int argc,char *argv[],UserInput_t *uvar,CHAR
LALregBOOLUserStruct(status, version, 'V', UVAR_SPECIAL, "Output code version"); LALregBOOLUserStruct(status, version, 'V', UVAR_SPECIAL, "Output code version");
/* do ALL cmdline and cfgfile handling */ /* do ALL cmdline and cfgfile handling */
LAL_CALL (LALUserVarReadAllInput(status->statusPtr, argc, argv), status->statusPtr); BOOLEAN should_exit = 0;
LAL_CALL (LALUserVarReadAllInput(status->statusPtr, &should_exit, argc, argv), status->statusPtr);
/* if help was requested, we're done here */ if (should_exit) exit(1);
if (uvar->help) exit(0);
if ((version_string = XLALGetVersionString(0)) == NULL) { if ((version_string = XLALGetVersionString(0)) == NULL) {
XLALPrintError("XLALGetVersionString(0) failed.\n"); XLALPrintError("XLALGetVersionString(0) failed.\n");
......
...@@ -97,7 +97,6 @@ typedef struct { ...@@ -97,7 +97,6 @@ typedef struct {
* A structure that sores user input variables * A structure that sores user input variables
*/ */
typedef struct { typedef struct {
BOOLEAN help; /**< trigger output of help string */
CHAR *inputfile; /**< input frame file name pattern */ CHAR *inputfile; /**< input frame file name pattern */
CHAR *channel; /**< the frame channel to read */ CHAR *channel; /**< the frame channel to read */
CHAR *outputfile; /**< name of output file */ CHAR *outputfile; /**< name of output file */
...@@ -244,17 +243,15 @@ void ReadUserVars(LALStatus *status,int argc,char *argv[],UserInput_t *uvar) ...@@ -244,17 +243,15 @@ void ReadUserVars(LALStatus *status,int argc,char *argv[],UserInput_t *uvar)
uvar->channel = NULL; uvar->channel = NULL;
/* ---------- register all user-variables ---------- */ /* ---------- register all user-variables ---------- */
LALregBOOLUserStruct(status, help, 'h', UVAR_HELP, "Print this message");
LALregSTRINGUserStruct(status,inputfile, 'i', UVAR_REQUIRED, "The input frame name pattern"); LALregSTRINGUserStruct(status,inputfile, 'i', UVAR_REQUIRED, "The input frame name pattern");
LALregSTRINGUserStruct(status,outputfile, 'o', UVAR_REQUIRED, "The output statistics file"); LALregSTRINGUserStruct(status,outputfile, 'o', UVAR_REQUIRED, "The output statistics file");
LALregSTRINGUserStruct(status,channel, 'c', UVAR_REQUIRED, "The frame channel to be read"); LALregSTRINGUserStruct(status,channel, 'c', UVAR_REQUIRED, "The frame channel to be read");
LALregBOOLUserStruct(status, version, 'V', UVAR_SPECIAL, "Output code version"); LALregBOOLUserStruct(status, version, 'V', UVAR_SPECIAL, "Output code version");
/* do ALL cmdline and cfgfile handling */ /* do ALL cmdline and cfgfile handling */
LAL_CALL (LALUserVarReadAllInput(status->statusPtr, argc, argv), status->statusPtr); BOOLEAN should_exit = 0;
LAL_CALL (LALUserVarReadAllInput(status->statusPtr, &should_exit, argc, argv), status->statusPtr);
/* if help was requested, we're done here */ if (should_exit) exit(1);
if (uvar->help) exit(0);
if ((version_string = XLALGetVersionString(0)) == NULL) { if ((version_string = XLALGetVersionString(0)) == NULL) {
XLALPrintError("XLALGetVersionString(0) failed.\n"); XLALPrintError("XLALGetVersionString(0) failed.\n");
......
...@@ -257,7 +257,6 @@ typedef struct { ...@@ -257,7 +257,6 @@ typedef struct {
* A structure that stores user input variables * A structure that stores user input variables
*/ */
typedef struct { typedef struct {
BOOLEAN help; /**< trigger output of help string */
CHAR *inputfile; /**< directory containing input FITS files */ CHAR *inputfile; /**< directory containing input FITS files */
CHAR *outputdir; /**< name of output directory */ CHAR *outputdir; /**< name of output directory */
REAL8 deltat; /**< the desired sampling time */ REAL8 deltat; /**< the desired sampling time */
...@@ -486,7 +485,6 @@ ReadUserVars( int argc,char *argv[], UserInput_t *uvar, CHAR *clargs) ...@@ -486,7 +485,6 @@ ReadUserVars( int argc,char *argv[], UserInput_t *uvar, CHAR *clargs)
uvar->deltat = MIN_DT; uvar->deltat = MIN_DT;
/* ---------- register all user-variables ---------- */ /* ---------- register all user-variables ---------- */
XLALRegisterUvarMember( help, BOOLEAN, 'h', HELP, "Print this message");
XLALRegisterUvarMember( inputfile, STRING, 'i', REQUIRED, "The input FITS file name"); XLALRegisterUvarMember( inputfile, STRING, 'i', REQUIRED, "The input FITS file name");
XLALRegisterUvarMember( outputdir, STRING, 'o', REQUIRED, "The output frame file directory name"); XLALRegisterUvarMember( outputdir, STRING, 'o', REQUIRED, "The output frame file directory name");
XLALRegisterUvarMember( deltat, REAL8, 't', OPTIONAL, "The output sampling time (in seconds)"); XLALRegisterUvarMember( deltat, REAL8, 't', OPTIONAL, "The output sampling time (in seconds)");
...@@ -494,10 +492,9 @@ ReadUserVars( int argc,char *argv[], UserInput_t *uvar, CHAR *clargs) ...@@ -494,10 +492,9 @@ ReadUserVars( int argc,char *argv[], UserInput_t *uvar, CHAR *clargs)
XLALRegisterUvarMember( version, BOOLEAN, 'V', SPECIAL, "Output code version"); XLALRegisterUvarMember( version, BOOLEAN, 'V', SPECIAL, "Output code version");
/* do ALL cmdline and cfgfile handling */ /* do ALL cmdline and cfgfile handling */
XLAL_CHECK ( XLALUserVarReadAllInput ( argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC ); BOOLEAN should_exit = 0;
XLAL_CHECK( XLALUserVarReadAllInput( &should_exit, argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC );
/* if help was requested, we're done here */ if ( should_exit ) { exit(1); }
if (uvar->help) { exit(0); }
if (uvar->version) { if (uvar->version) {
CHAR *version_string; CHAR *version_string;
......
...@@ -145,7 +145,6 @@ int main(INT4 argc, CHAR *argv[]) ...@@ -145,7 +145,6 @@ int main(INT4 argc, CHAR *argv[])
UINT4 k; UINT4 k;
/* user input variables */ /* user input variables */
BOOLEAN uvar_help = 0;
CHAR *uvar_nrDir = NULL; CHAR *uvar_nrDir = NULL;
CHAR *uvar_pattern = NULL; CHAR *uvar_pattern = NULL;
CHAR *uvar_nrGroup = NULL; CHAR *uvar_nrGroup = NULL;
...@@ -169,7 +168,6 @@ int main(INT4 argc, CHAR *argv[]) ...@@ -169,7 +168,6 @@ int main(INT4 argc, CHAR *argv[])
uvar_format = (CHAR *)LALCalloc(1, 256 * sizeof(CHAR)); uvar_format = (CHAR *)LALCalloc(1, 256 * sizeof(CHAR));
strcpy(uvar_format, "NINJA1"); strcpy(uvar_format, "NINJA1");
LAL_CALL(LALRegisterBOOLUserVar(&status, "help", 'h', UVAR_HELP, "Print this message", &uvar_help), &status);
LAL_CALL(LALRegisterSTRINGUserVar(&status, "datadir", 'D', UVAR_REQUIRED, "Directory with NR data", &uvar_nrDir), &status); LAL_CALL(LALRegisterSTRINGUserVar(&status, "datadir", 'D', UVAR_REQUIRED, "Directory with NR data", &uvar_nrDir), &status);
LAL_CALL(LALRegisterSTRINGUserVar(&status, "pattern", 0, UVAR_OPTIONAL, "Filename pattern", &uvar_pattern), &status); LAL_CALL(LALRegisterSTRINGUserVar(&status, "pattern", 0, UVAR_OPTIONAL, "Filename pattern", &uvar_pattern), &status);
...@@ -201,11 +199,10 @@ int main(INT4 argc, CHAR *argv[]) ...@@ -201,11 +199,10 @@ int main(INT4 argc, CHAR *argv[])
LAL_CALL(LALRegisterSTRINGUserVar(&status, "nr-group", 0, UVAR_OPTIONAL, "NR group list (default=all)", &uvar_nrGroup), &status); LAL_CALL(LALRegisterSTRINGUserVar(&status, "nr-group", 0, UVAR_OPTIONAL, "NR group list (default=all)", &uvar_nrGroup), &status);
/* read all command line variables */ /* read all command line variables */
LAL_CALL(LALUserVarReadAllInput(&status, argc, argv), &status); BOOLEAN should_exit = 0;
LAL_CALL(LALUserVarReadAllInput(&status, &should_exit, argc, argv), &status);
/* exit if help was required */ if (should_exit)
if (uvar_help) exit(1);
exit(0);
/* check for supported metadata format */ /* check for supported metadata format */
if (strcmp(uvar_format, "NINJA1") == 0); if (strcmp(uvar_format, "NINJA1") == 0);
......
...@@ -43,7 +43,6 @@ ...@@ -43,7 +43,6 @@
/* user input variables */ /* user input variables */
BOOLEAN uvar_help;
BOOLEAN uvar_version; /**< output version information */ BOOLEAN uvar_version; /**< output version information */