ATLAS Offline Software
Classes | Enumerations | Functions | Variables
cmdline.cxx File Reference
#include "CxxUtils/checker_macros.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include "cmdline.h"
Include dependency graph for cmdline.cxx:

Go to the source code of this file.

Classes

union  generic_value
 generic value variable More...
 
struct  generic_list
 holds temporary values for multiple options More...
 

Enumerations

enum  cmdline_parser_arg_type {
  ARG_NO, ARG_FLAG, ARG_STRING, ARG_INT,
  ARG_DOUBLE
}
 

Functions

void cmdline_parser_print_version (void)
 Print the version. More...
 
void cmdline_parser_print_help (void)
 Print the help. More...
 
void cmdline_parser_init (struct gengetopt_args_info *args_info)
 Initializes the passed gengetopt_args_info structure's fields (also set default values for options that have a default) More...
 
void cmdline_parser_params_init (struct cmdline_parser_params *params)
 Initializes all the fields a cmdline_parser_params structure to their default values. More...
 
struct cmdline_parser_paramscmdline_parser_params_create (void)
 Allocates dynamically a cmdline_parser_params structure and initializes all its fields to their default values. More...
 
int cmdline_parser_dump (FILE *outfile, struct gengetopt_args_info *args_info)
 Save the contents of the option struct into an already open FILE stream. More...
 
int cmdline_parser_file_save (const char *filename, struct gengetopt_args_info *args_info)
 Save the contents of the option struct into a (text) file. More...
 
void cmdline_parser_free (struct gengetopt_args_info *args_info)
 Deallocates the string fields of the gengetopt_args_info structure (but does not deallocate the structure itself) More...
 
int cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
 The command line parser. More...
 
int cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, struct cmdline_parser_params *params)
 The command line parser (version with additional parameters) More...
 
int cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
 The command line parser (version with additional parameters - deprecated) More...
 
int cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
 Checks that all the required options were specified. More...
 

Variables

 ATLAS_NO_CHECK_FILE_THREAD_SAFETY
 
const char * gengetopt_args_info_purpose = ""
 the purpose string of the program More...
 
const char * gengetopt_args_info_usage = "Usage: iLumiCalc.exe [OPTIONS]..."
 the usage string of the program More...
 
const char * gengetopt_args_info_description = ""
 
const char * gengetopt_args_info_help []
 all the lines making the help output More...
 

Enumeration Type Documentation

◆ cmdline_parser_arg_type

Enumerator
ARG_NO 
ARG_FLAG 
ARG_STRING 
ARG_INT 
ARG_DOUBLE 

Definition at line 67 of file cmdline.cxx.

