From c0d0491ee357a2d4fad1394b920fec9912cc811e Mon Sep 17 00:00:00 2001 From: Lev Walkin <vlm@lionet.info> Date: Fri, 25 Feb 2005 12:52:27 +0000 Subject: [PATCH] commonizing --- asn1c/Makefile.am | 2 ++ asn1c/Makefile.in | 9 +++++--- asn1c/asn1c.c | 22 ++++++------------- asn1c/enber.c | 24 +++++--------------- asn1c/sys-common.h | 55 ++++++++++++++++++++++++++++++++++++++++++++++ asn1c/unber.c | 24 +++++--------------- 6 files changed, 82 insertions(+), 54 deletions(-) create mode 100644 asn1c/sys-common.h diff --git a/asn1c/Makefile.am b/asn1c/Makefile.am index 14222667..5e3f5cbb 100644 --- a/asn1c/Makefile.am +++ b/asn1c/Makefile.am @@ -18,6 +18,8 @@ asn1c_LDADD = \ bin_PROGRAMS = asn1c unber enber +noinst_HEADERS = sys-common.h + dist_man1_MANS = asn1c.1 unber.1 enber.1 check_SCRIPTS = check-parsing.sh diff --git a/asn1c/Makefile.in b/asn1c/Makefile.in index dd6652aa..6e9f061f 100644 --- a/asn1c/Makefile.in +++ b/asn1c/Makefile.in @@ -14,6 +14,7 @@ @SET_MAKE@ + SOURCES = asn1c.c enber.c unber.c srcdir = @srcdir@ @@ -39,8 +40,8 @@ POST_UNINSTALL = : host_triplet = @host@ bin_PROGRAMS = asn1c$(EXEEXT) unber$(EXEEXT) enber$(EXEEXT) subdir = asn1c -DIST_COMMON = README $(dist_man1_MANS) $(srcdir)/Makefile.am \ - $(srcdir)/Makefile.in +DIST_COMMON = README $(dist_man1_MANS) $(noinst_HEADERS) \ + $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ @@ -87,6 +88,7 @@ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ man1dir = $(mandir)/man1 NROFF = nroff MANS = $(dist_man1_MANS) +HEADERS = $(noinst_HEADERS) ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) @@ -216,6 +218,7 @@ asn1c_LDADD = \ $(top_builddir)/libasn1fix/libasn1fix.la \ $(top_builddir)/libasn1compiler/libasn1compiler.la +noinst_HEADERS = sys-common.h dist_man1_MANS = asn1c.1 unber.1 enber.1 check_SCRIPTS = check-parsing.sh TESTS = check-parsing.sh @@ -618,7 +621,7 @@ check-am: all-am $(MAKE) $(AM_MAKEFLAGS) $(check_SCRIPTS) $(MAKE) $(AM_MAKEFLAGS) check-TESTS check: check-recursive -all-am: Makefile $(PROGRAMS) $(MANS) +all-am: Makefile $(PROGRAMS) $(MANS) $(HEADERS) installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \ diff --git a/asn1c/asn1c.c b/asn1c/asn1c.c index 6c20893e..36916a16 100644 --- a/asn1c/asn1c.c +++ b/asn1c/asn1c.c @@ -1,6 +1,6 @@ /*- - * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info> - * All rights reserved. + * Copyright (c) 2003, 2004, 2005 + * Lev Walkin <vlm@lionet.info>. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,15 +29,7 @@ * This is the program that connects the libasn1* libraries together. * It uses them in turn to parse, fix and then compile or print the ASN.1 tree. */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/stat.h> /* for stat(2) */ -#include <unistd.h> -#include <sysexits.h> /* for EX_USAGE */ -#include <assert.h> -#include <errno.h> +#include "sys-common.h" #include <asn1parser.h> /* Parse the ASN.1 file and build a tree */ #include <asn1fix.h> /* Fix the ASN.1 tree */ @@ -46,11 +38,11 @@ #include <asn1c_compat.h> /* Portable basename(3) and dirname(3) */ -static void usage(const char *av0); /* Print the Usage screen and exit */ +#undef COPYRIGHT +#define COPYRIGHT \ + "Copyright (c) 2003, 2004, 2005 Lev Walkin <vlm@lionet.info>\n" -#undef COPYRIGHT -#define COPYRIGHT \ - "Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>\n" +static void usage(const char *av0); /* Print the Usage screen and exit */ int main(int ac, char **av) { diff --git a/asn1c/enber.c b/asn1c/enber.c index dfbdf370..714f4663 100644 --- a/asn1c/enber.c +++ b/asn1c/enber.c @@ -1,6 +1,5 @@ /*- - * Copyright (c) 2004 Lev Walkin <vlm@lionet.info> - * All rights reserved. + * Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -25,18 +24,7 @@ * * $Id$ */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <unistd.h> -#include <sysexits.h> /* for EX_USAGE */ -#include <assert.h> -#include <errno.h> - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +#include "sys-common.h" #include <asn1parser.h> /* For static string tables */ @@ -45,14 +33,14 @@ #include <ber_tlv_tag.c> #include <ber_tlv_length.c> +#undef COPYRIGHT +#define COPYRIGHT \ + "Copyright (c) 2004 Lev Walkin <vlm@lionet.info>\n" + static void usage(const char *av0, int);/* Print the Usage screen and exit */ static int process(const char *fname); /* Perform the BER decoding */ static int process_line(const char *fname, char *line, int lineno); -#undef COPYRIGHT -#define COPYRIGHT \ - "Copyright (c) 2004 Lev Walkin <vlm@lionet.info>\n" - static int no_validation; /* -n */ int diff --git a/asn1c/sys-common.h b/asn1c/sys-common.h new file mode 100644 index 00000000..d9726531 --- /dev/null +++ b/asn1c/sys-common.h @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 2005 Lev Walkin <vlm@lionet.info>. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> /* for stat(2) */ +#include <unistd.h> +#include <assert.h> +#include <errno.h> + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifndef WIN32 +#include <sysexits.h> /* for EX_USAGE & others */ +#else /* WIN32 */ +#ifndef EX_USAGE +#define EX_USAGE 64 +#endif +#ifndef EX_DATAERR +#define EX_DATAERR 65 +#endif +#ifndef EX_SOFTWARE +#define EX_SOFTWARE 70 +#endif +#define alloca _alloca +#define snprintf _snprintf +#endif /* WIN32 */ + diff --git a/asn1c/unber.c b/asn1c/unber.c index a2280f31..ec3440fa 100644 --- a/asn1c/unber.c +++ b/asn1c/unber.c @@ -1,6 +1,5 @@ /*- - * Copyright (c) 2004 Lev Walkin <vlm@lionet.info> - * All rights reserved. + * Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -25,18 +24,7 @@ * * $Id$ */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <unistd.h> -#include <sysexits.h> /* for EX_USAGE */ -#include <assert.h> -#include <errno.h> - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif +#include "sys-common.h" #include <asn1parser.h> /* For static string tables */ @@ -48,14 +36,14 @@ #include <RELATIVE-OID.c> #include <asn_codecs_prim.c> +#undef COPYRIGHT +#define COPYRIGHT \ + "Copyright (c) 2004 Lev Walkin <vlm@lionet.info>\n" + static void usage(const char *av0); /* Print the Usage screen and exit */ static int process(const char *fname); /* Perform the BER decoding */ static int decode_tlv_from_string(const char *datastring); -#undef COPYRIGHT -#define COPYRIGHT \ - "Copyright (c) 2004 Lev Walkin <vlm@lionet.info>\n" - static int single_type_decoding = 0; /* -1 enables that */ static int pretty_printing = 1; /* -p disables that */ static char *indent_buffer = " "; /* -i controls that */ -- GitLab