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 | |
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')
-rw-r--r-- | src/asn1Coding.c | 46 | ||||
-rw-r--r-- | src/asn1Decoding.c | 41 | ||||
-rw-r--r-- | src/asn1Parser.c | 50 |
3 files changed, 35 insertions, 102 deletions
diff --git a/src/asn1Coding.c b/src/asn1Coding.c index 80d4525..91f5325 100644 --- a/src/asn1Coding.c +++ b/src/asn1Coding.c @@ -31,40 +31,26 @@ #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: asn1Coding [options] <file1> <file2>\n" +static const char help_man[] = + "Usage: asn1Coding [OPTION] DEFINITIONS ASSIGNMENTS\n" + "asn1Coding generates a DER encoding of ASN.1 DEFINITIONS file\n" + "and ASSIGNMENTS file with value assignments.\n" "\n" - "asn1Coding generates a DER encoding from FILE1\n" - "with ASN1 definitions and FILE2 with assignments.\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" + " -h, --help display this help and exit\n" + " -v, --version output version information and exit.\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" - "\n" - "Output:\n" - " -o <file>, --output <file> output file.\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" -#endif "Report bugs to <" PACKAGE_BUGREPORT ">."; #define ASSIGNMENT_SUCCESS 1 @@ -125,8 +111,6 @@ void createFileName(char *inputFileName, char **outputFileName) int main(int argc,char *argv[]) { - -#ifdef HAVE_GETOPT_LONG static struct option long_options[] = { {"help", no_argument, 0, 'h'}, @@ -136,8 +120,6 @@ main(int argc,char *argv[]) {0, 0, 0, 0} }; int option_index=0; -#endif - int option_result; char *outputFileName=NULL; char *inputFileAsnName=NULL; @@ -161,11 +143,7 @@ main(int argc,char *argv[]) while(1){ -#ifdef HAVE_GETOPT_LONG option_result=getopt_long(argc,argv,"hvco:",long_options,&option_index); -#else - option_result=getopt(argc,argv,"hvco:"); -#endif if(option_result == -1) break; diff --git a/src/asn1Decoding.c b/src/asn1Decoding.c index c948f98..a3db3fe 100644 --- a/src/asn1Decoding.c +++ b/src/asn1Decoding.c @@ -31,37 +31,24 @@ #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[] = - "asn1Decoding generates an ASN1 type from FILE1\n" - "with ASN1 definitions and FILE2 with a DER encoding.\n" +static const char help_man[] = + "Usage: asn1Decoding [OPTION] DEFINITIONS ENCODED ASN1TYPE\n" + "asn1Decoding decodes DER data in ENCODED file, for the ASN1TYPE element\n" + "described in ASN.1 DEFINITIONS file, and print decoded structures.\n" "\n" - "Usage: asn1Decoding [options] <file1> <file2> <type>\n" - " <file1> file with ASN1 definitions.\n" - " <file2> file with a DER coding.\n" - " <type> ASN1 type name\n" + " -c, --check checks the syntax only\n" + " -h, --help display this help and exit\n" + " -v, --version output version information and exit.\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" -#else - "Operation modes:\n" - " -h shows this message and exit.\n" - " -v shows version information and exit.\n" - " -c checks the syntax only.\n" -#endif "Report bugs to <" PACKAGE_BUGREPORT ">."; /********************************************************/ @@ -71,8 +58,6 @@ char help_man[] = int main(int argc,char *argv[]) { - -#ifdef HAVE_GETOPT_LONG static struct option long_options[] = { {"help", no_argument, 0, 'h'}, @@ -81,8 +66,6 @@ main(int argc,char *argv[]) {0, 0, 0, 0} }; int option_index = 0; -#endif - int option_result; char *inputFileAsnName=NULL; char *inputFileDerName=NULL; @@ -103,11 +86,7 @@ main(int argc,char *argv[]) while(1){ -#ifdef HAVE_GETOPT_LONG option_result=getopt_long(argc,argv,"hvc",long_options,&option_index); -#else - option_result=getopt(argc,argv,"hvc"); -#endif if(option_result == -1) break; 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); |