diff options
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | configure.in | 2 | ||||
-rw-r--r-- | gl/Makefile.am | 20 | ||||
-rw-r--r-- | gl/m4/gnulib-cache.m4 | 4 | ||||
-rw-r--r-- | gl/m4/gnulib-comp.m4 | 8 | ||||
-rw-r--r-- | gl/m4/stdarg.m4 | 40 | ||||
-rw-r--r-- | gl/progname.c | 50 | ||||
-rw-r--r-- | gl/progname.h | 60 | ||||
-rw-r--r-- | gl/version-etc-fsf.c | 31 | ||||
-rw-r--r-- | gl/version-etc.c | 173 | ||||
-rw-r--r-- | gl/version-etc.h | 37 | ||||
-rw-r--r-- | lib/libtasn1.h | 2 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/asn1Coding.c | 11 | ||||
-rw-r--r-- | src/asn1Decoding.c | 17 | ||||
-rw-r--r-- | src/asn1Parser.c | 11 |
16 files changed, 441 insertions, 29 deletions
diff --git a/Makefile.am b/Makefile.am index 07aaaf0..f1af529 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,7 +27,7 @@ EXTRA_DIST = windows/asn1-parser/asn1-parser.vcproj \ windows/test-parser/test-parser.vcproj \ windows/test-tree/test-tree.vcproj -SUBDIRS = lib src tests doc +SUBDIRS = gl lib src tests doc ACLOCAL_AMFLAGS = -I m4 -I gl/m4 diff --git a/configure.in b/configure.in index 452de88..9d4f4b8 100644 --- a/configure.in +++ b/configure.in @@ -149,6 +149,6 @@ elif ! mv fixhdr.tmp $srcdir/lib/libtasn1.h; then fi AC_CONFIG_FILES([Makefile src/Makefile tests/Makefile lib/Makefile \ - lib/libtasn1.pc lib/libtasn1-config doc/Makefile \ + gl/Makefile lib/libtasn1.pc lib/libtasn1-config doc/Makefile \ doc/reference/Makefile]) AC_OUTPUT diff --git a/gl/Makefile.am b/gl/Makefile.am index 130c33e..1074d81 100644 --- a/gl/Makefile.am +++ b/gl/Makefile.am @@ -9,7 +9,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=. --libtool --macro-prefix=gl gendocs getopt maintainer-makefile memmove strdup +# Reproduce by: gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=. --libtool --macro-prefix=gl gendocs getopt maintainer-makefile memmove progname strdup version-etc-fsf AUTOMAKE_OPTIONS = 1.5 gnits @@ -61,6 +61,12 @@ EXTRA_DIST += memmove.c ## end gnulib module memmove +## begin gnulib module progname + +libgnu_la_SOURCES += progname.h progname.c + +## end gnulib module progname + ## begin gnulib module strdup @@ -82,11 +88,17 @@ MOSTLYCLEANFILES += unistd.h ## end gnulib module unistd -## begin gnulib module dummy +## begin gnulib module version-etc + +libgnu_la_SOURCES += version-etc.h version-etc.c + +## end gnulib module version-etc + +## begin gnulib module version-etc-fsf -libgnu_la_SOURCES += dummy.c +libgnu_la_SOURCES += version-etc-fsf.c -## end gnulib module dummy +## end gnulib module version-etc-fsf mostlyclean-local: mostlyclean-generic diff --git a/gl/m4/gnulib-cache.m4 b/gl/m4/gnulib-cache.m4 index b3808ab..43f6520 100644 --- a/gl/m4/gnulib-cache.m4 +++ b/gl/m4/gnulib-cache.m4 @@ -15,11 +15,11 @@ # Specification in the form of a command-line invocation: -# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=. --libtool --macro-prefix=gl gendocs getopt maintainer-makefile memmove strdup +# gnulib-tool --import --dir=. --local-dir=gl/override --lib=libgnu --source-base=gl --m4-base=gl/m4 --doc-base=doc --aux-dir=. --libtool --macro-prefix=gl gendocs getopt maintainer-makefile memmove progname strdup version-etc-fsf # Specification in the form of a few gnulib-tool.m4 macro invocations: gl_LOCAL_DIR([gl/override]) -gl_MODULES([gendocs getopt maintainer-makefile memmove strdup]) +gl_MODULES([gendocs getopt maintainer-makefile memmove progname strdup version-etc-fsf]) gl_AVOID([]) gl_SOURCE_BASE([gl]) gl_M4_BASE([gl/m4]) diff --git a/gl/m4/gnulib-comp.m4 b/gl/m4/gnulib-comp.m4 index 194bea6..5f0a73e 100644 --- a/gl/m4/gnulib-comp.m4 +++ b/gl/m4/gnulib-comp.m4 @@ -38,6 +38,7 @@ AC_DEFUN([gl_INIT], gl_source_base='gl' gl_GETOPT gl_FUNC_MEMMOVE + gl_STDARG_H gl_FUNC_STRDUP gl_HEADER_UNISTD m4_popdef([AC_REPLACE_FUNCS]) @@ -76,17 +77,22 @@ AC_DEFUN([gl_FILE_LIST], [ build-aux/gendocs.sh build-aux/maint.mk doc/gendocs_template - lib/dummy.c lib/getopt.c lib/getopt1.c lib/getopt_.h lib/getopt_int.h lib/gettext.h lib/memmove.c + lib/progname.c + lib/progname.h lib/strdup.c lib/strdup.h + lib/version-etc-fsf.c + lib/version-etc.c + lib/version-etc.h m4/getopt.m4 m4/memmove.m4 + m4/stdarg.m4 m4/strdup.m4 m4/unistd_h.m4 ]) diff --git a/gl/m4/stdarg.m4 b/gl/m4/stdarg.m4 new file mode 100644 index 0000000..e8e680a --- /dev/null +++ b/gl/m4/stdarg.m4 @@ -0,0 +1,40 @@ +# stdarg.m4 serial 1 +dnl Copyright (C) 2006 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. +dnl Provide a working va_copy in combination with <stdarg.h>. + +AC_DEFUN([gl_STDARG_H], +[ + AC_MSG_CHECKING([for va_copy]) + AC_CACHE_VAL([gl_cv_func_va_copy], [ + AC_TRY_COMPILE([#include <stdarg.h>], [ +#ifndef va_copy +void (*func) (va_list, va_list) = va_copy; +#endif +], + [gl_cv_func_va_copy=yes], [gl_cv_func_va_copy=no])]) + AC_MSG_RESULT([$gl_cv_func_va_copy]) + if test $gl_cv_func_va_copy = no; then + # Provide a substitute, either __va_copy or as a simple assignment. + AC_CACHE_VAL([gl_cv_func___va_copy], [ + AC_TRY_COMPILE([#include <stdarg.h>], [ +#ifndef __va_copy +error, bail out +#endif +], + [gl_cv_func___va_copy=yes], [gl_cv_func___va_copy=no])]) + if test $gl_cv_func___va_copy = yes; then + AC_DEFINE([va_copy], [__va_copy], + [Define as a macro for copying va_list variables.]) + else + AH_VERBATIM([gl_VA_COPY], [/* A replacement for va_copy, if needed. */ +#define gl_va_copy(a,b) ((a) = (b))]) + AC_DEFINE([va_copy], [gl_va_copy], + [Define as a macro for copying va_list variables.]) + fi + fi +]) diff --git a/gl/progname.c b/gl/progname.c new file mode 100644 index 0000000..df52f60 --- /dev/null +++ b/gl/progname.c @@ -0,0 +1,50 @@ +/* Program name management. + Copyright (C) 2001-2003, 2005-2006 Free Software Foundation, Inc. + Written by Bruno Haible <haible@clisp.cons.org>, 2001. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + + +#include <config.h> + +/* Specification. */ +#undef ENABLE_RELOCATABLE /* avoid defining set_program_name as a macro */ +#include "progname.h" + +#include <string.h> + + +/* String containing name the program is called with. + To be initialized by main(). */ +const char *program_name = NULL; + +/* Set program_name, based on argv[0]. */ +void +set_program_name (const char *argv0) +{ + /* libtool creates a temporary executable whose name is sometimes prefixed + with "lt-" (depends on the platform). It also makes argv[0] absolute. + Remove this "<dirname>/.libs/" or "<dirname>/.libs/lt-" prefix here. */ + const char *slash; + const char *base; + + slash = strrchr (argv0, '/'); + base = (slash != NULL ? slash + 1 : argv0); + if (base - argv0 >= 7 && memcmp (base - 7, "/.libs/", 7) == 0) + argv0 = base; + if (strncmp (base, "lt-", 3) == 0) + argv0 = base + 3; + program_name = argv0; +} diff --git a/gl/progname.h b/gl/progname.h new file mode 100644 index 0000000..a5d9a04 --- /dev/null +++ b/gl/progname.h @@ -0,0 +1,60 @@ +/* Program name management. + Copyright (C) 2001-2004 Free Software Foundation, Inc. + Written by Bruno Haible <haible@clisp.cons.org>, 2001. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +#ifndef _PROGNAME_H +#define _PROGNAME_H + +/* Programs using this file should do the following in main(): + set_program_name (argv[0]); + */ + + +#ifdef __cplusplus +extern "C" { +#endif + + +/* String containing name the program is called with. */ +extern const char *program_name; + +/* Set program_name, based on argv[0]. */ +extern void set_program_name (const char *argv0); + +#if ENABLE_RELOCATABLE + +/* Set program_name, based on argv[0], and original installation prefix and + directory, for relocatability. */ +extern void set_program_name_and_installdir (const char *argv0, + const char *orig_installprefix, + const char *orig_installdir); +#define set_program_name(ARG0) \ + set_program_name_and_installdir (ARG0, INSTALLPREFIX, INSTALLDIR) + +/* Return the full pathname of the current executable, based on the earlier + call to set_program_name_and_installdir. Return NULL if unknown. */ +extern char *get_full_program_name (void); + +#endif + + +#ifdef __cplusplus +} +#endif + + +#endif /* _PROGNAME_H */ diff --git a/gl/version-etc-fsf.c b/gl/version-etc-fsf.c new file mode 100644 index 0000000..f25eb65 --- /dev/null +++ b/gl/version-etc-fsf.c @@ -0,0 +1,31 @@ +/* Variable with FSF copyright information, for version-etc. + Copyright (C) 1999-2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Jim Meyering. */ + +#include <config.h> + +/* Specification. */ +#include "version-etc.h" + +/* Default copyright goes to the FSF. */ + +const char version_etc_copyright[] = + /* Do *not* mark this string for translation. %s is a copyright + symbol suitable for this locale, and %d is the copyright + year. */ + "Copyright %s %d Free Software Foundation, Inc."; diff --git a/gl/version-etc.c b/gl/version-etc.c new file mode 100644 index 0000000..10d33fa --- /dev/null +++ b/gl/version-etc.c @@ -0,0 +1,173 @@ +/* Utility to help print --version output in a consistent format. + Copyright (C) 1999-2006 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Jim Meyering. */ + +#include <config.h> + +/* Specification. */ +#include "version-etc.h" + +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> + +#if USE_UNLOCKED_IO +# include "unlocked-io.h" +#endif + +#include "gettext.h" +#define _(msgid) gettext (msgid) + +enum { COPYRIGHT_YEAR = 2006 }; + +/* Like version_etc, below, but with the NULL-terminated author list + provided via a variable of type va_list. */ +void +version_etc_va (FILE *stream, + const char *command_name, const char *package, + const char *version, va_list authors) +{ + size_t n_authors; + + /* Count the number of authors. */ + { + va_list tmp_authors; + + va_copy (tmp_authors, authors); + + n_authors = 0; + while (va_arg (tmp_authors, const char *) != NULL) + ++n_authors; + } + + if (command_name) + fprintf (stream, "%s (%s) %s\n", command_name, package, version); + else + fprintf (stream, "%s %s\n", package, version); + + /* TRANSLATORS: Translate "(C)" to the copyright symbol + (C-in-a-circle), if this symbol is available in the user's + locale. Otherwise, do not translate "(C)"; leave it as-is. */ + fprintf (stream, version_etc_copyright, _("(C)"), COPYRIGHT_YEAR); + + fputs (_("\ +\n\ +This is free software. You may redistribute copies of it under the terms of\n\ +the GNU General Public License <http://www.gnu.org/licenses/gpl.html>.\n\ +There is NO WARRANTY, to the extent permitted by law.\n\ +\n\ +"), + stream); + + switch (n_authors) + { + case 0: + /* The caller must provide at least one author name. */ + abort (); + case 1: + /* TRANSLATORS: %s denotes an author name. */ + vfprintf (stream, _("Written by %s.\n"), authors); + break; + case 2: + /* TRANSLATORS: Each %s denotes an author name. */ + vfprintf (stream, _("Written by %s and %s.\n"), authors); + break; + case 3: + /* TRANSLATORS: Each %s denotes an author name. */ + vfprintf (stream, _("Written by %s, %s, and %s.\n"), authors); + break; + case 4: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("Written by %s, %s, %s,\nand %s.\n"), authors); + break; + case 5: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("Written by %s, %s, %s,\n%s, and %s.\n"), authors); + break; + case 6: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, and %s.\n"), + authors); + break; + case 7: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("Written by %s, %s, %s,\n%s, %s, %s, and %s.\n"), + authors); + break; + case 8: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("\ +Written by %s, %s, %s,\n%s, %s, %s, %s,\nand %s.\n"), + authors); + break; + case 9: + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("\ +Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, and %s.\n"), + authors); + break; + default: + /* 10 or more authors. Use an abbreviation, since the human reader + will probably not want to read the entire list anyway. */ + /* TRANSLATORS: Each %s denotes an author name. + You can use line breaks, estimating that each author name occupies + ca. 16 screen columns and that a screen line has ca. 80 columns. */ + vfprintf (stream, _("\ +Written by %s, %s, %s,\n%s, %s, %s, %s,\n%s, %s, and others.\n"), + authors); + break; + } + va_end (authors); +} + + +/* Display the --version information the standard way. + + If COMMAND_NAME is NULL, the PACKAGE is asumed to be the name of + the program. The formats are therefore: + + PACKAGE VERSION + + or + + COMMAND_NAME (PACKAGE) VERSION. + + The author names are passed as separate arguments, with an additional + NULL argument at the end. */ +void +version_etc (FILE *stream, + const char *command_name, const char *package, + const char *version, /* const char *author1, ...*/ ...) +{ + va_list authors; + + va_start (authors, version); + version_etc_va (stream, command_name, package, version, authors); +} diff --git a/gl/version-etc.h b/gl/version-etc.h new file mode 100644 index 0000000..84da535 --- /dev/null +++ b/gl/version-etc.h @@ -0,0 +1,37 @@ +/* Utility to help print --version output in a consistent format. + Copyright (C) 1999, 2003, 2005 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software Foundation, + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + +/* Written by Jim Meyering. */ + +#ifndef VERSION_ETC_H +# define VERSION_ETC_H 1 + +# include <stdarg.h> +# include <stdio.h> + +extern const char version_etc_copyright[]; + +extern void version_etc_va (FILE *stream, + const char *command_name, const char *package, + const char *version, va_list authors); + +extern void version_etc (FILE *stream, + const char *command_name, const char *package, + const char *version, + /* const char *author1, ...*/ ...); + +#endif /* VERSION_ETC_H */ diff --git a/lib/libtasn1.h b/lib/libtasn1.h index 565924b..00a2208 100644 --- a/lib/libtasn1.h +++ b/lib/libtasn1.h @@ -31,7 +31,7 @@ extern "C" { #endif -#define LIBTASN1_VERSION "0.3.6" +#define LIBTASN1_VERSION "0.3.7" #include <sys/types.h> #include <time.h> diff --git a/src/Makefile.am b/src/Makefile.am index 6a774bf..1c0d171 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -21,7 +21,7 @@ INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_builddir)/gl EXTRA_DIST = pkix.asn pkix_asn1_tab.c asn1Coding_test.asn asn1Coding_test.asg -LDADD = ../lib/libtasn1.la +LDADD = ../lib/libtasn1.la ../gl/libgnu.la bin_PROGRAMS = asn1Parser asn1Coding asn1Decoding noinst_PROGRAMS = CertificateExample CrlExample diff --git a/src/asn1Coding.c b/src/asn1Coding.c index 5b004c6..4edcbc7 100644 --- a/src/asn1Coding.c +++ b/src/asn1Coding.c @@ -35,6 +35,9 @@ #include <stdlib.h> #include <unistd.h> +#include <progname.h> +#include <version-etc.h> + #ifdef HAVE_GETOPT_H #include <getopt.h> #endif @@ -157,9 +160,9 @@ main(int argc,char *argv[]) int der_len; int k; - opterr=0; /* disable error messages from getopt */ + set_program_name (argv[0]); - printf("\n"); + opterr=0; /* disable error messages from getopt */ while(1){ @@ -179,8 +182,8 @@ main(int argc,char *argv[]) exit(0); break; case 'v': /* VERSION */ - printf("%s\n",version_man); - + version_etc (stdout, program_name, PACKAGE, VERSION, + "Fabio Fiorina", NULL); if(outputFileName) free(outputFileName); exit(0); break; diff --git a/src/asn1Decoding.c b/src/asn1Decoding.c index 1df53fb..8e48fec 100644 --- a/src/asn1Decoding.c +++ b/src/asn1Decoding.c @@ -35,6 +35,9 @@ #include <stdlib.h> #include <unistd.h> +#include <progname.h> +#include <version-etc.h> + #ifdef HAVE_GETOPT_H #include <getopt.h> #endif @@ -99,9 +102,9 @@ main(int argc,char *argv[]) int der_len=0; /* FILE *outputFile; */ - opterr=0; /* disable error messages from getopt */ + set_program_name (argv[0]); - printf("\n"); + opterr=0; /* disable error messages from getopt */ while(1){ @@ -119,7 +122,8 @@ main(int argc,char *argv[]) exit(0); break; case 'v': /* VERSION */ - printf("%s\n",version_man); + version_etc (stdout, program_name, PACKAGE, VERSION, + "Fabio Fiorina", NULL); exit(0); break; case 'c': /* CHECK SYNTAX */ @@ -280,10 +284,3 @@ main(int argc,char *argv[]) exit(0); } - - - - - - - diff --git a/src/asn1Parser.c b/src/asn1Parser.c index 918b3bf..4909d93 100644 --- a/src/asn1Parser.c +++ b/src/asn1Parser.c @@ -35,6 +35,9 @@ #include <stdlib.h> #include <unistd.h> +#include <progname.h> +#include <version-etc.h> + #ifdef HAVE_GETOPT_H #include <getopt.h> #endif @@ -100,9 +103,9 @@ main(int argc,char *argv[]) char errorDescription[MAX_ERROR_DESCRIPTION_SIZE]; int parse_result=ASN1_SUCCESS; - opterr=0; /* disable error messages from getopt */ + set_program_name (argv[0]); - printf("\n"); + opterr=0; /* disable error messages from getopt */ while(1){ @@ -130,8 +133,8 @@ main(int argc,char *argv[]) exit(0); break; case 'v': /* VERSION */ - printf("%s\n",version_man); - + version_etc (stdout, program_name, PACKAGE, VERSION, + "Fabio Fiorina", NULL); if(outputFileName) free(outputFileName); if(vectorName) free(vectorName); exit(0); |