ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitHzz4l/NonMCBackground/src/FOArgs.cc
Revision: 1.6
Committed: Tue Oct 23 11:20:50 2012 UTC (12 years, 6 months ago) by dkralph
Content type: text/plain
Branch: MAIN
CVS Tags: compiled, HEAD
Changes since 1.5: +39 -35 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 dkralph 1.1 #include <stdio.h>
2     #include <stdlib.h>
3     #include <getopt.h>
4    
5     #include "FOArgs.h"
6    
7     void parse_foargs( int argc, char** argv, FOFlags &flags ) {
8    
9     int c;
10     int digit_optind = 0;
11    
12     while (1) {
13     int this_option_optind = optind ? optind : 1;
14     int option_index = 0;
15     static struct option long_options[] = {
16 dkralph 1.6 {"config" , 1, 0, 'a'},
17     {"inputfile" , 1, 0, 'b'},
18     {"outdir" , 1, 0, 'c'},
19     {"debug" , 0, 0, 'd'},
20     {"mufakefile2011" , 1, 0, 'e'},
21     {"elefakefile2011" , 1, 0, 'f'},
22     {"mufakefile2012" , 1, 0, 'g'},
23     {"elefakefile2012" , 1, 0, 'h'},
24     {"faketype" , 1, 0, 'i'},
25     {"efftype" , 1, 0, 'j'},
26     {"uncert" , 1, 0, 'k'},
27     {"extraArgs" , 1, 0, 'l'},
28     {"plotWholeSample" , 0, 0, 'm'},
29     {"heavyFlavor" , 0, 0, 'n'},
30     {"ssof" , 0, 0, 'o'},
31     {"writessofratio" , 0, 0, 'p'},
32     {"plotAllCats" , 0, 0, 'q'},
33     {"makeFakeTuples" , 0, 0, 'r'},
34     {"hiStatFakes" , 0, 0, 's'},
35 dkralph 1.1 {0, 0, 0, 0}
36     };
37    
38     c = getopt_long (argc, argv, "a:b:",
39     long_options, &option_index);
40     if (c == -1)
41     break;
42    
43     switch (c) {
44     case 0:
45     printf ("option %s", long_options[option_index].name);
46     if (optarg)
47     printf (" with arg %s", optarg);
48     printf ("\n");
49     break;
50    
51     case 'a':
52 dkralph 1.6 flags.config = TString(optarg);
53 dkralph 1.1 break;
54     case 'b':
55 dkralph 1.6 flags.inputfile = TString(optarg);
56 dkralph 1.1 break;
57     case 'c':
58 dkralph 1.2 flags.outdir = TString(optarg);
59     break;
60     case 'd':
61 dkralph 1.6 flags.debug = true;
62 dkralph 1.2 break;
63     case 'e':
64 dkralph 1.6 flags.mufakefile2011 = TString(optarg);
65 dkralph 1.2 break;
66     case 'f':
67 dkralph 1.6 flags.elefakefile2011 = TString(optarg);
68 dkralph 1.2 break;
69     case 'g':
70 dkralph 1.6 flags.mufakefile2012 = TString(optarg);
71 dkralph 1.2 break;
72     case 'h':
73 dkralph 1.6 flags.elefakefile2012 = TString(optarg);
74 dkralph 1.2 break;
75     case 'i':
76 dkralph 1.6 flags.faketype = TString(optarg);
77 dkralph 1.2 break;
78     case 'j':
79 dkralph 1.6 flags.efftype = TString(optarg);
80 dkralph 1.2 break;
81     case 'k':
82 dkralph 1.6 flags.uncert = TString(optarg);
83 dkralph 1.2 break;
84     case 'l':
85 dkralph 1.6 flags.extraArgs = TString(optarg);
86 dkralph 1.2 break;
87     case 'm':
88 dkralph 1.6 flags.plotWholeSample = true;
89 dkralph 1.1 break;
90 dkralph 1.3 case 'n':
91 dkralph 1.6 flags.heavyFlavor = true;
92 dkralph 1.3 break;
93     case 'o':
94 dkralph 1.6 flags.ssof = true;
95 dkralph 1.3 break;
96 dkralph 1.4 case 'p':
97 dkralph 1.6 flags.writessofratio = true;
98 dkralph 1.4 break;
99 dkralph 1.5 case 'q':
100 dkralph 1.6 flags.plotAllCats = true;
101 dkralph 1.5 break;
102     case 'r':
103 dkralph 1.6 flags.makeFakeTuples = true;
104     break;
105     case 's':
106     flags.hiStatFakes = true;
107 dkralph 1.5 break;
108 dkralph 1.1 case '2':
109     if (digit_optind != 0 && digit_optind != this_option_optind)
110     printf ("digits occur in two different argv-elements.\n");
111     digit_optind = this_option_optind;
112     printf ("option %c\n", c);
113     break;
114    
115    
116     case '?':
117     break;
118    
119     default:
120     printf ("?? getopt returned character code 0%o ??\n", c);
121     }
122     }
123    
124     if (optind < argc) {
125     printf ("non-option ARGV-elements: ");
126     while (optind < argc)
127     printf ("%s ", argv[optind++]);
128     printf ("\n");
129     }
130    
131    
132     }