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

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
XLAL_CHECK ( help != NULL, XLAL_EINVAL );
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
LALUserVariable *ptr = &UVAR_vars;
while ( ptr->next != NULL )
......@@ -214,7 +218,7 @@ XLALRegisterUserVar ( void *cvar, /**< pointer to the actual C-variabe to link
// long-option name taken already?
XLAL_CHECK ( strcmp ( name, ptr->name ) != 0, XLAL_EINVAL, "Long-option name '--%s' already taken!\n", name );
// 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
......@@ -285,13 +289,19 @@ XLALDestroyUserVars ( void )
/**
* Parse command-line into UserVariable array
*
* If \p *should_exit is TRUE when this function returns, the
* caller should exit immediately.
*/
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 ( UVAR_vars.next != NULL, XLAL_EINVAL, "Internal error, no UVAR memory allocated. Did you register any user-variables?" );
*should_exit = 0;
LALUserVariable *ptr;
UINT4 pos;
......@@ -433,13 +443,19 @@ XLALUserVarReadCmdline ( int argc, char *argv[] )
* 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
*
* If \p *should_exit is TRUE when this function returns, the
* caller should exit immediately.
*/
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 ( 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;
XLAL_CHECK ( XLALParseDataFile ( &cfg, cfgfile ) == XLAL_SUCCESS, XLAL_EFUNC );
......@@ -556,9 +572,6 @@ XLALUserVarHelpString ( const CHAR *progname )
if ( ptr->category == UVAR_CATEGORY_REQUIRED ) {
strcpy (defaultstr, "REQUIRED");
}
else if ( ptr->category == UVAR_CATEGORY_HELP ) {
strcpy ( defaultstr, "");
}
else // write the current default-value into a string
{
CHAR *valstr;
......@@ -649,19 +662,40 @@ XLALUserVarHelpString ( const CHAR *progname )
/**
* 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
*
* If \p *should_exit is TRUE when this function returns, the
* program should exit immediately with a non-zero status.
*/
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 ( argv != 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?" );
*should_exit = 0;
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 ?
CHAR* cfgfile_name = NULL;
for ( INT4 i = 1; i < argc; i++ )
......@@ -681,26 +715,24 @@ XLALUserVarReadAllInput ( int argc, char *argv[] )
// ---------- if config-file specified, read from that first
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);
}
// ---------- 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 ----------
BOOLEAN skipCheckRequired = FALSE;
LALUserVariable *ptr = &UVAR_vars;
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
if ( (ptr->category == UVAR_CATEGORY_SPECIAL) && ptr->was_set ) {
......@@ -874,10 +906,10 @@ LALDestroyUserVars (LALStatus *status)
/** \deprecated use XLALUserVarReadCmdline() instead */
void
LALUserVarReadCmdline (LALStatus *status, int argc, char *argv[])
LALUserVarReadCmdline (LALStatus *status, BOOLEAN *should_exit, int argc, char *argv[])
{
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 );
ABORT ( status, USERINPUTH_EXLAL, USERINPUTH_MSGEXLAL );
}
......@@ -898,10 +930,10 @@ LALUserVarCheckRequired (LALStatus *status)
/** \deprecated use XLALUserVarReadAllInput() instead */
void
LALUserVarReadAllInput (LALStatus *status, int argc, char *argv[])
LALUserVarReadAllInput (LALStatus *status, BOOLEAN *should_exit, int argc, char *argv[])
{
INITSTATUS(status);
if ( XLALUserVarReadAllInput ( argc, argv ) != XLAL_SUCCESS ) {
if ( XLALUserVarReadAllInput ( should_exit, argc, argv ) != XLAL_SUCCESS ) {
XLALPrintError ( "XLALUserVarReadAllInput() failed with code %d\n", xlalErrno );
ABORT ( status, USERINPUTH_EXLAL, USERINPUTH_MSGEXLAL );
}
......@@ -1031,11 +1063,12 @@ LALRegisterLISTUserVar (LALStatus *status,
/** \deprecated use XLALUserVarReadCfgfile() instead */
void
LALUserVarReadCfgfile (LALStatus *status,
BOOLEAN *should_exit,
const CHAR *cfgfile) /* name of config-file */
{
INITSTATUS(status);
if ( XLALUserVarReadCfgfile ( cfgfile ) != XLAL_SUCCESS ) {
if ( XLALUserVarReadCfgfile ( should_exit, cfgfile ) != XLAL_SUCCESS ) {
ABORT ( status, USERINPUTH_EXLAL, USERINPUTH_MSGEXLAL );
}
RETURN (status);
......
......@@ -163,7 +163,6 @@ typedef enum {
UVAR_CATEGORY_OPTIONAL, ///< optional
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_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
......@@ -174,7 +173,6 @@ typedef enum {
// ***** the following are provided only for backwards compatibility until full transition to new XLAL interface *****
#define UVAR_OPTIONAL UVAR_CATEGORY_OPTIONAL
#define UVAR_REQUIRED UVAR_CATEGORY_REQUIRED
#define UVAR_HELP UVAR_CATEGORY_HELP
#define UVAR_DEVELOPER UVAR_CATEGORY_DEVELOPER
#define UVAR_SPECIAL UVAR_CATEGORY_SPECIAL
// **********
......@@ -192,10 +190,10 @@ typedef enum {
/* Function prototypes */
void XLALDestroyUserVars( void );
int XLALUserVarReadCmdline (int argc, char *argv[]);
int XLALUserVarReadCfgfile ( const CHAR *cfgfile );
int XLALUserVarReadCmdline( BOOLEAN *should_exit, int argc, char *argv[] );
int XLALUserVarReadCfgfile( BOOLEAN *should_exit, const CHAR *cfgfile );
CHAR *XLALUserVarHelpString ( const CHAR *progname );
int XLALUserVarReadAllInput ( int argc, char *argv[] );
int XLALUserVarReadAllInput( BOOLEAN *should_exit, int argc, char *argv[] );
int XLALUserVarCheckRequired( void );
int XLALUserVarWasSet (const void *cvar);
CHAR * XLALUserVarGetLog ( UserVarLogFormat format );
......@@ -291,9 +289,9 @@ void LALRegisterLISTUserVar (LALStatus *, const CHAR *name, CHAR optchar, UserVa
void LALDestroyUserVars (LALStatus *);
void LALUserVarReadAllInput(LALStatus *, int argc, char *argv[]);
void LALUserVarReadCmdline (LALStatus *, int argc, char *argv[]);
void LALUserVarReadCfgfile (LALStatus *, const CHAR *cfgfile);
void LALUserVarReadAllInput(LALStatus *, BOOLEAN *should_exit, int argc, char *argv[]);
void LALUserVarReadCmdline (LALStatus *, BOOLEAN *should_exit, int argc, char *argv[]);
void LALUserVarReadCfgfile (LALStatus *, BOOLEAN *should_exit, const CHAR *cfgfile);
void LALUserVarHelpString (LALStatus *, CHAR **helpstring, const CHAR *progname);
void LALUserVarCheckRequired (LALStatus *);
......
......@@ -83,7 +83,9 @@ main(int argc, char *argv[])
XLAL_CHECK ( XLALRegisterUvarMember( longInt, INT8, 0, REQUIRED, "Testing INT8 argument") == XLAL_SUCCESS, XLAL_EFUNC );
/* ---------- 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 */
CHAR *helpstr;
......
......@@ -111,7 +111,6 @@
// local types
typedef struct
{
BOOLEAN help; /**< Print this help/usage message */
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 inAlign; // alignment of input vectors; default is sizeof(void*), i.e. no particular alignment
......@@ -130,15 +129,15 @@ main ( int argc, char *argv[] )
uvar->Nruns = 1;
uvar->inAlign = uvar->outAlign = sizeof(void*);
// ---------- register user-variable ----------
XLALRegisterUvarMember( help, BOOLEAN, 'h', HELP , "Print this help/usage message");
XLALRegisterUvarMember( randSeed, INT4, 's', OPTIONAL, "Random-number seed");
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( 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 );
if ( uvar->help ) { /* if help was requested, we're done */
exit (0);
BOOLEAN should_exit = 0;
XLAL_CHECK( XLALUserVarReadAllInput( &should_exit, argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC );
if ( should_exit ) {
exit (1);
}
srand ( uvar->randSeed );
......
......@@ -164,7 +164,6 @@ typedef struct {
* A structure that sores user input variables
*/
typedef struct {
BOOLEAN help; /**< trigger output of help string */
CHAR *inputdir; /**< directory containing input frame files */
CHAR *pattern; /**< the input frame file name pattern */
CHAR *outputdir; /**< name of output directory */
......@@ -375,7 +374,6 @@ void ReadUserVars(LALStatus *status,int argc,char *argv[],UserInput_t *uvar,CHAR
uvar->goodxenon = 0;
/* ---------- 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,pattern, 'p', UVAR_OPTIONAL, "The frame file name pattern");
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
LALregBOOLUserStruct(status, version, 'V', UVAR_SPECIAL, "Output code version");
/* do ALL cmdline and cfgfile handling */
LAL_CALL (LALUserVarReadAllInput(status->statusPtr, argc, argv), status->statusPtr);
/* if help was requested, we're done here */
if (uvar->help) exit(0);
BOOLEAN should_exit = 0;
LAL_CALL (LALUserVarReadAllInput(status->statusPtr, &should_exit, argc, argv), status->statusPtr);
if (should_exit) exit(1);
if ((version_string = XLALGetVersionString(0)) == NULL) {
XLALPrintError("XLALGetVersionString(0) failed.\n");
......
......@@ -97,7 +97,6 @@ typedef struct {
* A structure that sores user input variables
*/
typedef struct {
BOOLEAN help; /**< trigger output of help string */
CHAR *inputfile; /**< input frame file name pattern */
CHAR *channel; /**< the frame channel to read */
CHAR *outputfile; /**< name of output file */
......@@ -244,17 +243,15 @@ void ReadUserVars(LALStatus *status,int argc,char *argv[],UserInput_t *uvar)
uvar->channel = NULL;
/* ---------- 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,outputfile, 'o', UVAR_REQUIRED, "The output statistics file");
LALregSTRINGUserStruct(status,channel, 'c', UVAR_REQUIRED, "The frame channel to be read");
LALregBOOLUserStruct(status, version, 'V', UVAR_SPECIAL, "Output code version");
/* do ALL cmdline and cfgfile handling */
LAL_CALL (LALUserVarReadAllInput(status->statusPtr, argc, argv), status->statusPtr);
/* if help was requested, we're done here */
if (uvar->help) exit(0);
BOOLEAN should_exit = 0;
LAL_CALL (LALUserVarReadAllInput(status->statusPtr, &should_exit, argc, argv), status->statusPtr);
if (should_exit) exit(1);
if ((version_string = XLALGetVersionString(0)) == NULL) {
XLALPrintError("XLALGetVersionString(0) failed.\n");
......
......@@ -257,7 +257,6 @@ typedef struct {
* A structure that stores user input variables
*/
typedef struct {
BOOLEAN help; /**< trigger output of help string */
CHAR *inputfile; /**< directory containing input FITS files */
CHAR *outputdir; /**< name of output directory */
REAL8 deltat; /**< the desired sampling time */
......@@ -486,7 +485,6 @@ ReadUserVars( int argc,char *argv[], UserInput_t *uvar, CHAR *clargs)
uvar->deltat = MIN_DT;
/* ---------- register all user-variables ---------- */
XLALRegisterUvarMember( help, BOOLEAN, 'h', HELP, "Print this message");
XLALRegisterUvarMember( inputfile, STRING, 'i', REQUIRED, "The input FITS file name");
XLALRegisterUvarMember( outputdir, STRING, 'o', REQUIRED, "The output frame file directory name");
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)
XLALRegisterUvarMember( version, BOOLEAN, 'V', SPECIAL, "Output code version");
/* do ALL cmdline and cfgfile handling */
XLAL_CHECK ( XLALUserVarReadAllInput ( argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC );
/* if help was requested, we're done here */
if (uvar->help) { exit(0); }
BOOLEAN should_exit = 0;
XLAL_CHECK( XLALUserVarReadAllInput( &should_exit, argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC );
if ( should_exit ) { exit(1); }
if (uvar->version) {
CHAR *version_string;
......
......@@ -145,7 +145,6 @@ int main(INT4 argc, CHAR *argv[])
UINT4 k;
/* user input variables */
BOOLEAN uvar_help = 0;
CHAR *uvar_nrDir = NULL;
CHAR *uvar_pattern = NULL;
CHAR *uvar_nrGroup = NULL;
......@@ -169,7 +168,6 @@ int main(INT4 argc, CHAR *argv[])
uvar_format = (CHAR *)LALCalloc(1, 256 * sizeof(CHAR));
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, "pattern", 0, UVAR_OPTIONAL, "Filename pattern", &uvar_pattern), &status);
......@@ -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);
/* read all command line variables */
LAL_CALL(LALUserVarReadAllInput(&status, argc, argv), &status);
/* exit if help was required */
if (uvar_help)
exit(0);
BOOLEAN should_exit = 0;
LAL_CALL(LALUserVarReadAllInput(&status, &should_exit, argc, argv), &status);
if (should_exit)
exit(1);
/* check for supported metadata format */
if (strcmp(uvar_format, "NINJA1") == 0);
......
......@@ -43,7 +43,6 @@
/* user input variables */
BOOLEAN uvar_help;
BOOLEAN uvar_version; /**< output version information */
BOOLEAN uvar_averagePsi;
BOOLEAN uvar_averageIota;
......@@ -218,11 +217,10 @@ int main(int argc, char *argv[]){
LAL_CALL (initUserVars(&status), &status);
/* read all command line variables */
LAL_CALL( LALUserVarReadAllInput(&status, argc, argv), &status);
/* exit if help was required */
if (uvar_help)
exit(0);
BOOLEAN should_exit = 0;
LAL_CALL( LALUserVarReadAllInput(&status, &should_exit, argc, argv), &status);
if (should_exit)
exit(1);
if ( (VCSInfoString = XLALGetVersionString(0)) == NULL ) {
......@@ -1722,7 +1720,6 @@ void initUserVars (LALStatus *status)
uvar_maxlag = 0;
uvar_help = FALSE;
uvar_version = FALSE;
uvar_averagePsi = TRUE;
uvar_averageIota = TRUE;
......@@ -1775,10 +1772,6 @@ void initUserVars (LALStatus *status)
strcpy(uvar_skyfile,SKYFILE);
/* register user input variables */
LALRegisterBOOLUserVar( status->statusPtr, "help",
'h', UVAR_HELP,
"Print this message",
&uvar_help);
LALRegisterBOOLUserVar( status->statusPtr, "version",
'V', UVAR_SPECIAL,
"Output version information",
......
......@@ -51,7 +51,6 @@
/* user input variables */
typedef struct{
BOOLEAN help; /**< if the user wants a help message */
INT4 startTime; /**< desired start GPS time of search */
INT4 endTime; /**< desired end GPS time */
REAL8 maxLag; /**< maximum lag time in seconds between SFTs in correlation */
......@@ -167,13 +166,13 @@ int main(int argc, char *argv[]){
}
/* read user input from the command line or config file */
if ( XLALUserVarReadAllInput ( argc, argv ) != XLAL_SUCCESS ) {
BOOLEAN should_exit = 0;
if ( XLALUserVarReadAllInput ( &should_exit, argc, argv ) != XLAL_SUCCESS ) {
LogPrintf ( LOG_CRITICAL, "%s: XLALUserVarReadAllInput() failed with errno=%d\n", __func__, xlalErrno );
XLAL_ERROR( XLAL_EFUNC );
}
if (uvar.help) /* if help was requested, then exit */
return 0;
if (should_exit)
return EXIT_FAILURE;
CHAR *VCSInfoString = XLALGetVersionString(0); /**<LAL + LALapps Vsersion string*/
/*If the version information was requested, output it and exit*/
......@@ -798,7 +797,6 @@ int XLALInitUserVars (UserInput_t *uvar)
{
/* initialize with some defaults */
uvar->help = FALSE;
uvar->maxLag = 0.0;
uvar->inclAutoCorr = FALSE;
uvar->fStart = 100.0;
......@@ -838,7 +836,6 @@ int XLALInitUserVars (UserInput_t *uvar)
uvar->version = FALSE;
/* register user-variables */
XLALRegisterUvarMember( help, BOOLEAN, 'h', HELP, "Print this message");
XLALRegisterUvarMember( startTime, INT4, 0, REQUIRED, "Desired start time of analysis in GPS seconds");
XLALRegisterUvarMember( endTime, INT4, 0, REQUIRED, "Desired end time of analysis in GPS seconds");
XLALRegisterUvarMember( maxLag, REAL8, 0, OPTIONAL, "Maximum lag time in seconds between SFTs in correlation");
......
......@@ -74,7 +74,6 @@ int main(int argc, char **argv)
REAL8 NumBinsAvg =0;
REAL8 timebaseline =0;
BOOLEAN help = 0;
CHAR *SFTpatt = NULL;
CHAR *IFO = NULL;
INT4 startGPS = 0;
......@@ -99,7 +98,6 @@ int main(int argc, char **argv)
/*========================================================================================================================*/
LAL_CALL(LALRegisterBOOLUserVar (&status, "help", 'h', UVAR_HELP, "Print this help message", &help ), &status);
LAL_CALL(LALRegisterSTRINGUserVar(&status, "SFTs", 'p', UVAR_REQUIRED, "SFT location/pattern", &SFTpatt ), &status);
LAL_CALL(LALRegisterSTRINGUserVar(&status, "IFO", 'I', UVAR_REQUIRED, "Detector", &IFO ), &status);
LAL_CALL(LALRegisterINTUserVar (&status, "startGPS", 's', UVAR_REQUIRED, "Starting GPS time", &startGPS ), &status);
......@@ -115,9 +113,10 @@ int main(int argc, char **argv)
LAL_CALL(LALRegisterSTRINGUserVar(&status, "earthFile", 'y', UVAR_OPTIONAL, "earth .dat file", &earthFile ), &status);
LAL_CALL(LALRegisterSTRINGUserVar(&status, "sunFile", 'z', UVAR_OPTIONAL, "sun .dat file", &sunFile ), &status);
LAL_CALL(LALUserVarReadAllInput(&status, argc, argv), &status);
if (help)
return(0);
BOOLEAN should_exit = 0;
LAL_CALL(LALUserVarReadAllInput(&status, &should_exit, argc, argv), &status);
if (should_exit)
return(1);
startTime.gpsSeconds = startGPS;/*cg; startTime is a structure, and gpsSeconds is a member of that structure*/
startTime.gpsNanoSeconds = 0;/*cg; gps NanoSeconds is also a member of the startTime structure */
......
......@@ -72,8 +72,6 @@ extern int vrbflg; /**< defined in lalapps.c */
/* ----- User-variables: can be set from config-file or command-line */
typedef struct {
BOOLEAN help; /**< trigger output of help string */
CHAR *inputSFTs; /**< SFT input-files to use */
CHAR *outputLFT; /**< output ('Long Fourier Transform') file to write total-time Fourier transform into */
INT4 minStartTime; /**< limit start-time of input SFTs to use */
......@@ -119,10 +117,10 @@ int main(int argc, char *argv[])
LAL_CALL ( LALInitUserVars(&status, &uvar), &status);
/* do ALL cmdline and cfgfile handling */
LAL_CALL (LALUserVarReadAllInput(&status, argc, argv), &status);
if (uvar.help) /* if help was requested, we're done here */
exit (0);
BOOLEAN should_exit = 0;
LAL_CALL (LALUserVarReadAllInput(&status, &should_exit, argc, argv), &status);
if (should_exit)
exit (1);
if ( uvar.version )
{
......@@ -233,16 +231,12 @@ LALInitUserVars ( LALStatus *status, UserInput_t *uvar )
INITSTATUS(status);
ATTATCHSTATUSPTR (status);
uvar->help = 0;
uvar->minStartTime = 0;
uvar->maxEndTime = LAL_INT4_MAX;
uvar->upsampling = 1;
/* register all our user-variables */
LALregBOOLUserStruct(status, help, 'h', UVAR_HELP, "Print this message");
LALregSTRINGUserStruct(status,inputSFTs, 'D', UVAR_OPTIONAL, "File-pattern specifying input SFT-files");
LALregSTRINGUserStruct(status,outputLFT, 'o', UVAR_OPTIONAL, "Output 'Long Fourier Transform' (LFT) file" );
......
......@@ -67,8 +67,6 @@ const REAL8 max_psi = LAL_PI_4;
int main(int argc, char *argv[]) {
LALStatus status = blank_status;
BOOLEAN help = FALSE;
REAL8 alpha = 0.0;
REAL8 alpha_band = 0.0;
REAL8 delta = 0.0;
......@@ -120,7 +118,6 @@ int main(int argc, char *argv[]) {
lal_errhandler = LAL_ERR_EXIT;
/* Register command line arguments */
LAL_CALL(LALRegisterBOOLUserVar (&status, "help", 'h', UVAR_HELP, "Print this help message", &help), &status);
LAL_CALL(LALRegisterREALUserVar (&status, "alpha", 'a', UVAR_REQUIRED, "Right ascension in radians", &alpha), &status);
LAL_CALL(LALRegisterREALUserVar (&status, "alpha-band", 'z', UVAR_OPTIONAL, "Right ascension band", &alpha), &status);
LAL_CALL(LALRegisterREALUserVar (&status, "delta", 'd', UVAR_REQUIRED, "Declination in radians", &delta), &status);
......@@ -148,9 +145,10 @@ int main(int argc, char *argv[]) {
LAL_CALL(LALRegisterREALUserVar (&status, "initial-h0", 0 , UVAR_DEVELOPER,"Initial guess of h0 (default: automatic)", &initial_h0), &status);
/* Get command line arguments */
LAL_CALL(LALUserVarReadAllInput(&status, argc, argv), &status);
if (help)
return EXIT_SUCCESS;
BOOLEAN should_exit = 0;
LAL_CALL(LALUserVarReadAllInput(&status, &should_exit, argc, argv), &status);
if (should_exit)
return EXIT_FAILURE;
/* Load the mismatch PDF histogram if available */
if (LALUserVarWasSet(&mism_hist_file)) {
......
......@@ -251,7 +251,6 @@ typedef struct {
CHAR *skyRegion; /**< list of skypositions defining a search-polygon */
CHAR *DataFiles; /**< glob-pattern for SFT data-files to use */
BOOLEAN help; /**< output help-string */
CHAR *outputLogfile; /**< write a log-file */
CHAR *outputFstat; /**< filename to output Fstatistic in */
CHAR *outputLoudest; /**< filename for loudest F-candidate plus parameter estimation */
......@@ -379,10 +378,10 @@ int main(int argc,char *argv[])
XLAL_CHECK_MAIN ( (GV.VCSInfoString = XLALGetVersionString(0)) != NULL, XLAL_EFUNC );
/* do ALL cmdline and cfgfile handling */
XLAL_CHECK_MAIN ( XLALUserVarReadAllInput(argc, argv) == XLAL_SUCCESS, XLAL_EFUNC );
if (uvar.help) { /* if help was requested, we're done here */
exit (0);
BOOLEAN should_exit = 0;
XLAL_CHECK_MAIN( XLALUserVarReadAllInput( &should_exit, argc, argv ) == XLAL_SUCCESS, XLAL_EFUNC );
if ( should_exit ) {
exit (1);
}
if ( uvar.version )
......@@ -922,7 +921,6 @@ initUserVars ( UserInput_t *uvar )
uvar->metricMismatch = 0.02;
uvar->help = FALSE;
uvar->version = FALSE;