~ubuntu-branches/ubuntu/saucy/gengetopt/saucy-proposed

« back to all changes in this revision

Viewing changes to src/cmdline.c

  • Committer: Package Import Robot
  • Author(s): Alessio Treglia
  • Date: 2013-05-09 12:48:17 UTC
  • mfrom: (16.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20130509124817-ex5jkvyh7cu8o22c
Tags: 2.22.6-2
* Upload to unstable.
* Fix VCS URLs.
* Bump Standards.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
  File autogenerated by gengetopt version 2.22.5
 
2
  File autogenerated by gengetopt version 2.22.6
3
3
  generated with the following command:
4
4
  ../src/gengetopt --input=../../src/cmdline.ggo --output-dir=../../src --no-handle-version --no-handle-help --no-handle-error --string-parser
5
5
 
29
29
 
30
30
const char *gengetopt_args_info_usage = "Usage: " CMDLINE_PARSER_PACKAGE " [OPTIONS]...";
31
31
 
 
32
const char *gengetopt_args_info_versiontext = "";
 
33
 
32
34
const char *gengetopt_args_info_description = "";
33
35
 
34
36
const char *gengetopt_args_info_detailed_help[] = {
35
37
  "  -h, --help                    Print help and exit",
36
 
  "      --detailed-help           Print help, including all details and hidden \n                                  options, and exit",
 
38
  "      --detailed-help           Print help, including all details and hidden\n                                  options, and exit",
37
39
  "  -V, --version                 Print version and exit",
38
40
  "\nMain options:",
39
41
  "",
40
42
  "  -i, --input=filename          input file (default std input)",
41
 
  "  -f, --func-name=name          name of generated function  \n                                  (default=`cmdline_parser')",
42
 
  "  -a, --arg-struct-name=name    name of generated args info struct  \n                                  (default=`gengetopt_args_info')",
 
43
  "  -f, --func-name=name          name of generated function\n                                  (default=`cmdline_parser')",
 
44
  "  -a, --arg-struct-name=name    name of generated args info struct\n                                  (default=`gengetopt_args_info')",
43
45
  "  -F, --file-name=name          name of generated file  (default=`cmdline')",
44
46
  "      --output-dir=path         output directory",
45
 
  "  \n  if this option is not specified, the files are generated in the current \n  directory.\n",
 
47
  "  \n  if this option is not specified, the files are generated in the current\n  directory.\n",
46
48
  "      --header-output-dir=path  header output directory",
47
49
  "      --src-output-dir=path     source output directory",
48
50
  "  -c, --c-extension=ext         extension of c file  (default=`c')",
49
51
  "  -H, --header-extension=ext    extension of header file  (default=`h')",
50
52
  "  -l, --long-help               long usage line in help",
51
53
  "  \n  The usage line will print all the options, e.g.,\n\n  sample1 -iINT|--int-opt=INT [-h|--help]\n",
52
 
  "      --default-optional        by default, an option is considered optional if \n                                  not specified otherwise",
53
 
  "  -u, --unamed-opts[=STRING]    accept options without names (e.g., file names) \n                                   (default=`FILES')",
54
 
  "\nThe parser generated is thought to be used to parse the command line arguments. \nHowever, you can also generate parsers for configuration files, or strings that \ncontain the arguments to parse, by using the following two options.\n",
 
54
  "      --default-optional        by default, an option is considered optional if\n                                  not specified otherwise",
 
55
  "  -u, --unamed-opts[=STRING]    accept options without names (e.g., file names)\n                                  (default=`FILES')",
 
56
  "\nThe parser generated is thought to be used to parse the command line arguments.\nHowever, you can also generate parsers for configuration files, or strings that\ncontain the arguments to parse, by using the following two options.\n",
55
57
  "  -C, --conf-parser             generate a config file parser",
56
 
  "  -S, --string-parser           generate a string parser (the string contains \n                                  the command line)",
57
 
  "",
 
58
  "  -S, --string-parser           generate a string parser (the string contains\n                                  the command line)",
58
59
  "\nAdditional options:",
59
 
  "  -G, --include-getopt          adds the code for getopt_long in the generated \n                                  C file",
 
60
  "  -G, --include-getopt          adds the code for getopt_long in the generated\n                                  C file",
60
61
  "  -n, --no-handle-help          do not handle --help|-h automatically",
61
 
  "  \n  If --no-handle-help is specified, the command line option --help|-h will not \n  be handled automatically, so the programmer will be able to print some other \n  information; then the function for printing the standard help output can be \n  used; this function is called <parser-name>_print_help.\n\n  Notice that, although the programmer can handle --help|-h manually, the \n  parser will return after finding such option: the other command line options, \n  if any, will be ignored.  In case you want to have full control on --help|-h, \n  you should use --ho-help.\n",
 
62
  "  \n  If --no-handle-help is specified, the command line option --help|-h will not\n  be handled automatically, so the programmer will be able to print some other\n  information; then the function for printing the standard help output can be\n  used; this function is called <parser-name>_print_help.\n\n  Notice that, although the programmer can handle --help|-h manually, the\n  parser will return after finding such option: the other command line options,\n  if any, will be ignored.  In case you want to have full control on --help|-h,\n  you should use --ho-help.\n",
62
63
  "      --no-help                 do not add --help|-h automatically",
63
 
  "  \n  With this option you can disable the automatic addition of options --help|-h. \n  The programmer will then be able to add this option in the input file and \n  handle it as he sees fit.  Notice that --no-help will also disable the \n  automatic options --detailed-help and --full-help.\n\n  The programmer can still define options with short character h as he wants, \n  but he cannot define options help, unless he specifies --no-help (otherwise \n  an error will be printed).\n",
 
64
  "  \n  With this option you can disable the automatic addition of options --help|-h.\n  The programmer will then be able to add this option in the input file and\n  handle it as he sees fit.  Notice that --no-help will also disable the\n  automatic options --detailed-help and --full-help.\n\n  The programmer can still define options with short character h as he wants,\n  but he cannot define options help, unless he specifies --no-help (otherwise\n  an error will be printed).\n",
64
65
  "  -N, --no-handle-version       do not handle --version|-V automatically",
65
66
  "      --no-version              do not add --version|-V automatically",
66
67
  "  \n  See above the details about --no-handle-help and --no-help, respectively.\n",
67
68
  "  -e, --no-handle-error         do not exit on errors",
68
 
  "  \n  With this option, if the generated parser encounters an error (e.g., an \n  unknown option) it does not make the main program exit; instead, the parser \n  function returns a value different 0, and the main program can print a help \n  message.\n",
69
 
  "      --show-required[=STRING]  in the output of help will specify which \n                                  options are mandatory, by using the optional \n                                  passed string  (default=`(mandatory)')",
70
 
  "  -g, --gen-version             put gengetopt version in the generated file  \n                                  (default=on)",
71
 
  "      --set-package=STRING      set the package name (override package defined \n                                  in the .ggo file)",
72
 
  "      --set-version=STRING      set the version number (override version \n                                  defined in the .ggo file)",
73
 
  "      --show-help               show the output of --help instead of generating \n                                  code",
74
 
  "      --show-full-help          show the output of --full-help (i.e., including \n                                  hidden options) instead of generating code",
75
 
  "      --show-detailed-help      show the output of --detailed-help (i.e., \n                                  including details and hidden options) instead \n                                  of generating code",
76
 
  "      --show-version            show the output of --version instead of \n                                  generating code",
 
69
  "  \n  With this option, if the generated parser encounters an error (e.g., an\n  unknown option) it does not make the main program exit; instead, the parser\n  function returns a value different 0, and the main program can print a help\n  message.\n",
 
70
  "      --show-required[=STRING]  in the output of help will specify which\n                                  options are mandatory, by using the optional\n                                  passed string  (default=`(mandatory)')",
 
71
  "      --strict-hidden           completely hide hidden options",
 
72
  "  -g, --gen-version             put gengetopt version in the generated file\n                                  (default=on)",
 
73
  "      --set-package=STRING      set the package name (override package defined\n                                  in the .ggo file)",
 
74
  "      --set-version=STRING      set the version number (override version\n                                  defined in the .ggo file)",
 
75
  "      --show-help               show the output of --help instead of generating\n                                  code",
 
76
  "      --show-full-help          show the output of --full-help (i.e., including\n                                  hidden options) instead of generating code",
 
77
  "      --show-detailed-help      show the output of --detailed-help (i.e.,\n                                  including details and hidden options) instead\n                                  of generating code",
 
78
  "      --show-version            show the output of --version instead of\n                                  generating code",
77
79
  "\nPlease refer to the info manual for further explanations.",
78
80
    0
79
81
};
104
106
  gengetopt_args_info_help[20] = gengetopt_args_info_detailed_help[22];
105
107
  gengetopt_args_info_help[21] = gengetopt_args_info_detailed_help[23];
106
108
  gengetopt_args_info_help[22] = gengetopt_args_info_detailed_help[24];
107
 
  gengetopt_args_info_help[23] = gengetopt_args_info_detailed_help[25];
108
 
  gengetopt_args_info_help[24] = gengetopt_args_info_detailed_help[27];
 
109
  gengetopt_args_info_help[23] = gengetopt_args_info_detailed_help[26];
 
110
  gengetopt_args_info_help[24] = gengetopt_args_info_detailed_help[28];
109
111
  gengetopt_args_info_help[25] = gengetopt_args_info_detailed_help[29];
110
 
  gengetopt_args_info_help[26] = gengetopt_args_info_detailed_help[30];
111
 
  gengetopt_args_info_help[27] = gengetopt_args_info_detailed_help[32];
 
112
  gengetopt_args_info_help[26] = gengetopt_args_info_detailed_help[31];
 
113
  gengetopt_args_info_help[27] = gengetopt_args_info_detailed_help[33];
112
114
  gengetopt_args_info_help[28] = gengetopt_args_info_detailed_help[34];
113
115
  gengetopt_args_info_help[29] = gengetopt_args_info_detailed_help[35];
114
116
  gengetopt_args_info_help[30] = gengetopt_args_info_detailed_help[36];
193
195
  args_info->no_version_given = 0 ;
194
196
  args_info->no_handle_error_given = 0 ;
195
197
  args_info->show_required_given = 0 ;
 
198
  args_info->strict_hidden_given = 0 ;
196
199
  args_info->gen_version_given = 0 ;
197
200
  args_info->set_package_given = 0 ;
198
201
  args_info->set_version_given = 0 ;
258
261
  args_info->unamed_opts_help = gengetopt_args_info_detailed_help[18] ;
259
262
  args_info->conf_parser_help = gengetopt_args_info_detailed_help[20] ;
260
263
  args_info->string_parser_help = gengetopt_args_info_detailed_help[21] ;
261
 
  args_info->include_getopt_help = gengetopt_args_info_detailed_help[24] ;
262
 
  args_info->no_handle_help_help = gengetopt_args_info_detailed_help[25] ;
263
 
  args_info->no_help_help = gengetopt_args_info_detailed_help[27] ;
264
 
  args_info->no_handle_version_help = gengetopt_args_info_detailed_help[29] ;
265
 
  args_info->no_version_help = gengetopt_args_info_detailed_help[30] ;
266
 
  args_info->no_handle_error_help = gengetopt_args_info_detailed_help[32] ;
267
 
  args_info->show_required_help = gengetopt_args_info_detailed_help[34] ;
 
264
  args_info->include_getopt_help = gengetopt_args_info_detailed_help[23] ;
 
265
  args_info->no_handle_help_help = gengetopt_args_info_detailed_help[24] ;
 
266
  args_info->no_help_help = gengetopt_args_info_detailed_help[26] ;
 
267
  args_info->no_handle_version_help = gengetopt_args_info_detailed_help[28] ;
 
268
  args_info->no_version_help = gengetopt_args_info_detailed_help[29] ;
 
269
  args_info->no_handle_error_help = gengetopt_args_info_detailed_help[31] ;
 
270
  args_info->show_required_help = gengetopt_args_info_detailed_help[33] ;
 
271
  args_info->strict_hidden_help = gengetopt_args_info_detailed_help[34] ;
268
272
  args_info->gen_version_help = gengetopt_args_info_detailed_help[35] ;
269
273
  args_info->set_package_help = gengetopt_args_info_detailed_help[36] ;
270
274
  args_info->set_version_help = gengetopt_args_info_detailed_help[37] ;
281
285
  printf ("%s %s\n",
282
286
     (strlen(CMDLINE_PARSER_PACKAGE_NAME) ? CMDLINE_PARSER_PACKAGE_NAME : CMDLINE_PARSER_PACKAGE),
283
287
     CMDLINE_PARSER_VERSION);
 
288
 
 
289
  if (strlen(gengetopt_args_info_versiontext) > 0)
 
290
    printf("\n%s\n", gengetopt_args_info_versiontext);
284
291
}
285
292
 
