/* File autogenerated by gengetopt version 2.13 generated with the following command: gengetopt -ibootstrap_prog.ggo -Fbootstrap_prog_cmdline -f bootstrap_prog_cmdline_parser --arg-struct-name=bootstrap_prog_args_info The developers of gengetopt consider the fixed text that goes in all gengetopt output files to be in the public domain: we make no copyright claims on it. */ /* If we use autoconf. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include #include #include #include "getopt.h" #include "bootstrap_prog_cmdline.h" static void clear_given (struct bootstrap_prog_args_info *args_info); static void clear_args (struct bootstrap_prog_args_info *args_info); static int bootstrap_prog_cmdline_parser_internal (int argc, char * const *argv, struct bootstrap_prog_args_info *args_info, int override, int initialize, int check_required, const char *additional_error); static int bootstrap_prog_cmdline_parser_required2 (struct bootstrap_prog_args_info *args_info, const char *prog_name, const char *additional_error); static char * gengetopt_strdup (const char *s); static void clear_given (struct bootstrap_prog_args_info *args_info) { args_info->help_given = 0 ; args_info->version_given = 0 ; args_info->treesList_given = 0 ; args_info->reftree_given = 0 ; args_info->outputfile_given = 0 ; args_info->Logfile_given = 0 ; args_info->verbose_given = 0 ; args_info->ConsensusLevel_given = 0 ; args_info->noBranchLen_given = 0 ; } static void clear_args (struct bootstrap_prog_args_info *args_info) { args_info->treesList_arg = NULL; args_info->reftree_arg = NULL; args_info->outputfile_arg = gengetopt_strdup ("-"); args_info->Logfile_arg = gengetopt_strdup ("-"); args_info->verbose_arg = 0 ; args_info->ConsensusLevel_arg = 0.5 ; args_info->noBranchLen_flag = 0; } void bootstrap_prog_cmdline_parser_print_version (void) { printf ("%s %s\n", BOOTSTRAP_PROG_CMDLINE_PARSER_PACKAGE, BOOTSTRAP_PROG_CMDLINE_PARSER_VERSION); } void bootstrap_prog_cmdline_parser_print_help (void) { bootstrap_prog_cmdline_parser_print_version (); printf("\n%s\n", "compute bootstrap values and consensus trees from a list of trees"); printf("\nUsage: bootstrap [OPTIONS]...\n\n"); printf("%s\n"," -h, --help Print help and exit"); printf("%s\n"," -V, --version Print version and exit"); printf("%s\n"," -t, --treesList=STRING filename of list of input trees"); printf("%s\n"," -r, --reftree=STRING Refremce Tree file name"); printf("%s\n"," -o, --outputfile=STRING Output tree file (default=`-')"); printf("%s\n"," -l, --Logfile=STRING Log file output name (default=`-')"); printf("%s\n"," -v, --verbose=INT Log report level (verbose) (default=`0')"); printf("%s\n"," -c, --ConsensusLevel=FLOAT use only branches with sport above this \n (default=`0.5')"); printf("%s\n"," -b, --noBranchLen Do not output branch lengths in output tree \n (default=off)"); } void bootstrap_prog_cmdline_parser_init (struct bootstrap_prog_args_info *args_info) { clear_given (args_info); clear_args (args_info); } void bootstrap_prog_cmdline_parser_free (struct bootstrap_prog_args_info *args_info) { if (args_info->treesList_arg) { free (args_info->treesList_arg); /* free previous argument */ args_info->treesList_arg = 0; } if (args_info->reftree_arg) { free (args_info->reftree_arg); /* free previous argument */ args_info->reftree_arg = 0; } if (args_info->outputfile_arg) { free (args_info->outputfile_arg); /* free previous argument */ args_info->outputfile_arg = 0; } if (args_info->Logfile_arg) { free (args_info->Logfile_arg); /* free previous argument */ args_info->Logfile_arg = 0; } clear_given (args_info); } /* gengetopt_strdup() */ /* strdup.c replacement of strdup, which is not standard */ char * gengetopt_strdup (const char *s) { char *result = NULL; if (!s) return result; result = (char*)malloc(strlen(s) + 1); if (result == (char*)0) return (char*)0; strcpy(result, s); return result; } int bootstrap_prog_cmdline_parser (int argc, char * const *argv, struct bootstrap_prog_args_info *args_info) { return bootstrap_prog_cmdline_parser2 (argc, argv, args_info, 0, 1, 1); } int bootstrap_prog_cmdline_parser2 (int argc, char * const *argv, struct bootstrap_prog_args_info *args_info, int override, int initialize, int check_required) { int result; result = bootstrap_prog_cmdline_parser_internal (argc, argv, args_info, override, initialize, check_required, NULL); if (result == EXIT_FAILURE) { bootstrap_prog_cmdline_parser_free (args_info); exit (EXIT_FAILURE); } return result; } int bootstrap_prog_cmdline_parser_required (struct bootstrap_prog_args_info *args_info, const char *prog_name) { int result = EXIT_SUCCESS; if (bootstrap_prog_cmdline_parser_required2(args_info, prog_name, NULL) > 0) result = EXIT_FAILURE; if (result == EXIT_FAILURE) { bootstrap_prog_cmdline_parser_free (args_info); exit (EXIT_FAILURE); } return result; } int bootstrap_prog_cmdline_parser_required2 (struct bootstrap_prog_args_info *args_info, const char *prog_name, const char *additional_error) { int error = 0; if (! args_info->treesList_given) { fprintf (stderr, "%s: '--treesList' ('-t') option required%s\n", prog_name, (additional_error ? additional_error : "")); error = 1; } return error; } int bootstrap_prog_cmdline_parser_internal (int argc, char * const *argv, struct bootstrap_prog_args_info *args_info, int override, int initialize, int check_required, const char *additional_error) { int c; /* Character of the parsed option. */ int error = 0; struct bootstrap_prog_args_info local_args_info; if (initialize) bootstrap_prog_cmdline_parser_init (args_info); bootstrap_prog_cmdline_parser_init (&local_args_info); optarg = 0; optind = 1; opterr = 1; optopt = '?'; while (1) { int option_index = 0; char *stop_char; static struct option long_options[] = { { "help", 0, NULL, 'h' }, { "version", 0, NULL, 'V' }, { "treesList", 1, NULL, 't' }, { "reftree", 1, NULL, 'r' }, { "outputfile", 1, NULL, 'o' }, { "Logfile", 1, NULL, 'l' }, { "verbose", 1, NULL, 'v' }, { "ConsensusLevel", 1, NULL, 'c' }, { "noBranchLen", 0, NULL, 'b' }, { NULL, 0, NULL, 0 } }; stop_char = 0; c = getopt_long (argc, argv, "hVt:r:o:l:v:c:b", long_options, &option_index); if (c == -1) break; /* Exit from `while (1)' loop. */ switch (c) { case 'h': /* Print help and exit. */ bootstrap_prog_cmdline_parser_print_help (); exit (EXIT_SUCCESS); case 'V': /* Print version and exit. */ bootstrap_prog_cmdline_parser_print_version (); exit (EXIT_SUCCESS); case 't': /* filename of list of input trees. */ if (local_args_info.treesList_given) { fprintf (stderr, "%s: `--treesList' (`-t') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->treesList_given && ! override) continue; local_args_info.treesList_given = 1; args_info->treesList_given = 1; if (args_info->treesList_arg) free (args_info->treesList_arg); /* free previous string */ args_info->treesList_arg = gengetopt_strdup (optarg); break; case 'r': /* Refremce Tree file name. */ if (local_args_info.reftree_given) { fprintf (stderr, "%s: `--reftree' (`-r') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->reftree_given && ! override) continue; local_args_info.reftree_given = 1; args_info->reftree_given = 1; if (args_info->reftree_arg) free (args_info->reftree_arg); /* free previous string */ args_info->reftree_arg = gengetopt_strdup (optarg); break; case 'o': /* Output tree file. */ if (local_args_info.outputfile_given) { fprintf (stderr, "%s: `--outputfile' (`-o') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->outputfile_given && ! override) continue; local_args_info.outputfile_given = 1; args_info->outputfile_given = 1; if (args_info->outputfile_arg) free (args_info->outputfile_arg); /* free previous string */ args_info->outputfile_arg = gengetopt_strdup (optarg); break; case 'l': /* Log file output name. */ if (local_args_info.Logfile_given) { fprintf (stderr, "%s: `--Logfile' (`-l') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->Logfile_given && ! override) continue; local_args_info.Logfile_given = 1; args_info->Logfile_given = 1; if (args_info->Logfile_arg) free (args_info->Logfile_arg); /* free previous string */ args_info->Logfile_arg = gengetopt_strdup (optarg); break; case 'v': /* Log report level (verbose). */ if (local_args_info.verbose_given) { fprintf (stderr, "%s: `--verbose' (`-v') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->verbose_given && ! override) continue; local_args_info.verbose_given = 1; args_info->verbose_given = 1; args_info->verbose_arg = strtol (optarg,&stop_char,0); break; case 'c': /* use only branches with sport above this. */ if (local_args_info.ConsensusLevel_given) { fprintf (stderr, "%s: `--ConsensusLevel' (`-c') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->ConsensusLevel_given && ! override) continue; local_args_info.ConsensusLevel_given = 1; args_info->ConsensusLevel_given = 1; args_info->ConsensusLevel_arg = (float)strtod (optarg, NULL); break; case 'b': /* Do not output branch lengths in output tree. */ if (local_args_info.noBranchLen_given) { fprintf (stderr, "%s: `--noBranchLen' (`-b') option given more than once%s\n", argv[0], (additional_error ? additional_error : "")); goto failure; } if (args_info->noBranchLen_given && ! override) continue; local_args_info.noBranchLen_given = 1; args_info->noBranchLen_given = 1; args_info->noBranchLen_flag = !(args_info->noBranchLen_flag); break; case 0: /* Long option with no short option */ case '?': /* Invalid option. */ /* `getopt_long' already printed an error message. */ goto failure; default: /* bug: option not considered. */ fprintf (stderr, "%s: option unknown: %c%s\n", BOOTSTRAP_PROG_CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : "")); abort (); } /* switch */ } /* while */ if (check_required) { error += bootstrap_prog_cmdline_parser_required2 (args_info, argv[0], additional_error); } bootstrap_prog_cmdline_parser_free (&local_args_info); if ( error ) return (EXIT_FAILURE); return 0; failure: bootstrap_prog_cmdline_parser_free (&local_args_info); return (EXIT_FAILURE); }