67  {ARG_NO
68  , ARG_FLAG
69  , ARG_STRING
70  , ARG_INT
71  , ARG_DOUBLE

Function Documentation

◆ cmdline_parser()

int cmdline_parser ( int  argc,
char **  argv,
struct gengetopt_args_info args_info 
)

The command line parser.

Parameters
argcthe number of command line options
argvthe command line options
args_infothe structure where option information will be stored
Returns
0 if everything went fine, NON 0 if an error took place

Definition at line 656 of file cmdline.cxx.

657 {
658  return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
659 }

◆ cmdline_parser2()

int cmdline_parser2 ( int  argc,
char **  argv,
struct gengetopt_args_info args_info,
int  override,
int  initialize,
int  check_required 
)

The command line parser (version with additional parameters - deprecated)

Parameters
argcthe number of command line options
argvthe command line options
args_infothe structure where option information will be stored
overridewhether to override possibly already present options
initializewhether to initialize the option structure my_args_info
check_requiredwhether to check that all required options were provided
Returns
0 if everything went fine, NON 0 if an error took place
Deprecated:
use cmdline_parser_ext() instead

Definition at line 678 of file cmdline.cxx.

679 {
680  int result;
682 
683  params.override = override;
684  params.initialize = initialize;
685  params.check_required = check_required;
686  params.check_ambiguity = 0;
687  params.print_errors = 1;
688 
689  result = cmdline_parser_internal (argc, argv, args_info, &params, 0);
690 
691  if (result == EXIT_FAILURE)
692  {
693  cmdline_parser_free (args_info);
694  exit (EXIT_FAILURE);
695  }
696 
697  return result;
698 }

◆ cmdline_parser_dump()

int cmdline_parser_dump ( FILE *  outfile,
struct gengetopt_args_info args_info 
)

Save the contents of the option struct into an already open FILE stream.

Parameters
outfilethe stream where to dump options
args_infothe option struct to dump
Returns
0 if everything went fine, NON 0 if an error took place

Definition at line 416 of file cmdline.cxx.

417 {
418  int i = 0;
419 
420  if (!outfile)
421  {
422  fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
423  return EXIT_FAILURE;
424  }
425 
426  if (args_info->help_given)
427  write_into_file(outfile, "help", 0, 0 );
428  if (args_info->version_given)
429  write_into_file(outfile, "version", 0, 0 );
430  write_multiple_into_file(outfile, args_info->runnumber_given, "runnumber", args_info->runnumber_orig, 0);
431  write_multiple_into_file(outfile, args_info->lbstart_given, "lbstart", args_info->lbstart_orig, 0);
432  write_multiple_into_file(outfile, args_info->lbend_given, "lbend", args_info->lbend_orig, 0);
433  write_multiple_into_file(outfile, args_info->xml_given, "xml", args_info->xml_orig, 0);
434  if (args_info->xml_blacklist_given)
435  write_into_file(outfile, "xml_blacklist", args_info->xml_blacklist_orig, 0);
436  write_multiple_into_file(outfile, args_info->tag_given, "tag", args_info->tag_orig, 0);
437  write_multiple_into_file(outfile, args_info->root_given, "root", args_info->root_orig, 0);
438  if (args_info->tree_given)
439  write_into_file(outfile, "tree", args_info->tree_orig, 0);
440  if (args_info->d3pd_dir_given)
441  write_into_file(outfile, "d3pd_dir", args_info->d3pd_dir_orig, 0);
442  if (args_info->lumitag_given)
443  write_into_file(outfile, "lumitag", args_info->lumitag_orig, 0);
444  if (args_info->online_given)
445  write_into_file(outfile, "online", 0, 0 );
446  if (args_info->lumichannel_given)
447  write_into_file(outfile, "lumichannel", args_info->lumichannel_orig, 0);
448  if (args_info->lumimethod_given)
449  write_into_file(outfile, "lumimethod", args_info->lumimethod_orig, 0);
450  write_multiple_into_file(outfile, args_info->trigger_given, "trigger", args_info->trigger_orig, 0);
451  if (args_info->livetrigger_given)
452  write_into_file(outfile, "livetrigger", args_info->livetrigger_orig, 0);
453  if (args_info->lar_given)
454  write_into_file(outfile, "lar", 0, 0 );
455  if (args_info->lartag_given)
456  write_into_file(outfile, "lartag", args_info->lartag_orig, 0);
457  if (args_info->beamspot_given)
458  write_into_file(outfile, "beamspot", 0, 0 );
459  if (args_info->beamspottag_given)
460  write_into_file(outfile, "beamspottag", args_info->beamspottag_orig, 0);
461  if (args_info->scale_lumi_given)
462  write_into_file(outfile, "scale_lumi", args_info->scale_lumi_orig, 0);
463  if (args_info->xml_out_given)
464  write_into_file(outfile, "xml_out", args_info->xml_out_orig, 0);
465  if (args_info->xml_collisionlist_given)
466  write_into_file(outfile, "xml_collisionlist", 0, 0 );
467  if (args_info->plots_given)
468  write_into_file(outfile, "plots", 0, 0 );
469  if (args_info->verbose_given)
470  write_into_file(outfile, "verbose", 0, 0 );
471  if (args_info->quiet_given)
472  write_into_file(outfile, "quiet", 0, 0 );
473 
474 
475  i = EXIT_SUCCESS;
476  return i;
477 }

◆ cmdline_parser_ext()

int cmdline_parser_ext ( int  argc,
char **  argv,
struct gengetopt_args_info args_info,
struct cmdline_parser_params params 
)

The command line parser (version with additional parameters)

Parameters
argcthe number of command line options
argvthe command line options
args_infothe structure where option information will be stored
paramsadditional parameters for the parser
Returns
0 if everything went fine, NON 0 if an error took place

Definition at line 662 of file cmdline.cxx.

664 {
665  int result;
666  result = cmdline_parser_internal (argc, argv, args_info, params, 0);
667 
668  if (result == EXIT_FAILURE)
669  {
670  cmdline_parser_free (args_info);
671  exit (EXIT_FAILURE);
672  }
673 
674  return result;
675 }

◆ cmdline_parser_file_save()

int cmdline_parser_file_save ( const char *  filename,
struct gengetopt_args_info args_info 
)

Save the contents of the option struct into a (text) file.

This file can be read by the config file parser (if generated by gengetopt)

Parameters
filenamethe file where to save
args_infothe option struct to save
Returns
0 if everything went fine, NON 0 if an error took place

Definition at line 480 of file cmdline.cxx.

481 {
482  FILE *outfile;
483  int i = 0;
484 
485  outfile = fopen(filename, "w");
486 
487  if (!outfile)
488  {
489  fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
490  return EXIT_FAILURE;
491  }
492 
493  i = cmdline_parser_dump(outfile, args_info);
494  fclose (outfile);
495 
496  return i;
497 }

◆ cmdline_parser_free()

void cmdline_parser_free ( struct gengetopt_args_info args_info)

Deallocates the string fields of the gengetopt_args_info structure (but does not deallocate the structure itself)

Parameters
args_infothe structure to deallocate

Definition at line 500 of file cmdline.cxx.

501 {
502  cmdline_parser_release (args_info);
503 }

◆ cmdline_parser_init()

void cmdline_parser_init ( struct gengetopt_args_info args_info)

Initializes the passed gengetopt_args_info structure's fields (also set default values for options that have a default)

Parameters
args_infothe structure to initialize

Definition at line 252 of file cmdline.cxx.

253 {
254  clear_given (args_info);
255  clear_args (args_info);
256  init_args_info (args_info);
257 }

◆ cmdline_parser_params_create()

struct cmdline_parser_params* cmdline_parser_params_create ( void  )

Allocates dynamically a cmdline_parser_params structure and initializes all its fields to their default values.

Returns
the created and initialized cmdline_parser_params structure

Definition at line 273 of file cmdline.cxx.

274 {
275  struct cmdline_parser_params *params =
276  (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
278  return params;
279 }

◆ cmdline_parser_params_init()

void cmdline_parser_params_init ( struct cmdline_parser_params params)

Initializes all the fields a cmdline_parser_params structure to their default values.

Parameters
paramsthe structure to initialize

Definition at line 260 of file cmdline.cxx.

261 {
262  if (params)
263  {
264  params->override = 0;
265  params->initialize = 1;
266  params->check_required = 1;
267  params->check_ambiguity = 0;
268  params->print_errors = 1;
269  }
270 }

◆ cmdline_parser_print_help()

void cmdline_parser_print_help ( void  )

Print the help.

Definition at line 243 of file cmdline.cxx.

244 {
245  int i = 0;
246  print_help_common();
247  while (gengetopt_args_info_help[i])
248  printf("%s\n", gengetopt_args_info_help[i++]);
249 }

◆ cmdline_parser_print_version()

void cmdline_parser_print_version ( void  )

Print the version.

Definition at line 220 of file cmdline.cxx.

221 {
222  printf ("%s %s\n",
225 }

◆ cmdline_parser_required()

int cmdline_parser_required ( struct gengetopt_args_info args_info,
const char *  prog_name 
)

Checks that all the required options were specified.

Parameters
args_infothe structure to check
prog_namethe name of the program that will be used to print possible errors
Returns

Definition at line 701 of file cmdline.cxx.

702 {
703  int result = EXIT_SUCCESS;
704 
705  if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
706  result = EXIT_FAILURE;
707 
708  if (result == EXIT_FAILURE)
709  {
710  cmdline_parser_free (args_info);
711  exit (EXIT_FAILURE);
712  }
713 
714  return result;
715 }

Variable Documentation

◆ ATLAS_NO_CHECK_FILE_THREAD_SAFETY

ATLAS_NO_CHECK_FILE_THREAD_SAFETY

Definition at line 12 of file cmdline.cxx.

◆ gengetopt_args_info_description

const char* gengetopt_args_info_description = ""

Definition at line 31 of file cmdline.cxx.

◆ gengetopt_args_info_help

const char* gengetopt_args_info_help[]

all the lines making the help output

Definition at line 33 of file cmdline.cxx.

◆ gengetopt_args_info_purpose

const char* gengetopt_args_info_purpose = ""

the purpose string of the program

Definition at line 27 of file cmdline.cxx.

◆ gengetopt_args_info_usage

const char* gengetopt_args_info_usage = "Usage: iLumiCalc.exe [OPTIONS]..."

the usage string of the program

Definition at line 29 of file cmdline.cxx.

cmdline_parser_dump
int cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
Save the contents of the option struct into an already open FILE stream.
Definition: cmdline.cxx:416
gengetopt_args_info::help_given
unsigned int help_given
Whether help was given.
Definition: cmdline.h:129
gengetopt_args_info::d3pd_dir_orig
char * d3pd_dir_orig
Name of TDirectory in input ROOT file where Lumi string is stored original value given at command lin...
Definition: cmdline.h:83
gengetopt_args_info::xml_out_orig
char * xml_out_orig
Output XML file name original value given at command line.
Definition: cmdline.h:118
CMDLINE_PARSER_PACKAGE_NAME
#define CMDLINE_PARSER_PACKAGE_NAME
the complete program name (used for help and version)
Definition: cmdline.h:33
gengetopt_args_info::tag_given
unsigned int tag_given
Whether tag was given.
Definition: cmdline.h:136
ARG_NO
@ ARG_NO
Definition: cmdline.cxx:67
gengetopt_args_info::beamspot_given
unsigned int beamspot_given
Whether beamspot was given.
Definition: cmdline.h:148
get_generator_info.result
result
Definition: get_generator_info.py:21
gengetopt_args_info::lumitag_given
unsigned int lumitag_given
Whether lumitag was given.
Definition: cmdline.h:140
gengetopt_args_info::xml_blacklist_orig
char * xml_blacklist_orig
Input XML file of blacklist original value given at command line.
Definition: cmdline.h:67
gengetopt_args_info::trigger_given
unsigned int trigger_given
Whether trigger was given.
Definition: cmdline.h:144
gengetopt_args_info::tree_given
unsigned int tree_given
Whether tree was given.
Definition: cmdline.h:138
initialize
void initialize()
Definition: run_EoverP.cxx:894
cmdline_parser_free
void cmdline_parser_free(struct gengetopt_args_info *args_info)
Deallocates the string fields of the gengetopt_args_info structure (but does not deallocate the struc...
Definition: cmdline.cxx:500
get_generator_info.stderr
stderr
Definition: get_generator_info.py:40
gengetopt_args_info::lbstart_orig
char ** lbstart_orig
LumiBlock number begin original value given at command line.
Definition: cmdline.h:52
gengetopt_args_info::beamspottag_orig
char * beamspottag_orig
Online beamspot database tag original value given at command line.
Definition: cmdline.h:112
gengetopt_args_info::lartag_given
unsigned int lartag_given
Whether lartag was given.
Definition: cmdline.h:147
ARG_FLAG
@ ARG_FLAG
Definition: cmdline.cxx:68
gengetopt_args_info::lumitag_orig
char * lumitag_orig
Offline luminosity database tag original value given at command line.
Definition: cmdline.h:86
gengetopt_args_info::runnumber_orig
char ** runnumber_orig
Run number, range, or comma separated list, e.g.
Definition: cmdline.h:47
gengetopt_args_info::scale_lumi_orig
char * scale_lumi_orig
Scale luminosity with a constant value original value given at command line.
Definition: cmdline.h:115
gengetopt_args_info::verbose_given
unsigned int verbose_given
Whether verbose was given.
Definition: cmdline.h:154
gengetopt_args_info::version_given
unsigned int version_given
Whether version was given.
Definition: cmdline.h:130
gengetopt_args_info::root_given
unsigned int root_given
Whether root was given.
Definition: cmdline.h:137
gengetopt_args_info::lumichannel_orig
char * lumichannel_orig
Luminosity estimate method by value original value given at command line.
Definition: cmdline.h:91
gengetopt_args_info::tree_orig
char * tree_orig
Name of TTree in input ROOT file to which Lumi string is attached original value given at command lin...
Definition: cmdline.h:80
gengetopt_args_info::runnumber_given
unsigned int runnumber_given
Whether runnumber was given.
Definition: cmdline.h:131
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArCellNtuple.argv
argv
Definition: LArCellNtuple.py:152
gengetopt_args_info::lartag_orig
char * lartag_orig
LAr noise burst database tag original value given at command line.
Definition: cmdline.h:107
ARG_STRING
@ ARG_STRING
Definition: cmdline.cxx:69
TrigInDetValidation_Base.malloc
malloc
Definition: TrigInDetValidation_Base.py:132
gengetopt_args_info::lbstart_given
unsigned int lbstart_given
Whether lbstart was given.
Definition: cmdline.h:132
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
gengetopt_args_info::xml_orig
char ** xml_orig
Input XML file name original value given at command line.
Definition: cmdline.h:62
gengetopt_args_info::lumimethod_given
unsigned int lumimethod_given
Whether lumimethod was given.
Definition: cmdline.h:143
calibdata.exit
exit
Definition: calibdata.py:236
gengetopt_args_info::xml_blacklist_given
unsigned int xml_blacklist_given
Whether xml_blacklist was given.
Definition: cmdline.h:135
gengetopt_args_info::plots_given
unsigned int plots_given
Whether plots was given.
Definition: cmdline.h:153
gengetopt_args_info::xml_collisionlist_given
unsigned int xml_collisionlist_given
Whether xml_collisionlist was given.
Definition: cmdline.h:152
gengetopt_args_info::xml_out_given
unsigned int xml_out_given
Whether xml_out was given.
Definition: cmdline.h:151
gengetopt_args_info_help
const char * gengetopt_args_info_help[]
all the lines making the help output
Definition: cmdline.cxx:33
gengetopt_args_info::livetrigger_given
unsigned int livetrigger_given
Whether livetrigger was given.
Definition: cmdline.h:145
gengetopt_args_info::lbend_orig
char ** lbend_orig
LumiBlock number end original value given at command line.
Definition: cmdline.h:57
gengetopt_args_info::tag_orig
char ** tag_orig
Input TAG file name original value given at command line.
Definition: cmdline.h:70
gengetopt_args_info::quiet_given
unsigned int quiet_given
Whether quiet was given.
Definition: cmdline.h:155
gengetopt_args_info::scale_lumi_given
unsigned int scale_lumi_given
Whether scale_lumi was given.
Definition: cmdline.h:150
cmdline_parser_params_init
void cmdline_parser_params_init(struct cmdline_parser_params *params)
Initializes all the fields a cmdline_parser_params structure to their default values.
Definition: cmdline.cxx:260
gengetopt_args_info::lumimethod_orig
char * lumimethod_orig
Luminosity estimate method by string original value given at command line.
Definition: cmdline.h:94
cmdline_parser_arg_type
cmdline_parser_arg_type
Definition: cmdline.cxx:67
gengetopt_args_info::livetrigger_orig
char * livetrigger_orig
L1 Trigger used for livetime calculation original value given at command line.
Definition: cmdline.h:102
gengetopt_args_info::d3pd_dir_given
unsigned int d3pd_dir_given
Whether d3pd_dir was given.
Definition: cmdline.h:139
gengetopt_args_info::lbend_given
unsigned int lbend_given
Whether lbend was given.
Definition: cmdline.h:133
ARG_DOUBLE
@ ARG_DOUBLE
Definition: cmdline.cxx:71
gengetopt_args_info::online_given
unsigned int online_given
Whether online was given.
Definition: cmdline.h:141
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
gengetopt_args_info::xml_given
unsigned int xml_given
Whether xml was given.
Definition: cmdline.h:134
cmdline_parser_params
The additional parameters to pass to parser functions.
Definition: cmdline.h:161
gengetopt_args_info::lar_given
unsigned int lar_given
Whether lar was given.
Definition: cmdline.h:146
gengetopt_args_info::root_orig
char ** root_orig
Input ROOT file name original value given at command line.
Definition: cmdline.h:75
gengetopt_args_info::lumichannel_given
unsigned int lumichannel_given
Whether lumichannel was given.
Definition: cmdline.h:142
cmdline_parser2
int cmdline_parser2(int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
The command line parser (version with additional parameters - deprecated)
Definition: cmdline.cxx:678
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
ARG_INT
@ ARG_INT
Definition: cmdline.cxx:70
CMDLINE_PARSER_PACKAGE
#define CMDLINE_PARSER_PACKAGE
the program name (used for printing errors)
Definition: cmdline.h:28
cmdline_parser_params::check_required
int check_required
whether to check that all required options were provided (default 1)
Definition: cmdline.h:164
PrepareReferenceFile.outfile
outfile
Definition: PrepareReferenceFile.py:42
gengetopt_args_info::trigger_orig
char ** trigger_orig
Trigger chain name used for prescale calculation original value given at command line.
Definition: cmdline.h:97
CMDLINE_PARSER_VERSION
#define CMDLINE_PARSER_VERSION
the program version
Definition: cmdline.h:38
gengetopt_args_info::beamspottag_given
unsigned int beamspottag_given
Whether beamspottag was given.
Definition: cmdline.h:149