diff options
author | Simon Josefsson <simon@josefsson.org> | 2006-10-19 14:46:24 +0000 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2006-10-19 14:46:24 +0000 |
commit | 4c92acfbc3f7b7263979dcb3ac73da9aef9d87f8 (patch) | |
tree | 8eb516c980218b30dfaca5b6bd56032a0d60d47f /src/asn1Parser.c | |
parent | 314ad1d95cf03c2aff2ae873f25cbb82a5eec3d7 (diff) | |
download | libtasn1-4c92acfbc3f7b7263979dcb3ac73da9aef9d87f8.tar.gz libtasn1-4c92acfbc3f7b7263979dcb3ac73da9aef9d87f8.tar.bz2 libtasn1-4c92acfbc3f7b7263979dcb3ac73da9aef9d87f8.zip |
Improve --help output. Assume getopt_long, since gnulib provides it.
Diffstat (limited to 'src/asn1Parser.c')
-rw-r--r-- | src/asn1Parser.c | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/src/asn1Parser.c b/src/asn1Parser.c index 6d111f0..ce8d609 100644 --- a/src/asn1Parser.c +++ b/src/asn1Parser.c @@ -31,41 +31,27 @@ #include <stdio.h> #include <string.h> -#include <libtasn1.h> #include <stdlib.h> #include <unistd.h> +#include <getopt.h> + +#include <libtasn1.h> #include <progname.h> #include <version-etc.h> -#ifdef HAVE_GETOPT_H - #include <getopt.h> -#endif - -char help_man[] = - "Usage: asn1Parser [options] FILE\n" - "asn1Parser reads FILE with ASN1 definitions and\n" - "generates a C array to use with libtasn1 functions.\n" +static const char help_man[] = + "Usage: asn1Parser [OPTION] FILE\n" + "Read FILE with ASN.1 definitions and generate\n" + "a C array that is used with libtasn1 functions.\n" "\n" -#ifdef HAVE_GETOPT_LONG - "Operation modes:\n" - " -h, --help shows this message and exit\n" - " -v, --version shows version information and exit.\n" - " -c, --check checks the syntax only.\n" + "Mandatory arguments to long options are mandatory for short options too.\n" + " -c, --check checks the syntax only\n" + " -o, --output FILE output file\n" + " -n, --name NAME array name\n" + " -h, --help display this help and exit\n" + " -v, --version output version information and exit.\n" "\n" - "Output:\n" - " -o <file>, --output <file> output file\n" - " -n <name>, --name <name> array name\n" -#else - "Operation modes:\n" - " -h shows this message and exit\n" - " -v shows version information and exit.\n" - " -c checks the syntax only.\n" - "\n" - "Output:\n" - " -o <file> output file\n" - " -n <name> array name\n" -#endif "Report bugs to <" PACKAGE_BUGREPORT ">."; /********************************************************/ @@ -75,8 +61,6 @@ char help_man[] = int main(int argc,char *argv[]) { - -#ifdef HAVE_GETOPT_LONG static struct option long_options[] = { {"help", no_argument, 0, 'h'}, @@ -87,8 +71,6 @@ main(int argc,char *argv[]) {0, 0, 0, 0} }; int option_index = 0; -#endif - int option_result; char *outputFileName=NULL; char *inputFileName=NULL; @@ -104,21 +86,15 @@ main(int argc,char *argv[]) while(1){ -#ifdef HAVE_GETOPT_LONG option_result=getopt_long(argc,argv,"hvco:n:",long_options,&option_index); -#else - option_result=getopt(argc,argv,"hvco:n:"); -#endif if(option_result == -1) break; switch(option_result){ case 0: -#ifdef HAVE_GETOPT_LONG printf("option %s",long_options[option_index].name); if(optarg) printf(" with arg %s",optarg); printf("\n"); -#endif break; case 'h': /* HELP */ printf("%s\n",help_man); |