286
293
static void print_help_common(void) {
465
472
    write_into_file(outfile, "no-handle-error", 0, 0 );
466
473
  if (args_info->show_required_given)
467
474
    write_into_file(outfile, "show-required", args_info->show_required_orig, 0);
 
475
  if (args_info->strict_hidden_given)
 
476
    write_into_file(outfile, "strict-hidden", 0, 0 );
468
477
  if (args_info->gen_version_given)
469
478
    write_into_file(outfile, "gen-version", 0, 0 );
470
479
  if (args_info->set_package_given)
677
686
{
678
687
  int c;        /* Character of the parsed option.  */
679
688
 
680
 
  int error = 0;
 
689
  int error_occurred = 0;
681
690
  struct gengetopt_args_info local_args_info;
682
691
  
683
692
  int override;
731
740
        { "no-version", 0, NULL, 0 },
732
741
        { "no-handle-error",    0, NULL, 'e' },
733
742
        { "show-required",      2, NULL, 0 },
 
743
        { "strict-hidden",      0, NULL, 0 },
734
744
        { "gen-version",        0, NULL, 'g' },
735
745
        { "set-package",        1, NULL, 0 },
736
746
        { "set-version",        1, NULL, 0 },
1069
1079
              goto failure;
1070
1080
          
1071
1081
          }
 
1082
          /* completely hide hidden options.  */
 
1083
          else if (strcmp (long_options[option_index].name, "strict-hidden") == 0)
 
1084
          {
 
1085
          
 
1086
          
 
1087
            if (update_arg( 0 , 
 
1088
                 0 , &(args_info->strict_hidden_given),
 
1089
                &(local_args_info.strict_hidden_given), optarg, 0, 0, ARG_NO,
 
1090
                check_ambiguity, override, 0, 0,
 
1091
                "strict-hidden", '-',
 
1092
                additional_error))
 
1093
              goto failure;
 
1094
          
 
1095
          }
1072
1096
          /* set the package name (override package defined in the .ggo file).  */
1073
1097
          else if (strcmp (long_options[option_index].name, "set-package") == 0)
1074
1098
          {
1170
1194
 
1171
1195
  cmdline_parser_release (&local_args_info);
1172
1196
 
1173
 
  if ( error )
 
1197
  if ( error_occurred )
1174
1198
    return (EXIT_FAILURE);
1175
1199
 
1176
1200
  return 0;