2 File autogenerated by gengetopt version 2.22.6
3 generated with the following command:
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.
11 /* If we use autoconf. */
21 #define FIX_UNUSED(X) (void) (X) /* avoid warnings for unused params */
28 const char *gengetopt_args_info_purpose = "A consensus neural network protein secondary structure prediction method\n- Trained with SCOP 1.75 data and UniRef90 release 15.4";
30 const char *gengetopt_args_info_usage = "Usage: Jnet [OPTIONS]...";
32 const char *gengetopt_args_info_versiontext = "";
34 const char *gengetopt_args_info_description = "";
36 const char *gengetopt_args_info_help[] = {
37 " -h, --help Print help and exit",
38 " -V, --version Print version and exit",
39 " -H, --hmmer=filename HMMER profile",
40 " -p, --pssm=filename PSIBLAST PSSM",
41 " -T, --test Flag for test style output (default=off)",
42 "\n Group: output\n Output options",
43 " --concise concise output (default)",
44 " --human[=INT] human readable output. Optionally, can take a width\n argument [default: 60]",
52 } cmdline_parser_arg_type;
55 void clear_given (struct gengetopt_args_info *args_info);
57 void clear_args (struct gengetopt_args_info *args_info);
60 cmdline_parser_internal (int argc, char **argv, struct gengetopt_args_info *args_info,
61 struct cmdline_parser_params *params, const char *additional_error);
64 cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error);
67 gengetopt_strdup (const char *s);
70 void clear_given (struct gengetopt_args_info *args_info)
72 args_info->help_given = 0 ;
73 args_info->version_given = 0 ;
74 args_info->hmmer_given = 0 ;
75 args_info->pssm_given = 0 ;
76 args_info->test_given = 0 ;
77 args_info->concise_given = 0 ;
78 args_info->human_given = 0 ;
79 args_info->output_group_counter = 0 ;
83 void clear_args (struct gengetopt_args_info *args_info)
85 FIX_UNUSED (args_info);
86 args_info->hmmer_arg = NULL;
87 args_info->hmmer_orig = NULL;
88 args_info->pssm_arg = NULL;
89 args_info->pssm_orig = NULL;
90 args_info->test_flag = 0;
91 args_info->human_orig = NULL;
96 void init_args_info(struct gengetopt_args_info *args_info)
100 args_info->help_help = gengetopt_args_info_help[0] ;
101 args_info->version_help = gengetopt_args_info_help[1] ;
102 args_info->hmmer_help = gengetopt_args_info_help[2] ;
103 args_info->pssm_help = gengetopt_args_info_help[3] ;
104 args_info->test_help = gengetopt_args_info_help[4] ;
105 args_info->concise_help = gengetopt_args_info_help[6] ;
106 args_info->human_help = gengetopt_args_info_help[7] ;
111 cmdline_parser_print_version (void)
114 (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
115 CMDLINE_PARSER_VERSION);
117 if (strlen(gengetopt_args_info_versiontext) > 0)
118 printf("\n%s\n", gengetopt_args_info_versiontext);
121 static void print_help_common(void) {
122 cmdline_parser_print_version ();
124 if (strlen(gengetopt_args_info_purpose) > 0)
125 printf("\n%s\n", gengetopt_args_info_purpose);
127 if (strlen(gengetopt_args_info_usage) > 0)
128 printf("\n%s\n", gengetopt_args_info_usage);
132 if (strlen(gengetopt_args_info_description) > 0)
133 printf("%s\n\n", gengetopt_args_info_description);
137 cmdline_parser_print_help (void)
141 while (gengetopt_args_info_help[i])
142 printf("%s\n", gengetopt_args_info_help[i++]);
146 cmdline_parser_init (struct gengetopt_args_info *args_info)
148 clear_given (args_info);
149 clear_args (args_info);
150 init_args_info (args_info);
154 cmdline_parser_params_init(struct cmdline_parser_params *params)
158 params->override = 0;
159 params->initialize = 1;
160 params->check_required = 1;
161 params->check_ambiguity = 0;
162 params->print_errors = 1;
166 struct cmdline_parser_params *
167 cmdline_parser_params_create(void)
169 struct cmdline_parser_params *params =
170 (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
171 cmdline_parser_params_init(params);
176 free_string_field (char **s)
187 cmdline_parser_release (struct gengetopt_args_info *args_info)
190 free_string_field (&(args_info->hmmer_arg));
191 free_string_field (&(args_info->hmmer_orig));
192 free_string_field (&(args_info->pssm_arg));
193 free_string_field (&(args_info->pssm_orig));
194 free_string_field (&(args_info->human_orig));
198 clear_given (args_info);
203 write_into_file(FILE *outfile, const char *opt, const char *arg, const char *values[])
207 fprintf(outfile, "%s=\"%s\"\n", opt, arg);
209 fprintf(outfile, "%s\n", opt);
215 cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
221 fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
225 if (args_info->help_given)
226 write_into_file(outfile, "help", 0, 0 );
227 if (args_info->version_given)
228 write_into_file(outfile, "version", 0, 0 );
229 if (args_info->hmmer_given)
230 write_into_file(outfile, "hmmer", args_info->hmmer_orig, 0);
231 if (args_info->pssm_given)
232 write_into_file(outfile, "pssm", args_info->pssm_orig, 0);
233 if (args_info->test_given)
234 write_into_file(outfile, "test", 0, 0 );
235 if (args_info->concise_given)
236 write_into_file(outfile, "concise", 0, 0 );
237 if (args_info->human_given)
238 write_into_file(outfile, "human", args_info->human_orig, 0);
246 cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
251 outfile = fopen(filename, "w");
255 fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
259 i = cmdline_parser_dump(outfile, args_info);
266 cmdline_parser_free (struct gengetopt_args_info *args_info)
268 cmdline_parser_release (args_info);
271 /** @brief replacement of strdup, which is not standard */
273 gengetopt_strdup (const char *s)
279 result = (char*)malloc(strlen(s) + 1);
280 if (result == (char*)0)
287 reset_group_output(struct gengetopt_args_info *args_info)
289 if (! args_info->output_group_counter)
292 args_info->concise_given = 0 ;
293 args_info->human_given = 0 ;
294 free_string_field (&(args_info->human_orig));
296 args_info->output_group_counter = 0;
300 cmdline_parser (int argc, char **argv, struct gengetopt_args_info *args_info)
302 return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
306 cmdline_parser_ext (int argc, char **argv, struct gengetopt_args_info *args_info,
307 struct cmdline_parser_params *params)
310 result = cmdline_parser_internal (argc, argv, args_info, params, 0);
312 if (result == EXIT_FAILURE)
314 cmdline_parser_free (args_info);
322 cmdline_parser2 (int argc, char **argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
325 struct cmdline_parser_params params;
327 params.override = override;
328 params.initialize = initialize;
329 params.check_required = check_required;
330 params.check_ambiguity = 0;
331 params.print_errors = 1;
333 result = cmdline_parser_internal (argc, argv, args_info, ¶ms, 0);
335 if (result == EXIT_FAILURE)
337 cmdline_parser_free (args_info);
345 cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
347 int result = EXIT_SUCCESS;
349 if (cmdline_parser_required2(args_info, prog_name, 0) > 0)
350 result = EXIT_FAILURE;
352 if (result == EXIT_FAILURE)
354 cmdline_parser_free (args_info);
362 cmdline_parser_required2 (struct gengetopt_args_info *args_info, const char *prog_name, const char *additional_error)
364 int error_occurred = 0;
365 FIX_UNUSED (additional_error);
367 /* checks for required options */
368 if (! args_info->hmmer_given)
370 fprintf (stderr, "%s: '--hmmer' ('-H') option required%s\n", prog_name, (additional_error ? additional_error : ""));
375 /* checks for dependences among options */
377 return error_occurred;
381 static char *package_name = 0;
384 * @brief updates an option
385 * @param field the generic pointer to the field to update
386 * @param orig_field the pointer to the orig field
387 * @param field_given the pointer to the number of occurrence of this option
388 * @param prev_given the pointer to the number of occurrence already seen
389 * @param value the argument for this option (if null no arg was specified)
390 * @param possible_values the possible values for this option (if specified)
391 * @param default_value the default value (in case the option only accepts fixed values)
392 * @param arg_type the type of this option
393 * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
394 * @param override @see cmdline_parser_params.override
395 * @param no_free whether to free a possible previous value
396 * @param multiple_option whether this is a multiple option
397 * @param long_opt the corresponding long option
398 * @param short_opt the corresponding short option (or '-' if none)
399 * @param additional_error possible further error specification
402 int update_arg(void *field, char **orig_field,
403 unsigned int *field_given, unsigned int *prev_given,
404 char *value, const char *possible_values[],
405 const char *default_value,
406 cmdline_parser_arg_type arg_type,
407 int check_ambiguity, int override,
408 int no_free, int multiple_option,
409 const char *long_opt, char short_opt,
410 const char *additional_error)
413 const char *val = value;
421 if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
423 if (short_opt != '-')
424 fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
425 package_name, long_opt, short_opt,
426 (additional_error ? additional_error : ""));
428 fprintf (stderr, "%s: `--%s' option given more than once%s\n",
429 package_name, long_opt,
430 (additional_error ? additional_error : ""));
431 return 1; /* failure */
434 FIX_UNUSED (default_value);
436 if (field_given && *field_given && ! override)
443 val = possible_values[found];
447 *((int *)field) = !*((int *)field);
450 if (val) *((int *)field) = strtol (val, &stop_char, 0);
454 string_field = (char **)field;
455 if (!no_free && *string_field)
456 free (*string_field); /* free previous string */
457 *string_field = gengetopt_strdup (val);
464 /* check numeric conversion */
467 if (val && !(stop_char && *stop_char == '\0')) {
468 fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
469 return 1; /* failure */
476 /* store the original value */
482 if (value && orig_field) {
487 free (*orig_field); /* free previous string */
488 *orig_field = gengetopt_strdup (value);
498 cmdline_parser_internal (
499 int argc, char **argv, struct gengetopt_args_info *args_info,
500 struct cmdline_parser_params *params, const char *additional_error)
502 int c; /* Character of the parsed option. */
504 int error_occurred = 0;
505 struct gengetopt_args_info local_args_info;
512 package_name = argv[0];
514 override = params->override;
515 initialize = params->initialize;
516 check_required = params->check_required;
517 check_ambiguity = params->check_ambiguity;
520 cmdline_parser_init (args_info);
522 cmdline_parser_init (&local_args_info);
526 opterr = params->print_errors;
531 int option_index = 0;
533 static struct option long_options[] = {
534 { "help", 0, NULL, 'h' },
535 { "version", 0, NULL, 'V' },
536 { "hmmer", 1, NULL, 'H' },
537 { "pssm", 1, NULL, 'p' },
538 { "test", 0, NULL, 'T' },
539 { "concise", 0, NULL, 0 },
540 { "human", 2, NULL, 0 },
544 c = getopt_long (argc, argv, "hVH:p:T", long_options, &option_index);
546 if (c == -1) break; /* Exit from `while (1)' loop. */
550 case 'h': /* Print help and exit. */
551 cmdline_parser_print_help ();
552 cmdline_parser_free (&local_args_info);
555 case 'V': /* Print version and exit. */
556 cmdline_parser_print_version ();
557 cmdline_parser_free (&local_args_info);
560 case 'H': /* HMMER profile. */
563 if (update_arg( (void *)&(args_info->hmmer_arg),
564 &(args_info->hmmer_orig), &(args_info->hmmer_given),
565 &(local_args_info.hmmer_given), optarg, 0, 0, ARG_STRING,
566 check_ambiguity, override, 0, 0,
572 case 'p': /* PSIBLAST PSSM. */
575 if (update_arg( (void *)&(args_info->pssm_arg),
576 &(args_info->pssm_orig), &(args_info->pssm_given),
577 &(local_args_info.pssm_given), optarg, 0, 0, ARG_STRING,
578 check_ambiguity, override, 0, 0,
584 case 'T': /* Flag for test style output. */
587 if (update_arg((void *)&(args_info->test_flag), 0, &(args_info->test_given),
588 &(local_args_info.test_given), optarg, 0, 0, ARG_FLAG,
589 check_ambiguity, override, 1, 0, "test", 'T',
595 case 0: /* Long option with no short option */
596 /* concise output (default). */
597 if (strcmp (long_options[option_index].name, "concise") == 0)
600 if (args_info->output_group_counter && override)
601 reset_group_output (args_info);
602 args_info->output_group_counter += 1;
605 0 , &(args_info->concise_given),
606 &(local_args_info.concise_given), optarg, 0, 0, ARG_NO,
607 check_ambiguity, override, 0, 0,
613 /* human readable output. Optionally, can take a width argument [default: 60]. */
614 else if (strcmp (long_options[option_index].name, "human") == 0)
617 if (args_info->output_group_counter && override)
618 reset_group_output (args_info);
619 args_info->output_group_counter += 1;
621 if (update_arg( (void *)&(args_info->human_arg),
622 &(args_info->human_orig), &(args_info->human_given),
623 &(local_args_info.human_given), optarg, 0, 0, ARG_INT,
624 check_ambiguity, override, 0, 0,
632 case '?': /* Invalid option. */
633 /* `getopt_long' already printed an error message. */
636 default: /* bug: option not considered. */
637 fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
642 if (args_info->output_group_counter > 1)
644 fprintf (stderr, "%s: %d options of group output were given. At most one is required%s.\n", argv[0], args_info->output_group_counter, (additional_error ? additional_error : ""));
652 error_occurred += cmdline_parser_required2 (args_info, argv[0], additional_error);
655 cmdline_parser_release (&local_args_info);
657 if ( error_occurred )
658 return (EXIT_FAILURE);
664 cmdline_parser_release (&local_args_info);
665 return (EXIT_FAILURE);