From 4c92acfbc3f7b7263979dcb3ac73da9aef9d87f8 Mon Sep 17 00:00:00 2001 From: Simon Josefsson Date: Thu, 19 Oct 2006 14:46:24 +0000 Subject: Improve --help output. Assume getopt_long, since gnulib provides it. --- src/asn1Parser.c | 50 +++++++++++++------------------------------------- 1 file changed, 13 insertions(+), 37 deletions(-) (limited to 'src/asn1Parser.c') 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 #include -#include #include #include +#include + +#include #include #include -#ifdef HAVE_GETOPT_H - #include -#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 , --output output file\n" - " -n , --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 output file\n" - " -n 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); -- cgit v1.2.3