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

# Content
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 {"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 {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 flags.config = TString(optarg);
53 break;
54 case 'b':
55 flags.inputfile = TString(optarg);
56 break;
57 case 'c':
58 flags.outdir = TString(optarg);
59 break;
60 case 'd':
61 flags.debug = true;
62 break;
63 case 'e':
64 flags.mufakefile2011 = TString(optarg);
65 break;
66 case 'f':
67 flags.elefakefile2011 = TString(optarg);
68 break;
69 case 'g':
70 flags.mufakefile2012 = TString(optarg);
71 break;
72 case 'h':
73 flags.elefakefile2012 = TString(optarg);
74 break;
75 case 'i':
76 flags.faketype = TString(optarg);
77 break;
78 case 'j':
79 flags.efftype = TString(optarg);
80 break;
81 case 'k':
82 flags.uncert = TString(optarg);
83 break;
84 case 'l':
85 flags.extraArgs = TString(optarg);
86 break;
87 case 'm':
88 flags.plotWholeSample = true;
89 break;
90 case 'n':
91 flags.heavyFlavor = true;
92 break;
93 case 'o':
94 flags.ssof = true;
95 break;
96 case 'p':
97 flags.writessofratio = true;
98 break;
99 case 'q':
100 flags.plotAllCats = true;
101 break;
102 case 'r':
103 flags.makeFakeTuples = true;
104 break;
105 case 's':
106 flags.hiStatFakes = true;
107 break;
108 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 }