Use getopt gnulib module. Always use getopt_long.
authorSimon Josefsson <simon@josefsson.org>
Fri, 12 Aug 2005 13:12:07 +0000 (13:12 +0000)
committerSimon Josefsson <simon@josefsson.org>
Fri, 12 Aug 2005 13:12:07 +0000 (13:12 +0000)
configure.in
src/asn1Coding.c
src/asn1Decoding.c
src/asn1Parser.c

index e097fea..8703d30 100644 (file)
@@ -64,8 +64,7 @@ fi
 AC_MSG_NOTICE([Detecting C library capabilities])
 
 AC_HEADER_STDC
-AC_CHECK_HEADERS(getopt.h unistd.h strings.h inttypes.h stdint.h)
-AC_CHECK_FUNCS(getopt_long)
+AC_CHECK_HEADERS(unistd.h strings.h inttypes.h stdint.h)
 AC_FUNC_ALLOCA
 
 AC_MSG_NOTICE([Detecting system's parameters])
@@ -80,7 +79,7 @@ AC_CHECK_SIZEOF(unsigned char, 1)
 
 gl_SOURCE_BASE(gl)
 gl_M4_BASE(gl/m4)
-gl_MODULES(memmove)
+gl_MODULES(memmove getopt)
 gl_LGPL
 gl_INIT
 
@@ -89,7 +88,6 @@ AM_PROG_LIBTOOL
 
 LIBTASN1_LIBS="-L${libdir} -ltasn1 $LIBS"
 LIBTASN1_CFLAGS="-I${includedir}"
-
 AC_SUBST(LIBTASN1_LIBS)
 AC_SUBST(LIBTASN1_CFLAGS)
 
index 5a7ad07..62804cb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *      Copyright (C) 2002 Fabio Fiorina
+ *      Copyright (C) 2002, 2005 Fabio Fiorina
  *
  * This file is part of LIBTASN1.
  *
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-
-#ifdef HAVE_GETOPT_H
-  #include <getopt.h>
-#endif
+#include <getopt.h>
 
 char version_man[] = "asn1Coding (GNU libtasn1) " VERSION;
 
@@ -49,7 +46,6 @@ char help_man[] = "asn1Coding generates a DER encoding from a file\n"
                   " <file1> file with ASN1 definitions.\n"
                   " <file2> file with assignments.\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"
@@ -57,15 +53,6 @@ char help_man[] = "asn1Coding generates a DER encoding from a file\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
 
 
 #define ASSIGNMENT_SUCCESS 1
@@ -127,7 +114,6 @@ int
 main(int argc,char *argv[])
 {
 
-#ifdef HAVE_GETOPT_LONG
   static struct option long_options[] =
   {
     {"help",    no_argument,       0, 'h'},
@@ -137,8 +123,6 @@ main(int argc,char *argv[])
     {0, 0, 0, 0}
   };
   int option_index=0;
-#endif
-
  int option_result;
  char *outputFileName=NULL;
  char *inputFileAsnName=NULL;
@@ -162,11 +146,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;
 
index 3176ba6..05c5193 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *      Copyright (C) 2002 Fabio Fiorina
+ *      Copyright (C) 2002, 2005 Fabio Fiorina
  *
  * This file is part of LIBTASN1.
  *
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-
-#ifdef HAVE_GETOPT_H
-  #include <getopt.h>
-#endif
+#include <getopt.h>
 
 char version_man[] = "asn1Decoding (GNU libtasn1) " VERSION;
 
@@ -50,17 +47,10 @@ char help_man[] = "asn1Decoding generates an ASN1 type from a file\n"
                   " <file2> file with a DER coding.\n"
                   " <type>  ASN1 type name\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
 
 
 
@@ -72,7 +62,6 @@ int
 main(int argc,char *argv[])
 {
 
-#ifdef HAVE_GETOPT_LONG
   static struct option long_options[] =
   {
     {"help",    no_argument,       0, 'h'},
@@ -81,8 +70,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 +90,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;
 
index c67b104..0acfd35 100644 (file)
@@ -1,5 +1,5 @@
 /*\r
- *      Copyright (C) 2002 Fabio Fiorina\r
+ *      Copyright (C) 2002, 2005 Fabio Fiorina\r
  *\r
  * This file is part of LIBTASN1.\r
  *\r
 #ifdef HAVE_UNISTD_H\r
 #include <unistd.h>\r
 #endif\r
-\r
-#ifdef HAVE_GETOPT_H\r
-  #include <getopt.h>\r
-#endif\r
+#include <getopt.h>\r
 \r
 char version_man[] = "asn1Parser (GNU libasn1) " VERSION;\r
 \r
@@ -47,7 +44,6 @@ char help_man[] = "asn1Parser reads files with ASN1 definitions and\n"
                   "\n"\r
                   "Usage: asn1Parser [options] file\n"\r
                   "\n"\r
-#ifdef HAVE_GETOPT_LONG\r
                   "Operation modes:\n"\r
                   "  -h, --help    shows this message and exit\n"\r
                   "  -v, --version shows version information and exit.\n"\r
@@ -56,16 +52,6 @@ char help_man[] = "asn1Parser reads files with ASN1 definitions and\n"
                   "Output:\n"\r
                   "  -o <file>, --output <file>  output file\n"\r
                   "  -n <name>, --name <name>    array name\n";\r
-#else\r
-                  "Operation modes:\n"\r
-                  "  -h    shows this message and exit\n"\r
-                  "  -v    shows version information and exit.\n"\r
-                  "  -c    checks the syntax only.\n"\r
-                  "\n"\r
-                  "Output:\n"\r
-                  "  -o <file>  output file\n"\r
-                  "  -n <name>  array name\n";\r
-#endif\r
 \r
 /********************************************************/\r
 /* Function : main                                      */\r
@@ -74,8 +60,6 @@ char help_man[] = "asn1Parser reads files with ASN1 definitions and\n"
 int\r
 main(int argc,char *argv[])\r
 {\r
-\r
-#ifdef HAVE_GETOPT_LONG\r
   static struct option long_options[] =\r
   {\r
     {"help",    no_argument,       0, 'h'},\r
@@ -86,8 +70,6 @@ main(int argc,char *argv[])
     {0, 0, 0, 0}\r
   };\r
   int option_index = 0;\r
-#endif\r
-\r
  int option_result;\r
  char *outputFileName=NULL;\r
  char *inputFileName=NULL;\r
@@ -103,11 +85,7 @@ main(int argc,char *argv[])
 \r
  while(1){\r
 \r
-#ifdef HAVE_GETOPT_LONG\r
    option_result=getopt_long(argc,argv,"hvco:n:",long_options,&option_index);\r
-#else\r
-   option_result=getopt(argc,argv,"hvco:n:");\r
-#endif\r
 \r
    if(option_result == -1) break;\r
 \r