| 1 | /* | 
| 2 | File autogenerated by gengetopt version 2.22.4 | 
| 3 | generated with the following command: | 
| 4 | gengetopt --file-name=DynamicPropsCmd --unamed-opts | 
| 5 |  | 
| 6 | The developers of gengetopt consider the fixed text that goes in all | 
| 7 | gengetopt output files to be in the public domain: | 
| 8 | we make no copyright claims on it. | 
| 9 | */ | 
| 10 |  | 
| 11 | /* If we use autoconf.  */ | 
| 12 | #ifdef HAVE_CONFIG_H | 
| 13 | #include "config.h" | 
| 14 | #endif | 
| 15 |  | 
| 16 | #include <stdio.h> | 
| 17 | #include <stdlib.h> | 
| 18 | #include <string.h> | 
| 19 |  | 
| 20 | #ifndef FIX_UNUSED | 
| 21 | #define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */ | 
| 22 | #endif | 
| 23 |  | 
| 24 | #include <getopt.h> | 
| 25 |  | 
| 26 | #include "DynamicPropsCmd.h" | 
| 27 |  | 
| 28 | const char *gengetopt_args_info_purpose = ""; | 
| 29 |  | 
| 30 | const char *gengetopt_args_info_usage = "Usage: DynamicProps [OPTIONS]... [FILES]..."; | 
| 31 |  | 
| 32 | const char *gengetopt_args_info_description = ""; | 
| 33 |  | 
| 34 | const char *gengetopt_args_info_help[] = { | 
| 35 | "  -h, --help                    Print help and exit", | 
| 36 | "  -V, --version                 Print version and exit", | 
| 37 | "  -i, --input=filename          input dump file", | 
| 38 | "  -o, --output=filename         output file name", | 
| 39 | "      --sele1=selection script  select first stuntdouble set", | 
| 40 | "      --sele2=selection script  select second stuntdouble set (if sele2 is not \n                                  set, use script from sele1)", | 
| 41 | "      --order=INT               Lengendre Polynomial Order", | 
| 42 | "  -z, --nzbins=INT              Number of Z bins  (default=`100')", | 
| 43 | "  -m, --memory=memory specification\n                                Available memory (defaults to 2G)  \n                                  (default=`2G')", | 
| 44 | "\n Group: dynamicProps\n   an option of this group is required", | 
| 45 | "  -s, --selecorr                selection correlation function", | 
| 46 | "  -r, --rcorr                   rmsd", | 
| 47 | "  -v, --vcorr                   velocity correlation function", | 
| 48 | "  -d, --dcorr                   dipole correlation function", | 
| 49 | "  -l, --lcorr                   Lengendre correlation function", | 
| 50 | "      --lcorrZ                  Lengendre correlation function binned by Z", | 
| 51 | "      --cohZ                    Lengendre correlation function for OH bond \n                                  vectors binned by Z", | 
| 52 | "  -M, --sdcorr                  System dipole correlation function", | 
| 53 | "      --r_rcorr                 Radial rmsd", | 
| 54 | "      --thetacorr               Angular rmsd", | 
| 55 | "      --drcorr                  Directional rmsd for particles with unit \n                                  vectors", | 
| 56 | "      --helfandEcorr            Helfand moment for thermal conductvity", | 
| 57 | "  -p, --momentum                Helfand momentum for viscosity", | 
| 58 | "      --stresscorr              Stress tensor correlation function", | 
| 59 | 0 | 
| 60 | }; | 
| 61 |  | 
| 62 | typedef enum {ARG_NO | 
| 63 | , ARG_STRING | 
| 64 | , ARG_INT | 
| 65 | } cmdline_parser_arg_type; | 
| 66 |  | 
| 67 | static | 
| 68 | void clear_given (struct gengetopt_args_info *args_info); | 
| 69 | static | 
| 70 | void clear_args (struct gengetopt_args_info *args_info); | 
| 71 |  | 
| 72 | static int | 
| 73 | cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info, | 
| 74 | struct cmdline_parser_params *params, const char *additional_error); | 
| 75 |  | 
| 76 | static int | 
| 77 | cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error); | 
| 78 |  | 
| 79 | static char * | 
| 80 | gengetopt_strdup (const char *s); | 
| 81 |  | 
| 82 | static | 
| 83 | void clear_given (struct gengetopt_args_info *args_info) | 
| 84 | { | 
| 85 | args_info->help_given = 0 ; | 
| 86 | args_info->version_given = 0 ; | 
| 87 | args_info->input_given = 0 ; | 
| 88 | args_info->output_given = 0 ; | 
| 89 | args_info->sele1_given = 0 ; | 
| 90 | args_info->sele2_given = 0 ; | 
| 91 | args_info->order_given = 0 ; | 
| 92 | args_info->nzbins_given = 0 ; | 
| 93 | args_info->memory_given = 0 ; | 
| 94 | args_info->selecorr_given = 0 ; | 
| 95 | args_info->rcorr_given = 0 ; | 
| 96 | args_info->vcorr_given = 0 ; | 
| 97 | args_info->dcorr_given = 0 ; | 
| 98 | args_info->lcorr_given = 0 ; | 
| 99 | args_info->lcorrZ_given = 0 ; | 
| 100 | args_info->cohZ_given = 0 ; | 
| 101 | args_info->sdcorr_given = 0 ; | 
| 102 | args_info->r_rcorr_given = 0 ; | 
| 103 | args_info->thetacorr_given = 0 ; | 
| 104 | args_info->drcorr_given = 0 ; | 
| 105 | args_info->helfandEcorr_given = 0 ; | 
| 106 | args_info->momentum_given = 0 ; | 
| 107 | args_info->stresscorr_given = 0 ; | 
| 108 | args_info->dynamicProps_group_counter = 0 ; | 
| 109 | } | 
| 110 |  | 
| 111 | static | 
| 112 | void clear_args (struct gengetopt_args_info *args_info) | 
| 113 | { | 
| 114 | FIX_UNUSED (args_info); | 
| 115 | args_info->input_arg = NULL; | 
| 116 | args_info->input_orig = NULL; | 
| 117 | args_info->output_arg = NULL; | 
| 118 | args_info->output_orig = NULL; | 
| 119 | args_info->sele1_arg = NULL; | 
| 120 | args_info->sele1_orig = NULL; | 
| 121 | args_info->sele2_arg = NULL; | 
| 122 | args_info->sele2_orig = NULL; | 
| 123 | args_info->order_orig = NULL; | 
| 124 | args_info->nzbins_arg = 100; | 
| 125 | args_info->nzbins_orig = NULL; | 
| 126 | args_info->memory_arg = gengetopt_strdup ("2G"); | 
| 127 | args_info->memory_orig = NULL; | 
| 128 |  | 
| 129 | } | 
| 130 |  | 
| 131 | static | 
| 132 | void init_args_info(struct gengetopt_args_info *args_info) | 
| 133 | { | 
| 134 |  | 
| 135 |  | 
| 136 | args_info->help_help = gengetopt_args_info_help[0] ; | 
| 137 | args_info->version_help = gengetopt_args_info_help[1] ; | 
| 138 | args_info->input_help = gengetopt_args_info_help[2] ; | 
| 139 | args_info->output_help = gengetopt_args_info_help[3] ; | 
| 140 | args_info->sele1_help = gengetopt_args_info_help[4] ; | 
| 141 | args_info->sele2_help = gengetopt_args_info_help[5] ; | 
| 142 | args_info->order_help = gengetopt_args_info_help[6] ; | 
| 143 | args_info->nzbins_help = gengetopt_args_info_help[7] ; | 
| 144 | args_info->memory_help = gengetopt_args_info_help[8] ; | 
| 145 | args_info->selecorr_help = gengetopt_args_info_help[10] ; | 
| 146 | args_info->rcorr_help = gengetopt_args_info_help[11] ; | 
| 147 | args_info->vcorr_help = gengetopt_args_info_help[12] ; | 
| 148 | args_info->dcorr_help = gengetopt_args_info_help[13] ; | 
| 149 | args_info->lcorr_help = gengetopt_args_info_help[14] ; | 
| 150 | args_info->lcorrZ_help = gengetopt_args_info_help[15] ; | 
| 151 | args_info->cohZ_help = gengetopt_args_info_help[16] ; | 
| 152 | args_info->sdcorr_help = gengetopt_args_info_help[17] ; | 
| 153 | args_info->r_rcorr_help = gengetopt_args_info_help[18] ; | 
| 154 | args_info->thetacorr_help = gengetopt_args_info_help[19] ; | 
| 155 | args_info->drcorr_help = gengetopt_args_info_help[20] ; | 
| 156 | args_info->helfandEcorr_help = gengetopt_args_info_help[21] ; | 
| 157 | args_info->momentum_help = gengetopt_args_info_help[22] ; | 
| 158 | args_info->stresscorr_help = gengetopt_args_info_help[23] ; | 
| 159 |  | 
| 160 | } | 
| 161 |  | 
| 162 | void | 
| 163 | cmdline_parser_print_version (void) | 
| 164 | { | 
| 165 | printf ("%s %s\n", | 
| 166 | (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE), | 
| 167 | CMDLINE_PARSER_VERSION); | 
| 168 | } | 
| 169 |  | 
| 170 | static void print_help_common(void) { | 
| 171 | cmdline_parser_print_version (); | 
| 172 |  | 
| 173 | if (strlen(gengetopt_args_info_purpose) > 0) | 
| 174 | printf("\n%s\n", gengetopt_args_info_purpose); | 
| 175 |  | 
| 176 | if (strlen(gengetopt_args_info_usage) > 0) | 
| 177 | printf("\n%s\n", gengetopt_args_info_usage); | 
| 178 |  | 
| 179 | printf("\n"); | 
| 180 |  | 
| 181 | if (strlen(gengetopt_args_info_description) > 0) | 
| 182 | printf("%s\n\n", gengetopt_args_info_description); | 
| 183 | } | 
| 184 |  | 
| 185 | void | 
| 186 | cmdline_parser_print_help (void) | 
| 187 | { | 
| 188 | int i = 0; | 
| 189 | print_help_common(); | 
| 190 | while (gengetopt_args_info_help[i]) | 
| 191 | printf("%s\n", gengetopt_args_info_help[i++]); | 
| 192 | } | 
| 193 |  | 
| 194 | void | 
| 195 | cmdline_parser_init (struct gengetopt_args_info *args_info) | 
| 196 | { | 
| 197 | clear_given (args_info); | 
| 198 | clear_args (args_info); | 
| 199 | init_args_info (args_info); | 
| 200 |  | 
| 201 | args_info->inputs = 0; | 
| 202 | args_info->inputs_num = 0; | 
| 203 | } | 
| 204 |  | 
| 205 | void | 
| 206 | cmdline_parser_params_init(struct cmdline_parser_params *params) | 
| 207 | { | 
| 208 | if (params) | 
| 209 | { | 
| 210 | params->override = 0; | 
| 211 | params->initialize = 1; | 
| 212 | params->check_required = 1; | 
| 213 | params->check_ambiguity = 0; | 
| 214 | params->print_errors = 1; | 
| 215 | } | 
| 216 | } | 
| 217 |  | 
| 218 | struct cmdline_parser_params * | 
| 219 | cmdline_parser_params_create(void) | 
| 220 | { | 
| 221 | struct cmdline_parser_params *params = | 
| 222 | (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params)); | 
| 223 | cmdline_parser_params_init(params); | 
| 224 | return params; | 
| 225 | } | 
| 226 |  | 
| 227 | static void | 
| 228 | free_string_field (char **s) | 
| 229 | { | 
| 230 | if (*s) | 
| 231 | { | 
| 232 | free (*s); | 
| 233 | *s = 0; | 
| 234 | } | 
| 235 | } | 
| 236 |  | 
| 237 |  | 
| 238 | static void | 
| 239 | cmdline_parser_release (struct gengetopt_args_info *args_info) | 
| 240 | { | 
| 241 | unsigned int i; | 
| 242 | free_string_field (&(args_info->input_arg)); | 
| 243 | free_string_field (&(args_info->input_orig)); | 
| 244 | free_string_field (&(args_info->output_arg)); | 
| 245 | free_string_field (&(args_info->output_orig)); | 
| 246 | free_string_field (&(args_info->sele1_arg)); | 
| 247 | free_string_field (&(args_info->sele1_orig)); | 
| 248 | free_string_field (&(args_info->sele2_arg)); | 
| 249 | free_string_field (&(args_info->sele2_orig)); | 
| 250 | free_string_field (&(args_info->order_orig)); | 
| 251 | free_string_field (&(args_info->nzbins_orig)); | 
| 252 | free_string_field (&(args_info->memory_arg)); | 
| 253 | free_string_field (&(args_info->memory_orig)); | 
| 254 |  | 
| 255 |  | 
| 256 | for (i = 0; i < args_info->inputs_num; ++i) | 
| 257 | free (args_info->inputs [i]); | 
| 258 |  | 
| 259 | if (args_info->inputs_num) | 
| 260 | free (args_info->inputs); | 
| 261 |  | 
| 262 | clear_given (args_info); | 
| 263 | } | 
| 264 |  | 
| 265 |  | 
| 266 | static void | 
| 267 | write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[]) | 
| 268 | { | 
| 269 | FIX_UNUSED (values); | 
| 270 | if (arg) { | 
| 271 | fprintf(outfile, "%s=\"%s\"\n", opt, arg); | 
| 272 | } else { | 
| 273 | fprintf(outfile, "%s\n", opt); | 
| 274 | } | 
| 275 | } | 
| 276 |  | 
| 277 |  | 
| 278 | int | 
| 279 | cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info) | 
| 280 | { | 
| 281 | int i = 0; | 
| 282 |  | 
| 283 | if (!outfile) | 
| 284 | { | 
| 285 | fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE); | 
| 286 | return EXIT_FAILURE; | 
| 287 | } | 
| 288 |  | 
| 289 | if (args_info->help_given) | 
| 290 | write_into_file(outfile, "help", 0, 0 ); | 
| 291 | if (args_info->version_given) | 
| 292 | write_into_file(outfile, "version", 0, 0 ); | 
| 293 | if (args_info->input_given) | 
| 294 | write_into_file(outfile, "input", args_info->input_orig, 0); | 
| 295 | if (args_info->output_given) | 
| 296 | write_into_file(outfile, "output", args_info->output_orig, 0); | 
| 297 | if (args_info->sele1_given) | 
| 298 | write_into_file(outfile, "sele1", args_info->sele1_orig, 0); | 
| 299 | if (args_info->sele2_given) | 
| 300 | write_into_file(outfile, "sele2", args_info->sele2_orig, 0); | 
| 301 | if (args_info->order_given) | 
| 302 | write_into_file(outfile, "order", args_info->order_orig, 0); | 
| 303 | if (args_info->nzbins_given) | 
| 304 | write_into_file(outfile, "nzbins", args_info->nzbins_orig, 0); | 
| 305 | if (args_info->memory_given) | 
| 306 | write_into_file(outfile, "memory", args_info->memory_orig, 0); | 
| 307 | if (args_info->selecorr_given) | 
| 308 | write_into_file(outfile, "selecorr", 0, 0 ); | 
| 309 | if (args_info->rcorr_given) | 
| 310 | write_into_file(outfile, "rcorr", 0, 0 ); | 
| 311 | if (args_info->vcorr_given) | 
| 312 | write_into_file(outfile, "vcorr", 0, 0 ); | 
| 313 | if (args_info->dcorr_given) | 
| 314 | write_into_file(outfile, "dcorr", 0, 0 ); | 
| 315 | if (args_info->lcorr_given) | 
| 316 | write_into_file(outfile, "lcorr", 0, 0 ); | 
| 317 | if (args_info->lcorrZ_given) | 
| 318 | write_into_file(outfile, "lcorrZ", 0, 0 ); | 
| 319 | if (args_info->cohZ_given) | 
| 320 | write_into_file(outfile, "cohZ", 0, 0 ); | 
| 321 | if (args_info->sdcorr_given) | 
| 322 | write_into_file(outfile, "sdcorr", 0, 0 ); | 
| 323 | if (args_info->r_rcorr_given) | 
| 324 | write_into_file(outfile, "r_rcorr", 0, 0 ); | 
| 325 | if (args_info->thetacorr_given) | 
| 326 | write_into_file(outfile, "thetacorr", 0, 0 ); | 
| 327 | if (args_info->drcorr_given) | 
| 328 | write_into_file(outfile, "drcorr", 0, 0 ); | 
| 329 | if (args_info->helfandEcorr_given) | 
| 330 | write_into_file(outfile, "helfandEcorr", 0, 0 ); | 
| 331 | if (args_info->momentum_given) | 
| 332 | write_into_file(outfile, "momentum", 0, 0 ); | 
| 333 | if (args_info->stresscorr_given) | 
| 334 | write_into_file(outfile, "stresscorr", 0, 0 ); | 
| 335 |  | 
| 336 |  | 
| 337 | i = EXIT_SUCCESS; | 
| 338 | return i; | 
| 339 | } | 
| 340 |  | 
| 341 | int | 
| 342 | cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info) | 
| 343 | { | 
| 344 | FILE *outfile; | 
| 345 | int i = 0; | 
| 346 |  | 
| 347 | outfile = fopen(filename, "w"); | 
| 348 |  | 
| 349 | if (!outfile) | 
| 350 | { | 
| 351 | fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename); | 
| 352 | return EXIT_FAILURE; | 
| 353 | } | 
| 354 |  | 
| 355 | i = cmdline_parser_dump(outfile, args_info); | 
| 356 | fclose (outfile); | 
| 357 |  | 
| 358 | return i; | 
| 359 | } | 
| 360 |  | 
| 361 | void | 
| 362 | cmdline_parser_free (struct gengetopt_args_info *args_info) | 
| 363 | { | 
| 364 | cmdline_parser_release (args_info); | 
| 365 | } | 
| 366 |  | 
| 367 | /** @brief replacement of strdup, which is not standard */ | 
| 368 | char * | 
| 369 | gengetopt_strdup (const char *s) | 
| 370 | { | 
| 371 | char *result = 0; | 
| 372 | if (!s) | 
| 373 | return result; | 
| 374 |  | 
| 375 | result = (char*)malloc(strlen(s) + 1); | 
| 376 | if (result == (char*)0) | 
| 377 | return (char*)0; | 
| 378 | strcpy(result, s); | 
| 379 | return result; | 
| 380 | } | 
| 381 |  | 
| 382 | static void | 
| 383 | reset_group_dynamicProps(struct gengetopt_args_info *args_info) | 
| 384 | { | 
| 385 | if (! args_info->dynamicProps_group_counter) | 
| 386 | return; | 
| 387 |  | 
| 388 | args_info->selecorr_given = 0 ; | 
| 389 | args_info->rcorr_given = 0 ; | 
| 390 | args_info->vcorr_given = 0 ; | 
| 391 | args_info->dcorr_given = 0 ; | 
| 392 | args_info->lcorr_given = 0 ; | 
| 393 | args_info->lcorrZ_given = 0 ; | 
| 394 | args_info->cohZ_given = 0 ; | 
| 395 | args_info->sdcorr_given = 0 ; | 
| 396 | args_info->r_rcorr_given = 0 ; | 
| 397 | args_info->thetacorr_given = 0 ; | 
| 398 | args_info->drcorr_given = 0 ; | 
| 399 | args_info->helfandEcorr_given = 0 ; | 
| 400 | args_info->momentum_given = 0 ; | 
| 401 | args_info->stresscorr_given = 0 ; | 
| 402 |  | 
| 403 | args_info->dynamicProps_group_counter = 0; | 
| 404 | } | 
| 405 |  | 
| 406 | int | 
| 407 | cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info) | 
| 408 | { | 
| 409 | return cmdline_parser2 (argc, argv, args_info, 0, 1, 1); | 
| 410 | } | 
| 411 |  | 
| 412 | int | 
| 413 | cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info, | 
| 414 | struct cmdline_parser_params *params) | 
| 415 | { | 
| 416 | int result; | 
| 417 | result = cmdline_parser_internal (argc, argv, args_info, params, 0); | 
| 418 |  | 
| 419 | if (result == EXIT_FAILURE) | 
| 420 | { | 
| 421 | cmdline_parser_free (args_info); | 
| 422 | exit (EXIT_FAILURE); | 
| 423 | } | 
| 424 |  | 
| 425 | return result; | 
| 426 | } | 
| 427 |  | 
| 428 | int | 
| 429 | cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required) | 
| 430 | { | 
| 431 | int result; | 
| 432 | struct cmdline_parser_params params; | 
| 433 |  | 
| 434 | params.override = override; | 
| 435 | params.initialize = initialize; | 
| 436 | params.check_required = check_required; | 
| 437 | params.check_ambiguity = 0; | 
| 438 | params.print_errors = 1; | 
| 439 |  | 
| 440 | result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0); | 
| 441 |  | 
| 442 | if (result == EXIT_FAILURE) | 
| 443 | { | 
| 444 | cmdline_parser_free (args_info); | 
| 445 | exit (EXIT_FAILURE); | 
| 446 | } | 
| 447 |  | 
| 448 | return result; | 
| 449 | } | 
| 450 |  | 
| 451 | int | 
| 452 | cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name) | 
| 453 | { | 
| 454 | int result = EXIT_SUCCESS; | 
| 455 |  | 
| 456 | if (cmdline_parser_required2(args_info, prog_name, 0) > 0) | 
| 457 | result = EXIT_FAILURE; | 
| 458 |  | 
| 459 | if (result == EXIT_FAILURE) | 
| 460 | { | 
| 461 | cmdline_parser_free (args_info); | 
| 462 | exit (EXIT_FAILURE); | 
| 463 | } | 
| 464 |  | 
| 465 | return result; | 
| 466 | } | 
| 467 |  | 
| 468 | int | 
| 469 | cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error) | 
| 470 | { | 
| 471 | int error = 0; | 
| 472 | FIX_UNUSED (additional_error); | 
| 473 |  | 
| 474 | /* checks for required options */ | 
| 475 | if (! args_info->input_given) | 
| 476 | { | 
| 477 | fprintf (stderr, "%s: '--input' ('-i') option required%s\n", prog_name, (additional_error ? additional_error : "")); | 
| 478 | error = 1; | 
| 479 | } | 
| 480 |  | 
| 481 | if (args_info->dynamicProps_group_counter == 0) | 
| 482 | { | 
| 483 | fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required%s.\n", prog_name, args_info->dynamicProps_group_counter, (additional_error ? additional_error : "")); | 
| 484 | error = 1; | 
| 485 | } | 
| 486 |  | 
| 487 |  | 
| 488 | /* checks for dependences among options */ | 
| 489 |  | 
| 490 | return error; | 
| 491 | } | 
| 492 |  | 
| 493 |  | 
| 494 | static char *package_name = 0; | 
| 495 |  | 
| 496 | /** | 
| 497 | * @brief updates an option | 
| 498 | * @param field the generic pointer to the field to update | 
| 499 | * @param orig_field the pointer to the orig field | 
| 500 | * @param field_given the pointer to the number of occurrence of this option | 
| 501 | * @param prev_given the pointer to the number of occurrence already seen | 
| 502 | * @param value the argument for this option (if null no arg was specified) | 
| 503 | * @param possible_values the possible values for this option (if specified) | 
| 504 | * @param default_value the default value (in case the option only accepts fixed values) | 
| 505 | * @param arg_type the type of this option | 
| 506 | * @param check_ambiguity @see cmdline_parser_params.check_ambiguity | 
| 507 | * @param override @see cmdline_parser_params.override | 
| 508 | * @param no_free whether to free a possible previous value | 
| 509 | * @param multiple_option whether this is a multiple option | 
| 510 | * @param long_opt the corresponding long option | 
| 511 | * @param short_opt the corresponding short option (or '-' if none) | 
| 512 | * @param additional_error possible further error specification | 
| 513 | */ | 
| 514 | static | 
| 515 | int update_arg(void *field, char **orig_field, | 
| 516 | unsigned int *field_given, unsigned int *prev_given, | 
| 517 | char *value, const char *possible_values[], | 
| 518 | const char *default_value, | 
| 519 | cmdline_parser_arg_type arg_type, | 
| 520 | int check_ambiguity, int override, | 
| 521 | int no_free, int multiple_option, | 
| 522 | const char *long_opt, char short_opt, | 
| 523 | const char *additional_error) | 
| 524 | { | 
| 525 | char *stop_char = 0; | 
| 526 | const char *val = value; | 
| 527 | int found; | 
| 528 | char **string_field; | 
| 529 | FIX_UNUSED (field); | 
| 530 |  | 
| 531 | stop_char = 0; | 
| 532 | found = 0; | 
| 533 |  | 
| 534 | if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given))) | 
| 535 | { | 
| 536 | if (short_opt != '-') | 
| 537 | fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n", | 
| 538 | package_name, long_opt, short_opt, | 
| 539 | (additional_error ? additional_error : "")); | 
| 540 | else | 
| 541 | fprintf (stderr, "%s: `--%s' option given more than once%s\n", | 
| 542 | package_name, long_opt, | 
| 543 | (additional_error ? additional_error : "")); | 
| 544 | return 1; /* failure */ | 
| 545 | } | 
| 546 |  | 
| 547 | FIX_UNUSED (default_value); | 
| 548 |  | 
| 549 | if (field_given && *field_given && ! override) | 
| 550 | return 0; | 
| 551 | if (prev_given) | 
| 552 | (*prev_given)++; | 
| 553 | if (field_given) | 
| 554 | (*field_given)++; | 
| 555 | if (possible_values) | 
| 556 | val = possible_values[found]; | 
| 557 |  | 
| 558 | switch(arg_type) { | 
| 559 | case ARG_INT: | 
| 560 | if (val) *((int *)field) = strtol (val, &stop_char, 0); | 
| 561 | break; | 
| 562 | case ARG_STRING: | 
| 563 | if (val) { | 
| 564 | string_field = (char **)field; | 
| 565 | if (!no_free && *string_field) | 
| 566 | free (*string_field); /* free previous string */ | 
| 567 | *string_field = gengetopt_strdup (val); | 
| 568 | } | 
| 569 | break; | 
| 570 | default: | 
| 571 | break; | 
| 572 | }; | 
| 573 |  | 
| 574 | /* check numeric conversion */ | 
| 575 | switch(arg_type) { | 
| 576 | case ARG_INT: | 
| 577 | if (val && !(stop_char && *stop_char == '\0')) { | 
| 578 | fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val); | 
| 579 | return 1; /* failure */ | 
| 580 | } | 
| 581 | break; | 
| 582 | default: | 
| 583 | ; | 
| 584 | }; | 
| 585 |  | 
| 586 | /* store the original value */ | 
| 587 | switch(arg_type) { | 
| 588 | case ARG_NO: | 
| 589 | break; | 
| 590 | default: | 
| 591 | if (value && orig_field) { | 
| 592 | if (no_free) { | 
| 593 | *orig_field = value; | 
| 594 | } else { | 
| 595 | if (*orig_field) | 
| 596 | free (*orig_field); /* free previous string */ | 
| 597 | *orig_field = gengetopt_strdup (value); | 
| 598 | } | 
| 599 | } | 
| 600 | }; | 
| 601 |  | 
| 602 | return 0; /* OK */ | 
| 603 | } | 
| 604 |  | 
| 605 |  | 
| 606 | int | 
| 607 | cmdline_parser_internal ( | 
| 608 | int argc, char **argv, struct gengetopt_args_info *args_info, | 
| 609 | struct cmdline_parser_params *params, const char *additional_error) | 
| 610 | { | 
| 611 | int c;        /* Character of the parsed option.  */ | 
| 612 |  | 
| 613 | int error = 0; | 
| 614 | struct gengetopt_args_info local_args_info; | 
| 615 |  | 
| 616 | int override; | 
| 617 | int initialize; | 
| 618 | int check_required; | 
| 619 | int check_ambiguity; | 
| 620 |  | 
| 621 | package_name = argv[0]; | 
| 622 |  | 
| 623 | override = params->override; | 
| 624 | initialize = params->initialize; | 
| 625 | check_required = params->check_required; | 
| 626 | check_ambiguity = params->check_ambiguity; | 
| 627 |  | 
| 628 | if (initialize) | 
| 629 | cmdline_parser_init (args_info); | 
| 630 |  | 
| 631 | cmdline_parser_init (&local_args_info); | 
| 632 |  | 
| 633 | optarg = 0; | 
| 634 | optind = 0; | 
| 635 | opterr = params->print_errors; | 
| 636 | optopt = '?'; | 
| 637 |  | 
| 638 | while (1) | 
| 639 | { | 
| 640 | int option_index = 0; | 
| 641 |  | 
| 642 | static struct option long_options[] = { | 
| 643 | { "help",       0, NULL, 'h' }, | 
| 644 | { "version",    0, NULL, 'V' }, | 
| 645 | { "input",      1, NULL, 'i' }, | 
| 646 | { "output",     1, NULL, 'o' }, | 
| 647 | { "sele1",      1, NULL, 0 }, | 
| 648 | { "sele2",      1, NULL, 0 }, | 
| 649 | { "order",      1, NULL, 0 }, | 
| 650 | { "nzbins",     1, NULL, 'z' }, | 
| 651 | { "memory",     1, NULL, 'm' }, | 
| 652 | { "selecorr",   0, NULL, 's' }, | 
| 653 | { "rcorr",      0, NULL, 'r' }, | 
| 654 | { "vcorr",      0, NULL, 'v' }, | 
| 655 | { "dcorr",      0, NULL, 'd' }, | 
| 656 | { "lcorr",      0, NULL, 'l' }, | 
| 657 | { "lcorrZ",     0, NULL, 0 }, | 
| 658 | { "cohZ",       0, NULL, 0 }, | 
| 659 | { "sdcorr",     0, NULL, 'M' }, | 
| 660 | { "r_rcorr",    0, NULL, 0 }, | 
| 661 | { "thetacorr",  0, NULL, 0 }, | 
| 662 | { "drcorr",     0, NULL, 0 }, | 
| 663 | { "helfandEcorr",       0, NULL, 0 }, | 
| 664 | { "momentum",   0, NULL, 'p' }, | 
| 665 | { "stresscorr", 0, NULL, 0 }, | 
| 666 | { 0,  0, 0, 0 } | 
| 667 | }; | 
| 668 |  | 
| 669 | c = getopt_long (argc, argv, "hVi:o:z:m:srvdlMp", long_options, &option_index); | 
| 670 |  | 
| 671 | if (c == -1) break;       /* Exit from `while (1)' loop.  */ | 
| 672 |  | 
| 673 | switch (c) | 
| 674 | { | 
| 675 | case 'h':       /* Print help and exit.  */ | 
| 676 | cmdline_parser_print_help (); | 
| 677 | cmdline_parser_free (&local_args_info); | 
| 678 | exit (EXIT_SUCCESS); | 
| 679 |  | 
| 680 | case 'V':       /* Print version and exit.  */ | 
| 681 | cmdline_parser_print_version (); | 
| 682 | cmdline_parser_free (&local_args_info); | 
| 683 | exit (EXIT_SUCCESS); | 
| 684 |  | 
| 685 | case 'i':       /* input dump file.  */ | 
| 686 |  | 
| 687 |  | 
| 688 | if (update_arg( (void *)&(args_info->input_arg), | 
| 689 | &(args_info->input_orig), &(args_info->input_given), | 
| 690 | &(local_args_info.input_given), optarg, 0, 0, ARG_STRING, | 
| 691 | check_ambiguity, override, 0, 0, | 
| 692 | "input", 'i', | 
| 693 | additional_error)) | 
| 694 | goto failure; | 
| 695 |  | 
| 696 | break; | 
| 697 | case 'o':       /* output file name.  */ | 
| 698 |  | 
| 699 |  | 
| 700 | if (update_arg( (void *)&(args_info->output_arg), | 
| 701 | &(args_info->output_orig), &(args_info->output_given), | 
| 702 | &(local_args_info.output_given), optarg, 0, 0, ARG_STRING, | 
| 703 | check_ambiguity, override, 0, 0, | 
| 704 | "output", 'o', | 
| 705 | additional_error)) | 
| 706 | goto failure; | 
| 707 |  | 
| 708 | break; | 
| 709 | case 'z':       /* Number of Z bins.  */ | 
| 710 |  | 
| 711 |  | 
| 712 | if (update_arg( (void *)&(args_info->nzbins_arg), | 
| 713 | &(args_info->nzbins_orig), &(args_info->nzbins_given), | 
| 714 | &(local_args_info.nzbins_given), optarg, 0, "100", ARG_INT, | 
| 715 | check_ambiguity, override, 0, 0, | 
| 716 | "nzbins", 'z', | 
| 717 | additional_error)) | 
| 718 | goto failure; | 
| 719 |  | 
| 720 | break; | 
| 721 | case 'm':       /* Available memory (defaults to 2G).  */ | 
| 722 |  | 
| 723 |  | 
| 724 | if (update_arg( (void *)&(args_info->memory_arg), | 
| 725 | &(args_info->memory_orig), &(args_info->memory_given), | 
| 726 | &(local_args_info.memory_given), optarg, 0, "2G", ARG_STRING, | 
| 727 | check_ambiguity, override, 0, 0, | 
| 728 | "memory", 'm', | 
| 729 | additional_error)) | 
| 730 | goto failure; | 
| 731 |  | 
| 732 | break; | 
| 733 | case 's':       /* selection correlation function.  */ | 
| 734 |  | 
| 735 | if (args_info->dynamicProps_group_counter && override) | 
| 736 | reset_group_dynamicProps (args_info); | 
| 737 | args_info->dynamicProps_group_counter += 1; | 
| 738 |  | 
| 739 | if (update_arg( 0 , | 
| 740 | 0 , &(args_info->selecorr_given), | 
| 741 | &(local_args_info.selecorr_given), optarg, 0, 0, ARG_NO, | 
| 742 | check_ambiguity, override, 0, 0, | 
| 743 | "selecorr", 's', | 
| 744 | additional_error)) | 
| 745 | goto failure; | 
| 746 |  | 
| 747 | break; | 
| 748 | case 'r':       /* rmsd.  */ | 
| 749 |  | 
| 750 | if (args_info->dynamicProps_group_counter && override) | 
| 751 | reset_group_dynamicProps (args_info); | 
| 752 | args_info->dynamicProps_group_counter += 1; | 
| 753 |  | 
| 754 | if (update_arg( 0 , | 
| 755 | 0 , &(args_info->rcorr_given), | 
| 756 | &(local_args_info.rcorr_given), optarg, 0, 0, ARG_NO, | 
| 757 | check_ambiguity, override, 0, 0, | 
| 758 | "rcorr", 'r', | 
| 759 | additional_error)) | 
| 760 | goto failure; | 
| 761 |  | 
| 762 | break; | 
| 763 | case 'v':       /* velocity correlation function.  */ | 
| 764 |  | 
| 765 | if (args_info->dynamicProps_group_counter && override) | 
| 766 | reset_group_dynamicProps (args_info); | 
| 767 | args_info->dynamicProps_group_counter += 1; | 
| 768 |  | 
| 769 | if (update_arg( 0 , | 
| 770 | 0 , &(args_info->vcorr_given), | 
| 771 | &(local_args_info.vcorr_given), optarg, 0, 0, ARG_NO, | 
| 772 | check_ambiguity, override, 0, 0, | 
| 773 | "vcorr", 'v', | 
| 774 | additional_error)) | 
| 775 | goto failure; | 
| 776 |  | 
| 777 | break; | 
| 778 | case 'd':       /* dipole correlation function.  */ | 
| 779 |  | 
| 780 | if (args_info->dynamicProps_group_counter && override) | 
| 781 | reset_group_dynamicProps (args_info); | 
| 782 | args_info->dynamicProps_group_counter += 1; | 
| 783 |  | 
| 784 | if (update_arg( 0 , | 
| 785 | 0 , &(args_info->dcorr_given), | 
| 786 | &(local_args_info.dcorr_given), optarg, 0, 0, ARG_NO, | 
| 787 | check_ambiguity, override, 0, 0, | 
| 788 | "dcorr", 'd', | 
| 789 | additional_error)) | 
| 790 | goto failure; | 
| 791 |  | 
| 792 | break; | 
| 793 | case 'l':       /* Lengendre correlation function.  */ | 
| 794 |  | 
| 795 | if (args_info->dynamicProps_group_counter && override) | 
| 796 | reset_group_dynamicProps (args_info); | 
| 797 | args_info->dynamicProps_group_counter += 1; | 
| 798 |  | 
| 799 | if (update_arg( 0 , | 
| 800 | 0 , &(args_info->lcorr_given), | 
| 801 | &(local_args_info.lcorr_given), optarg, 0, 0, ARG_NO, | 
| 802 | check_ambiguity, override, 0, 0, | 
| 803 | "lcorr", 'l', | 
| 804 | additional_error)) | 
| 805 | goto failure; | 
| 806 |  | 
| 807 | break; | 
| 808 | case 'M':       /* System dipole correlation function.  */ | 
| 809 |  | 
| 810 | if (args_info->dynamicProps_group_counter && override) | 
| 811 | reset_group_dynamicProps (args_info); | 
| 812 | args_info->dynamicProps_group_counter += 1; | 
| 813 |  | 
| 814 | if (update_arg( 0 , | 
| 815 | 0 , &(args_info->sdcorr_given), | 
| 816 | &(local_args_info.sdcorr_given), optarg, 0, 0, ARG_NO, | 
| 817 | check_ambiguity, override, 0, 0, | 
| 818 | "sdcorr", 'M', | 
| 819 | additional_error)) | 
| 820 | goto failure; | 
| 821 |  | 
| 822 | break; | 
| 823 | case 'p':       /* Helfand momentum for viscosity.  */ | 
| 824 |  | 
| 825 | if (args_info->dynamicProps_group_counter && override) | 
| 826 | reset_group_dynamicProps (args_info); | 
| 827 | args_info->dynamicProps_group_counter += 1; | 
| 828 |  | 
| 829 | if (update_arg( 0 , | 
| 830 | 0 , &(args_info->momentum_given), | 
| 831 | &(local_args_info.momentum_given), optarg, 0, 0, ARG_NO, | 
| 832 | check_ambiguity, override, 0, 0, | 
| 833 | "momentum", 'p', | 
| 834 | additional_error)) | 
| 835 | goto failure; | 
| 836 |  | 
| 837 | break; | 
| 838 |  | 
| 839 | case 0: /* Long option with no short option */ | 
| 840 | /* select first stuntdouble set.  */ | 
| 841 | if (strcmp (long_options[option_index].name, "sele1") == 0) | 
| 842 | { | 
| 843 |  | 
| 844 |  | 
| 845 | if (update_arg( (void *)&(args_info->sele1_arg), | 
| 846 | &(args_info->sele1_orig), &(args_info->sele1_given), | 
| 847 | &(local_args_info.sele1_given), optarg, 0, 0, ARG_STRING, | 
| 848 | check_ambiguity, override, 0, 0, | 
| 849 | "sele1", '-', | 
| 850 | additional_error)) | 
| 851 | goto failure; | 
| 852 |  | 
| 853 | } | 
| 854 | /* select second stuntdouble set (if sele2 is not set, use script from sele1).  */ | 
| 855 | else if (strcmp (long_options[option_index].name, "sele2") == 0) | 
| 856 | { | 
| 857 |  | 
| 858 |  | 
| 859 | if (update_arg( (void *)&(args_info->sele2_arg), | 
| 860 | &(args_info->sele2_orig), &(args_info->sele2_given), | 
| 861 | &(local_args_info.sele2_given), optarg, 0, 0, ARG_STRING, | 
| 862 | check_ambiguity, override, 0, 0, | 
| 863 | "sele2", '-', | 
| 864 | additional_error)) | 
| 865 | goto failure; | 
| 866 |  | 
| 867 | } | 
| 868 | /* Lengendre Polynomial Order.  */ | 
| 869 | else if (strcmp (long_options[option_index].name, "order") == 0) | 
| 870 | { | 
| 871 |  | 
| 872 |  | 
| 873 | if (update_arg( (void *)&(args_info->order_arg), | 
| 874 | &(args_info->order_orig), &(args_info->order_given), | 
| 875 | &(local_args_info.order_given), optarg, 0, 0, ARG_INT, | 
| 876 | check_ambiguity, override, 0, 0, | 
| 877 | "order", '-', | 
| 878 | additional_error)) | 
| 879 | goto failure; | 
| 880 |  | 
| 881 | } | 
| 882 | /* Lengendre correlation function binned by Z.  */ | 
| 883 | else if (strcmp (long_options[option_index].name, "lcorrZ") == 0) | 
| 884 | { | 
| 885 |  | 
| 886 | if (args_info->dynamicProps_group_counter && override) | 
| 887 | reset_group_dynamicProps (args_info); | 
| 888 | args_info->dynamicProps_group_counter += 1; | 
| 889 |  | 
| 890 | if (update_arg( 0 , | 
| 891 | 0 , &(args_info->lcorrZ_given), | 
| 892 | &(local_args_info.lcorrZ_given), optarg, 0, 0, ARG_NO, | 
| 893 | check_ambiguity, override, 0, 0, | 
| 894 | "lcorrZ", '-', | 
| 895 | additional_error)) | 
| 896 | goto failure; | 
| 897 |  | 
| 898 | } | 
| 899 | /* Lengendre correlation function for OH bond vectors binned by Z.  */ | 
| 900 | else if (strcmp (long_options[option_index].name, "cohZ") == 0) | 
| 901 | { | 
| 902 |  | 
| 903 | if (args_info->dynamicProps_group_counter && override) | 
| 904 | reset_group_dynamicProps (args_info); | 
| 905 | args_info->dynamicProps_group_counter += 1; | 
| 906 |  | 
| 907 | if (update_arg( 0 , | 
| 908 | 0 , &(args_info->cohZ_given), | 
| 909 | &(local_args_info.cohZ_given), optarg, 0, 0, ARG_NO, | 
| 910 | check_ambiguity, override, 0, 0, | 
| 911 | "cohZ", '-', | 
| 912 | additional_error)) | 
| 913 | goto failure; | 
| 914 |  | 
| 915 | } | 
| 916 | /* Radial rmsd.  */ | 
| 917 | else if (strcmp (long_options[option_index].name, "r_rcorr") == 0) | 
| 918 | { | 
| 919 |  | 
| 920 | if (args_info->dynamicProps_group_counter && override) | 
| 921 | reset_group_dynamicProps (args_info); | 
| 922 | args_info->dynamicProps_group_counter += 1; | 
| 923 |  | 
| 924 | if (update_arg( 0 , | 
| 925 | 0 , &(args_info->r_rcorr_given), | 
| 926 | &(local_args_info.r_rcorr_given), optarg, 0, 0, ARG_NO, | 
| 927 | check_ambiguity, override, 0, 0, | 
| 928 | "r_rcorr", '-', | 
| 929 | additional_error)) | 
| 930 | goto failure; | 
| 931 |  | 
| 932 | } | 
| 933 | /* Angular rmsd.  */ | 
| 934 | else if (strcmp (long_options[option_index].name, "thetacorr") == 0) | 
| 935 | { | 
| 936 |  | 
| 937 | if (args_info->dynamicProps_group_counter && override) | 
| 938 | reset_group_dynamicProps (args_info); | 
| 939 | args_info->dynamicProps_group_counter += 1; | 
| 940 |  | 
| 941 | if (update_arg( 0 , | 
| 942 | 0 , &(args_info->thetacorr_given), | 
| 943 | &(local_args_info.thetacorr_given), optarg, 0, 0, ARG_NO, | 
| 944 | check_ambiguity, override, 0, 0, | 
| 945 | "thetacorr", '-', | 
| 946 | additional_error)) | 
| 947 | goto failure; | 
| 948 |  | 
| 949 | } | 
| 950 | /* Directional rmsd for particles with unit vectors.  */ | 
| 951 | else if (strcmp (long_options[option_index].name, "drcorr") == 0) | 
| 952 | { | 
| 953 |  | 
| 954 | if (args_info->dynamicProps_group_counter && override) | 
| 955 | reset_group_dynamicProps (args_info); | 
| 956 | args_info->dynamicProps_group_counter += 1; | 
| 957 |  | 
| 958 | if (update_arg( 0 , | 
| 959 | 0 , &(args_info->drcorr_given), | 
| 960 | &(local_args_info.drcorr_given), optarg, 0, 0, ARG_NO, | 
| 961 | check_ambiguity, override, 0, 0, | 
| 962 | "drcorr", '-', | 
| 963 | additional_error)) | 
| 964 | goto failure; | 
| 965 |  | 
| 966 | } | 
| 967 | /* Helfand moment for thermal conductvity.  */ | 
| 968 | else if (strcmp (long_options[option_index].name, "helfandEcorr") == 0) | 
| 969 | { | 
| 970 |  | 
| 971 | if (args_info->dynamicProps_group_counter && override) | 
| 972 | reset_group_dynamicProps (args_info); | 
| 973 | args_info->dynamicProps_group_counter += 1; | 
| 974 |  | 
| 975 | if (update_arg( 0 , | 
| 976 | 0 , &(args_info->helfandEcorr_given), | 
| 977 | &(local_args_info.helfandEcorr_given), optarg, 0, 0, ARG_NO, | 
| 978 | check_ambiguity, override, 0, 0, | 
| 979 | "helfandEcorr", '-', | 
| 980 | additional_error)) | 
| 981 | goto failure; | 
| 982 |  | 
| 983 | } | 
| 984 | /* Stress tensor correlation function.  */ | 
| 985 | else if (strcmp (long_options[option_index].name, "stresscorr") == 0) | 
| 986 | { | 
| 987 |  | 
| 988 | if (args_info->dynamicProps_group_counter && override) | 
| 989 | reset_group_dynamicProps (args_info); | 
| 990 | args_info->dynamicProps_group_counter += 1; | 
| 991 |  | 
| 992 | if (update_arg( 0 , | 
| 993 | 0 , &(args_info->stresscorr_given), | 
| 994 | &(local_args_info.stresscorr_given), optarg, 0, 0, ARG_NO, | 
| 995 | check_ambiguity, override, 0, 0, | 
| 996 | "stresscorr", '-', | 
| 997 | additional_error)) | 
| 998 | goto failure; | 
| 999 |  | 
| 1000 | } | 
| 1001 |  | 
| 1002 | break; | 
| 1003 | case '?':       /* Invalid option.  */ | 
| 1004 | /* `getopt_long' already printed an error message.  */ | 
| 1005 | goto failure; | 
| 1006 |  | 
| 1007 | default:        /* bug: option not considered.  */ | 
| 1008 | fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); | 
| 1009 | abort (); | 
| 1010 | } /* switch */ | 
| 1011 | } /* while */ | 
| 1012 |  | 
| 1013 | if (args_info->dynamicProps_group_counter > 1) | 
| 1014 | { | 
| 1015 | fprintf (stderr, "%s: %d options of group dynamicProps were given. One is required%s.\n", argv[0], args_info->dynamicProps_group_counter, (additional_error ? additional_error : "")); | 
| 1016 | error = 1; | 
| 1017 | } | 
| 1018 |  | 
| 1019 |  | 
| 1020 |  | 
| 1021 | if (check_required) | 
| 1022 | { | 
| 1023 | error += cmdline_parser_required2 (args_info, argv[0], additional_error); | 
| 1024 | } | 
| 1025 |  | 
| 1026 | cmdline_parser_release (&local_args_info); | 
| 1027 |  | 
| 1028 | if ( error ) | 
| 1029 | return (EXIT_FAILURE); | 
| 1030 |  | 
| 1031 | if (optind < argc) | 
| 1032 | { | 
| 1033 | int i = 0 ; | 
| 1034 | int found_prog_name = 0; | 
| 1035 | /* whether program name, i.e., argv[0], is in the remaining args | 
| 1036 | (this may happen with some implementations of getopt, | 
| 1037 | but surely not with the one included by gengetopt) */ | 
| 1038 |  | 
| 1039 | i = optind; | 
| 1040 | while (i < argc) | 
| 1041 | if (argv[i++] == argv[0]) { | 
| 1042 | found_prog_name = 1; | 
| 1043 | break; | 
| 1044 | } | 
| 1045 | i = 0; | 
| 1046 |  | 
| 1047 | args_info->inputs_num = argc - optind - found_prog_name; | 
| 1048 | args_info->inputs = | 
| 1049 | (char **)(malloc ((args_info->inputs_num)*sizeof(char *))) ; | 
| 1050 | while (optind < argc) | 
| 1051 | if (argv[optind++] != argv[0]) | 
| 1052 | args_info->inputs[ i++ ] = gengetopt_strdup (argv[optind-1]) ; | 
| 1053 | } | 
| 1054 |  | 
| 1055 | return 0; | 
| 1056 |  | 
| 1057 | failure: | 
| 1058 |  | 
| 1059 | cmdline_parser_release (&local_args_info); | 
| 1060 | return (EXIT_FAILURE); | 
| 1061 | } |