diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..d510bcde --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Lev Walkin diff --git a/BUGS b/BUGS new file mode 100644 index 00000000..3e8145c0 --- /dev/null +++ b/BUGS @@ -0,0 +1,31 @@ + +0. ASN.1 grammar parser is written mostly with respect to constructing a tree, +so a tree destruction is not fully supported and certain memory leaks are +known. Not a huge problem for run-once programs like a compiler. +NOTE: This statement does not apply to the target code _produced_ + by the compiler. + +1. REAL type is not supported yet. + +2. For purposes of compilation, INTEGER type is modelled using a large +static type (asn_integer_t), but defined as any positive or negative value +by ASN.1. Not a problem as most specifications use very small values anyway. +NOTE: This statement does not apply to the target code _produced_ + by the compiler. + +3. ASN Macros are prohibited by the current ASN.1 standard, +and are not supported. + +4. Multiple tags applied at the same level are not supported: + BadTags ::= [0] EXPLICIT [2] IMPLICIT OtherType + The same thing could be achieved by using the indirection: + GoodTags ::= [0] EXPLICIT OtherTypePtr + OtherTypePtr ::= [2] IMPLICIT OtherType + +5. Mixed definite/indefinite length in a _single_ BER tags sequence is not +supported. Should not be a problem in the real world. Please note that it +is still possible, for example, to encode a wrapper structure using definite +length, and encode its substructure member using indefinite length. The BER +decoder is perfectly capable of decoding such sequences. + + diff --git a/COPYING b/COPYING new file mode 100644 index 00000000..5addee94 --- /dev/null +++ b/COPYING @@ -0,0 +1,27 @@ +/*- + * Copyright (c) 2003, 2004 Lev Walkin + * 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$ + */ diff --git a/ChangeLog b/ChangeLog new file mode 100644 index 00000000..45a11c82 --- /dev/null +++ b/ChangeLog @@ -0,0 +1,130 @@ + +0.8.10: 2004-Jun-02 + + * Added const qualifier where necessary. + * Changed position of outmost_tag fetcher within asn1_TYPE_descriptor_t + structure. + +0.8.9: 2004-May-26 + + * Added *_{get|set}_arcs_*() functions for OBJECT IDENTIFIER + and RELATIVE-OID, together with test cases. + +0.8.8: 2004-May-09 + + * Introduced subtype constraints support (incomplete!). + * Fixed compiler. If the last member of the SEQUENCE is OPTIONAL + and absent in the encoding, and the type is extensible (...) or + EXTENSIBILITY IMPLIED flag is set, then the structure could not + be correctly decoded. (Severity: high, Security impact: low). + * Compiler: fixed recursive ASN.1 types inclusion (Severity: low, + Security impact: none). + * Parser: IMPORTS/FROM fixes, now allowing multiple sections. + * Code compiled and checked on PowerPC (@MacOS X). No major portability + issues experienced. + +0.8.7: 2004-Apr-11 T-version-0-8-7 + + * Fixed SEQUENCE BER decoder: if the last member of the SEQUENCE is + OPTIONAL and absent in the encoding, RC_FAIL was returned instead + of RC_OK (Severity: high, Security impact: low). + * Added test case to check the above problem. + * Added test case to check -fnative-integers mode. + +0.8.6: 2004-Apr-03 T-version-0-8-6 + + * Fixed compiler output for embedded ASN.1 structures. + +0.8.5: 2004-Mar-28 T-version-0-8-5 + + * Fixed ber_tlv_length() computation problem (Severity: blocker, + Security impact: none). + Reported by + +0.8.4: 2004-Mar-22 + + * Removed RC_ITAG enumeration element from BER decoder. + This return code did not have much practical value. + +0.8.3: 2004-Mar-14 T-version-0-8-3 + + * Fixed SET::BER decoder: restart after reaching a buffer boundary + weas broken (Severity: blocker, Security impact: low). + * Fixed OCTET STRING::BER decoder: restart after reaching a buffer + boundary was broken (Severity: blocker, Security impact: low). + Reported by + * Added test cases to check decoders restartability. + * Slightly more general INTEGER2long decoder. + * Allowed nested /* C-type */ comments, as per X.680:2002. + +0.8.2: 2004-Mar-01 T-version-0-8-2 + + * Fixed SEQUENCE BER decoder: an OPTIONAL element was required, where + should not have been (Severity: major; Security impact: low). + * Fixed print_struct pointer inheritance. + * Added -fno-c99 and -funnamed-unions + +0.8.1: 2004-Feb-22 + + * -R switch to asn1c: Omit support code, compile only the tables. + * Introduced NativeInteger pseudotype. + * Corrected the informal print_struct()'s output format. + +0.8.0: 2004-Feb-03 T-version-0-8-0 + + * Some documentation is created (a .pdf and a short manual page). + * Last touches to the code. + +0.7.9: 2004-Feb-01 T-version-0-7-9 + + * Human readable printing support. + * Support for implicit (standard) constraints. + +0.7.8: 2004-Jan-31 + + * SET now rejects duplicate fields in the data stream. + +0.7.7: 2004-Jan-25 + + * Added types: GeneralizedTime and UTCTime. + +0.7.6: 2004-Jan-24 T-version-0-7-6 + + * DER encoding of a SET OF now involves dynamic sorting. + +0.7.5: 2004-Jan-24 T-version-0-7-5 + + * DER encoding of a SET with untagged CHOICE + now involves dynamic sorting. + +0.7.0: 2004-Jan-19 T-version-0-7-0 + + * A bunch of DER encoders is implemented. + +0.6.6: 2004-Jan-11 + + * Implemented CHOICE decoder. + * Implemented destructors support. + +0.6.5: 2004-Jan-03 + + * Implemented SET decoder. + * Implemented SET OF and SEQUENCE OF decoders. + +0.6.4: 2003-Dec-31 + + * Implemented BOOLEAN, NULL, ENUMERATED decoders. + * Implemented OCTET STRING decoder. + * Implemented BIT STRING decoder. + +0.6: 2003-Dec-30 + + * First decoding of a BER-encoded structure! + +0.5: 2003-Dec-28 + + * Framework and most of the compiler backbone coding done. + +0.1: 2003-Nov-28 + + * Programming started. diff --git a/INSTALL b/INSTALL new file mode 100644 index 00000000..5d2d54c5 --- /dev/null +++ b/INSTALL @@ -0,0 +1,14 @@ +QUICK START INSTALLATION +======================== + +./configure # Configure the build infrastructure for your platform +make # Build the libraries and the compiler +make check # Ensure that the code is still behaving well + # after compiling on your platform +make install # Install the compiler into standard location + + +QUICK USAGE GUIDE +================= + +For usage guide and more information please refer to README file. diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 00000000..1be9e9f6 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,9 @@ +libasn1compiler +libasn1parser +libasn1print +libasn1fix +skeletons +examples +tests +asn1c +doc diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..da7f6821 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,8 @@ + +SUBDIRS = \ + libasn1parser libasn1print \ + libasn1fix libasn1compiler \ + skeletons examples tests \ + doc asn1c + +EXTRA_DIST = BUGS MANIFEST diff --git a/Makefile.in b/Makefile.in new file mode 100644 index 00000000..1ce7ad4c --- /dev/null +++ b/Makefile.in @@ -0,0 +1,430 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = . + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +SUBDIRS = \ + libasn1parser libasn1print \ + libasn1fix libasn1compiler \ + skeletons examples tests \ + doc asn1c + + +EXTRA_DIST = BUGS MANIFEST +subdir = . +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = + +RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ + uninstall-info-recursive all-recursive install-data-recursive \ + install-exec-recursive installdirs-recursive install-recursive \ + uninstall-recursive check-recursive installcheck-recursive +DIST_COMMON = README ./stamp-h.in AUTHORS COPYING ChangeLog INSTALL \ + Makefile.am Makefile.in NEWS TODO aclocal.m4 config.guess \ + config.h.in config.sub configure configure.in depcomp \ + install-sh ltconfig ltmain.sh missing mkinstalldirs +DIST_SUBDIRS = $(SUBDIRS) +all: config.h + $(MAKE) $(AM_MAKEFLAGS) all-recursive + +.SUFFIXES: + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$@ $(SHELL) ./config.status + +$(top_builddir)/config.status: $(srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + $(SHELL) ./config.status --recheck +$(srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(srcdir)/configure.in $(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES) + cd $(srcdir) && $(AUTOCONF) + +$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ configure.in + cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) +config.h: stamp-h + @if test ! -f $@; then \ + rm -f stamp-h; \ + $(MAKE) stamp-h; \ + else :; fi +stamp-h: $(srcdir)/config.h.in $(top_builddir)/config.status + @rm -f stamp-h stamp-hT + @echo timestamp > stamp-hT 2> /dev/null + cd $(top_builddir) \ + && CONFIG_FILES= CONFIG_HEADERS=config.h \ + $(SHELL) ./config.status + @mv stamp-hT stamp-h +$(srcdir)/config.h.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/./stamp-h.in + @if test ! -f $@; then \ + rm -f $(srcdir)/./stamp-h.in; \ + $(MAKE) $(srcdir)/./stamp-h.in; \ + else :; fi +$(srcdir)/./stamp-h.in: $(top_srcdir)/configure.in $(ACLOCAL_M4) + @rm -f $(srcdir)/./stamp-h.in $(srcdir)/./stamp-h.inT + @echo timestamp > $(srcdir)/./stamp-h.inT 2> /dev/null + cd $(top_srcdir) && $(AUTOHEADER) + @mv $(srcdir)/./stamp-h.inT $(srcdir)/./stamp-h.in + +distclean-hdr: + -rm -f config.h +uninstall-info-am: + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)config.h.in$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags config.h.in $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = . +# Avoid unsightly `./'. +distdir = $(PACKAGE)-$(VERSION) + +GZIP_ENV = --best + +distdir: $(DISTFILES) + -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir) + mkdir $(distdir) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + for subdir in $(SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" \ + distdir=../$(distdir)/$$subdir \ + distdir) \ + || exit 1; \ + fi; \ + done + -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ + ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ + || chmod -R a+r $(distdir) +dist: distdir + $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir) + +# This target untars the dist file and tries a VPATH configuration. Then +# it guarantees that the distribution is self-contained by making another +# tarfile. +distcheck: dist + -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir) + GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(AMTAR) xf - + chmod -R a-w $(distdir); chmod a+w $(distdir) + mkdir $(distdir)/=build + mkdir $(distdir)/=inst + chmod a-w $(distdir) + dc_install_base=`CDPATH=: && cd $(distdir)/=inst && pwd` \ + && cd $(distdir)/=build \ + && ../configure --srcdir=.. --prefix=$$dc_install_base \ + && $(MAKE) $(AM_MAKEFLAGS) \ + && $(MAKE) $(AM_MAKEFLAGS) dvi \ + && $(MAKE) $(AM_MAKEFLAGS) check \ + && $(MAKE) $(AM_MAKEFLAGS) install \ + && $(MAKE) $(AM_MAKEFLAGS) installcheck \ + && $(MAKE) $(AM_MAKEFLAGS) uninstall \ + && (test `find $$dc_install_base -type f -print | wc -l` -le 1 \ + || (echo "Error: files left after uninstall" 1>&2; \ + exit 1) ) \ + && $(MAKE) $(AM_MAKEFLAGS) dist \ + && $(MAKE) $(AM_MAKEFLAGS) distclean \ + && rm -f $(distdir).tar.gz \ + && (test `find . -type f -print | wc -l` -eq 0 \ + || (echo "Error: files left after distclean" 1>&2; \ + exit 1) ) + -chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir) + @echo "$(distdir).tar.gz is ready for distribution" | \ + sed 'h;s/./=/g;p;x;p;x' +check-am: all-am +check: check-recursive +all-am: Makefile config.h +installdirs: installdirs-recursive +installdirs-am: + +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool mostlyclean-am + +dist-all: distdir + $(AMTAR) chof - $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz + -chmod -R a+w $(distdir) >/dev/null 2>&1; rm -rf $(distdir) +distclean: distclean-recursive + -rm -f config.status config.cache config.log +distclean-am: clean-am distclean-generic distclean-hdr distclean-libtool \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-recursive + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +uninstall-am: uninstall-info-am + +uninstall-info: uninstall-info-recursive + +.PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-am clean \ + clean-generic clean-libtool clean-recursive dist dist-all \ + distcheck distclean distclean-generic distclean-hdr \ + distclean-libtool distclean-recursive distclean-tags distdir \ + dvi dvi-am dvi-recursive info info-am info-recursive install \ + install-am install-data install-data-am install-data-recursive \ + install-exec install-exec-am install-exec-recursive \ + install-info install-info-am install-info-recursive install-man \ + install-recursive install-strip installcheck installcheck-am \ + installdirs installdirs-am installdirs-recursive \ + maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-generic \ + mostlyclean-libtool mostlyclean-recursive tags tags-recursive \ + uninstall uninstall-am uninstall-info-am \ + uninstall-info-recursive uninstall-recursive + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/NEWS b/NEWS new file mode 100644 index 00000000..e69de29b diff --git a/README b/README new file mode 100644 index 00000000..586bb3d3 --- /dev/null +++ b/README @@ -0,0 +1,69 @@ +WHAT TO READ? +============= + +For quick installation tips read INSTALL. + +For more complete documentation on this compiler and on using the +results of compilation please look into ./doc directory. + +An excellent book on ASN.1 is written by Olivier Dubuisson: +"ASN.1 Communication between heterogeneous systems", ISBN:0-12-6333361-0. + + +QUICK START +=========== + +After building [and installing] the compiler (see INSTALL), you may use +the asn1c command to compile the ASN.1 specification: + + asn1c + +If several specifications contain interdependencies, all of them must be +specified: + + asn1c ... + +The ./examples directory contains several ASN.1 modules and a script to +extract ASN.1 modules from RFC documents. To compile X.509 PKI module: + + ./asn1c/asn1c -P ./examples/*PKIX*93*.asn1 + +In this example, -P option is used to instruct the compiler to print the +compiled text on the standard output instead of creating multiple .c +and .h files for every ASN.1 type found inside the specified files. +This is useful for debugging and tests automation. + +The compiler -E and -EF options are used for testing the parser and +the semantic fixer, respectively. These options will instruct the compiler +to dump out the parsed (and fixed) ASN.1 specification as it was +"understood" by the compiler. It might be useful for checking +whether a particular syntactic construction is properly supported +by the compiler. + + asn1c -EF + + +MODEL OF OPERATION +================== + +The asn1c compiler works by processing the ASN.1 module specification +in several stages: +1. In the first stage, the ASN.1 file is parsed. + (Parsing produces an ASN.1 syntax tree for the subsequent levels.) +2. In the second stage, the syntax tree is "fixed". + (Fixing is done by checking the tree for semantic errors + and by transforming the tree into the canonical representation.) +3. In the third stage, the syntax tree is compiled into the target language. + +There are several command-line options reserved for printing the results +after each stage of operation: + + => print (-E) + => => print (-E -F) + => => => print (-P) + => => => save-compiled [default] + + +-- +Lev Walkin +vlm@lionet.info diff --git a/TODO b/TODO new file mode 100644 index 00000000..1316b857 --- /dev/null +++ b/TODO @@ -0,0 +1,18 @@ +MAJOR: + +1. Support for the explicit subtype constraints: + Name ::= IA5String (FROM("A".."Z")) + Status: in progress. + +2. Support for Information Object Classes. + Status: support for parsing IOCs is mostly present. Support for slicing + the IOCs to produce "views" is not yet designed. + +3. Support for PER encoding. Requires advanced subtype constraints support (#1) + +4. Support for XER encoding. + +MISC: + +1. Make sure asn1_DEF__tags is not an empty structure. + diff --git a/aclocal.m4 b/aclocal.m4 new file mode 100644 index 00000000..f71fa03e --- /dev/null +++ b/aclocal.m4 @@ -0,0 +1,998 @@ +# aclocal.m4 generated automatically by aclocal 1.5 + +# Copyright 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +# Do all the work for Automake. This macro actually does too much -- +# some checks are only needed if your package does certain things. +# But this isn't really a big deal. + +# serial 5 + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + +# We require 2.13 because we rely on SHELL being computed by configure. +AC_PREREQ([2.13]) + +# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED) +# ----------------------------------------------------------- +# If MACRO-NAME is provided do IF-PROVIDED, else IF-NOT-PROVIDED. +# The purpose of this macro is to provide the user with a means to +# check macros which are provided without letting her know how the +# information is coded. +# If this macro is not defined by Autoconf, define it here. +ifdef([AC_PROVIDE_IFELSE], + [], + [define([AC_PROVIDE_IFELSE], + [ifdef([AC_PROVIDE_$1], + [$2], [$3])])]) + + +# AM_INIT_AUTOMAKE(PACKAGE,VERSION, [NO-DEFINE]) +# ---------------------------------------------- +AC_DEFUN([AM_INIT_AUTOMAKE], +[AC_REQUIRE([AC_PROG_INSTALL])dnl +# test to see if srcdir already configured +if test "`CDPATH=:; cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + AC_MSG_ERROR([source directory already configured; run \"make distclean\" there first]) +fi + +# Define the identity of the package. +PACKAGE=$1 +AC_SUBST(PACKAGE)dnl +VERSION=$2 +AC_SUBST(VERSION)dnl +ifelse([$3],, +[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) +AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])]) + +# Autoconf 2.50 wants to disallow AM_ names. We explicitly allow +# the ones we care about. +ifdef([m4_pattern_allow], + [m4_pattern_allow([^AM_[A-Z]+FLAGS])])dnl + +# Autoconf 2.50 always computes EXEEXT. However we need to be +# compatible with 2.13, for now. So we always define EXEEXT, but we +# don't compute it. +AC_SUBST(EXEEXT) +# Similar for OBJEXT -- only we only use OBJEXT if the user actually +# requests that it be used. This is a bit dumb. +: ${OBJEXT=o} +AC_SUBST(OBJEXT) + +# Some tools Automake needs. +AC_REQUIRE([AM_SANITY_CHECK])dnl +AC_REQUIRE([AC_ARG_PROGRAM])dnl +AM_MISSING_PROG(ACLOCAL, aclocal) +AM_MISSING_PROG(AUTOCONF, autoconf) +AM_MISSING_PROG(AUTOMAKE, automake) +AM_MISSING_PROG(AUTOHEADER, autoheader) +AM_MISSING_PROG(MAKEINFO, makeinfo) +AM_MISSING_PROG(AMTAR, tar) +AM_PROG_INSTALL_SH +AM_PROG_INSTALL_STRIP +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([AC_PROG_MAKE_SET])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl +AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_PROVIDE_IFELSE([AC_PROG_][CC], + [_AM_DEPENDENCIES(CC)], + [define([AC_PROG_][CC], + defn([AC_PROG_][CC])[_AM_DEPENDENCIES(CC)])])dnl +AC_PROVIDE_IFELSE([AC_PROG_][CXX], + [_AM_DEPENDENCIES(CXX)], + [define([AC_PROG_][CXX], + defn([AC_PROG_][CXX])[_AM_DEPENDENCIES(CXX)])])dnl +]) + +# +# Check to make sure that the build environment is sane. +# + +# serial 3 + +# AM_SANITY_CHECK +# --------------- +AC_DEFUN([AM_SANITY_CHECK], +[AC_MSG_CHECKING([whether build environment is sane]) +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$[*]" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$[*]" != "X $srcdir/configure conftest.file" \ + && test "$[*]" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken +alias in your environment]) + fi + + test "$[2]" = conftest.file + ) +then + # Ok. + : +else + AC_MSG_ERROR([newly created file is older than distributed files! +Check your system clock]) +fi +AC_MSG_RESULT(yes)]) + + +# serial 2 + +# AM_MISSING_PROG(NAME, PROGRAM) +# ------------------------------ +AC_DEFUN([AM_MISSING_PROG], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +$1=${$1-"${am_missing_run}$2"} +AC_SUBST($1)]) + + +# AM_MISSING_HAS_RUN +# ------------------ +# Define MISSING if not defined so far and test if it supports --run. +# If it does, set am_missing_run to use it, otherwise, to nothing. +AC_DEFUN([AM_MISSING_HAS_RUN], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + am_backtick='`' + AC_MSG_WARN([${am_backtick}missing' script is too old or missing]) +fi +]) + +# AM_AUX_DIR_EXPAND + +# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets +# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to +# `$srcdir', `$srcdir/..', or `$srcdir/../..'. +# +# Of course, Automake must honor this variable whenever it calls a +# tool from the auxiliary directory. The problem is that $srcdir (and +# therefore $ac_aux_dir as well) can be either absolute or relative, +# depending on how configure is run. This is pretty annoying, since +# it makes $ac_aux_dir quite unusable in subdirectories: in the top +# source directory, any form will work fine, but in subdirectories a +# relative path needs to be adjusted first. +# +# $ac_aux_dir/missing +# fails when called from a subdirectory if $ac_aux_dir is relative +# $top_srcdir/$ac_aux_dir/missing +# fails if $ac_aux_dir is absolute, +# fails when called from a subdirectory in a VPATH build with +# a relative $ac_aux_dir +# +# The reason of the latter failure is that $top_srcdir and $ac_aux_dir +# are both prefixed by $srcdir. In an in-source build this is usually +# harmless because $srcdir is `.', but things will broke when you +# start a VPATH build or use an absolute $srcdir. +# +# So we could use something similar to $top_srcdir/$ac_aux_dir/missing, +# iff we strip the leading $srcdir from $ac_aux_dir. That would be: +# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` +# and then we would define $MISSING as +# MISSING="\${SHELL} $am_aux_dir/missing" +# This will work as long as MISSING is not called from configure, because +# unfortunately $(top_srcdir) has no meaning in configure. +# However there are other variables, like CC, which are often used in +# configure, and could therefore not use this "fixed" $ac_aux_dir. +# +# Another solution, used here, is to always expand $ac_aux_dir to an +# absolute PATH. The drawback is that using absolute paths prevent a +# configured tree to be moved without reconfiguration. + +AC_DEFUN([AM_AUX_DIR_EXPAND], [ +# expand $ac_aux_dir to an absolute path +am_aux_dir=`CDPATH=:; cd $ac_aux_dir && pwd` +]) + +# AM_PROG_INSTALL_SH +# ------------------ +# Define $install_sh. +AC_DEFUN([AM_PROG_INSTALL_SH], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +install_sh=${install_sh-"$am_aux_dir/install-sh"} +AC_SUBST(install_sh)]) + +# One issue with vendor `install' (even GNU) is that you can't +# specify the program used to strip binaries. This is especially +# annoying in cross-compiling environments, where the build's strip +# is unlikely to handle the host's binaries. +# Fortunately install-sh will honor a STRIPPROG variable, so we +# always use install-sh in `make install-strip', and initialize +# STRIPPROG with the value of the STRIP variable (set by the user). +AC_DEFUN([AM_PROG_INSTALL_STRIP], +[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" +AC_SUBST([INSTALL_STRIP_PROGRAM])]) + +# serial 4 -*- Autoconf -*- + + + +# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be +# written in clear, in which case automake, when reading aclocal.m4, +# will think it sees a *use*, and therefore will trigger all it's +# C support machinery. Also note that it means that autoscan, seeing +# CC etc. in the Makefile, will ask for an AC_PROG_CC use... + + + +# _AM_DEPENDENCIES(NAME) +# --------------------- +# See how the compiler implements dependency checking. +# NAME is "CC", "CXX" or "OBJC". +# We try a few techniques and use that to set a single cache variable. +# +# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was +# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular +# dependency, and given that the user is not expected to run this macro, +# just rely on AC_PROG_CC. +AC_DEFUN([_AM_DEPENDENCIES], +[AC_REQUIRE([AM_SET_DEPDIR])dnl +AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl +AC_REQUIRE([AM_MAKE_INCLUDE])dnl +AC_REQUIRE([AM_DEP_TRACK])dnl + +ifelse([$1], CC, [depcc="$CC" am_compiler_list=], + [$1], CXX, [depcc="$CXX" am_compiler_list=], + [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'] + [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], + [depcc="$$1" am_compiler_list=]) + +AC_CACHE_CHECK([dependency style of $depcc], + [am_cv_$1_dependencies_compiler_type], +[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + + am_cv_$1_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` + fi + for depmode in $am_compiler_list; do + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + echo '#include "conftest.h"' > conftest.c + echo 'int i;' > conftest.h + echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=conftest.c object=conftest.o \ + depfile=conftest.Po tmpdepfile=conftest.TPo \ + $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && + grep conftest.h conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + am_cv_$1_dependencies_compiler_type=$depmode + break + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_$1_dependencies_compiler_type=none +fi +]) +$1DEPMODE="depmode=$am_cv_$1_dependencies_compiler_type" +AC_SUBST([$1DEPMODE]) +]) + + +# AM_SET_DEPDIR +# ------------- +# Choose a directory name for dependency files. +# This macro is AC_REQUIREd in _AM_DEPENDENCIES +AC_DEFUN([AM_SET_DEPDIR], +[rm -f .deps 2>/dev/null +mkdir .deps 2>/dev/null +if test -d .deps; then + DEPDIR=.deps +else + # MS-DOS does not allow filenames that begin with a dot. + DEPDIR=_deps +fi +rmdir .deps 2>/dev/null +AC_SUBST(DEPDIR) +]) + + +# AM_DEP_TRACK +# ------------ +AC_DEFUN([AM_DEP_TRACK], +[AC_ARG_ENABLE(dependency-tracking, +[ --disable-dependency-tracking Speeds up one-time builds + --enable-dependency-tracking Do not reject slow dependency extractors]) +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi +AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) +pushdef([subst], defn([AC_SUBST])) +subst(AMDEPBACKSLASH) +popdef([subst]) +]) + +# Generate code to set up dependency tracking. +# This macro should only be invoked once -- use via AC_REQUIRE. +# Usage: +# AM_OUTPUT_DEPENDENCY_COMMANDS + +# +# This code is only required when automatic dependency tracking +# is enabled. FIXME. This creates each `.P' file that we will +# need in order to bootstrap the dependency handling code. +AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],[ +AC_OUTPUT_COMMANDS([ +test x"$AMDEP_TRUE" != x"" || +for mf in $CONFIG_FILES; do + case "$mf" in + Makefile) dirpart=.;; + */Makefile) dirpart=`echo "$mf" | sed -e 's|/[^/]*$||'`;; + *) continue;; + esac + grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue + # Extract the definition of DEP_FILES from the Makefile without + # running `make'. + DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` + test -z "$DEPDIR" && continue + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n -e '/^U = / s///p' < "$mf"` + test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" + # We invoke sed twice because it is the simplest approach to + # changing $(DEPDIR) to its actual value in the expansion. + for file in `sed -n -e ' + /^DEP_FILES = .*\\\\$/ { + s/^DEP_FILES = // + :loop + s/\\\\$// + p + n + /\\\\$/ b loop + p + } + /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`echo "$file" | sed -e 's|/[^/]*$||'` + $ac_aux_dir/mkinstalldirs "$dirpart/$fdir" > /dev/null 2>&1 + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done +], [AMDEP_TRUE="$AMDEP_TRUE" +ac_aux_dir="$ac_aux_dir"])]) + +# AM_MAKE_INCLUDE() +# ----------------- +# Check to see how make treats includes. +AC_DEFUN([AM_MAKE_INCLUDE], +[am_make=${MAKE-make} +cat > confinc << 'END' +doit: + @echo done +END +# If we don't find an include directive, just comment out the code. +AC_MSG_CHECKING([for style of include used by $am_make]) +am__include='#' +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | fgrep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote='"' + _am_result=BSD + fi +fi +AC_SUBST(am__include) +AC_SUBST(am__quote) +AC_MSG_RESULT($_am_result) +rm -f confinc confmf +]) + +# serial 3 + +# AM_CONDITIONAL(NAME, SHELL-CONDITION) +# ------------------------------------- +# Define a conditional. +# +# FIXME: Once using 2.50, use this: +# m4_match([$1], [^TRUE\|FALSE$], [AC_FATAL([$0: invalid condition: $1])])dnl +AC_DEFUN([AM_CONDITIONAL], +[ifelse([$1], [TRUE], + [errprint(__file__:__line__: [$0: invalid condition: $1 +])dnl +m4exit(1)])dnl +ifelse([$1], [FALSE], + [errprint(__file__:__line__: [$0: invalid condition: $1 +])dnl +m4exit(1)])dnl +AC_SUBST([$1_TRUE]) +AC_SUBST([$1_FALSE]) +if $2; then + $1_TRUE= + $1_FALSE='#' +else + $1_TRUE='#' + $1_FALSE= +fi]) + +# Add --enable-maintainer-mode option to configure. +# From Jim Meyering + +# serial 1 + +AC_DEFUN([AM_MAINTAINER_MODE], +[AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) + dnl maintainer-mode is disabled by default + AC_ARG_ENABLE(maintainer-mode, +[ --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer], + USE_MAINTAINER_MODE=$enableval, + USE_MAINTAINER_MODE=no) + AC_MSG_RESULT([$USE_MAINTAINER_MODE]) + AM_CONDITIONAL(MAINTAINER_MODE, [test $USE_MAINTAINER_MODE = yes]) + MAINT=$MAINTAINER_MODE_TRUE + AC_SUBST(MAINT)dnl +] +) + + +# serial 40 AC_PROG_LIBTOOL +AC_DEFUN(AC_PROG_LIBTOOL, +[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl + +# Save cache, so that ltconfig can load it +AC_CACHE_SAVE + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +|| AC_MSG_ERROR([libtool configure failed]) + +# Reload cache, that may have been modified by ltconfig +AC_CACHE_LOAD + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log +]) + +AC_DEFUN(AC_LIBTOOL_SETUP, +[AC_PREREQ(2.13)dnl +AC_REQUIRE([AC_ENABLE_SHARED])dnl +AC_REQUIRE([AC_ENABLE_STATIC])dnl +AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([AC_PROG_RANLIB])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_LD])dnl +AC_REQUIRE([AC_PROG_NM])dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +dnl + +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac + +# Check for any special flags to pass to ltconfig. +libtool_flags="--cache-file=$cache_file" +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" +test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" +ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN], +[libtool_flags="$libtool_flags --enable-dlopen"]) +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[libtool_flags="$libtool_flags --enable-win32-dll"]) +AC_ARG_ENABLE(libtool-lock, + [ --disable-libtool-lock avoid locking (might break parallel builds)]) +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case "$lt_target" in +*-*-irix6*) + # Find out which ABI we are using. + echo '[#]line __oline__ "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])]) + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + +ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL], +[*-*-cygwin* | *-*-mingw*) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +]) +esac +]) + +# AC_LIBTOOL_DLOPEN - enable checks for dlopen support +AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])]) + +# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's +AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])]) + +# AC_ENABLE_SHARED - implement the --enable-shared flag +# Usage: AC_ENABLE_SHARED[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_SHARED, [dnl +define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(shared, +changequote(<<, >>)dnl +<< --enable-shared[=PKGS] build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl +]) + +# AC_DISABLE_SHARED - set the default shared flag to --disable-shared +AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_SHARED(no)]) + +# AC_ENABLE_STATIC - implement the --enable-static flag +# Usage: AC_ENABLE_STATIC[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_STATIC, [dnl +define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(static, +changequote(<<, >>)dnl +<< --enable-static[=PKGS] build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_static=AC_ENABLE_STATIC_DEFAULT)dnl +]) + +# AC_DISABLE_STATIC - set the default static flag to --disable-static +AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_STATIC(no)]) + + +# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag +# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)] +# Where DEFAULT is either `yes' or `no'. If omitted, it defaults to +# `yes'. +AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl +define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl +AC_ARG_ENABLE(fast-install, +changequote(<<, >>)dnl +<< --enable-fast-install[=PKGS] optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT], +changequote([, ])dnl +[p=${PACKAGE-default} +case "$enableval" in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac], +enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl +]) + +# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install +AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl +AC_ENABLE_FAST_INSTALL(no)]) + +# AC_PROG_LD - find the path to the GNU or non-GNU linker +AC_DEFUN(AC_PROG_LD, +[AC_ARG_WITH(gnu-ld, +[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]], +test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no) +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +ac_prog=ld +if test "$ac_cv_prog_gcc" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by GCC]) + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. +changequote(,)dnl + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' +changequote([,])dnl + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(ac_cv_path_LD, +[if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + ac_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + ac_cv_path_LD="$LD" # Let the user override the test with a path. +fi]) +LD="$ac_cv_path_LD" +if test -n "$LD"; then + AC_MSG_RESULT($LD) +else + AC_MSG_RESULT(no) +fi +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH]) +AC_PROG_LD_GNU +]) + +AC_DEFUN(AC_PROG_LD_GNU, +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld, +[# I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + ac_cv_prog_gnu_ld=yes +else + ac_cv_prog_gnu_ld=no +fi]) +]) + +# AC_PROG_NM - find the path to a BSD-compatible name lister +AC_DEFUN(AC_PROG_NM, +[AC_MSG_CHECKING([for BSD-compatible nm]) +AC_CACHE_VAL(ac_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + ac_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -p" + break + else + ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm +fi]) +NM="$ac_cv_path_NM" +AC_MSG_RESULT([$NM]) +]) + +# AC_CHECK_LIBM - check for math library +AC_DEFUN(AC_CHECK_LIBM, +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case "$lt_target" in +*-*-beos* | *-*-cygwin*) + # These system don't have libm + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw") + AC_CHECK_LIB(m, main, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, main, LIBM="-lm") + ;; +esac +]) + +# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl convenience library, adds --enable-ltdl-convenience to +# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor +# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed +# to be `${top_builddir}/libltdl'. Make sure you start DIR with +# '${top_builddir}/' (note the single quotes!) if your package is not +# flat, and, if you're not using automake, define top_builddir as +# appropriate in the Makefiles. +AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + case "$enable_ltdl_convenience" in + no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;; + "") enable_ltdl_convenience=yes + ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;; + esac + LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdlc.la + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) +]) + +# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for +# the libltdl installable library, and adds --enable-ltdl-install to +# the configure arguments. Note that LIBLTDL is not AC_SUBSTed, nor +# is AC_CONFIG_SUBDIRS called. If DIR is not provided, it is assumed +# to be `${top_builddir}/libltdl'. Make sure you start DIR with +# '${top_builddir}/' (note the single quotes!) if your package is not +# flat, and, if you're not using automake, define top_builddir as +# appropriate in the Makefiles. +# In the future, this macro may have to be called after AC_PROG_LIBTOOL. +AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl + AC_CHECK_LIB(ltdl, main, + [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no], + [if test x"$enable_ltdl_install" = xno; then + AC_MSG_WARN([libltdl not installed, but installation disabled]) + else + enable_ltdl_install=yes + fi + ]) + if test x"$enable_ltdl_install" = x"yes"; then + ac_configure_args="$ac_configure_args --enable-ltdl-install" + LIBLTDL=ifelse($#,1,$1,['${top_builddir}/libltdl'])/libltdl.la + INCLTDL=ifelse($#,1,-I$1,['-I${top_builddir}/libltdl']) + else + ac_configure_args="$ac_configure_args --enable-ltdl-install=no" + LIBLTDL="-lltdl" + INCLTDL= + fi +]) + +dnl old names +AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl +AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl +AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl +AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl +AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl +AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl +AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl + +dnl This is just to silence aclocal about the macro not being used +ifelse([AC_DISABLE_FAST_INSTALL])dnl + +# Like AC_CONFIG_HEADER, but automatically create stamp file. + +# serial 3 + +# When config.status generates a header, we must update the stamp-h file. +# This file resides in the same directory as the config header +# that is generated. We must strip everything past the first ":", +# and everything past the last "/". + +AC_PREREQ([2.12]) + +AC_DEFUN([AM_CONFIG_HEADER], +[ifdef([AC_FOREACH],dnl + [dnl init our file count if it isn't already + m4_ifndef([_AM_Config_Header_Index], m4_define([_AM_Config_Header_Index], [0])) + dnl prepare to store our destination file list for use in config.status + AC_FOREACH([_AM_File], [$1], + [m4_pushdef([_AM_Dest], m4_patsubst(_AM_File, [:.*])) + m4_define([_AM_Config_Header_Index], m4_incr(_AM_Config_Header_Index)) + dnl and add it to the list of files AC keeps track of, along + dnl with our hook + AC_CONFIG_HEADERS(_AM_File, +dnl COMMANDS, [, INIT-CMDS] +[# update the timestamp +echo timestamp >"AS_ESCAPE(_AM_DIRNAME(]_AM_Dest[))/stamp-h]_AM_Config_Header_Index[" +][$2]m4_ifval([$3], [, [$3]]))dnl AC_CONFIG_HEADERS + m4_popdef([_AM_Dest])])],dnl +[AC_CONFIG_HEADER([$1]) + AC_OUTPUT_COMMANDS( + ifelse(patsubst([$1], [[^ ]], []), + [], + [test -z "$CONFIG_HEADERS" || echo timestamp >dnl + patsubst([$1], [^\([^:]*/\)?.*], [\1])stamp-h]),dnl +[am_indx=1 +for am_file in $1; do + case " \$CONFIG_HEADERS " in + *" \$am_file "*) + am_dir=\`echo \$am_file |sed 's%:.*%%;s%[^/]*\$%%'\` + if test -n "\$am_dir"; then + am_tmpdir=\`echo \$am_dir |sed 's%^\(/*\).*\$%\1%'\` + for am_subdir in \`echo \$am_dir |sed 's%/% %'\`; do + am_tmpdir=\$am_tmpdir\$am_subdir/ + if test ! -d \$am_tmpdir; then + mkdir \$am_tmpdir + fi + done + fi + echo timestamp > "\$am_dir"stamp-h\$am_indx + ;; + esac + am_indx=\`expr \$am_indx + 1\` +done]) +])]) # AM_CONFIG_HEADER + +# _AM_DIRNAME(PATH) +# ----------------- +# Like AS_DIRNAME, only do it during macro expansion +AC_DEFUN([_AM_DIRNAME], + [m4_if(m4_regexp([$1], [^.*[^/]//*[^/][^/]*/*$]), -1, + m4_if(m4_regexp([$1], [^//\([^/]\|$\)]), -1, + m4_if(m4_regexp([$1], [^/.*]), -1, + [.], + m4_patsubst([$1], [^\(/\).*], [\1])), + m4_patsubst([$1], [^\(//\)\([^/].*\|$\)], [\1])), + m4_patsubst([$1], [^\(.*[^/]\)//*[^/][^/]*/*$], [\1]))[]dnl +]) # _AM_DIRNAME + + +# AM_PROG_LEX +# Look for flex, lex or missing, then run AC_PROG_LEX and AC_DECL_YYTEXT +AC_DEFUN([AM_PROG_LEX], +[AC_REQUIRE([AM_MISSING_HAS_RUN]) +AC_CHECK_PROGS(LEX, flex lex, [${am_missing_run}flex]) +dnl AC_PROG_LEX +AC_DECL_YYTEXT]) + diff --git a/asn1c/Makefile.am b/asn1c/Makefile.am new file mode 100644 index 00000000..2363c189 --- /dev/null +++ b/asn1c/Makefile.am @@ -0,0 +1,25 @@ + +SUBDIRS = . tests + +AM_CFLAGS = @ADD_CFLAGS@ +AM_CPPFLAGS = \ + -I${top_srcdir}/libasn1compiler \ + -I${top_srcdir}/libasn1parser \ + -I${top_srcdir}/libasn1print \ + -I${top_srcdir}/libasn1fix \ + -DDATADIR=\"${pkgdatadir}\" + +LDADD = \ + ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la \ + ${top_builddir}/libasn1print/libasn1print.la \ + ${top_builddir}/libasn1compiler/libasn1compiler.la + +bin_PROGRAMS = asn1c + +dist_man1_MANS = asn1c.1 + +check_SCRIPTS = check-parsing.sh +TESTS = check-parsing.sh +EXTRA_DIST = check-parsing.sh +CLEANFILES = .check-parsing.*.tmp diff --git a/asn1c/Makefile.in b/asn1c/Makefile.in new file mode 100644 index 00000000..6b7805bc --- /dev/null +++ b/asn1c/Makefile.in @@ -0,0 +1,556 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +SUBDIRS = . tests + +AM_CFLAGS = @ADD_CFLAGS@ +AM_CPPFLAGS = \ + -I${top_srcdir}/libasn1compiler \ + -I${top_srcdir}/libasn1parser \ + -I${top_srcdir}/libasn1print \ + -I${top_srcdir}/libasn1fix \ + -DDATADIR=\"${pkgdatadir}\" + + +LDADD = \ + ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la \ + ${top_builddir}/libasn1print/libasn1print.la \ + ${top_builddir}/libasn1compiler/libasn1compiler.la + + +bin_PROGRAMS = asn1c + +dist_man1_MANS = asn1c.1 + +check_SCRIPTS = check-parsing.sh +TESTS = check-parsing.sh +EXTRA_DIST = check-parsing.sh +CLEANFILES = .check-parsing.*.tmp +subdir = asn1c +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +bin_PROGRAMS = asn1c$(EXEEXT) +PROGRAMS = $(bin_PROGRAMS) + +asn1c_SOURCES = asn1c.c +asn1c_OBJECTS = asn1c.$(OBJEXT) +asn1c_LDADD = $(LDADD) +asn1c_DEPENDENCIES = ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la \ + ${top_builddir}/libasn1print/libasn1print.la \ + ${top_builddir}/libasn1compiler/libasn1compiler.la +asn1c_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/asn1c.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = asn1c.c + +NROFF = nroff +MANS = $(dist_man1_MANS) + +RECURSIVE_TARGETS = info-recursive dvi-recursive install-info-recursive \ + uninstall-info-recursive all-recursive install-data-recursive \ + install-exec-recursive installdirs-recursive install-recursive \ + uninstall-recursive check-recursive installcheck-recursive +DIST_COMMON = README $(dist_man1_MANS) Makefile.am Makefile.in +DIST_SUBDIRS = $(SUBDIRS) +SOURCES = asn1c.c + +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu asn1c/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status +install-binPROGRAMS: $(bin_PROGRAMS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ + if test -f $$p \ + || test -f $$p1 \ + ; then \ + f=`echo $$p1|sed '$(transform);s/$$/$(EXEEXT)/'`; \ + echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$f"; \ + $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$f; \ + else :; fi; \ + done + +uninstall-binPROGRAMS: + @$(NORMAL_UNINSTALL) + @list='$(bin_PROGRAMS)'; for p in $$list; do \ + f=`echo $$p|sed 's/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ + echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ + rm -f $(DESTDIR)$(bindir)/$$f; \ + done + +clean-binPROGRAMS: + -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) +asn1c$(EXEEXT): $(asn1c_OBJECTS) $(asn1c_DEPENDENCIES) + @rm -f asn1c$(EXEEXT) + $(LINK) $(asn1c_LDFLAGS) $(asn1c_OBJECTS) $(asn1c_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1c.Po@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ +uninstall-info-am: + +man1dir = $(mandir)/man1 +install-man1: $(man1_MANS) $(man_MANS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(man1dir) + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ + else file=$$i; fi; \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst"; \ + $(INSTALL_DATA) $$file $(DESTDIR)$(man1dir)/$$inst; \ + done +uninstall-man1: + @$(NORMAL_UNINSTALL) + @list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \ + l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ + for i in $$l2; do \ + case "$$i" in \ + *.1*) list="$$list $$i" ;; \ + esac; \ + done; \ + for i in $$list; do \ + ext=`echo $$i | sed -e 's/^.*\\.//'`; \ + inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ + inst=`echo $$inst | sed -e 's/^.*\///'`; \ + inst=`echo $$inst | sed '$(transform)'`.$$ext; \ + echo " rm -f $(DESTDIR)$(man1dir)/$$inst"; \ + rm -f $(DESTDIR)$(man1dir)/$$inst; \ + done + +# This directory's subdirectories are mostly independent; you can cd +# into them and run `make' without going through this Makefile. +# To change the values of `make' variables: instead of editing Makefiles, +# (1) if the variable is set in `config.status', edit `config.status' +# (which will cause the Makefiles to be regenerated when you run `make'); +# (2) otherwise, pass the desired values on the `make' command line. +$(RECURSIVE_TARGETS): + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +mostlyclean-recursive clean-recursive distclean-recursive \ +maintainer-clean-recursive: + @set fnord $(MAKEFLAGS); amf=$$2; \ + dot_seen=no; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + rev=''; for subdir in $$list; do \ + if test "$$subdir" = "."; then :; else \ + rev="$$subdir $$rev"; \ + fi; \ + done; \ + rev="$$rev ."; \ + target=`echo $@ | sed s/-recursive//`; \ + for subdir in $$rev; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ + done && test -z "$$fail" +tags-recursive: + list='$(SUBDIRS)'; for subdir in $$list; do \ + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ + done + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test -f $$subdir/TAGS && tags="$$tags -i $$here/$$subdir/TAGS"; \ + fi; \ + done; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done + for subdir in $(SUBDIRS); do \ + if test "$$subdir" = .; then :; else \ + test -d $(distdir)/$$subdir \ + || mkdir $(distdir)/$$subdir \ + || exit 1; \ + (cd $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$(top_distdir)" \ + distdir=../$(distdir)/$$subdir \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_SCRIPTS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-recursive +all-am: Makefile $(PROGRAMS) $(MANS) +installdirs: installdirs-recursive +installdirs-am: + $(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(man1dir) + +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am + +distclean: distclean-recursive + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-recursive + +dvi-am: + +info: info-recursive + +info-am: + +install-data-am: install-man + +install-exec-am: install-binPROGRAMS + +install-info: install-info-recursive + +install-man: install-man1 + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man + +uninstall-info: uninstall-info-recursive + +uninstall-man: uninstall-man1 + +.PHONY: $(RECURSIVE_TARGETS) GTAGS all all-am check check-TESTS check-am \ + clean clean-binPROGRAMS clean-generic clean-libtool \ + clean-recursive distclean distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-recursive \ + distclean-tags distdir dvi dvi-am dvi-recursive info info-am \ + info-recursive install install-am install-binPROGRAMS \ + install-data install-data-am install-data-recursive \ + install-exec install-exec-am install-exec-recursive \ + install-info install-info-am install-info-recursive install-man \ + install-man1 install-recursive install-strip installcheck \ + installcheck-am installdirs installdirs-am \ + installdirs-recursive maintainer-clean maintainer-clean-generic \ + maintainer-clean-recursive mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \ + tags tags-recursive uninstall uninstall-am \ + uninstall-binPROGRAMS uninstall-info-am \ + uninstall-info-recursive uninstall-man uninstall-man1 \ + uninstall-recursive + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/asn1c/README b/asn1c/README new file mode 100644 index 00000000..158cd115 --- /dev/null +++ b/asn1c/README @@ -0,0 +1 @@ +The ASN.1 Compiler diff --git a/asn1c/asn1c.1 b/asn1c/asn1c.1 new file mode 100644 index 00000000..1b58f4df --- /dev/null +++ b/asn1c/asn1c.1 @@ -0,0 +1,99 @@ +.de Id +.. +.Id $Id" +.TH ASN1C 1 "\*(Dt" "ASN.1 Compiler" "ASN.1 Compiler" +.SH NAME +asn1c \- ASN.1 Compiler +.ND ASN.1 compiler +.SH SYNOPSIS +.B asn1c +.RI "[ " option " | " filename " ].\|.\|." +.SH DESCRIPTION +asn1c is a tool to compile the ASN.1 specifications into C language structures +and accompanying routines to perform data encoding and decoding. +.SH OPTIONS +.TP +.B Overall Options +\-E +\-F +\-L +\-N +\-P +.RI "\-S " directory +\-R +.TP +.B Language Options +.br +\-ftypes88 +\-fnative-integers +\-fno-c99 +\-funnamed-unions +.TP +.B Warning Options +.br +\-Werror +\-Wdebug-lexer +\-Wdebug-fixer +\-Wdebug-compiler +.SH OVERALL OPTIONS +.TP +.B \-E +Stop after the parsing stage. The output is reconstructed ASN.1 +specification code, which is sent to the standard output. +.TP +.B \-F +Used together with \c +.B \-E\c +, instructs the compiler to stop after the ASN.1 syntax +tree fixing stage and dump the reconstructed ASN.1 specification +to the standard output. +.TP +.B \-L +Generate "-- #line" comments in +.B -E +output. +.TP +.B \-N +Do not generate certain type of comments in +.B -E +output. +.TP +.B \-P +Dump the compiled output to the standard output instead of creating the +target language files on disk. +.TP +.B \-S directory +Use the specified directory with ASN.1 skeleton files. +.TP +.B \-R +Restrict the compiler to generate only the ASN.1 tables, +omitting the usual support code. +.SH LANGUAGE OPTIONS +.TP +.B \-ftypes88 +Use only ASN.1:1988 embedded types. +.TP +.B \-fnative-integers +Use native machine's integer types whenever possible, +instead of the complex ASN.1 INTEGER and ENUMERATED types. +.TP +.B \-fno-c99 +Disable use of certain C99 extensions, like designated initializers. +.TP +.B \-funnamed-unions +Enable unnamed unions in structures definitions. +.SH WARNING OPTIONS +.TP +.B \-Werror +Treat warnings as errors; abort if any warning is produced. +.TP +.B \-Wdebug-lexer +Enable lexer debugging during the ASN.1 parsing stage. +.TP +.B \-Wdebug-fixer +Enable ASN.1 syntax tree fixer debugging during the fixing stage. +.TP +.B \-Wdebug-compiler +Enable debugging during the actual compile time. +.SH AUTHORS +Lev Walkin diff --git a/asn1c/asn1c.c b/asn1c/asn1c.c new file mode 100644 index 00000000..afedf6bf --- /dev/null +++ b/asn1c/asn1c.c @@ -0,0 +1,267 @@ +/* + * 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 +#include +#include +#include +#include /* for stat(2) */ +#include +#include /* for basename(3) */ +#include /* for EX_USAGE */ +#include +#include + +#include /* Parse the ASN.1 file and build a tree */ +#include /* Fix the ASN.1 tree */ +#include /* Print the ASN.1 tree */ +#include /* Compile the ASN.1 tree */ + +static void usage(char *av0); /* Print the Usage screen and exit(EX_USAGE) */ + +int +main(int ac, char **av) { + enum asn1p_flags asn1_parser_flags = A1P_NOFLAGS; + enum asn1f_flags asn1_fixer_flags = A1F_NOFLAGS; + enum asn1c_flags asn1_compiler_flags = A1C_NOFLAGS; + int print_arg__print_out = 0; /* Don't compile, just print parsed */ + int print_arg__fix_n_print = 0; /* Fix and print */ + enum asn1print_flags_e print_arg__flags = APF_NOFLAGS; + int warnings_as_errors = 0; /* Treat warnings as errors */ + char *skeletons_dir = NULL; /* Directory with supplementary stuff */ + asn1p_t *asn = 0; /* An ASN.1 parsed tree */ + int ret; /* Return value from misc functions */ + int ch; /* Command line character */ + int i; /* Index in some loops */ + + /* + * Process command-line options. + */ + while((ch = getopt(ac, av, "EFf:LNPRS:W:")) != -1) + switch(ch) { + case 'E': + print_arg__print_out = 1; + break; + case 'F': + print_arg__fix_n_print = 1; + break; + case 'f': + if(strcmp(optarg, "types88") == 0) { + asn1_parser_flags |= A1P_TYPES_RESTRICT_TO_1988; + } else if(strcmp(optarg, "constr90") == 0) { + asn1_parser_flags |= A1P_CONSTRUCTS_RESTRICT_TO_1990; + } else if(strcmp(optarg, "native-integers") == 0) { + asn1_compiler_flags |= A1C_USE_NATIVE_INTEGERS; + } else if(strcmp(optarg, "no-c99") == 0) { + asn1_compiler_flags |= A1C_NO_C99; + } else if(strcmp(optarg, "unnamed-unions") == 0) { + asn1_compiler_flags |= A1C_UNNAMED_UNIONS; + } else { + fprintf(stderr, "-f%s: Invalid argument\n", optarg); + exit(EX_USAGE); + } + break; + case 'L': + print_arg__flags = APF_LINE_COMMENTS; + break; + case 'N': + print_arg__flags = APF_NO_SOURCE_COMMENTS; + break; + case 'P': + asn1_compiler_flags |= A1C_PRINT_COMPILED; + break; + case 'R': + asn1_compiler_flags |= A1C_OMIT_SUPPORT_CODE; + break; + case 'S': + skeletons_dir = optarg; + break; + case 'W': + if(strcmp(optarg, "error") == 0) { + warnings_as_errors = 1; + break; + } else if(strcmp(optarg, "debug-lexer") == 0) { + asn1_parser_flags |= A1P_LEXER_DEBUG; + break; + } else if(strcmp(optarg, "debug-fixer") == 0) { + asn1_fixer_flags |= A1F_DEBUG; + break; + } else if(strcmp(optarg, "debug-compiler") == 0) { + asn1_compiler_flags |= A1C_DEBUG; + break; + } else { + fprintf(stderr, "-W%s: Invalid argument\n", optarg); + exit(EX_USAGE); + } + break; + default: + usage(av[0]); + } + + /* + * Validate the options combination. + */ + if(!print_arg__print_out) { + if(print_arg__fix_n_print) { + fprintf(stderr, "Error: -F requires -E\n"); + exit(EX_USAGE); + } + } + + /* + * Ensure that there are some input files present. + */ + if(ac > optind) { + ac -= optind; + av += optind; + } else { + fprintf(stderr, "%s: No input files specified\n", + basename(av[0])); + exit(1); + } + + /* + * Iterate over input files and parse each. + * All syntax trees from all files will be bundled together. + */ + for(i = 0; i < ac; i++) { + asn1p_t *new_asn; + + new_asn = asn1p_parse_file(av[i], asn1_parser_flags); + if(new_asn == NULL) { + fprintf(stderr, "Cannot parse \"%s\"\n", av[i]); + exit(EX_DATAERR); + } + + /* + * Bundle the parsed tree with existing one. + */ + if(asn) { + asn1p_module_t *mod; + while((mod = TQ_REMOVE(&(new_asn->modules), mod_next))) + TQ_ADD(&(asn->modules), mod, mod_next); + asn1p_free(new_asn); + } else { + asn = new_asn; + } + + } + + /* + * Dump the parsed ASN.1 tree if -E specified and -F is not given. + */ + if(print_arg__print_out && !print_arg__fix_n_print) { + if(asn1print(asn, print_arg__flags)) + exit(EX_SOFTWARE); + return 0; + } + + + /* + * Process the ASN.1 specification: perform semantic checks, + * expand references, etc, etc. + * This function will emit necessary warnings and error messages. + */ + ret = asn1f_process(asn, asn1_fixer_flags, + NULL /* default fprintf(stderr) */); + switch(ret) { + case 1: + if(!warnings_as_errors) + /* Fall through */ + case 0: + break; /* All clear */ + case -1: + exit(EX_DATAERR); /* Fatal failure */ + } + + /* + * Dump the parsed ASN.1 tree if -E specified and -F is given. + */ + if(print_arg__print_out && print_arg__fix_n_print) { + if(asn1print(asn, print_arg__flags)) + exit(EX_SOFTWARE); + return 0; + } + + /* + * Make sure the skeleton directory is out there. + */ + if(skeletons_dir == NULL) { + struct stat sb; + skeletons_dir = DATADIR; + if((av[-optind][0] == '.' || av[-optind][1] == '/') + && stat(skeletons_dir, &sb)) { + /* + * The default skeletons directory does not exist, + * compute it from my file name: + * ./asn1c/asn1c -> ./skeletons + */ + char *p; + int len; + + p = dirname(av[-optind]); + + len = strlen(p) + sizeof("/../skeletons"); + skeletons_dir = alloca(len); + snprintf(skeletons_dir, len, "%s/../skeletons", p); + if(stat(skeletons_dir, &sb)) { + fprintf(stderr, + "WARNING: skeletons are neither in " + "\"%s\" nor in \"%s\"!\n", + DATADIR, skeletons_dir); + if(warnings_as_errors) + exit(EX_SOFTWARE); + } + } + } + + /* + * Compile the ASN.1 tree into a set of source files + * of another language. + */ + if(asn1_compile(asn, skeletons_dir, asn1_compiler_flags)) { + exit(EX_SOFTWARE); + } + + return 0; +} + +/* + * Print the usage screen and exit(EX_USAGE). + */ +static void +usage(char *av0) { + fprintf(stderr, + "ASN.1 Compiler, v" VERSION "\n" + "Copyright (c) 2003, 2004 Lev Walkin \n" + "Usage: %s [options] ...\n" + "Where [options] are:\n" + "\t-E\tRun only the ASN.1 parser and print out the tree\n" + "\t-F\tDuring -E operation, also perform tree fixing\n" + "\t-L\tGenerate \"-- #line\" comments in -E output\n" + "\t-N\tDo not generate certain type of comments in -E output\n" + "\n" + "\t-P \tConcatenate and print the compiled text\n" + "\t-S \tDirectory with support (skeleton?) files\n" + "\t \t(Default is \"%s\")\n" + "\t-R \tRestrict output (tables only, no support code)\n" + "\n" + "\t-ftypes88\tUse only ASN.1:1988 embedded types\n" +/* + "\t-fconstr90\tUse only ASN.1:1990 constructs (not available)\n" +*/ + "\t-fnative-integers\tUse native integers where possible\n" + "\t-fno-c99\tDisable C99 extensions\n" + "\t-funnamed-unions\tEnable unnamed unions in structures\n" + "\n" + "\t-Werror \tTreat warnings as errors; abort if any warning\n" + "\t-Wdebug-lexer\tEnable verbose debugging output from lexer\n" + "\t-Wdebug-fixer\tDebug ASN.1 semantics processor\n" + "\t-Wdebug-compiler\tDebug ASN.1 compiler\n" + , + basename(av0), DATADIR + ); + exit(EX_USAGE); +} + diff --git a/asn1c/check-parsing.sh b/asn1c/check-parsing.sh new file mode 100755 index 00000000..9a7bfde7 --- /dev/null +++ b/asn1c/check-parsing.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +tmpfile=".check-parsing.$$.tmp" + +ec=0 + +for ref in ../tests/*.asn1.-*; do + src=`echo "$ref" | sed -e 's/\.-[a-zA-Z]*$//'` + flags=`echo "$ref" | sed -e 's/.*\.-//'` + echo "Checking $src against $ref" + ./asn1c "-$flags" "$src" > "$tmpfile" || ec=$? + if [ $? = 0 ]; then + diff "$ref" "$tmpfile" || ec=$? + fi + rm -f "$tmpfile" +done + +exit $ec diff --git a/asn1c/tests/Makefile.am b/asn1c/tests/Makefile.am new file mode 100644 index 00000000..91dc54d3 --- /dev/null +++ b/asn1c/tests/Makefile.am @@ -0,0 +1,10 @@ + +check_SCRIPTS = ./check-assembly.sh + +TESTS_ENVIRONMENT= ./check-assembly.sh +TESTS = check-*.c + +EXTRA_DIST = ${check_SCRIPTS} check-*.c + +clean: + for t in test-*; do rm -rf $$t; done diff --git a/asn1c/tests/Makefile.in b/asn1c/tests/Makefile.in new file mode 100644 index 00000000..6689049c --- /dev/null +++ b/asn1c/tests/Makefile.in @@ -0,0 +1,284 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = ../.. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +check_SCRIPTS = ./check-assembly.sh + +TESTS_ENVIRONMENT = ./check-assembly.sh +TESTS = check-*.c + +EXTRA_DIST = ${check_SCRIPTS} check-*.c +subdir = asn1c/tests +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = +DIST_COMMON = README Makefile.am Makefile.in +all: all-am + +.SUFFIXES: + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu asn1c/tests/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status +uninstall-info-am: +tags: TAGS +TAGS: + + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = ../.. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_SCRIPTS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-generic distclean-libtool + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-TESTS check-am clean clean-generic \ + clean-libtool distclean distclean-generic distclean-libtool \ + distdir dvi dvi-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool uninstall uninstall-am uninstall-info-am + + +clean: + for t in test-*; do rm -rf $$t; done +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/asn1c/tests/README b/asn1c/tests/README new file mode 100644 index 00000000..b7fb5605 --- /dev/null +++ b/asn1c/tests/README @@ -0,0 +1,6 @@ + +This is a very funny test automation. The name of the check-*.c file is used +as a pointer to the file in ../..//tests/*-*.asn1. This file is compiled +using the asn1c from above directory. Then, everything is build together +in a temporary directory with a check-*.c used as a testing engine. + diff --git a/asn1c/tests/check-22.c b/asn1c/tests/check-22.c new file mode 100644 index 00000000..c80f9881 --- /dev/null +++ b/asn1c/tests/check-22.c @@ -0,0 +1,141 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf1[] = { + 32 | 16, /* [UNIVERSAL 16], constructed */ + 12, /* L */ + /* INTEGER a */ + ((2 << 6) + 0), /* [0], primitive */ + 2, /* L */ + 150, + 70, + /* b [1] EXPLICIT CHOICE */ + 32 | ((2 << 6) + 1), /* [1] */ + 3, /* L */ + ((2 << 6) + 1), /* [1] */ + 1, + 'i', + /* UTF8String c */ + ((2 << 6) + 2), /* [2], primitive */ + 1, /* L */ + 'x' +}; + +uint8_t buf2[128]; +int buf2_pos; + +static int +buf2_fill(const void *buffer, size_t size, void *app_key) { + if(buf2_pos + size > sizeof(buf2)) + return -1; + + memcpy(buf2 + buf2_pos, buffer, size); + buf2_pos += size; + + return 0; +} + +static void +check(int is_ok, uint8_t *buf, int size, int consumed) { + T1_t t, *tp; + ber_dec_rval_t rval; + der_enc_rval_t erval; + int i; + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "Buf %p\n", buf); + rval = ber_decode(&asn1_DEF_T1, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d\n", + (int)rval.code, (int)rval.consumed); + + if(is_ok) { + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + assert(t.a.size == 2); + assert(t.b.present == b_PR_n); + assert(t.b.choice.n.size == 1); + assert(t.b.choice.n.buf[0] == 'i'); + assert(t.c.size == 1); + assert(t.c.buf[0] == 'x'); + + } else { + if(rval.code == RC_OK) { + assert(t.a.size != 2 + || t.b.present != b_PR_n + || t.b.choice.n.size != 1 + || t.c.size != 1 + ); + } + assert(rval.consumed <= consumed); + return; + } + + fprintf(stderr, "=> Re-creating using DER encoder <=\n"); + + /* + * Try to re-create using DER encoding. + */ + buf2_pos = 0; + erval = der_encode(&asn1_DEF_T1, tp, buf2_fill, 0); + assert(erval.encoded != -1); + if(erval.encoded != sizeof(buf1)) { + printf("%d != %d\n", (int)erval.encoded, (int)sizeof(buf1)); + } + assert(erval.encoded == sizeof(buf1)); + for(i = 0; i < sizeof(buf1); i++) { + if(buf1[i] != buf2[i]) { + fprintf(stderr, "Recreated buffer content mismatch:\n"); + fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n", + i, + buf1[i], buf2[i], + buf1[i], buf2[i] + ); + } + assert(buf1[i] == buf2[i]); + } + + fprintf(stderr, "=== PRINT ===\n"); + asn_fprint(stderr, &asn1_DEF_T1, tp); + fprintf(stderr, "=== EOF ===\n"); +} + +static void +try_corrupt(uint8_t *buf, int size) { + uint8_t *tmp; + int i; + + fprintf(stderr, "\nCorrupting...\n"); + + tmp = alloca(size); + + for(i = 0; i < 1000; i++) { + int loc; + memcpy(tmp, buf, size); + + /* Corrupt random _non-value_ location. */ + do { loc = random() % size; } while(tmp[loc] >= 70); + do { tmp[loc] ^= random(); } while(tmp[loc] == buf[loc]); + + fprintf(stderr, "\nTry %d: corrupting byte %d (%d->%d)\n", + i, loc, buf[loc], tmp[loc]); + + check(0, tmp, size, size); + } +} + +int +main(int ac, char **av) { + + check(1, buf1, sizeof(buf1), sizeof(buf1)); + try_corrupt(buf1, sizeof(buf1)); + check(1, buf1, sizeof(buf1) + 10, sizeof(buf1)); + + return 0; +} diff --git a/asn1c/tests/check-24.c b/asn1c/tests/check-24.c new file mode 100644 index 00000000..b74ca165 --- /dev/null +++ b/asn1c/tests/check-24.c @@ -0,0 +1,94 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf1[] = { + 32 | ((2 << 6) + 5), /* [5], constructed */ + 17, /* L */ + 32 | 16, /* [UNIVERSAL 16], constructed */ + 15, /* L */ + /* INTEGER a */ + 2, /* [UNIVERSAL 2] */ + 2, /* L */ + 150, + 70, + /* INTEGER b */ + ((2 << 6) + 0), /* [0] */ + 1, /* L */ + 123, + /* INTEGER c */ + ((2 << 6) + 1), /* [1] */ + 1, /* L */ + 123, + /* INTEGER d */ + 32 | ((2 << 6) + 5), /* [5], constructed */ + 3, + 2, + 1, /* L */ + 123, +}; + +static void +check(int is_ok, uint8_t *buf, int size, int consumed) { + T_t t, *tp; + ber_dec_rval_t rval; + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "Buf %p\n", buf); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d\n", + (int)rval.code, (int)rval.consumed); + + if(is_ok) { + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + } else { + if(rval.code == RC_OK) { + assert(t.a.size != 2 + || (!t.b || t.b->size != 1) + || (!t.c || t.c->size != 1) + || t.d.size != 1 + ); + } + assert(rval.consumed <= consumed); + } +} + +static void +try_corrupt(uint8_t *buf, int size) { + uint8_t *tmp; + int i; + + fprintf(stderr, "\nCorrupting...\n"); + + tmp = alloca(size); + + for(i = 0; i < 1000; i++) { + int loc; + memcpy(tmp, buf, size); + + /* Corrupt random _non-value_ location. */ + do { loc = random() % size; } while(tmp[loc] >= 70); + do { tmp[loc] ^= random(); } while(tmp[loc] == buf[loc]); + + fprintf(stderr, "\nTry %d: corrupting byte %d (%d->%d)\n", + i, loc, buf[loc], tmp[loc]); + + check(0, tmp, size, size); + } +} + +int +main(int ac, char **av) { + + check(1, buf1, sizeof(buf1), sizeof(buf1)); + try_corrupt(buf1, sizeof(buf1)); + + return 0; +} diff --git a/asn1c/tests/check-25.c b/asn1c/tests/check-25.c new file mode 100644 index 00000000..bd803da3 --- /dev/null +++ b/asn1c/tests/check-25.c @@ -0,0 +1,252 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf1[] = { + 32 | 16, /* [UNIVERSAL 16], constructed */ + 128, /* L */ + /* a INTEGER */ + 2, /* [UNIVERSAL 2] */ + 2, /* L */ + 150, + 70, + /* b BOOLEAN */ + 128 | 2, /* [2] */ + 1, /* L */ + 0xff, + /* c NULL */ + 5, /* [UNIVERSAL 5] */ + 0, /* L */ + /* d ENUMERATED */ + 10, /* [UNIVERSAL 10] */ + 1, /* L */ + 222, + 4, /* [UNIVERSAL 4] */ + 3, /* L */ + 'x', + 'y', + 'z', + /* f OCTET STRING */ + 32 | 4, /* [UNIVERSAL 4], constructed */ + 128, /* L indefinite */ + 4, /* [UNIVERSAL 4], primitive */ + 2, + 'l', + 'o', + 32 | 4, /* [UNIVERSAL 4], recursively constructed */ + 128, + 4, + 1, + 'v', + 4, + 2, + 'e', + '_', + 0, + 0, + 4, /* [UNIVERSAL 4], primitive */ + 2, + 'i', + 't', + 0, + 0, + /* g BIT STRING */ + 3, /* [UNIVERSAL 3], primitive */ + 3, /* L */ + 2, /* Skip 2 bits */ + 147, + 150, /* => 148 */ + /* h BIT STRING */ + 32 | 3, /* [UNIVERSAL 3], constructed */ + 128, /* L indefinite */ + 3, /* [UNIVERSAL 3], primitive */ + 3, /* L */ + 0, /* Skip 0 bits */ + 140, + 141, + 3, /* [UNIVERSAL 3], primitive */ + 2, /* L */ + 1, /* Skip 1 bit */ + 143, /* => 142 */ + 0, /* End of f */ + 0, + 0, /* End of the whole structure */ + 0, + /* Three bytes of planned leftover */ + 111, 222, 223 +}; + +static void +check(int is_ok, uint8_t *buf, int size, int consumed) { + T_t t, *tp; + ber_dec_rval_t rval; + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "Buf %p (%d)\n", buf, (int)size); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d, expected %d\n", + (int)rval.code, (int)rval.consumed, (int)consumed); + + if(is_ok) { + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + + assert(strcmp(t.e->buf, "xyz") == 0); + assert(strcmp(t.f->buf, "love_it") == 0); + + assert(t.g->size == 3); + assert(t.g->buf[0] == 2); + assert(t.g->buf[1] == 147); + assert(t.g->buf[2] == 148); + + printf("%d\n", t.h->buf[3]); + assert(t.h->size == 4); + assert(t.h->buf[0] == 1); + assert(t.h->buf[1] == 140); + assert(t.h->buf[2] == 141); + assert(t.h->buf[3] == 142); + } else { + if(rval.code == RC_OK) { + assert(t.a.size != 2 + || !t.d + || t.d->size != 1 + || !t.e + || t.e->size != 3 + || !t.f + || t.f->size != 7 + || !t.g + || t.g->size != 3 + || !t.h + || t.h->size != 4 + ); + } + fprintf(stderr, "%d %d\n", (int)rval.consumed, (int)consumed); + assert(rval.consumed <= consumed); + } + + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); +} + +static void +try_corrupt(uint8_t *buf, int size, int allow_consume) { + uint8_t *tmp; + int i; + + fprintf(stderr, "\nCorrupting...\n"); + + tmp = alloca(size); + + for(i = 0; i < 1000; i++) { + int loc; + memcpy(tmp, buf, size); + + /* Corrupt random _non-value_ location. */ + do { loc = random() % size; } while( + loc == 44 /* bit skips */ + || loc == 51 /* bit skips */ + || loc == 56 /* bit skips */ + || tmp[loc] >= 70); + do { tmp[loc] = buf[loc] ^ random(); } while( + (tmp[loc] == buf[loc]) + || (buf[loc] == 0 && tmp[loc] == 0x80)); + + fprintf(stderr, "\nTry %d: corrupting byte %d (%d->%d)\n", + i, loc, buf[loc], tmp[loc]); + + check(0, tmp, size, allow_consume); + } +} + +static void +partial_read(uint8_t *buf, int size) { + T_t t, *tp; + ber_dec_rval_t rval; + int i1, i2; + uint8_t *buf1 = alloca(size); + uint8_t *buf2 = alloca(size); + uint8_t *buf3 = alloca(size); + + fprintf(stderr, "\nPartial read sequence...\n"); + + /* + * Divide the space (size) into three blocks in various combinations: + * |<----->i1<----->i2<----->| + * ^ buf ^ buf+size + * Try to read block by block. + */ + for(i1 = 0; i1 < size; i1++) { + for(i2 = i1; i2 < size; i2++) { + uint8_t *chunk1 = buf; + int size1 = i1; + uint8_t *chunk2 = buf + size1; + int size2 = i2 - i1; + uint8_t *chunk3 = buf + size1 + size2; + int size3 = size - size1 - size2; + + fprintf(stderr, "\n%d:{%d, %d, %d}...\n", + size, size1, size2, size3); + + memset(buf1, 0, size); + memset(buf2, 0, size); + memset(buf3, 0, size); + memcpy(buf1, chunk1, size1); + memcpy(buf2, chunk2, size2); + memcpy(buf3, chunk3, size3); + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "=> Chunk 1 (%d):\n", size1); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf1, size1); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size1); + if(rval.consumed < size1) { + int leftover = size1 - rval.consumed; + memcpy(buf2, buf1 + rval.consumed, leftover); + memcpy(buf2 + leftover, chunk2, size2); + size2 += leftover; + } + + fprintf(stderr, "=> Chunk 2 (%d):\n", size2); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf2, size2); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size2); + if(rval.consumed < size2) { + int leftover = size2 - rval.consumed; + memcpy(buf3, buf2 + rval.consumed, leftover); + memcpy(buf3 + leftover, chunk3, size3); + size3 += leftover; + } + + fprintf(stderr, "=> Chunk 3 (%d):\n", size3); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf3, size3); + assert(rval.code == RC_OK); + assert(rval.consumed == size3); + + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + } + } +} + +int +main(int ac, char **av) { + + /* Check that the full buffer may be decoded normally */ + check(1, buf1, sizeof(buf1), sizeof(buf1) - 3); + + /* Check that some types of buffer corruptions will lead to failure */ + try_corrupt(buf1, sizeof(buf1) - 3, sizeof(buf1) - 3); + + /* Split the buffer in parts and check decoder restartability */ + partial_read(buf1, sizeof(buf1) - 3); + + return 0; +} diff --git a/asn1c/tests/check-30.c b/asn1c/tests/check-30.c new file mode 100644 index 00000000..9e5adf22 --- /dev/null +++ b/asn1c/tests/check-30.c @@ -0,0 +1,116 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf1[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 8, /* L */ + + /* a INTEGER */ + 64 | 3, /* [APPLICATION 3] */ + 1, /* L */ + 96, + + /* b IA5String */ + 22, /* [UNIVERSAL 22] */ + 3, /* L */ + 'x', + 'y', + 'z' +}; + +/* + * This buffer aims at checking the duplication. + */ +uint8_t buf2[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 8, /* L */ + + /* a INTEGER */ + 64 | 3, /* [APPLICATION 3] */ + 1, /* L */ + 96, + + /* a INTEGER _again_ */ + 64 | 3, /* [APPLICATION 3] */ + 1, /* L */ + 97, +}; + +static void +check(int is_ok, uint8_t *buf, int size, int consumed) { + T_t t, *tp; + ber_dec_rval_t rval; + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "Buf %p\n", buf); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d\n", + (int)rval.code, (int)rval.consumed); + + if(is_ok) { + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + + assert(t.a.size == 1); + assert(t.a.buf[0] == 96); + assert(t.b.size == 3); + assert(t.c == 0); + assert(strcmp(t.b.buf, "xyz") == 0); + } else { + if(rval.code == RC_OK) { + assert(t.a.size != 1 + || t.b.size != 3 + || !t.c + ); + } + assert(rval.consumed <= consumed); + } +} + +static void +try_corrupt(uint8_t *buf, int size) { + uint8_t *tmp; + int i; + + fprintf(stderr, "\nCorrupting...\n"); + + tmp = alloca(size); + + for(i = 0; i < 1000; i++) { + int loc; + memcpy(tmp, buf, size); + + /* Corrupt random _non-value_ location. */ + do { loc = random() % size; } while(tmp[loc] >= 70); + do { tmp[loc] = buf[loc] ^ random(); } while( + (tmp[loc] == buf[loc]) + || (buf[loc] == 0 && tmp[loc] == 0x80)); + + fprintf(stderr, "\nTry %d: corrupting byte %d (%d->%d)\n", + i, loc, buf[loc], tmp[loc]); + + check(0, tmp, size, size); + } +} + +int +main(int ac, char **av) { + + fprintf(stderr, "Must succeed:\n"); + check(1, buf1, sizeof(buf1) + 20, sizeof(buf1)); + + fprintf(stderr, "\nMust fail:\n"); + check(0, buf2, sizeof(buf2) + 1, 5); + + fprintf(stderr, "\nPseudo-random buffer corruptions must fail\n"); + try_corrupt(buf1, sizeof(buf1)); + + return 0; +} diff --git a/asn1c/tests/check-31.c b/asn1c/tests/check-31.c new file mode 100644 index 00000000..53a90cba --- /dev/null +++ b/asn1c/tests/check-31.c @@ -0,0 +1,175 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf1[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 128, /* L, indefinite */ + + 32 | 16, /* [UNIVERSAL 16], constructed */ + 6, /* L */ + + /* height INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 100, + /* width INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 80, + + 32 | 16, /* [UNIVERSAL 16], constructed */ + 6, /* L */ + + /* height INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 110, + /* width INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 82, + + 0, /* End of forest */ + 0 +}; + +uint8_t buf1_reconstr[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 16, /* L */ + + 32 | 16, /* [UNIVERSAL 16], constructed */ + 6, /* L */ + + /* height INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 100, + /* width INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 80, + + 32 | 16, /* [UNIVERSAL 16], constructed */ + 6, /* L */ + + /* height INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 110, + /* width INTEGER */ + 2, /* [UNIVERSAL 2] */ + 1, /* L */ + 82 + +}; + +int buf_pos; +int bytes_compare(const void *bufferp, size_t size, void *key) { + const uint8_t *buffer = bufferp; + assert(buf_pos + size <= sizeof(buf1_reconstr)); + + fprintf(stderr, " writing %d (%d)\n", (int)size, buf_pos + (int)size); + + for(; size; buf_pos++, size--, buffer++) { + if(buf1_reconstr[buf_pos] != *buffer) { + fprintf(stderr, + "Byte %d is different: %d != %d (%x != %x)\n", + buf_pos, + *buffer, buf1_reconstr[buf_pos], + *buffer, buf1_reconstr[buf_pos] + ); + assert(buf1_reconstr[buf_pos] == *buffer); + } + } + + return 0; +} + +static void +check(int is_ok, uint8_t *buf, int size, int consumed) { + Forest_t t, *tp; + ber_dec_rval_t rval; + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "Buf %p\n", buf); + rval = ber_decode(&asn1_DEF_Forest, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d\n", + (int)rval.code, (int)rval.consumed); + + if(is_ok) { + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + + assert(t.list.count == 2); + assert(t.list.array[0]->height.size == 1); + assert(t.list.array[0]->width.size == 1); + assert(t.list.array[1]->height.size == 1); + assert(t.list.array[1]->width.size == 1); + } else { + if(rval.code == RC_OK) { + assert(t.list.count != 2 + || t.list.array[0]->height.size != 1 + || t.list.array[0]->width.size != 1 + || t.list.array[1]->height.size != 1 + || t.list.array[1]->width.size != 1 + ); + } + assert(rval.consumed <= consumed); + return; + } + + /* + * Try to re-create the buffer. + */ + buf_pos = 0; + der_encode(&asn1_DEF_Forest, &t, + bytes_compare, buf1_reconstr); + assert(buf_pos == sizeof(buf1_reconstr)); + + asn_fprint(stderr, &asn1_DEF_Forest, &t); + + asn1_DEF_Forest.free_struct(&asn1_DEF_Forest, &t, 1); +} + +static void +try_corrupt(uint8_t *buf, int size) { + uint8_t *tmp; + int i; + + fprintf(stderr, "\nCorrupting...\n"); + + tmp = alloca(size); + + for(i = 0; i < 1000; i++) { + int loc; + memcpy(tmp, buf, size); + + /* Corrupt random _non-value_ location. */ + do { loc = random() % size; } while(tmp[loc] >= 70); + do { tmp[loc] = buf[loc] ^ random(); } while( + (tmp[loc] == buf[loc]) + || (buf[loc] == 0 && tmp[loc] == 0x80)); + + fprintf(stderr, "\nTry %d: corrupting byte %d (%d->%d)\n", + i, loc, buf[loc], tmp[loc]); + + check(0, tmp, size, size); + } +} + +int +main(int ac, char **av) { + + check(1, buf1, sizeof(buf1), sizeof(buf1)); + try_corrupt(buf1, sizeof(buf1)); + check(1, buf1, sizeof(buf1) + 20, sizeof(buf1)); + + return 0; +} diff --git a/asn1c/tests/check-32.c b/asn1c/tests/check-32.c new file mode 100644 index 00000000..3cb0fdac --- /dev/null +++ b/asn1c/tests/check-32.c @@ -0,0 +1,21 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +int +main(int ac, char **av) { + Programming_t p; + + memset(&p, 0, sizeof(p)); + + /* + * No plans to fill it up: just checking whether it compiles or not. + */ + + return 0; +} diff --git a/asn1c/tests/check-33.c b/asn1c/tests/check-33.c new file mode 100644 index 00000000..14f5377a --- /dev/null +++ b/asn1c/tests/check-33.c @@ -0,0 +1,21 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +int +main(int ac, char **av) { + T_t t; + + memset(&t, 0, sizeof(t)); + + /* + * No plans to fill it up: just checking whether it compiles or not. + */ + + return 0; +} diff --git a/asn1c/tests/check-35.c b/asn1c/tests/check-35.c new file mode 100644 index 00000000..6b6c04d6 --- /dev/null +++ b/asn1c/tests/check-35.c @@ -0,0 +1,277 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf1[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 13, /* L */ + + /* b CHOICE { b2 ObjectDescriptor }*/ + 7, /* [UNIVERSAL 7] */ + 1, /* L */ + 'z', + + /* c BOOLEAN */ + 1, /* [UNIVERSAL 1] */ + 0, /* L */ + + /* a NumericString */ + 18, /* [UNIVERSAL 18] */ + 2, /* L */ + 'n', + 's', + + /* d.r-oid RELATIVE-OID */ + 13, /* [UNIVERSAL 13] */ + 2, /* L */ + 85, + 79, + +}; + +uint8_t buf1_reconstr[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 14, /* L */ + + /* c BOOLEAN */ + 1, /* [UNIVERSAL 1] */ + 1, /* L */ + 0, + + /* b CHOICE { b2 ObjectDescriptor }*/ + 7, /* [UNIVERSAL 7] */ + 1, /* L */ + 'z', + + /* d.r-oid RELATIVE-OID */ + 13, /* [UNIVERSAL 1] */ + 2, /* L */ + 85, + 79, + + /* a NumericString */ + 18, /* [UNIVERSAL 18] */ + 2, /* L */ + 'n', + 's' +}; + +uint8_t buf2[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 13, /* L */ + + /* a NumericString */ + 18, /* [UNIVERSAL 18] */ + 2, /* L */ + 'n', + 's', + + /* c BOOLEAN */ + 1, /* [UNIVERSAL 1] */ + 1, /* L */ + 2, /* True */ + + /* b CHOICE { b1 IA5String }*/ + 22, /* [UNIVERSAL 22] */ + 1, /* L */ + 'z', + + /* d.oid RELATIVE-OID */ + 6, /* [UNIVERSAL 6] */ + 1, /* L */ + 81, + +}; + +uint8_t buf2_reconstr[] = { + 32 | 17, /* [UNIVERSAL 17], constructed */ + 13, /* L */ + + /* c BOOLEAN */ + 1, /* [UNIVERSAL 1] */ + 1, /* L */ + 0xff, /* Canonical True */ + + /* d.oid RELATIVE-OID */ + 6, /* [UNIVERSAL 6] */ + 1, /* L */ + 81, + + /* a NumericString */ + 18, /* [UNIVERSAL 18] */ + 2, /* L */ + 'n', + 's', + + /* b CHOICE { b1 IA5String }*/ + 22, /* [UNIVERSAL 22] */ + 1, /* L */ + 'z' +}; + +static void +check(T_t *tp, uint8_t *buf, int size, int consumed) { + ber_dec_rval_t rval; + + tp = memset(tp, 0, sizeof(*tp)); + + fprintf(stderr, "Buf %p (%d)\n", buf, size); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d\n", + (int)rval.code, (int)rval.consumed); + + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + + assert(strcmp(tp->a.buf, "ns") == 0); + assert(strcmp(tp->b.choice.b1.buf, "z") == 0 + && strcmp(tp->b.choice.b2.buf, "z") == 0); +} + +int buf_pos; +int buf_size; +uint8_t *buf; + +static int +buf_fill(const void *buffer, size_t size, void *app_key) { + + if(buf_pos + size > buf_size) { + fprintf(stderr, "%d + %d > %d\n", buf_pos, (int)size, buf_size); + return -1; + } + + memcpy(buf + buf_pos, buffer, size); + buf_pos += size; + fprintf(stderr, " written %d (%d)\n", (int)size, buf_pos); + + return 0; +} + +void +compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) { + der_enc_rval_t erval; + int i; + + buf_size = cmp_buf_size + 100; + buf = alloca(buf_size); + buf_pos = 0; + + /* + * Try to re-create using DER encoding. + */ + erval = der_encode(&asn1_DEF_T, tp, buf_fill, 0); + assert(erval.encoded != -1); + if(erval.encoded != cmp_buf_size) { + printf("%d != %d\n", erval.encoded, cmp_buf_size); + } + assert(erval.encoded == cmp_buf_size); + for(i = 0; i < cmp_buf_size; i++) { + if(buf[i] != cmp_buf[i]) { + fprintf(stderr, "Recreated buffer content mismatch:\n"); + fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n", + i, + buf[i], cmp_buf[i], + buf[i], cmp_buf[i] + ); + } + assert(buf[i] == cmp_buf[i]); + } +} + +static void +partial_read(uint8_t *buf, int size) { + T_t t, *tp; + ber_dec_rval_t rval; + int i1, i2; + uint8_t *buf1 = alloca(size); + uint8_t *buf2 = alloca(size); + uint8_t *buf3 = alloca(size); + + fprintf(stderr, "\nPartial read sequence...\n"); + + /* + * Divide the space (size) into three blocks in various combinations: + * |<----->i1<----->i2<----->| + * ^ buf ^ buf+size + * Try to read block by block. + */ + for(i1 = 0; i1 < size; i1++) { + for(i2 = i1; i2 < size; i2++) { + uint8_t *chunk1 = buf; + int size1 = i1; + uint8_t *chunk2 = buf + size1; + int size2 = i2 - i1; + uint8_t *chunk3 = buf + size1 + size2; + int size3 = size - size1 - size2; + + fprintf(stderr, "\n%d:{%d, %d, %d}...\n", + size, size1, size2, size3); + + memset(buf1, 0, size); + memset(buf2, 0, size); + memset(buf3, 0, size); + memcpy(buf1, chunk1, size1); + memcpy(buf2, chunk2, size2); + memcpy(buf3, chunk3, size3); + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "=> Chunk 1 (%d):\n", size1); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf1, size1); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size1); + if(rval.consumed < size1) { + int leftover = size1 - rval.consumed; + memcpy(buf2, buf1 + rval.consumed, leftover); + memcpy(buf2 + leftover, chunk2, size2); + size2 += leftover; + } + + fprintf(stderr, "=> Chunk 2 (%d):\n", size2); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf2, size2); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size2); + if(rval.consumed < size2) { + int leftover = size2 - rval.consumed; + memcpy(buf3, buf2 + rval.consumed, leftover); + memcpy(buf3 + leftover, chunk3, size3); + size3 += leftover; + } + + fprintf(stderr, "=> Chunk 3 (%d):\n", size3); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf3, size3); + assert(rval.code == RC_OK); + assert(rval.consumed == size3); + + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + } + } +} + +int +main(int ac, char **av) { + T_t t; + + check(&t, buf1, sizeof(buf1) + 10, sizeof(buf1)); + compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + check(&t, buf2, sizeof(buf2) + 10, sizeof(buf2)); + compare(&t, buf2_reconstr, sizeof(buf2_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + /* Split the buffer in parts and check decoder restartability */ + partial_read(buf1, sizeof(buf1)); + + return 0; +} diff --git a/asn1c/tests/check-41.c b/asn1c/tests/check-41.c new file mode 100644 index 00000000..c2238cf5 --- /dev/null +++ b/asn1c/tests/check-41.c @@ -0,0 +1,315 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include + +uint8_t buf0[] = { + 32 | ((2 << 6) + 1), /* [1], constructed */ + 18, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 16, /* L */ + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', +}; + +uint8_t buf0_reconstr[] = { + 32 | ((2 << 6) + 1), /* [1], constructed */ + 18, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 16, /* L */ + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', +}; + + + +uint8_t buf1[] = { + 32 | (2 << 6), /* [0], constructed */ + 0x80 | 1, /* L */ + 134, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 0x80 | 1, /* L */ + 128, + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + + /* alpha [1] IMPLICIT INTEGER OPTIONAL */ + (2 << 6) + 1, /* [1] */ + 1, /* L */ + 75, +}; + +uint8_t buf1_reconstr[] = { + 32 | (2 << 6), /* [0], constructed */ + 0x80 | 1, /* L */ + 134, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 0x80 | 1, /* L */ + 128, + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + + /* alpha [1] IMPLICIT INTEGER OPTIONAL */ + (2 << 6) + 1, /* [1] */ + 1, /* L */ + 75, +}; + +uint8_t buf2[] = { + 32 | ((2 << 6) + 1), /* [1], constructed */ + 0x80 | 1, /* L */ + 134, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 0x80 | 1, /* L */ + 128, + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + + /* beta [2] IMPLICIT INTEGER OPTIONAL */ + (2 << 6) + 2, /* [2] */ + 1, /* L */ + 75, +}; + +uint8_t buf2_reconstr[] = { + 32 | ((2 << 6) + 1), /* [1], constructed */ + 0x80 | 1, /* L */ + 134, + + /* string [0] IMPLICIT UTF8String, */ + (2 << 6), /* [0] */ + 0x80 | 1, /* L */ + 128, + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', 'z', + + /* beta [2] IMPLICIT INTEGER OPTIONAL */ + (2 << 6) + 2, /* [2] */ + 1, /* L */ + 75, +}; + + + + + +static void +check(T_t *tp, uint8_t *buf, int size, int consumed) { + ber_dec_rval_t rval; + + tp = memset(tp, 0, sizeof(*tp)); + + fprintf(stderr, "Buf %p (%d)\n", buf, size); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, buf, size); + fprintf(stderr, "Returned code %d, consumed %d\n", + (int)rval.code, (int)rval.consumed); + + assert(rval.code == RC_OK); + assert(rval.consumed == consumed); + + /* + assert(tp->string.size == 128); + assert(strncmp(tp->string.buf, "zz") == 0); + assert(strcmp(tp->b.choice.b1.buf, "z") == 0 + && strcmp(tp->b.choice.b2.buf, "z") == 0); + */ +} + +int buf_pos; +int buf_size; +uint8_t *buf; + +static int +buf_fill(const void *buffer, size_t size, void *app_key) { + + if(buf_pos + size > buf_size) { + fprintf(stderr, "%d + %d > %d\n", buf_pos, (int)size, buf_size); + return -1; + } + + memcpy(buf + buf_pos, buffer, size); + buf_pos += size; + fprintf(stderr, " written %d (%d)\n", (int)size, buf_pos); + + return 0; +} + +void +compare(T_t *tp, uint8_t *cmp_buf, int cmp_buf_size) { + der_enc_rval_t erval; + int i; + + buf_size = cmp_buf_size + 100; + buf = alloca(buf_size); + buf_pos = 0; + + /* + * Try to re-create using DER encoding. + */ + erval = der_encode(&asn1_DEF_T, tp, buf_fill, 0); + assert(erval.encoded != -1); + if(erval.encoded != cmp_buf_size) { + printf("%d != %d\n", erval.encoded, cmp_buf_size); + } + assert(erval.encoded == cmp_buf_size); + for(i = 0; i < cmp_buf_size; i++) { + if(buf[i] != cmp_buf[i]) { + fprintf(stderr, "Recreated buffer content mismatch:\n"); + fprintf(stderr, "Byte %d, %x != %x (%d != %d)\n", + i, + buf[i], cmp_buf[i], + buf[i], cmp_buf[i] + ); + } + assert(buf[i] == cmp_buf[i]); + } +} + +static void +partial_read(uint8_t *buf, int size) { + T_t t, *tp; + ber_dec_rval_t rval; + int i1, i2; + uint8_t *buf1 = alloca(size); + uint8_t *buf2 = alloca(size); + uint8_t *buf3 = alloca(size); + + fprintf(stderr, "\nPartial read sequence...\n"); + + /* + * Divide the space (size) into three blocks in various combinations: + * |<----->i1<----->i2<----->| + * ^ buf ^ buf+size + * Try to read block by block. + */ + for(i1 = 0; i1 < size; i1++) { + for(i2 = i1; i2 < size; i2++) { + uint8_t *chunk1 = buf; + int size1 = i1; + uint8_t *chunk2 = buf + size1; + int size2 = i2 - i1; + uint8_t *chunk3 = buf + size1 + size2; + int size3 = size - size1 - size2; + + fprintf(stderr, "\n%d:{%d, %d, %d}...\n", + size, size1, size2, size3); + + memset(buf1, 0, size); + memset(buf2, 0, size); + memset(buf3, 0, size); + memcpy(buf1, chunk1, size1); + memcpy(buf2, chunk2, size2); + memcpy(buf3, chunk3, size3); + + tp = memset(&t, 0, sizeof(t)); + + fprintf(stderr, "=> Chunk 1 (%d):\n", size1); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf1, size1); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size1); + if(rval.consumed < size1) { + int leftover = size1 - rval.consumed; + memcpy(buf2, buf1 + rval.consumed, leftover); + memcpy(buf2 + leftover, chunk2, size2); + size2 += leftover; + } + + fprintf(stderr, "=> Chunk 2 (%d):\n", size2); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf2, size2); + assert(rval.code == RC_WMORE); + assert(rval.consumed <= size2); + if(rval.consumed < size2) { + int leftover = size2 - rval.consumed; + memcpy(buf3, buf2 + rval.consumed, leftover); + memcpy(buf3 + leftover, chunk3, size3); + size3 += leftover; + } + + fprintf(stderr, "=> Chunk 3 (%d):\n", size3); + rval = ber_decode(&asn1_DEF_T, (void **)&tp, + buf3, size3); + assert(rval.code == RC_OK); + assert(rval.consumed == size3); + + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + } + } +} + +int +main(int ac, char **av) { + T_t t; + + /* Check exact buf0 */ + check(&t, buf0, sizeof(buf0), sizeof(buf0)); + compare(&t, buf0_reconstr, sizeof(buf0_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + /* Check exact buf1 */ + check(&t, buf1, sizeof(buf1), sizeof(buf1)); + compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + /* Check slightly more than buf1 */ + check(&t, buf1, sizeof(buf1) + 10, sizeof(buf1)); + compare(&t, buf1_reconstr, sizeof(buf1_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + /* Check exact buf2 */ + check(&t, buf2, sizeof(buf2), sizeof(buf2)); + compare(&t, buf2_reconstr, sizeof(buf2_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + /* Check slightly more than buf2 */ + check(&t, buf2, sizeof(buf2) + 10, sizeof(buf2)); + compare(&t, buf2_reconstr, sizeof(buf2_reconstr)); + asn_fprint(stderr, &asn1_DEF_T, &t); + asn1_DEF_T.free_struct(&asn1_DEF_T, &t, 1); + + /* Split the buffer in parts and check decoder restartability */ + partial_read(buf0, sizeof(buf0)); + + return 0; +} diff --git a/asn1c/tests/check-43.c b/asn1c/tests/check-43.c new file mode 100644 index 00000000..e44218d8 --- /dev/null +++ b/asn1c/tests/check-43.c @@ -0,0 +1,24 @@ +#undef NDEBUG +#include +#include +#include +#include +#include + +#include +#include + +int +main(int ac, char **av) { + Test_structure_1_t ts1; + Sets_t s1; + + memset(&ts1, 0, sizeof(ts1)); + memset(&s1, 0, sizeof(s1)); + + /* + * No plans to fill it up: just checking whether it compiles or not. + */ + + return 0; +} diff --git a/asn1c/tests/check-assembly.sh b/asn1c/tests/check-assembly.sh new file mode 100755 index 00000000..a1756b4d --- /dev/null +++ b/asn1c/tests/check-assembly.sh @@ -0,0 +1,56 @@ +#!/bin/sh + +# +# This script is designed to quickly create lots of files in underlying +# test-* directories, do lots of other magic stuff and exit cleanly. +# + +# Compute the .asn1 spec name by the given file name. +source=$(echo "$1" | sed -e 's/.*\///') +testno=`echo "$source" | cut -f2 -d'-' | cut -f1 -d'.'` + +args=$(echo "$source" | sed -e 's/\.c$//') +testdir=test-${args} + +OFS=$IFS +IFS="." +set $args +shift +IFS=$OFS + +if [ ! -d $testdir ]; then + mkdir $testdir || exit $? +fi +cd $testdir || exit $? +ln -fs ../$source || exit $? +# Compile the corresponding .asn1 spec. +set -x +../../asn1c \ + -S ../../../skeletons \ + -Wdebug-compiler "$@" \ + ../../../tests/${testno}-*.asn1 || exit $? +set +x + +# Create a Makefile for the project. +cat > Makefile <. +# Please send patches to . +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit build system type. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + + +dummy=dummy-$$ +trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int dummy(){}" > $dummy.c ; + for c in cc gcc c89 ; do + ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ; + if test $? = 0 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + rm -f $dummy.c $dummy.o $dummy.rel ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # Netbsd (nbsd) targets should (where applicable) match one or + # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # Determine the machine/vendor (is the vendor relevant). + case "${UNAME_MACHINE}" in + amiga) machine=m68k-unknown ;; + arm32) machine=arm-unknown ;; + atari*) machine=m68k-atari ;; + sun3*) machine=m68k-sun ;; + mac68k) machine=m68k-apple ;; + macppc) machine=powerpc-apple ;; + hp3[0-9][05]) machine=m68k-hp ;; + ibmrt|romp-ibm) machine=romp-ibm ;; + *) machine=${UNAME_MACHINE}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE}" in + i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep __ELF__ >/dev/null + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # The OS release + release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}" + exit 0 ;; + alpha:OSF1:*:*) + if test $UNAME_RELEASE = "V4.0"; then + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + fi + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + cat <$dummy.s + .data +\$Lformat: + .byte 37,100,45,37,120,10,0 # "%d-%x\n" + + .text + .globl main + .align 4 + .ent main +main: + .frame \$30,16,\$26,0 + ldgp \$29,0(\$27) + .prologue 1 + .long 0x47e03d80 # implver \$0 + lda \$2,-1 + .long 0x47e20c21 # amask \$2,\$1 + lda \$16,\$Lformat + mov \$0,\$17 + not \$1,\$18 + jsr \$26,printf + ldgp \$29,0(\$26) + mov 0,\$16 + jsr \$26,exit + .end main +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null + if test "$?" = 0 ; then + case `./$dummy` in + 0-0) + UNAME_MACHINE="alpha" + ;; + 1-0) + UNAME_MACHINE="alphaev5" + ;; + 1-1) + UNAME_MACHINE="alphaev56" + ;; + 1-101) + UNAME_MACHINE="alphapca56" + ;; + 2-303) + UNAME_MACHINE="alphaev6" + ;; + 2-307) + UNAME_MACHINE="alphaev67" + ;; + 2-1307) + UNAME_MACHINE="alphaev68" + ;; + esac + fi + rm -f $dummy.s $dummy + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + exit 0 ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit 0 ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit 0 ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit 0;; + amiga:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit 0 ;; + arc64:OpenBSD:*:*) + echo mips64el-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + arc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + hkmips:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + pmax:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + sgi:OpenBSD:*:*) + echo mips-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + wgrisc:OpenBSD:*:*) + echo mipsel-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit 0;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit 0 ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + i86pc:SunOS:5.*:*) + echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit 0 ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit 0 ;; + sparc*:NetBSD:*) + echo `uname -p`-unknown-netbsd${UNAME_RELEASE} + exit 0 ;; + atari*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit 0 ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit 0 ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit 0 ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit 0 ;; + sun3*:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mac68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme68k:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + mvme88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit 0 ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit 0 ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.c -o $dummy \ + && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ + && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit 0 ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit 0 ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:[45]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit 0 ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit 0 ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + case "${HPUX_REV}" in + 11.[0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + esac ;; + esac + fi ;; + esac + if [ "${HP_ARCH}" = "" ]; then + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + eval $set_cc_for_build + (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy` + if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi + rm -f $dummy.c $dummy + fi ;; + esac + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit 0 ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit 0 ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit 0 ;; + hppa*:OpenBSD:*:*) + echo hppa-unknown-openbsd + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:*:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3D:*:*:*) + echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit 0 ;; + CRAY-2:*:*:*) + echo cray2-cray-unicos + exit 0 ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit 0 ;; + hp300:OpenBSD:*:*) + echo m68k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit 0 ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:OpenBSD:*:*) + echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit 0 ;; + i*:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit 0 ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit 0 ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i386-pc-interix + exit 0 ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit 0 ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit 0 ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit 0 ;; + arm*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux + exit 0 ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + mips:Linux:*:*) + case `sed -n '/^byte/s/^.*: \(.*\) endian/\1/p' < /proc/cpuinfo` in + big) echo mips-unknown-linux-gnu && exit 0 ;; + little) echo mipsel-unknown-linux-gnu && exit 0 ;; + esac + ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu + exit 0 ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit 0 ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit 0 ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-gnu ;; + PA8*) echo hppa2.0-unknown-linux-gnu ;; + *) echo hppa-unknown-linux-gnu ;; + esac + exit 0 ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu + exit 0 ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux + exit 0 ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; + x86_64:Linux:*:*) + echo x86_64-unknown-linux-gnu + exit 0 ;; + i*86:Linux:*:*) + # The BFD linker knows what the default object file format is, so + # first see if it will tell us. cd to the root directory to prevent + # problems with other programs or directories called `ld' in the path. + ld_supported_targets=`cd /; ld --help 2>&1 \ + | sed -ne '/supported targets:/!d + s/[ ][ ]*/ /g + s/.*supported targets: *// + s/ .*// + p'` + case "$ld_supported_targets" in + elf32-i386) + TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" + ;; + a.out-i386-linux) + echo "${UNAME_MACHINE}-pc-linux-gnuaout" + exit 0 ;; + coff-i386) + echo "${UNAME_MACHINE}-pc-linux-gnucoff" + exit 0 ;; + "") + # Either a pre-BFD a.out linker (linux-gnuoldld) or + # one that does not give us useful --help. + echo "${UNAME_MACHINE}-pc-linux-gnuoldld" + exit 0 ;; + esac + # Determine whether the default compiler is a.out or elf + cat >$dummy.c < +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif +#ifdef __ELF__ +# ifdef __GLIBC__ +# if __GLIBC__ >= 2 + printf ("%s-pc-linux-gnu\n", argv[1]); +# else + printf ("%s-pc-linux-gnulibc1\n", argv[1]); +# endif +# else + printf ("%s-pc-linux-gnulibc1\n", argv[1]); +# endif +#else + printf ("%s-pc-linux-gnuaout\n", argv[1]); +#endif + return 0; +} +EOF + eval $set_cc_for_build + $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0 + rm -f $dummy.c $dummy + test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 + ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit 0 ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit 0 ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit 0 ;; + i*86:*:5:[78]*) + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit 0 ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit 0 ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit 0 ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i386. + echo i386-pc-msdosdjgpp + exit 0 ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit 0 ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M68*:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3${OS_REL} && exit 0 + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit 0 ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit 0 ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit 0 ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit 0 ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit 0 ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit 0 ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit 0 ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit 0 ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit 0 ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit 0 ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit 0 ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit 0 ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit 0 ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit 0 ;; + *:Darwin:*:*) + echo `uname -p`-apple-darwin${UNAME_RELEASE} + exit 0 ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + if test "${UNAME_MACHINE}" = "x86pc"; then + UNAME_MACHINE=pc + fi + echo `uname -p`-${UNAME_MACHINE}-nto-qnx + exit 0 ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit 0 ;; + NSR-[KW]:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit 0 ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit 0 ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit 0 ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit 0 ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit 0 ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit 0 ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit 0 ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit 0 ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit 0 ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit 0 ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit 0 ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit 0 ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +cat >$dummy.c < +# include +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); + +#endif + +#if defined (vax) +# if !defined (ultrix) +# include +# if defined (BSD) +# if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +# else +# if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# endif +# else + printf ("vax-dec-bsd\n"); exit (0); +# endif +# else + printf ("vax-dec-ultrix\n"); exit (0); +# endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +eval $set_cc_for_build +$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0 +rm -f $dummy.c $dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/config.h.in b/config.h.in new file mode 100644 index 00000000..1910711f --- /dev/null +++ b/config.h.in @@ -0,0 +1,81 @@ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_ERRNO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strtoimax' function. */ +#undef HAVE_STRTOIMAX + +/* Define to 1 if you have the `strtoll' function. */ +#undef HAVE_STRTOLL + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if your declares `struct tm'. */ +#undef TM_IN_SYS_TIME + +/* Version number of package */ +#undef VERSION + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#undef WORDS_BIGENDIAN + +/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a + `char[]'. */ +#undef YYTEXT_POINTER + +/* Define to `int64_t' if does not define. */ +#undef intmax_t + +/* Define to `long' if does not define. */ +#undef off_t + +/* Define to `unsigned' if does not define. */ +#undef size_t diff --git a/config.sub b/config.sub new file mode 100755 index 00000000..12ebc787 --- /dev/null +++ b/config.sub @@ -0,0 +1,1410 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. + +timestamp='2001-08-13' + +# This file is (in principle) common to ALL GNU software. +# The presence of a machine in this file suggests that SOME GNU software +# can handle that machine. It does not imply ALL GNU software can. +# +# This file 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 of the License, 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., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit 0 ;; + --version | -v ) + echo "$version" ; exit 0 ;; + --help | --h* | -h ) + echo "$usage"; exit 0 ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit 0;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis) + os= + basic_machine=$1 + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ + | c4x | clipper \ + | d10v | d30v | dsp16xx \ + | fr30 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | i370 | i860 | i960 | ia64 \ + | m32r | m68000 | m68k | m88k | mcore \ + | mips16 | mips64 | mips64el | mips64orion | mips64orionel \ + | mips64vr4100 | mips64vr4100el | mips64vr4300 \ + | mips64vr4300el | mips64vr5000 | mips64vr5000el \ + | mipsbe | mipsel | mipsle | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | ns16k | ns32k \ + | openrisc \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ + | pyramid \ + | s390 | s390x \ + | sh | sh[34] | sh[34]eb | shbe | shle \ + | sparc | sparc64 | sparclet | sparclite | sparcv9 | sparcv9b \ + | strongarm \ + | tahoe | thumb | tic80 | tron \ + | v850 \ + | we32k \ + | x86 | xscale \ + | z8k) + basic_machine=$basic_machine-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12) + # Motorola 68HC11/12. + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alphapca5[67]-* | arc-* \ + | arm-* | armbe-* | armle-* | armv*-* \ + | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c54x-* \ + | clipper-* | cray2-* | cydra-* \ + | d10v-* | d30v-* \ + | elxsi-* \ + | f30[01]-* | f700-* | fr30-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | m32r-* \ + | m68000-* | m680[01234]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | mcore-* \ + | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \ + | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipsel-* \ + | mipsle-* | mipstx39-* | mipstx39el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ + | pyramid-* \ + | romp-* | rs6000-* \ + | s390-* | s390x-* \ + | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* \ + | sparc-* | sparc64-* | sparc86x-* | sparclite-* \ + | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* \ + | t3e-* | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \ + | v850-* | vax-* \ + | we32k-* \ + | x86-* | x86_64-* | xmp-* | xps100-* | xscale-* \ + | ymp-* \ + | z8k-*) + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | ymp) + basic_machine=ymp-cray + os=-unicos + ;; + cray2) + basic_machine=cray2-cray + os=-unicos + ;; + [cjt]90) + basic_machine=${basic_machine}-cray + os=-unicos + ;; + crds | unos) + basic_machine=m68k-crds + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; +# I'm not sure what "Sysv32" means. Should this be sysv3.2? + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + mingw32) + basic_machine=i386-pc + os=-mingw32 + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mipsel*-linux*) + basic_machine=mipsel-unknown + os=-linux-gnu + ;; + mips*-linux*) + basic_machine=mips-unknown + os=-linux-gnu + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + mmix*) + basic_machine=mmix-knuth + os=-mmixware + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pentium | p5 | k5 | k6 | nexgen) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon) + basic_machine=i686-pc + ;; + pentiumii | pentium2) + basic_machine=i686-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc) basic_machine=powerpc-unknown + ;; + ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sparclite-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=t3e-cray + os=-unicos + ;; + tic54x | c54x*) + basic_machine=tic54x-unknown + os=-coff + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + windows32) + basic_machine=i386-pc + os=-windows32-msvcrt + ;; + xmp) + basic_machine=xmp-cray + os=-unicos + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + mips) + if [ x$os = x-linux-gnu ]; then + basic_machine=mips-unknown + else + basic_machine=mips-mips + fi + ;; + romp) + basic_machine=romp-ibm + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh3 | sh4 | sh3eb | sh4eb) + basic_machine=sh-unknown + ;; + sparc | sparcv9 | sparcv9b) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + c4x*) + basic_machine=c4x-none + os=-coff + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ + | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* \ + | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ + | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto*) + os=-nto-qnx + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + # This also exists in the configure program, but was not the + # default. + # os=-sunos4 + ;; + m68*-cisco) + os=-aout + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-ibm) + os=-aix + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -vxsim* | -vxworks*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/configure b/configure new file mode 100755 index 00000000..b7be2110 --- /dev/null +++ b/configure @@ -0,0 +1,6937 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.57. +# +# Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +# Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2 + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +exec 6>&1 + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_config_libobj_dir=. +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Maximum number of lines to put in a shell here document. +# This variable seems obsolete. It should probably be removed, and +# only ac_max_sed_lines should be used. +: ${ac_max_here_lines=38} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +ac_unique_file="libasn1parser/asn1p_y.y" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#if HAVE_SYS_TYPES_H +# include +#endif +#if HAVE_SYS_STAT_H +# include +#endif +#if STDC_HEADERS +# include +# include +#else +# if HAVE_STDLIB_H +# include +# endif +#endif +#if HAVE_STRING_H +# if !STDC_HEADERS && HAVE_MEMORY_H +# include +# endif +# include +#endif +#if HAVE_STRINGS_H +# include +#endif +#if HAVE_INTTYPES_H +# include +#else +# if HAVE_STDINT_H +# include +# endif +#endif +#if HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PACKAGE VERSION EXEEXT OBJEXT ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO AMTAR install_sh INSTALL_STRIP_PROGRAM AWK SET_MAKE AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH DEPDIR PATH MAINTAINER_MODE_TRUE MAINTAINER_MODE_FALSE MAINT RANLIB ac_ct_RANLIB CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC am__include am__quote CCDEPMODE LN_S LIBTOOL CONFIGURE_DEPENDS CPP YACC LEX LEXLIB LEX_OUTPUT_ROOT AR ADD_CFLAGS EGREP LIBOBJS LTLIBOBJS' +ac_subst_files='' + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +ac_prev= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + ac_optarg=`expr "x$ac_option" : 'x[^=]*=\(.*\)'` + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_option in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + eval "enable_$ac_feature=no" ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "enable_$ac_feature='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package| sed 's/-/_/g'` + case $ac_option in + *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;; + *) ac_optarg=yes ;; + esac + eval "with_$ac_package='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/-/_/g'` + eval "with_$ac_package=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` + eval "$ac_envvar='$ac_optarg'" + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute paths. +for ac_var in exec_prefix prefix +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* | NONE | '' ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# Be sure to have absolute paths. +for ac_var in bindir sbindir libexecdir datadir sysconfdir sharedstatedir \ + localstatedir libdir includedir oldincludedir infodir mandir +do + eval ac_val=$`echo $ac_var` + case $ac_val in + [\\/$]* | ?:[\\/]* ) ;; + *) { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; };; + esac +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_confdir=`(dirname "$0") 2>/dev/null || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2 + { (exit 1); exit 1; }; } + else + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } + fi +fi +(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null || + { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2 + { (exit 1); exit 1; }; } +srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'` +ac_env_build_alias_set=${build_alias+set} +ac_env_build_alias_value=$build_alias +ac_cv_env_build_alias_set=${build_alias+set} +ac_cv_env_build_alias_value=$build_alias +ac_env_host_alias_set=${host_alias+set} +ac_env_host_alias_value=$host_alias +ac_cv_env_host_alias_set=${host_alias+set} +ac_cv_env_host_alias_value=$host_alias +ac_env_target_alias_set=${target_alias+set} +ac_env_target_alias_value=$target_alias +ac_cv_env_target_alias_set=${target_alias+set} +ac_cv_env_target_alias_value=$target_alias +ac_env_CC_set=${CC+set} +ac_env_CC_value=$CC +ac_cv_env_CC_set=${CC+set} +ac_cv_env_CC_value=$CC +ac_env_CFLAGS_set=${CFLAGS+set} +ac_env_CFLAGS_value=$CFLAGS +ac_cv_env_CFLAGS_set=${CFLAGS+set} +ac_cv_env_CFLAGS_value=$CFLAGS +ac_env_LDFLAGS_set=${LDFLAGS+set} +ac_env_LDFLAGS_value=$LDFLAGS +ac_cv_env_LDFLAGS_set=${LDFLAGS+set} +ac_cv_env_LDFLAGS_value=$LDFLAGS +ac_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_env_CPPFLAGS_value=$CPPFLAGS +ac_cv_env_CPPFLAGS_set=${CPPFLAGS+set} +ac_cv_env_CPPFLAGS_value=$CPPFLAGS +ac_env_CPP_set=${CPP+set} +ac_env_CPP_value=$CPP +ac_cv_env_CPP_set=${CPP+set} +ac_cv_env_CPP_value=$CPP + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +_ACEOF + + cat <<_ACEOF +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data [PREFIX/share] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --infodir=DIR info documentation [PREFIX/info] + --mandir=DIR man documentation [PREFIX/man] +_ACEOF + + cat <<\_ACEOF + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + --target=TARGET configure for building compilers for TARGET [HOST] +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Optional Features: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-dependency-tracking Speeds up one-time builds + --enable-dependency-tracking Do not reject slow dependency extractors + --enable-maintainer-mode enable make rules and dependencies not useful + (and sometimes confusing) to the casual installer + --enable-shared=PKGS build shared libraries default=yes + --enable-static=PKGS build static libraries default=yes + --enable-fast-install=PKGS optimize for fast installation default=yes + --disable-libtool-lock avoid locking (might break parallel builds) + --disable-autoconf disable automatic generation of configure script + --enable-Werror abort compilation after any C compiler warning + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-gnu-ld assume the C compiler uses GNU ld default=no + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + CPPFLAGS C/C++ preprocessor flags, e.g. -I if you have + headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + ac_popdir=`pwd` + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d $ac_dir || continue + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + cd $ac_dir + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_srcdir/configure.gnu; then + echo + $SHELL $ac_srcdir/configure.gnu --help=recursive + elif test -f $ac_srcdir/configure; then + echo + $SHELL $ac_srcdir/configure --help=recursive + elif test -f $ac_srcdir/configure.ac || + test -f $ac_srcdir/configure.in; then + echo + $ac_configure --help + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi + cd $ac_popdir + done +fi + +test -n "$ac_init_help" && exit 0 +if $ac_init_version; then + cat <<\_ACEOF + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002 +Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit 0 +fi +exec 5>config.log +cat >&5 <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.57. Invocation command line was + + $ $0 $@ + +_ACEOF +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +hostinfo = `(hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_sep= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args$ac_sep'$ac_arg'" + # Get rid of the leading space. + ac_sep=" " + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Be sure not to use single quotes in there, as some shells, +# such as our DU 5.0 friend, will then `close' the trap. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +{ + (set) 2>&1 | + case `(ac_space='"'"' '"'"'; set | grep ac_space) 2>&1` in + *ac_space=\ *) + sed -n \ + "s/'"'"'/'"'"'\\\\'"'"''"'"'/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='"'"'\\2'"'"'/p" + ;; + *) + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------- ## +## Output files. ## +## ------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=$`echo $ac_var` + echo "$ac_var='"'"'$ac_val'"'"'" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + sed "/^$/d" confdefs.h | sort + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core core.* *.core && + rm -rf conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status + ' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo >confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in `(set) 2>&1 | + sed -n 's/^ac_env_\([a-zA-Z_0-9]*\)_set=.*/\1/p'`; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val="\$ac_cv_env_${ac_var}_value" + eval ac_new_val="\$ac_env_${ac_var}_value" + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?\"\']*) + ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + + + + + + + + + + + + + + + + + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f $ac_dir/shtool; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&5 +echo "$as_me: error: cannot find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." >&2;} + { (exit 1); exit 1; }; } +fi +ac_config_guess="$SHELL $ac_aux_dir/config.guess" +ac_config_sub="$SHELL $ac_aux_dir/config.sub" +ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. + +# Make sure we can run config.sub. +$ac_config_sub sun4 >/dev/null 2>&1 || + { { echo "$as_me:$LINENO: error: cannot run $ac_config_sub" >&5 +echo "$as_me: error: cannot run $ac_config_sub" >&2;} + { (exit 1); exit 1; }; } + +echo "$as_me:$LINENO: checking build system type" >&5 +echo $ECHO_N "checking build system type... $ECHO_C" >&6 +if test "${ac_cv_build+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_build_alias=$build_alias +test -z "$ac_cv_build_alias" && + ac_cv_build_alias=`$ac_config_guess` +test -z "$ac_cv_build_alias" && + { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 +echo "$as_me: error: cannot guess build type; you must specify one" >&2;} + { (exit 1); exit 1; }; } +ac_cv_build=`$ac_config_sub $ac_cv_build_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_build_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_build_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_build" >&5 +echo "${ECHO_T}$ac_cv_build" >&6 +build=$ac_cv_build +build_cpu=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $ac_cv_build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking host system type" >&5 +echo $ECHO_N "checking host system type... $ECHO_C" >&6 +if test "${ac_cv_host+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_host_alias=$host_alias +test -z "$ac_cv_host_alias" && + ac_cv_host_alias=$ac_cv_build_alias +ac_cv_host=`$ac_config_sub $ac_cv_host_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_host_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_host_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_host" >&5 +echo "${ECHO_T}$ac_cv_host" >&6 +host=$ac_cv_host +host_cpu=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $ac_cv_host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +echo "$as_me:$LINENO: checking target system type" >&5 +echo $ECHO_N "checking target system type... $ECHO_C" >&6 +if test "${ac_cv_target+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_target_alias=$target_alias +test "x$ac_cv_target_alias" = "x" && + ac_cv_target_alias=$ac_cv_host_alias +ac_cv_target=`$ac_config_sub $ac_cv_target_alias` || + { { echo "$as_me:$LINENO: error: $ac_config_sub $ac_cv_target_alias failed" >&5 +echo "$as_me: error: $ac_config_sub $ac_cv_target_alias failed" >&2;} + { (exit 1); exit 1; }; } + +fi +echo "$as_me:$LINENO: result: $ac_cv_target" >&5 +echo "${ECHO_T}$ac_cv_target" >&6 +target=$ac_cv_target +target_cpu=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $ac_cv_target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` + + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +test -n "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6 +# Just in case +sleep 1 +echo timestamp > conftest.file +# Do `set' in a subshell so we don't clobber the current shell's +# arguments. Must try -L first in case configure is actually a +# symlink; some systems play weird games with the mod time of symlinks +# (eg FreeBSD returns the mod time of the symlink's containing +# directory). +if ( + set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` + if test "$*" = "X"; then + # -L didn't work. + set X `ls -t $srcdir/configure conftest.file` + fi + rm -f conftest.file + if test "$*" != "X $srcdir/configure conftest.file" \ + && test "$*" != "X conftest.file $srcdir/configure"; then + + # If neither matched, then we have a broken ls. This can happen + # if, for instance, CONFIG_SHELL is bash and it inherits a + # broken ls alias from the environment. This has actually + # happened. Such a system could not be considered "sane". + { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&5 +echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken +alias in your environment" >&2;} + { (exit 1); exit 1; }; } + fi + + test "$2" = conftest.file + ) +then + # Ok. + : +else + { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! +Check your system clock" >&5 +echo "$as_me: error: newly created file is older than distributed files! +Check your system clock" >&2;} + { (exit 1); exit 1; }; } +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +test "$program_prefix" != NONE && + program_transform_name="s,^,$program_prefix,;$program_transform_name" +# Use a double $ so make ignores it. +test "$program_suffix" != NONE && + program_transform_name="s,\$,$program_suffix,;$program_transform_name" +# Double any \ or $. echo might interpret backslashes. +# By default was `s,x,x', remove it if useless. +cat <<\_ACEOF >conftest.sed +s/[\\$]/&&/g;s/;s,x,x,$// +_ACEOF +program_transform_name=`echo $program_transform_name | sed -f conftest.sed` +rm conftest.sed + + +# expand $ac_aux_dir to an absolute path +am_aux_dir=`CDPATH=:; cd $ac_aux_dir && pwd` + +test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" +# Use eval to expand $SHELL +if eval "$MISSING --run true"; then + am_missing_run="$MISSING --run " +else + am_missing_run= + am_backtick='`' + { echo "$as_me:$LINENO: WARNING: ${am_backtick}missing' script is too old or missing" >&5 +echo "$as_me: WARNING: ${am_backtick}missing' script is too old or missing" >&2;} +fi + +for ac_prog in gawk mawk nawk awk +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_AWK+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$AWK"; then + ac_cv_prog_AWK="$AWK" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_AWK="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +AWK=$ac_cv_prog_AWK +if test -n "$AWK"; then + echo "$as_me:$LINENO: result: $AWK" >&5 +echo "${ECHO_T}$AWK" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$AWK" && break +done + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +# Check whether --enable-dependency-tracking or --disable-dependency-tracking was given. +if test "${enable_dependency_tracking+set}" = set; then + enableval="$enable_dependency_tracking" + +fi; +if test "x$enable_dependency_tracking" != xno; then + am_depcomp="$ac_aux_dir/depcomp" + AMDEPBACKSLASH='\' +fi + + +if test "x$enable_dependency_tracking" != xno; then + AMDEP_TRUE= + AMDEP_FALSE='#' +else + AMDEP_TRUE='#' + AMDEP_FALSE= +fi + + + + +rm -f .deps 2>/dev/null +mkdir .deps 2>/dev/null +if test -d .deps; then + DEPDIR=.deps +else + # MS-DOS does not allow filenames that begin with a dot. + DEPDIR=_deps +fi +rmdir .deps 2>/dev/null + + +# test to see if srcdir already configured +if test "`CDPATH=:; cd $srcdir && pwd`" != "`pwd`" && + test -f $srcdir/config.status; then + { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 +echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} + { (exit 1); exit 1; }; } +fi + +# Define the identity of the package. +PACKAGE=asn1c +VERSION=0.8.10 + +cat >>confdefs.h <<_ACEOF +#define PACKAGE "$PACKAGE" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define VERSION "$VERSION" +_ACEOF + + +# Autoconf 2.50 wants to disallow AM_ names. We explicitly allow +# the ones we care about. + +# Autoconf 2.50 always computes EXEEXT. However we need to be +# compatible with 2.13, for now. So we always define EXEEXT, but we +# don't compute it. + +# Similar for OBJEXT -- only we only use OBJEXT if the user actually +# requests that it be used. This is a bit dumb. +: ${OBJEXT=o} + + +# Some tools Automake needs. + +ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal"} + + +AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} + + +AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake"} + + +AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} + + +MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} + + +AMTAR=${AMTAR-"${am_missing_run}tar"} + +install_sh=${install_sh-"$am_aux_dir/install-sh"} + +INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" + +# We need awk for the "check" target. The system "awk" is bad on +# some platforms. + + + + +echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5 +echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6 + # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. +if test "${enable_maintainer_mode+set}" = set; then + enableval="$enable_maintainer_mode" + USE_MAINTAINER_MODE=$enableval +else + USE_MAINTAINER_MODE=no +fi; + echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5 +echo "${ECHO_T}$USE_MAINTAINER_MODE" >&6 + + +if test $USE_MAINTAINER_MODE = yes; then + MAINTAINER_MODE_TRUE= + MAINTAINER_MODE_FALSE='#' +else + MAINTAINER_MODE_TRUE='#' + MAINTAINER_MODE_FALSE= +fi + MAINT=$MAINTAINER_MODE_TRUE + + + +# Check whether --enable-shared or --disable-shared was given. +if test "${enable_shared+set}" = set; then + enableval="$enable_shared" + p=${PACKAGE-default} +case "$enableval" in +yes) enable_shared=yes ;; +no) enable_shared=no ;; +*) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_shared=yes +fi; +# Check whether --enable-static or --disable-static was given. +if test "${enable_static+set}" = set; then + enableval="$enable_static" + p=${PACKAGE-default} +case "$enableval" in +yes) enable_static=yes ;; +no) enable_static=no ;; +*) + enable_static=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_static=yes +fi; +# Check whether --enable-fast-install or --disable-fast-install was given. +if test "${enable_fast_install+set}" = set; then + enableval="$enable_fast_install" + p=${PACKAGE-default} +case "$enableval" in +yes) enable_fast_install=yes ;; +no) enable_fast_install=no ;; +*) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:," + for pkg in $enableval; do + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS="$ac_save_ifs" + ;; +esac +else + enable_fast_install=yes +fi; +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +RANLIB=$ac_cv_prog_RANLIB +if test -n "$RANLIB"; then + echo "$as_me:$LINENO: result: $RANLIB" >&5 +echo "${ECHO_T}$RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_RANLIB"; then + ac_ct_RANLIB=$RANLIB + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_RANLIB"; then + ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_RANLIB="ranlib" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_prog_ac_ct_RANLIB" && ac_cv_prog_ac_ct_RANLIB=":" +fi +fi +ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB +if test -n "$ac_ct_RANLIB"; then + echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 +echo "${ECHO_T}$ac_ct_RANLIB" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + RANLIB=$ac_ct_RANLIB +else + RANLIB="$ac_cv_prog_RANLIB" +fi + + + ac_config_commands="$ac_config_commands default-1" + +am_make=${MAKE-make} +cat > confinc << 'END' +doit: + @echo done +END +# If we don't find an include directive, just comment out the code. +echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6 +am__include='#' +am__quote= +_am_result=none +# First try GNU make style include. +echo "include confinc" > confmf +# We grep out `Entering directory' and `Leaving directory' +# messages which can occur if `w' ends up in MAKEFLAGS. +# In particular we don't look at `^make:' because GNU make might +# be invoked under some other name (usually "gmake"), in which +# case it prints its new name instead of `make'. +if test "`$am_make -s -f confmf 2> /dev/null | fgrep -v 'ing directory'`" = "done"; then + am__include=include + am__quote= + _am_result=GNU +fi +# Now try BSD make style include. +if test "$am__include" = "#"; then + echo '.include "confinc"' > confmf + if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then + am__include=.include + am__quote='"' + _am_result=BSD + fi +fi + + +echo "$as_me:$LINENO: result: $_am_result" >&5 +echo "${ECHO_T}$_am_result" >&6 +rm -f confinc confmf + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +echo "$as_me:$LINENO: checking for C compiler default output" >&5 +echo $ECHO_N "checking for C compiler default output... $ECHO_C" >&6 +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +if { (eval echo "$as_me:$LINENO: \"$ac_link_default\"") >&5 + (eval $ac_link_default) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Find the output, starting from the most likely. This scheme is +# not robust to junk in `.', hence go to wildcards (a.*) only as a last +# resort. + +# Be careful to initialize this variable, since it used to be cached. +# Otherwise an old cache value of `no' led to `EXEEXT = no' in a Makefile. +ac_cv_exeext= +# b.out is created by i960 compilers. +for ac_file in a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) + ;; + conftest.$ac_ext ) + # This is the source file. + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + # FIXME: I believe we export ac_cv_exeext for Libtool, + # but it would be cool to find out if it's true. Does anybody + # maintain Libtool? --akim. + export ac_cv_exeext + break;; + * ) + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6 + +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6 +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6 +echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6 + +echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6 +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + export ac_cv_exeext + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6 + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6 +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in `(ls conftest.o conftest.obj; ls conftest.*) 2>/dev/null`; do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6 +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + ''\ + '#include ' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + echo '#include "conftest.h"' > conftest.c + echo 'int i;' > conftest.h + echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=conftest.c object=conftest.o \ + depfile=conftest.Po tmpdepfile=conftest.TPo \ + $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && + grep conftest.h conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 +CCDEPMODE="depmode=$am_cv_CC_dependencies_compiler_type" + + + +# Check whether --with-gnu-ld or --without-gnu-ld was given. +if test "${with_gnu_ld+set}" = set; then + withval="$with_gnu_ld" + test "$withval" = no || with_gnu_ld=yes +else + with_gnu_ld=no +fi; +ac_prog=ld +if test "$ac_cv_c_compiler_gnu" = yes; then + # Check if gcc -print-prog-name=ld gives a path. + echo "$as_me:$LINENO: checking for ld used by GCC" >&5 +echo $ECHO_N "checking for ld used by GCC... $ECHO_C" >&6 + ac_prog=`($CC -print-prog-name=ld) 2>&5` + case "$ac_prog" in + # Accept absolute paths. + [\\/]* | [A-Za-z]:[\\/]*) + re_direlt='/[^/][^/]*/\.\./' + # Canonicalize the path of ld + ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'` + while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do + ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"` + done + test -z "$LD" && LD="$ac_prog" + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test "$with_gnu_ld" = yes; then + echo "$as_me:$LINENO: checking for GNU ld" >&5 +echo $ECHO_N "checking for GNU ld... $ECHO_C" >&6 +else + echo "$as_me:$LINENO: checking for non-GNU ld" >&5 +echo $ECHO_N "checking for non-GNU ld... $ECHO_C" >&6 +fi +if test "${ac_cv_path_LD+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$LD"; then + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH; do + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + ac_cv_path_LD="$ac_dir/$ac_prog" + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some GNU ld's only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then + test "$with_gnu_ld" != no && break + else + test "$with_gnu_ld" != yes && break + fi + fi + done + IFS="$ac_save_ifs" +else + ac_cv_path_LD="$LD" # Let the user override the test with a path. +fi +fi + +LD="$ac_cv_path_LD" +if test -n "$LD"; then + echo "$as_me:$LINENO: result: $LD" >&5 +echo "${ECHO_T}$LD" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi +test -z "$LD" && { { echo "$as_me:$LINENO: error: no acceptable ld found in \$PATH" >&5 +echo "$as_me: error: no acceptable ld found in \$PATH" >&2;} + { (exit 1); exit 1; }; } +echo "$as_me:$LINENO: checking if the linker ($LD) is GNU ld" >&5 +echo $ECHO_N "checking if the linker ($LD) is GNU ld... $ECHO_C" >&6 +if test "${ac_cv_prog_gnu_ld+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # I'd rather use --version here, but apparently some GNU ld's only accept -v. +if $LD -v 2>&1 &5; then + ac_cv_prog_gnu_ld=yes +else + ac_cv_prog_gnu_ld=no +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_gnu_ld" >&5 +echo "${ECHO_T}$ac_cv_prog_gnu_ld" >&6 + + +echo "$as_me:$LINENO: checking for BSD-compatible nm" >&5 +echo $ECHO_N "checking for BSD-compatible nm... $ECHO_C" >&6 +if test "${ac_cv_path_NM+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$NM"; then + # Let the user override the test. + ac_cv_path_NM="$NM" +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}" + for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the `sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -B" + break + elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then + ac_cv_path_NM="$ac_dir/nm -p" + break + else + ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + fi + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm +fi +fi + +NM="$ac_cv_path_NM" +echo "$as_me:$LINENO: result: $NM" >&5 +echo "${ECHO_T}$NM" >&6 + +echo "$as_me:$LINENO: checking whether ln -s works" >&5 +echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:$LINENO: result: no, using $LN_S" >&5 +echo "${ECHO_T}no, using $LN_S" >&6 +fi + + + +case "$target" in +NONE) lt_target="$host" ;; +*) lt_target="$target" ;; +esac + +# Check for any special flags to pass to ltconfig. +libtool_flags="--cache-file=$cache_file" +test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared" +test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static" +test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install" +test "$ac_cv_c_compiler_gnu" = yes && libtool_flags="$libtool_flags --with-gcc" +test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld" + + +# Check whether --enable-libtool-lock or --disable-libtool-lock was given. +if test "${enable_libtool_lock+set}" = set; then + enableval="$enable_libtool_lock" + +fi; +test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock" +test x"$silent" = xyes && libtool_flags="$libtool_flags --silent" + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case "$lt_target" in +*-*-irix6*) + # Find out which ABI we are using. + echo '#line 3024 "configure"' > conftest.$ac_ext + if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + case "`/usr/bin/file conftest.o`" in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -belf" + echo "$as_me:$LINENO: checking whether the C compiler needs -belf" >&5 +echo $ECHO_N "checking whether the C compiler needs -belf... $ECHO_C" >&6 +if test "${lt_cv_cc_needs_belf+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + lt_cv_cc_needs_belf=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +lt_cv_cc_needs_belf=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $lt_cv_cc_needs_belf" >&5 +echo "${ECHO_T}$lt_cv_cc_needs_belf" >&6 + if test x"$lt_cv_cc_needs_belf" != x"yes"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS="$SAVE_CFLAGS" + fi + ;; + + +esac + + +# Save cache, so that ltconfig can load it +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +# Actually configure libtool. ac_aux_dir is where install-sh is found. +CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \ +LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \ +LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \ +DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \ +${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \ +$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \ +|| { { echo "$as_me:$LINENO: error: libtool configure failed" >&5 +echo "$as_me: error: libtool configure failed" >&2;} + { (exit 1); exit 1; }; } + +# Reload cache, that may have been modified by ltconfig +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . $cache_file;; + *) . ./$cache_file;; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh" + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' + +# Redirect the config.log output again, so that the ltconfig log is not +# clobbered by the next message. +exec 5>>./config.log + + +# Check whether --enable-autoconf or --disable-autoconf was given. +if test "${enable_autoconf+set}" = set; then + enableval="$enable_autoconf" + enable_autoconf=$enableval +else + enable_autoconf=yes + +fi; +# Extract the first word of "autoconf", so it can be a program name with args. +set dummy autoconf; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_AUTOCONF+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $AUTOCONF in + [\\/]* | ?:[\\/]*) + ac_cv_path_AUTOCONF="$AUTOCONF" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_AUTOCONF="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_path_AUTOCONF" && ac_cv_path_AUTOCONF="@echo autoconf not available" + ;; +esac +fi +AUTOCONF=$ac_cv_path_AUTOCONF + +if test -n "$AUTOCONF"; then + echo "$as_me:$LINENO: result: $AUTOCONF" >&5 +echo "${ECHO_T}$AUTOCONF" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +# Extract the first word of "autoheader", so it can be a program name with args. +set dummy autoheader; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_AUTOHEADER+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $AUTOHEADER in + [\\/]* | ?:[\\/]*) + ac_cv_path_AUTOHEADER="$AUTOHEADER" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_AUTOHEADER="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_path_AUTOHEADER" && ac_cv_path_AUTOHEADER="@echo autoheader not available" + ;; +esac +fi +AUTOHEADER=$ac_cv_path_AUTOHEADER + +if test -n "$AUTOHEADER"; then + echo "$as_me:$LINENO: result: $AUTOHEADER" >&5 +echo "${ECHO_T}$AUTOHEADER" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +if test -z "$AUTOCONF"; then enable_autoconf=no ; fi +if test -z "$AUTOHEADER"; then enable_autoconf=no ; fi +if test x$enable_autoconf = xyes; then + CONFIGURE_DEPENDS="configure.in aclocal.m4" +fi + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + CC=$ac_ct_CC +else + CC="$ac_cv_prog_CC" +fi + +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$ac_ct_CC" && break +done + + CC=$ac_ct_CC +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO:" \ + "checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 + (eval $ac_compiler --version &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v &5\"") >&5 + (eval $ac_compiler -v &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V &5\"") >&5 + (eval $ac_compiler -V &5) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6 +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_compiler_gnu=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6 +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +CFLAGS="-g" +echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_prog_cc_g=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6 +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5 +echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6 +if test "${ac_cv_prog_cc_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_stdc=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_cc_stdc=$ac_arg +break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC + +fi + +case "x$ac_cv_prog_cc_stdc" in + x|xno) + echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6 ;; + *) + echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6 + CC="$CC $ac_cv_prog_cc_stdc" ;; +esac + +# Some people use a C++ compiler to compile C. Since we use `exit', +# in C++ we need to declare it. In case someone uses the same compiler +# for both compiling C and C++ we need to have the C++ compiler decide +# the declaration of exit, since it's the most demanding environment. +cat >conftest.$ac_ext <<_ACEOF +#ifndef __cplusplus + choke me +#endif +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + for ac_declaration in \ + ''\ + '#include ' \ + 'extern "C" void std::exit (int) throw (); using std::exit;' \ + 'extern "C" void std::exit (int); using std::exit;' \ + 'extern "C" void exit (int) throw ();' \ + 'extern "C" void exit (int);' \ + 'void exit (int);' +do + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +continue +fi +rm -f conftest.$ac_objext conftest.$ac_ext + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_declaration +int +main () +{ +exit (42); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +done +rm -f conftest* +if test -n "$ac_declaration"; then + echo '#ifdef __cplusplus' >>confdefs.h + echo $ac_declaration >>confdefs.h + echo '#endif' >>confdefs.h +fi + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +depcc="$CC" am_compiler_list= + +echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6 +if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then + # We make a subdir and do the tests there. Otherwise we can end up + # making bogus files that we don't know about and never remove. For + # instance it was reported that on HP-UX the gcc test will end up + # making a dummy file named `D' -- because `-MD' means `put the output + # in D'. + mkdir conftest.dir + # Copy depcomp to subdir because otherwise we won't find it if we're + # using a relative directory. + cp "$am_depcomp" conftest.dir + cd conftest.dir + + am_cv_CC_dependencies_compiler_type=none + if test "$am_compiler_list" = ""; then + am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` + fi + for depmode in $am_compiler_list; do + # We need to recreate these files for each test, as the compiler may + # overwrite some of them when testing with obscure command lines. + # This happens at least with the AIX C compiler. + echo '#include "conftest.h"' > conftest.c + echo 'int i;' > conftest.h + echo "${am__include} ${am__quote}conftest.Po${am__quote}" > confmf + + case $depmode in + nosideeffect) + # after this tag, mechanisms are not by side-effect, so they'll + # only be used when explicitly requested + if test "x$enable_dependency_tracking" = xyes; then + continue + else + break + fi + ;; + none) break ;; + esac + # We check with `-c' and `-o' for the sake of the "dashmstdout" + # mode. It turns out that the SunPro C++ compiler does not properly + # handle `-M -o', and we need to detect this. + if depmode=$depmode \ + source=conftest.c object=conftest.o \ + depfile=conftest.Po tmpdepfile=conftest.TPo \ + $SHELL ./depcomp $depcc -c conftest.c -o conftest.o >/dev/null 2>&1 && + grep conftest.h conftest.Po > /dev/null 2>&1 && + ${MAKE-make} -s -f confmf > /dev/null 2>&1; then + am_cv_CC_dependencies_compiler_type=$depmode + break + fi + done + + cd .. + rm -rf conftest.dir +else + am_cv_CC_dependencies_compiler_type=none +fi + +fi +echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6 +CCDEPMODE="depmode=$am_cv_CC_dependencies_compiler_type" + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6 +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether non-existent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6 +if test -z "$INSTALL"; then +if test "${ac_cv_path_install+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in + ./ | .// | /cC/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + done + done + ;; +esac +done + + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL=$ac_install_sh + fi +fi +echo "$as_me:$LINENO: result: $INSTALL" >&5 +echo "${ECHO_T}$INSTALL" >&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +echo "$as_me:$LINENO: checking whether ln -s works" >&5 +echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6 +LN_S=$as_ln_s +if test "$LN_S" = "ln -s"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 +else + echo "$as_me:$LINENO: result: no, using $LN_S" >&5 +echo "${ECHO_T}no, using $LN_S" >&6 +fi + +echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6 +set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y,./+-,__p_,'` +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.make <<\_ACEOF +all: + @echo 'ac_maketemp="$(MAKE)"' +_ACEOF +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftest.make 2>/dev/null | grep temp=` +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftest.make +fi +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6 + SET_MAKE= +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 + SET_MAKE="MAKE=${MAKE-make}" +fi + +for ac_prog in 'bison -y' byacc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_YACC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$YACC"; then + ac_cv_prog_YACC="$YACC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_YACC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +YACC=$ac_cv_prog_YACC +if test -n "$YACC"; then + echo "$as_me:$LINENO: result: $YACC" >&5 +echo "${ECHO_T}$YACC" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$YACC" && break +done +test -n "$YACC" || YACC="yacc" + + +for ac_prog in flex lex +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_LEX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$LEX"; then + ac_cv_prog_LEX="$LEX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_LEX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +LEX=$ac_cv_prog_LEX +if test -n "$LEX"; then + echo "$as_me:$LINENO: result: $LEX" >&5 +echo "${ECHO_T}$LEX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$LEX" && break +done +test -n "$LEX" || LEX="${am_missing_run}flex" + +for ac_prog in flex lex +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_prog_LEX+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$LEX"; then + ac_cv_prog_LEX="$LEX" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_LEX="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + +fi +fi +LEX=$ac_cv_prog_LEX +if test -n "$LEX"; then + echo "$as_me:$LINENO: result: $LEX" >&5 +echo "${ECHO_T}$LEX" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + test -n "$LEX" && break +done +test -n "$LEX" || LEX=":" + +if test -z "$LEXLIB" +then + echo "$as_me:$LINENO: checking for yywrap in -lfl" >&5 +echo $ECHO_N "checking for yywrap in -lfl... $ECHO_C" >&6 +if test "${ac_cv_lib_fl_yywrap+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lfl $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char yywrap (); +int +main () +{ +yywrap (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_fl_yywrap=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_fl_yywrap=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_fl_yywrap" >&5 +echo "${ECHO_T}$ac_cv_lib_fl_yywrap" >&6 +if test $ac_cv_lib_fl_yywrap = yes; then + LEXLIB="-lfl" +else + echo "$as_me:$LINENO: checking for yywrap in -ll" >&5 +echo $ECHO_N "checking for yywrap in -ll... $ECHO_C" >&6 +if test "${ac_cv_lib_l_yywrap+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-ll $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char yywrap (); +int +main () +{ +yywrap (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_l_yywrap=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_l_yywrap=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_l_yywrap" >&5 +echo "${ECHO_T}$ac_cv_lib_l_yywrap" >&6 +if test $ac_cv_lib_l_yywrap = yes; then + LEXLIB="-ll" +fi + +fi + +fi + +if test "x$LEX" != "x:"; then + echo "$as_me:$LINENO: checking lex output file root" >&5 +echo $ECHO_N "checking lex output file root... $ECHO_C" >&6 +if test "${ac_cv_prog_lex_root+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # The minimal lex program is just a single line: %%. But some broken lexes +# (Solaris, I think it was) want two %% lines, so accommodate them. +cat >conftest.l <<_ACEOF +%% +%% +_ACEOF +{ (eval echo "$as_me:$LINENO: \"$LEX conftest.l\"") >&5 + (eval $LEX conftest.l) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +if test -f lex.yy.c; then + ac_cv_prog_lex_root=lex.yy +elif test -f lexyy.c; then + ac_cv_prog_lex_root=lexyy +else + { { echo "$as_me:$LINENO: error: cannot find output from $LEX; giving up" >&5 +echo "$as_me: error: cannot find output from $LEX; giving up" >&2;} + { (exit 1); exit 1; }; } +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_lex_root" >&5 +echo "${ECHO_T}$ac_cv_prog_lex_root" >&6 +rm -f conftest.l +LEX_OUTPUT_ROOT=$ac_cv_prog_lex_root + +echo "$as_me:$LINENO: checking whether yytext is a pointer" >&5 +echo $ECHO_N "checking whether yytext is a pointer... $ECHO_C" >&6 +if test "${ac_cv_prog_lex_yytext_pointer+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # POSIX says lex can declare yytext either as a pointer or an array; the +# default is implementation-dependent. Figure out which it is, since +# not all implementations provide the %pointer and %array declarations. +ac_cv_prog_lex_yytext_pointer=no +echo 'extern char *yytext;' >>$LEX_OUTPUT_ROOT.c +ac_save_LIBS=$LIBS +LIBS="$LIBS $LEXLIB" +cat >conftest.$ac_ext <<_ACEOF +`cat $LEX_OUTPUT_ROOT.c` +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_prog_lex_yytext_pointer=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_save_LIBS +rm -f "${LEX_OUTPUT_ROOT}.c" + +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_lex_yytext_pointer" >&5 +echo "${ECHO_T}$ac_cv_prog_lex_yytext_pointer" >&6 +if test $ac_cv_prog_lex_yytext_pointer = yes; then + +cat >>confdefs.h <<\_ACEOF +#define YYTEXT_POINTER 1 +_ACEOF + +fi + +fi +# Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6 +if test "${ac_cv_path_AR+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + case $AR in + [\\/]* | ?:[\\/]*) + ac_cv_path_AR="$AR" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_dummy="$PATH:/usr/ucb:/usr/ccs/bin" +for as_dir in $as_dummy +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_AR="$as_dir/$ac_word$ac_exec_ext" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done + + test -z "$ac_cv_path_AR" && ac_cv_path_AR="ar" + ;; +esac +fi +AR=$ac_cv_path_AR + +if test -n "$AR"; then + echo "$as_me:$LINENO: result: $AR" >&5 +echo "${ECHO_T}$AR" >&6 +else + echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6 +fi + + +case "$build" in +*cygwin*) + case "$target" in + *mingw*) + CC="$CC -mno-cygwin" + esac ;; +esac + +# Check whether --enable-autoconf or --disable-autoconf was given. +if test "${enable_autoconf+set}" = set; then + enableval="$enable_autoconf" + ADD_CFLAGS="-Werror" +fi; + + +case "$GCC" in + yes) + CFLAGS="$CFLAGS -Wall" + CFLAGS="$CFLAGS -Wshadow" + CFLAGS="$CFLAGS -Wcast-qual" + CFLAGS="$CFLAGS -Wcast-align" + CFLAGS="$CFLAGS -Wmissing-prototypes" + CFLAGS="$CFLAGS -Wmissing-declarations" + CFLAGS="$CFLAGS -Wredundant-decls" + CFLAGS="$CFLAGS -Wnested-externs" + ;; +esac + + + +echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6 +if test "${ac_cv_prog_egrep+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | (grep -E '(a|b)') >/dev/null 2>&1 + then ac_cv_prog_egrep='grep -E' + else ac_cv_prog_egrep='egrep' + fi +fi +echo "$as_me:$LINENO: result: $ac_cv_prog_egrep" >&5 +echo "${ECHO_T}$ac_cv_prog_egrep" >&6 + EGREP=$ac_cv_prog_egrep + + +echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_header_stdc=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + exit(2); + exit (0); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +fi +echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6 +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_Header=no" +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + +for ac_header in errno.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6 +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # See if sys/param.h defines the BYTE_ORDER macro. +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN + bogus endian macros +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + # It does; now see whether it defined to BIG_ENDIAN or not. +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_c_bigendian=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +# It does not; compile a test program. +if test "$cross_compiling" = yes; then + # try to guess the endianness by grepping values into an object file + ac_cv_c_bigendian=unknown + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +short ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } +int +main () +{ + _ascii (); _ebcdic (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + ac_cv_c_bigendian=yes +fi +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi +fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +fi +rm -f conftest.$ac_objext conftest.$ac_ext +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +int +main () +{ + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long l; + char c[sizeof (long)]; + } u; + u.l = 1; + exit (u.c[sizeof (long) - 1] == 1); +} +_ACEOF +rm -f conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=no +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_c_bigendian=yes +fi +rm -f core core.* *.core gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6 +case $ac_cv_c_bigendian in + yes) + +cat >>confdefs.h <<\_ACEOF +#define WORDS_BIGENDIAN 1 +_ACEOF + ;; + no) + ;; + *) + { { echo "$as_me:$LINENO: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&5 +echo "$as_me: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} + { (exit 1); exit 1; }; } ;; +esac + +echo "$as_me:$LINENO: checking for off_t" >&5 +echo $ECHO_N "checking for off_t... $ECHO_C" >&6 +if test "${ac_cv_type_off_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((off_t *) 0) + return 0; +if (sizeof (off_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_off_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_off_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_off_t" >&5 +echo "${ECHO_T}$ac_cv_type_off_t" >&6 +if test $ac_cv_type_off_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define off_t long +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for size_t" >&5 +echo $ECHO_N "checking for size_t... $ECHO_C" >&6 +if test "${ac_cv_type_size_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((size_t *) 0) + return 0; +if (sizeof (size_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_size_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_size_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_size_t" >&5 +echo "${ECHO_T}$ac_cv_type_size_t" >&6 +if test $ac_cv_type_size_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned +_ACEOF + +fi + +echo "$as_me:$LINENO: checking whether struct tm is in sys/time.h or time.h" >&5 +echo $ECHO_N "checking whether struct tm is in sys/time.h or time.h... $ECHO_C" >&6 +if test "${ac_cv_struct_tm+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +struct tm *tp; tp->tm_sec; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_struct_tm=time.h +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_struct_tm=sys/time.h +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_struct_tm" >&5 +echo "${ECHO_T}$ac_cv_struct_tm" >&6 +if test $ac_cv_struct_tm = sys/time.h; then + +cat >>confdefs.h <<\_ACEOF +#define TM_IN_SYS_TIME 1 +_ACEOF + +fi + +echo "$as_me:$LINENO: checking for intmax_t" >&5 +echo $ECHO_N "checking for intmax_t... $ECHO_C" >&6 +if test "${ac_cv_type_intmax_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((intmax_t *) 0) + return 0; +if (sizeof (intmax_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_intmax_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_intmax_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_intmax_t" >&5 +echo "${ECHO_T}$ac_cv_type_intmax_t" >&6 +if test $ac_cv_type_intmax_t = yes; then + : +else + +cat >>confdefs.h <<_ACEOF +#define intmax_t int64_t +_ACEOF + +fi + + + + +for ac_func in strtoimax strtoll +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ +#ifdef __STDC__ +# include +#else +# include +#endif +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + + + + + ac_config_headers="$ac_config_headers config.h" + + + ac_config_files="$ac_config_files libasn1compiler/Makefile skeletons/tests/Makefile libasn1parser/Makefile libasn1print/Makefile asn1c/tests/Makefile libasn1fix/Makefile skeletons/Makefile examples/Makefile tests/Makefile asn1c/Makefile doc/Makefile Makefile" +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +{ + (set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n \ + "s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1=\\2/p" + ;; + esac; +} | + sed ' + t clear + : clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + /^ac_cv_env/!s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + : end' >>confcache +if diff $cache_file confcache >/dev/null 2>&1; then :; else + if test -w $cache_file; then + test "x$cache_file" != "x/dev/null" && echo "updating cache $cache_file" + cat confcache >$cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# VPATH may cause trouble with some makes, so we remove $(srcdir), +# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=/{ +s/:*\$(srcdir):*/:/; +s/:*\${srcdir}:*/:/; +s/:*@srcdir@:*/:/; +s/^\([^=]*=[ ]*\):*/\1/; +s/:*$//; +s/^[^=]*=[ ]*$//; +}' +fi + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_i=`echo "$ac_i" | + sed 's/\$U\././;s/\.o$//;s/\.obj$//'` + # 2. Add them. + ac_libobjs="$ac_libobjs $ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs $ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be Bourne compatible +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' +elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then + set -o posix +fi + +# Support unset when possible. +if (FOO=FOO; unset FOO) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# Work around bugs in pre-3.0 UWIN ksh. +$as_unset ENV MAIL MAILPATH +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -n "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +if (basename /) >/dev/null 2>&1 && test "X`basename / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)$' \| \ + . : '\(.\)' 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/; q; } + /^X\/\(\/\/\)$/{ s//\1/; q; } + /^X\/\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + + +# PATH needs CR, and LINENO needs CR and PATH. +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" || { + # Find who we are. Look in the path if we contain no path at all + # relative or not. + case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done + + ;; + esac + # We did not find ourselves, most probably we were run as `sh COMMAND' + # in which case we are not to be found in the path. + if test "x$as_myself" = x; then + as_myself=$0 + fi + if test ! -f "$as_myself"; then + { { echo "$as_me:$LINENO: error: cannot find myself; rerun with an absolute path" >&5 +echo "$as_me: error: cannot find myself; rerun with an absolute path" >&2;} + { (exit 1); exit 1; }; } + fi + case $CONFIG_SHELL in + '') + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for as_base in sh bash ksh sh5; do + case $as_dir in + /*) + if ("$as_dir/$as_base" -c ' + as_lineno_1=$LINENO + as_lineno_2=$LINENO + as_lineno_3=`(expr $as_lineno_1 + 1) 2>/dev/null` + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x$as_lineno_3" = "x$as_lineno_2" ') 2>/dev/null; then + $as_unset BASH_ENV || test "${BASH_ENV+set}" != set || { BASH_ENV=; export BASH_ENV; } + $as_unset ENV || test "${ENV+set}" != set || { ENV=; export ENV; } + CONFIG_SHELL=$as_dir/$as_base + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$0" ${1+"$@"} + fi;; + esac + done +done +;; + esac + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line before each line; the second 'sed' does the real + # work. The second script uses 'N' to pair each line-number line + # with the numbered line, and appends trailing '-' during + # substitution so that $LINENO is not a special case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # second 'sed' script. Blame Lee E. McMahon for sed's syntax. :-) + sed '=' <$as_myself | + sed ' + N + s,$,-, + : loop + s,^\(['$as_cr_digits']*\)\(.*\)[$]LINENO\([^'$as_cr_alnum'_]\),\1\2\1\3, + t loop + s,-$,, + s,^['$as_cr_digits']*\n,, + ' >$as_me.lineno && + chmod +x $as_me.lineno || + { { echo "$as_me:$LINENO: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&5 +echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2;} + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensible to this). + . ./$as_me.lineno + # Exit status is that of the last command. + exit +} + + +case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in + *c*,-n*) ECHO_N= ECHO_C=' +' ECHO_T=' ' ;; + *c*,* ) ECHO_N=-n ECHO_C= ECHO_T= ;; + *) ECHO_N= ECHO_C='\c' ECHO_T= ;; +esac + +if expr a : '\(a\)' >/dev/null 2>&1; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + # We could just check for DJGPP; but this test a) works b) is more generic + # and c) will remain valid once DJGPP supports symlinks (DJGPP 2.04). + if test -f conf$$.exe; then + # Don't use ln at all; we don't have any links + as_ln_s='cp -p' + else + as_ln_s='ln -s' + fi +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.file + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + as_mkdir_p=false +fi + +as_executable_p="test -f" + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="sed y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="sed y%*+%pp%;s%[^_$as_cr_alnum]%_%g" + + +# IFS +# We need space, tab and new line, in precisely that order. +as_nl=' +' +IFS=" $as_nl" + +# CDPATH. +$as_unset CDPATH + +exec 6>&1 + +# Open the log real soon, to keep \$[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. Logging --version etc. is OK. +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX +} >&5 +cat >&5 <<_CSEOF + +This file was extended by $as_me, which was +generated by GNU Autoconf 2.57. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +_CSEOF +echo "on `(hostname || uname -n) 2>/dev/null | sed 1q`" >&5 +echo >&5 +_ACEOF + +# Files that config.status was made for. +if test -n "$ac_config_files"; then + echo "config_files=\"$ac_config_files\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_headers"; then + echo "config_headers=\"$ac_config_headers\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_links"; then + echo "config_links=\"$ac_config_links\"" >>$CONFIG_STATUS +fi + +if test -n "$ac_config_commands"; then + echo "config_commands=\"$ac_config_commands\"" >>$CONFIG_STATUS +fi + +cat >>$CONFIG_STATUS <<\_ACEOF + +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Configuration commands: +$config_commands + +Report bugs to ." +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.57, + with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" + +Copyright 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001 +Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." +srcdir=$srcdir +INSTALL="$INSTALL" +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "x$1" : 'x\([^=]*\)='` + ac_optarg=`expr "x$1" : 'x[^=]*=\(.*\)'` + ac_shift=: + ;; + -*) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + *) # This is not an option, so the user has probably given explicit + # arguments. + ac_option=$1 + ac_need_defaults=false;; + esac + + case $ac_option in + # Handling of the options. +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --vers* | -V ) + echo "$ac_cs_version"; exit 0 ;; + --he | --h) + # Conflict between --help and --header + { { echo "$as_me:$LINENO: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + CONFIG_FILES="$CONFIG_FILES $ac_optarg" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { { echo "$as_me:$LINENO: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&5 +echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2;} + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running $SHELL $0 " $ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + exec $SHELL $0 $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# +# INIT-COMMANDS section. +# + +AMDEP_TRUE="$AMDEP_TRUE" +ac_aux_dir="$ac_aux_dir" + +_ACEOF + + + +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_config_target in $ac_config_targets +do + case "$ac_config_target" in + # Handling of arguments. + "libasn1compiler/Makefile" ) CONFIG_FILES="$CONFIG_FILES libasn1compiler/Makefile" ;; + "skeletons/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES skeletons/tests/Makefile" ;; + "libasn1parser/Makefile" ) CONFIG_FILES="$CONFIG_FILES libasn1parser/Makefile" ;; + "libasn1print/Makefile" ) CONFIG_FILES="$CONFIG_FILES libasn1print/Makefile" ;; + "asn1c/tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES asn1c/tests/Makefile" ;; + "libasn1fix/Makefile" ) CONFIG_FILES="$CONFIG_FILES libasn1fix/Makefile" ;; + "skeletons/Makefile" ) CONFIG_FILES="$CONFIG_FILES skeletons/Makefile" ;; + "examples/Makefile" ) CONFIG_FILES="$CONFIG_FILES examples/Makefile" ;; + "tests/Makefile" ) CONFIG_FILES="$CONFIG_FILES tests/Makefile" ;; + "asn1c/Makefile" ) CONFIG_FILES="$CONFIG_FILES asn1c/Makefile" ;; + "doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; + "Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "default-1" ) CONFIG_COMMANDS="$CONFIG_COMMANDS default-1" ;; + "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers + test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason to put it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Create a temporary directory, and hook for its removal unless debugging. +$debug || +{ + trap 'exit_status=$?; rm -rf $tmp && exit $exit_status' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} + +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d -q "./confstatXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./confstat$$-$RANDOM + (umask 077 && mkdir $tmp) +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF + +# +# CONFIG_FILES section. +# + +# No need to generate the scripts if there are no CONFIG_FILES. +# This happens for instance when ./config.status config.h +if test -n "\$CONFIG_FILES"; then + # Protect against being on the right side of a sed subst in config.status. + sed 's/,@/@@/; s/@,/@@/; s/,;t t\$/@;t t/; /@;t t\$/s/[\\\\&,]/\\\\&/g; + s/@@/,@/; s/@@/@,/; s/@;t t\$/,;t t/' >\$tmp/subs.sed <<\\CEOF +s,@SHELL@,$SHELL,;t t +s,@PATH_SEPARATOR@,$PATH_SEPARATOR,;t t +s,@PACKAGE_NAME@,$PACKAGE_NAME,;t t +s,@PACKAGE_TARNAME@,$PACKAGE_TARNAME,;t t +s,@PACKAGE_VERSION@,$PACKAGE_VERSION,;t t +s,@PACKAGE_STRING@,$PACKAGE_STRING,;t t +s,@PACKAGE_BUGREPORT@,$PACKAGE_BUGREPORT,;t t +s,@exec_prefix@,$exec_prefix,;t t +s,@prefix@,$prefix,;t t +s,@program_transform_name@,$program_transform_name,;t t +s,@bindir@,$bindir,;t t +s,@sbindir@,$sbindir,;t t +s,@libexecdir@,$libexecdir,;t t +s,@datadir@,$datadir,;t t +s,@sysconfdir@,$sysconfdir,;t t +s,@sharedstatedir@,$sharedstatedir,;t t +s,@localstatedir@,$localstatedir,;t t +s,@libdir@,$libdir,;t t +s,@includedir@,$includedir,;t t +s,@oldincludedir@,$oldincludedir,;t t +s,@infodir@,$infodir,;t t +s,@mandir@,$mandir,;t t +s,@build_alias@,$build_alias,;t t +s,@host_alias@,$host_alias,;t t +s,@target_alias@,$target_alias,;t t +s,@DEFS@,$DEFS,;t t +s,@ECHO_C@,$ECHO_C,;t t +s,@ECHO_N@,$ECHO_N,;t t +s,@ECHO_T@,$ECHO_T,;t t +s,@LIBS@,$LIBS,;t t +s,@build@,$build,;t t +s,@build_cpu@,$build_cpu,;t t +s,@build_vendor@,$build_vendor,;t t +s,@build_os@,$build_os,;t t +s,@host@,$host,;t t +s,@host_cpu@,$host_cpu,;t t +s,@host_vendor@,$host_vendor,;t t +s,@host_os@,$host_os,;t t +s,@target@,$target,;t t +s,@target_cpu@,$target_cpu,;t t +s,@target_vendor@,$target_vendor,;t t +s,@target_os@,$target_os,;t t +s,@INSTALL_PROGRAM@,$INSTALL_PROGRAM,;t t +s,@INSTALL_SCRIPT@,$INSTALL_SCRIPT,;t t +s,@INSTALL_DATA@,$INSTALL_DATA,;t t +s,@PACKAGE@,$PACKAGE,;t t +s,@VERSION@,$VERSION,;t t +s,@EXEEXT@,$EXEEXT,;t t +s,@OBJEXT@,$OBJEXT,;t t +s,@ACLOCAL@,$ACLOCAL,;t t +s,@AUTOCONF@,$AUTOCONF,;t t +s,@AUTOMAKE@,$AUTOMAKE,;t t +s,@AUTOHEADER@,$AUTOHEADER,;t t +s,@MAKEINFO@,$MAKEINFO,;t t +s,@AMTAR@,$AMTAR,;t t +s,@install_sh@,$install_sh,;t t +s,@INSTALL_STRIP_PROGRAM@,$INSTALL_STRIP_PROGRAM,;t t +s,@AWK@,$AWK,;t t +s,@SET_MAKE@,$SET_MAKE,;t t +s,@AMDEP_TRUE@,$AMDEP_TRUE,;t t +s,@AMDEP_FALSE@,$AMDEP_FALSE,;t t +s,@AMDEPBACKSLASH@,$AMDEPBACKSLASH,;t t +s,@DEPDIR@,$DEPDIR,;t t +s,@PATH@,$PATH,;t t +s,@MAINTAINER_MODE_TRUE@,$MAINTAINER_MODE_TRUE,;t t +s,@MAINTAINER_MODE_FALSE@,$MAINTAINER_MODE_FALSE,;t t +s,@MAINT@,$MAINT,;t t +s,@RANLIB@,$RANLIB,;t t +s,@ac_ct_RANLIB@,$ac_ct_RANLIB,;t t +s,@CC@,$CC,;t t +s,@CFLAGS@,$CFLAGS,;t t +s,@LDFLAGS@,$LDFLAGS,;t t +s,@CPPFLAGS@,$CPPFLAGS,;t t +s,@ac_ct_CC@,$ac_ct_CC,;t t +s,@am__include@,$am__include,;t t +s,@am__quote@,$am__quote,;t t +s,@CCDEPMODE@,$CCDEPMODE,;t t +s,@LN_S@,$LN_S,;t t +s,@LIBTOOL@,$LIBTOOL,;t t +s,@CONFIGURE_DEPENDS@,$CONFIGURE_DEPENDS,;t t +s,@CPP@,$CPP,;t t +s,@YACC@,$YACC,;t t +s,@LEX@,$LEX,;t t +s,@LEXLIB@,$LEXLIB,;t t +s,@LEX_OUTPUT_ROOT@,$LEX_OUTPUT_ROOT,;t t +s,@AR@,$AR,;t t +s,@ADD_CFLAGS@,$ADD_CFLAGS,;t t +s,@EGREP@,$EGREP,;t t +s,@LIBOBJS@,$LIBOBJS,;t t +s,@LTLIBOBJS@,$LTLIBOBJS,;t t +CEOF + +_ACEOF + + cat >>$CONFIG_STATUS <<\_ACEOF + # Split the substitutions into bite-sized pieces for seds with + # small command number limits, like on Digital OSF/1 and HP-UX. + ac_max_sed_lines=48 + ac_sed_frag=1 # Number of current file. + ac_beg=1 # First line for current file. + ac_end=$ac_max_sed_lines # Line after last line for current file. + ac_more_lines=: + ac_sed_cmds= + while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + else + sed "${ac_end}q" $tmp/subs.sed >$tmp/subs.frag + fi + if test ! -s $tmp/subs.frag; then + ac_more_lines=false + else + # The purpose of the label and of the branching condition is to + # speed up the sed processing (if there are no `@' at all, there + # is no need to browse any of the substitutions). + # These are the two extra sed commands mentioned above. + (echo ':t + /@[a-zA-Z_][a-zA-Z_0-9]*@/!b' && cat $tmp/subs.frag) >$tmp/subs-$ac_sed_frag.sed + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f $tmp/subs-$ac_sed_frag.sed" + else + ac_sed_cmds="$ac_sed_cmds | sed -f $tmp/subs-$ac_sed_frag.sed" + fi + ac_sed_frag=`expr $ac_sed_frag + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_lines` + fi + done + if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat + fi +fi # test -n "$CONFIG_FILES" + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +for ac_file in : $CONFIG_FILES; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + # Compute @srcdir@, @top_srcdir@, and @INSTALL@ for subdirectories. + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_builddir$INSTALL ;; + esac + + if test x"$ac_file" != x-; then + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + rm -f "$ac_file" + fi + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + configure_input= + else + configure_input="$ac_file. " + fi + configure_input=$configure_input"Generated from `echo $ac_file_in | + sed 's,.*/,,'` by configure." + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF + sed "$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s,@configure_input@,$configure_input,;t t +s,@srcdir@,$ac_srcdir,;t t +s,@abs_srcdir@,$ac_abs_srcdir,;t t +s,@top_srcdir@,$ac_top_srcdir,;t t +s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t +s,@builddir@,$ac_builddir,;t t +s,@abs_builddir@,$ac_abs_builddir,;t t +s,@top_builddir@,$ac_top_builddir,;t t +s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s,@INSTALL@,$ac_INSTALL,;t t +" $ac_file_inputs | (eval "$ac_sed_cmds") >$tmp/out + rm -f $tmp/stdin + if test x"$ac_file" != x-; then + mv $tmp/out $ac_file + else + cat $tmp/out + rm -f $tmp/out + fi + +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_HEADER section. +# + +# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where +# NAME is the cpp macro being defined and VALUE is the value it is being given. +# +# ac_d sets the value in "#define NAME VALUE" lines. +ac_dA='s,^\([ ]*\)#\([ ]*define[ ][ ]*\)' +ac_dB='[ ].*$,\1#\2' +ac_dC=' ' +ac_dD=',;t' +# ac_u turns "#undef NAME" without trailing blanks into "#define NAME VALUE". +ac_uA='s,^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' +ac_uB='$,\1#\2define\3' +ac_uC=' ' +ac_uD=',;t' + +for ac_file in : $CONFIG_HEADERS; do test "x$ac_file" = x: && continue + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case $ac_file in + - | *:- | *:-:* ) # input from stdin + cat >$tmp/stdin + ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + *:* ) ac_file_in=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_file=`echo "$ac_file" | sed 's,:.*,,'` ;; + * ) ac_file_in=$ac_file.in ;; + esac + + test x"$ac_file" != x- && { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + + # First look for the input files in the build tree, otherwise in the + # src tree. + ac_file_inputs=`IFS=: + for f in $ac_file_in; do + case $f in + -) echo $tmp/stdin ;; + [\\/$]*) + # Absolute (can't be DOS-style, as IFS=:) + test -f "$f" || { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + echo $f;; + *) # Relative + if test -f "$f"; then + # Build tree + echo $f + elif test -f "$srcdir/$f"; then + # Source tree + echo $srcdir/$f + else + # /dev/null tree + { { echo "$as_me:$LINENO: error: cannot find input file: $f" >&5 +echo "$as_me: error: cannot find input file: $f" >&2;} + { (exit 1); exit 1; }; } + fi;; + esac + done` || { (exit 1); exit 1; } + # Remove the trailing spaces. + sed 's/[ ]*$//' $ac_file_inputs >$tmp/in + +_ACEOF + +# Transform confdefs.h into two sed scripts, `conftest.defines' and +# `conftest.undefs', that substitutes the proper values into +# config.h.in to produce config.h. The first handles `#define' +# templates, and the second `#undef' templates. +# And first: Protect against being on the right side of a sed subst in +# config.status. Protect against being in an unquoted here document +# in config.status. +rm -f conftest.defines conftest.undefs +# Using a here document instead of a string reduces the quoting nightmare. +# Putting comments in sed scripts is not portable. +# +# `end' is used to avoid that the second main sed command (meant for +# 0-ary CPP macros) applies to n-ary macro definitions. +# See the Autoconf documentation for `clear'. +cat >confdef2sed.sed <<\_ACEOF +s/[\\&,]/\\&/g +s,[\\$`],\\&,g +t clear +: clear +s,^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*\)\(([^)]*)\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1\2${ac_dC}\3${ac_dD},gp +t end +s,^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)$,${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD},gp +: end +_ACEOF +# If some macros were called several times there might be several times +# the same #defines, which is useless. Nevertheless, we may not want to +# sort them, since we want the *last* AC-DEFINE to be honored. +uniq confdefs.h | sed -n -f confdef2sed.sed >conftest.defines +sed 's/ac_d/ac_u/g' conftest.defines >conftest.undefs +rm -f confdef2sed.sed + +# This sed command replaces #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +cat >>conftest.undefs <<\_ACEOF +s,^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*,/* & */, +_ACEOF + +# Break up conftest.defines because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #define templates only if necessary.' >>$CONFIG_STATUS +echo ' if grep "^[ ]*#[ ]*define" $tmp/in >/dev/null; then' >>$CONFIG_STATUS +echo ' # If there are no defines, we may have an empty if/fi' >>$CONFIG_STATUS +echo ' :' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.defines >/dev/null +do + # Write a limited-size here document to $tmp/defines.sed. + echo ' cat >$tmp/defines.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#define' lines. + echo '/^[ ]*#[ ]*define/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/defines.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.defines >conftest.tail + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines +echo ' fi # grep' >>$CONFIG_STATUS +echo >>$CONFIG_STATUS + +# Break up conftest.undefs because some shells have a limit on the size +# of here documents, and old seds have small limits too (100 cmds). +echo ' # Handle all the #undef templates' >>$CONFIG_STATUS +rm -f conftest.tail +while grep . conftest.undefs >/dev/null +do + # Write a limited-size here document to $tmp/undefs.sed. + echo ' cat >$tmp/undefs.sed <>$CONFIG_STATUS + # Speed up: don't consider the non `#undef' + echo '/^[ ]*#[ ]*undef/!b' >>$CONFIG_STATUS + # Work around the forget-to-reset-the-flag bug. + echo 't clr' >>$CONFIG_STATUS + echo ': clr' >>$CONFIG_STATUS + sed ${ac_max_here_lines}q conftest.undefs >>$CONFIG_STATUS + echo 'CEOF + sed -f $tmp/undefs.sed $tmp/in >$tmp/out + rm -f $tmp/in + mv $tmp/out $tmp/in +' >>$CONFIG_STATUS + sed 1,${ac_max_here_lines}d conftest.undefs >conftest.tail + rm -f conftest.undefs + mv conftest.tail conftest.undefs +done +rm -f conftest.undefs + +cat >>$CONFIG_STATUS <<\_ACEOF + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + if test x"$ac_file" = x-; then + echo "/* Generated by configure. */" >$tmp/config.h + else + echo "/* $ac_file. Generated by configure. */" >$tmp/config.h + fi + cat $tmp/in >>$tmp/config.h + rm -f $tmp/in + if test x"$ac_file" != x-; then + if diff $ac_file $tmp/config.h >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + ac_dir=`(dirname "$ac_file") 2>/dev/null || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + { if $as_mkdir_p; then + mkdir -p "$ac_dir" + else + as_dir="$ac_dir" + as_dirs= + while test ! -d "$as_dir"; do + as_dirs="$as_dir $as_dirs" + as_dir=`(dirname "$as_dir") 2>/dev/null || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + done + test ! -n "$as_dirs" || mkdir $as_dirs + fi || { { echo "$as_me:$LINENO: error: cannot create directory \"$ac_dir\"" >&5 +echo "$as_me: error: cannot create directory \"$ac_dir\"" >&2;} + { (exit 1); exit 1; }; }; } + + rm -f $ac_file + mv $tmp/config.h $ac_file + fi + else + cat $tmp/config.h + rm -f $tmp/config.h + fi + # Run the commands associated with the file. + case $ac_file in + config.h ) # update the timestamp +echo timestamp >"./stamp-h1" + ;; + esac +done +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF + +# +# CONFIG_COMMANDS section. +# +for ac_file in : $CONFIG_COMMANDS; do test "x$ac_file" = x: && continue + ac_dest=`echo "$ac_file" | sed 's,:.*,,'` + ac_source=`echo "$ac_file" | sed 's,[^:]*:,,'` + ac_dir=`(dirname "$ac_dest") 2>/dev/null || +$as_expr X"$ac_dest" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_dest" : 'X\(//\)[^/]' \| \ + X"$ac_dest" : 'X\(//\)$' \| \ + X"$ac_dest" : 'X\(/\)' \| \ + . : '\(.\)' 2>/dev/null || +echo X"$ac_dest" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/; q; } + /^X\(\/\/\)[^/].*/{ s//\1/; q; } + /^X\(\/\/\)$/{ s//\1/; q; } + /^X\(\/\).*/{ s//\1/; q; } + s/.*/./; q'` + ac_builddir=. + +if test "$ac_dir" != .; then + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A "../" for each directory in $ac_dir_suffix. + ac_top_builddir=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,../,g'` +else + ac_dir_suffix= ac_top_builddir= +fi + +case $srcdir in + .) # No --srcdir option. We are building in place. + ac_srcdir=. + if test -z "$ac_top_builddir"; then + ac_top_srcdir=. + else + ac_top_srcdir=`echo $ac_top_builddir | sed 's,/$,,'` + fi ;; + [\\/]* | ?:[\\/]* ) # Absolute path. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir ;; + *) # Relative path. + ac_srcdir=$ac_top_builddir$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_builddir$srcdir ;; +esac +# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be +# absolute. +ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd` +ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd` +ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd` +ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd` + + + { echo "$as_me:$LINENO: executing $ac_dest commands" >&5 +echo "$as_me: executing $ac_dest commands" >&6;} + case $ac_dest in + default-1 ) +test x"$AMDEP_TRUE" != x"" || +for mf in $CONFIG_FILES; do + case "$mf" in + Makefile) dirpart=.;; + */Makefile) dirpart=`echo "$mf" | sed -e 's|/[^/]*$||'`;; + *) continue;; + esac + grep '^DEP_FILES *= *[^ #]' < "$mf" > /dev/null || continue + # Extract the definition of DEP_FILES from the Makefile without + # running `make'. + DEPDIR=`sed -n -e '/^DEPDIR = / s///p' < "$mf"` + test -z "$DEPDIR" && continue + # When using ansi2knr, U may be empty or an underscore; expand it + U=`sed -n -e '/^U = / s///p' < "$mf"` + test -d "$dirpart/$DEPDIR" || mkdir "$dirpart/$DEPDIR" + # We invoke sed twice because it is the simplest approach to + # changing $(DEPDIR) to its actual value in the expansion. + for file in `sed -n -e ' + /^DEP_FILES = .*\\\\$/ { + s/^DEP_FILES = // + :loop + s/\\\\$// + p + n + /\\\\$/ b loop + p + } + /^DEP_FILES = / s/^DEP_FILES = //p' < "$mf" | \ + sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do + # Make sure the directory exists. + test -f "$dirpart/$file" && continue + fdir=`echo "$file" | sed -e 's|/[^/]*$||'` + $ac_aux_dir/mkinstalldirs "$dirpart/$fdir" > /dev/null 2>&1 + # echo "creating $dirpart/$file" + echo '# dummy' > "$dirpart/$file" + done +done + ;; + esac +done +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + + diff --git a/configure.in b/configure.in new file mode 100644 index 00000000..a4ad1b06 --- /dev/null +++ b/configure.in @@ -0,0 +1,95 @@ +dnl Process this file with autoconf to produce a configure script. +AC_INIT(libasn1parser/asn1p_y.y) +AC_CANONICAL_SYSTEM +AC_PREREQ(2.53) +AM_INIT_AUTOMAKE(asn1c, 0.8.10) + +AC_SUBST(PATH) + +AM_MAINTAINER_MODE + +AM_PROG_LIBTOOL + +dnl *** Autoconf support *** +AC_ARG_ENABLE(autoconf, + [ --disable-autoconf disable automatic generation of configure script ], + enable_autoconf=$enableval, enable_autoconf=yes +) +AC_PATH_PROG(AUTOCONF, autoconf, @echo autoconf not available) +AC_PATH_PROG(AUTOHEADER, autoheader, @echo autoheader not available) +if test -z "$AUTOCONF"; then enable_autoconf=no ; fi +if test -z "$AUTOHEADER"; then enable_autoconf=no ; fi +if test x$enable_autoconf = xyes; then + CONFIGURE_DEPENDS="configure.in aclocal.m4" +fi +AC_SUBST(CONFIGURE_DEPENDS) + +dnl Checks for programs. +AC_PROG_CC +AC_PROG_CPP +AC_PROG_INSTALL +AC_PROG_LN_S +AC_PROG_MAKE_SET +AC_PROG_YACC +AM_PROG_LEX +AC_PATH_PROG(AR, ar, ar, $PATH:/usr/ucb:/usr/ccs/bin) + +dnl *** Building mingw32 with cygwin compiler *** +case "$build" in +*cygwin*) + case "$target" in + *mingw*) + CC="$CC -mno-cygwin" + esac ;; +esac + +AC_ARG_ENABLE(autoconf, + [ --enable-Werror abort compilation after any C compiler warning], + ADD_CFLAGS="-Werror") +AC_SUBST(ADD_CFLAGS) + +dnl Add these flags if we're using GCC. +case "$GCC" in + yes) + CFLAGS="$CFLAGS -Wall" + CFLAGS="$CFLAGS -Wshadow" + CFLAGS="$CFLAGS -Wcast-qual" + CFLAGS="$CFLAGS -Wcast-align" + CFLAGS="$CFLAGS -Wmissing-prototypes" + CFLAGS="$CFLAGS -Wmissing-declarations" + CFLAGS="$CFLAGS -Wredundant-decls" + CFLAGS="$CFLAGS -Wnested-externs" + ;; +esac + + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS(errno.h) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_BIGENDIAN +AC_TYPE_OFF_T +AC_TYPE_SIZE_T +AC_STRUCT_TM +AC_CHECK_TYPE(intmax_t, int64_t) + +AC_CHECK_FUNCS(strtoimax strtoll) + +AM_CONFIG_HEADER(config.h) + +AC_OUTPUT( \ +libasn1compiler/Makefile \ +skeletons/tests/Makefile \ +libasn1parser/Makefile \ +libasn1print/Makefile \ +asn1c/tests/Makefile \ +libasn1fix/Makefile \ +skeletons/Makefile \ +examples/Makefile \ +tests/Makefile \ +asn1c/Makefile \ +doc/Makefile \ +Makefile \ +) + diff --git a/depcomp b/depcomp new file mode 100755 index 00000000..65899658 --- /dev/null +++ b/depcomp @@ -0,0 +1,411 @@ +#! /bin/sh + +# depcomp - compile a program generating dependencies as side-effects +# Copyright 1999, 2000 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., 59 Temple Place - Suite 330, Boston, MA +# 02111-1307, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi +# `libtool' can also be set to `yes' or `no'. + +depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. This file always lives in the current directory. + # Also, the AIX compiler puts `$object:' at the start of each line; + # $object doesn't have directory information. + stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + outname="$stripped.o" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +tru64) + # The Tru64 AIX compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + + tmpdepfile1="$object.d" + tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'` + if test "$libtool" = yes; then + "$@" -Wc,-MD + else + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + if test -f "$tmpdepfile1"; then + tmpdepfile="$tmpdepfile1" + else + tmpdepfile="$tmpdepfile2" + fi + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a space and a tab in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the proprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + test -z "$dashmflag" && dashmflag=-M + ( IFS=" " + case " $* " in + *" --mode=compile "*) # this is libtool, let us make it quiet + for arg + do # cycle over the arguments + case "$arg" in + "--mode=compile") + # insert --quiet before "--mode=compile" + set fnord "$@" --quiet + shift # fnord + ;; + esac + set fnord "$@" "$arg" + shift # fnord + shift # "$arg" + done + ;; + esac + "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + # X makedepend + ( + shift + cleared=no + for arg in "$@"; do + case $cleared in no) + set ""; shift + cleared=yes + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift;; + -*) + ;; + *) + set fnord "$@" "$arg"; shift;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tail +3 "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the proprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + ( IFS=" " + case " $* " in + *" --mode=compile "*) + for arg + do # cycle over the arguments + case $arg in + "--mode=compile") + # insert --quiet before "--mode=compile" + set fnord "$@" --quiet + shift # fnord + ;; + esac + set fnord "$@" "$arg" + shift # fnord + shift # "$arg" + done + ;; + esac + "$@" -E | + sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the proprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + ( IFS=" " + case " $* " in + *" --mode=compile "*) + for arg + do # cycle over the arguments + case $arg in + "--mode=compile") + # insert --quiet before "--mode=compile" + set fnord "$@" --quiet + shift # fnord + ;; + esac + set fnord "$@" "$arg" + shift # fnord + shift # "$arg" + done + ;; + esac + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + ) & + proc=$! + "$@" + stat=$? + wait "$proc" + if test "$stat" != 0; then exit $stat; fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 00000000..be8cd82c --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,3 @@ + +EXTRA_DIST = *.pdf +CLEANFILES = *.*~ diff --git a/doc/Makefile.in b/doc/Makefile.in new file mode 100644 index 00000000..656e8774 --- /dev/null +++ b/doc/Makefile.in @@ -0,0 +1,221 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +EXTRA_DIST = *.pdf +CLEANFILES = *.*~ +subdir = doc +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +DIST_SOURCES = +DIST_COMMON = Makefile.am Makefile.in +all: all-am + +.SUFFIXES: + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu doc/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status +uninstall-info-am: +tags: TAGS +TAGS: + + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-generic distclean-libtool + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am info info-am install install-am install-data \ + install-data-am install-exec install-exec-am install-info \ + install-info-am install-man install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-generic \ + mostlyclean-libtool uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/doc/asn1c-usage.pdf b/doc/asn1c-usage.pdf new file mode 100644 index 00000000..1d0d28de Binary files /dev/null and b/doc/asn1c-usage.pdf differ diff --git a/examples/Makefile.am b/examples/Makefile.am new file mode 100644 index 00000000..5b856e50 --- /dev/null +++ b/examples/Makefile.am @@ -0,0 +1,4 @@ + +dist_bin_SCRIPTS = crfc2asn1.pl clyx2asn1.pl + +EXTRA_DIST = *.asn1 rfc*.txt diff --git a/examples/Makefile.in b/examples/Makefile.in new file mode 100644 index 00000000..468ae065 --- /dev/null +++ b/examples/Makefile.in @@ -0,0 +1,246 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +dist_bin_SCRIPTS = crfc2asn1.pl clyx2asn1.pl + +EXTRA_DIST = *.asn1 rfc*.txt +subdir = examples +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +SCRIPTS = $(dist_bin_SCRIPTS) + +DIST_SOURCES = +DIST_COMMON = README $(dist_bin_SCRIPTS) Makefile.am Makefile.in +all: all-am + +.SUFFIXES: + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu examples/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status +install-dist_binSCRIPTS: $(dist_bin_SCRIPTS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(bindir) + @list='$(dist_bin_SCRIPTS)'; for p in $$list; do \ + f="`echo $$p|sed '$(transform)'`"; \ + if test -f $$p; then \ + echo " $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/$$f"; \ + $(INSTALL_SCRIPT) $$p $(DESTDIR)$(bindir)/$$f; \ + elif test -f $(srcdir)/$$p; then \ + echo " $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/$$f"; \ + $(INSTALL_SCRIPT) $(srcdir)/$$p $(DESTDIR)$(bindir)/$$f; \ + else :; fi; \ + done + +uninstall-dist_binSCRIPTS: + @$(NORMAL_UNINSTALL) + @list='$(dist_bin_SCRIPTS)'; for p in $$list; do \ + f="`echo $$p|sed '$(transform)'`"; \ + echo " rm -f $(DESTDIR)$(bindir)/$$f"; \ + rm -f $(DESTDIR)$(bindir)/$$f; \ + done +uninstall-info-am: +tags: TAGS +TAGS: + + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(SCRIPTS) + +installdirs: + $(mkinstalldirs) $(DESTDIR)$(bindir) + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-generic distclean-libtool + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: install-dist_binSCRIPTS + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-generic mostlyclean-libtool + +uninstall-am: uninstall-dist_binSCRIPTS uninstall-info-am + +.PHONY: all all-am check check-am clean clean-generic clean-libtool \ + distclean distclean-generic distclean-libtool distdir dvi \ + dvi-am info info-am install install-am install-data \ + install-data-am install-dist_binSCRIPTS install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-generic mostlyclean-libtool uninstall uninstall-am \ + uninstall-dist_binSCRIPTS uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/examples/README b/examples/README new file mode 100644 index 00000000..06480809 --- /dev/null +++ b/examples/README @@ -0,0 +1,6 @@ + +This directory contains several convertors from known text formats into +the ASN.1 specifications, as well as examples of these formats and the +sample convertor's output. + +Try ../asn1c/asn1c -P *PKIX*93.asn1 diff --git a/examples/clyx2asn1.pl b/examples/clyx2asn1.pl new file mode 100755 index 00000000..e544baa5 --- /dev/null +++ b/examples/clyx2asn1.pl @@ -0,0 +1,51 @@ +#!/usr/bin/perl + +# +# $Id$ +# $Author$ +# +# Simple tool that fetches known ASN.1 specifications from the +# stream of LyX data. +# + +if($#ARGV == -1) { + print STDERR "Extract known modules from LyX data\n"; + print STDERR "Usage: cat *.lyx | $0 ...\n"; + exit 64; +} + +# Convert arguments into a hash for quicker search. +for(my $i; $i <= $#ARGV; $i++) { + $modules{$ARGV[$i]} = $ARGV[$i].".asn1"; +} + +# Process incoming stream in search for ASN.1 modules. +while() { + chop; + if($inmodule) { + next if(/^$/); + if(/^\\layout /) { + print O "\n"; + next; + } + if(/^\\begin_inset Quotes/) { + print O '"'; + next; + } + next if(/^\\/); + print O; + if(/^END$/) { + $inmodule = 0; + print O "\n"; + } + } else { + next unless $modules{$_}; + open(O, '> '.$modules{$_}); + print O; + $inmodule = 1; + delete $modules{$_}; + } +} + +# Make sure noone's missing. +die "Modules not found: " . join(", ", keys %modules) . "\n" if keys %modules; diff --git a/examples/crfc2asn1.pl b/examples/crfc2asn1.pl new file mode 100755 index 00000000..20e1f9f7 --- /dev/null +++ b/examples/crfc2asn1.pl @@ -0,0 +1,86 @@ +#!/usr/bin/perl + +# +# $Id$ +# $Author$ +# +# Simple tool that fetches the ASN.1 specifications from the +# given set of RFC files. +# + + +my $inasn = 0; # Are we inside ASN.1 grammar? +my $found = 0; + +if(-t STDIN && $#ARGV == -1) { + print STDERR "Rip ASN.1 specification from RFC file\n"; + print STDERR "Usage: $0 ...\n"; + print STDERR "Usage: | $0\n"; + exit(1); +} + +while(<>) { + # + # Strip RFC page delimiters. + # + next if /^[A-Z].*\[Page [0-9]+\]$/; + next if /^ $/; + next if /^RFC [0-9].*[0-9]+$/; + + if($inasn == 0) { + # + # The least correct way to find the start of ASN + # definition. + # + if(/^[ \t]*END[ \t]*$/) { + print STDERR + "Missed an ASN.1 grammar before line ". $. ."?\n"; + exit(1); + } + + my $rfcid = ''; + $rfcid = $1 . '-' if($ARGV =~ /([a-z0-9]+)/i); + + if(/^[ \t]+([A-Za-z0-9-]+).*DEFINITIONS.*::=/) { + my $fname = $rfcid . $1 . ".asn1"; + open(O, "> $fname") or die "Can't open $fname"; + select(O); + $inasn = 1; + } elsif(/^[ \t]*([A-Za-z0-9-]+).*{.*iso/) { + my $fname = $rfcid . $1 . ".asn1"; + my @a = ($_); + my $i; + for($i = 0; $i < 8; $i++) { + $_ = <>; + push(@a, $_); + if(/DEFINITIONS/) { + $_ = join('', @a); + $inasn = 1; + last; + } + } + next unless $inasn; + open(O, "> $fname") or die "Can't open $fname"; + select(O); + } else { + next; + } + + $found++; + print "\n"; + print "-- \n"; + print "-- Grammar found in $ARGV by $0 at " . $. . "\n"; + print "-- \n"; + print "\n"; + } + + print; + + if(/^[ \t]*END[ \t]*$/) { + select(STDOUT); + close(O); + $inasn = 0; + } +} + +die "No ASN.1 specifications found\n" unless $found; diff --git a/install-sh b/install-sh new file mode 100755 index 00000000..e9de2384 --- /dev/null +++ b/install-sh @@ -0,0 +1,251 @@ +#!/bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + chmodcmd="" + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/libasn1compiler/Makefile.am b/libasn1compiler/Makefile.am new file mode 100644 index 00000000..6b2babdf --- /dev/null +++ b/libasn1compiler/Makefile.am @@ -0,0 +1,28 @@ + +AM_CPPFLAGS = \ + -I${top_srcdir}/libasn1parser \ + -I${top_srcdir}/libasn1fix + +noinst_LTLIBRARIES = libasn1compiler.la + +libasn1compiler_la_LDFLAGS = -all-static +libasn1compiler_la_SOURCES = \ + asn1compiler.c asn1compiler.h \ + asn1c_misc.c asn1c_misc.h \ + asn1c_out.c asn1c_out.h \ + asn1c_lang.c asn1c_lang.h \ + asn1c_save.c asn1c_save.h \ + asn1c_C.c asn1c_C.h \ + asn1c_internal.h + +libasn1compiler_la_LIBADD = \ + ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la + +check_PROGRAMS = check_compiler + +TESTS = ${check_PROGRAMS} + +LDADD = ${noinst_LTLIBRARIES} ${libasn1compiler_la_LIBADD} +DEPENDENCIES = ${LDADD} + diff --git a/libasn1compiler/Makefile.in b/libasn1compiler/Makefile.in new file mode 100644 index 00000000..3869df39 --- /dev/null +++ b/libasn1compiler/Makefile.in @@ -0,0 +1,424 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +AM_CPPFLAGS = \ + -I${top_srcdir}/libasn1parser \ + -I${top_srcdir}/libasn1fix + + +noinst_LTLIBRARIES = libasn1compiler.la + +libasn1compiler_la_LDFLAGS = -all-static +libasn1compiler_la_SOURCES = \ + asn1compiler.c asn1compiler.h \ + asn1c_misc.c asn1c_misc.h \ + asn1c_out.c asn1c_out.h \ + asn1c_lang.c asn1c_lang.h \ + asn1c_save.c asn1c_save.h \ + asn1c_C.c asn1c_C.h \ + asn1c_internal.h + + +libasn1compiler_la_LIBADD = \ + ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la + + +check_PROGRAMS = check_compiler + +TESTS = ${check_PROGRAMS} + +LDADD = ${noinst_LTLIBRARIES} ${libasn1compiler_la_LIBADD} +DEPENDENCIES = ${LDADD} +subdir = libasn1compiler +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) + +libasn1compiler_la_DEPENDENCIES = \ + ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la +am_libasn1compiler_la_OBJECTS = asn1compiler.lo asn1c_misc.lo \ + asn1c_out.lo asn1c_lang.lo asn1c_save.lo asn1c_C.lo +libasn1compiler_la_OBJECTS = $(am_libasn1compiler_la_OBJECTS) +check_PROGRAMS = check_compiler$(EXEEXT) +check_compiler_SOURCES = check_compiler.c +check_compiler_OBJECTS = check_compiler.$(OBJEXT) +check_compiler_LDADD = $(LDADD) +check_compiler_DEPENDENCIES = libasn1compiler.la \ + ${top_builddir}/libasn1parser/libasn1parser.la \ + ${top_builddir}/libasn1fix/libasn1fix.la +check_compiler_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/asn1c_C.Plo $(DEPDIR)/asn1c_lang.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1c_misc.Plo $(DEPDIR)/asn1c_out.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1c_save.Plo $(DEPDIR)/asn1compiler.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/check_compiler.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = $(libasn1compiler_la_SOURCES) check_compiler.c +DIST_COMMON = Makefile.am Makefile.in +SOURCES = $(libasn1compiler_la_SOURCES) check_compiler.c + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu libasn1compiler/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) +libasn1compiler.la: $(libasn1compiler_la_OBJECTS) $(libasn1compiler_la_DEPENDENCIES) + $(LINK) $(libasn1compiler_la_LDFLAGS) $(libasn1compiler_la_OBJECTS) $(libasn1compiler_la_LIBADD) $(LIBS) + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +check_compiler$(EXEEXT): $(check_compiler_OBJECTS) $(check_compiler_DEPENDENCIES) + @rm -f check_compiler$(EXEEXT) + $(LINK) $(check_compiler_LDFLAGS) $(check_compiler_OBJECTS) $(check_compiler_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1c_C.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1c_lang.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1c_misc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1c_out.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1c_save.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1compiler.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/check_compiler.Po@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ +uninstall-info-am: + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(LTLIBRARIES) + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES distclean distclean-compile \ + distclean-depend distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + tags uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libasn1compiler/asn1c_C.c b/libasn1compiler/asn1c_C.c new file mode 100644 index 00000000..8ec476c6 --- /dev/null +++ b/libasn1compiler/asn1c_C.c @@ -0,0 +1,2021 @@ +/* + * Don't look into this file. First, because it's a mess, and second, because + * it's a brain of the compiler, and you don't wanna mess with brains do you? ;) + */ +#include "asn1c_internal.h" +#include "asn1c_C.h" +#include /* exportable stuff from libasn1fix */ + +static int asn1c_lang_C_type_SEQUENCE_def(arg_t *arg); +static int asn1c_lang_C_type_SET_def(arg_t *arg); +static int asn1c_lang_C_type_CHOICE_def(arg_t *arg); +static int asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of); +static int _print_tag(arg_t *arg, asn1p_expr_t *expr, struct asn1p_type_tag_s *tag_p); +static int emit_constraint_checking_code(arg_t *arg); +static int emit_single_constraint_check(arg_t *arg, asn1p_constraint_t *ct, int mode); +static int emit_alphabet_tables(arg_t *arg, asn1p_constraint_t *ct, int *table); +static int emit_alphabet_check_cycle(arg_t *arg); +static int check_constraint_type_presence(asn1p_constraint_t *ct, enum asn1p_constraint_type_e type); +static asn1p_expr_type_e _find_terminal_type(arg_t *arg); +static int emit_value_determination_code(arg_t *arg); +static int emit_size_determination_code(arg_t *arg); +static long compute_min_size(arg_t *arg); +static long compute_max_size(arg_t *arg); +static long compute_xxx_size(arg_t *arg, int _max); + +typedef struct tag2el_s { + struct asn1p_type_tag_s el_tag; + int el_no; + asn1p_expr_t *from_expr; +} tag2el_t; + +static int _fill_tag2el_map(arg_t *arg, tag2el_t **tag2el, int *count, int el_no); +static int _add_tag2el_member(arg_t *arg, tag2el_t **tag2el, int *count, int el_no); + +#define C99_MODE (arg->flags & A1C_NO_C99) +#define UNNAMED_UNIONS (arg->flags & A1C_UNNAMED_UNIONS) + +#define PCTX_DEF INDENTED( \ + OUT("\n"); \ + OUT("/* Context for parsing across buffer boundaries */\n"); \ + OUT("ber_dec_ctx_t _ber_dec_ctx;\n")); + +#define DEPENDENCIES do { \ + int saved_target = arg->target->target; \ + int saved_indent = arg->indent_level; \ + int comment_printed = 0; \ + REDIR(OT_DEPS); \ + arg->indent_level = 0; \ + TQ_FOR(v, &(expr->members), next) { \ + if((!(v->expr_type & ASN_CONSTR_MASK) \ + && v->expr_type > ASN_CONSTR_MASK) \ + || v->meta_type == AMT_TYPEREF) { \ + if(!comment_printed++) \ + OUT("/* Dependencies for %s */\n", \ + asn1c_type_name(arg, expr, TNF_UNMODIFIED)); \ + OUT("#include <%s.h>\n", \ + asn1c_type_name(arg, v, TNF_INCLUDE)); \ + } \ + } \ + if(expr->expr_type == ASN_CONSTR_SET_OF) \ + OUT("#include \n"); \ + if(expr->expr_type == ASN_CONSTR_SEQUENCE_OF) \ + OUT("#include \n"); \ + OUT("\n"); \ + REDIR(saved_target); \ + INDENT(saved_indent); \ + } while(0) + +#define MKID(id) asn1c_make_identifier(0, (id), 0) + +int +asn1c_lang_C_type_ENUMERATED(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + + REDIR(OT_DEPS); + + OUT("typedef enum %s {\n", MKID(expr->Identifier)); + TQ_FOR(v, &(expr->members), next) { + switch(v->expr_type) { + case A1TC_UNIVERVAL: + OUT("\t%s\t= %lld,\n", + asn1c_make_identifier(0, + expr->Identifier, + v->Identifier, 0), + v->value->value.v_integer); + break; + case A1TC_EXTENSIBLE: + OUT("\t/*\n"); + OUT("\t * Enumeration is extensible\n"); + OUT("\t */\n"); + break; + default: + return -1; + } + } + OUT("} %s_e;\n", MKID(expr->Identifier)); + + return asn1c_lang_C_type_SIMPLE_TYPE(arg); +} + + +int +asn1c_lang_C_type_INTEGER(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + + REDIR(OT_DEPS); + + if(TQ_FIRST(&(expr->members))) { + OUT("typedef enum %s {\n", MKID(expr->Identifier)); + TQ_FOR(v, &(expr->members), next) { + switch(v->expr_type) { + case A1TC_UNIVERVAL: + OUT("\t%s\t= %lld,\n", + asn1c_make_identifier(0, + expr->Identifier, + v->Identifier, 0), + v->value->value.v_integer); + break; + default: + return -1; + } + } + OUT("} %s_e;\n", MKID(expr->Identifier)); + } + + return asn1c_lang_C_type_SIMPLE_TYPE(arg); +} + +int +asn1c_lang_C_type_SEQUENCE(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int comp_mode = 0; /* {root,ext=1,root,root,...} */ + + DEPENDENCIES; + + if(arg->embed) { + OUT("struct %s {\n", + MKID(expr->Identifier)); + } else { + OUT("typedef struct %s {\n", + MKID(expr->Identifier)); + } + + TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) { + if(comp_mode < 3) comp_mode++; + } + if(comp_mode == 1 && !v->marker) + v->marker = EM_OPTIONAL; + EMBED(v); + } + + PCTX_DEF; + OUT("} %s%s", expr->marker?"*":"", + MKID(expr->Identifier)); + if(arg->embed) OUT(";\n"); else OUT("_t;\n"); + + return asn1c_lang_C_type_SEQUENCE_def(arg); +} + +static int +asn1c_lang_C_type_SEQUENCE_def(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int elements; /* Number of elements */ + int tags_impl_skip = 0; + int comp_mode = 0; /* {root,ext=1,root,root,...} */ + int ext_start = -1; + int ext_stop = -1; + char *p; + + REDIR(OT_STAT_DEFS); + + OUT("#include \n"); + OUT("\n"); + + /* + * Print out the table according to which the parsing is performed. + */ + p = MKID(expr->Identifier); + OUT("static asn1_SEQUENCE_element_t asn1_DEF_%s_elements[] = {\n", p); + + elements = 0; + INDENTED(TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) { + if((++comp_mode) == 1) + ext_start = elements - 1; + else + ext_stop = elements - 1; + continue; + } + OUT("{ "); + elements++; + OUT("offsetof(struct %s, ", MKID(expr->Identifier)); + OUT("%s), ", MKID(v->Identifier)); + if(v->marker) { + asn1p_expr_t *tv; + int opts = 0; + for(tv = v; tv && tv->marker; + tv = TQ_NEXT(tv, next), opts++) { + if(tv->expr_type == A1TC_EXTENSIBLE) + opts--; + } + OUT("%d,", opts); + } else { + OUT("0,"); + } + OUT("\n"); + INDENT(+1); + if(C99_MODE) OUT(".tag = "); + _print_tag(arg, v, NULL); + OUT(",\n"); + if(C99_MODE) OUT(".tag_mode = "); + if(v->tag.tag_class) { + if(v->tag.tag_mode == TM_IMPLICIT) + OUT("-1,\t/* IMPLICIT tag at current level */\n"); + else + OUT("+1,\t/* EXPLICIT tag at current level */\n"); + } else { + OUT("0,\n"); + } + if(C99_MODE) OUT(".type = "); + OUT("(void *)&asn1_DEF_%s,\n", + asn1c_type_name(arg, v, TNF_SAFE)); + if(C99_MODE) OUT(".name = "); + OUT("\"%s\"\n", v->Identifier); + OUT("},\n"); + INDENT(-1); + }); + OUT("};\n"); + + p = MKID(expr->Identifier); + OUT("static ber_tlv_tag_t asn1_DEF_%s_tags[] = {\n", p); + INDENTED( + if(expr->tag.tag_class) { + _print_tag(arg, expr, &expr->tag); + if(expr->tag.tag_mode != TM_EXPLICIT) + tags_impl_skip++; + } + if(!expr->tag.tag_class + || (expr->meta_type == AMT_TYPE + && expr->tag.tag_mode == TM_EXPLICIT)) { + struct asn1p_type_tag_s tag; + if(expr->tag.tag_class) + OUT(",\n"); + tag.tag_class = TC_UNIVERSAL; + tag.tag_mode = TM_IMPLICIT; + tag.tag_value = expr_type2uclass_value[expr->expr_type]; + _print_tag(arg, expr, &tag); + } + OUT("\n"); + ); + OUT("};\n"); + + OUT("static asn1_SEQUENCE_specifics_t asn1_DEF_%s_specs = {\n", p); + INDENTED( + OUT("sizeof(struct %s),\n", p); + OUT("offsetof(struct %s, _ber_dec_ctx),\n", p); + OUT("asn1_DEF_%s_elements,\n", p); + OUT("%d,\t/* Elements count */\n", elements); + OUT("%d,\t/* Start extensions */\n", + ext_start); + OUT("%d\t/* Stop extensions */\n", + (ext_stopIdentifier); + OUT("SEQUENCE_constraint,\n"); + OUT("SEQUENCE_decode_ber,\n"); + OUT("SEQUENCE_encode_der,\n"); + OUT("SEQUENCE_print,\n"); + OUT("SEQUENCE_free,\n"); + OUT("0,\t/* Use generic outmost tag fetcher */\n"); + OUT("asn1_DEF_%s_tags,\n", p); + OUT("sizeof(asn1_DEF_%s_tags)\n", p); + OUT("\t/sizeof(asn1_DEF_%s_tags[0]),\n", p); + OUT("%d,\t/* Tags to skip */\n", tags_impl_skip); + OUT("%d,\t/* Whether CONSTRUCTED */\n", 1); + OUT("&asn1_DEF_%s_specs\t/* Additional specs */\n", p); + ); + OUT("};\n"); + OUT("\n"); + + REDIR(OT_DEPS); + OUT("#include \n"); + OUT("\n"); + if(!arg->embed) + OUT("extern asn1_TYPE_descriptor_t asn1_DEF_%s;\n", p); + REDIR(OT_TYPE_DECLS); + + return 0; +} + +int +asn1c_lang_C_type_SEQUENCE_OF(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + + DEPENDENCIES; + + if(arg->embed) { + OUT("struct %s {\n", MKID(expr->Identifier)); + } else { + OUT("typedef struct %s {\n", MKID(expr->Identifier)); + } + + TQ_FOR(v, &(expr->members), next) { + INDENTED(OUT("A_SEQUENCE_OF(%s) list;\n", + asn1c_type_name(arg, v, TNF_RSAFE))); + } + + PCTX_DEF; + OUT("} %s%s", expr->marker?"*":"", MKID(expr->Identifier)); + if(arg->embed) OUT(";\n"); else OUT("_t;\n"); + + /* + * SET OF/SEQUENCE OF definition, SEQUENCE OF mode. + */ + return asn1c_lang_C_type_SEx_OF_def(arg, 1); +} + +int +asn1c_lang_C_type_SET(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + long mcount; + char *id; + int comp_mode = 0; /* {root,ext=1,root,root,...} */ + + DEPENDENCIES; + + REDIR(OT_DEPS); + + OUT("\n"); + OUT("/*\n"); + OUT(" * Method of determining the components presence\n"); + OUT(" */\n"); + mcount = 0; + OUT("enum %s_PR_e {\n", MKID(expr->Identifier)); + TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) continue; + INDENTED( + id = MKID(expr->Identifier); + OUT("%s_PR_", id); + id = MKID(v->Identifier); + OUT("%s,\t/* Member %s is present */\n", + id, id) + ); + mcount++; + } + OUT("};\n"); + + REDIR(OT_TYPE_DECLS); + + if(arg->embed) { + OUT("struct %s {\n", MKID(expr->Identifier)); + } else { + OUT("typedef struct %s {\n", MKID(expr->Identifier)); + } + + TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) { + if(comp_mode < 3) comp_mode++; + } + if(comp_mode == 1 && !v->marker) + v->marker = EM_OPTIONAL; + EMBED(v); + } + + INDENTED( + id = MKID(expr->Identifier); + OUT("\n"); + OUT("/* Presence bitmask: ASN_SET_ISPRESENT(p%s, %s_PR_x) */\n", + id, id); + OUT("unsigned int _presence_map\n"); + OUT("\t[((%ld+(8*sizeof(unsigned int))-1)/(8*sizeof(unsigned int)))];\n", mcount); + ); + + PCTX_DEF; + OUT("} %s%s", expr->marker?"*":"", MKID(expr->Identifier)); + if(arg->embed) OUT(";\n"); else OUT("_t;\n"); + + return asn1c_lang_C_type_SET_def(arg); +} + +/* + * Compare tags according to their canonical order. + * Canonical order: [UNIVERSAL] [APPLICATION] [] [PRIVATE] + * As you see, the class is encoded using the two lowest bits. + */ +static arg_t *_ctc_arg; +static int _canonical_tags_cmp(const void *ap, const void *bp) + __attribute__ ((unused)); +static int +_canonical_tags_cmp(const void *ap, const void *bp) { + asn1p_expr_t *a, *b; + struct asn1p_type_tag_s ta, tb; + + (const asn1p_expr_t *)a = *(const asn1p_expr_t * const *)ap; + (const asn1p_expr_t *)b = *(const asn1p_expr_t * const *)bp; + + if(asn1f_fetch_tag(_ctc_arg->asn, _ctc_arg->mod, a, &ta) + || asn1f_fetch_tag(_ctc_arg->asn, _ctc_arg->mod, b, &tb)) + return 0; + + if(ta.tag_class == tb.tag_class) { + if(ta.tag_value == tb.tag_value) + return 0; + else if(ta.tag_value < tb.tag_value) + return -1; + else + return 1; + } else if(ta.tag_class < tb.tag_class) { + return -1; + } else { + return 1; + } +} + +static int +_tag2el_cmp(const void *ap, const void *bp) { + const tag2el_t *a = ap; + const tag2el_t *b = bp; + const struct asn1p_type_tag_s *ta = &a->el_tag; + const struct asn1p_type_tag_s *tb = &b->el_tag; + + if(ta->tag_class == tb->tag_class) { + if(ta->tag_value == tb->tag_value) + return 0; + else if(ta->tag_value < tb->tag_value) + return -1; + else + return 1; + } else if(ta->tag_class < tb->tag_class) { + return -1; + } else { + return 1; + } +} + +static int +asn1c_lang_C_type_SET_def(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int elements; + int tags_impl_skip = 0; + int comp_mode = 0; /* {root,ext=1,root,root,...} */ + int extensible = 0; + tag2el_t *tag2el = NULL; + int tag2el_count = 0; + char *p; + + /* + * Fetch every inner tag from the tag to elements map. + */ + if(_fill_tag2el_map(arg, &tag2el, &tag2el_count, -1)) { + if(tag2el) free(tag2el); + return -1; + } else { + /* + * Sort the map according to canonical order of their tags. + */ + _ctc_arg = arg; + qsort(tag2el, tag2el_count, sizeof(*tag2el), _tag2el_cmp); + } + + + REDIR(OT_STAT_DEFS); + + OUT("#include \n"); + OUT("\n"); + + /* + * Print out the table according to which the parsing is performed. + */ + p = MKID(expr->Identifier); + OUT("static asn1_SET_element_t asn1_DEF_%s_elements[] = {\n", p); + + elements = 0; + INDENTED(TQ_FOR(v, &(expr->members), next) { + if(v->expr_type != A1TC_EXTENSIBLE) { + if(comp_mode == 1) + v->marker = EM_OPTIONAL; + elements++; + } else { + if(comp_mode < 3) comp_mode++; + continue; + } + OUT("{ "); + p = MKID(expr->Identifier); + OUT("offsetof(struct %s, ", p); + p = MKID(v->Identifier); + OUT("%s), ", p); + if(v->marker) { + OUT("1, /* Optional element */\n"); + } else { + OUT("0,\n"); + } + INDENT(+1); + if(C99_MODE) OUT(".tag = "); + _print_tag(arg, v, NULL); + OUT(",\n"); + if(C99_MODE) OUT(".tag_mode = "); + if(v->tag.tag_class) { + if(v->tag.tag_mode == TM_IMPLICIT) + OUT("-1,\t/* IMPLICIT tag at current level */\n"); + else + OUT("+1,\t/* EXPLICIT tag at current level */\n"); + } else { + OUT("0,\n"); + } + if(C99_MODE) OUT(".type = "); + OUT("(void *)&asn1_DEF_%s,\n", + asn1c_type_name(arg, v, TNF_SAFE)); + if(C99_MODE) OUT(".name = "); + OUT("\"%s\"\n", v->Identifier); + OUT("},\n"); + INDENT(-1); + }); + OUT("};\n"); + + p = MKID(expr->Identifier); + OUT("static ber_tlv_tag_t asn1_DEF_%s_tags[] = {\n", p); + INDENTED( + if(expr->tag.tag_class) { + _print_tag(arg, expr, &expr->tag); + if(expr->tag.tag_mode != TM_EXPLICIT) + tags_impl_skip++; + } + if(!expr->tag.tag_class + || (expr->meta_type == AMT_TYPE + && expr->tag.tag_mode == TM_EXPLICIT)) { + struct asn1p_type_tag_s tag; + if(expr->tag.tag_class) + OUT(",\n"); + tag.tag_class = TC_UNIVERSAL; + tag.tag_mode = TM_IMPLICIT; + tag.tag_value = expr_type2uclass_value[expr->expr_type]; + _print_tag(arg, expr, &tag); + } + OUT("\n"); + ); + OUT("};\n"); + + /* + * Tags to elements map. + */ + p = MKID(expr->Identifier); + OUT("static asn1_SET_tag2member_t asn1_DEF_%s_tag2el[] = {\n", p); + if(tag2el_count) { + int i; + for(i = 0; i < tag2el_count; i++) { + OUT(" { "); + _print_tag(arg, expr, &tag2el[i].el_tag); + OUT(", "); + OUT("%d ", tag2el[i].el_no); + OUT("}, /* %s at %d */\n", + tag2el[i].from_expr->Identifier, + tag2el[i].from_expr->_lineno + ); + } + } + OUT("};\n"); + + /* + * Emit a map of mandatory elements. + */ + OUT("static uint8_t asn1_DEF_%s_mmap", p); + OUT("[(%d + (8 * sizeof(unsigned int)) - 1) / 8]", elements); + OUT(" = {\n", p); + INDENTED( + if(elements) { + int delimit = 0; + int el = 0; + TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) continue; + if(delimit) { + OUT(",\n"); + delimit = 0; + } else if(el) { + OUT(" | "); + } + OUT("(%d << %d)", v->marker?0:1, 7 - (el % 8)); + if(el && (el % 8) == 0) + delimit = 1; + el++; + } + } else { + OUT("0"); + } + ); + OUT("\n"); + OUT("};\n"); + + OUT("static asn1_SET_specifics_t asn1_DEF_%s_specs = {\n", p); + INDENTED( + OUT("sizeof(struct %s),\n", p); + OUT("offsetof(struct %s, _ber_dec_ctx),\n", p); + OUT("offsetof(struct %s, _presence_map),\n", p); + OUT("asn1_DEF_%s_elements,\n", p); + OUT("%d,\t/* Elements count */\n", elements); + OUT("asn1_DEF_%s_tag2el,\n", p); + OUT("%d,\t/* Count of tags in the map */\n", tag2el_count); + OUT("%d,\t/* Whether extensible */\n", extensible); + OUT("(unsigned int *)asn1_DEF_%s_mmap\t/* Mandatory elements map */\n", p); + ); + OUT("};\n"); + OUT("asn1_TYPE_descriptor_t asn1_DEF_%s = {\n", p); + INDENTED( + OUT("\"%s\",\n", expr->Identifier); + OUT("SET_constraint,\n"); + OUT("SET_decode_ber,\n"); + OUT("SET_encode_der,\n"); + OUT("SET_print,\n"); + OUT("SET_free,\n"); + OUT("0,\t/* Use generic outmost tag fetcher */\n"); + OUT("asn1_DEF_%s_tags,\n", p); + OUT("sizeof(asn1_DEF_%s_tags)\n", p); + OUT("\t/sizeof(asn1_DEF_%s_tags[0]),\n", p); + OUT("%d,\t/* Tags to skip */\n", tags_impl_skip); + OUT("%d,\t/* Whether CONSTRUCTED */\n", 1); + OUT("&asn1_DEF_%s_specs\t/* Additional specs */\n", p); + ); + OUT("};\n"); + OUT("\n"); + + REDIR(OT_DEPS); + OUT("#include \n"); + OUT("\n"); + if(!arg->embed) + OUT("extern asn1_TYPE_descriptor_t asn1_DEF_%s;\n", p); + REDIR(OT_TYPE_DECLS); + + return 0; +} + +int +asn1c_lang_C_type_SET_OF(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + + DEPENDENCIES; + + if(arg->embed) { + OUT("struct %s {\n", MKID(expr->Identifier)); + } else { + OUT("typedef struct %s {\n", + MKID(expr->Identifier)); + } + + TQ_FOR(v, &(expr->members), next) { + INDENTED(OUT("A_SET_OF(%s) list;\n", + asn1c_type_name(arg, v, TNF_RSAFE))); + } + + PCTX_DEF; + OUT("} %s%s", expr->marker?"*":"", MKID(expr->Identifier)); + if(arg->embed) OUT(";\n"); else OUT("_t;\n"); + + /* + * SET OF/SEQUENCE OF definition, SET OF mode. + */ + return asn1c_lang_C_type_SEx_OF_def(arg, 0); +} + +static int +asn1c_lang_C_type_SEx_OF_def(arg_t *arg, int seq_of) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int tags_impl_skip = 0; + char *p; + + REDIR(OT_DEPS); + + if(seq_of) { + OUT("#include \n"); + } else { + OUT("#include \n"); + OUT("\n"); + } + + REDIR(OT_STAT_DEFS); + + /* + * Print out the table according to which the parsing is performed. + */ + p = MKID(expr->Identifier); + OUT("static asn1_SET_OF_element_t asn1_DEF_%s_elements[] = {\n", p); + + INDENTED(OUT("{ "); + v = TQ_FIRST(&(expr->members)); + INDENT(+1); + if(C99_MODE) OUT(".tag = "); + _print_tag(arg, v, NULL); + OUT(",\n"); + if(C99_MODE) OUT(".type = "); + OUT("(void *)&asn1_DEF_%s", + asn1c_type_name(arg, v, TNF_SAFE)); + OUT(" "); + OUT("},\n"); + INDENT(-1); + ); + OUT("};\n"); + + p = MKID(expr->Identifier); + OUT("static ber_tlv_tag_t asn1_DEF_%s_tags[] = {\n", p); + INDENTED( + if(expr->tag.tag_class) { + _print_tag(arg, expr, &expr->tag); + if(expr->tag.tag_mode != TM_EXPLICIT) + tags_impl_skip++; + } + if(!expr->tag.tag_class + || (expr->meta_type == AMT_TYPE + && expr->tag.tag_mode == TM_EXPLICIT)) { + struct asn1p_type_tag_s tag; + if(expr->tag.tag_class) + OUT(",\n"); + tag.tag_class = TC_UNIVERSAL; + tag.tag_mode = TM_IMPLICIT; + tag.tag_value = expr_type2uclass_value[expr->expr_type]; + _print_tag(arg, expr, &tag); + } + OUT("\n"); + ); + OUT("};\n"); + + OUT("static asn1_SET_OF_specifics_t asn1_DEF_%s_specs = {\n", p); + INDENTED( + OUT("sizeof(struct %s),\n", p); + OUT("offsetof(struct %s, _ber_dec_ctx),\n", p); + OUT("asn1_DEF_%s_elements\n", p); + ); + OUT("};\n"); + OUT("asn1_TYPE_descriptor_t asn1_DEF_%s = {\n", p); + INDENTED( + OUT("\"%s\",\n", expr->Identifier); + if(seq_of) { + OUT("SEQUENCE_OF_constraint,\n"); + OUT("SEQUENCE_OF_decode_ber,\n"); + OUT("SEQUENCE_OF_encode_der,\n"); + OUT("SEQUENCE_OF_print,\n"); + OUT("SEQUENCE_OF_free,\n"); + } else { + OUT("SET_OF_constraint,\n"); + OUT("SET_OF_decode_ber,\n"); + OUT("SET_OF_encode_der,\n"); + OUT("SET_OF_print,\n"); + OUT("SET_OF_free,\n"); + } + OUT("0,\t/* Use generic outmost tag fetcher */\n"); + OUT("asn1_DEF_%s_tags,\n", p); + OUT("sizeof(asn1_DEF_%s_tags)\n", p); + OUT("\t/sizeof(asn1_DEF_%s_tags[0]),\n", p); + OUT("%d,\t/* Tags to skip */\n", tags_impl_skip); + OUT("%d,\t/* Whether CONSTRUCTED */\n", 1); + OUT("&asn1_DEF_%s_specs\t/* Additional specs */\n", p); + ); + OUT("};\n"); + OUT("\n"); + + REDIR(OT_DEPS); + if(!arg->embed) + OUT("extern asn1_TYPE_descriptor_t asn1_DEF_%s;\n", p); + REDIR(OT_TYPE_DECLS); + + return 0; +} + +int +asn1c_lang_C_type_CHOICE(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + char *p; + + DEPENDENCIES; + + p = MKID(expr->Identifier); + + if(arg->embed) { + OUT("struct %s {\n", p); + } else { + OUT("typedef struct %s {\n", p); + } + + INDENTED( + OUT("enum {\n"); + INDENTED( + OUT("%s_PR_NOTHING,\t" + "/* No components present */\n", p); + TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) continue; + p = MKID(expr->Identifier); + OUT("%s_PR_", p); + p = MKID(v->Identifier); + OUT("%s,\n", p, p); + } + ); + OUT("} present;\n"); + + OUT("union {\n", p); + TQ_FOR(v, &(expr->members), next) { + EMBED(v); + } + if(UNNAMED_UNIONS) OUT("};\n"); + else OUT("} choice;\n"); + ); + + PCTX_DEF; + OUT("} %s%s", expr->marker?"*":"", MKID(expr->Identifier)); + if(arg->embed) OUT(";\n"); else OUT("_t;\n"); + + return asn1c_lang_C_type_CHOICE_def(arg); +} + +static int +asn1c_lang_C_type_CHOICE_def(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int elements; /* Number of elements */ + int tags_impl_skip = 0; + int comp_mode = 0; /* {root,ext=1,root,root,...} */ + int extensible = 0; + tag2el_t *tag2el = NULL; + int tag2el_count = 0; + char *p; + + /* + * Fetch every inner tag from the tag to elements map. + */ + if(_fill_tag2el_map(arg, &tag2el, &tag2el_count, -1)) { + if(tag2el) free(tag2el); + return -1; + } else { + /* + * Sort the map according to canonical order of their tags. + */ + _ctc_arg = arg; + qsort(tag2el, tag2el_count, sizeof(*tag2el), _tag2el_cmp); + } + + REDIR(OT_STAT_DEFS); + + OUT("#include \n"); + OUT("\n"); + + /* + * Print out the table according to which the parsing is performed. + */ + p = MKID(expr->Identifier); + OUT("static asn1_CHOICE_element_t asn1_DEF_%s_elements[] = {\n", p); + + elements = 0; + INDENTED(TQ_FOR(v, &(expr->members), next) { + if(v->expr_type != A1TC_EXTENSIBLE) { + if(comp_mode == 1) + v->marker = EM_OPTIONAL; + elements++; + } else { + if(comp_mode < 3) comp_mode++; + continue; + } + OUT("{ "); + p = MKID(expr->Identifier); + OUT("offsetof(struct %s, ", p); + p = MKID(v->Identifier); + if(!UNNAMED_UNIONS) OUT("choice."); + OUT("%s), ", p); + if(v->marker) { + OUT("1, /* Optional element */\n"); + } else { + OUT("0,\n"); + } + INDENT(+1); + if(C99_MODE) OUT(".tag = "); + _print_tag(arg, v, NULL); + OUT(",\n"); + if(C99_MODE) OUT(".tag_mode = "); + if(v->tag.tag_class) { + if(v->tag.tag_mode == TM_IMPLICIT) + OUT("-1,\t/* IMPLICIT tag at current level */\n"); + else + OUT("+1,\t/* EXPLICIT tag at current level */\n"); + } else { + OUT("0,\n"); + } + if(C99_MODE) OUT(".type = "); + OUT("(void *)&asn1_DEF_%s,\n", + asn1c_type_name(arg, v, TNF_SAFE)); + if(C99_MODE) OUT(".name = "); + OUT("\"%s\"\n", v->Identifier); + OUT("},\n"); + INDENT(-1); + }); + OUT("};\n"); + + p = MKID(expr->Identifier); + OUT("static ber_tlv_tag_t asn1_DEF_%s_tags[] = {\n", p); + if(arg->embed) { + /* + * Our parent structure has already taken this into account. + */ + } else { + INDENTED( + if(expr->tag.tag_class) { + _print_tag(arg, expr, &expr->tag); + if(expr->tag.tag_mode != TM_EXPLICIT) + tags_impl_skip++; + } + OUT("\n"); + ); + } + OUT("};\n"); + + /* + * Tags to elements map. + */ + p = MKID(expr->Identifier); + OUT("static asn1_CHOICE_tag2member_t asn1_DEF_%s_tag2el[] = {\n", p); + if(tag2el_count) { + int i; + for(i = 0; i < tag2el_count; i++) { + OUT(" { "); + _print_tag(arg, expr, &tag2el[i].el_tag); + OUT(", "); + OUT("%d ", tag2el[i].el_no); + OUT("}, /* %s at %d */\n", + tag2el[i].from_expr->Identifier, + tag2el[i].from_expr->_lineno + ); + } + } + OUT("};\n"); + + OUT("static asn1_CHOICE_specifics_t asn1_DEF_%s_specs = {\n", p); + INDENTED( + OUT("sizeof(struct %s),\n", p); + OUT("offsetof(struct %s, _ber_dec_ctx),\n", p); + OUT("offsetof(struct %s, present),\n", p); + OUT("sizeof(((struct %s *)0)->present),\n", p); + OUT("asn1_DEF_%s_elements,\n", p); + OUT("%d,\t/* Elements count */\n", elements); + OUT("asn1_DEF_%s_tag2el,\n", p); + OUT("%d,\t/* Count of tags in the map */\n", tag2el_count); + OUT("%d\t/* Whether extensible */\n", extensible); + ); + OUT("};\n"); + OUT("asn1_TYPE_descriptor_t asn1_DEF_%s = {\n", p); + INDENTED( + OUT("\"%s\",\n", expr->Identifier); + OUT("CHOICE_constraint,\n"); + OUT("CHOICE_decode_ber,\n"); + OUT("CHOICE_encode_der,\n"); + OUT("CHOICE_print,\n"); + OUT("CHOICE_free,\n"); + OUT("CHOICE_outmost_tag,\n"); + OUT("asn1_DEF_%s_tags,\n", p); + OUT("sizeof(asn1_DEF_%s_tags)\n", p); + OUT("\t/sizeof(asn1_DEF_%s_tags[0]),\n", p); + OUT("%d,\t/* Tags to skip */\n", tags_impl_skip); + OUT("%d,\t/* Whether CONSTRUCTED */\n", 1); + OUT("&asn1_DEF_%s_specs\t/* Additional specs */\n", p); + ); + OUT("};\n"); + OUT("\n"); + + REDIR(OT_DEPS); + if(!arg->embed) + OUT("extern asn1_TYPE_descriptor_t asn1_DEF_%s;\n", p); + REDIR(OT_TYPE_DECLS); + + return 0; +} + +int +asn1c_lang_C_type_REFERENCE(arg_t *arg) { + asn1p_ref_t *ref; + + ref = arg->expr->reference; + if(ref->components[ref->comp_count-1].name[0] == '&') { + asn1p_module_t *mod; + asn1p_expr_t *extract; + arg_t tmp; + int ret; + + extract = asn1f_class_access_ex(arg->asn, arg->mod, arg->expr, + ref, &mod); + if(extract == NULL) + return -1; + + extract = asn1p_expr_clone(extract); + if(extract) { + if(extract->Identifier) + free(extract->Identifier); + extract->Identifier = strdup(arg->expr->Identifier); + if(extract->Identifier == NULL) { + asn1p_expr_free(extract); + return -1; + } + } else { + return -1; + } + + tmp = *arg; + tmp.asn = arg->asn; + tmp.mod = mod; + tmp.expr = extract; + + ret = arg->default_cb(&tmp); + + asn1p_expr_free(extract); + + return ret; + } + + + return asn1c_lang_C_type_SIMPLE_TYPE(arg); +} + +int +asn1c_lang_C_type_SIMPLE_TYPE(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + int tags_impl_skip = 0; + char *p; + + if(arg->embed) { + REDIR(OT_TYPE_DECLS); + + OUT("%s\t", asn1c_type_name(arg, arg->expr, + expr->marker?TNF_RSAFE:TNF_CTYPE)); + OUT("%s", expr->marker?"*":" "); + OUT("%s;", MKID(expr->Identifier)); + if(expr->marker) OUT("\t/* %s */", + (expr->marker==EM_OPTIONAL)?"OPTIONAL":"DEFAULT"); + OUT("\n"); + return 0; + } + + REDIR(OT_DEPS); + + OUT("#include <%s.h>\n", asn1c_type_name(arg, expr, TNF_INCLUDE)); + + REDIR(OT_TYPE_DECLS); + + OUT("typedef %s\t", asn1c_type_name(arg, arg->expr, TNF_CTYPE)); + OUT("%s", expr->marker?"*":" "); + OUT("%s_t;\n", MKID(expr->Identifier)); + OUT("\n"); + + REDIR(OT_STAT_DEFS); + + p = MKID(expr->Identifier); + OUT("static ber_tlv_tag_t asn1_DEF_%s_tags[] = {\n", p); + INDENTED( + if(expr->tag.tag_class) { + _print_tag(arg, expr, &expr->tag); + if(expr->tag.tag_mode != TM_EXPLICIT) + tags_impl_skip++; + } + if(!expr->tag.tag_class + || (expr->meta_type == AMT_TYPE + && expr->tag.tag_mode == TM_EXPLICIT)) { + struct asn1p_type_tag_s tag; + if(expr->tag.tag_class) + OUT(",\n"); + tag.tag_class = TC_UNIVERSAL; + tag.tag_mode = TM_IMPLICIT; + tag.tag_value = expr_type2uclass_value[expr->expr_type]; + _print_tag(arg, expr, &tag); + } + OUT("\n"); + ); + OUT("};\n"); + + OUT("asn1_TYPE_descriptor_t asn1_DEF_%s = {\n", p); + INDENTED( + OUT("\"%s\",\n", expr->Identifier); + OUT("%s_constraint,\n", p); + OUT("%s_decode_ber,\n", p); + OUT("%s_encode_der,\n", p); + OUT("%s_print,\n", p); + OUT("%s_free,\n", p); + OUT("0,\t/* Use generic outmost tag fetcher */\n"); + OUT("asn1_DEF_%s_tags,\n", p); + OUT("sizeof(asn1_DEF_%s_tags)\n", p); + OUT("\t/sizeof(asn1_DEF_%s_tags[0]),\n", p); + OUT("%d,\t/* Tags to skip */\n", tags_impl_skip); + OUT("-0\t/* Unknown yet */\n"); + ); + OUT("};\n"); + OUT("\n"); + + /* + * Constraint checking. + */ + if(expr->constraints) /* Emit tables with FROM() constraints */ + emit_alphabet_tables(arg, expr->constraints, 0); + p = MKID(expr->Identifier); + OUT("int\n"); + OUT("%s_constraint(asn1_TYPE_descriptor_t *td, const void *sptr,\n", p); + INDENTED( + OUT("\t\tasn_app_consume_bytes_f *app_errlog, void *app_key) {\n"); + OUT("\n"); + if(expr->constraints) { + + emit_constraint_checking_code(arg); + + OUT("/* Check the constraints of the underlying type */\n"); + OUT("return asn1_DEF_%s.check_constraints\n", + asn1c_type_name(arg, expr, TNF_SAFE)); + OUT("\t(td, sptr, app_errlog, app_key);\n"); + } else { + OUT("/* Make the underlying type checker permanent */\n"); + OUT("td->check_constraints = asn1_DEF_%s.check_constraints;\n", + asn1c_type_name(arg, expr, TNF_SAFE)); + OUT("return td->check_constraints\n"); + OUT("\t(td, sptr, app_errlog, app_key);\n"); + } + ); + OUT("}\n"); + OUT("\n"); + + /* + * Emit suicidal functions. + */ + + { + /* + * This function replaces certain fields from the definition + * of a type with the corresponding fields from the basic type + * (from which the current type is inherited). + */ + char *type_name = asn1c_type_name(arg, expr, TNF_SAFE); + OUT("/*\n"); + OUT(" * This type is implemented using %s,\n", type_name); + OUT(" * so adjust the DEF appropriately.\n"); + OUT(" */\n"); + OUT("static void\n"); + OUT("inherit_TYPE_descriptor(asn1_TYPE_descriptor_t *td) {\n"); + INDENT(+1); + OUT("td->ber_decoder = asn1_DEF_%s.ber_decoder;\n", type_name); + OUT("td->der_encoder = asn1_DEF_%s.der_encoder;\n", type_name); + OUT("td->free_struct = asn1_DEF_%s.free_struct;\n", type_name); + OUT("td->print_struct = asn1_DEF_%s.print_struct;\n", type_name); + OUT("td->last_tag_form = asn1_DEF_%s.last_tag_form;\n", type_name); + OUT("td->specifics = asn1_DEF_%s.specifics;\n", type_name); + INDENT(-1); + OUT("}\n"); + OUT("\n"); + } + + p = MKID(expr->Identifier); + OUT("ber_dec_rval_t\n"); + OUT("%s_decode_ber(asn1_TYPE_descriptor_t *td,\n", p); + INDENTED( + OUT("\tvoid **structure, void *bufptr, size_t size, int tag_mode) {\n"); + OUT("inherit_TYPE_descriptor(td);\n"); + OUT("return td->ber_decoder(td, structure,\n"); + OUT("\tbufptr, size, tag_mode);\n"); + ); + OUT("}\n"); + OUT("\n"); + + p = MKID(expr->Identifier); + OUT("der_enc_rval_t\n"); + OUT("%s_encode_der(asn1_TYPE_descriptor_t *td,\n", p); + INDENTED( + OUT("\tvoid *structure, int tag_mode, ber_tlv_tag_t tag,\n"); + OUT("\tasn_app_consume_bytes_f *cb, void *app_key) {\n"); + OUT("inherit_TYPE_descriptor(td);\n"); + OUT("return td->der_encoder(td, structure, tag_mode, tag, cb, app_key);\n"); + ); + OUT("}\n"); + OUT("\n"); + + p = MKID(expr->Identifier); + OUT("int\n"); + OUT("%s_print(asn1_TYPE_descriptor_t *td, const void *struct_ptr,\n", p); + INDENTED( + OUT("\tint ilevel, asn_app_consume_bytes_f *cb, void *app_key) {\n"); + OUT("inherit_TYPE_descriptor(td);\n"); + OUT("return td->print_struct(td, struct_ptr, ilevel, cb, app_key);\n"); + ); + OUT("}\n"); + OUT("\n"); + + p = MKID(expr->Identifier); + OUT("void\n"); + OUT("%s_free(asn1_TYPE_descriptor_t *td,\n", p); + INDENTED( + OUT("\tvoid *struct_ptr, int contents_only) {\n"); + OUT("inherit_TYPE_descriptor(td);\n"); + OUT("td->free_struct(td, struct_ptr, contents_only);\n"); + ); + OUT("}\n"); + OUT("\n"); + + REDIR(OT_FUNC_DECLS); + + p = MKID(expr->Identifier); + OUT("extern asn1_TYPE_descriptor_t asn1_DEF_%s;\n", p); + OUT("asn_constr_check_f %s_constraint;\n", p); + OUT("ber_type_decoder_f %s_decode_ber;\n", p); + OUT("der_type_encoder_f %s_encode_der;\n", p); + OUT("asn_struct_print_f %s_print;\n", p); + OUT("asn_struct_free_f %s_free;\n", p); + + return 0; +} + +int +asn1c_lang_C_type_EXTENSIBLE(arg_t *arg) { + + OUT("/*\n"); + OUT(" * This type is extensible,\n"); + OUT(" * possible extensions are below.\n"); + OUT(" */\n"); + + return 0; +} + +static int +_print_tag(arg_t *arg, asn1p_expr_t *expr, struct asn1p_type_tag_s *tag_p) { + struct asn1p_type_tag_s tag; + + if(tag_p) { + tag = *tag_p; + } else { + if(asn1f_fetch_tag(arg->asn, arg->mod, expr, &tag)) { + OUT("-1 /* Ambiguous tag (CHOICE?) */"); + return 0; + } + } + + OUT("("); + switch(tag.tag_class) { + case TC_UNIVERSAL: OUT("ASN_TAG_CLASS_UNIVERSAL"); break; + case TC_APPLICATION: OUT("ASN_TAG_CLASS_APPLICATION"); break; + case TC_CONTEXT_SPECIFIC: OUT("ASN_TAG_CLASS_CONTEXT"); break; + case TC_PRIVATE: OUT("ASN_TAG_CLASS_PRIVATE"); break; + case TC_NOCLASS: + break; + } + OUT(" | (%lld << 2))", tag.tag_value); + + return 0; +} + +/* + * For constructed types, number of external tags may be greater than + * number of elements in the type because of CHOICE type. + * T ::= SET { -- Three possible tags: + * a INTEGER, -- One tag is here... + * b Choice1 -- ... and two more tags are there. + * } + * Choice1 ::= CHOICE { + * s1 IA5String, + * s2 ObjectDescriptor + * } + */ +static int +_fill_tag2el_map(arg_t *arg, tag2el_t **tag2el, int *count, int el_no) { + asn1p_expr_t *expr = arg->expr; + arg_t tmparg = *arg; + asn1p_expr_t *v; + int element = 0; + + TQ_FOR(v, &(expr->members), next) { + if(v->expr_type == A1TC_EXTENSIBLE) + continue; + + tmparg.expr = v; + + if(_add_tag2el_member(&tmparg, tag2el, count, + (el_no==-1)?element:el_no)) { + return -1; + } + + element++; + } + + return 0; +} + +static int +_add_tag2el_member(arg_t *arg, tag2el_t **tag2el, int *count, int el_no) { + struct asn1p_type_tag_s tag; + int ret; + + assert(el_no >= 0); + + ret = asn1f_fetch_tag(arg->asn, arg->mod, arg->expr, &tag); + if(ret == 0) { + void *p; + p = realloc(*tag2el, sizeof(tag2el_t) * ((*count) + 1)); + if(p) *tag2el = p; + else return -1; + + DEBUG("Found tag for %s: %ld", + arg->expr->Identifier, + (long)tag.tag_value); + + (*tag2el)[*count].el_tag = tag; + (*tag2el)[*count].el_no = el_no; + (*tag2el)[*count].from_expr = arg->expr; + (*count)++; + return 0; + } + + DEBUG("Searching tag in complex expression %s:%x at line %d", + arg->expr->Identifier, + arg->expr->expr_type, + arg->expr->_lineno); + + /* + * Iterate over members of CHOICE type. + */ + if(arg->expr->expr_type == ASN_CONSTR_CHOICE) { + return _fill_tag2el_map(arg, tag2el, count, el_no); + } + + if(arg->expr->expr_type == A1TC_REFERENCE) { + arg_t tmp = *arg; + asn1p_expr_t *expr; + expr = asn1f_lookup_symbol_ex(tmp.asn, &tmp.mod, tmp.expr, + arg->expr->reference); + if(expr) { + tmp.expr = expr; + return _add_tag2el_member(&tmp, tag2el, count, el_no); + } else { + FATAL("Cannot dereference %s at line %d", + arg->expr->Identifier, + arg->expr->_lineno); + return -1; + } + } + + DEBUG("No tag for %s at line %d", + arg->expr->Identifier, + arg->expr->_lineno); + + return -1; +} + +static int +emit_constraint_checking_code(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_type_e etype; + int size_present, value_present; + + if(expr->constraints == NULL) + return 0; /* No constraints defined */ + + etype = _find_terminal_type(arg); + + size_present = check_constraint_type_presence(expr->constraints, + ACT_CT_SIZE); + value_present = check_constraint_type_presence(expr->constraints, + ACT_EL_VALUE); + + if(size_present || value_present) { + OUT("%s_t *st = sptr;\n", MKID(arg->expr->Identifier)); + if(size_present) { + OUT("size_t size;\n"); + OUT("size_t min_size __attribute__ ((unused)) = %ld;\n", + compute_min_size(arg)); + OUT("size_t max_size __attribute__ ((unused)) = %ld;\n", + compute_max_size(arg)); + } + if(value_present) + switch(etype) { + case ASN_BASIC_INTEGER: + case ASN_BASIC_ENUMERATED: + OUT("long value;\n"); + break; + case ASN_BASIC_BOOLEAN: + OUT("int value;\n"); + break; + default: + break; + } + OUT("\n"); + } + + OUT("if(!sptr) {\n"); + INDENT(+1); + OUT("_ASN_ERRLOG(\"%%s: value not given\", td->name);\n"); + OUT("return -1;\n"); + INDENT(-1); + OUT("}\n"); + OUT("\n"); + + if(size_present) + emit_size_determination_code(arg); + if(value_present) + emit_value_determination_code(arg); + + OUT("\n"); + OUT("if(\n"); + emit_single_constraint_check(arg, expr->constraints, 0); + OUT(") {\n"); + INDENTED(OUT("/* Constraint check succeeded */\n")); + OUT("} else {\n"); + INDENT(+1); + OUT("_ASN_ERRLOG(\"%%s: constraint failed\", td->name);\n"); + OUT("return -1;\n"); + INDENT(-1); + OUT("}\n"); + + return 0; +} + +static int +emit_single_constraint_check(arg_t *arg, asn1p_constraint_t *ct, int mode) { + char *s_v; + int el; + + assert(arg && ct); + + switch(ct->type) { + case ACT_INVALID: + assert(ct->type != ACT_INVALID); + OUT("-1 /* Invalid constraint at line %d */\n", ct->_lineno); + break; + case ACT_EL_VALUE: + OUT("("); + if(mode == ACT_CT_SIZE) s_v = "size"; + else s_v = "value"; + OUT("%s", s_v); + if(ct->value->type != ATV_TRUE) + OUT(" == "); + switch(ct->value->type) { + case ATV_INTEGER: OUT("%lld", + (long long)ct->value->value.v_integer); break; + case ATV_MIN: OUT("min_%s", s_v); break; + case ATV_MAX: OUT("max_%s", s_v); break; + case ATV_FALSE: OUT("0"); break; + case ATV_TRUE: break; + default: + break; + } + OUT(")\n"); + break; + case ACT_EL_RANGE: + case ACT_EL_LLRANGE: + case ACT_EL_RLRANGE: + case ACT_EL_ULRANGE: + if(mode == ACT_CT_SIZE) { + s_v = "size"; + } else { + s_v = "value"; + } + OUT("((%s", s_v); + switch(ct->type) { + case ACT_EL_RANGE: + case ACT_EL_RLRANGE: + OUT(" >= "); break; + case ACT_EL_LLRANGE: + case ACT_EL_ULRANGE: + OUT(" > "); break; + default: break; + } + switch(ct->range_start->type) { + case ATV_INTEGER: OUT("%lld", + (long long)ct->range_start->value.v_integer); break; + case ATV_MIN: OUT("min_%s", s_v); break; + case ATV_MAX: OUT("max_%s", s_v); break; + case ATV_FALSE: OUT("0"); break; + case ATV_TRUE: break; + default: + break; + } + OUT(") && (%s", s_v); + switch(ct->type) { + case ACT_EL_RANGE: + case ACT_EL_LLRANGE: + OUT(" <= "); break; + case ACT_EL_RLRANGE: + case ACT_EL_ULRANGE: + OUT(" < "); break; + default: break; + } + switch(ct->range_stop->type) { + case ATV_INTEGER: OUT("%lld", + (long long)ct->range_stop->value.v_integer); break; + case ATV_MIN: OUT("min_%s", s_v); break; + case ATV_MAX: OUT("max_%s", s_v); break; + case ATV_FALSE: OUT("0"); break; + case ATV_TRUE: break; + default: + break; + } + OUT("))\n"); + break; + case ACT_EL_EXT: + OUT("0 /* Extensible (...), but not defined herein */\n"); + break; + case ACT_CT_SIZE: + if(mode) { + OUT("0 /* Invalid constraint at line %d */\n", + ct->_lineno); + return -1; + } + assert(ct->el_count == 1); + return emit_single_constraint_check(arg, + ct->elements[0], ACT_CT_SIZE); + case ACT_CT_FROM: + if(mode) { + OUT("0 /* Invalid constraint at line %d */\n", + ct->_lineno); + return -1; + } + OUT("check_alphabet_%x(sptr)\n", ct); + break; + case ACT_CT_WCOMP: + case ACT_CT_WCOMPS: + OUT("%d /* Unsupported constraint at line %d */\n", + ct->type, ct->_lineno); + return -1; + break; + case ACT_CA_SET: + OUT("(\n"); + INDENT(+1); + for(el = 0; el < ct->el_count; el++) { + if(el) OUT("&& "); + emit_single_constraint_check(arg, + ct->elements[el], mode); + } + INDENT(-1); + OUT(")\n"); + break; + case ACT_CA_CSV: + OUT("(\n"); + INDENT(+1); + for(el = 0; el < ct->el_count; el++) { + if(el) OUT("|| "); + emit_single_constraint_check(arg, + ct->elements[el], mode); + } + INDENT(-1); + OUT(")\n"); + break; + case ACT_CA_UNI: + OUT("(\n"); + INDENT(+1); + for(el = 0; el < ct->el_count; el++) { + if(el) OUT("|| "); + emit_single_constraint_check(arg, + ct->elements[el], mode); + } + INDENT(-1); + OUT(")\n"); + break; + case ACT_CA_INT: + OUT("(\n"); + INDENT(+1); + for(el = 0; el < ct->el_count; el++) { + if(el) OUT("&& "); + emit_single_constraint_check(arg, + ct->elements[el], mode); + } + INDENT(-1); + OUT(")\n"); + break; + case ACT_CA_CRC: + WARNING("Unsupported component relation constraint at line %d", + ct->_lineno); + OUT("%d /* Unsupported component relation constraint " + "at line %d */\n", + ct->type, ct->_lineno); + return -1; + case ACT_CA_EXC: + WARNING("Unsupported EXCEPT constraint at line %d", + ct->_lineno); + OUT("%d /* Unsupported EXCEPT constraint at line %d */\n", + ct->type, ct->_lineno); + return -1; + } + + return 0; +} + +static int +check_constraint_type_presence(asn1p_constraint_t *ct, enum asn1p_constraint_type_e type) { + int el; + + if(ct == NULL) return 0; + + if(ct->type == type) return 1; + + if(type == ACT_EL_VALUE) { + if(ct->type >= ACT_CT_SIZE + && ct->type <= ACT_CT_WCOMPS) + /* Values defined further + * are not really value's values */ + return 0; + if(ct->type > ACT_EL_VALUE && ct->type < ACT_CT_SIZE) + return 1; /* Also values */ + } + + for(el = 0; el < ct->el_count; el++) { + if(check_constraint_type_presence(ct->elements[el], type)) + return 1; + } + + return 0; +} + +static int +emit_alphabet_tables(arg_t *arg, asn1p_constraint_t *ct, int *table) { + int ch = 0; + int ch_start = 0; + int ch_stop = 0; + int el = 0; + + assert(arg && ct); + + switch(ct->type) { + case ACT_INVALID: + break; + case ACT_EL_VALUE: + if(!table) break; + + switch(ct->value->type) { + case ATV_INTEGER: + if(ct->value->value.v_integer < 0 + || ct->value->value.v_integer > 255) { + OUT("\n"); + OUT("#error Value %lld out of range " + "for alphabet character at line %d\n", + (long long)ct->value->value.v_integer, + ct->_lineno); + break; + } else { + ch = ct->value->value.v_integer; + table[ch] = 1; + } + break; + case ATV_STRING: + for(ch = 0; ch < ct->value->value.string.size; ch++) + table[ct->value->value.string.buf[ch]] = 1; + break; + default: + OUT("\n"); + WARNING("Invalid alphabet character specification " + "at line %d", ct->_lineno); + OUT("#error Invalid alphabet character specification " + "at line %d\n", ct->_lineno); + break; + } + break; + case ACT_EL_RANGE: + case ACT_EL_LLRANGE: + case ACT_EL_RLRANGE: + case ACT_EL_ULRANGE: + if(!table) break; + + ch_start = 0; + ch_stop = 255; + + switch(ct->range_start->type) { + case ATV_INTEGER: + ch_start = ct->range_start->value.v_integer; break; + case ATV_MIN: ch_start = 0; break; + case ATV_MAX: ch_start = 255; break; + case ATV_STRING: + if(ct->range_start->value.string.size == 1) { + ch_start = ct->range_start->value.string.buf[0]; + break; + } + /* Fall through */ + default: + OUT("\n"); + FATAL("Invalid alphabet range constraint " + "at line %d\n", ct->_lineno); + OUT("#error Invalid alphabet range constraint " + "at line %d\n", ct->_lineno); + return -1; + } + + switch(ct->range_stop->type) { + case ATV_INTEGER: + ch_stop = ct->range_stop->value.v_integer; break; + case ATV_MIN: ch_stop = 0; break; + case ATV_MAX: ch_stop = 255; break; + case ATV_STRING: + if(ct->range_stop->value.string.size == 1) { + ch_stop = ct->range_stop->value.string.buf[0]; + break; + } + /* Fall through */ + default: + OUT("\n"); + FATAL("Invalid alphabet range constraint " + "at line %d\n", ct->_lineno); + OUT("#error Invalid alphabet range constraint " + "at line %d\n", ct->_lineno); + break; + } + + switch(ct->type) { + case ACT_EL_RANGE: break; + case ACT_EL_RLRANGE: ch_stop--; break; + case ACT_EL_LLRANGE: ch_start++; break; + case ACT_EL_ULRANGE: ch_start++; ch_stop--; break; + default: break; + } + + if(ch_start > ch_stop) { + WARNING("Empty character range " + "alphabet constraint at line %d", ct->_lineno); + OUT("#warning Empty character range " + "alphabet constraint at line %d\n", ct->_lineno); + break; + } + + for(ch = ch_start; ch <= ch_stop; ch++) { + if(ch < 0 || ch > 255) continue; + table[ch] = 1; + } + + break; + case ACT_EL_EXT: + break; + case ACT_CT_SIZE: + break; + case ACT_CT_FROM: + if(table) { + OUT("#error Nested FROM in subtype constraints\n"); + return -1; + } else { + table = alloca(256 * sizeof(table[0])); + memset(table, 0, 256 * sizeof(table[0])); + + for(el = 0; el < ct->el_count; el++) { + emit_alphabet_tables(arg, ct->elements[el], + table); + } + OUT("static int alphabet_table_%x[256] = {\n", ct); + for(ch = 0; ch < 256; ch++) { + OUT("%d,", table[ch]?1:0); + if(!((ch+1) % 16)) { + if(ch) { + int c; + OUT("\t/* "); + for(c = ch - 16; c < ch; c++) { + if(table[c]) { + if(c > 0x20 + && c < 0x80) + OUT("%c", c); + else + OUT(".", c); + } else { + OUT(" "); + } + } + OUT(" */"); + } + OUT("\n"); + } + } + OUT("};\n"); + OUT("static int check_alphabet_%x(void *sptr) {\n", ct); + INDENT(+1); + OUT("int *table = alphabet_table_%x;\n", ct); + emit_alphabet_check_cycle(arg); + OUT("return 1;\n"); + INDENT(-1); + OUT("};\n"); + } + break; + case ACT_CT_WCOMP: + case ACT_CT_WCOMPS: + break; + case ACT_CA_CRC: + break; + case ACT_CA_SET: + case ACT_CA_CSV: + case ACT_CA_UNI: + for(el = 0; el < ct->el_count; el++) + emit_alphabet_tables(arg, ct->elements[el], table); + break; + case ACT_CA_INT: + if(table) { + int table2[256]; + + assert(ct->el_count >= 1); + emit_alphabet_tables(arg, ct->elements[0], table); + for(el = 1; el < ct->el_count; el++) { + memset(table2, 0, sizeof(table2)); + emit_alphabet_tables(arg, + ct->elements[el], table2); + /* Intersection */ + for(ch = 0; ch < 256; ch++) { + if(table2[ch] == 0) + table[ch] = 0; + } + } + } else { + for(el = 0; el < ct->el_count; el++) + emit_alphabet_tables(arg, ct->elements[el], 0); + } + + break; + case ACT_CA_EXC: + OUT("EXC\n"); + if(table) { + int table2[256]; + + assert(ct->el_count >= 1); + emit_alphabet_tables(arg, ct->elements[0], table); + for(el = 1; el < ct->el_count; el++) { + memset(table2, 0, sizeof(table2)); + emit_alphabet_tables(arg, + ct->elements[el], table2); + /* Exclusion */ + for(ch = 0; ch < 256; ch++) { + if(table2[ch]) + table[ch] = 0; + } + } + } else { + for(el = 0; el < ct->el_count; el++) + emit_alphabet_tables(arg, ct->elements[el], 0); + } + break; + } + + return 0; +} + +static int +emit_alphabet_check_cycle(arg_t *arg) { + asn1p_expr_type_e etype; + + etype = _find_terminal_type(arg); + if(!(etype & ASN_STRING_MASK) + && !(etype == ASN_BASIC_OCTET_STRING)) { + OUT("#error Cannot apply FROM constraint to ASN.1 type %s\n", + ASN_EXPR_TYPE2STR(etype)); + return -1; + } + + OUT("/* The underlying type is %s */\n", + ASN_EXPR_TYPE2STR(etype)); + OUT("%s_t *st = sptr;\n", MKID(arg->expr->Identifier)); + + switch(etype) { + case ASN_STRING_UTF8String: + OUT("uint8_t *ch = st->buf;\n"); + OUT("uint8_t *end = ch + st->size;\n"); + OUT("\n"); + OUT("for(; ch < end; ch++) {\n"); + INDENT(+1); + OUT("if(*ch >= 0x80 || !table[*ch]) return 0;\n"); + INDENT(-1); + OUT("}\n"); + break; + case ASN_STRING_UniversalString: + OUT("uint32_t *ch = st->buf;\n"); + OUT("uint32_t *end = ch + st->size;\n"); + OUT("\n"); + OUT("for(; ch < end; ch++) {\n"); + INDENT(+1); + OUT("uint32_t wc = (((uint8_t *)ch)[0] << 24)\n"); + OUT("\t\t| (((uint8_t *)ch)[1] << 16)\n"); + OUT("\t\t| (((uint8_t *)ch)[2] << 8)\n"); + OUT("\t\t| ((uint8_t *)ch)[3]\n"); + OUT("if(wc > 255 || !table[wc]) return 0;\n"); + INDENT(-1); + OUT("}\n"); + OUT("if(ch != end) return 0; /* (size%4)! */\n"); + break; + case ASN_STRING_BMPString: + OUT("uint16_t *ch = st->buf;\n"); + OUT("uint16_t *end = ch + st->size;\n"); + OUT("\n"); + OUT("for(; ch < end; ch++) {\n"); + INDENT(+1); + OUT("uint16_t wc = (((uint8_t *)ch)[0] << 8)\n"); + OUT("\t\t| ((uint8_t *)ch)[1];\n"); + OUT("if(wc > 255 || !table[wc]) return 0;\n"); + INDENT(-1); + OUT("}\n"); + OUT("if(ch != end) return 0; /* (size%2)! */\n"); + break; + case ASN_BASIC_OCTET_STRING: + default: + OUT("uint8_t *ch = st->buf;\n"); + OUT("uint8_t *end = ch + st->size;\n"); + OUT("\n"); + OUT("for(; ch < end; ch++) {\n"); + INDENT(+1); + OUT("if(!table[*ch]) return 0;\n"); + INDENT(-1); + OUT("}\n"); + break; + } + + return 0; +} + +static int +emit_size_determination_code(arg_t *arg) { + asn1p_expr_type_e etype = _find_terminal_type(arg); + + switch(etype) { + case ASN_BASIC_BIT_STRING: + OUT("if(st->size > 0) {\n"); + OUT("\t/* Size in bits */\n"); + OUT("\tsize = (st->size - 1) - (st->buf[0] & 0x7);\n"); + OUT("} else {\n"); + OUT("\tsize = 0;\n"); + OUT("}\n"); + break; + case ASN_STRING_UniversalString: + OUT("size = st->size >> 2;\t/* 4 byte per character */\n"); + break; + case ASN_STRING_BMPString: + OUT("size = st->size >> 1;\t/* 2 byte per character */\n"); + break; + case ASN_STRING_UTF8String: + OUT("size = UTF8String_length(st, td->name, app_errlog, app_key);\n"); + OUT("if(size == (size_t)-1) return -1;\n"); + break; + default: + if((etype & ASN_STRING_MASK) + || etype == ASN_BASIC_OCTET_STRING) { + OUT("size = st->size;\n"); + break; + } else { + WARNING("Size operation is not defined for %s", + ASN_EXPR_TYPE2STR(etype)); + OUT("#warning Size operation not defined!\n"); + OUT("size = st->size;\n"); + } + return -1; + } + + return 0; +} + +static int +emit_value_determination_code(arg_t *arg) { + asn1p_expr_type_e etype = _find_terminal_type(arg); + + switch(etype) { + case ASN_BASIC_INTEGER: + case ASN_BASIC_ENUMERATED: + OUT("if(asn1_INTEGER2long(st, &value)) {\n"); + INDENT(+1); + OUT("_ASN_ERRLOG(\"%%s: value too large\", td->name);\n"); + OUT("return -1;\n"); + INDENT(-1); + OUT("}\n"); + break; + case ASN_BASIC_BOOLEAN: + OUT("value = st->value;\n"); + break; + default: + WARNING("Value cannot be determined " + "for constraint check for %s at line %d\n", + arg->expr->Identifier, arg->expr->_lineno); + OUT("#error Value cannot be determined for %s at %d\n", + arg->expr->Identifier, arg->expr->_lineno); + break; + } + + return 0; +} + +static long compute_min_size(arg_t *arg) { return compute_xxx_size(arg, 0); } +static long compute_max_size(arg_t *arg) { return compute_xxx_size(arg, 1); } + +static long compute_xxx_size(arg_t *arg, int _max) { + asn1p_expr_type_e etype; + long basic_max = 0x7fffffff; + long basic_min = 0x80000000; + long svalue = 0; + + etype = _find_terminal_type(arg); + switch(etype) { + case ASN_BASIC_BIT_STRING: + svalue = _max?basic_max/8:0; + break; + case ASN_STRING_UTF8String: + svalue = _max?basic_max/6:0; + break; + case ASN_STRING_UniversalString: + svalue = _max?basic_max/4:0; + break; + case ASN_STRING_BMPString: + svalue = _max?basic_max/2:0; + break; + case ASN_BASIC_OCTET_STRING: + svalue = _max?basic_max:0; + break; + default: + if((etype & ASN_STRING_MASK)) { + svalue = _max?basic_max:0; + break; + } + svalue = _max?basic_max:basic_min; + break; + } + + return svalue; +} + +static asn1p_expr_type_e +_find_terminal_type(arg_t *arg) { + asn1p_expr_t *expr; + expr = asn1f_find_terminal_type_ex(arg->asn, arg->mod, arg->expr, NULL); + assert(expr); + return expr->expr_type; +} diff --git a/libasn1compiler/asn1c_C.h b/libasn1compiler/asn1c_C.h new file mode 100644 index 00000000..643d6293 --- /dev/null +++ b/libasn1compiler/asn1c_C.h @@ -0,0 +1,69 @@ +#ifndef ASN1_COMPILER_LANGUAGE_C_H +#define ASN1_COMPILER_LANGUAGE_C_H + +#include "asn1c_lang.h" + +int asn1c_lang_C_type_REFERENCE(arg_t *); +int asn1c_lang_C_type_EXTENSIBLE(arg_t *); + +int asn1c_lang_C_type_SEQUENCE(arg_t *); +int asn1c_lang_C_type_SEQUENCE_OF(arg_t *); +int asn1c_lang_C_type_SET(arg_t *); +int asn1c_lang_C_type_SET_OF(arg_t *); +int asn1c_lang_C_type_CHOICE(arg_t *); + +int asn1c_lang_C_type_INTEGER(arg_t *); +int asn1c_lang_C_type_ENUMERATED(arg_t *); +int asn1c_lang_C_type_SIMPLE_TYPE(arg_t *); + +static asn1_language_map_t asn1_lang_C[] __attribute__ ((unused)) = { + { AMT_TYPE, A1TC_REFERENCE, asn1c_lang_C_type_REFERENCE }, + { AMT_TYPEREF, A1TC_REFERENCE, asn1c_lang_C_type_REFERENCE }, + { AMT_TYPE, A1TC_EXTENSIBLE, asn1c_lang_C_type_EXTENSIBLE }, + /* + * Constructed types + */ + { AMT_TYPE, ASN_CONSTR_SEQUENCE, asn1c_lang_C_type_SEQUENCE }, + { AMT_TYPE, ASN_CONSTR_SEQUENCE_OF, asn1c_lang_C_type_SEQUENCE_OF }, + { AMT_TYPEREF, ASN_CONSTR_SEQUENCE_OF, asn1c_lang_C_type_SEQUENCE_OF }, + { AMT_TYPE, ASN_CONSTR_SET, asn1c_lang_C_type_SET }, + { AMT_TYPE, ASN_CONSTR_SET_OF, asn1c_lang_C_type_SET_OF }, + { AMT_TYPEREF, ASN_CONSTR_SET_OF, asn1c_lang_C_type_SET_OF }, + { AMT_TYPE, ASN_CONSTR_CHOICE, asn1c_lang_C_type_CHOICE }, + /* + * Basic types + */ + { AMT_TYPE, ASN_BASIC_BOOLEAN, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_NULL, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_INTEGER, asn1c_lang_C_type_INTEGER }, + /* [Skipped REAL] */ + { AMT_TYPE, ASN_BASIC_ENUMERATED, asn1c_lang_C_type_ENUMERATED }, + { AMT_TYPE, ASN_BASIC_BIT_STRING, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_OCTET_STRING, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_OBJECT_IDENTIFIER,asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_RELATIVE_OID, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_CHARACTER_STRING, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_UTCTime, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_BASIC_GeneralizedTime, asn1c_lang_C_type_SIMPLE_TYPE }, + /* + * String types + */ + { AMT_TYPE, ASN_STRING_BMPString, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_GeneralString, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_GraphicString, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_IA5String, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_ISO646String, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_NumericString, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_PrintableString,asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_TeletexString, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_T61String, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_UniversalString,asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_UTF8String, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_VideotexString,asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_VisibleString, asn1c_lang_C_type_SIMPLE_TYPE }, + { AMT_TYPE, ASN_STRING_ObjectDescriptor,asn1c_lang_C_type_SIMPLE_TYPE }, + { 0, 0, 0 } +}; + + +#endif /* ASN1_COMPILER_LANGUAGE_C_H */ diff --git a/libasn1compiler/asn1c_internal.h b/libasn1compiler/asn1c_internal.h new file mode 100644 index 00000000..91772cdc --- /dev/null +++ b/libasn1compiler/asn1c_internal.h @@ -0,0 +1,81 @@ +#ifndef _ASN1_COMPILER_INTERNAL_H_ +#define _ASN1_COMPILER_INTERNAL_H_ + +#include +#include +#include /* for fstat(2) */ +#include /* for unlink(2) */ +#include /* for open(2) */ +#include /* for glob(3) */ +#include /* for basename(3) */ +#include +#include /* for isalnum(3) */ +#include +#include +#include + +#include "asn1compiler.h" + +typedef struct arg_s { + + enum asn1c_flags flags; + + void (*logger_cb)(int _severity, const char *fmt, ...); + + int (*default_cb)(struct arg_s *); + + struct compiler_streams *target; + + asn1p_t *asn; + asn1p_module_t *mod; + asn1p_expr_t *expr; + + int indent_level; + int indented; + int embed; +} arg_t; + +#include "asn1c_lang.h" /* Target language initialization */ +#include "asn1c_misc.h" /* Miscellaneous functions */ +#include "asn1c_out.h" /* Handle output during compilation */ +#include "asn1c_save.h" /* Save compiled output */ + +#define INDENT(val) arg->indent_level += (val) +#define INDENTED(code) do { \ + INDENT(+1); \ + do { code; } while(0); \ + INDENT(-1); \ + } while(0) +#define FLAT(code) do { \ + int _il = arg->indent_level; \ + arg->indent_level = 0; \ + do { code; } while(0); \ + arg->indent_level = _il; \ + } while(0) +#define EMBED(ev) do { \ + REDIR(OT_TYPE_DECLS); \ + arg->embed++; \ + INDENTED(arg_t _tmp = *arg; \ + _tmp.expr = ev; \ + _tmp.default_cb(&_tmp); \ + ); \ + arg->embed--; \ + } while(0) +#define OUT(fmt, args...) asn1c_compiled_output(arg, fmt, ##args) + +#define REDIR(foo) do { arg->target->target = foo; } while(0) + +/* + * Logging. + */ +#define LOG(ll, fmt, args...) do { \ + arg->logger_cb(ll, fmt, ##args); \ + } while(0) +#define DEBUG(fmt, args...) do { \ + if(arg->flags & A1C_DEBUG) \ + LOG(-1, fmt, ##args); \ + } while(0) +#define WARNING(fmt, args...) LOG(0, fmt, ##args); +#define FATAL(fmt, args...) LOG(1, fmt, ##args); + +#endif /* _ASN1_COMPILER_INTERNAL_H_ */ diff --git a/libasn1compiler/asn1c_lang.c b/libasn1compiler/asn1c_lang.c new file mode 100644 index 00000000..fa07540a --- /dev/null +++ b/libasn1compiler/asn1c_lang.c @@ -0,0 +1,32 @@ +#include "asn1c_internal.h" +#include "asn1c_C.h" + +asn1_language_map_t asn1_lang_map[AMT_EXPR_META_MAX][ASN_EXPR_TYPE_MAX]; + +int +asn1c_with_language(asn1c_target_language_e lang) { + asn1_language_map_t *lptr; + int lsize; + if(lang != ASN1C_LANGUAGE_C) { + errno = EINVAL; + return -1; + } + + lptr = asn1_lang_C; + lsize = sizeof(asn1_lang_C)/sizeof(asn1_lang_C[0]); + + memset(asn1_lang_map, 0, sizeof(asn1_lang_map)); + + for(; lsize && lptr->expr_match; lsize--, lptr++) { + assert(lptr->meta_match > 0); + assert(lptr->meta_match < AMT_EXPR_META_MAX); + assert(lptr->expr_match > 0); + assert(lptr->expr_match < ASN_EXPR_TYPE_MAX); + + asn1_lang_map[lptr->meta_match][lptr->expr_match] + = *lptr; + } + + return 0; +} + diff --git a/libasn1compiler/asn1c_lang.h b/libasn1compiler/asn1c_lang.h new file mode 100644 index 00000000..8c9a6ea7 --- /dev/null +++ b/libasn1compiler/asn1c_lang.h @@ -0,0 +1,28 @@ +#ifndef ASN1_COMPILER_LANGUAGE_H +#define ASN1_COMPILER_LANGUAGE_H + +struct arg_s; + +typedef struct asn1_language_map_s { + asn1p_expr_meta_e meta_match; /* meta_type */ + asn1p_expr_type_e expr_match; /* expr_type */ + /* + * A callback that would create a language-specific type declaration. + */ + int (*type_cb)(struct arg_s *arg); +} asn1_language_map_t; + + +extern asn1_language_map_t asn1_lang_map[AMT_EXPR_META_MAX][ASN_EXPR_TYPE_MAX]; + + +typedef enum asn1c_target_language { + ASN1C_LANGUAGE_C, +} asn1c_target_language_e; + +/* + * Initialize the compiler to generate specified target language. + */ +int asn1c_with_language(asn1c_target_language_e lang); + +#endif /* ASN1_COMPILER_LANGUAGE_H */ diff --git a/libasn1compiler/asn1c_misc.c b/libasn1compiler/asn1c_misc.c new file mode 100644 index 00000000..b464b64c --- /dev/null +++ b/libasn1compiler/asn1c_misc.c @@ -0,0 +1,232 @@ +#include "asn1c_internal.h" +#include + +#ifndef DEFFILEMODE /* Normally in */ +#define DEFFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) +#endif + +/* + * Construct identifier from multiple parts. + * Convert unsafe characters to underscores. + */ +char * +asn1c_make_identifier(int unsafe_only_spaces, char *arg1, ...) { + static char *storage; + static int storage_size; + int nodelimiter = 0; + va_list ap; + char *str; + int size; + char *p; + + if(arg1 == NULL) + return NULL; + + /* + * Estimate the necessary storage size + */ + size = strlen(arg1); + va_start(ap, arg1); + while((str = va_arg(ap, char *))) + size += 1 + strlen(str); + va_end(ap); + + /* + * Make sure we have this amount of storage. + */ + if(storage_size <= size) { + if(storage) free(storage); + storage = malloc(size + 1); + if(storage) { + storage_size = size; + } else { + storage_size = 0; + return NULL; + } + } + + /* + * Fill-in the storage. + */ + va_start(ap, arg1); + str = arg1; + p = storage; + for(str = arg1; str; str = va_arg(ap, char *)) { + int subst_made = 0; + + if(str[0] == ' ' && str[1] == '\0') { + *p++ = ' '; + nodelimiter = 1; /* No delimiter */ + continue; + } + + if(str != arg1 && !nodelimiter) + *p++ = '_'; /* Delimiter between tokens */ + nodelimiter = 0; + + for(; *str; str++) { + if(isalnum(*str)) { + *p++ = *str; + subst_made = 0; + } else if(!subst_made++) { + if(unsafe_only_spaces && !isspace(*str)) { + *p ++ = *str; + } else { + *p++ = '_'; + } + } + } + } + va_end(ap); + *p = '\0'; + + assert((p - storage) <= storage_size); + + return storage; +} + +FILE * +asn1c_open_file(arg_t *arg, const char *name, const char *ext) { + int created = 1; + struct stat sb; + char *fname; + int len; + FILE *fp; + int fd; + + /* + * Compute filenames. + */ + len = strlen(name) + strlen(ext) + 1; + fname = alloca(len); + snprintf(fname, len, "%s%s", name, ext); + + /* + * Create files. + */ + fd = open(fname, O_CREAT | O_EXCL | O_WRONLY, DEFFILEMODE); + if(fd == -1 && errno == EEXIST) { + fd = open(fname, O_WRONLY, DEFFILEMODE); + created = 0; + } + if(fd == -1) { + perror(fname); + return NULL; + } + + /* + * Check sanity. + */ + if(fstat(fd, &sb) || !S_ISREG(sb.st_mode)) { + fprintf(stderr, "%s: Not a regular file\n", fname); + if(created) unlink(fname); + close(fd); + return NULL; + } + + (void)ftruncate(fd, 0); + + /* + * Convert file descriptor into file pointer. + */ + fp = fdopen(fd, "w"); + if(fp == NULL) { + if(created) unlink(fname); + close(fd); + } + return fp; +} + +char * +asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format) { + char *typename; + + switch(expr->expr_type) { + case A1TC_REFERENCE: + typename = expr->reference->components[ + expr->reference->comp_count-1].name; + if(typename[0] == '&') { + arg_t tmp = *arg; + + /* + * This is a reference to a type defined in a class. + * Resolve it and use instead. + */ + tmp.expr = asn1f_class_access_ex(arg->asn, arg->mod, + arg->expr, expr->reference, &tmp.mod); + if(tmp.expr) return NULL; + + return asn1c_type_name(&tmp, tmp.expr, _format); + } else if(_format == TNF_RSAFE) { + /* + * The recursion-safe format is requested. + * The problem here is that only constructed types + * might be referenced with "struct". + * Change RSAFE to CTYPE if the terminal type + * is primitive. + */ + asn1p_expr_t *terminal; + terminal = asn1f_find_terminal_type_ex( + arg->asn, arg->mod, arg->expr, NULL); + if(terminal + && (terminal->expr_type + & (ASN_BASIC_MASK | ASN_STRING_MASK))) + _format = TNF_CTYPE; + } + break; + case ASN_CONSTR_SEQUENCE_OF: + case ASN_CONSTR_SET_OF: + if(expr->Identifier) { + typename = expr->Identifier; + } else { + asn1p_expr_t *child; + child = TQ_FIRST(&(expr->members)); + typename = asn1c_type_name(arg, child, _format); + if(typename) + return typename; + _format = TNF_SAFE; + typename = child->Identifier; + } + break; + case ASN_BASIC_INTEGER: + case ASN_BASIC_ENUMERATED: + if((arg->flags & A1C_USE_NATIVE_INTEGERS)) { + switch(_format) { + case TNF_CTYPE: + case TNF_RSAFE: + return "int"; + default: + if(expr->expr_type == ASN_BASIC_INTEGER) + return "NativeInteger"; + else + return "NativeEnumerated"; + } + } + /* Fall through */ + default: + if(expr->expr_type & (ASN_BASIC_MASK | ASN_STRING_MASK)) { + if(_format == TNF_RSAFE) + _format = TNF_CTYPE; + typename = ASN_EXPR_TYPE2STR(expr->expr_type); + } else { + _format = TNF_SAFE; + typename = expr->Identifier; + } + } + + switch(_format) { + case TNF_UNMODIFIED: + case TNF_INCLUDE: + return asn1c_make_identifier(1, typename, 0); + case TNF_SAFE: + return asn1c_make_identifier(0, typename, 0); + case TNF_CTYPE: + return asn1c_make_identifier(0, typename, "t", 0); + case TNF_RSAFE: + return asn1c_make_identifier(0, "struct", " ", typename, 0); + } + + assert("!unreachable"); + return typename; +} + diff --git a/libasn1compiler/asn1c_misc.h b/libasn1compiler/asn1c_misc.h new file mode 100644 index 00000000..2f82b0b6 --- /dev/null +++ b/libasn1compiler/asn1c_misc.h @@ -0,0 +1,28 @@ +#ifndef _ASN1_COMPILER_MISC_H_ +#define _ASN1_COMPILER_MISC_H_ + +/* + * Make the target language identifier out of one or more names. + * The function will concatenate the names and replace unsafe characters + * with safe ones. + */ +char *asn1c_make_identifier(int unsafe_only_spaces, char *arg1, ...); + +/* + * Return the type name of the specified expression. + */ +enum tnfmt { + TNF_UNMODIFIED, /* Return unmodified type name */ + TNF_INCLUDE, /* Format for #include <> */ + TNF_CTYPE, /* Format as normal C-ish type (append "_t") */ + TNF_SAFE, /* Replace unsafe characters with _ */ + TNF_RSAFE, /* Recursion-safe C type format */ +}; +char *asn1c_type_name(arg_t *arg, asn1p_expr_t *expr, enum tnfmt _format); + +/* + * Open the arbitrary file by its base name and extension. + */ +FILE *asn1c_open_file(arg_t *arg, const char *base_part, const char *extension); + +#endif /* _ASN1_COMPILER_MISC_H_ */ diff --git a/libasn1compiler/asn1c_out.c b/libasn1compiler/asn1c_out.c new file mode 100644 index 00000000..a6432418 --- /dev/null +++ b/libasn1compiler/asn1c_out.c @@ -0,0 +1,75 @@ +#include "asn1c_internal.h" + +/* + * Add an elementary chunk of target language text + * into appropriate output stream. + */ +int +asn1c_compiled_output(arg_t *arg, const char *fmt, ...) { + const char *p; + int lf_found; + va_list ap; + out_chunk_t *m; + char *buf; + int ret; + + /* + * Make sure the output has a single LF and only at the end. + */ + for(lf_found = 0, p = fmt; *p; p++) { + if(*p == '\n') { + lf_found++; + assert(p[1] == '\0'); + } + } + assert(lf_found <= 1); + + /* + * Print out the indentation. + */ + if(arg->indented == 0) { + int i = arg->indent_level; + arg->indented = 1; + while(i--) { + ret = asn1c_compiled_output(arg, "\t"); + if(ret == -1) return -1; + } + } + + /* + * Estimate necessary size. + */ + buf = ""; + va_start(ap, fmt); + ret = vsnprintf(buf, 0, fmt, ap); + va_end(ap); + assert(ret >= 0); + + /* + * Allocate buffer. + */ + m = calloc(1, sizeof(out_chunk_t)); + if(m == NULL) return -1; + m->len = ret + 1; + m->buf = malloc(ret + 1); + if(m->buf == NULL) { + free(m); + return -1; + } + + /* + * Fill the buffer. + */ + va_start(ap, fmt); + ret = vsnprintf(m->buf, m->len, fmt, ap); + assert(ret < m->len); + m->len = ret; + va_end(ap); + + TQ_ADD(&(arg->target->targets[arg->target->target]), m, next); + + if(lf_found) + arg->indented = 0; + + return 0; +} diff --git a/libasn1compiler/asn1c_out.h b/libasn1compiler/asn1c_out.h new file mode 100644 index 00000000..2267d5db --- /dev/null +++ b/libasn1compiler/asn1c_out.h @@ -0,0 +1,31 @@ +#ifndef _ASN1_COMPILED_OUTPUT_H_ +#define _ASN1_COMPILED_OUTPUT_H_ + +/* + * An elementary chunk of target language text. + */ +typedef struct out_chunk { + char *buf; + int len; + + TQ_ENTRY(struct out_chunk) next; +} out_chunk_t; + +typedef struct compiler_streams { + enum { + OT_DEPS, /* Dependencies */ + OT_TYPE_DECLS, /* Type declarations */ + OT_FUNC_DECLS, /* Function declarations */ + OT_STAT_DEFS, /* Static definitions */ + OT_CODE, /* Some code */ + OT_MAX + } target; + TQ_HEAD(out_chunk_t) targets[OT_MAX]; +} compiler_streams_t; + +static char *_compiler_stream2str[] __attribute__ ((unused)) + = { "DEPS", "TYPE-DECLS", "FUNC-DECLS", "STAT-DEFS", "CODE" }; + +int asn1c_compiled_output(arg_t *arg, const char *fmt, ...); + +#endif /* _ASN1_COMPILED_OUTPUT_H_ */ diff --git a/libasn1compiler/asn1c_save.c b/libasn1compiler/asn1c_save.c new file mode 100644 index 00000000..0e5b0fbc --- /dev/null +++ b/libasn1compiler/asn1c_save.c @@ -0,0 +1,225 @@ +#include "asn1c_internal.h" + +static int asn1c_dump_streams(arg_t *arg); +static int asn1c_print_streams(arg_t *arg); +static int asn1c_save_streams(arg_t *arg); +static int asn1c_copy_over(arg_t *arg, char *path); + +int +asn1c_save_compiled_output(arg_t *arg, const char *datadir) { + + (void)datadir; + + TQ_FOR(arg->mod, &(arg->asn->modules), mod_next) { + TQ_FOR(arg->expr, &(arg->mod->members), next) { + if(asn1_lang_map[arg->expr->meta_type] + [arg->expr->expr_type].type_cb) { + if(asn1c_dump_streams(arg)) + return -1; + } + } + } + + /* + * Dump out the Makefile template and the rest of the support code. + */ + if((arg->flags & A1C_PRINT_COMPILED) == 0 + && (arg->flags & A1C_OMIT_SUPPORT_CODE) == 0) { + glob_t pg; + FILE *mkf; + char *p; + int i; + + i = strlen(datadir) + sizeof("/*.[ch]"); + p = alloca(i); + snprintf(p, i, "%s/*.[ch]", datadir); + + memset(&pg, 0, sizeof(pg)); + if(glob(p, GLOB_ERR +#ifdef GLOB_TILDE + | GLOB_TILDE +#endif /* GLOB_TILDE */ + , NULL, &pg)) { + fprintf(stderr, + "Bad skeletons directory (-S) %s: %s\n", + datadir, strerror(errno)); + return -1; + } + + mkf = asn1c_open_file(arg, "Makefile.am", ".sample"); + if(mkf == NULL) { + globfree(&pg); + perror("Makefile.am.sample"); + return -1; + } + + fprintf(mkf, "ASN_SRCS="); + TQ_FOR(arg->mod, &(arg->asn->modules), mod_next) { + TQ_FOR(arg->expr, &(arg->mod->members), next) { + if(asn1_lang_map[arg->expr->meta_type] + [arg->expr->expr_type].type_cb) { + fprintf(mkf, "\t\\\n\t%s.c %s.h", + arg->expr->Identifier, + arg->expr->Identifier); + } + } + } + + for(i = 0; i < pg.gl_pathc; i++) { + if(asn1c_copy_over(arg, pg.gl_pathv[i])) { + fprintf(mkf, ">>>ABORTED<<<"); + fclose(mkf); + globfree(&pg); + return -1; + } else { + fprintf(mkf, "\t\\\n\t%s", + basename(pg.gl_pathv[i])); + } + } + + fprintf(mkf, "\n\n"); + fprintf(mkf, "lib_LTLIBRARIES=libsomething.la\n"); + fprintf(mkf, "libsomething_la_SOURCES=${ASN_SRCS}\n"); + fclose(mkf); + fprintf(stderr, "Generated Makefile.am.sample\n"); + globfree(&pg); + } + + return 0; +} + +/* + * Dump the streams. + */ +static int +asn1c_dump_streams(arg_t *arg) { + if(arg->flags & A1C_PRINT_COMPILED) { + return asn1c_print_streams(arg); + } else { + return asn1c_save_streams(arg); + } +} + +static int +asn1c_print_streams(arg_t *arg) { + compiler_streams_t *cs = arg->expr->data; + asn1p_expr_t *expr = arg->expr; + int i; + + for(i = 0; i < OT_MAX; i++) { + out_chunk_t *ot; + if(TQ_FIRST(&cs->targets[i]) == NULL) + continue; + + printf("\n/*** <<< %s [%s] >>> ***/\n\n", + _compiler_stream2str[i], + expr->Identifier); + + TQ_FOR(ot, &(cs->targets[i]), next) { + fwrite(ot->buf, ot->len, 1, stdout); + } + } + + return 0; +} + +static int +asn1c_save_streams(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + compiler_streams_t *cs = expr->data; + out_chunk_t *ot; + FILE *fp_c, *fp_h; + char *header_id; + + if(cs == NULL) { + fprintf(stderr, "Cannot compile %s at line %d\n", + expr->Identifier, expr->_lineno); + return -1; + } + + fp_c = asn1c_open_file(arg, expr->Identifier, ".c"); + fp_h = asn1c_open_file(arg, expr->Identifier, ".h"); + if(fp_c == NULL || fp_h == NULL) { + if(fp_c) fclose(fp_c); /* lacks unlink() */ + if(fp_h) fclose(fp_h); /* lacks unlink() */ + return -1; + } + + header_id = alloca(strlen(expr->Identifier) + 1); + if(1) { + char *src, *dst; + for(src = expr->Identifier, dst = header_id; + (*dst=*src); src++, dst++) + if(!isalnum(*src)) *dst = '_'; + *dst = '\0'; + } + + fprintf(fp_h, + "#ifndef\t_%s_H_\n" + "#define\t_%s_H_\n" + "\n", header_id, header_id); + + fprintf(fp_h, "#include \n\n"); + + TQ_FOR(ot, &(cs->targets[OT_DEPS]), next) + fwrite(ot->buf, ot->len, 1, fp_h); + fprintf(fp_h, "\n"); + TQ_FOR(ot, &(cs->targets[OT_TYPE_DECLS]), next) + fwrite(ot->buf, ot->len, 1, fp_h); + fprintf(fp_h, "\n"); + TQ_FOR(ot, &(cs->targets[OT_FUNC_DECLS]), next) + fwrite(ot->buf, ot->len, 1, fp_h); + + fprintf(fp_c, "#include <%s.h>\n\n", expr->Identifier); + TQ_FOR(ot, &(cs->targets[OT_STAT_DEFS]), next) + fwrite(ot->buf, ot->len, 1, fp_c); + TQ_FOR(ot, &(cs->targets[OT_CODE]), next) + fwrite(ot->buf, ot->len, 1, fp_c); + + assert(OT_MAX == 5); + + fprintf(fp_h, "\n#endif\t/* _%s_H_ */\n", header_id); + + fclose(fp_c); + fclose(fp_h); + fprintf(stderr, "Compiled %s.c\n", expr->Identifier); + fprintf(stderr, "Compiled %s.h\n", expr->Identifier); + return 0; +} + +static int +asn1c_copy_over(arg_t *arg, char *path) { + char *fname = basename(path); + + if(symlink(path, fname)) { + if(errno == EEXIST) { + struct stat sb1, sb2; + if(stat(path, &sb1) == 0 + && stat(fname, &sb2) == 0 + && sb1.st_dev == sb2.st_dev + && sb1.st_ino == sb2.st_ino) { + /* + * Nothing to do. + */ + fprintf(stderr, + "File %s is already here as %s\n", + path, fname); + return 0; + } else { + fprintf(stderr, + "Retaining local %s (%s suggested)\n", + fname, path); + return 0; + } + } else { + fprintf(stderr, "Symlink %s -> %s failed: %s\n", + path, fname, strerror(errno)); + return -1; + } + } + + fprintf(stderr, "Symlinked %s\t-> %s\n", path, fname); + + return 0; +} + diff --git a/libasn1compiler/asn1c_save.h b/libasn1compiler/asn1c_save.h new file mode 100644 index 00000000..487e625b --- /dev/null +++ b/libasn1compiler/asn1c_save.h @@ -0,0 +1,6 @@ +#ifndef _ASN1_SAVE_H_ +#define _ASN1_SAVE_H_ + +int asn1c_save_compiled_output(arg_t *arg, const char *datadir); + +#endif /* _ASN1_SAVE_H_ */ diff --git a/libasn1compiler/asn1compiler.c b/libasn1compiler/asn1compiler.c new file mode 100644 index 00000000..d647c05b --- /dev/null +++ b/libasn1compiler/asn1compiler.c @@ -0,0 +1,160 @@ +#include "asn1c_internal.h" + +static void default_logger_cb(int, const char *fmt, ...); +static int asn1c_compile_expr(arg_t *arg); +static int asn1c_attach_streams(asn1p_expr_t *expr); + +int +asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags) { + arg_t arg_s; + arg_t *arg = &arg_s; + int ret; + + /* + * Initialize target language. + */ + ret = asn1c_with_language(ASN1C_LANGUAGE_C); + assert(ret == 0); + + memset(arg, 0, sizeof(*arg)); + arg->default_cb = asn1c_compile_expr; + arg->logger_cb = default_logger_cb; + arg->flags = flags; + arg->asn = asn; + + /* + * Compile each individual top level structure. + */ + TQ_FOR(arg->mod, &(asn->modules), mod_next) { + TQ_FOR(arg->expr, &(arg->mod->members), next) { + compiler_streams_t *cs = NULL; + + if(asn1c_attach_streams(arg->expr)) + return -1; + + cs = arg->expr->data; + cs->target = OT_TYPE_DECLS; + arg->target = cs; + + ret = asn1c_compile_expr(arg); + if(ret) { + FATAL("Cannot compile %s (%x:%x) at line %d", + arg->expr->Identifier, + arg->expr->expr_type, + arg->expr->meta_type, + arg->expr->_lineno); + return ret; + } + } + } + + DEBUG("Saving compiled data"); + + /* + * Save or print out the compiled result. + */ + if(asn1c_save_compiled_output(arg, datadir)) + return -1; + + return 0; +} + +static int +asn1c_compile_expr(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + int (*type_cb)(arg_t *); + int ret; + + assert(expr->meta_type >= AMT_INVALID); + assert(expr->meta_type < AMT_EXPR_META_MAX); + assert(expr->expr_type >= A1TC_INVALID); + assert(expr->expr_type < ASN_EXPR_TYPE_MAX); + + type_cb = asn1_lang_map[expr->meta_type][expr->expr_type].type_cb; + if(type_cb) { + + if(arg->indent_level == 0) + OUT("\n"); + + DEBUG("Compiling %s at line %d", + expr->Identifier, + expr->_lineno); + + ret = type_cb(arg); + } else { + ret = -1; + /* + * Even if the target language compiler does not know + * how to compile the given expression, we know that + * certain expressions need not to be compiled at all. + */ + switch(expr->meta_type) { + case AMT_PARAMTYPE: + case AMT_OBJECT: + case AMT_OBJECTSET: + case AMT_VALUE: + case AMT_VALUESET: + ret = 0; + break; + default: + break; + } + + switch(expr->expr_type) { + case A1TC_TYPEID: + ret = 0; /* TYPE-IDENTIFIER is a CLASS */ + default: + break; + } + } + + if(ret == -1) { + OUT("#error Cannot compile \"%s\" (%x/%x) at line %d\n", + arg->expr->Identifier, + arg->expr->meta_type, + arg->expr->expr_type, + arg->expr->_lineno + ); + } + + return ret; +} + +static int +asn1c_attach_streams(asn1p_expr_t *expr) { + compiler_streams_t *cs; + int i; + + if(expr->data) + return 0; /* Already attached? */ + + expr->data = calloc(1, sizeof(compiler_streams_t)); + if(expr->data == NULL) + return -1; + + cs = expr->data; + for(i = 0; i < OT_MAX; i++) { + TQ_INIT(&(cs->targets[i])); + } + + return 0; +} + +static void +default_logger_cb(int _severity, const char *fmt, ...) { + va_list ap; + char *pfx = ""; + + switch(_severity) { + case -1: pfx = "DEBUG: "; break; + case 0: pfx = "WARNING: "; break; + case 1: pfx = "FATAL: "; break; + } + + fprintf(stderr, "%s", pfx); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +} + diff --git a/libasn1compiler/asn1compiler.h b/libasn1compiler/asn1compiler.h new file mode 100644 index 00000000..d104dc9a --- /dev/null +++ b/libasn1compiler/asn1compiler.h @@ -0,0 +1,41 @@ +#ifndef ASN1_COMPILER_H +#define ASN1_COMPILER_H + +#include + +enum asn1c_flags { + A1C_NOFLAGS, + /* + * Debug the compiler. + */ + A1C_DEBUG = 0x0001, + /* + * Do not split the target output in several files, just print it. + * (Note: the output is not likely to be compilable in this case). + */ + A1C_PRINT_COMPILED = 0x0002, + /* + * Generate only the tables for ASN.1 types, + * do not emit ASN.1 parsing support code. + */ + A1C_OMIT_SUPPORT_CODE = 0x0004, + /* + * Use native integers instead of INTEGER_t and ENUMERATED_t types. + */ + A1C_USE_NATIVE_INTEGERS = 0x0008, + /* + * Do not use C99 extensions. + */ + A1C_NO_C99 = 0x0010, + /* + * Enable use of unnamed unions (non-portable feature). + */ + A1C_UNNAMED_UNIONS = 0x0020, +}; + +/* + * Compile the ASN.1 specification. + */ +int asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags); + +#endif /* ASN1_COMPILER_H */ diff --git a/libasn1compiler/check_compiler.c b/libasn1compiler/check_compiler.c new file mode 100644 index 00000000..1da6902f --- /dev/null +++ b/libasn1compiler/check_compiler.c @@ -0,0 +1,7 @@ +#include "asn1compiler.h" + +int +main(int ac, char **av) { + return 0; +} + diff --git a/libasn1fix/Makefile.am b/libasn1fix/Makefile.am new file mode 100644 index 00000000..0e52b4f3 --- /dev/null +++ b/libasn1fix/Makefile.am @@ -0,0 +1,36 @@ + + +AM_CFLAGS = @ADD_CFLAGS@ +AM_CPPFLAGS = -I${top_srcdir}/libasn1parser + +noinst_LTLIBRARIES = libasn1fix.la + +libasn1fix_la_LDFLAGS = -all-static +libasn1fix_la_SOURCES = \ + asn1fix.c asn1fix.h \ + asn1fix_internal.h \ + asn1fix_misc.c asn1fix_misc.h \ + asn1fix_value.c asn1fix_value.h \ + asn1fix_compat.c asn1fix_compat.h \ + asn1fix_constr.c asn1fix_constr.h \ + asn1fix_cstring.c asn1fix_cstring.h \ + asn1fix_retrieve.c asn1fix_retrieve.h \ + asn1fix_bitstring.c asn1fix_bitstring.h \ + asn1fix_integer.c asn1fix_integer.h \ + asn1fix_dereft.c asn1fix_dereft.h \ + asn1fix_derefv.c asn1fix_derefv.h \ + asn1fix_export.c asn1fix_export.h \ + asn1fix_param.c asn1fix_param.h \ + asn1fix_class.c asn1fix_class.h \ + asn1fix_tags.c asn1fix_tags.h \ + asn1fix_enum.c asn1fix_enum.h +libasn1fix_la_LIBADD = ${top_builddir}/libasn1parser/libasn1parser.la + +check_PROGRAMS = check_fixer + +LDADD = ${noinst_LTLIBRARIES} ${libasn1fix_la_LIBADD} +DEPENDENCIES = ${LDADD} + +TESTS_ENVIRONMENT= ./check_fixer +TESTS = ${top_srcdir}/tests/*.asn1 +## TESTS = ${check_PROGRAMS} # This is an alternate form of testing diff --git a/libasn1fix/Makefile.in b/libasn1fix/Makefile.in new file mode 100644 index 00000000..8d919c20 --- /dev/null +++ b/libasn1fix/Makefile.in @@ -0,0 +1,454 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +AM_CFLAGS = @ADD_CFLAGS@ +AM_CPPFLAGS = -I${top_srcdir}/libasn1parser + +noinst_LTLIBRARIES = libasn1fix.la + +libasn1fix_la_LDFLAGS = -all-static +libasn1fix_la_SOURCES = \ + asn1fix.c asn1fix.h \ + asn1fix_internal.h \ + asn1fix_misc.c asn1fix_misc.h \ + asn1fix_value.c asn1fix_value.h \ + asn1fix_compat.c asn1fix_compat.h \ + asn1fix_constr.c asn1fix_constr.h \ + asn1fix_cstring.c asn1fix_cstring.h \ + asn1fix_retrieve.c asn1fix_retrieve.h \ + asn1fix_bitstring.c asn1fix_bitstring.h \ + asn1fix_integer.c asn1fix_integer.h \ + asn1fix_dereft.c asn1fix_dereft.h \ + asn1fix_derefv.c asn1fix_derefv.h \ + asn1fix_export.c asn1fix_export.h \ + asn1fix_param.c asn1fix_param.h \ + asn1fix_class.c asn1fix_class.h \ + asn1fix_tags.c asn1fix_tags.h \ + asn1fix_enum.c asn1fix_enum.h + +libasn1fix_la_LIBADD = ${top_builddir}/libasn1parser/libasn1parser.la + +check_PROGRAMS = check_fixer + +LDADD = ${noinst_LTLIBRARIES} ${libasn1fix_la_LIBADD} +DEPENDENCIES = ${LDADD} + +TESTS_ENVIRONMENT = ./check_fixer +TESTS = ${top_srcdir}/tests/*.asn1 +subdir = libasn1fix +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) + +libasn1fix_la_DEPENDENCIES = \ + ${top_builddir}/libasn1parser/libasn1parser.la +am_libasn1fix_la_OBJECTS = asn1fix.lo asn1fix_misc.lo asn1fix_value.lo \ + asn1fix_compat.lo asn1fix_constr.lo asn1fix_cstring.lo \ + asn1fix_retrieve.lo asn1fix_bitstring.lo asn1fix_integer.lo \ + asn1fix_dereft.lo asn1fix_derefv.lo asn1fix_export.lo \ + asn1fix_param.lo asn1fix_class.lo asn1fix_tags.lo \ + asn1fix_enum.lo +libasn1fix_la_OBJECTS = $(am_libasn1fix_la_OBJECTS) +check_PROGRAMS = check_fixer$(EXEEXT) +check_fixer_SOURCES = check_fixer.c +check_fixer_OBJECTS = check_fixer.$(OBJEXT) +check_fixer_LDADD = $(LDADD) +check_fixer_DEPENDENCIES = libasn1fix.la \ + ${top_builddir}/libasn1parser/libasn1parser.la +check_fixer_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/asn1fix.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_bitstring.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_class.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_compat.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_constr.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_cstring.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_dereft.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_derefv.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_enum.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_export.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_integer.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_misc.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_param.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_retrieve.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_tags.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1fix_value.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/check_fixer.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = $(libasn1fix_la_SOURCES) check_fixer.c +DIST_COMMON = Makefile.am Makefile.in +SOURCES = $(libasn1fix_la_SOURCES) check_fixer.c + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu libasn1fix/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) +libasn1fix.la: $(libasn1fix_la_OBJECTS) $(libasn1fix_la_DEPENDENCIES) + $(LINK) $(libasn1fix_la_LDFLAGS) $(libasn1fix_la_OBJECTS) $(libasn1fix_la_LIBADD) $(LIBS) + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +check_fixer$(EXEEXT): $(check_fixer_OBJECTS) $(check_fixer_DEPENDENCIES) + @rm -f check_fixer$(EXEEXT) + $(LINK) $(check_fixer_LDFLAGS) $(check_fixer_OBJECTS) $(check_fixer_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_bitstring.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_class.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_compat.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_constr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_cstring.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_dereft.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_derefv.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_enum.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_export.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_integer.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_misc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_param.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_retrieve.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_tags.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1fix_value.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/check_fixer.Po@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ +uninstall-info-am: + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(LTLIBRARIES) + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES distclean distclean-compile \ + distclean-depend distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + tags uninstall uninstall-am uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libasn1fix/asn1fix.c b/libasn1fix/asn1fix.c new file mode 100644 index 00000000..af110999 --- /dev/null +++ b/libasn1fix/asn1fix.c @@ -0,0 +1,354 @@ +#include +#include +#include +#include + +#include "asn1fix.h" +#include "asn1fix_internal.h" + +/* Print everything to stderr */ +static void _default_error_logger(int _severity, const char *fmt, ...); + +/* + * Internal check functions. + */ +static int asn1f_fix_module(arg_t *arg); +static int asn1f_fix_simple(arg_t *arg); /* For INTEGER/ENUMERATED */ +static int asn1f_fix_constructed(arg_t *arg); /* For SEQUENCE/SET/CHOICE */ +static int asn1f_fix_constraints(arg_t *arg); /* For subtype constraints */ + + +/* + * Scan every module defined here in search for inconsistences. + */ +int +asn1f_process(asn1p_t *asn, enum asn1f_flags flags, + error_logger_f error_logger) { + arg_t arg; + int fatals = 0; + int warnings = 0; + + /* + * Check validity of arguments. + */ + if(asn == NULL) { + errno = EINVAL; + return -1; + } + + /* + * If errors handler is not specified, default to internal one. + */ + if(error_logger == 0) { + error_logger = _default_error_logger; + } + + memset(&arg, 0, sizeof(arg)); + arg.asn = asn; + arg.eh = error_logger; + + if(flags & A1F_DEBUG) { + arg.debug = arg.eh; + arg.debug(-1, "Called %s() with flags %d", __func__, flags); + flags &= ~A1F_DEBUG; + } + + /* + * Check that we haven't missed an unknown flag. + */ + if(flags) { + errno = EINVAL; + return -1; + } + + /* + * Process each module in the list. + */ + TQ_FOR(arg.mod, &(asn->modules), mod_next) { + int ret = asn1f_fix_module(&arg); + /* + * These lines are used for illustration purposes. + * RET2RVAL() is used everywhere else. + */ + if(ret == -1) fatals++; + if(ret == 1) warnings++; + } + + /* + * Compute a return value. + */ + return fatals?-1:warnings?1:0; +} + +/* + * Check the internals of a single module. + */ +static int +asn1f_fix_module(arg_t *arg) { + asn1p_expr_t *expr; + int rvalue = 0; + + switch((arg->mod->module_flags + & (MSF_EXPLICIT_TAGS | MSF_IMPLICIT_TAGS | MSF_AUTOMATIC_TAGS))) { + case MSF_NOFLAGS: + case MSF_EXPLICIT_TAGS: + case MSF_IMPLICIT_TAGS: + case MSF_AUTOMATIC_TAGS: + break; + default: + FATAL("Module %s defined with ambiguous global tagging mode", + arg->mod->Identifier); + RET2RVAL(-1, rvalue); + } + + /* + * Do various non-recursive transformations. + * Order is not important. + */ + TQ_FOR(expr, &(arg->mod->members), next) { + int ret; + arg->expr = expr; + + if(expr->meta_type == AMT_PARAMTYPE) + /* Do not process the parametrized type just yet */ + continue; + + DEBUG("=== Now processing \"%s\" at line %d ===", + expr->Identifier, expr->_lineno); + assert(expr->meta_type != AMT_INVALID); + + /* + * 2.1 Pre-process simple types (ENUMERATED, INTEGER, etc). + */ + ret = asn1f_recurse_expr(arg, asn1f_fix_simple); + RET2RVAL(ret, rvalue); + + /* + * 2.[234] Process SEQUENCE/SET/CHOICE types. + */ + ret = asn1f_recurse_expr(arg, asn1f_fix_constructed); + RET2RVAL(ret, rvalue); + + /* + * 2.5.4 + */ + ret = asn1f_recurse_expr(arg, asn1f_fix_dereference_types); + RET2RVAL(ret, rvalue); + + /* + * 2.5.5 + */ + ret = asn1f_recurse_expr(arg, asn1f_fix_dereference_values); + RET2RVAL(ret, rvalue); + + /* + * Resolve references in constraints. + */ + ret = asn1f_recurse_expr(arg, asn1f_fix_constraints); + RET2RVAL(ret, rvalue); + + /* + * 6. INTEGER value processed at 2.5.4. + */ + + /* + * Make sure everybody's behaving well. + */ + assert(arg->expr == expr); + } + + /* + * 5. Automatic tagging + */ + TQ_FOR(expr, &(arg->mod->members), next) { + int ret; + + arg->expr = expr; + + ret = asn1f_recurse_expr(arg, asn1f_fix_constr_autotag); + RET2RVAL(ret, rvalue); + + assert(arg->expr == expr); + } + + /* + * 8. fix BIT STRING + * 9. fix spaces in cstrings + */ + TQ_FOR(expr, &(arg->mod->members), next) { + int ret; + arg->expr = expr; + + ret = asn1f_recurse_expr(arg, asn1f_fix_bit_string); + RET2RVAL(ret, rvalue); + + ret = asn1f_recurse_expr(arg, asn1f_fix_cstring); + RET2RVAL(ret, rvalue); + + assert(arg->expr == expr); + } + + /* + * ... Check for tags distinctness. + */ + TQ_FOR(expr, &(arg->mod->members), next) { + int ret; + arg->expr = expr; + + ret = asn1f_recurse_expr(arg, asn1f_check_constr_tags_distinct); + RET2RVAL(ret, rvalue); + + assert(arg->expr == expr); + } + + return rvalue; +} + + +static int +asn1f_fix_simple(arg_t *arg) { + int rvalue = 0; + int ret; + + ret = asn1f_fix_enum(arg); + RET2RVAL(ret, rvalue); + + ret = asn1f_fix_integer(arg); + RET2RVAL(ret, rvalue); + + return rvalue; +} + +static int +asn1f_fix_constructed(arg_t *arg) { + int rvalue = 0; + int ret; + + switch(arg->expr->expr_type) { + case ASN_CONSTR_SEQUENCE: + case ASN_CONSTR_SET: + case ASN_CONSTR_CHOICE: + break; + default: + return 0; + } + + /* Check identifier distinctness */ + ret = asn1f_check_unique_expr(arg, NULL); + RET2RVAL(ret, rvalue); + + /* Fix extensibility */ + ret = asn1f_fix_constr_ext(arg); + RET2RVAL(ret, rvalue); + + /* Fix tagging */ + ret = asn1f_fix_constr_tag(arg); + RET2RVAL(ret, rvalue); + + return rvalue; +} + +static int +_constraint_value_resolve(arg_t *arg, asn1p_value_t **value) { + asn1p_expr_t expr; + asn1p_expr_t *tmp_expr; + asn1p_module_t *tmp_mod; + asn1p_module_t *mod_r = NULL; + int rvalue = 0; + int ret; + + tmp_expr = asn1f_lookup_symbol(arg, (*value)->value.reference, &mod_r); + if(tmp_expr == NULL) { + FATAL("Cannot find symbol %s " + "used in %s subtype constraint at line %d", + asn1f_printable_reference((*value)->value.reference), + arg->expr->Identifier, arg->expr->_lineno); + assert((*value)->type == ATV_REFERENCED); + return -1; + } + + memset(&expr, 0, sizeof(expr)); + expr.meta_type = tmp_expr->meta_type; + expr.expr_type = tmp_expr->expr_type; + expr.Identifier = tmp_expr->Identifier; + expr.value = *value; + tmp_expr = arg->expr; + tmp_mod = arg->mod; + arg->expr = &expr; + arg->mod = mod_r; + ret = asn1f_fix_dereference_values(arg); + RET2RVAL(ret, rvalue); + arg->expr = tmp_expr; + arg->mod = tmp_mod; + assert(expr.value); + *value = expr.value; + + return rvalue; +} + +static int +_resolve_constraints(arg_t *arg, asn1p_constraint_t *ct) { + int rvalue = 0; + int ret; + int el; + + /* Don't touch information object classes */ + if(ct->type == ACT_CT_WCOMP + || ct->type == ACT_CT_WCOMPS + || ct->type == ACT_CA_CRC) + return 0; + + if(ct->value && ct->value->type == ATV_REFERENCED) { + ret = _constraint_value_resolve(arg, &ct->value); + RET2RVAL(ret, rvalue); + } + if(ct->range_start && ct->range_start->type == ATV_REFERENCED) { + ret = _constraint_value_resolve(arg, &ct->range_start); + RET2RVAL(ret, rvalue); + } + if(ct->range_stop && ct->range_stop->type == ATV_REFERENCED) { + ret = _constraint_value_resolve(arg, &ct->range_stop); + RET2RVAL(ret, rvalue); + } + + for(el = 0; el < ct->el_count; el++) { + ret = _resolve_constraints(arg, ct->elements[el]); + RET2RVAL(ret, rvalue); + } + + return rvalue; +} + +static int +asn1f_fix_constraints(arg_t *arg) { + int rvalue = 0; + int ret; + + if(arg->expr->constraints) { + ret = _resolve_constraints(arg, arg->expr->constraints); + RET2RVAL(ret, rvalue); + } + + return rvalue; +} + +/* + * Print everything to stderr + */ +static void +_default_error_logger(int _severity, const char *fmt, ...) { + va_list ap; + char *pfx = ""; + + switch(_severity) { + case -1: pfx = "DEBUG: "; break; + case 0: pfx = "WARNING: "; break; + case 1: pfx = "FATAL: "; break; + } + + fprintf(stderr, "%s", pfx); + va_start(ap, fmt); + vfprintf(stderr, fmt, ap); + va_end(ap); + fprintf(stderr, "\n"); +} diff --git a/libasn1fix/asn1fix.h b/libasn1fix/asn1fix.h new file mode 100644 index 00000000..4847330a --- /dev/null +++ b/libasn1fix/asn1fix.h @@ -0,0 +1,30 @@ +/* + * This is the public interface for the processor (fixer) of the ASN.1 tree + * produced by the libasn1parser. + */ +#ifndef ASN1FIX_H +#define ASN1FIX_H + +#include + +/* + * Operation flags for the function below. + */ +enum asn1f_flags { + A1F_NOFLAGS, + A1F_DEBUG, /* Print debugging output using (_is_fatal = -1) */ +}; + +/* + * Perform a set of semantics checks, transformations and small fixes + * on the given tree. + * RETURN VALUES: + * -1: Some fatal problems were encountered. + * 0: No inconsistencies were found. + * 1: Some warnings were issued, but no fatal problems encountered. + */ +int asn1f_process(asn1p_t *_asn, + enum asn1f_flags, + void (*error_log_callback)(int _severity, const char *fmt, ...)); + +#endif /* ASN1FIX_H */ diff --git a/libasn1fix/asn1fix_bitstring.c b/libasn1fix/asn1fix_bitstring.c new file mode 100644 index 00000000..0d3961d4 --- /dev/null +++ b/libasn1fix/asn1fix_bitstring.c @@ -0,0 +1,230 @@ +#include "asn1fix_internal.h" + +int asn1f_fix_bit_string_value(arg_t *arg, asn1p_expr_t *ttype); +static void asn1f_BS_remove_trailing_zero_bits(asn1p_value_t *value); +static int asn1f_BS_unparsed_convert(arg_t *arg, asn1p_value_t *value, asn1p_expr_t *ttype); + +int +asn1f_fix_bit_string(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + int r_value = 0; + int ret; + + if(expr->meta_type == AMT_VALUE) { + asn1p_expr_t *ttype; + + DEBUG("%s(%s) for line %d", __func__, + expr->Identifier, expr->_lineno); + + ttype = asn1f_find_terminal_type(arg, expr, 0); + if(ttype && ttype->expr_type == ASN_BASIC_BIT_STRING) { + ret = asn1f_fix_bit_string_value(arg, ttype); + RET2RVAL(ret, r_value); + } + } + + return r_value; +} + +int +asn1f_fix_bit_string_value(arg_t *arg, asn1p_expr_t *ttype) { + asn1p_expr_t *expr = arg->expr; + int r_value = 0; + + DEBUG("%s(%s) for line %d", __func__, + expr->Identifier, expr->_lineno); + + switch(expr->value->type) { + case ATV_UNPARSED: + /* + * Most definitely we have something like + * value BitStringType1 ::= { a, b, c } + * which could not be parsed by the LALR parser, mostly + * because it requires knowledge about BitStringType1 + * during the parsing. So, here's a little hack: we create + * a buffer containing the full specification of a module, + * which contains some pre-defined INTEGER type with the + * opaque definition "{ a, b, c }" from the bit string. + */ + if(asn1f_BS_unparsed_convert(arg, expr->value, ttype)) { + r_value = -1; + break; + } + /* Fall through: remove trailing zero bits */ + case ATV_BITVECTOR: + asn1f_BS_remove_trailing_zero_bits(expr->value); + break; + default: + break; + } + + return r_value; +} + +static void +asn1f_BS_remove_trailing_zero_bits(asn1p_value_t *value) { + int lmfb = -1; /* Last meaningful byte position */ + int bits; /* Number of bits in the BIT STRING value */ + int b; + + assert(value->type == ATV_BITVECTOR); + + bits = value->value.binary_vector.size_in_bits; + /* + * Figure out the rightmost meaningful byte. + */ + for(b = 0; b < ((bits + 7) >> 3); b++) { + uint8_t uc = value->value.binary_vector.bits[b]; + if(uc && b > lmfb) + lmfb = b; + } + if(lmfb == -1) { + bits = 0; + } else { + uint8_t uc; + uc = value->value.binary_vector.bits[lmfb]; + bits = (lmfb+1) * 8; + /* + * Squeeze the bit string width until the rightmost + * bit is set. + */ + for(; uc && (uc & 1) == 0; uc >>= 1) + bits--; + if(uc == 0) { + bits = lmfb * 8; + } + } + value->value.binary_vector.size_in_bits = bits; +} + +static int +asn1f_BS_unparsed_convert(arg_t *arg, asn1p_value_t *value, asn1p_expr_t *ttype) { + asn1p_t *asn; + asn1p_module_t *mod; + asn1p_expr_t *V; + asn1p_expr_t *bit; + asn1_integer_t aI; + uint8_t *bitbuf; + int bits; + int psize; + char *p; + int ret; + int r_value = 0; + + assert(value->type == ATV_UNPARSED); + + psize = value->value.string.size + 64; + p = malloc(psize); + if(p == NULL) + return -1; + + ret = snprintf(p, psize, + "M DEFINITIONS ::=\nBEGIN\n" + "V ::= INTEGER %s\n" + "END\n", + value->value.string.buf + ); + assert(ret < psize); + psize = ret; + + asn = asn1p_parse_buffer(p, psize, A1P_NOFLAGS); + free(p); + if(asn == NULL) { + FATAL("Cannot parse BIT STRING value %s " + "defined as %s at line %d", + arg->expr->Identifier, + value->value.string.buf, + arg->expr->_lineno + ); + return -1; + } + + mod = TQ_FIRST(&(asn->modules)); + assert(mod); + V = TQ_FIRST(&(mod->members)); + assert(V); + assert(strcmp(V->Identifier, "V") == 0); + assert(TQ_FIRST(&(V->members))); + + /* + * Simple loop just to fetch the maximal bit position + * out of the BIT STRING value defined as NamedBitList. + */ + aI = -1; + TQ_FOR(bit, &(V->members), next) { + asn1p_expr_t *bitdef; + bitdef = asn1f_lookup_child(ttype, bit->Identifier); + if(bitdef && bitdef->value + && bitdef->value->type == ATV_INTEGER) { + if(bitdef->value->value.v_integer > aI) + aI = bitdef->value->value.v_integer; + } + } + + if(aI > 1024 * 1024 * 8) { /* One megabyte */ + FATAL("Unsupportedly large BIT STRING value \"%s\" " + "defined at line %d " + "(larger than 1MByte)", + arg->expr->Identifier, + arg->expr->_lineno + ); + asn1p_free(asn); + return -1; + } + + bits = aI + 1; /* Number of bits is more than a last bit position */ + bitbuf = calloc(1, 1 + ((bits + 7) / 8)); + if(bitbuf == NULL) { + asn1p_free(asn); + return -1; + } + + TQ_FOR(bit, &(V->members), next) { + asn1p_expr_t *bitdef; + int set_bit_pos; + + if(bit->value) { + WARNING("Identifier \"%s\" at line %d " + "must not have a value", + bit->Identifier, bit->_lineno); + RET2RVAL(1, r_value); + } + bitdef = asn1f_lookup_child(ttype, bit->Identifier); + if(bitdef == NULL) { + FATAL("Identifier \"%s\" at line %d is not defined " + "in the \"%s\" type definition at line %d", + bit->Identifier, + bit->_lineno, + ttype->Identifier, + ttype->_lineno + ); + RET2RVAL(-1, r_value); + continue; + } + if(bitdef->value == NULL + || bitdef->value->type != ATV_INTEGER) { + FATAL("Broken identifier " + "\"%s\" at line %d " + "referenced by \"%s\" at line %d", + bitdef->Identifier, + bitdef->_lineno, + arg->expr->Identifier, + arg->expr->_lineno + ); + RET2RVAL(-1, r_value); + continue; + } + + assert(bitdef->value->value.v_integer < bits); + set_bit_pos = bitdef->value->value.v_integer; + bitbuf[set_bit_pos>>3] |= 1 << (7-(set_bit_pos % 8)); + } + + asn1p_free(asn); + free(value->value.string.buf); + value->type = ATV_BITVECTOR; + value->value.binary_vector.bits = bitbuf; + value->value.binary_vector.size_in_bits = bits; + + return r_value; +} diff --git a/libasn1fix/asn1fix_bitstring.h b/libasn1fix/asn1fix_bitstring.h new file mode 100644 index 00000000..1230856f --- /dev/null +++ b/libasn1fix/asn1fix_bitstring.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_BIT_STRING_H_ +#define _ASN1FIX_BIT_STRING_H_ + +int asn1f_fix_bit_string(arg_t *); + +#endif /* _ASN1FIX_BIT_STRING_H_ */ diff --git a/libasn1fix/asn1fix_class.c b/libasn1fix/asn1fix_class.c new file mode 100644 index 00000000..c541fd62 --- /dev/null +++ b/libasn1fix/asn1fix_class.c @@ -0,0 +1,237 @@ +#include "asn1fix_internal.h" + +typedef enum field_category { + OFC_INVALID, /* Invalid object field category */ + OFC_TYPE, + OFC_FIXED_TYPE_VALUE, + OFC_VARIABLE_TYPE_VALUE, + OFC_FIXED_TYPE_VALUE_SET, + OFC_VARIABLE_TYPE_VALUE_SET, + OFC_INFORMATION_OBJECT, + OFC_INFORMATION_OBJECT_SET, +} field_category_e; + +typedef enum object_category { + OC_INVALID, + OC_OBJECT, + OC_OBJECTSET, +} object_category_e; + +static field_category_e asn1f_class_field_category(asn1p_expr_t *ofield); +static object_category_e asn1f_class_object_category(asn1p_expr_t *expr); +static asn1p_expr_t * +asn1f_class_dot_lookup(arg_t *arg, asn1p_expr_t *obj, asn1p_ref_t *ref); + +asn1p_expr_t * +asn1f_class_access(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **mod_r) { + asn1p_expr_t *obj; /* Information Object or Object Set */ + object_category_e obj_cat; /* Object category */ + //field_category_e field_cat; /* Field category */ + asn1p_expr_t *result; + asn1p_ref_t tmpref; + + assert(ref->comp_count > 1); + + DEBUG("%s(%s) for line %d", __func__, + asn1f_printable_reference(ref), + ref->_lineno); + + /* + * Fetch the first part of the reference (OBJECT or ObjectSet). + * OBJECT.&... + * ObjectSet.&... + */ + assert(isupper(ref->components[0].name[0])); + + tmpref = *ref; + tmpref.comp_count = 1; + obj = asn1f_lookup_symbol(arg, &tmpref, 0); + if(obj == NULL) { + errno = ESRCH; + return NULL; + } + + /* + * Make sure the symbol lexical property (upper-case, lower-case) + * corresponds to the type of the expression returned by + * lookup_symbol(). + */ + obj_cat = asn1f_class_object_category(obj); + switch(obj_cat) { + case OC_OBJECT: + case OC_OBJECTSET: + if(ref->components[0].lex_type + == (obj_cat==OC_OBJECT) + ? RLT_CAPITALS + : RLT_Uppercase) + break; + /* Fall through */ + case OC_INVALID: + WARNING("Symbol \"%s\" is not compatible " + "with referenced expression \"%s\" at line %d", + ref->components[0].name, + obj->Identifier, obj->_lineno); + errno = EPERM; + return NULL; + } + + /* + * Find the specified field within the object. + */ + result = asn1f_class_dot_lookup(arg, obj, ref); + if(result == NULL) { + return NULL; + } + + //field_cat = asn1f_class_field_category(result); + + DEBUG("FILLME: %s", result->Identifier); + + return result; +} + +static object_category_e +asn1f_class_object_category(asn1p_expr_t *expr) { + + switch(expr->meta_type) { + case AMT_OBJECT: + return OC_OBJECT; + case AMT_OBJECTSET: + return OC_OBJECTSET; + case AMT_VALUESET: + if(expr->expr_type == A1TC_REFERENCE + && expr->reference + && expr->reference->comp_count == 1 + && expr->reference->components[0].lex_type == RLT_CAPITALS) + { + /* FIXME: use find_terminal_type instead! */ + return OC_OBJECTSET; + } + break; + default: + break; + } + + return OC_INVALID; +} + +static field_category_e +asn1f_class_field_category(asn1p_expr_t *ofield) { + if(ofield->Identifier[0] != '&') { + assert(ofield->Identifier[0] == '&'); + return OFC_INVALID; + } + + if(isupper(ofield->Identifier[1])) { + if(ofield->reference) { + enum asn1p_ref_lex_type_e lex_type + = ofield->reference->components[0].lex_type; + + switch(lex_type) { + case RLT_CAPITALS: + return OFC_INFORMATION_OBJECT_SET; + case RLT_Uppercase: + return OFC_FIXED_TYPE_VALUE_SET; + case RLT_AmpUppercase: + return OFC_VARIABLE_TYPE_VALUE_SET; + default: + break; + } + } else { + if(ofield->expr_type == A1TC_CLASSFIELD) + return OFC_TYPE; + + switch(ofield->meta_type) { + case AMT_TYPE: + case AMT_TYPEREF: + return OFC_FIXED_TYPE_VALUE_SET; + default: + break; + } + + } + } else { + if(ofield->reference) { + enum asn1p_ref_lex_type_e lex_type + = ofield->reference->components[0].lex_type; + + switch(lex_type) { + case RLT_CAPITALS: + return OFC_INFORMATION_OBJECT; + case RLT_Uppercase: + return OFC_FIXED_TYPE_VALUE; + case RLT_AmpUppercase: + return OFC_VARIABLE_TYPE_VALUE; + default: + break; + } + } else { + switch(ofield->meta_type) { + case AMT_TYPE: + case AMT_TYPEREF: + return OFC_FIXED_TYPE_VALUE; + default: + break; + } + } + } + + return OFC_INVALID; +} + + +static asn1p_expr_t * +asn1f_class_dot_lookup(arg_t *arg, asn1p_expr_t *obj, asn1p_ref_t *ref) { + asn1p_expr_t *ofield = NULL; /* Information Object's Field */ + field_category_e field_cat; /* Field category */ + int comp; + + assert(ref->comp_count >= 2); + + for(comp = 1 /* sic! */; comp < ref->comp_count; comp++) { + int is_last_component = (comp + 1 == ref->comp_count); + char *comp_name = ref->components[comp].name; + + ofield = asn1f_lookup_child(obj, comp_name); + if(ofield == NULL) { + DEBUG("Cannot find field \"%s\" in \"%s\" at line %d", + ref->components[1].name, + obj->Identifier, + obj->_lineno); + } + + /* + * Compute the category of the field of + * the information object class. + */ + field_cat = asn1f_class_field_category(ofield); + + switch(field_cat) { + case OFC_INVALID: + WARNING("Invalid field category of \"%s\" at line %d", + ofield->Identifier, ofield->_lineno); + errno = EPERM; + return NULL; + case OFC_TYPE: + case OFC_FIXED_TYPE_VALUE: + case OFC_VARIABLE_TYPE_VALUE: + case OFC_FIXED_TYPE_VALUE_SET: + case OFC_VARIABLE_TYPE_VALUE_SET: + if(!is_last_component) { + FATAL("Field name component \"%s\" at line %d " + "specifies non-dereferenceable thing", + comp_name, ref->_lineno); + errno = EPERM; + return NULL; + } + break; + case OFC_INFORMATION_OBJECT: + case OFC_INFORMATION_OBJECT_SET: + obj = ofield; + break; + } + } + + assert(ofield); + return ofield; +} diff --git a/libasn1fix/asn1fix_class.h b/libasn1fix/asn1fix_class.h new file mode 100644 index 00000000..c849b2b3 --- /dev/null +++ b/libasn1fix/asn1fix_class.h @@ -0,0 +1,16 @@ +#ifndef _ASN1FIX_CLASS_H_ +#define _ASN1FIX_CLASS_H_ + +/* + * Fetch the element from the class-related stuff (thing) by its reference. + */ +asn1p_expr_t * +asn1f_class_access(arg_t *, asn1p_ref_t *, asn1p_module_t **mod_r); + +/* + * Externally accessible version of above function. + */ +asn1p_expr_t *asn1f_class_access2(asn1p_t *asn, asn1p_module_t *mod, + asn1p_expr_t *expr, asn1p_ref_t *, asn1p_module_t **mod_r); + +#endif /* _ASN1FIX_CLASS_H_ */ diff --git a/libasn1fix/asn1fix_compat.c b/libasn1fix/asn1fix_compat.c new file mode 100644 index 00000000..aef26c0b --- /dev/null +++ b/libasn1fix/asn1fix_compat.c @@ -0,0 +1,132 @@ +#include "asn1fix_internal.h" + +static int asn1f_check_same_children(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b); + +/* + * Check that the expressions given are compatible in their type. + * ORDER DOES MATTER! (See .h). + */ +int +asn1f_check_type_compatibility(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b) { + asn1p_expr_type_e atype, btype; + + atype = a->expr_type; + btype = b->expr_type; + + DEBUG("%s(%s:%x@%d, %s:%x@%d)", __func__, + a->Identifier, atype, a->_lineno, + b->Identifier, btype, b->_lineno); + + /* + * Expected terminal type! + */ + assert(atype != A1TC_REFERENCE); + assert(btype != A1TC_REFERENCE); + + if(atype != btype) { + /* + * Limited compatibility. + */ + if((atype == A1TC_UNIVERVAL && btype == ASN_BASIC_INTEGER) + || (atype == A1TC_UNIVERVAL && btype == ASN_BASIC_ENUMERATED) + ) + return 0; + DEBUG("\t%s and %s are not compatible", + a->Identifier, b->Identifier); + return -1; /* Fairly obviously */ + } + + if(a == b) + return 0; /* Fairly obviously */ + + switch(atype) { + case ASN_BASIC_INTEGER: + /* All integers are compatible */ + return 0; + case ASN_BASIC_ENUMERATED: + /* + * Enumerations are not compatible + * unless their definitions are the same. + */ + if(asn1f_check_same_children(arg, a, b)) { + DEBUG("\tEnumerations are different %s and %s", + a->Identifier, b->Identifier); + return -1; + } + return 0; + default: + /* Compatibility is not defined yet */ + DEBUG("\tCompatibility rule is not defined for %s and %s", + a->Identifier, b->Identifier); + return -1; + } + + return 0; +} + +/* + * Check that the children are exactly same. + */ +static int +asn1f_check_same_children(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b) { + asn1p_expr_t *achild; + asn1p_expr_t *bchild; + + achild = TQ_FIRST(&(a->members)); + bchild = TQ_FIRST(&(b->members)); + + while(1) { + if(achild->expr_type != bchild->expr_type) + return -1; + + if(achild->Identifier && bchild->Identifier) { + if(strcmp(achild->Identifier, bchild->Identifier)) + return -1; + } else if(!(!achild->Identifier && !bchild->Identifier)) { + return -1; + } + + if(achild->value && bchild->value) { + if(achild->value->type != bchild->value->type) + return -1; + switch(achild->value->type) { + case ATV_INTEGER: + if(achild->value->value.v_integer + != bchild->value->value.v_integer) + return -1; + break; + case ATV_REFERENCED: + default: + DEBUG("Value %s at lines %d and " + "%d cannot be used in " + "semantical equality check", + asn1f_printable_value(achild->value), + achild->value->value.reference->_lineno, + bchild->value->value.reference->_lineno + ); + return -1; + } + } else if(!(!achild->value && !bchild->value)) { + /* One of values is defined, and another is not */ + return -1; + } + + achild = TQ_NEXT(achild, next); + bchild = TQ_NEXT(bchild, next); + + if(achild && bchild) + continue; + else if(!achild && !bchild) + break; + else + return -1; + } + + DEBUG("\t%s:%x@%d and %s:%x@%d are semantically equivalent", + a->Identifier, a->expr_type, a->_lineno, + b->Identifier, b->expr_type, b->_lineno); + + return 0; +} + + diff --git a/libasn1fix/asn1fix_compat.h b/libasn1fix/asn1fix_compat.h new file mode 100644 index 00000000..429e7dd8 --- /dev/null +++ b/libasn1fix/asn1fix_compat.h @@ -0,0 +1,14 @@ +#ifndef _ASN1FIX_COMPAT_H_ +#define _ASN1FIX_COMPAT_H_ + +/* + * Check that the expressions given are compatible in their type. + * ORDER DOES MATTER! + * The compatibility is being checked as if the value of b were used + * to assign it to type a. + */ +int asn1f_check_type_compatibility(arg_t *arg, + asn1p_expr_t *a, + asn1p_expr_t *b); + +#endif /* _ASN1FIX_COMPAT_H_ */ diff --git a/libasn1fix/asn1fix_constr.c b/libasn1fix/asn1fix_constr.c new file mode 100644 index 00000000..2aa79827 --- /dev/null +++ b/libasn1fix/asn1fix_constr.c @@ -0,0 +1,364 @@ +#include "asn1fix_internal.h" + +static int _asn1f_check_if_tag_must_be_explicit(arg_t *arg, asn1p_expr_t *v); +static int _asn1f_compare_tags(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b); + + +int +asn1f_fix_constr_ext(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + TQ_HEAD(asn1p_expr_t) root_list; + TQ_HEAD(asn1p_expr_t) ext_list; + TQ_HEAD(asn1p_expr_t) *cur_list; + int r_value = 0; + int ext_count = 0; + + switch(expr->expr_type) { + case ASN_CONSTR_SEQUENCE: + case ASN_CONSTR_SET: + case ASN_CONSTR_CHOICE: + break; + default: + return 0; + } + + DEBUG("%s(%s) for line %d", __func__, + expr->Identifier, expr->_lineno); + + TQ_INIT(&root_list); + TQ_INIT(&ext_list); + cur_list = (void *)&root_list; + + while((v = TQ_REMOVE(&(expr->members), next))) { + if(v->expr_type == A1TC_EXTENSIBLE) { + ext_count++; + switch(ext_count) { + case 1: cur_list = (void *)&ext_list; break; + case 2: + cur_list = (void *)&root_list; + if(v->value) { + FATAL("Optional extension marker " + "must not contain " + "an exception mark " + "at line %d", v->_lineno); + r_value = -1; + } + asn1p_expr_free(v); + continue; + case 3: + FATAL("Third extension marker " + "is not allowed at line %d", v->_lineno); + default: + r_value = -1; + } + } + + TQ_ADD(cur_list, v, next); + } + + /* + * Copy the root list and extension list back into the main list. + */ + TQ_HEAD_COPY(&(expr->members), &root_list); + while((v = TQ_REMOVE(&ext_list, next))) + TQ_ADD(&(expr->members), v, next); + + if(arg->mod->module_flags & MSF_EXTENSIBILITY_IMPLIED + && ext_count < 1) { + v = asn1p_expr_new(0); + if(v) { + v->Identifier = strdup("..."); + v->expr_type = A1TC_EXTENSIBLE; + v->meta_type = AMT_TYPE; + if(v->Identifier == NULL) { + asn1p_expr_free(v); + r_value = -1; + } else { + TQ_ADD(&(expr->members), v, next); + } + } else { + r_value = -1; + } + } + + return r_value; +} + + +int +asn1f_fix_constr_tag(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int fl_impl_tags = 0; + int fl_auto_tags = 0; + int root_tagged = 0; /* The root component is manually tagged */ + int ext_tagged = 0; /* The extensions are manually tagged */ + int component_number = 0; + int r_value = 0; + + switch(expr->expr_type) { + case ASN_CONSTR_SEQUENCE: + case ASN_CONSTR_SET: + case ASN_CONSTR_CHOICE: + break; + default: + return 0; + } + + fl_impl_tags = (arg->mod->module_flags & MSF_IMPLICIT_TAGS); + fl_auto_tags = (arg->mod->module_flags & MSF_AUTOMATIC_TAGS); + + DEBUG("%s(%s) {%d, %d} for line %d", __func__, + expr->Identifier, fl_impl_tags, fl_auto_tags, expr->_lineno); + + TQ_FOR(v, &(expr->members), next) { + int must_explicit = 0; + + if(v->expr_type == A1TC_EXTENSIBLE) { + component_number++; + continue; + } + + if(v->tag.tag_class == TC_NOCLASS) { + continue; + } else { + switch(component_number) { + case 0: case 2: + root_tagged = 1; break; + default: + ext_tagged = 1; break; + } + } + + must_explicit = _asn1f_check_if_tag_must_be_explicit(arg, v); + + if(fl_impl_tags) { + if(v->tag.tag_mode != TM_EXPLICIT) { + if(must_explicit) + v->tag.tag_mode = TM_EXPLICIT; + else + v->tag.tag_mode = TM_IMPLICIT; + } + } else { + if(v->tag.tag_mode == TM_DEFAULT) { + v->tag.tag_mode = TM_EXPLICIT; + } + } + + /* + * Perform a final sanity check. + */ + if(must_explicit) { + if(v->tag.tag_mode == TM_IMPLICIT) { + FATAL("%s tagged in IMPLICIT mode " + "but must be EXPLICIT at line %d", + v->Identifier, v->_lineno); + r_value = -1; + } else { + v->tag.tag_mode = TM_EXPLICIT; + } + } + } + + if(ext_tagged && !root_tagged) { + FATAL("In %s at line %d: " + "extensions are tagged " + "but root components are not", + expr->Identifier, expr->_lineno); + r_value = -1; + } else if(!root_tagged && !ext_tagged && fl_auto_tags) { + expr->auto_tags_OK = 1; + } + + return r_value; +} + +int +asn1f_fix_constr_autotag(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + asn1_integer_t tag_value = 0; + int r_value = 0; + + switch(expr->expr_type) { + case ASN_CONSTR_SEQUENCE: + case ASN_CONSTR_SET: + case ASN_CONSTR_CHOICE: + if(expr->auto_tags_OK) + break; + /* Automatic tagging is not applicable */ + /* Fall through */ + default: + return 0; + } + + DEBUG("%s(%s) for line %d", __func__, + expr->Identifier, expr->_lineno); + + TQ_FOR(v, &(expr->members), next) { + int must_explicit; + + if(v->expr_type == A1TC_EXTENSIBLE) + break; + + assert(v->tag.tag_class == TC_NOCLASS); + + must_explicit = _asn1f_check_if_tag_must_be_explicit(arg, v); + + v->tag.tag_class = TC_CONTEXT_SPECIFIC; + v->tag.tag_mode = must_explicit ? TM_EXPLICIT : TM_IMPLICIT; + v->tag.tag_value = tag_value++; + } + + return r_value; +} + +/* + * Check that tags are distinct. + */ +int +asn1f_check_constr_tags_distinct(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *v; + int r_value = 0; + + switch(expr->expr_type) { + case ASN_CONSTR_SEQUENCE: + case ASN_CONSTR_SET: + case ASN_CONSTR_CHOICE: + break; + default: + return 0; + } + + TQ_FOR(v, &(expr->members), next) { + /* + * In every series of non-mandatory components, + * the tags must be distinct from each other AND the + * tag of the following mandatory component. + * For SET and CHOICE treat everything as a big set of + * non-mandatory components. + */ + if(expr->expr_type != ASN_CONSTR_SEQUENCE || v->marker) { + asn1p_expr_t *nv; + for(nv = v; (nv = TQ_NEXT(nv, next));) { + if(_asn1f_compare_tags(arg, v, nv)) + r_value = -1; + if(expr->expr_type == ASN_CONSTR_SEQUENCE + && !nv->marker) break; + } + } + } + + return r_value; +} + +static int +_asn1f_check_if_tag_must_be_explicit(arg_t *arg, asn1p_expr_t *v) { + asn1p_expr_t *reft; + + reft = asn1f_find_terminal_type(arg, v, 0); + if(reft) { + switch(reft->expr_type) { + case ASN_CONSTR_CHOICE: + return 1; + default: + return 0; + } + } + + return 0; +} + +/* + * Check that the tags are distinct. + */ +static int +_asn1f_compare_tags(arg_t *arg, asn1p_expr_t *a, asn1p_expr_t *b) { + struct asn1p_type_tag_s ta, tb; + int ra, rb; + int ret; + + ra = asn1f_fetch_tag(arg->asn, arg->mod, a, &ta); + rb = asn1f_fetch_tag(arg->asn, arg->mod, b, &tb); + + /* + * If both tags are explicitly or implicitly given, use them. + */ + if(ra == 0 && rb == 0) { + /* + * Simple case: fetched both tags. + */ + if(ta.tag_value == tb.tag_value + && ta.tag_class == tb.tag_class) { + char *p = (a->expr_type == A1TC_EXTENSIBLE) + ?"potentially ":""; + FATAL("Component \"%s\" at line %d %shas the same tag " + "with component \"%s\" at line %d", + a->Identifier, + a->_lineno, + p, + b->Identifier, + b->_lineno + ); + return -1; + } else { + /* Tags are distinct */ + return 0; + } + } + + /********************************************************** + * Now we must perform some very funny recursion to check + * multiple components of CHOICE type, etc. + */ + + DEBUG("Comparing tags %s:%x <-> %s:%x", + a->Identifier, a->expr_type, + b->Identifier, b->expr_type); + + if(a->meta_type == AMT_TYPEREF) { + asn1p_module_t *mod; + + DEBUG(" %s is a type reference", a->Identifier); + + a = asn1f_lookup_symbol(arg, a->reference, &mod); + if(!a) return 0; /* Already FATAL()'ed somewhere else */ + WITH_MODULE(mod, ret = _asn1f_compare_tags(arg, a, b)); + return ret; + } + + if(a->expr_type == ASN_CONSTR_CHOICE) { + asn1p_expr_t *v; + + DEBUG(" %s is a choice type (%d)", a->Identifier, a->_mark); + + /* + * Iterate over members of CHOICE. + */ + //if(a->_mark & TM_RECURSION) return 0; + TQ_FOR(v, &(a->members), next) { + //a->_mark |= TM_RECURSION; + ret = _asn1f_compare_tags(arg, v, b); + //a->_mark &= ~TM_RECURSION; + if(ret) return ret; + } + return 0; + } + + if(b->expr_type == ASN_CONSTR_CHOICE) { + return _asn1f_compare_tags(arg, b, a); + } + + if(a->_mark & TM_RECURSION) return 0; + if(b->_mark & TM_RECURSION) return 0; + a->_mark |= TM_RECURSION; + b->_mark |= TM_RECURSION; + ret = _asn1f_compare_tags(arg, b, a); + a->_mark &= ~TM_RECURSION; + b->_mark &= ~TM_RECURSION; + + return ret; +} + diff --git a/libasn1fix/asn1fix_constr.h b/libasn1fix/asn1fix_constr.h new file mode 100644 index 00000000..aeb05c0a --- /dev/null +++ b/libasn1fix/asn1fix_constr.h @@ -0,0 +1,24 @@ +#ifndef _ASN1FIX_CONSTRUCTED_H_ +#define _ASN1FIX_CONSTRUCTED_H_ + +/* + * Fix extensions in constructed types. + */ +int asn1f_fix_constr_ext(arg_t *); + +/* + * Fix tagging in constructed types. + */ +int asn1f_fix_constr_tag(arg_t *); + +/* + * Check distinctive tagging in constructed types. + */ +int asn1f_check_constr_tags_distinct(arg_t *); + +/* + * Perform automatic tagging. + */ +int asn1f_fix_constr_autotag(arg_t *); + +#endif /* _ASN1FIX_CONSTRUCTED_H_ */ diff --git a/libasn1fix/asn1fix_cstring.c b/libasn1fix/asn1fix_cstring.c new file mode 100644 index 00000000..b8a38833 --- /dev/null +++ b/libasn1fix/asn1fix_cstring.c @@ -0,0 +1,73 @@ +#include "asn1fix_internal.h" + +struct _cstring_pattern { + char *start; + int length; +}; +static int _asn1f_cstring_find_line_pattern(char *s, struct _cstring_pattern *); + +int +asn1f_fix_cstring(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + int r_value = 0; + + if(expr->value && expr->value->type == ATV_STRING) { + struct _cstring_pattern cp; + char *buf = expr->value->value.string.buf; + int buflen = expr->value->value.string.size; + int start = 0; + + DEBUG("%s(%s) for line %d", __func__, + expr->Identifier, expr->_lineno); + + while(_asn1f_cstring_find_line_pattern(buf + start, &cp)) { + assert(cp.length); + memmove(cp.start, cp.start + cp.length, + buflen - ((cp.start + cp.length) - buf)); + buflen -= cp.length; + start = cp.start - buf; + buf[buflen] = '\0'; + } + } + + return r_value; +} + +/* + * If a string has a newline, the tabulation and spaces before and + * after it must be eliminated. + */ +static int +_asn1f_cstring_find_line_pattern(char *s, struct _cstring_pattern *cp) { + int newline_found = 0; + + cp->start = NULL; + + for(;;s++) { + switch(*s) { + case '\r': case '\n': + newline_found = 1; + /* Fall through */ + case ' ': case '\t': + if(cp->start == NULL) + cp->start = s; + continue; + case '\0': + default: + if(newline_found) { + cp->length = s - cp->start; + return 1; + } + + cp->start = NULL; + if(*s == '\0') + break; + continue; + } + break; + } + + return 0; +} + + diff --git a/libasn1fix/asn1fix_cstring.h b/libasn1fix/asn1fix_cstring.h new file mode 100644 index 00000000..bd647abe --- /dev/null +++ b/libasn1fix/asn1fix_cstring.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_CSTRING_H_ +#define _ASN1FIX_CSTRING_H_ + +int asn1f_fix_cstring(arg_t *); + +#endif /* _ASN1FIX_CSTRING_H_ */ diff --git a/libasn1fix/asn1fix_dereft.c b/libasn1fix/asn1fix_dereft.c new file mode 100644 index 00000000..f0ec9a6c --- /dev/null +++ b/libasn1fix/asn1fix_dereft.c @@ -0,0 +1,68 @@ +#include "asn1fix_internal.h" + +int +asn1f_fix_dereference_types(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *type_expr; + int r_value = 0; + + if(expr->expr_type == A1TC_PARAMETRIZED) + return asn1f_fix_parametrized_assignment(arg); + + if(expr->expr_type != A1TC_REFERENCE + || expr->meta_type != AMT_TYPEREF) { + //assert(expr->reference == 0); + return 0; /* Just ignore it */ + } + + DEBUG("%s(\"%s\":%x ::= \"%s\") for line %d", + __func__, expr->Identifier, expr->expr_type, + asn1f_printable_value(expr->value), + expr->_lineno); + + assert(TQ_FIRST(&(expr->members)) == 0); + assert(expr->reference); + + /* + * Follow the reference. + */ + type_expr = asn1f_find_terminal_type(arg, expr, 0); + if(type_expr == NULL) { + FATAL("Unknown type \"%s\" referenced by \"%s\" at line %d", + asn1f_printable_reference(expr->reference), + expr->Identifier, expr->_lineno); + return -1; + } + + /* + * Copying members of the source expression + * into the current expression. + */ + if(0) { + asn1p_expr_t *tmp_clone; + + tmp_clone = asn1p_expr_clone(type_expr); + if(tmp_clone == NULL) { + FATAL("Could not clone \"%s\" at line %d", + type_expr->Identifier, type_expr->_lineno); + return -1; + } + + /* + * Replace the referenced type with its definition. + */ + DEBUG("\tChanging type of \"%s\":%x to %x for line %d", + expr->Identifier, + expr->expr_type, + type_expr->expr_type, + expr->_lineno + ); + expr->expr_type = type_expr->expr_type; + expr->members = tmp_clone->members; + memset(&tmp_clone->members, 0, sizeof(tmp_clone->members)); + asn1p_expr_free(tmp_clone); + } + + return r_value; +} + diff --git a/libasn1fix/asn1fix_dereft.h b/libasn1fix/asn1fix_dereft.h new file mode 100644 index 00000000..bee8151a --- /dev/null +++ b/libasn1fix/asn1fix_dereft.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_DEREFT_H_ +#define _ASN1FIX_DEREFT_H_ + +int asn1f_fix_dereference_types(arg_t *); + +#endif /* _ASN1FIX_DEREFT_H_ */ diff --git a/libasn1fix/asn1fix_derefv.c b/libasn1fix/asn1fix_derefv.c new file mode 100644 index 00000000..7be9d6d2 --- /dev/null +++ b/libasn1fix/asn1fix_derefv.c @@ -0,0 +1,56 @@ +#include "asn1fix_internal.h" + +/* + * Dereference DefinedValues: + */ +int +asn1f_fix_dereference_values(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + int r_value = 0; + + if(expr->meta_type != AMT_VALUE) + return 0; /* Just ignore it */ + + if(expr->value == NULL) + return 0; /* Just ignore it */ + + if(expr->value && expr->value->type != ATV_REFERENCED) + return 0; /* Not a reference */ + + DEBUG("%s(%s %x ::= %s) for line %d", __func__, + expr->Identifier, expr->expr_type, + asn1f_printable_value(expr->value), expr->_lineno); + + /* + * If this integer has a value, check that this value + * is an integer. If it is a reference, resolve it. + */ + if(expr->value) { + + if(asn1f_value_resolve(arg, expr)) { + /* This function will emit messages */ + r_value = -1; + } + + if(expr->value->type != ATV_INTEGER) { + FATAL( + "INTEGER value %s at line %d: " + "Incompatible value specified: %s", + expr->Identifier, + expr->_lineno, + asn1f_printable_value(expr->value) + ); + r_value = -1; + } + } else { + FATAL("Value of \"%s\" at line %d: " + "Incompatible value specified", + expr->Identifier, + expr->_lineno + ); + r_value = -1; + } + + return r_value; +} + diff --git a/libasn1fix/asn1fix_derefv.h b/libasn1fix/asn1fix_derefv.h new file mode 100644 index 00000000..93153851 --- /dev/null +++ b/libasn1fix/asn1fix_derefv.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_DEREFV_H_ +#define _ASN1FIX_DEREFV_H_ + +int asn1f_fix_dereference_values(arg_t *); + +#endif /* _ASN1FIX_DEREFV_H_ */ diff --git a/libasn1fix/asn1fix_enum.c b/libasn1fix/asn1fix_enum.c new file mode 100644 index 00000000..8a90a435 --- /dev/null +++ b/libasn1fix/asn1fix_enum.c @@ -0,0 +1,136 @@ +#include "asn1fix_internal.h" + +/* + * Check the validity of an enumeration. + */ +int +asn1f_fix_enum(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *ev; + asn1_integer_t max_value = -1; + int rvalue = 0; + asn1p_expr_t *ext_marker = NULL; /* "..." position */ + int ret; + + if(expr->expr_type != ASN_BASIC_ENUMERATED) + return 0; /* Just ignore it */ + + DEBUG("%s(%s)", __func__, expr->Identifier); + + /* + * 1. Scan the enumeration values in search for inconsistencies. + */ + TQ_FOR(ev, &(expr->members), next) { + asn1_integer_t eval; + + if(ev->value) + DEBUG("\tItem %s(%s)", ev->Identifier, + asn1f_printable_value(ev->value)); + else + DEBUG("\tItem %s", ev->Identifier); + + /* + * 1.1 Found an extension mark "...", check correctness. + */ + if(ev->expr_type == A1TC_EXTENSIBLE) { + if(ext_marker) { + arg->eh(1, + "Enumeration %s at line %d: " + "Second extension marker is not allowed", + expr->Identifier, + ev->_lineno); + rvalue = -1; + } else { + /* + * Remember the marker's position. + */ + ext_marker = ev; + } + continue; + } else if(ev->Identifier == NULL + || ev->expr_type != A1TC_UNIVERVAL) { + FATAL( + "Enumeration %s at line %d: " + "Unsupported enumeration element %s", + expr->Identifier, + ev->_lineno, + ev->Identifier?ev->Identifier:""); + rvalue = -1; + continue; + } + + /* + * 1.2 Compute the value of the enumeration element. + */ + if(ev->value) { + switch(ev->value->type) { + case ATV_INTEGER: + eval = ev->value->value.v_integer; + break; + case ATV_REFERENCED: + FATAL("HERE HERE HERE", 1); + rvalue = -1; + continue; + break; + default: + FATAL("ENUMERATED type %s at line %d " + "contain element %s(%s) at line %d", + expr->Identifier, expr->_lineno, + ev->Identifier, + asn1f_printable_value(ev->value), + ev->_lineno); + rvalue = -1; + continue; + } + } else { + eval = max_value + 1; + ev->value = asn1p_value_fromint(eval); + if(ev->value == NULL) { + rvalue = -1; + continue; + } + } + + /* + * 1.3 Check the applicability of this value. + */ + if(eval <= max_value) { + if(ext_marker) { + /* + * Enumeration is allowed to be unordered + * before the first marker. + */ + FATAL( + "Enumeration %s at line %d: " + "Explicit value \"%s(%lld)\" " + "is not greater " + "than previous values (max %lld)", + expr->Identifier, + ev->_lineno, + ev->Identifier, + eval, + max_value); + rvalue = -1; + } + } else if(eval > max_value) { + max_value = eval; + } + + /* + * 1.4 Check that all identifiers before the current one + * differs from it. + */ + ret = asn1f_check_unique_expr_child(arg, ev, NULL); + RET2RVAL(ret, rvalue); + } + + + /* + * 2. Reorder the first half (before optional "...") of the + * identifiers alphabetically. + */ + // TODO + + return rvalue; +} + diff --git a/libasn1fix/asn1fix_enum.h b/libasn1fix/asn1fix_enum.h new file mode 100644 index 00000000..14c6fb52 --- /dev/null +++ b/libasn1fix/asn1fix_enum.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_ENUM_H_ +#define _ASN1FIX_ENUM_H_ + +int asn1f_fix_enum(arg_t *); /* Enumeration ::= ENUMERATED { a(1), b(2) } */ + +#endif /* _ASN1FIX_ENUM_H_ */ diff --git a/libasn1fix/asn1fix_export.c b/libasn1fix/asn1fix_export.c new file mode 100644 index 00000000..d6bb37b4 --- /dev/null +++ b/libasn1fix/asn1fix_export.c @@ -0,0 +1,48 @@ +#include "asn1fix_internal.h" +#include "asn1fix_export.h" + +asn1p_expr_t * +asn1f_lookup_symbol_ex( + asn1p_t *asn, + asn1p_module_t **module_rw, + asn1p_expr_t *expr, + asn1p_ref_t *ref) { + arg_t arg; + + memset(&arg, 0, sizeof(arg)); + + arg.asn = asn; + arg.mod = *module_rw; + arg.expr = expr; + + return asn1f_lookup_symbol(&arg, ref, module_rw); +} + +asn1p_expr_t * +asn1f_class_access_ex(asn1p_t *asn, + asn1p_module_t *mod, + asn1p_expr_t *expr, + asn1p_ref_t *ref, + asn1p_module_t **mod_r) { + static arg_t arg; + + arg.asn = asn; + arg.mod = mod; + arg.expr = expr; + + return asn1f_class_access(&arg, ref, mod_r); +} + +asn1p_expr_t * +asn1f_find_terminal_type_ex(asn1p_t *asn, + asn1p_module_t *mod, + asn1p_expr_t *expr, + asn1p_module_t **mod_r) { + static arg_t arg; + + arg.asn = asn; + arg.mod = mod; + arg.expr = expr; + + return asn1f_find_terminal_type(&arg, expr, mod_r); +} diff --git a/libasn1fix/asn1fix_export.h b/libasn1fix/asn1fix_export.h new file mode 100644 index 00000000..2ade0c9a --- /dev/null +++ b/libasn1fix/asn1fix_export.h @@ -0,0 +1,32 @@ +/* + * This header exports fixer procedures that are common enough to be used + * in other modules. + */ +#ifndef _ASN1FIX_EXPORT_H_ +#define _ASN1FIX_EXPORT_H_ + +#include + +/* + * Exportable version of an asn1f_lookup_symbol(). + */ +asn1p_expr_t *asn1f_lookup_symbol_ex( + asn1p_t *asn, + asn1p_module_t **module_rw, + asn1p_expr_t *expr, + asn1p_ref_t *ref); + +/* + * Exportable version of an asn1f_class_access(). + */ +asn1p_expr_t *asn1f_class_access_ex(asn1p_t *asn, asn1p_module_t *mod, + asn1p_expr_t *expr, asn1p_ref_t *, asn1p_module_t **mod_r); + +/* + * Exportable version of asn1f_find_terminal_type(). + */ +asn1p_expr_t *asn1f_find_terminal_type_ex(asn1p_t *asn, asn1p_module_t *mod, + asn1p_expr_t *tc, asn1p_module_t **opt_module_r); + +#endif /* _ASN1FIX_EXPORT_H_ */ + diff --git a/libasn1fix/asn1fix_integer.c b/libasn1fix/asn1fix_integer.c new file mode 100644 index 00000000..514ab70e --- /dev/null +++ b/libasn1fix/asn1fix_integer.c @@ -0,0 +1,161 @@ +#include "asn1fix_internal.h" + +static int _compare_value(asn1p_expr_t *expr1, asn1p_expr_t *expr2) { + if(expr2->value->type == ATV_INTEGER + && expr1->value->type == ATV_INTEGER) { + return expr2->value->value.v_integer + - expr1->value->value.v_integer; + } else { + return -1; + } +} + +/* + * Check the validity of an INTEGER type. + */ +int +asn1f_fix_integer(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *iv; + int rvalue = 0; + int ret; + + if(expr->expr_type != ASN_BASIC_INTEGER) + return 0; /* Just ignore it */ + + DEBUG("%s(\"%s\", %x) for line %d", __func__, + expr->Identifier, expr->expr_type, expr->_lineno); + + /* + * Scan the integer values in search for inconsistencies. + */ + TQ_FOR(iv, &(expr->members), next) { + + DEBUG("\tItem %s(%s)", iv->Identifier, + asn1f_printable_value(iv->value)); + + /* + * Found "...", check correctness. + */ + if(iv->expr_type == A1TC_EXTENSIBLE) { + arg->eh(1, + "INTEGER %s at line %d: " + "Extension marker is not allowed", + expr->Identifier, + iv->_lineno + ); + rvalue = -1; + continue; + } + + if(iv->Identifier == NULL + || iv->expr_type != A1TC_UNIVERVAL) { + arg->eh(1, + "INTEGER %s at line %d: " + "Unsupported enumeration element %s", + expr->Identifier, + iv->_lineno, + iv->Identifier?iv->Identifier:"" + ); + rvalue = -1; + continue; + } + + if(iv->value == NULL) { + arg->eh(1, + "INTEGER %s at line %d: " + "Value for the identifier %s " + "must be set explicitly", + expr->Identifier, + iv->_lineno, + iv->Identifier + ); + rvalue = -1; + continue; + } else if(iv->value->type == ATV_REFERENCED) { + /* + * Resolve the value, once and for all. + */ + if(asn1f_value_resolve(arg, iv)) { + /* This function will emit messages */ + rvalue = -1; + continue; + } + } + + if(iv->value->type != ATV_INTEGER) { + arg->eh(1, + "INTEGER %s at line %d: " + "Value for the identifier %s " + "is not compatible with INTEGER type", + expr->Identifier, + iv->_lineno); + rvalue = -1; + continue; + } + + /* + * Check that all identifiers are distinct. + */ + ret = asn1f_check_unique_expr_child(arg, iv, NULL); + RET2RVAL(ret, rvalue); + /* + * Check that all values are distinct. + */ + ret = asn1f_check_unique_expr_child(arg, iv, _compare_value); + RET2RVAL(ret, rvalue); + } + + + return rvalue; +} + +static int +_asn1f_make_sure_type_is(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_type_e type) { + asn1p_module_t *mod = NULL; + asn1p_expr_t *next_expr; + int expr_type; + int ret; + + expr_type = expr->expr_type; + + /* + * Here we're trying to make sure that the type of the given + * expression is really what is expected. + * This is ensured in two ways. + * First, if the immediate type matches the provided one, + * this is a clear hit. + */ + if(expr_type == type) + return 0; + + /* + * Otherwise, it must be either a reference or a different type. + */ + if(expr_type != A1TC_REFERENCE) { + errno = EPERM; + return -1; + } + + assert(expr_type == A1TC_REFERENCE); + assert(expr->reference); + + /* + * Then, it is a reference. For a reference, try to resolve type + * and try again. + */ + next_expr = asn1f_lookup_symbol(arg, expr->reference, &mod); + if(next_expr == NULL) { + errno = ESRCH; + return -1; + } + + /* + * If symbol is here, recursively check that it conforms to the type. + */ + WITH_MODULE(mod, ret = _asn1f_make_sure_type_is(arg, next_expr, type)); + + return ret; +} + + diff --git a/libasn1fix/asn1fix_integer.h b/libasn1fix/asn1fix_integer.h new file mode 100644 index 00000000..d306fc03 --- /dev/null +++ b/libasn1fix/asn1fix_integer.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_INTEGER_H_ +#define _ASN1FIX_INTEGER_H_ + +int asn1f_fix_integer(arg_t *); /* Type1 ::= INTEGER { a(1), b(2) } */ + +#endif /* _ASN1FIX_INTEGER_H_ */ diff --git a/libasn1fix/asn1fix_internal.h b/libasn1fix/asn1fix_internal.h new file mode 100644 index 00000000..ff3b4e96 --- /dev/null +++ b/libasn1fix/asn1fix_internal.h @@ -0,0 +1,106 @@ +#ifndef _ASN1FIX_INTERNAL_H_ +#define _ASN1FIX_INTERNAL_H_ + +/* + * System headers required in various modules. + */ +#include +#include +#include +#include /* isupper() */ +#include +#include + +#include /* Our lovely ASN.1 parser module */ + +/* + * A definition of a function that will log error messages. + */ +typedef void (*error_logger_f)(int _is_fatal, const char *fmt, ...); + +/* + * Universal argument. + */ +typedef struct arg_s { + asn1p_t *asn; + asn1p_module_t *mod; + asn1p_expr_t *expr; + error_logger_f eh; + error_logger_f debug; + void *key; /* The next level key */ +} arg_t; + +/* + * Functions performing normalization of various types. + */ +#include "asn1fix_misc.h" /* Support functions */ +#include "asn1fix_value.h" /* Value processing */ +#include "asn1fix_cstring.h" /* Fix cstring values */ +#include "asn1fix_compat.h" /* Data compatibility */ +#include "asn1fix_constr.h" /* Constructed types */ +#include "asn1fix_class.h" /* CLASS support */ +#include "asn1fix_param.h" /* Parametrization */ +#include "asn1fix_retrieve.h" /* Data retrieval */ +#include "asn1fix_enum.h" /* Process ENUMERATED */ +#include "asn1fix_integer.h" /* Process INTEGER */ +#include "asn1fix_bitstring.h" /* Process BIT STRING */ +#include "asn1fix_dereft.h" /* Dereference types */ +#include "asn1fix_derefv.h" /* Dereference values */ +#include "asn1fix_tags.h" /* Tags-related stuff */ + + +/* + * Merge the return value of the called function with the already + * partially computed return value of the current function. + */ +#define RET2RVAL(ret,rv) do { \ + int __ret = ret; \ + switch(__ret) { \ + case 0: break; \ + case 1: if(rv) break; \ + case -1: rv = __ret; break; \ + default: \ + assert(__ret >= -1 && __ret <= 1); \ + rv = -1; \ + } \ + } while(0) + +/* + * Temporary substitute module for the purposes of evaluating expression. + */ +#define WITH_MODULE(tmp_mod, expr) do { \ + void *_saved_mod = arg->mod; \ + arg->mod = tmp_mod; \ + do { expr; } while(0); \ + arg->mod = _saved_mod; \ + } while(0) + +#define LOG(code, fmt, args...) do { \ + int _save_errno = errno; \ + if(code < 0) { \ + if(arg->debug) \ + arg->debug(code, fmt, ##args); \ + } else { \ + arg->eh(code, fmt " in %s", ##args, \ + arg->mod->source_file_name); \ + } \ + errno = _save_errno; \ + } while(0) + +#define DEBUG(fmt, args...) LOG(-1, fmt, ##args) +#define FATAL(fmt, args...) LOG( 1, fmt, ##args) +#define WARNING(fmt, args...) LOG( 0, fmt, ##args) + + +/* + * Define the symbol corresponding to the name of the current function. + */ +#if __STDC_VERSION__ < 199901 +#if !(__GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3) +#define __func__ (char *)0 /* Name of the current function */ +#endif /* GNUC */ +/* __func__ is supposed to be defined */ +#endif + + +#endif /* _ASN1FIX_INTERNAL_H_ */ diff --git a/libasn1fix/asn1fix_misc.c b/libasn1fix/asn1fix_misc.c new file mode 100644 index 00000000..5fe69034 --- /dev/null +++ b/libasn1fix/asn1fix_misc.c @@ -0,0 +1,276 @@ +#include "asn1fix_internal.h" + + +char const * +asn1f_printable_reference(asn1p_ref_t *ref) { + if(ref) { + asn1p_value_t v; + + v.type = ATV_REFERENCED; + v.value.reference = ref; + + return asn1f_printable_value(&v); + } else { + return ""; + } +} + +char const * +asn1f_printable_value(asn1p_value_t *v) { + static char buf[128]; + static char *managedptr; + static int managedptr_len; + int ret; + +#define ENSURE(len) do { \ + if(len >= managedptr_len) { \ + if(managedptr) \ + free(managedptr); \ + managedptr = malloc(len + 1); \ + if(managedptr) { \ + managedptr_len = len; \ + } else { \ + managedptr_len = 0; \ + return ""; \ + } \ + } \ + } while(0) + + if(v == NULL) + return ""; + + switch(v->type) { + case ATV_NOVALUE: + return ""; + case ATV_REFERENCED: + { + asn1p_ref_t *ref; + char reflen; + char *ptr; + int i; + + assert(v->value.reference); + ref = v->value.reference; + reflen = ref->comp_count; /* Number of dots */ + for(i = 0; i < ref->comp_count; i++) + reflen += strlen(ref->components[i].name); + /* + * Make sure we have a buffer of this size. + */ + ENSURE(reflen); + + /* + * Fill-up the buffer. + */ + ptr = managedptr; + for(i = 0; i < ref->comp_count; i++) { + char *nc; + if(i) *ptr++ = '.'; + for(nc = ref->components[i].name; *nc; nc++) + *ptr++ = *nc; + } + *ptr++ = '\0'; + assert(reflen == (ptr - managedptr)); + return managedptr; + } + case ATV_REAL: + ret = snprintf(buf, sizeof(buf), "%f", v->value.v_double); + if(ret >= sizeof(buf)) + memcpy(buf + sizeof(buf) - 4, "...", 4); + return buf; + case ATV_INTEGER: + ret = snprintf(buf, sizeof(buf), "%lld", + (long long)v->value.v_integer); + if(ret >= sizeof(buf)) + memcpy(buf + sizeof(buf) - 4, "...", 4); + return buf; + case ATV_MIN: return "MIN"; + case ATV_MAX: return "MAX"; + case ATV_FALSE: return "FALSE"; + case ATV_TRUE: return "TRUE"; + case ATV_STRING: + case ATV_UNPARSED: + /* Buffer is guaranteed to be null-terminated */ + assert(v->value.string.buf[v->value.string.size] == '\0'); + return v->value.string.buf; + case ATV_BITVECTOR: + { + uint8_t *bitvector; + char *ptr; + int len; + int i; + /* + * Compute number of bytes necessary + * to represend the binary value. + */ + int bits = v->value.binary_vector.size_in_bits; + len = ((bits%8)?bits:(bits >> 2)) + sizeof("''H"); + /* + * Reallocate managed buffer + */ + ENSURE(len); + + /* + * Fill the buffer. + */ + ptr = managedptr; + bitvector = v->value.binary_vector.bits; + *ptr++ = '\''; + if(bits%8) { + /* + * Dump bit by bit. + */ + for(i = 0; i < bits; i++) { + uint8_t uc; + uc = bitvector[i>>3]; + *ptr++ = ((uc >> (7-(i%8)))&1)?'1':'0'; + } + } else { + char hextable[16] = "0123456789ABCDEF"; + /* + * Dump byte by byte. + */ + for(i = 0; i < (bits >> 3); i++) { + *ptr++ = hextable[bitvector[i] >> 4]; + *ptr++ = hextable[bitvector[i] & 0x0f]; + } + } + *ptr++ = '\''; + *ptr++ = (bits%8)?'B':'H'; + *ptr++ = 'H'; + assert((ptr - managedptr) == len); + return managedptr; + } + } + + return ""; +} + + +/* + * Recursively invoke a given function over the given expr and all its + * children. + */ +int +asn1f_recurse_expr(arg_t *arg, int (*callback)(arg_t *arg)) { + asn1p_expr_t *expr = arg->expr; + int rvalue = 0; + int ret; + + assert(expr); + + /* + * Invoke the callback at this very level. + */ + ret = callback(arg); + RET2RVAL(ret, rvalue); + + /* + * Recursively invoke myself + * to iterate over each element in the tree. + */ + TQ_FOR(arg->expr, &(expr->members), next) { + assert(arg->expr->expr_type != A1TC_INVALID); + ret = asn1f_recurse_expr(arg, callback); + RET2RVAL(ret, rvalue); + } + + arg->expr = expr; /* Restore original position */ + + return rvalue; +} + + +/* + * Check that every child of a given expr has unique name or does not have any. + */ +int +asn1f_check_unique_expr(arg_t *arg, + int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b)) { + asn1p_expr_t *expr; + int rvalue = 0; + + TQ_FOR(expr, &(arg->expr->members), next) { + if(expr->Identifier) { + int ret = asn1f_check_unique_expr_child(arg, expr, + opt_compare); + if(ret) rvalue = -1; + } else { + /* + * No point of comparing this child with any other: + * this one does not have a name. + */ + } + } + + return rvalue; +} + +/* + * Check that every preceeding child of the given expr is not + * having the name of the given one. + */ +int +asn1f_check_unique_expr_child(arg_t *arg, asn1p_expr_t *child, + int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b)) { + asn1p_expr_t *expr; + int rvalue = 0; + + assert(child); + assert(opt_compare || child->Identifier); + + TQ_FOR(expr, &(arg->expr->members), next) { + int ret; + + if(expr == child) + break; + + /* + * Compare according to the custom rule or default + * names comparisons. + */ + if(opt_compare) { + ret = opt_compare(expr, child); + } else { + if(expr->Identifier == NULL + || expr->expr_type == A1TC_EXTENSIBLE) + continue; + ret = strcasecmp(expr->Identifier, child->Identifier); + } + + if(ret == 0) { + char *msg; + msg = opt_compare + ?"Expressions clash" + :"Identifiers name clash"; + arg->eh(1, + "%s: " + "\"%s\" at line %d has similar %s with " + "\"%s\" at line %d", + msg, + expr->Identifier, + expr->_lineno, + opt_compare?"property":"name", + child->Identifier, + child->_lineno + ); + + rvalue = -1; + } + } + + return rvalue; +} + +int +asn1f_count_children(asn1p_expr_t *expr) { + asn1p_expr_t *child; + int count = 0; + + TQ_FOR(child, &(expr->members), next) { + count++; + } + + return count; +} + diff --git a/libasn1fix/asn1fix_misc.h b/libasn1fix/asn1fix_misc.h new file mode 100644 index 00000000..e88e4322 --- /dev/null +++ b/libasn1fix/asn1fix_misc.h @@ -0,0 +1,47 @@ +/* + * Miscellaneous functions necessary for several other modules. + */ +#ifndef _ASN1FIX_MISC_H_ +#define _ASN1FIX_MISC_H_ + +/* + * Return a pointer to the locally held string with human-readable + * definition of the value. + */ +char const *asn1f_printable_value(asn1p_value_t *); + +/* + * Return a pointer to the locally held string with human-readable + * definition of the reference. + */ +char const *asn1f_printable_reference(asn1p_ref_t *); + +/* + * Recursively invoke a given function over the given expr and all its + * children. + */ +int asn1f_recurse_expr(arg_t *arg, int (*f)(arg_t *arg)); + +/* + * Check that every child of a given expr has unique name or does not have any. + * If opt_compare == NULL, the default comparison of the argument's + * names (identifiers) will be performed. + */ +int asn1f_check_unique_expr(arg_t *arg, + int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b)); + +/* + * Check that every preceeding child of the given expr is not + * having the name of the given one. + * If opt_compare == NULL, the default comparison of the argument's + * names (identifiers) will be performed. + */ +int asn1f_check_unique_expr_child(arg_t *arg, asn1p_expr_t *child, + int (*opt_compare)(asn1p_expr_t *a, asn1p_expr_t *b)); + +/* + * Return number of children. + */ +int asn1f_count_children(asn1p_expr_t *parent); + +#endif /* _ASN1FIX_MISC_H_ */ diff --git a/libasn1fix/asn1fix_param.c b/libasn1fix/asn1fix_param.c new file mode 100644 index 00000000..0c838cc5 --- /dev/null +++ b/libasn1fix/asn1fix_param.c @@ -0,0 +1,165 @@ +#include "asn1fix_internal.h" + +static int asn1f_parametrize(arg_t *arg, asn1p_expr_t *ex, asn1p_expr_t *ptype); +static int asn1f_param_process_recursive(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptype, asn1p_expr_t *actargs); +static asn1p_expr_t *_referenced_argument(asn1p_ref_t *ref, asn1p_expr_t *ptype, asn1p_expr_t *actargs); + +int +asn1f_fix_parametrized_assignment(arg_t *arg) { + asn1p_expr_t *expr = arg->expr; + asn1p_expr_t *ptype; + + assert(expr->expr_type == A1TC_PARAMETRIZED); + assert(expr->reference); + + DEBUG("%s(\"%s\" ::= \"%s\" { %s }) for line %d", + __func__, expr->Identifier, + asn1f_printable_reference(expr->reference), + asn1f_printable_value(expr->value), + expr->_lineno); + + /* + * Find the corresponding parametrized type definition. + */ + DEBUG("Looking for parametrized type definition \"%s\"", + asn1f_printable_reference(expr->reference)); + ptype = asn1f_lookup_symbol(arg, expr->reference, 0); + if(ptype == NULL) { + DEBUG("%s: missing parametrized type declaration", + asn1f_printable_reference(expr->reference)); + return -1; + } + + /* + * Check that the number of arguments which are expected by + * the parametrized type declaration is consistent with the + * number of arguments supplied by the parametrized assignment. + */ + if(asn1f_count_children(expr) != ptype->params->params_count) { + FATAL("Number of actual arguments %d in %s at line %d " + "is not equal to number of expected arguments " + "%d in %s at line %d", + asn1f_count_children(expr), + asn1f_printable_reference(expr->reference), + expr->_lineno, + ptype->params->params_count, + ptype->Identifier, + ptype->_lineno + ); + return -1; + } + + /* + * Perform an expansion of a parametrized assignment. + */ + return asn1f_parametrize(arg, expr, ptype); +} + +#define SUBSTITUTE(to, from) do { \ + asn1p_expr_t tmp; \ + tmp = *(to); \ + *(to) = *(from); \ + *(from) = tmp; \ + (to)->next = tmp.next; \ + memset(&((from)->next), 0, \ + sizeof((from)->next)); \ + asn1p_expr_free(from); \ + } while(0) + +static int +asn1f_parametrize(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptype) { + asn1p_expr_t *nex; + void *p; + int ret; + + /* + * The algorithm goes like that: + * 1. Replace the expression's type with parametrized type. + * 2. For every child in the parametrized type, import it + * as a child of the expression, replacing all occurences of + * symbols which are defined as parametrized type arguments + * with the actual values. + */ + + nex = asn1p_expr_clone(ptype); + if(nex == NULL) return -1; + + /* + * Cleanup the new expression so there is no ptype-related + * stuff hanging around. + */ + p = strdup(expr->Identifier); + if(p) { + free(nex->Identifier); + nex->Identifier = p; + } else { + asn1p_expr_free(nex); + return -1; + } + asn1p_paramlist_free(nex->params); + nex->params = NULL; + nex->meta_type = expr->meta_type; + + ret = asn1f_param_process_recursive(arg, nex, ptype, expr); + if(ret != 0) { + asn1p_expr_free(nex); + return ret; + } + + SUBSTITUTE(expr, nex); + + return ret; +} + +static int +asn1f_param_process_recursive(arg_t *arg, asn1p_expr_t *expr, asn1p_expr_t *ptype, asn1p_expr_t *actargs) { + asn1p_expr_t *child; + + TQ_FOR(child, &(expr->members), next) { + asn1p_expr_t *ra; + asn1p_expr_t *ne; + + ra = _referenced_argument(child->reference, ptype, actargs); + if(ra == NULL) continue; + + DEBUG("Substituting parameter for %s %s at line %d", + child->Identifier, + asn1f_printable_reference(child->reference), + child->_lineno + ); + + assert(child->meta_type == AMT_TYPEREF); + assert(child->expr_type == A1TC_REFERENCE); + + ne = asn1p_expr_clone(ra); + if(ne == NULL) return -1; + assert(ne->Identifier == 0); + ne->Identifier = strdup(child->Identifier); + if(ne->Identifier == 0) { + asn1p_expr_free(ne); + return -1; + } + SUBSTITUTE(child, ne); + } + + return 0; +} + +static asn1p_expr_t * +_referenced_argument(asn1p_ref_t *ref, asn1p_expr_t *ptype, asn1p_expr_t *actargs) { + asn1p_expr_t *aa; + int i; + + if(ref == NULL || ref->comp_count != 1) + return NULL; + + aa = TQ_FIRST(&(actargs->members)); + for(i = 0; i < ptype->params->params_count; + i++, aa = TQ_NEXT(aa, next)) { + if(strcmp(ref->components[0].name, + ptype->params->params[i].argument) == 0) + return aa; + } + + return NULL; +} diff --git a/libasn1fix/asn1fix_param.h b/libasn1fix/asn1fix_param.h new file mode 100644 index 00000000..062ad8bd --- /dev/null +++ b/libasn1fix/asn1fix_param.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_PARAMETRIZATION_H_ +#define _ASN1FIX_PARAMETRIZATION_H_ + +int asn1f_fix_parametrized_assignment(arg_t *arg); + +#endif /* _ASN1FIX_PARAMETRIZATION_H_ */ diff --git a/libasn1fix/asn1fix_retrieve.c b/libasn1fix/asn1fix_retrieve.c new file mode 100644 index 00000000..0dfcce40 --- /dev/null +++ b/libasn1fix/asn1fix_retrieve.c @@ -0,0 +1,366 @@ +#include "asn1fix_internal.h" + +static asn1p_expr_t *asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr, asn1p_module_t **optm, int type_or_value); +static int asn1f_compatible_with_exports(arg_t *arg, asn1p_module_t *mod, const char *name); + + +/* + * Lookup a child by its name. + */ +asn1p_expr_t * +asn1f_lookup_child(asn1p_expr_t *tc, const char *name) { + asn1p_expr_t *child_tc; + + TQ_FOR(child_tc, &(tc->members), next) { + if(child_tc->Identifier + && strcmp(child_tc->Identifier, name) == 0) { + return child_tc; + } + } + + errno = ESRCH; + return NULL; +} + +asn1p_module_t * +asn1f_lookup_in_imports(arg_t *arg, const char *name) { + asn1p_module_t *mod; + asn1p_xports_t *xp; + asn1p_expr_t *tc; + + /* + * Search in which exactly module this name is defined. + */ + TQ_FOR(xp, &(arg->mod->imports), xp_next) { + TQ_FOR(tc, &(xp->members), next) { + if(strcmp(name, tc->Identifier) == 0) + break; + } + if(tc) break; + } + if(xp == NULL) { + errno = ESRCH; + return NULL; + } + + /* + * Okay, right now we have a module name and, hopefully, an OID. + * Search the arg->asn for the specified module. + */ + mod = asn1f_lookup_module(arg, xp->from, xp->from_oid); + if(mod == NULL) { + /* ENOENT/ETOOMANYREFS */ + return NULL; + } + + /* + * Check that the EXPORTS section of this module contains + * the symbol we care about, or it is EXPORTS ALL. + */ + if(asn1f_compatible_with_exports(arg, mod, name)) { + errno = EPERM; + return NULL; + } + + return mod; +} + +asn1p_module_t * +asn1f_lookup_module(arg_t *arg, const char *module_name, asn1p_oid_t *oid) { + asn1p_module_t *mod; + + assert(module_name); + + /* + * If OID is given, the module_name is unused. + * If OID is not given, the module_name may mean + * either the real module's name, or the symbol which is the + * result of renaming. Check this first. + */ + if(oid == 0) { + asn1p_xports_t *xp; + /* + * Check inside the IMPORTS section for possible renaming. + * Renaming practically means that a module_name is mentioned + * somewhere in the IMPORTS section AND OID is given. + */ + TQ_FOR(xp, &(arg->mod->imports), xp_next) { + if(strcmp(module_name, xp->from)) + continue; + if(oid) { + FATAL("Ambiguous reference: " + "%s " + "matches several modules", + module_name); + errno = ETOOMANYREFS; + return NULL; + } + /* + * Yes, there is a renaming. + * Make lookup use OID instead. + */ + oid = xp->from_oid; + } + } + + /* + * Perform lookup using OID or module_name. + */ + TQ_FOR(mod, &(arg->asn->modules), mod_next) { + if(oid) { + if(mod->module_oid) { + if(asn1p_oid_compare(oid, + mod->module_oid)) { + continue; + } else { + /* Match! Even if name doesn't. */ + return mod; + } + } else { + /* Not match, even if name is the same. */ + continue; + } + } + + if(strcmp(module_name, mod->Identifier) == 0) + return mod; + } + + DEBUG("\tModule \"%s\" not found", module_name); + + errno = ENOENT; + return NULL; +} + + + +asn1p_expr_t * +asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref, asn1p_module_t **module_r) { + asn1p_expr_t *ref_tc; /* Referenced tc */ + asn1p_module_t *src_mod; + char *modulename; + char *identifier; + + /* + * First of all, a reference to a symbol may be specified + * using several possible forms: + * a) simple identifier + * v INTEGER ::= value + * b) external reference + * v INTEGER ::= Module1.value + * c) class-related stuff (the most complex stuff) + * v ::= <[A-Z][A-Z0-9a-z-]*>.&<[A-Z0-9a-z-]+>. + * All other forms are not implemented at this moment. + */ + + DEBUG("%s(%s) in %s for line %d", __func__, + asn1f_printable_reference(ref), + arg->mod->Identifier, + ref->_lineno); + + if(ref->comp_count == 1) { + modulename = NULL; + identifier = ref->components[0].name; + } else if(ref->comp_count == 2 + && ref->components[1].name[0] != '&') { + modulename = ref->components[0].name; + identifier = ref->components[1].name; + } else if(ref->comp_count > 1 + && isupper(ref->components[0].name[0]) + && ref->components[1].name[0] == '&') { + asn1p_expr_t *extract; + /* + * This is a reference to a CLASS-related stuff. + * Employ a separate function for that. + */ + extract = asn1f_class_access(arg, ref, module_r); + + return extract; + } else { + DEBUG("\tToo many components: %d", ref->comp_count); + errno = EINVAL; + return NULL; + } + + /* + * If module name is specified explicitly + * OR the current module's IMPORTS clause contains the identifier, + * fetch that module. + */ + if(modulename) { + src_mod = asn1f_lookup_module(arg, modulename, 0); + if(src_mod == NULL) { + FATAL("Module \"%s\" " + "mentioned at line %d is not found", + modulename, ref->_lineno); + return NULL; + } + + /* + * Check that the EXPORTS section of this module contains + * the symbol we care about, or it is EXPORTS ALL. + */ + if(asn1f_compatible_with_exports(arg, src_mod, identifier)) { + errno = EPERM; + return NULL; + } + } else { + src_mod = asn1f_lookup_in_imports(arg, identifier); + if(src_mod == NULL && errno != ESRCH) { + /* + * Return only of the name was not found. + * If module was not found or more serious error + * encountered, just return preserving the errno. + */ + return NULL; + } + } + + if(src_mod == 0) src_mod = arg->mod; + + /* + * Now we know where to search for a value. + */ + TQ_FOR(ref_tc, &(src_mod->members), next) { + if(ref_tc->Identifier) + if(strcmp(ref_tc->Identifier, identifier) == 0) + break; + } + if(ref_tc == NULL) { + DEBUG("Module \"%s\" does not contain \"%s\" " + "mentioned at line %d", + src_mod->Identifier, + identifier, + ref->_lineno + ); + errno = ESRCH; + return NULL; + } + + if(module_r) + *module_r = src_mod; + + return ref_tc; +} + + +asn1p_expr_t * +asn1f_find_terminal_type(arg_t *arg, asn1p_expr_t *expr, + asn1p_module_t **optm) { + return asn1f_find_terminal_thing(arg, expr, optm, 0); +} + +asn1p_expr_t * +asn1f_find_terminal_value(arg_t *arg, asn1p_expr_t *expr, + asn1p_module_t **optm) { + return asn1f_find_terminal_thing(arg, expr, optm, 1); +} + +static asn1p_expr_t * +asn1f_find_terminal_thing(arg_t *arg, asn1p_expr_t *expr, + asn1p_module_t **optm, int type_or_value) { + asn1p_module_t *mod; + asn1p_ref_t *ref; + asn1p_expr_t *tc; + + if(type_or_value) { + /* VALUE */ + assert(expr->meta_type == AMT_VALUE); + assert(expr->value); + if(expr->value->type != ATV_REFERENCED) { + /* Expression is a terminal value itself */ + if(optm) *optm = arg->mod; + return expr; + } + ref = expr->value->value.reference; + } else { + /* TYPE */ + if(expr->expr_type != A1TC_REFERENCE) { + /* Expression is a terminal type itself */ + if(optm) *optm = arg->mod; + return expr; + } + ref = expr->reference; + } + + DEBUG("%s:%s(%s->%s) for line %d", + __func__, type_or_value?"VALUE":"TYPE", + expr->Identifier, asn1f_printable_reference(ref), + expr->_lineno); + + assert(ref); + + /* + * Lookup inside the type itself (ENUMERATED, INTEGER, etc). + */ + if(type_or_value) { + asn1p_expr_t *val_type_tc; + val_type_tc = asn1f_find_terminal_type(arg, expr, 0); + if(val_type_tc + && asn1f_look_value_in_type(arg, val_type_tc, expr)) + return NULL; + if(expr->value->type != ATV_REFERENCED) { + if(optm) *optm = arg->mod; + return expr; + } + assert(ref == expr->value->value.reference); + ref = expr->value->value.reference; + } + + /* + * Lookup inside the default module. + */ + tc = asn1f_lookup_symbol(arg, ref, &mod); + if(tc == NULL) { + DEBUG("\tSymbol \"%s\" not found", + asn1f_printable_reference(ref)); + return NULL; + } + + /* + * Recursive loops detection. + */ + if(tc->_mark & TM_RECURSION) { + DEBUG("Recursion loop detected for %s at line %d", + asn1f_printable_reference(ref), ref->_lineno); + errno = EPERM; + return NULL; + } + + tc->_mark |= TM_RECURSION; + WITH_MODULE(mod, + expr = asn1f_find_terminal_thing(arg, tc, optm, type_or_value)); + tc->_mark &= ~TM_RECURSION; + + return expr; +} + +/* + * Make sure that the specified name is present or otherwise does + * not contradict with the EXPORTS clause of the specified module. + */ +static int +asn1f_compatible_with_exports(arg_t *arg, asn1p_module_t *mod, const char *name) { + asn1p_xports_t *exports; + asn1p_expr_t *item; + + assert(mod); + assert(name); + + exports = TQ_FIRST(&(mod->exports)); + if(exports == NULL) { + /* No EXPORTS section or EXPORTS ALL; */ + return 0; + } + + TQ_FOR(item, &(exports->members), next) { + if(strcmp(item->Identifier, name) == 0) + return 0; + } + + DEBUG("Symbol \"%s\" contradicts with EXPORTS of module %s", + name, mod->Identifier); + + errno = ESRCH; + return -1; +} diff --git a/libasn1fix/asn1fix_retrieve.h b/libasn1fix/asn1fix_retrieve.h new file mode 100644 index 00000000..47aa0a5b --- /dev/null +++ b/libasn1fix/asn1fix_retrieve.h @@ -0,0 +1,73 @@ +/* + * Miscellaneous functions necessary for several other modules. + */ +#ifndef _ASN1FIX_RETRIEVE_H_ +#define _ASN1FIX_RETRIEVE_H_ + +/* + * Simple search for the label in the descendants of the given node. + * ERRORS: + * NULL/ESRCH + */ +asn1p_expr_t *asn1f_lookup_child(asn1p_expr_t *tc, const char *name); + +/* + * Return a module which contain a specified name, as stated in appropriate + * IMPORTS section of the current module (arg->mod). + * + * RETURN VALUES: + * NULL/ESRCH: The name was not found in IMPORTS section. + * NULL/EPERM: The name was not found in EXPORTS section of the source module. + * Also, NULL with errno values defined by asn1f_lookup_module(). + */ +asn1p_module_t *asn1f_lookup_in_imports(arg_t *arg, const char *name); + +/* + * Return a module by its name or optional OID. + * + * RETURN VALUES: + * NULL/ENOENT: No module was found by the specified name and oid + * NULL/ETOOMANYREFS: Several modules are matching the specified name and oid + */ +asn1p_module_t *asn1f_lookup_module(arg_t *arg, + const char *module_name, + asn1p_oid_t *module_oid); + +/* + * Return the reference to a destination of the given reference, + * symbol lookup. Not a recursive function. + * Optional module reference may be assigned a module in which the + * particular expr was found. + */ +asn1p_expr_t *asn1f_lookup_symbol(arg_t *arg, asn1p_ref_t *ref, + asn1p_module_t **opt_module_r); + +/* + * Recursively find the original type for the given expression. + * i.e.: + * If the original specification defines + * v Type1 ::= 5 + * Type1 ::= Type2 (1..5) + * Type3 ::= Type4 (2..7) + * Type4 ::= INTEGER (1..10) + * Then this function, given the the first expression as an argument, + * would return an expression for Type4. + * WARNING: No attempts are made to honor constraints at this moment. + */ +asn1p_expr_t *asn1f_find_terminal_type(arg_t *arg, asn1p_expr_t *tc, + asn1p_module_t **opt_module_r); + +/* + * Recursively find the original value for the given expression. + * i.e.: + * If the original specification defines + * v Type1 ::= value + * value Type2 ::= value2 + * value2 Type3 ::= 3 + * Then this function will return the expression for value2 if given + * the v as an argment. + */ +asn1p_expr_t *asn1f_find_terminal_value(arg_t *arg, asn1p_expr_t *tc, + asn1p_module_t **opt_module_r); + +#endif /* _ASN1FIX_RETRIEVE_H_ */ diff --git a/libasn1fix/asn1fix_tags.c b/libasn1fix/asn1fix_tags.c new file mode 100644 index 00000000..ed8c19f2 --- /dev/null +++ b/libasn1fix/asn1fix_tags.c @@ -0,0 +1,47 @@ +#include "asn1fix_internal.h" + +int +asn1f_fetch_tag(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *expr, struct asn1p_type_tag_s *tag) { + int ret; + + if(expr->tag.tag_class != TC_NOCLASS) { + *tag = expr->tag; + return 0; + } + + if(expr->expr_type == A1TC_EXTENSIBLE) { + memset(tag, 0, sizeof(*tag)); + tag->tag_class = -1; + return 0; + } + + if(expr->meta_type == AMT_TYPE) { + memset(tag, 0, sizeof(*tag)); + tag->tag_class = TC_UNIVERSAL; + tag->tag_value = expr_type2uclass_value[expr->expr_type]; + return (tag->tag_value == 0) ? -1 : 0; + } + + if(expr->meta_type == AMT_TYPEREF) { + arg_t arg; + + memset(&arg, 0, sizeof(arg)); + arg.asn = asn; + arg.mod = mod; + arg.expr = expr; + + expr = asn1f_lookup_symbol(&arg, expr->reference, &mod); + if(expr == NULL) return -1; + + if(expr->_mark & TM_RECURSION) + return -1; + + expr->_mark |= TM_RECURSION; + ret = asn1f_fetch_tag(asn, mod, expr, tag); + expr->_mark &= ~TM_RECURSION; + return ret; + } + + return -1; +} + diff --git a/libasn1fix/asn1fix_tags.h b/libasn1fix/asn1fix_tags.h new file mode 100644 index 00000000..9d3595b9 --- /dev/null +++ b/libasn1fix/asn1fix_tags.h @@ -0,0 +1,6 @@ +#ifndef _ASN1FIX_TAGS_H_ +#define _ASN1FIX_TAGS_H_ + +int asn1f_fetch_tag(asn1p_t *asn, asn1p_module_t *mod, asn1p_expr_t *expr, struct asn1p_type_tag_s *tag); + +#endif /* _ASN1FIX_TAGS_H_ */ diff --git a/libasn1fix/asn1fix_value.c b/libasn1fix/asn1fix_value.c new file mode 100644 index 00000000..a22fd3dc --- /dev/null +++ b/libasn1fix/asn1fix_value.c @@ -0,0 +1,159 @@ +#include "asn1fix_internal.h" + +static int _asn1f_copy_value(arg_t *arg, asn1p_expr_t *to,asn1p_expr_t *from); + +int +asn1f_value_resolve(arg_t *arg, asn1p_expr_t *expr) { + asn1p_module_t *val_mod; + asn1p_expr_t *val_type_expr; + asn1p_expr_t *value_expr; + asn1p_expr_t *type_expr; + int ret; + + /* Make sure this IS a value assignment */ + assert(expr->meta_type == AMT_VALUE); + assert(expr->value); + + DEBUG("%s(=\"%s\", %x)", __func__, + asn1f_printable_value(expr->value), expr->expr_type); + + /* + * 1. Find the terminal type for this assignment. + */ + type_expr = asn1f_find_terminal_type(arg, expr, 0); + if(type_expr == 0) { + DEBUG("\tTerminal type for %s not found", expr->Identifier); + return -1; + } + + if(asn1f_look_value_in_type(arg, type_expr, expr) == -1) + return -1; + + /* + * 2. Find the terminal value also. + */ + value_expr = asn1f_find_terminal_value(arg, expr, &val_mod); + if(value_expr) { + DEBUG("\tTerminal value for %s->%s is %s at line %d", + expr->Identifier, asn1f_printable_value(expr->value), + value_expr->Identifier, value_expr->_lineno); + } else { + DEBUG("\tTerminal value for %s->%s not found", + expr->Identifier, asn1f_printable_value(expr->value)); + return -1; + } + + /* + * 3. Find the _type_ of a _terminal value_. + */ + WITH_MODULE(val_mod, + val_type_expr = asn1f_find_terminal_type(arg, value_expr, 0)); + if(val_type_expr) { + DEBUG("\tTerminal type of value %s->%s is %s at line %d", + expr->Identifier, asn1f_printable_value(expr->value), + val_type_expr->Identifier, val_type_expr->_lineno); + } else { + DEBUG("\tTerminal type of value %s->%s not found", + expr->Identifier, asn1f_printable_value(expr->value)); + return -1; + } + + /* + * 4. Check compatibility between the type of the current expression + * and the type of the discovered value. + */ + ret = asn1f_check_type_compatibility(arg, type_expr, val_type_expr); + if(ret == -1) { + DEBUG("\tIncompatible type of %s at %d with %s at %d", + type_expr->Identifier, type_expr->_lineno, + val_type_expr->Identifier, val_type_expr->_lineno); + return -1; + } + + if(asn1f_look_value_in_type(arg, val_type_expr, expr) == -1) + return -1; + + /* + * 5. Copy value from the terminal value into the current expression. + */ + ret = _asn1f_copy_value(arg, expr, value_expr); + if(ret == -1) { + DEBUG("\tValue %s cannot be copied from line %d to line %d", + asn1f_printable_value(value_expr->value), + value_expr->_lineno, expr->_lineno); + return -1; + } + + DEBUG("\tFinal value for \"%s\" at line %d is %s", + expr->Identifier, expr->_lineno, + asn1f_printable_value(expr->value)); + + return 0; +} + +static int +_asn1f_copy_value(arg_t *arg, asn1p_expr_t *to, asn1p_expr_t *from) { + asn1p_value_t *v; + + v = asn1p_value_clone(from->value); + if(v) { + asn1p_value_free(to->value); + to->value = v; + DEBUG("Copied value %s from \"%s\" on line %d " + "to \"%s\" on line %d", + asn1f_printable_value(v), + from->Identifier, + from->_lineno, + to->Identifier, + to->_lineno + ); + return 0; + } else { + return -1; + } +} + +int +asn1f_look_value_in_type(arg_t *arg, + asn1p_expr_t *type_expr, + asn1p_expr_t *value_expr) { + asn1p_expr_t *child_expr; + char *identifier; + + if(value_expr->value->type != ATV_REFERENCED + || value_expr->value->value.reference->comp_count != 1) + return 0; + if(type_expr->expr_type != ASN_BASIC_INTEGER + && type_expr->expr_type != ASN_BASIC_ENUMERATED) + return 0; + + DEBUG("%s(for %s in %s %x) for line %d", __func__, + asn1f_printable_value(value_expr->value), + type_expr->Identifier, + type_expr->expr_type, + value_expr->_lineno); + + /* + * Look into the definitions of the type itself: + * Type1 ::= INTEGER { a(1), b(2) } + * value Type1 = b -- will assign 2 + */ + identifier = value_expr->value->value.reference->components[0].name; + + child_expr = asn1f_lookup_child(type_expr, identifier); + DEBUG("\tLooking into a type %s at line %d for %s at line %d: %s", + type_expr->Identifier, type_expr->_lineno, + identifier, value_expr->_lineno, + child_expr + ? asn1f_printable_value(child_expr->value) + : "" + ); + + if(child_expr && child_expr->value) { + if(_asn1f_copy_value(arg, value_expr, child_expr)) + return -1; + /* Fall through */ + } + + return 0; +} diff --git a/libasn1fix/asn1fix_value.h b/libasn1fix/asn1fix_value.h new file mode 100644 index 00000000..7234035e --- /dev/null +++ b/libasn1fix/asn1fix_value.h @@ -0,0 +1,28 @@ +/* + * Functions related with processing values. + */ +#ifndef _ASN1FIX_VALUE_H_ +#define _ASN1FIX_VALUE_H_ + +/* + * Resolve the value given by reference. + * This function also takes a parameter which specifies the desired + * value's type. + * + * RETURN VALUES: + * 0: Value resolved successfully. + * -1/EPERM: Recursive looping detected. + * -1/EEXIST: Reference is not compatible with the desired type. + * -1/ESRCH: Cannot find the terminal reference. + */ +int asn1f_value_resolve(arg_t *arg, asn1p_expr_t *tc); + +/* + * Check if a value in value_expr refers to the enumeration or integer element + * within the type provided. If yes, it will replace referenced value with + * the appropriate inline value. + */ +int asn1f_look_value_in_type(arg_t *arg, + asn1p_expr_t *type_expr, asn1p_expr_t *value_expr); + +#endif /* _ASN1FIX_VALUE_H_ */ diff --git a/libasn1fix/check_fixer.c b/libasn1fix/check_fixer.c new file mode 100644 index 00000000..21c5b12f --- /dev/null +++ b/libasn1fix/check_fixer.c @@ -0,0 +1,313 @@ +#undef NDEBUG +#include +#include +#include +#include +#include +#include +#include +#include + +#include "asn1fix.h" +#include "asn1fix_internal.h" + +static int check(const char *fname, + enum asn1p_flags parser_flags, + enum asn1f_flags fixer_flags); +static int post_fix_check(asn1p_t *asn); +static int post_fix_check_element(asn1p_module_t *mod, asn1p_expr_t *expr); + +int +main(int ac, char **av) { + struct dirent *dp; + DIR *dir; + int failed = 0; + int completed = 0; + enum asn1p_flags parser_flags = A1P_NOFLAGS; + enum asn1f_flags fixer_flags = A1F_NOFLAGS; + int ret; + + /* + * Just in case when one decides that some flags better be + * enabled during `ASN1_FIXER_FLAGS=1 make check` or some + * similar usage. + */ + if(getenv("ASN1_PARSER_FLAGS")) + parser_flags = atoi(getenv("ASN1_PARSER_FLAGS")); + if(getenv("ASN1_FIXER_FLAGS")) + fixer_flags = atoi(getenv("ASN1_FIXER_FLAGS")); + + /* + * Go into a directory with tests. + */ + if(ac <= 1) { + fprintf(stderr, "Testing in ./tests...\n"); + ret = chdir("../tests"); + assert(ret == 0); + dir = opendir("."); + assert(dir); + } else { + dir = 0; + } + + /* + * Scan every *.asn1 file and try to parse and fix it. + */ + if(dir) { + while((dp = readdir(dir))) { + int len = strlen(dp->d_name); + if(len && strcmp(dp->d_name + len - 5, ".asn1") == 0) { + ret = check(dp->d_name, + parser_flags, fixer_flags); + if(ret) { + fprintf(stderr, + "FAILED: %s\n", + dp->d_name); + failed++; + } + completed++; + } + } + closedir(dir); + + fprintf(stderr, + "Tests COMPLETED: %d\n" + "Tests FAILED: %d\n" + , + completed, failed + ); + } else { + int i; + for(i = 1; i < ac; i++) { + ret = check(av[i], parser_flags, fixer_flags); + if(ret) { + fprintf(stderr, "FAILED: %s\n", av[i]); + failed++; + } + completed++; + } + } + + if(completed == 0) { + fprintf(stderr, "No tests defined?!\n"); + exit(EX_NOINPUT); + } + + if(failed) + exit(EX_DATAERR); + return 0; +} + +static int +check(const char *fname, + enum asn1p_flags parser_flags, + enum asn1f_flags fixer_flags) { + asn1p_t *asn; + int expected_parseable; /* Is it expected to be parseable? */ + int expected_fix_code; /* What code a fixer must return */ + int r_value = 0; + + /* + * Figure out how the processing should go by inferring + * expectations from the file name. + */ + if(strstr(fname, "-OK.")) { + expected_parseable = 1; + expected_fix_code = 0; + } else if(strstr(fname, "-NP.")) { + expected_parseable = 0; + expected_fix_code = 123; /* Does not matter */ + } else if(strstr(fname, "-SE.")) { + expected_parseable = 1; + expected_fix_code = -1; /* Semantically incorrect */ + } else if(strstr(fname, "-SW.")) { + expected_parseable = 1; + expected_fix_code = 1; /* Semantically suspicious */ + } else { + fprintf(stderr, "%s: Invalid file name format\n", fname); + return -1; + } + + fprintf(stderr, "[=> %s]\n", fname); + + /* + * Perform low-level parsing. + */ + if(!expected_parseable) + fprintf(stderr, "Expecting error...\n"); + asn = asn1p_parse_file(fname, parser_flags); + if(asn == NULL) { + if(expected_parseable) { + fprintf(stderr, "Cannot parse file \"%s\"\n", fname); + r_value = -1; + } else { + fprintf(stderr, + "Previous error is EXPECTED, no worry\n"); + } + } else if(!expected_parseable) { + fprintf(stderr, + "The file \"%s\" is not expected to be parseable, " + "yet parsing was successfull!\n", fname); + r_value = -1; + } + + /* + * Perform semantical checks and fixes. + */ + if(asn && r_value == 0) { + int ret; + + if(expected_fix_code) + fprintf(stderr, "Expecting some problems...\n"); + + ret = asn1f_process(asn, fixer_flags, 0); + if(ret) { + if(ret == expected_fix_code) { + fprintf(stderr, + "Previous error is EXPECTED, " + "no worry\n"); + } else { + fprintf(stderr, + "Cannot process file \"%s\": %d\n", + fname, ret); + r_value = -1; + } + } else if(ret != expected_fix_code) { + fprintf(stderr, + "File \"%s\" is expected " + "to be semantically incorrect, " + "yet processing was successful!\n", + fname); + r_value = -1; + } + } + + /* + * Check validity of some values, if grammar has special + * instructions for that. + */ + if(asn && r_value == 0) { + if(post_fix_check(asn)) + r_value = -1; + } + + /* + * TODO: destroy the asn. + */ + + return r_value; +} + + +static int +post_fix_check(asn1p_t *asn) { + asn1p_module_t *mod; + asn1p_expr_t *expr; + int r_value = 0; + + TQ_FOR(mod, &(asn->modules), mod_next) { + TQ_FOR(expr, &(mod->members), next) { + assert(expr->Identifier); + if(strncmp(expr->Identifier, "check-", 6) == 0) { + if(post_fix_check_element(mod, expr)) + r_value = -1; + } + } + } + + return r_value; +} + + +static int +post_fix_check_element(asn1p_module_t *mod, asn1p_expr_t *check_expr) { + asn1p_expr_t *expr = NULL; + char *name; + asn1p_value_t *value; + + if(check_expr->expr_type != ASN_BASIC_INTEGER + || check_expr->meta_type != AMT_VALUE) { + fprintf(stderr, + "CHECKER: Unsupported type of \"%s\" value: " + "%d at line %d of %s\n", + check_expr->Identifier, + check_expr->expr_type, + check_expr->_lineno, + mod->source_file_name + ); + return -1; + } + + assert(check_expr->meta_type == AMT_VALUE); + + value = check_expr->value; + if(value == NULL || value->type != ATV_INTEGER) { + fprintf(stderr, + "CHECKER: Unsupported value type of \"%s\": " + "%d at line %d of %s\n", + check_expr->Identifier, + value?value->type:-1, + expr->_lineno, + mod->source_file_name + ); + return -1; + } + + name = check_expr->Identifier + sizeof("check-") - 1; + + /* + * Scan in search for the original. + */ + TQ_FOR(expr, &(mod->members), next) { + if(strcmp(expr->Identifier, name) == 0) + break; + } + + if(expr == NULL) { + fprintf(stderr, + "CHECKER: Value \"%s\" requested by " + "\"check-%s\" at line %d of %s is not found!\n", + name, name, check_expr->_lineno, + mod->source_file_name + ); + return -1; + } + + if(0 && expr->expr_type != check_expr->expr_type) { + fprintf(stderr, + "CHECKER: Value type of \"%s\" (=%d) at line %d " + "does not have desired type %d as requested by " + "\"check-%s\" in %s\n", + expr->Identifier, + expr->expr_type, + expr->_lineno, + check_expr->expr_type, + name, + mod->source_file_name + ); + return -1; + } + + if(expr->value == NULL + || expr->value->type != value->type) { + fprintf(stderr, + "CHECKER: Value of \"%s\" (\"%s\", type=%d) at line %d " + "does not have desired type %d as requested by " + "\"check-%s\" in %s\n", + expr->Identifier, + asn1f_printable_value(expr->value), + expr->value->type, + expr->_lineno, + value->type, + name, + mod->source_file_name + ); + return -1; + } + + assert(value->type = ATV_INTEGER); + + return 0; +} + + diff --git a/libasn1parser/Makefile.am b/libasn1parser/Makefile.am new file mode 100644 index 00000000..0f9ff161 --- /dev/null +++ b/libasn1parser/Makefile.am @@ -0,0 +1,35 @@ + +AM_CFLAGS = @ADD_CFLAGS@ +AM_YFLAGS = -p asn1p_ -d +AM_LFLAGS = -sp -Cem -Pasn1p_ -olex.yy.c + +noinst_LTLIBRARIES = libasn1parser.la + +libasn1parser_la_LDFLAGS = -all-static +libasn1parser_la_SOURCES = \ + asn1parser.c asn1parser.h \ + asn1p_y.y asn1p_l.l \ + asn1p_module.c asn1p_module.h \ + asn1p_oid.c asn1p_oid.h \ + asn1p_value.c asn1p_value.h \ + asn1p_expr.c asn1p_expr.h \ + asn1p_expr_str.h \ + asn1p_expr2uclass.h \ + asn1p_xports.c asn1p_xports.h \ + asn1p_constr.c asn1p_constr.h \ + asn1p_param.c asn1p_param.h \ + asn1p_class.c asn1p_class.h \ + asn1p_ref.c asn1p_ref.h \ + asn1p_list.h + +asn1p_expr_str.h: expr-h.pl asn1p_expr.h + ./expr-h.pl asn1p_expr.h > $@ + +EXTRA_DIST = expr-h.pl + +check_PROGRAMS = check_parser + +LDADD = ${noinst_LTLIBRARIES} +DEPENDENCIES = ${noinst_LTLIBRARIES} + +TESTS = ${check_PROGRAMS} diff --git a/libasn1parser/Makefile.in b/libasn1parser/Makefile.in new file mode 100644 index 00000000..7c4bd5f8 --- /dev/null +++ b/libasn1parser/Makefile.in @@ -0,0 +1,459 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +AM_CFLAGS = @ADD_CFLAGS@ +AM_YFLAGS = -p asn1p_ -d +AM_LFLAGS = -sp -Cem -Pasn1p_ -olex.yy.c + +noinst_LTLIBRARIES = libasn1parser.la + +libasn1parser_la_LDFLAGS = -all-static +libasn1parser_la_SOURCES = \ + asn1parser.c asn1parser.h \ + asn1p_y.y asn1p_l.l \ + asn1p_module.c asn1p_module.h \ + asn1p_oid.c asn1p_oid.h \ + asn1p_value.c asn1p_value.h \ + asn1p_expr.c asn1p_expr.h \ + asn1p_expr_str.h \ + asn1p_expr2uclass.h \ + asn1p_xports.c asn1p_xports.h \ + asn1p_constr.c asn1p_constr.h \ + asn1p_param.c asn1p_param.h \ + asn1p_class.c asn1p_class.h \ + asn1p_ref.c asn1p_ref.h \ + asn1p_list.h + + +EXTRA_DIST = expr-h.pl + +check_PROGRAMS = check_parser + +LDADD = ${noinst_LTLIBRARIES} +DEPENDENCIES = ${noinst_LTLIBRARIES} + +TESTS = ${check_PROGRAMS} +subdir = libasn1parser +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) + +libasn1parser_la_LIBADD = +am_libasn1parser_la_OBJECTS = asn1parser.lo asn1p_y.lo asn1p_l.lo \ + asn1p_module.lo asn1p_oid.lo asn1p_value.lo asn1p_expr.lo \ + asn1p_xports.lo asn1p_constr.lo asn1p_param.lo asn1p_class.lo \ + asn1p_ref.lo +libasn1parser_la_OBJECTS = $(am_libasn1parser_la_OBJECTS) +check_PROGRAMS = check_parser$(EXEEXT) +check_parser_SOURCES = check_parser.c +check_parser_OBJECTS = check_parser.$(OBJEXT) +check_parser_LDADD = $(LDADD) +check_parser_DEPENDENCIES = libasn1parser.la +check_parser_LDFLAGS = + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/asn1p_class.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1p_constr.Plo $(DEPDIR)/asn1p_expr.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1p_l.Plo $(DEPDIR)/asn1p_module.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1p_oid.Plo $(DEPDIR)/asn1p_param.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1p_ref.Plo $(DEPDIR)/asn1p_value.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1p_xports.Plo $(DEPDIR)/asn1p_y.Plo \ +@AMDEP_TRUE@ $(DEPDIR)/asn1parser.Plo $(DEPDIR)/check_parser.Po +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) +LTLEXCOMPILE = $(LIBTOOL) --mode=compile $(LEX) $(LFLAGS) $(AM_LFLAGS) +YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS) +LTYACCCOMPILE = $(LIBTOOL) --mode=compile $(YACC) $(YFLAGS) $(AM_YFLAGS) +DIST_SOURCES = $(libasn1parser_la_SOURCES) check_parser.c +DIST_COMMON = Makefile.am Makefile.in asn1p_l.c asn1p_y.c asn1p_y.h +SOURCES = $(libasn1parser_la_SOURCES) check_parser.c + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .l .lo .o .obj .y + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu libasn1parser/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) +asn1p_y.h: asn1p_y.c +libasn1parser.la: $(libasn1parser_la_OBJECTS) $(libasn1parser_la_DEPENDENCIES) + $(LINK) $(libasn1parser_la_LDFLAGS) $(libasn1parser_la_OBJECTS) $(libasn1parser_la_LIBADD) $(LIBS) + +clean-checkPROGRAMS: + -test -z "$(check_PROGRAMS)" || rm -f $(check_PROGRAMS) +check_parser$(EXEEXT): $(check_parser_OBJECTS) $(check_parser_DEPENDENCIES) + @rm -f check_parser$(EXEEXT) + $(LINK) $(check_parser_LDFLAGS) $(check_parser_OBJECTS) $(check_parser_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_class.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_constr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_expr.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_l.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_module.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_oid.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_param.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_ref.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_value.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_xports.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1p_y.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1parser.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/check_parser.Po@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ + +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LEXLIB = @LEXLIB@ + +.l.c: + $(LEXCOMPILE) $< && mv $(LEX_OUTPUT_ROOT).c $@ + +.y.c: + $(YACCCOMPILE) $< && mv y.tab.c $@ + if test -f y.tab.h; then \ + if cmp -s y.tab.h $*.h; then \ + rm -f y.tab.h; \ + else \ + mv y.tab.h $*.h; \ + fi; \ + fi +uninstall-info-am: + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS) + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(LTLIBRARIES) + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." + -test -z "asn1p_y.h" || rm -f asn1p_y.h +clean: clean-am + +clean-am: clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: GTAGS all all-am check check-TESTS check-am clean \ + clean-checkPROGRAMS clean-generic clean-libtool \ + clean-noinstLTLIBRARIES distclean distclean-compile \ + distclean-depend distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am info info-am install \ + install-am install-data install-data-am install-exec \ + install-exec-am install-info install-info-am install-man \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + tags uninstall uninstall-am uninstall-info-am + + +asn1p_expr_str.h: expr-h.pl asn1p_expr.h + ./expr-h.pl asn1p_expr.h > $@ +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libasn1parser/asn1p_class.c b/libasn1parser/asn1p_class.c new file mode 100644 index 00000000..cd0e385a --- /dev/null +++ b/libasn1parser/asn1p_class.c @@ -0,0 +1,135 @@ +#include +#include +#include +#include +#include + +#include "asn1parser.h" + +asn1p_wsyntx_chunk_t * +asn1p_wsyntx_chunk_new() { + asn1p_wsyntx_chunk_t *wc; + + wc = calloc(1, sizeof(*wc)); + + return wc; +} + +void +asn1p_wsyntx_chunk_free(asn1p_wsyntx_chunk_t *wc) { + if(wc) { + if(wc->ref) + asn1p_ref_free(wc->ref); + if(wc->buf) + free(wc->buf); + free(wc); + } +} + +asn1p_wsyntx_chunk_t * +asn1p_wsyntx_chunk_clone(asn1p_wsyntx_chunk_t *wc) { + asn1p_wsyntx_chunk_t *nc; + + nc = asn1p_wsyntx_chunk_new(); + if(nc) { + if(wc->buf) { + nc->buf = malloc(wc->len + 1); + if(nc->buf) { + nc->len = wc->len; + memcpy(nc->buf, wc->buf, wc->len); + nc->buf[nc->len] = '\0'; + } + } + if(wc->ref) { + nc->ref = asn1p_ref_clone(wc->ref); + } + + if(!nc->ref && !nc->buf) { + asn1p_wsyntx_chunk_free(nc); + return NULL; + } + } + + return nc; +} + +asn1p_wsyntx_t * +asn1p_wsyntx_new() { + asn1p_wsyntx_t *wx; + + wx = calloc(1, sizeof(*wx)); + if(wx) { + TQ_INIT(&(wx->chunks)); + } + + return wx; +} + +void +asn1p_wsyntx_free(asn1p_wsyntx_t *wx) { + if(wx) { + asn1p_wsyntx_chunk_t *wc; + while((wc = TQ_REMOVE(&(wx->chunks), next))) + asn1p_wsyntx_chunk_free(wc); + free(wx); + } +} + +asn1p_wsyntx_t * +asn1p_wsyntx_clone(asn1p_wsyntx_t *wx) { + asn1p_wsyntx_t *nw; + + nw = asn1p_wsyntx_new(); + if(nw) { + asn1p_wsyntx_chunk_t *wc; + asn1p_wsyntx_chunk_t *nc; + TQ_FOR(wc, &(wx->chunks), next) { + nc = asn1p_wsyntx_chunk_clone(wc); + if(nc) { + TQ_ADD(&(nw->chunks), nc, next); + } else { + asn1p_wsyntx_free(nw); + return NULL; + } + } + } + + return nw; +} + +asn1p_wsyntx_chunk_t * +asn1p_wsyntx_chunk_fromref(asn1p_ref_t *ref, int do_copy) { + asn1p_wsyntx_chunk_t *wc; + + if(do_copy) { + static asn1p_wsyntx_chunk_t tmp; + tmp.ref = ref; + wc = asn1p_wsyntx_chunk_clone(&tmp); + } else { + wc = asn1p_wsyntx_chunk_new(); + if(wc) wc->ref = ref; + } + + return wc; +} + +asn1p_wsyntx_chunk_t * +asn1p_wsyntx_chunk_frombuf(char *buf, int len, int do_copy) { + asn1p_wsyntx_chunk_t *wc; + + if(do_copy) { + static asn1p_wsyntx_chunk_t tmp; + tmp.buf = buf; + tmp.len = len; + wc = asn1p_wsyntx_chunk_clone(&tmp); + } else { + wc = asn1p_wsyntx_chunk_new(); + if(wc) { + wc->buf = buf; + wc->len = len; + } + } + + return wc; +} + diff --git a/libasn1parser/asn1p_class.h b/libasn1parser/asn1p_class.h new file mode 100644 index 00000000..4a0f19e1 --- /dev/null +++ b/libasn1parser/asn1p_class.h @@ -0,0 +1,53 @@ +/* + * CLASS-related stuff. + */ +#ifndef ASN1_PARSER_CLASS_H +#define ASN1_PARSER_CLASS_H + +#include + +/* + * WITH SYNTAX free-form chunks. + */ +typedef struct asn1p_wsyntx_chunk_s { + /* + * It could be the union, but the story is: + * if ref is here, the ref is used. + * Otherwise, buf/len is used. + */ + asn1p_ref_t *ref; + + char *buf; + int len; + + TQ_ENTRY(struct asn1p_wsyntx_chunk_s) next; +} asn1p_wsyntx_chunk_t; + +typedef struct asn1p_wsyntx_s { + + TQ_HEAD(struct asn1p_wsyntx_chunk_s) chunks; + +} asn1p_wsyntx_t; + + +/* + * Constructor, destructor and cloning function. + */ +asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_new(void); +void asn1p_wsyntx_chunk_free(asn1p_wsyntx_chunk_t *); +asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_clone(asn1p_wsyntx_chunk_t *); + +asn1p_wsyntx_t *asn1p_wsyntx_new(void); +void asn1p_wsyntx_free(asn1p_wsyntx_t *); +asn1p_wsyntx_t *asn1p_wsyntx_clone(asn1p_wsyntx_t *); + +/* + * RETURN VALUES: + * 0: Component has been added + * -1: Failure to add component (refer to errno) + */ +asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_fromref(asn1p_ref_t *ref, int do_copy); +asn1p_wsyntx_chunk_t *asn1p_wsyntx_chunk_frombuf(char *buf, int len, int do_copy); + + +#endif /* ASN1_PARSER_CLASS_H */ diff --git a/libasn1parser/asn1p_constr.c b/libasn1parser/asn1p_constr.c new file mode 100644 index 00000000..6e198892 --- /dev/null +++ b/libasn1parser/asn1p_constr.c @@ -0,0 +1,91 @@ +#include +#include +#include +#include + +#include "asn1parser.h" + +asn1p_constraint_t * +asn1p_constraint_new(int _lineno) { + asn1p_constraint_t *ct; + + ct = calloc(1, sizeof(*ct)); + if(ct) { + ct->_lineno = _lineno; + } + + return ct; +} + + +void +asn1p_constraint_free(asn1p_constraint_t *ct) { + if(ct) { + + if(ct->value) + asn1p_value_free(ct->value); + if(ct->range_start) + asn1p_value_free(ct->range_start); + if(ct->range_stop) + asn1p_value_free(ct->range_stop); + + if(ct->elements) { + while(ct->el_count--) { + asn1p_constraint_free( + ct->elements[ct->el_count]); + } + free(ct->elements); + } + + free(ct); + } +} + +asn1p_constraint_t * +asn1p_constraint_clone(asn1p_constraint_t *src) { + asn1p_constraint_t *clone; + +#define CLONE(field, func) do { if(src->field) { \ + clone->field = func(src->field); \ + if(clone->field == NULL) { \ + asn1p_constraint_free(clone); \ + return NULL; \ + } \ + } } while(0) + + clone = asn1p_constraint_new(src->_lineno); + if(clone) { + clone->type = src->type; + CLONE(value, asn1p_value_clone); + CLONE(range_start, asn1p_value_clone); + CLONE(range_stop, asn1p_value_clone); + } + + return clone; +} + +int +asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what) { + assert(into); + assert(what); + + /* + * Make sure there's enough space to add an element. + */ + if(into->el_count == into->el_size) { + int newsize = into->el_size?into->el_size<<2:4; + void *p; + p = realloc(into->elements, + newsize * sizeof(into->elements[0])); + if(p) { + into->elements = p; + into->el_size = newsize; + } else { + return -1; + } + } + + into->elements[into->el_count++] = what; + + return 0; +} diff --git a/libasn1parser/asn1p_constr.h b/libasn1parser/asn1p_constr.h new file mode 100644 index 00000000..19099b2f --- /dev/null +++ b/libasn1parser/asn1p_constr.h @@ -0,0 +1,79 @@ +/* + * Type constraints. + */ +#ifndef ASN1_PARSER_CONSTRAINT_H +#define ASN1_PARSER_CONSTRAINT_H + +typedef struct asn1p_constraint_s { + + enum asn1p_constraint_type_e { + ACT_INVALID, /* for assertions */ + /* + * Constraint elements. + */ + ACT_EL_VALUE, /* 123, "A", T (elementary value) */ + ACT_EL_RANGE, /* 1..2 (elementary range) */ + ACT_EL_LLRANGE, /* 1<..2 (elementary range) */ + ACT_EL_RLRANGE, /* 1..<2 (elementary range) */ + ACT_EL_ULRANGE, /* 1<..<2 (elementary range) */ + ACT_EL_EXT, /* ... (extensibility mark) */ + /* + * Constraint types. + */ + ACT_CT_SIZE, /* SIZE constraint type */ + ACT_CT_FROM, /* FROM constraint type */ + ACT_CT_WCOMP, /* WITH COMPONENT */ + ACT_CT_WCOMPS, /* WITH COMPONENTS */ + /* + * Arrays of constraints. + */ + ACT_CA_SET, /* A set of constraints: (c1)(c2) */ + ACT_CA_CRC, /* Comp. relation c-t: ({a})({@b}) */ + ACT_CA_CSV, /* Comma-separated constraints array */ + ACT_CA_UNI, /* UNION (|) */ + ACT_CA_INT, /* INTERSECTION (^) */ + ACT_CA_EXC, /* EXCEPT */ + } type; + + enum asn1p_constr_pres_e { + ACPRES_DEFAULT, + ACPRES_PRESENT, + ACPRES_ABSENT, + ACPRES_OPTIONAL, + } presence; + + /* + * A single values. + */ + asn1p_value_t *value; + asn1p_value_t *range_start; + asn1p_value_t *range_stop; + + /* + * A collection of constraint elements. + */ + struct asn1p_constraint_s **elements; + int el_count; /* Number of meaningful elements */ + int el_size; /* Size of the allocated (elements) */ + + int _lineno; /* Position in a source file */ +} asn1p_constraint_t; + + +/* + * Constructors and a recursive destructor. + */ +asn1p_constraint_t *asn1p_constraint_new(int _lineno); +void asn1p_constraint_free(asn1p_constraint_t *); + +/* + * Clone the constraint and all its children. + */ +asn1p_constraint_t *asn1p_constraint_clone(asn1p_constraint_t *source_to_clone); + +/* + * Insert additional element into the element array of a (to) constraint. + */ +int asn1p_constraint_insert(asn1p_constraint_t *into, asn1p_constraint_t *what); + +#endif /* ASN1_PARSER_CONSTRAINT_H */ diff --git a/libasn1parser/asn1p_expr.c b/libasn1parser/asn1p_expr.c new file mode 100644 index 00000000..23ab4cb3 --- /dev/null +++ b/libasn1parser/asn1p_expr.c @@ -0,0 +1,112 @@ +#include +#include +#include +#include +#include + +#include "asn1parser.h" + +/* + * Construct a new empty types collection. + */ +asn1p_expr_t * +asn1p_expr_new(int _lineno) { + asn1p_expr_t *expr; + + expr = calloc(1, sizeof *expr); + if(expr) { + TQ_INIT(&(expr->members)); + expr->_lineno = _lineno; + } + + return expr; +} + +asn1p_expr_t * +asn1p_expr_clone(asn1p_expr_t *expr) { + asn1p_expr_t *clone; + asn1p_expr_t *tcmemb; /* Child of tc */ + + clone = asn1p_expr_new(expr->_lineno); + if(clone == NULL) return NULL; + +#define CLCOPY(field) do { clone->field = expr->field; } while(0) +#define CLCLONE(field, func) do { if(expr->field) { \ + clone->field = func(expr->field); \ + if(clone->field == NULL) { \ + asn1p_expr_free(clone); \ + return NULL; \ + } \ + } } while(0) + + /* + * Copy simple fields. + */ + CLCOPY(meta_type); + CLCOPY(expr_type); + CLCOPY(tag); + CLCOPY(marker); + CLCOPY(_mark); + + clone->data = 0; /* Do not clone this */ + clone->data_free = 0; /* Do not clone this */ + + /* + * Clone complex fields. + */ + CLCLONE(Identifier, strdup); + CLCLONE(reference, asn1p_ref_clone); + CLCLONE(constraints, asn1p_constraint_clone); + CLCLONE(params, asn1p_paramlist_clone); + CLCLONE(value, asn1p_value_clone); + CLCLONE(with_syntax, asn1p_wsyntx_clone); + + /* + * Copy all the children of this expr. + */ + TQ_FOR(tcmemb, &(expr->members), next) { + asn1p_expr_t *cmemb = asn1p_expr_clone(tcmemb); + if(cmemb == NULL) { + asn1p_expr_free(clone); + return NULL; + } + TQ_ADD(&(clone->members), cmemb, next); + } + + return clone; +} + +/* + * Destruct the types collection structure. + */ +void +asn1p_expr_free(asn1p_expr_t *expr) { + if(expr) { + asn1p_expr_t *tm; + + if(expr->Identifier) + free(expr->Identifier); + if(expr->reference) + asn1p_ref_free(expr->reference); + if(expr->constraints) + asn1p_constraint_free(expr->constraints); + if(expr->params) + asn1p_paramlist_free(expr->params); + if(expr->value) + asn1p_value_free(expr->value); + if(expr->with_syntax) + asn1p_wsyntx_free(expr->with_syntax); + + /* Remove all children */ + while((tm = TQ_REMOVE(&(expr->members), next))) { + asn1p_expr_free(tm); + } + + if(expr->data && expr->data_free) + expr->data_free(expr->data); + + memset(expr, 0, sizeof(*expr)); + free(expr); + } +} + diff --git a/libasn1parser/asn1p_expr.h b/libasn1parser/asn1p_expr.h new file mode 100644 index 00000000..331285c7 --- /dev/null +++ b/libasn1parser/asn1p_expr.h @@ -0,0 +1,214 @@ +/* + * A collection of data members of unspecified types. + */ +#ifndef ASN1_PARSER_EXPR_H +#define ASN1_PARSER_EXPR_H + +/* + * Meta type of the ASN expression. + */ +typedef enum asn1p_expr_meta { + AMT_INVALID, + AMT_TYPE, /* Type1 ::= INTEGER */ + AMT_TYPEREF, /* Type2 ::= Type1 */ + AMT_PARAMTYPE, /* Type3{Parameter} ::= SET { ... } */ + AMT_VALUE, /* value1 Type1 ::= 1 */ + AMT_VALUESET, /* ValueSet Type1 ::= { value1 } */ + AMT_OBJECT, /* FUNCTION ::= CLASS {...} */ + AMT_OBJECTSET, /* Functions FUNCTION ::= {...} */ + AMT_OBJECTFIELD, /* ... */ + AMT_EXPR_META_MAX +} asn1p_expr_meta_e; + +/* + * ASN type of the expression. + */ +typedef enum asn1p_expr_type { + /* + * Internal types. + */ + A1TC_INVALID, /* Invalid type */ + A1TC_REFERENCE, /* Reference to the type defined elsewhere */ + A1TC_EXPORTVAR, /* We're exporting this definition */ + A1TC_UNIVERVAL, /* A value of an ENUMERATED, INTEGER or BS */ + A1TC_BOOLBITPOS, /* A bit position in a BIT STRING */ + A1TC_BITVECTOR, /* A plain collection of bits */ + A1TC_OPAQUE, /* Opaque data encoded as a bitvector */ + A1TC_EXTENSIBLE, /* An extension marker "..." */ + A1TC_PARAMETRIZED, /* A parametrized type declaration */ + A1TC_VALUESET, /* Value set definition */ + A1TC_CLASSDEF, /* Information Object Class */ + A1TC_CLASSFIELD, /* Information Object Class field */ + A1TC_INSTANCE, /* Instance of Object Class */ + A1TC_TYPEID, /* Type identifier */ + /* + * ASN.1 Constructed types + */ +#define ASN_CONSTR_MASK 0x10 /* Every constructed type */ + ASN_CONSTR_SEQUENCE = ASN_CONSTR_MASK, /* SEQUENCE */ + ASN_CONSTR_CHOICE, /* CHOICE */ + ASN_CONSTR_SET, /* SET */ + ASN_CONSTR_SEQUENCE_OF, /* SEQUENCE OF */ + ASN_CONSTR_SET_OF, /* SET OF */ + ASN_CONSTR_ANY, /* ANY (deprecated) */ + /* + * ASN.1 Basic types + */ +#define ASN_BASIC_MASK 0x20 /* Every basic type */ + ASN_BASIC_BOOLEAN = ASN_BASIC_MASK, + ASN_BASIC_NULL, + ASN_BASIC_INTEGER, + ASN_BASIC_REAL, + ASN_BASIC_ENUMERATED, + ASN_BASIC_BIT_STRING, + ASN_BASIC_OCTET_STRING, + ASN_BASIC_OBJECT_IDENTIFIER, + ASN_BASIC_RELATIVE_OID, + ASN_BASIC_EXTERNAL, + ASN_BASIC_EMBEDDED_PDV, + ASN_BASIC_CHARACTER_STRING, + ASN_BASIC_UTCTime, + ASN_BASIC_GeneralizedTime, + /* + * ASN.1 String types + */ +#define ASN_STRING_MASK 0x40 /* Every string type */ + ASN_STRING_BMPString = ASN_STRING_MASK, + ASN_STRING_GeneralString, + ASN_STRING_GraphicString, + ASN_STRING_IA5String, + ASN_STRING_ISO646String, + ASN_STRING_NumericString, + ASN_STRING_PrintableString, + ASN_STRING_TeletexString, + ASN_STRING_T61String, + ASN_STRING_UniversalString, + ASN_STRING_UTF8String, + ASN_STRING_VideotexString, + ASN_STRING_VisibleString, + ASN_STRING_ObjectDescriptor, + ASN_EXPR_TYPE_MAX +} asn1p_expr_type_e; + +#include "asn1p_expr_str.h" +#include "asn1p_expr2uclass.h" + +/* + * A named collection of types. + */ +typedef struct asn1p_expr_s { + + /* + * Human readable name. + */ + char *Identifier; + + /* + * Meta type of the expression (type, value, value set, etc). + */ + asn1p_expr_meta_e meta_type; + + /* + * ASN type of the expression. + */ + asn1p_expr_type_e expr_type; + + /* + * Referenced type, if defined elsewhere. + * (If expr_type == A1TC_REFERENCE) + */ + asn1p_ref_t *reference; + + /* + * Constraints for the type. + */ + asn1p_constraint_t *constraints; + + /* + * A list of parameters for parametrized type declaration + * (AMT_PARAMTYPE). + */ + asn1p_paramlist_t *params; + + /* + * The actual value (DefinedValue or inlined value). + */ + asn1p_value_t *value; + + /* + * The WITH SYHTAX clause. + */ + asn1p_wsyntx_t *with_syntax; + + /* + * A tag. + */ + struct asn1p_type_tag_s { + enum { + TC_NOCLASS, + TC_UNIVERSAL, + TC_APPLICATION, + TC_CONTEXT_SPECIFIC, + TC_PRIVATE, + } tag_class; + enum { + TM_DEFAULT, + TM_IMPLICIT, + TM_EXPLICIT, + } tag_mode; + asn1_integer_t tag_value; + } tag; + + /* + * Whether automatic tagging is applicable for subtypes. + */ + int auto_tags_OK; + + enum asn1p_expr_marker_e { + EM_NOMARK, + EM_OPTIONAL, + EM_DEFAULT, /* FIXME: store the value somewhere. */ + } marker; + int unique; /* UNIQUE */ + + /* + * Members of the constructed type. + */ + TQ_HEAD(struct asn1p_expr_s) members; + + /* + * Next expression in the list. + */ + TQ_ENTRY(struct asn1p_expr_s) next; + + /* + * Line number where this structure is defined in the original + * grammar source. + */ + int _lineno; + /* + * Marks are used for various purposes. + * Here are some predefined ones. + */ + enum { + TM_NOMARK, + TM_RECURSION, /* Used to break recursion */ + } _mark; + + /* + * Opaque data may be attached to this structure, + * probably by compiler. + */ + void *data; + void (*data_free)(void *data); +} asn1p_expr_t; + + +/* + * Constructor and destructor. + */ +asn1p_expr_t *asn1p_expr_new(int _lineno); +asn1p_expr_t *asn1p_expr_clone(asn1p_expr_t *); +void asn1p_expr_free(asn1p_expr_t *expr); + +#endif /* ASN1_PARSER_EXPR_H */ diff --git a/libasn1parser/asn1p_expr2uclass.h b/libasn1parser/asn1p_expr2uclass.h new file mode 100644 index 00000000..416c9f72 --- /dev/null +++ b/libasn1parser/asn1p_expr2uclass.h @@ -0,0 +1,41 @@ +#ifndef ASN1_PARSER_EXPR2UCLASS_H +#define ASN1_PARSER_EXPR2UCLASS_H + +static int +expr_type2uclass_value[ASN_EXPR_TYPE_MAX] + __attribute__ ((unused)) = { + [ ASN_BASIC_BOOLEAN ] = 1, + [ ASN_BASIC_INTEGER ] = 2, + [ ASN_BASIC_BIT_STRING ] = 3, + [ ASN_BASIC_OCTET_STRING ] = 4, + [ ASN_BASIC_NULL ] = 5, + [ ASN_BASIC_OBJECT_IDENTIFIER ] = 6, + [ ASN_BASIC_EXTERNAL ] = 7, + [ ASN_STRING_ObjectDescriptor ] = 7, + [ ASN_BASIC_REAL ] = 9, + [ ASN_BASIC_ENUMERATED ] = 10, + [ ASN_BASIC_EMBEDDED_PDV ] = 11, + [ ASN_STRING_UTF8String ] = 12, + [ ASN_BASIC_RELATIVE_OID ] = 13, + [ ASN_CONSTR_SEQUENCE ] = 16, + [ ASN_CONSTR_SEQUENCE_OF ] = 16, + [ ASN_CONSTR_SET ] = 17, + [ ASN_CONSTR_SET_OF ] = 17, + [ ASN_STRING_NumericString ] = 18, + [ ASN_STRING_PrintableString ] = 19, + [ ASN_STRING_TeletexString ] = 20, + [ ASN_STRING_T61String ] = 20, + [ ASN_STRING_VideotexString ] = 21, + [ ASN_STRING_IA5String ] = 22, + [ ASN_BASIC_UTCTime ] = 23, + [ ASN_BASIC_GeneralizedTime ] = 24, + [ ASN_STRING_GraphicString ] = 25, + [ ASN_STRING_VisibleString ] = 26, + [ ASN_STRING_ISO646String ] = 26, + [ ASN_STRING_GeneralString ] = 27, + [ ASN_STRING_UniversalString ] = 28, + [ ASN_BASIC_CHARACTER_STRING ] = 29, + [ ASN_STRING_BMPString ] = 30, +}; + +#endif /* ASN1_PARSER_EXPR2UCLASS_H */ diff --git a/libasn1parser/asn1p_expr_str.h b/libasn1parser/asn1p_expr_str.h new file mode 100644 index 00000000..02de131b --- /dev/null +++ b/libasn1parser/asn1p_expr_str.h @@ -0,0 +1,57 @@ +/* + * This file is automatically generated by ./expr-h.pl + * DO NOT EDIT MANUALLY, fix the ./expr-h.pl instead if necessary. + */ +#ifndef ASN1_PARSER_EXPR_STR_H +#define ASN1_PARSER_EXPR_STR_H + +static char *asn1p_expr_type2str[] __attribute__ ((unused)) = { + [ ASN_CONSTR_SEQUENCE ] = "SEQUENCE", + [ ASN_CONSTR_CHOICE ] = "CHOICE", + [ ASN_CONSTR_SET ] = "SET", + [ ASN_CONSTR_SEQUENCE_OF ] = "SEQUENCE OF", + [ ASN_CONSTR_SET_OF ] = "SET OF", + [ ASN_CONSTR_ANY ] = "ANY", + [ ASN_BASIC_BOOLEAN ] = "BOOLEAN", + [ ASN_BASIC_NULL ] = "NULL", + [ ASN_BASIC_INTEGER ] = "INTEGER", + [ ASN_BASIC_REAL ] = "REAL", + [ ASN_BASIC_ENUMERATED ] = "ENUMERATED", + [ ASN_BASIC_BIT_STRING ] = "BIT STRING", + [ ASN_BASIC_OCTET_STRING ] = "OCTET STRING", + [ ASN_BASIC_OBJECT_IDENTIFIER ] = "OBJECT IDENTIFIER", + [ ASN_BASIC_RELATIVE_OID ] = "RELATIVE-OID", + [ ASN_BASIC_EXTERNAL ] = "EXTERNAL", + [ ASN_BASIC_EMBEDDED_PDV ] = "EMBEDDED PDV", + [ ASN_BASIC_CHARACTER_STRING ] = "CHARACTER STRING", + [ ASN_BASIC_UTCTime ] = "UTCTime", + [ ASN_BASIC_GeneralizedTime ] = "GeneralizedTime", + [ ASN_STRING_BMPString ] = "BMPString", + [ ASN_STRING_GeneralString ] = "GeneralString", + [ ASN_STRING_GraphicString ] = "GraphicString", + [ ASN_STRING_IA5String ] = "IA5String", + [ ASN_STRING_ISO646String ] = "ISO646String", + [ ASN_STRING_NumericString ] = "NumericString", + [ ASN_STRING_PrintableString ] = "PrintableString", + [ ASN_STRING_TeletexString ] = "TeletexString", + [ ASN_STRING_T61String ] = "T61String", + [ ASN_STRING_UniversalString ] = "UniversalString", + [ ASN_STRING_UTF8String ] = "UTF8String", + [ ASN_STRING_VideotexString ] = "VideotexString", + [ ASN_STRING_VisibleString ] = "VisibleString", + [ ASN_STRING_ObjectDescriptor ] = "ObjectDescriptor", +}; + +/* + * Convert the ASN.1 expression type back into the string representation. + */ +#define ASN_EXPR_TYPE2STR(type) \ + ( \ + ((type) < 0 \ + || (type) >= sizeof(asn1p_expr_type2str) \ + / sizeof(asn1p_expr_type2str[0])) \ + ? (char *)0 \ + : asn1p_expr_type2str[(type)] \ + ) + +#endif /* ASN1_PARSER_EXPR_STR_H */ diff --git a/libasn1parser/asn1p_l.c b/libasn1parser/asn1p_l.c new file mode 100644 index 00000000..6a6eb446 --- /dev/null +++ b/libasn1parser/asn1p_l.c @@ -0,0 +1,3861 @@ +#define yy_create_buffer asn1p__create_buffer +#define yy_delete_buffer asn1p__delete_buffer +#define yy_scan_buffer asn1p__scan_buffer +#define yy_scan_string asn1p__scan_string +#define yy_scan_bytes asn1p__scan_bytes +#define yy_flex_debug asn1p__flex_debug +#define yy_init_buffer asn1p__init_buffer +#define yy_flush_buffer asn1p__flush_buffer +#define yy_load_buffer_state asn1p__load_buffer_state +#define yy_switch_to_buffer asn1p__switch_to_buffer +#define yyin asn1p_in +#define yyleng asn1p_leng +#define yylex asn1p_lex +#define yyout asn1p_out +#define yyrestart asn1p_restart +#define yytext asn1p_text +#define yylineno asn1p_lineno + +#line 20 "lex.yy.c" +/* A lexical scanner generated by flex */ + +/* Scanner skeleton version: + * $Header$ + */ + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 + +#include + + +/* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */ +#ifdef c_plusplus +#ifndef __cplusplus +#define __cplusplus +#endif +#endif + + +#ifdef __cplusplus + +#include +#include + +/* Use prototypes in function declarations. */ +#define YY_USE_PROTOS + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +#if __STDC__ + +#define YY_USE_PROTOS +#define YY_USE_CONST + +#endif /* __STDC__ */ +#endif /* ! __cplusplus */ + +#ifdef __TURBOC__ + #pragma warn -rch + #pragma warn -use +#include +#include +#define YY_USE_CONST +#define YY_USE_PROTOS +#endif + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + + +#ifdef YY_USE_PROTOS +#define YY_PROTO(proto) proto +#else +#define YY_PROTO(proto) () +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN yy_start = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START ((yy_start - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE yyrestart( yyin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#define YY_BUF_SIZE 16384 + +typedef struct yy_buffer_state *YY_BUFFER_STATE; + +extern int yyleng; +extern FILE *yyin, *yyout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + +/* The funky do-while in the following #define is used to turn the definition + * int a single C statement (which needs a semi-colon terminator). This + * avoids problems with code like: + * + * if ( condition_holds ) + * yyless( 5 ); + * else + * do_something_else(); + * + * Prior to using the do-while the compiler would get upset at the + * "else" because it interpreted the "if" statement as being all + * done when it reached the ';' after the yyless() call. + */ + +/* Return all but the first 'n' matched characters back to the input stream. */ + +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + *yy_cp = yy_hold_char; \ + YY_RESTORE_YY_MORE_OFFSET \ + yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up yytext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, yytext_ptr ) + +/* The following is because we cannot portably get our hands on size_t + * (without autoconf's help, which isn't available because we want + * flex-generated scanners to compile on their own). + */ +typedef unsigned int yy_size_t; + + +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via yyrestart()), so that the user can continue scanning by + * just pointing yyin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + }; + +static YY_BUFFER_STATE yy_current_buffer = 0; + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + */ +#define YY_CURRENT_BUFFER yy_current_buffer + + +/* yy_hold_char holds the character lost when yytext is formed. */ +static char yy_hold_char; + +static int yy_n_chars; /* number of characters read into yy_ch_buf */ + + +int yyleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 1; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow yywrap()'s to do buffer switches + * instead of setting up a fresh yyin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void yyrestart YY_PROTO(( FILE *input_file )); + +void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer )); +void yy_load_buffer_state YY_PROTO(( void )); +YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size )); +void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b )); +void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file )); +void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b )); +#define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer ) + +YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size )); +YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str )); +YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len )); + +static void *yy_flex_alloc YY_PROTO(( yy_size_t )); +static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t )); +static void yy_flex_free YY_PROTO(( void * )); + +#define yy_new_buffer yy_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! yy_current_buffer ) \ + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \ + yy_current_buffer->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (yy_current_buffer->yy_at_bol) + + +#define YY_USES_REJECT + +#define yywrap() 1 +#define YY_SKIP_YYWRAP + +#define FLEX_DEBUG +typedef unsigned char YY_CHAR; +FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +typedef int yy_state_type; + +#define FLEX_DEBUG +extern int yylineno; +int yylineno = 1; +extern char *yytext; +#define yytext_ptr yytext + +static yy_state_type yy_get_previous_state YY_PROTO(( void )); +static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state )); +static int yy_get_next_buffer YY_PROTO(( void )); +static void yy_fatal_error YY_PROTO(( yyconst char msg[] )); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up yytext. + */ +#define YY_DO_BEFORE_ACTION \ + yytext_ptr = yy_bp; \ + yyleng = (int) (yy_cp - yy_bp); \ + yy_hold_char = *yy_cp; \ + *yy_cp = '\0'; \ + yy_c_buf_p = yy_cp; + +#define YY_NUM_RULES 123 +#define YY_END_OF_BUFFER 124 +static yyconst short int yy_acclist[1196] = + { 0, + 124, 122, 123, 117, 122, 123, 117, 123, 116, 122, + 123, 15, 122, 123, 116, 122, 123, 122, 123, 116, + 122, 123, 122, 123, 116, 122, 123, 122, 123, 23, + 122, 123, 22, 122, 123, 116, 122, 123, 122, 123, + 111, 112, 122, 123, 111, 112, 122, 123, 111, 112, + 122, 123, 111, 112, 122, 123, 111, 112, 122, 123, + 111, 112, 122, 123, 111, 112, 122, 123, 111, 112, + 122, 123, 111, 112, 122, 123, 111, 112, 122, 123, + 111, 112, 122, 123, 111, 112, 122, 123, 111, 112, + 122, 123, 111, 112, 122, 123, 111, 112, 122, 123, + + 111, 112, 122, 123, 111, 112, 122, 123, 111, 112, + 122, 123, 111, 112, 122, 123, 116, 122, 123, 110, + 122, 123, 5, 122, 123, 2, 123, 2, 122, 123, + 4, 122, 123, 7, 9, 122, 123, 7, 123, 9, + 122, 123, 9, 122, 123, 17, 122, 123, 17, 123, + 18, 122, 123, 12, 122, 123, 12, 123, 14, 122, + 123, 14, 122, 123, 10, 122, 123, 11, 122, 123, + 119, 122, 123, 120, 122, 123, 120, 123, 122, 123, + 121, 122, 123, 117, 15, 15, 108, 109, 1, 21, + 115, 6, 22, 111, 112, 111, 112, 111, 112, 111, + + 112, 111, 112, 111, 112, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 36, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 112, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 112, 111, 112, 111, 112, 79, 111, + 112, 111, 112, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 112, 111, 112, 111, 112, 112, 112, 111, 112, + + 110, 5, 3, 8, 17, 16, 12, 119, 120, 118, + 108, 109, 21, 114, 113, 111, 112, 28, 111, 112, + 29, 111, 112, 111, 112, 111, 112, 111, 112, 33, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 49, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 112, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 71, 111, 112, 72, 111, 112, 111, + 112, 112, 111, 112, 111, 112, 111, 112, 112, 111, + + 112, 82, 111, 112, 111, 112, 111, 112, 111, 112, + 112, 111, 112, 111, 112, 111, 112, 90, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 112, 111, 112, 111, 112, 111, + 112, 112, 112, 112, 111, 112, 24, 13, 20, 19, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 57, 111, 112, 112, + + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 74, + 111, 112, 112, 111, 112, 111, 112, 111, 112, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 112, 87, + 111, 112, 111, 112, 111, 112, 91, 111, 112, 111, + 112, 111, 112, 111, 112, 95, 111, 112, 97, 111, + 112, 111, 112, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 112, 112, 112, 107, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 32, 111, + 112, 112, 111, 112, 111, 112, 111, 112, 39, 111, + + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 56, 111, 112, + 112, 112, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 112, 111, 112, 78, 111, 112, 111, 112, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 112, 111, + 112, 111, 112, 111, 112, 111, 112, 112, 111, 112, + 112, 99, 111, 112, 111, 112, 111, 112, 112, 111, + 112, 112, 112, 112, 25, 26, 111, 112, 111, 112, + + 111, 112, 111, 112, 112, 111, 112, 111, 112, 38, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 51, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 112, 112, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 111, 112, 112, 76, 111, 112, 111, 112, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 112, + 111, 112, 111, 112, 92, 111, 112, 93, 111, 112, + 112, 111, 112, 112, 100, 111, 112, 111, 112, 112, + + 112, 112, 112, 112, 111, 112, 111, 112, 111, 112, + 112, 35, 111, 112, 111, 112, 111, 112, 111, 112, + 111, 112, 44, 111, 112, 45, 111, 112, 111, 112, + 111, 112, 48, 111, 112, 111, 112, 111, 112, 53, + 111, 112, 111, 112, 111, 112, 112, 112, 112, 111, + 112, 111, 112, 64, 111, 112, 65, 111, 112, 111, + 112, 111, 112, 68, 111, 112, 111, 112, 111, 112, + 111, 112, 112, 111, 112, 112, 81, 111, 112, 111, + 112, 84, 111, 112, 86, 111, 112, 112, 111, 112, + 111, 112, 112, 111, 112, 112, 111, 112, 103, 112, + + 112, 112, 112, 112, 111, 112, 111, 112, 111, 112, + 112, 111, 112, 111, 112, 111, 112, 111, 112, 111, + 112, 47, 111, 112, 111, 112, 52, 111, 112, 111, + 112, 55, 111, 112, 112, 112, 112, 112, 111, 112, + 63, 111, 112, 66, 111, 112, 67, 111, 112, 111, + 112, 112, 111, 112, 112, 80, 111, 112, 112, 111, + 112, 112, 111, 112, 89, 111, 112, 112, 111, 112, + 112, 111, 112, 112, 112, 112, 112, 111, 112, 111, + 112, 31, 111, 112, 34, 112, 37, 111, 112, 40, + 111, 112, 111, 112, 111, 112, 111, 112, 111, 112, + + 111, 112, 112, 112, 112, 61, 112, 111, 112, 111, + 112, 112, 111, 112, 112, 112, 111, 112, 112, 111, + 112, 94, 112, 111, 112, 112, 101, 111, 112, 112, + 112, 112, 112, 111, 112, 111, 112, 41, 111, 112, + 42, 111, 112, 43, 111, 112, 111, 112, 50, 111, + 112, 111, 112, 112, 112, 112, 62, 111, 112, 111, + 112, 112, 111, 112, 112, 112, 111, 112, 112, 111, + 112, 111, 112, 112, 104, 112, 112, 112, 112, 111, + 112, 30, 111, 112, 46, 111, 112, 111, 112, 112, + 112, 112, 111, 112, 112, 111, 112, 112, 112, 111, + + 112, 112, 111, 112, 111, 112, 112, 112, 112, 112, + 24, 25, 111, 112, 111, 112, 112, 112, 112, 69, + 111, 112, 70, 112, 111, 112, 112, 112, 111, 112, + 112, 88, 111, 112, 111, 112, 112, 112, 112, 112, + 111, 112, 54, 111, 112, 59, 112, 112, 60, 112, + 111, 112, 75, 112, 112, 83, 111, 112, 112, 111, + 112, 96, 112, 112, 112, 106, 112, 111, 112, 112, + 73, 111, 112, 112, 112, 111, 112, 112, 105, 112, + 27, 111, 112, 58, 112, 112, 85, 112, 98, 111, + 112, 102, 112, 77, 112 + + } ; + +static yyconst short int yy_accept[676] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 2, 4, 7, 9, 12, 15, 18, + 20, 23, 25, 28, 30, 33, 36, 39, 41, 45, + 49, 53, 57, 61, 65, 69, 73, 77, 81, 85, + 89, 93, 97, 101, 105, 109, 113, 117, 120, 123, + 126, 128, 131, 134, 138, 140, 143, 146, 149, 151, + 154, 157, 159, 162, 165, 168, 171, 174, 177, 179, + 181, 184, 184, 185, 186, 187, 187, 188, 188, 189, + 189, 189, 190, 191, 192, 193, 194, 194, 196, 198, + 200, 202, 204, 206, 207, 209, 211, 213, 215, 218, + + 220, 222, 224, 226, 228, 230, 232, 234, 236, 237, + 238, 240, 242, 244, 246, 248, 250, 252, 254, 255, + 257, 259, 262, 264, 265, 267, 269, 271, 273, 274, + 276, 278, 280, 282, 284, 286, 288, 290, 292, 293, + 295, 297, 298, 299, 301, 301, 301, 301, 301, 301, + 302, 303, 304, 305, 306, 307, 308, 308, 309, 310, + 311, 311, 312, 313, 313, 313, 314, 315, 316, 318, + 321, 324, 326, 328, 330, 333, 335, 337, 339, 341, + 343, 345, 347, 349, 351, 353, 356, 358, 360, 362, + 364, 366, 368, 369, 370, 372, 374, 376, 378, 380, + + 382, 384, 387, 390, 392, 393, 395, 397, 399, 400, + 402, 405, 407, 409, 411, 412, 414, 416, 418, 421, + 423, 425, 427, 429, 431, 433, 435, 436, 438, 440, + 442, 443, 444, 445, 447, 448, 448, 448, 448, 448, + 449, 449, 450, 451, 453, 455, 457, 459, 461, 463, + 465, 467, 469, 471, 473, 475, 477, 479, 481, 483, + 485, 487, 489, 491, 493, 495, 497, 500, 501, 502, + 504, 506, 508, 510, 512, 514, 516, 518, 520, 523, + 524, 526, 528, 530, 531, 533, 535, 537, 539, 540, + 543, 545, 547, 550, 552, 554, 556, 559, 562, 564, + + 565, 567, 569, 571, 573, 575, 576, 577, 578, 581, + 581, 581, 581, 581, 583, 585, 587, 589, 592, 593, + 595, 597, 599, 602, 604, 606, 608, 610, 612, 614, + 616, 618, 620, 622, 624, 626, 628, 631, 632, 633, + 634, 636, 638, 640, 642, 644, 646, 648, 650, 652, + 653, 655, 658, 660, 661, 663, 665, 667, 669, 670, + 672, 674, 676, 678, 679, 681, 682, 685, 687, 689, + 690, 692, 693, 694, 695, 696, 696, 696, 696, 699, + 701, 703, 705, 706, 708, 710, 713, 715, 717, 719, + 721, 723, 725, 727, 729, 731, 734, 736, 738, 740, + + 742, 743, 744, 745, 747, 749, 751, 753, 755, 757, + 759, 761, 763, 765, 766, 769, 771, 772, 774, 776, + 778, 780, 781, 783, 785, 788, 791, 792, 794, 795, + 798, 800, 801, 802, 803, 804, 805, 805, 805, 805, + 807, 809, 811, 812, 815, 817, 819, 821, 823, 826, + 829, 831, 833, 836, 838, 840, 843, 845, 847, 848, + 849, 850, 852, 854, 857, 860, 862, 864, 867, 869, + 871, 873, 874, 876, 877, 880, 882, 885, 888, 889, + 891, 893, 894, 896, 897, 899, 901, 902, 903, 904, + 905, 905, 905, 905, 907, 909, 911, 912, 914, 916, + + 918, 920, 922, 925, 927, 930, 932, 935, 936, 937, + 938, 939, 941, 944, 947, 950, 952, 953, 955, 956, + 959, 960, 962, 963, 965, 968, 969, 971, 972, 974, + 975, 976, 977, 978, 978, 978, 978, 980, 982, 985, + 987, 990, 993, 995, 997, 999, 1001, 1003, 1004, 1005, + 1006, 1008, 1010, 1012, 1013, 1015, 1016, 1017, 1019, 1020, + 1022, 1024, 1026, 1027, 1030, 1031, 1032, 1033, 1034, 1034, + 1034, 1034, 1036, 1038, 1041, 1044, 1047, 1049, 1052, 1054, + 1055, 1056, 1057, 1060, 1062, 1063, 1065, 1066, 1067, 1069, + 1070, 1072, 1074, 1075, 1077, 1078, 1079, 1080, 1080, 1080, + + 1080, 1082, 1085, 1088, 1090, 1091, 1092, 1093, 1095, 1096, + 1098, 1099, 1100, 1102, 1103, 1105, 1107, 1108, 1109, 1110, + 1111, 1111, 1113, 1113, 1115, 1117, 1118, 1119, 1120, 1123, + 1125, 1127, 1128, 1129, 1131, 1132, 1135, 1137, 1138, 1139, + 1140, 1141, 1141, 1143, 1146, 1148, 1149, 1151, 1153, 1155, + 1156, 1159, 1160, 1162, 1164, 1165, 1166, 1168, 1168, 1170, + 1171, 1174, 1175, 1176, 1178, 1179, 1181, 1184, 1186, 1187, + 1189, 1192, 1194, 1196, 1196 + } ; + +static yyconst int yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 5, 6, 1, 1, 1, 7, 8, 9, + 9, 10, 1, 9, 11, 12, 13, 14, 15, 16, + 16, 17, 18, 19, 16, 20, 16, 21, 22, 23, + 24, 1, 1, 9, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, + 51, 1, 52, 53, 1, 1, 54, 55, 56, 57, + + 58, 59, 60, 61, 62, 63, 59, 64, 65, 66, + 67, 68, 59, 69, 70, 71, 72, 73, 59, 74, + 59, 75, 76, 77, 78, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst int yy_meta[79] = + { 0, + 1, 2, 3, 3, 1, 4, 5, 6, 1, 1, + 7, 1, 1, 8, 8, 8, 8, 8, 8, 8, + 9, 1, 1, 9, 8, 8, 8, 8, 8, 8, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 1, 1, 1, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 12, 1, 12 + } ; + +static yyconst short int yy_base[691] = + { 0, + 0, 0, 76, 78, 80, 81, 82, 89, 83, 93, + 96, 106, 844, 833, 116, 119, 822, 821, 177, 126, + 4166, 127, 816, 123, 4166, 134, 805, 4166, 242, 292, + 141, 298, 152, 314, 322, 130, 338, 359, 360, 376, + 382, 397, 410, 437, 440, 462, 463, 495, 0, 0, + 4166, 4166, 811, 4166, 4166, 807, 807, 0, 0, 809, + 0, 0, 787, 4166, 4166, 4166, 0, 160, 191, 104, + 4166, 800, 261, 0, 798, 797, 0, 79, 0, 426, + 793, 4166, 511, 787, 4166, 527, 771, 512, 513, 528, + 529, 544, 550, 0, 561, 567, 578, 589, 595, 611, + + 617, 628, 641, 644, 664, 661, 672, 685, 727, 737, + 696, 702, 713, 719, 730, 741, 747, 758, 725, 771, + 774, 787, 795, 725, 798, 811, 822, 835, 720, 851, + 857, 868, 874, 885, 900, 901, 916, 917, 716, 932, + 933, 716, 45, 948, 980, 987, 736, 97, 120, 0, + 0, 4166, 4166, 0, 4166, 0, 750, 0, 291, 4166, + 761, 0, 0, 79, 739, 994, 4166, 4166, 990, 1003, + 1011, 1014, 1027, 1035, 1038, 1051, 1059, 1067, 1075, 1088, + 1096, 1099, 1120, 1121, 1136, 1142, 1153, 1159, 1170, 1176, + 1187, 1198, 707, 693, 1211, 1219, 1222, 1237, 1240, 1243, + + 1267, 1261, 1264, 1282, 702, 1285, 1300, 1306, 696, 1317, + 1328, 1334, 1345, 1356, 686, 1367, 1373, 1384, 1390, 1405, + 1406, 1421, 1432, 1438, 1453, 1459, 692, 1470, 1481, 1492, + 675, 686, 681, 1503, 4166, 1542, 697, 143, 158, 4166, + 683, 4166, 4166, 1527, 1528, 1543, 1549, 1564, 1565, 1582, + 1581, 1597, 1603, 1614, 1625, 1643, 1640, 1646, 1661, 1664, + 1667, 1682, 1688, 1699, 1710, 1725, 1731, 664, 668, 1742, + 1748, 1763, 1764, 1779, 1785, 1796, 1809, 1817, 1825, 658, + 1840, 1843, 1856, 670, 1864, 1880, 1879, 1896, 649, 1897, + 1912, 1925, 1933, 1936, 1954, 1951, 1957, 1972, 1975, 648, + + 1978, 1993, 1999, 2010, 2016, 660, 649, 660, 2031, 2063, + 283, 280, 305, 2048, 2064, 2072, 2080, 2088, 644, 2096, + 2104, 2117, 2125, 2128, 2146, 2143, 2149, 2164, 2170, 2185, + 2186, 2201, 2216, 2222, 2233, 2239, 2254, 653, 641, 627, + 2255, 2275, 2272, 2293, 2292, 2310, 2309, 2325, 2331, 633, + 2342, 2353, 2359, 623, 2370, 2381, 2387, 2398, 639, 2411, + 2414, 2422, 2435, 616, 2446, 625, 2452, 2467, 2468, 613, + 2483, 607, 604, 610, 4166, 302, 321, 96, 2489, 2504, + 2507, 2515, 610, 2530, 2536, 2547, 2553, 2564, 2570, 2581, + 2592, 2598, 2615, 2621, 2637, 2638, 2653, 2654, 2669, 2675, + + 605, 607, 599, 2686, 2692, 2707, 2708, 2728, 2729, 2744, + 2752, 2765, 2773, 604, 2776, 2794, 631, 2791, 2797, 2812, + 2815, 603, 2823, 2838, 2841, 2844, 590, 2859, 574, 2862, + 2865, 588, 576, 574, 583, 581, 317, 309, 328, 2880, + 2883, 2896, 572, 2904, 2917, 2925, 2928, 2941, 2949, 2952, + 2965, 2976, 2973, 2989, 3000, 3011, 3017, 3028, 54, 589, + 564, 3034, 3045, 3056, 3062, 3073, 3079, 3094, 3095, 3110, + 3111, 583, 3126, 566, 3127, 3144, 3147, 3150, 558, 3165, + 3171, 554, 3186, 576, 3192, 0, 555, 559, 536, 566, + 347, 226, 339, 3203, 3209, 3224, 548, 3230, 3241, 3254, + + 3262, 3265, 3280, 3283, 3291, 3304, 3307, 531, 525, 525, + 531, 3322, 3328, 3339, 3345, 3356, 516, 3367, 512, 3373, + 511, 3384, 521, 3395, 3401, 517, 3412, 504, 3418, 506, + 507, 520, 466, 325, 465, 348, 3429, 3440, 3451, 0, + 3457, 3468, 3479, 3490, 3496, 3511, 3512, 467, 476, 464, + 0, 3527, 3528, 470, 3544, 450, 462, 3545, 474, 3560, + 0, 3566, 447, 3577, 444, 454, 423, 424, 361, 3616, + 353, 3601, 3602, 3617, 3618, 3633, 3634, 3649, 3650, 430, + 434, 428, 3665, 3673, 421, 3681, 421, 412, 3689, 403, + 3697, 3705, 410, 0, 400, 401, 403, 189, 3737, 519, + + 3722, 3723, 3738, 3746, 398, 417, 394, 3759, 398, 3767, + 391, 391, 3770, 383, 3783, 3794, 383, 378, 383, 378, + 371, 4166, 3833, 3818, 3819, 378, 363, 359, 3834, 0, + 3840, 357, 347, 3851, 351, 3857, 3868, 330, 315, 305, + 295, 558, 3884, 3881, 0, 282, 0, 3892, 0, 262, + 3907, 256, 3910, 0, 188, 141, 0, 3954, 3939, 138, + 3940, 120, 105, 3955, 95, 0, 3956, 0, 37, 0, + 3972, 0, 0, 4166, 4017, 4029, 4041, 4053, 4065, 4077, + 4088, 4089, 4093, 4104, 4116, 4128, 4139, 4144, 4149, 4154 + } ; + +static yyconst short int yy_def[691] = + { 0, + 674, 1, 675, 675, 676, 676, 677, 677, 678, 678, + 679, 679, 674, 674, 674, 674, 674, 680, 674, 681, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 682, 683, 684, + 674, 674, 674, 674, 674, 674, 674, 685, 685, 674, + 686, 686, 674, 674, 674, 674, 687, 674, 674, 19, + 674, 674, 674, 680, 680, 674, 688, 674, 689, 681, + 681, 674, 674, 674, 674, 674, 674, 29, 29, 29, + 29, 29, 29, 690, 29, 29, 29, 29, 29, 29, + + 29, 29, 29, 29, 29, 29, 29, 29, 690, 690, + 29, 29, 29, 29, 29, 29, 29, 29, 690, 29, + 29, 29, 29, 690, 29, 29, 29, 29, 690, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 690, 29, + 29, 690, 690, 29, 674, 682, 146, 146, 146, 683, + 684, 674, 674, 685, 674, 686, 674, 687, 674, 674, + 674, 688, 689, 674, 674, 674, 674, 674, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 690, 690, 29, 29, 29, 29, 29, 29, + + 29, 29, 29, 29, 690, 29, 29, 29, 690, 29, + 29, 29, 29, 29, 690, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 690, 29, 29, 29, + 690, 690, 690, 29, 674, 674, 146, 146, 146, 674, + 674, 674, 674, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 690, 690, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 690, + 29, 29, 29, 690, 29, 29, 29, 29, 690, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 690, + + 29, 29, 29, 29, 29, 690, 690, 690, 29, 674, + 146, 146, 146, 29, 29, 29, 29, 29, 690, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 690, 690, 690, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 690, + 29, 29, 29, 690, 29, 29, 29, 29, 690, 29, + 29, 29, 29, 690, 29, 690, 29, 29, 29, 690, + 29, 690, 690, 690, 674, 146, 146, 146, 29, 29, + 29, 29, 690, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + + 690, 690, 690, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 690, 29, 29, 690, 29, 29, 29, + 29, 690, 29, 29, 29, 29, 690, 29, 690, 29, + 29, 690, 690, 690, 690, 690, 146, 146, 146, 29, + 29, 29, 690, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 690, 690, + 690, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 690, 29, 690, 29, 29, 29, 29, 690, 29, + 29, 690, 29, 690, 29, 690, 690, 690, 690, 690, + 146, 146, 146, 29, 29, 29, 690, 29, 29, 29, + + 29, 29, 29, 29, 29, 29, 29, 690, 690, 690, + 690, 29, 29, 29, 29, 29, 690, 29, 690, 29, + 690, 29, 690, 29, 29, 690, 29, 690, 29, 690, + 690, 690, 690, 146, 146, 146, 29, 29, 29, 690, + 29, 29, 29, 29, 29, 29, 29, 690, 690, 690, + 690, 29, 29, 690, 29, 690, 690, 29, 690, 29, + 690, 29, 690, 29, 690, 690, 690, 690, 146, 674, + 146, 29, 29, 29, 29, 29, 29, 29, 29, 690, + 690, 690, 29, 29, 690, 29, 690, 690, 29, 690, + 29, 29, 690, 690, 690, 690, 690, 146, 674, 146, + + 29, 29, 29, 29, 690, 690, 690, 29, 690, 29, + 690, 690, 29, 690, 29, 29, 690, 690, 690, 690, + 146, 674, 674, 29, 29, 690, 690, 690, 29, 690, + 29, 690, 690, 29, 690, 29, 29, 690, 690, 690, + 690, 146, 29, 29, 690, 690, 690, 29, 690, 690, + 29, 690, 29, 690, 690, 690, 690, 674, 29, 690, + 29, 690, 690, 29, 690, 690, 29, 690, 690, 690, + 29, 690, 690, 0, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674 + } ; + +static yyconst short int yy_nxt[4245] = + { 0, + 14, 15, 16, 15, 17, 18, 19, 20, 21, 14, + 22, 23, 24, 25, 26, 26, 26, 26, 26, 26, + 27, 17, 28, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 36, 36, 36, 38, 39, 40, 41, + 36, 42, 43, 44, 45, 46, 47, 36, 36, 36, + 48, 17, 14, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 49, 49, 49, 49, 49, 21, 17, 21, 51, 52, + 51, 52, 55, 55, 59, 62, 53, 60, 53, 56, + 56, 59, 57, 57, 60, 62, 508, 68, 69, 68, + + 76, 232, 70, 63, 242, 673, 64, 68, 69, 68, + 243, 674, 70, 63, 233, 509, 64, 73, 73, 73, + 73, 73, 73, 72, 439, 674, 72, 80, 80, 80, + 72, 78, 85, 72, 72, 147, 147, 82, 238, 80, + 80, 83, 83, 83, 83, 83, 83, 86, 86, 86, + 86, 86, 86, 86, 672, 88, 674, 239, 65, 147, + 66, 159, 159, 159, 670, 88, 88, 88, 65, 88, + 66, 28, 100, 71, 88, 312, 101, 88, 88, 102, + 88, 28, 147, 71, 72, 88, 669, 88, 104, 105, + 313, 88, 159, 159, 159, 668, 88, 147, 76, 106, + + 666, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, + 77, 77, 77, 77, 77, 77, 77, 621, 147, 78, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, + 79, 79, 88, 665, 535, 88, 88, 88, 88, 88, + 88, 88, 73, 73, 73, 147, 88, 89, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 90, 88, 91, + 88, 92, 88, 88, 88, 88, 93, 88, 88, 88, + 88, 88, 159, 159, 159, 94, 94, 94, 94, 94, + + 94, 94, 94, 94, 94, 94, 94, 94, 94, 94, + 94, 94, 94, 94, 94, 94, 94, 88, 376, 147, + 95, 663, 147, 88, 96, 377, 103, 88, 97, 88, + 98, 88, 662, 88, 437, 88, 88, 88, 107, 88, + 99, 147, 88, 491, 147, 438, 660, 88, 147, 88, + 378, 88, 492, 88, 657, 108, 147, 88, 88, 88, + 147, 88, 111, 88, 147, 112, 88, 147, 569, 493, + 656, 534, 571, 88, 113, 114, 655, 88, 147, 109, + 115, 536, 88, 116, 88, 88, 147, 147, 600, 654, + 110, 117, 147, 598, 88, 88, 88, 88, 88, 88, + + 147, 120, 121, 88, 118, 122, 125, 88, 642, 126, + 147, 88, 652, 88, 650, 123, 649, 127, 647, 88, + 88, 88, 88, 128, 646, 130, 88, 80, 80, 80, + 124, 119, 88, 164, 88, 88, 88, 645, 131, 80, + 80, 88, 132, 641, 640, 88, 639, 88, 638, 88, + 129, 635, 633, 133, 88, 135, 632, 630, 134, 628, + 627, 136, 88, 626, 620, 88, 570, 570, 570, 619, + 618, 617, 88, 614, 88, 88, 88, 140, 137, 88, + 612, 88, 611, 141, 88, 138, 609, 88, 88, 607, + 606, 605, 597, 596, 139, 144, 595, 88, 88, 88, + + 88, 88, 88, 594, 147, 142, 88, 88, 145, 145, + 145, 145, 145, 145, 145, 593, 590, 588, 587, 146, + 623, 623, 623, 143, 166, 166, 166, 166, 166, 166, + 166, 585, 582, 581, 148, 580, 568, 88, 88, 149, + 86, 86, 86, 86, 86, 86, 86, 88, 88, 88, + 88, 88, 88, 88, 88, 169, 88, 88, 147, 658, + 658, 658, 567, 170, 88, 88, 88, 88, 88, 88, + 566, 565, 88, 88, 563, 88, 561, 171, 559, 88, + 557, 88, 556, 172, 554, 88, 88, 88, 88, 88, + 551, 174, 88, 173, 88, 550, 88, 147, 88, 549, + + 88, 548, 88, 88, 88, 88, 88, 540, 533, 532, + 175, 88, 531, 88, 88, 88, 530, 176, 528, 526, + 88, 523, 88, 521, 88, 519, 88, 177, 88, 511, + 88, 510, 88, 88, 88, 178, 88, 497, 490, 88, + 489, 180, 88, 488, 487, 486, 88, 484, 88, 179, + 88, 482, 88, 88, 88, 88, 88, 479, 474, 472, + 461, 88, 460, 88, 181, 182, 88, 88, 459, 184, + 183, 443, 88, 436, 435, 434, 88, 432, 88, 88, + 88, 88, 429, 88, 427, 88, 88, 188, 88, 88, + 185, 186, 422, 417, 414, 403, 88, 88, 88, 88, + + 189, 88, 402, 88, 190, 88, 401, 191, 187, 88, + 88, 88, 383, 195, 374, 373, 88, 372, 366, 359, + 88, 88, 88, 192, 88, 354, 350, 88, 339, 88, + 196, 88, 338, 88, 160, 88, 311, 88, 88, 88, + 88, 88, 308, 307, 88, 198, 88, 306, 88, 300, + 88, 289, 197, 284, 88, 88, 88, 88, 88, 280, + 269, 199, 200, 88, 268, 88, 88, 88, 201, 88, + 243, 241, 88, 240, 88, 147, 88, 231, 88, 227, + 88, 215, 88, 88, 203, 88, 88, 209, 202, 205, + 194, 88, 193, 204, 168, 88, 88, 88, 167, 88, + + 165, 161, 88, 160, 206, 160, 88, 157, 88, 88, + 88, 88, 88, 88, 155, 88, 85, 207, 88, 153, + 88, 152, 88, 88, 88, 87, 88, 84, 75, 72, + 88, 88, 88, 88, 88, 88, 88, 88, 208, 88, + 72, 210, 88, 674, 674, 674, 88, 88, 88, 674, + 88, 674, 674, 674, 674, 88, 211, 88, 674, 88, + 88, 88, 674, 213, 674, 674, 212, 214, 674, 674, + 88, 674, 88, 674, 88, 216, 88, 674, 674, 88, + 674, 674, 88, 674, 674, 674, 217, 674, 88, 674, + 88, 674, 88, 88, 88, 88, 88, 218, 674, 88, + + 219, 88, 674, 88, 674, 88, 674, 88, 674, 88, + 88, 88, 88, 88, 223, 221, 674, 220, 88, 674, + 88, 674, 222, 674, 88, 88, 88, 674, 674, 88, + 674, 224, 674, 674, 674, 88, 88, 88, 88, 88, + 88, 88, 88, 674, 88, 88, 674, 674, 674, 674, + 674, 88, 88, 88, 88, 88, 226, 88, 88, 229, + 225, 88, 230, 674, 228, 674, 674, 88, 88, 88, + 88, 88, 88, 88, 674, 674, 88, 88, 674, 674, + 674, 674, 674, 88, 674, 88, 674, 88, 236, 236, + 236, 234, 88, 145, 145, 145, 145, 145, 145, 145, + + 674, 674, 674, 674, 674, 674, 674, 166, 166, 166, + 166, 166, 166, 166, 674, 88, 674, 674, 244, 674, + 674, 674, 674, 674, 674, 88, 237, 88, 88, 88, + 674, 235, 674, 245, 88, 674, 88, 674, 88, 88, + 88, 674, 88, 674, 674, 674, 88, 88, 88, 246, + 88, 88, 88, 88, 674, 88, 674, 674, 88, 674, + 88, 674, 88, 88, 88, 247, 88, 248, 674, 674, + 88, 88, 88, 88, 88, 88, 88, 88, 674, 88, + 674, 674, 88, 674, 88, 674, 88, 674, 88, 674, + 88, 674, 88, 249, 250, 88, 88, 674, 88, 674, + + 88, 674, 88, 88, 88, 674, 88, 252, 251, 674, + 88, 88, 88, 88, 88, 674, 674, 674, 674, 88, + 674, 88, 674, 88, 88, 88, 674, 88, 674, 674, + 253, 88, 88, 88, 88, 254, 88, 674, 88, 674, + 88, 255, 256, 88, 257, 88, 88, 674, 674, 259, + 674, 674, 258, 674, 674, 88, 88, 88, 88, 88, + 88, 88, 674, 674, 88, 88, 674, 88, 674, 674, + 674, 88, 674, 88, 260, 88, 674, 88, 88, 88, + 88, 88, 674, 674, 88, 674, 88, 262, 88, 261, + 88, 674, 88, 674, 88, 88, 88, 88, 88, 674, + + 674, 88, 674, 88, 265, 263, 674, 88, 264, 88, + 674, 88, 88, 88, 88, 88, 674, 674, 674, 674, + 88, 674, 88, 88, 88, 674, 88, 674, 674, 266, + 674, 88, 674, 88, 267, 88, 88, 88, 674, 674, + 674, 674, 88, 674, 88, 674, 88, 88, 88, 674, + 88, 674, 674, 270, 88, 88, 271, 272, 88, 88, + 273, 88, 88, 88, 674, 88, 88, 674, 88, 674, + 674, 276, 274, 674, 88, 88, 88, 88, 88, 88, + 88, 88, 88, 275, 88, 277, 88, 88, 674, 88, + 674, 674, 88, 674, 674, 674, 88, 674, 88, 88, + + 88, 88, 88, 88, 88, 88, 88, 88, 278, 674, + 88, 88, 674, 281, 674, 674, 674, 279, 674, 88, + 88, 88, 88, 674, 88, 88, 88, 674, 282, 88, + 674, 88, 674, 674, 674, 88, 674, 88, 283, 88, + 674, 88, 88, 88, 88, 88, 674, 674, 674, 674, + 88, 674, 88, 88, 88, 674, 88, 674, 674, 88, + 285, 88, 674, 88, 674, 88, 674, 88, 674, 88, + 88, 88, 88, 88, 674, 674, 286, 674, 88, 674, + 88, 88, 88, 674, 88, 674, 674, 287, 674, 88, + 674, 88, 88, 88, 674, 88, 674, 291, 88, 674, + + 88, 288, 290, 674, 88, 674, 88, 674, 88, 88, + 88, 88, 88, 674, 674, 88, 674, 88, 674, 88, + 674, 88, 674, 88, 674, 88, 674, 88, 292, 88, + 88, 88, 674, 293, 88, 674, 674, 674, 294, 674, + 88, 88, 88, 88, 88, 88, 88, 674, 674, 88, + 88, 674, 674, 674, 674, 674, 88, 88, 88, 674, + 88, 674, 674, 88, 295, 88, 674, 88, 674, 88, + 674, 88, 674, 88, 296, 88, 88, 88, 88, 674, + 297, 298, 88, 674, 88, 674, 674, 299, 88, 674, + 88, 674, 88, 674, 88, 88, 88, 88, 88, 674, + + 674, 674, 674, 88, 674, 88, 88, 88, 301, 88, + 302, 305, 674, 674, 88, 303, 88, 88, 88, 674, + 88, 674, 674, 674, 304, 88, 674, 88, 88, 88, + 674, 88, 674, 674, 309, 674, 88, 674, 88, 674, + 88, 674, 88, 236, 236, 236, 674, 88, 674, 674, + 674, 674, 88, 88, 674, 310, 310, 310, 310, 310, + 310, 310, 88, 88, 314, 88, 88, 88, 88, 315, + 674, 88, 88, 674, 88, 316, 674, 674, 88, 674, + 88, 674, 88, 674, 88, 317, 88, 88, 88, 88, + 88, 674, 674, 88, 674, 674, 674, 674, 674, 88, + + 88, 318, 88, 88, 88, 321, 88, 88, 88, 88, + 320, 674, 674, 674, 674, 674, 88, 88, 88, 88, + 88, 88, 88, 322, 674, 88, 88, 674, 88, 674, + 674, 674, 88, 674, 88, 319, 88, 674, 88, 88, + 88, 88, 88, 674, 674, 323, 674, 88, 674, 88, + 88, 88, 324, 88, 674, 674, 674, 674, 88, 674, + 88, 674, 88, 674, 88, 88, 325, 326, 88, 88, + 674, 88, 674, 674, 674, 88, 674, 88, 88, 88, + 88, 88, 88, 328, 327, 88, 88, 88, 329, 88, + 88, 330, 88, 674, 674, 331, 88, 674, 88, 88, + + 88, 88, 88, 88, 88, 88, 88, 88, 88, 674, + 674, 88, 674, 88, 674, 674, 674, 88, 674, 88, + 333, 332, 674, 88, 88, 88, 88, 88, 674, 674, + 674, 674, 88, 674, 88, 88, 88, 674, 88, 674, + 334, 674, 674, 88, 674, 88, 674, 335, 674, 88, + 88, 336, 674, 337, 88, 674, 88, 674, 674, 674, + 88, 674, 88, 674, 88, 674, 88, 88, 88, 88, + 88, 674, 674, 88, 674, 88, 674, 88, 674, 88, + 674, 88, 674, 88, 674, 88, 88, 88, 88, 88, + 674, 341, 88, 674, 674, 342, 674, 674, 88, 88, + + 88, 88, 88, 88, 88, 343, 674, 88, 88, 345, + 88, 674, 340, 674, 88, 674, 88, 674, 88, 674, + 88, 88, 88, 344, 88, 348, 346, 674, 674, 88, + 674, 88, 674, 88, 88, 88, 674, 347, 674, 674, + 88, 674, 88, 674, 88, 674, 88, 674, 88, 674, + 88, 674, 88, 88, 88, 674, 88, 674, 674, 349, + 88, 88, 88, 674, 88, 88, 351, 674, 88, 88, + 674, 674, 674, 674, 674, 88, 674, 88, 88, 88, + 88, 88, 88, 674, 88, 674, 352, 88, 674, 88, + 356, 88, 355, 88, 353, 88, 674, 674, 674, 88, + + 88, 88, 674, 88, 88, 88, 674, 357, 88, 674, + 674, 674, 674, 674, 88, 88, 88, 88, 88, 88, + 358, 88, 88, 88, 88, 674, 674, 674, 674, 674, + 674, 88, 88, 88, 88, 88, 88, 88, 674, 674, + 88, 88, 674, 674, 674, 674, 674, 88, 674, 88, + 88, 88, 674, 361, 674, 360, 88, 674, 88, 674, + 88, 88, 88, 674, 88, 674, 674, 674, 88, 88, + 88, 88, 88, 362, 674, 88, 88, 88, 363, 88, + 88, 674, 88, 674, 674, 365, 88, 674, 88, 88, + 88, 88, 88, 88, 88, 88, 88, 88, 88, 674, + + 88, 88, 674, 88, 674, 674, 674, 88, 674, 88, + 88, 88, 88, 88, 88, 367, 88, 88, 88, 88, + 674, 364, 88, 674, 88, 674, 674, 369, 88, 674, + 88, 674, 88, 674, 88, 88, 88, 368, 88, 674, + 674, 88, 674, 88, 674, 88, 674, 88, 674, 88, + 674, 88, 674, 88, 88, 88, 88, 674, 371, 674, + 88, 674, 674, 674, 674, 674, 88, 674, 88, 674, + 88, 370, 674, 88, 674, 88, 310, 310, 310, 310, + 310, 310, 310, 88, 674, 88, 674, 88, 380, 88, + 674, 379, 88, 674, 674, 674, 674, 88, 381, 88, + + 674, 88, 674, 88, 382, 88, 674, 88, 88, 88, + 674, 88, 674, 88, 375, 88, 88, 88, 674, 88, + 384, 88, 674, 88, 88, 88, 674, 88, 674, 88, + 385, 88, 88, 88, 674, 88, 674, 674, 674, 88, + 88, 88, 88, 88, 674, 386, 674, 674, 88, 674, + 88, 674, 88, 88, 88, 674, 88, 674, 674, 674, + 88, 88, 88, 88, 88, 387, 674, 88, 88, 88, + 388, 88, 88, 674, 88, 389, 674, 674, 88, 674, + 88, 88, 88, 88, 390, 88, 88, 88, 88, 88, + 88, 674, 391, 88, 674, 88, 392, 393, 674, 88, + + 674, 88, 674, 88, 674, 88, 674, 88, 88, 88, + 88, 88, 674, 394, 88, 674, 674, 674, 674, 674, + 88, 88, 88, 88, 88, 88, 88, 395, 674, 88, + 88, 674, 674, 674, 674, 674, 88, 674, 88, 674, + 88, 88, 397, 674, 396, 88, 674, 88, 674, 674, + 674, 88, 674, 88, 674, 88, 674, 88, 88, 88, + 88, 88, 674, 674, 88, 398, 88, 674, 88, 674, + 88, 674, 88, 674, 88, 399, 400, 88, 88, 88, + 88, 674, 674, 88, 674, 674, 674, 404, 674, 88, + 88, 88, 88, 88, 88, 674, 674, 88, 88, 88, + + 88, 405, 674, 406, 674, 674, 674, 88, 674, 88, + 88, 88, 88, 674, 88, 407, 88, 88, 88, 88, + 408, 674, 674, 674, 674, 674, 674, 88, 88, 409, + 88, 88, 88, 674, 88, 88, 88, 88, 410, 674, + 674, 413, 674, 412, 88, 88, 88, 88, 88, 88, + 88, 411, 674, 88, 88, 674, 88, 674, 674, 674, + 88, 674, 88, 674, 88, 674, 88, 88, 88, 88, + 88, 674, 674, 674, 674, 88, 674, 88, 88, 88, + 674, 88, 674, 674, 88, 415, 88, 674, 88, 674, + 88, 674, 88, 674, 88, 88, 416, 88, 88, 674, + + 674, 674, 674, 88, 674, 88, 88, 88, 674, 88, + 674, 418, 88, 419, 88, 674, 88, 674, 88, 674, + 88, 674, 88, 88, 420, 88, 88, 674, 674, 674, + 674, 88, 674, 88, 674, 88, 88, 88, 674, 88, + 674, 421, 88, 423, 674, 674, 88, 88, 88, 88, + 88, 424, 425, 88, 674, 88, 674, 88, 88, 88, + 88, 88, 674, 674, 674, 674, 88, 674, 674, 674, + 88, 88, 88, 674, 88, 674, 674, 88, 428, 88, + 674, 88, 426, 88, 674, 88, 674, 88, 674, 88, + 88, 88, 88, 88, 674, 430, 88, 674, 674, 674, + + 674, 674, 88, 88, 88, 88, 88, 88, 88, 431, + 674, 88, 88, 674, 88, 674, 674, 674, 88, 674, + 88, 674, 88, 674, 88, 674, 88, 88, 88, 88, + 440, 441, 88, 88, 674, 674, 674, 674, 674, 88, + 88, 88, 88, 88, 88, 674, 88, 674, 88, 674, + 88, 88, 88, 433, 88, 88, 674, 674, 442, 88, + 674, 88, 674, 674, 674, 88, 674, 444, 674, 88, + 674, 88, 88, 88, 88, 88, 674, 674, 88, 445, + 88, 446, 88, 674, 88, 674, 88, 674, 88, 88, + 88, 88, 88, 674, 674, 88, 447, 88, 674, 88, + + 674, 88, 674, 88, 674, 88, 88, 448, 88, 88, + 674, 674, 674, 674, 88, 674, 88, 88, 88, 450, + 88, 674, 674, 88, 449, 88, 674, 88, 674, 88, + 674, 88, 674, 88, 674, 88, 88, 88, 674, 674, + 88, 451, 88, 452, 674, 674, 88, 674, 453, 674, + 88, 674, 88, 674, 88, 674, 88, 674, 88, 88, + 88, 454, 88, 88, 674, 88, 674, 674, 674, 674, + 674, 674, 88, 88, 88, 88, 88, 88, 88, 88, + 674, 88, 88, 674, 674, 455, 674, 674, 88, 88, + 88, 88, 88, 88, 88, 674, 456, 88, 88, 458, + + 88, 457, 674, 674, 88, 674, 88, 674, 88, 674, + 88, 88, 88, 88, 88, 462, 674, 88, 674, 88, + 674, 88, 674, 88, 463, 88, 674, 88, 674, 88, + 88, 88, 88, 88, 464, 674, 88, 674, 674, 674, + 674, 674, 88, 88, 88, 88, 88, 88, 674, 674, + 465, 88, 88, 88, 88, 467, 466, 674, 674, 674, + 674, 674, 674, 88, 88, 88, 88, 88, 88, 88, + 674, 674, 88, 88, 674, 674, 674, 88, 674, 88, + 469, 88, 674, 88, 674, 468, 674, 88, 88, 88, + 88, 88, 674, 674, 674, 674, 88, 674, 88, 674, + + 88, 88, 88, 674, 88, 471, 674, 470, 88, 88, + 88, 88, 88, 88, 674, 88, 88, 88, 473, 88, + 88, 674, 88, 674, 674, 674, 88, 674, 475, 88, + 88, 88, 88, 88, 476, 88, 88, 88, 88, 674, + 88, 88, 674, 478, 674, 674, 674, 88, 88, 88, + 88, 88, 88, 674, 88, 477, 88, 674, 88, 88, + 88, 674, 88, 88, 481, 674, 88, 88, 480, 88, + 674, 674, 674, 88, 674, 88, 88, 88, 88, 88, + 88, 88, 88, 88, 88, 88, 483, 88, 88, 674, + 88, 674, 674, 674, 88, 674, 88, 88, 88, 88, + + 88, 88, 88, 88, 88, 88, 88, 485, 88, 88, + 674, 674, 674, 674, 674, 88, 674, 88, 88, 88, + 88, 88, 88, 494, 88, 674, 495, 88, 496, 88, + 674, 88, 674, 88, 674, 88, 674, 674, 674, 88, + 88, 88, 88, 88, 674, 498, 674, 674, 88, 674, + 88, 674, 88, 88, 88, 674, 88, 674, 674, 674, + 88, 88, 499, 88, 88, 500, 88, 88, 674, 88, + 674, 674, 88, 501, 88, 674, 88, 88, 88, 674, + 88, 674, 674, 674, 88, 88, 88, 88, 88, 88, + 88, 88, 674, 88, 674, 674, 88, 502, 88, 674, + + 88, 88, 88, 503, 88, 674, 674, 674, 88, 88, + 88, 88, 88, 88, 88, 88, 674, 88, 674, 674, + 88, 674, 674, 674, 88, 88, 88, 674, 88, 674, + 674, 674, 504, 88, 674, 88, 88, 88, 674, 88, + 674, 674, 506, 505, 88, 674, 88, 674, 88, 674, + 88, 674, 88, 88, 88, 88, 88, 674, 674, 88, + 674, 88, 674, 507, 674, 88, 512, 88, 674, 88, + 88, 88, 88, 88, 674, 674, 674, 674, 88, 674, + 88, 88, 88, 674, 88, 674, 674, 88, 513, 88, + 674, 88, 674, 88, 674, 88, 674, 88, 88, 88, + + 88, 88, 674, 674, 88, 674, 88, 515, 88, 674, + 88, 674, 88, 674, 88, 514, 88, 88, 88, 88, + 88, 516, 674, 88, 674, 674, 674, 674, 674, 88, + 88, 88, 88, 88, 88, 88, 88, 674, 88, 88, + 674, 674, 674, 674, 674, 88, 88, 88, 518, 88, + 88, 88, 88, 674, 88, 88, 674, 674, 674, 674, + 674, 520, 88, 88, 88, 88, 88, 674, 674, 88, + 88, 88, 88, 522, 674, 88, 674, 674, 674, 88, + 517, 88, 88, 88, 88, 88, 88, 88, 88, 88, + 88, 88, 674, 524, 88, 674, 88, 674, 674, 525, + + 88, 674, 88, 674, 88, 674, 88, 674, 88, 88, + 88, 88, 674, 537, 527, 88, 529, 88, 674, 674, + 674, 88, 674, 88, 674, 88, 674, 88, 88, 88, + 88, 88, 674, 674, 88, 674, 88, 674, 88, 674, + 88, 538, 88, 674, 88, 674, 88, 88, 88, 88, + 539, 674, 674, 88, 674, 88, 674, 674, 674, 88, + 674, 88, 674, 88, 674, 88, 88, 88, 88, 88, + 674, 541, 674, 674, 88, 674, 88, 674, 88, 88, + 88, 674, 543, 674, 542, 88, 674, 88, 674, 88, + 88, 88, 674, 88, 674, 674, 674, 88, 88, 544, + + 88, 88, 88, 545, 88, 88, 88, 674, 88, 88, + 674, 546, 674, 674, 674, 88, 88, 88, 88, 88, + 88, 674, 88, 674, 88, 674, 88, 88, 88, 88, + 88, 674, 88, 674, 674, 88, 547, 674, 674, 88, + 674, 88, 88, 88, 88, 674, 88, 88, 88, 674, + 552, 88, 674, 88, 674, 674, 674, 88, 674, 88, + 674, 88, 674, 88, 88, 88, 88, 88, 674, 674, + 88, 674, 88, 674, 88, 674, 88, 674, 88, 674, + 88, 88, 88, 88, 88, 674, 674, 674, 674, 88, + 674, 88, 88, 88, 674, 88, 555, 674, 88, 553, + + 88, 674, 88, 674, 88, 560, 88, 674, 88, 88, + 88, 88, 88, 674, 674, 674, 558, 88, 674, 88, + 88, 88, 674, 88, 674, 674, 88, 674, 88, 674, + 88, 674, 88, 674, 88, 674, 88, 88, 88, 88, + 88, 674, 674, 88, 674, 88, 674, 88, 674, 562, + 674, 88, 674, 564, 88, 88, 88, 88, 674, 674, + 674, 674, 88, 674, 88, 88, 88, 674, 88, 674, + 674, 572, 674, 88, 674, 88, 88, 88, 573, 88, + 674, 674, 88, 674, 88, 674, 88, 674, 88, 674, + 88, 674, 88, 88, 88, 88, 88, 674, 674, 674, + + 674, 88, 674, 88, 88, 88, 575, 88, 674, 674, + 574, 674, 88, 674, 88, 88, 88, 674, 88, 674, + 576, 88, 674, 88, 674, 88, 674, 88, 674, 88, + 674, 88, 674, 577, 88, 88, 88, 88, 578, 674, + 88, 674, 674, 674, 674, 674, 88, 579, 88, 88, + 88, 88, 88, 88, 674, 88, 88, 674, 674, 674, + 584, 674, 88, 88, 88, 88, 88, 88, 583, 88, + 88, 88, 88, 674, 674, 674, 586, 674, 674, 88, + 88, 88, 589, 88, 88, 88, 674, 674, 88, 88, + 674, 88, 674, 674, 674, 88, 674, 88, 591, 88, + + 674, 88, 88, 88, 88, 88, 674, 674, 674, 592, + 88, 674, 88, 674, 88, 674, 88, 570, 570, 570, + 674, 88, 674, 674, 674, 674, 88, 88, 674, 599, + 599, 599, 599, 599, 599, 599, 88, 88, 88, 602, + 88, 88, 88, 88, 674, 88, 88, 674, 674, 601, + 674, 674, 88, 88, 88, 88, 88, 88, 88, 88, + 674, 88, 88, 674, 674, 674, 674, 674, 88, 88, + 88, 88, 88, 88, 88, 88, 603, 88, 88, 674, + 674, 674, 604, 674, 88, 88, 88, 88, 88, 88, + 88, 674, 674, 88, 88, 674, 674, 674, 88, 674, + + 88, 674, 88, 674, 88, 674, 88, 674, 88, 88, + 88, 608, 88, 674, 88, 674, 88, 88, 610, 674, + 88, 613, 88, 674, 88, 88, 88, 674, 88, 615, + 88, 674, 88, 88, 88, 674, 88, 616, 674, 674, + 88, 88, 88, 674, 88, 674, 674, 88, 88, 88, + 599, 599, 599, 599, 599, 599, 599, 88, 88, 624, + 88, 88, 88, 88, 674, 674, 88, 88, 674, 674, + 674, 88, 674, 88, 674, 88, 674, 88, 674, 674, + 674, 88, 88, 88, 88, 88, 674, 674, 622, 625, + 88, 674, 88, 674, 88, 88, 629, 674, 88, 631, + + 674, 674, 88, 88, 88, 88, 88, 88, 88, 88, + 636, 88, 674, 634, 88, 674, 674, 674, 88, 88, + 88, 674, 88, 637, 674, 674, 674, 88, 674, 88, + 674, 88, 674, 88, 623, 623, 623, 674, 88, 674, + 674, 674, 674, 88, 88, 674, 599, 599, 599, 599, + 599, 599, 599, 88, 88, 88, 88, 88, 88, 88, + 674, 643, 88, 88, 674, 88, 674, 644, 674, 88, + 674, 88, 674, 88, 674, 88, 88, 88, 88, 88, + 674, 674, 88, 648, 88, 674, 88, 674, 88, 674, + 88, 674, 88, 88, 88, 88, 88, 674, 674, 651, + + 653, 88, 674, 88, 674, 88, 88, 88, 659, 88, + 674, 674, 88, 674, 674, 674, 88, 88, 88, 88, + 88, 88, 674, 88, 674, 88, 674, 88, 88, 88, + 674, 88, 88, 674, 674, 88, 88, 674, 664, 674, + 661, 674, 88, 674, 88, 88, 88, 88, 674, 88, + 674, 88, 674, 674, 88, 658, 658, 658, 674, 674, + 674, 674, 674, 674, 88, 88, 674, 599, 599, 599, + 599, 599, 599, 599, 88, 88, 88, 88, 88, 88, + 88, 88, 674, 88, 88, 674, 667, 674, 674, 674, + 88, 88, 88, 88, 88, 88, 671, 88, 674, 88, + + 88, 674, 674, 674, 674, 674, 674, 88, 674, 88, + 674, 88, 674, 674, 674, 674, 88, 50, 50, 50, + 50, 50, 50, 50, 50, 50, 50, 50, 50, 54, + 54, 54, 54, 54, 54, 54, 54, 54, 54, 54, + 54, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 58, 58, 58, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 67, 67, 67, 67, 67, + 67, 67, 67, 67, 67, 67, 67, 74, 74, 74, + 674, 74, 74, 74, 74, 74, 74, 74, 74, 81, + 81, 674, 674, 81, 674, 81, 147, 674, 147, 150, + + 150, 674, 150, 150, 151, 151, 674, 151, 151, 151, + 674, 151, 151, 151, 151, 151, 154, 154, 154, 674, + 154, 154, 154, 154, 154, 154, 154, 154, 156, 156, + 156, 156, 156, 156, 156, 156, 674, 156, 156, 158, + 674, 674, 158, 674, 158, 158, 158, 158, 158, 158, + 162, 162, 674, 162, 162, 163, 163, 674, 163, 163, + 94, 94, 674, 94, 94, 13, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674 + } ; + +static yyconst short int yy_chk[4245] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, + 4, 4, 5, 6, 7, 9, 3, 7, 4, 5, + 6, 8, 5, 6, 8, 10, 459, 11, 11, 11, + + 78, 143, 11, 9, 164, 669, 9, 12, 12, 12, + 164, 70, 12, 10, 143, 459, 10, 15, 15, 15, + 16, 16, 16, 15, 378, 70, 16, 20, 20, 20, + 24, 78, 24, 20, 22, 378, 148, 22, 148, 20, + 20, 22, 22, 22, 22, 22, 22, 26, 26, 26, + 26, 26, 26, 26, 665, 36, 70, 149, 9, 149, + 9, 68, 68, 68, 663, 36, 31, 36, 10, 36, + 10, 11, 31, 11, 36, 238, 31, 33, 31, 31, + 31, 12, 238, 12, 19, 31, 662, 33, 33, 33, + 239, 33, 69, 69, 69, 660, 33, 239, 19, 33, + + 656, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 598, 598, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, + 19, 19, 29, 655, 492, 29, 29, 29, 29, 29, + 29, 29, 73, 73, 73, 492, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 159, 159, 159, 29, 29, 29, 29, 29, + + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 30, 311, 312, + 30, 652, 311, 32, 30, 312, 32, 30, 30, 30, + 30, 30, 650, 32, 376, 32, 30, 32, 34, 34, + 30, 376, 32, 437, 313, 377, 646, 35, 438, 34, + 313, 34, 438, 34, 641, 34, 437, 35, 34, 35, + 377, 35, 37, 37, 534, 37, 35, 439, 534, 439, + 640, 491, 536, 37, 37, 37, 639, 37, 493, 35, + 37, 493, 37, 38, 38, 39, 491, 536, 571, 638, + 35, 38, 571, 569, 38, 39, 38, 39, 38, 39, + + 569, 40, 40, 38, 39, 40, 41, 41, 621, 41, + 621, 40, 635, 40, 633, 40, 632, 41, 628, 41, + 40, 41, 42, 41, 627, 42, 41, 80, 80, 80, + 40, 39, 42, 80, 42, 43, 42, 626, 43, 80, + 80, 42, 43, 620, 619, 43, 618, 43, 617, 43, + 41, 614, 612, 43, 43, 44, 611, 609, 43, 607, + 606, 44, 44, 605, 597, 45, 535, 535, 535, 596, + 595, 593, 44, 590, 44, 45, 44, 45, 44, 45, + 588, 44, 587, 45, 45, 44, 585, 46, 47, 582, + 581, 580, 568, 567, 44, 47, 566, 46, 47, 46, + + 47, 46, 47, 565, 535, 45, 46, 47, 48, 48, + 48, 48, 48, 48, 48, 563, 559, 557, 556, 48, + 600, 600, 600, 46, 83, 83, 83, 83, 83, 83, + 83, 554, 550, 549, 48, 548, 533, 88, 89, 48, + 86, 86, 86, 86, 86, 86, 86, 88, 89, 88, + 89, 88, 89, 90, 91, 89, 88, 89, 600, 642, + 642, 642, 532, 90, 91, 90, 91, 90, 91, 92, + 531, 530, 90, 91, 528, 93, 526, 91, 523, 92, + 521, 92, 519, 92, 517, 93, 95, 93, 92, 93, + 511, 95, 96, 93, 93, 510, 95, 642, 95, 509, + + 95, 508, 96, 97, 96, 95, 96, 497, 490, 489, + 96, 96, 488, 97, 98, 97, 487, 97, 484, 482, + 99, 479, 97, 474, 98, 472, 98, 98, 98, 461, + 99, 460, 99, 98, 99, 100, 100, 443, 436, 99, + 435, 101, 101, 434, 433, 432, 100, 429, 100, 100, + 100, 427, 101, 102, 101, 100, 101, 422, 417, 414, + 403, 101, 402, 102, 102, 102, 103, 102, 401, 104, + 103, 383, 102, 374, 373, 372, 103, 370, 103, 104, + 103, 104, 366, 104, 364, 103, 106, 106, 104, 105, + 105, 105, 359, 354, 350, 340, 106, 107, 106, 105, + + 106, 105, 339, 105, 106, 106, 338, 107, 105, 107, + 108, 107, 319, 111, 308, 307, 107, 306, 300, 289, + 108, 111, 108, 108, 108, 284, 280, 112, 269, 108, + 112, 111, 268, 111, 241, 111, 237, 112, 113, 112, + 111, 112, 233, 232, 114, 114, 112, 231, 113, 227, + 113, 215, 113, 209, 114, 115, 114, 113, 114, 205, + 194, 114, 114, 114, 193, 115, 116, 115, 115, 115, + 165, 161, 117, 157, 115, 147, 116, 142, 116, 139, + 116, 129, 117, 118, 117, 116, 117, 124, 116, 119, + 110, 117, 109, 118, 87, 118, 120, 118, 84, 121, + + 81, 76, 118, 75, 120, 72, 120, 63, 120, 121, + 120, 121, 122, 121, 60, 120, 57, 121, 121, 56, + 123, 53, 122, 125, 122, 27, 122, 23, 18, 17, + 123, 122, 123, 125, 123, 125, 126, 125, 123, 123, + 14, 125, 125, 13, 0, 0, 126, 127, 126, 0, + 126, 0, 0, 0, 0, 126, 126, 127, 0, 127, + 128, 127, 0, 128, 0, 0, 127, 128, 0, 0, + 128, 0, 128, 0, 128, 130, 130, 0, 0, 128, + 0, 0, 131, 0, 0, 0, 130, 0, 130, 0, + 130, 0, 131, 132, 131, 130, 131, 131, 0, 133, + + 131, 131, 0, 132, 0, 132, 0, 132, 0, 133, + 134, 133, 132, 133, 135, 133, 0, 132, 133, 0, + 134, 0, 134, 0, 134, 135, 136, 0, 0, 134, + 0, 136, 0, 0, 0, 135, 136, 135, 136, 135, + 136, 137, 138, 0, 135, 136, 0, 0, 0, 0, + 0, 137, 138, 137, 138, 137, 138, 140, 141, 141, + 137, 138, 141, 0, 140, 0, 0, 140, 141, 140, + 141, 140, 141, 144, 0, 0, 140, 141, 0, 0, + 0, 0, 0, 144, 0, 144, 0, 144, 146, 146, + 146, 144, 144, 145, 145, 145, 145, 145, 145, 145, + + 146, 146, 146, 146, 146, 146, 146, 166, 166, 166, + 166, 166, 166, 166, 0, 169, 0, 0, 169, 0, + 0, 0, 0, 0, 0, 169, 146, 169, 170, 169, + 0, 145, 0, 169, 169, 0, 171, 0, 170, 172, + 170, 0, 170, 0, 0, 0, 171, 170, 171, 172, + 171, 172, 173, 172, 0, 171, 0, 0, 172, 0, + 174, 0, 173, 175, 173, 173, 173, 174, 0, 0, + 174, 173, 174, 175, 174, 175, 176, 175, 0, 174, + 0, 0, 175, 0, 177, 0, 176, 0, 176, 0, + 176, 0, 178, 176, 177, 176, 177, 0, 177, 0, + + 179, 0, 178, 177, 178, 0, 178, 179, 178, 0, + 179, 178, 179, 180, 179, 0, 0, 0, 0, 179, + 0, 181, 0, 180, 182, 180, 0, 180, 0, 0, + 180, 181, 180, 181, 182, 181, 182, 0, 182, 0, + 181, 182, 182, 182, 183, 183, 184, 0, 0, 184, + 0, 0, 183, 0, 0, 183, 184, 183, 184, 183, + 184, 185, 0, 0, 183, 184, 0, 186, 0, 0, + 0, 185, 0, 185, 185, 185, 0, 186, 187, 186, + 185, 186, 0, 0, 188, 0, 186, 188, 187, 187, + 187, 0, 187, 0, 188, 189, 188, 187, 188, 0, + + 0, 190, 0, 188, 190, 189, 0, 189, 189, 189, + 0, 190, 191, 190, 189, 190, 0, 0, 0, 0, + 190, 0, 191, 192, 191, 0, 191, 0, 0, 191, + 0, 191, 0, 192, 192, 192, 195, 192, 0, 0, + 0, 0, 192, 0, 196, 0, 195, 197, 195, 0, + 195, 0, 0, 195, 196, 195, 196, 197, 196, 197, + 197, 197, 198, 196, 0, 199, 197, 0, 200, 0, + 0, 200, 198, 0, 198, 199, 198, 199, 200, 199, + 200, 198, 200, 199, 199, 201, 202, 200, 0, 203, + 0, 0, 201, 0, 0, 0, 202, 0, 202, 203, + + 202, 203, 201, 203, 201, 202, 201, 204, 203, 0, + 206, 201, 0, 206, 0, 0, 0, 204, 0, 204, + 206, 204, 206, 0, 206, 207, 204, 0, 207, 206, + 0, 208, 0, 0, 0, 207, 0, 207, 208, 207, + 0, 208, 210, 208, 207, 208, 0, 0, 0, 0, + 208, 0, 210, 211, 210, 0, 210, 0, 0, 212, + 210, 210, 0, 211, 0, 211, 0, 211, 0, 212, + 213, 212, 211, 212, 0, 0, 212, 0, 212, 0, + 213, 214, 213, 0, 213, 0, 0, 213, 0, 213, + 0, 214, 216, 214, 0, 214, 0, 217, 217, 0, + + 214, 214, 216, 0, 216, 0, 216, 0, 217, 218, + 217, 216, 217, 0, 0, 219, 0, 217, 0, 218, + 0, 218, 0, 218, 0, 219, 0, 219, 218, 219, + 220, 221, 0, 220, 219, 0, 0, 0, 221, 0, + 220, 221, 220, 221, 220, 221, 222, 0, 0, 220, + 221, 0, 0, 0, 0, 0, 222, 223, 222, 0, + 222, 0, 0, 224, 222, 222, 0, 223, 0, 223, + 0, 223, 0, 224, 223, 224, 223, 224, 225, 0, + 224, 225, 224, 0, 226, 0, 0, 226, 225, 0, + 225, 0, 225, 0, 226, 228, 226, 225, 226, 0, + + 0, 0, 0, 226, 0, 228, 229, 228, 228, 228, + 228, 230, 0, 0, 228, 228, 229, 230, 229, 0, + 229, 0, 0, 0, 229, 229, 0, 230, 234, 230, + 0, 230, 0, 0, 234, 0, 230, 0, 234, 0, + 234, 0, 234, 236, 236, 236, 0, 234, 0, 0, + 0, 0, 244, 245, 0, 236, 236, 236, 236, 236, + 236, 236, 244, 245, 244, 245, 244, 245, 246, 245, + 0, 244, 245, 0, 247, 246, 0, 0, 246, 0, + 246, 0, 246, 0, 247, 247, 247, 246, 247, 248, + 249, 0, 0, 247, 0, 0, 0, 0, 0, 248, + + 249, 248, 249, 248, 249, 251, 251, 250, 248, 249, + 250, 0, 0, 0, 0, 0, 251, 250, 251, 250, + 251, 250, 252, 252, 0, 251, 250, 0, 253, 0, + 0, 0, 252, 0, 252, 249, 252, 0, 253, 254, + 253, 252, 253, 0, 0, 253, 0, 253, 0, 254, + 255, 254, 254, 254, 0, 0, 0, 0, 254, 0, + 255, 0, 255, 0, 255, 257, 255, 256, 256, 255, + 0, 258, 0, 0, 0, 257, 0, 257, 256, 257, + 256, 258, 256, 258, 257, 258, 259, 256, 259, 260, + 258, 260, 261, 0, 0, 261, 259, 0, 259, 260, + + 259, 260, 261, 260, 261, 259, 261, 262, 260, 0, + 0, 261, 0, 263, 0, 0, 0, 262, 0, 262, + 263, 262, 0, 263, 264, 263, 262, 263, 0, 0, + 0, 0, 263, 0, 264, 265, 264, 0, 264, 0, + 264, 0, 0, 264, 0, 265, 0, 265, 0, 265, + 266, 265, 0, 266, 265, 0, 267, 0, 0, 0, + 266, 0, 266, 0, 266, 0, 267, 270, 267, 266, + 267, 0, 0, 271, 0, 267, 0, 270, 0, 270, + 0, 270, 0, 271, 0, 271, 270, 271, 272, 273, + 0, 271, 271, 0, 0, 272, 0, 0, 272, 273, + + 272, 273, 272, 273, 274, 273, 0, 272, 273, 275, + 275, 0, 270, 0, 274, 0, 274, 0, 274, 0, + 275, 276, 275, 274, 275, 277, 276, 0, 0, 275, + 0, 276, 0, 276, 277, 276, 0, 276, 0, 0, + 276, 0, 278, 0, 277, 0, 277, 0, 277, 0, + 279, 0, 278, 277, 278, 0, 278, 0, 0, 278, + 279, 278, 279, 0, 279, 281, 281, 0, 282, 279, + 0, 0, 0, 0, 0, 281, 0, 281, 282, 281, + 282, 283, 282, 0, 281, 0, 282, 282, 0, 285, + 286, 283, 285, 283, 283, 283, 0, 0, 0, 285, + + 283, 285, 0, 285, 287, 286, 0, 287, 285, 0, + 0, 0, 0, 0, 287, 286, 287, 286, 287, 286, + 288, 288, 290, 287, 286, 0, 0, 0, 0, 0, + 0, 288, 290, 288, 290, 288, 290, 291, 0, 0, + 288, 290, 0, 0, 0, 0, 0, 291, 0, 291, + 292, 291, 0, 292, 0, 291, 291, 0, 293, 0, + 292, 294, 292, 0, 292, 0, 0, 0, 293, 292, + 293, 294, 293, 294, 0, 294, 296, 293, 295, 295, + 294, 0, 297, 0, 0, 299, 296, 0, 296, 295, + 296, 295, 297, 295, 297, 296, 297, 298, 295, 0, + + 299, 297, 0, 301, 0, 0, 0, 298, 0, 298, + 299, 298, 299, 301, 299, 301, 298, 301, 302, 299, + 0, 296, 301, 0, 303, 0, 0, 303, 302, 0, + 302, 0, 302, 0, 303, 304, 303, 302, 303, 0, + 0, 305, 0, 303, 0, 304, 0, 304, 0, 304, + 0, 305, 0, 305, 304, 305, 309, 0, 305, 0, + 305, 0, 0, 0, 0, 0, 309, 0, 309, 0, + 309, 304, 0, 314, 0, 309, 310, 310, 310, 310, + 310, 310, 310, 314, 0, 314, 0, 314, 315, 315, + 0, 314, 314, 0, 0, 0, 0, 316, 316, 315, + + 0, 315, 0, 315, 317, 317, 0, 316, 315, 316, + 0, 316, 0, 318, 310, 317, 316, 317, 0, 317, + 320, 320, 0, 318, 317, 318, 0, 318, 0, 321, + 321, 320, 318, 320, 0, 320, 0, 0, 0, 321, + 320, 321, 322, 321, 0, 322, 0, 0, 321, 0, + 323, 0, 322, 324, 322, 0, 322, 0, 0, 0, + 323, 322, 323, 324, 323, 324, 0, 324, 326, 323, + 325, 325, 324, 0, 327, 326, 0, 0, 326, 0, + 326, 325, 326, 325, 327, 325, 327, 326, 327, 328, + 325, 0, 328, 327, 0, 329, 328, 329, 0, 328, + + 0, 328, 0, 328, 0, 329, 0, 329, 328, 329, + 330, 331, 0, 330, 329, 0, 0, 0, 0, 0, + 330, 331, 330, 331, 330, 331, 332, 331, 0, 330, + 331, 0, 0, 0, 0, 0, 332, 0, 332, 0, + 332, 333, 333, 0, 332, 332, 0, 334, 0, 0, + 0, 333, 0, 333, 0, 333, 0, 334, 335, 334, + 333, 334, 0, 0, 336, 334, 334, 0, 335, 0, + 335, 0, 335, 0, 336, 335, 336, 335, 336, 337, + 341, 0, 0, 336, 0, 0, 0, 341, 0, 337, + 341, 337, 341, 337, 341, 0, 0, 343, 337, 341, + + 342, 342, 0, 342, 0, 0, 0, 343, 0, 343, + 342, 343, 342, 0, 342, 343, 343, 345, 344, 342, + 344, 0, 0, 0, 0, 0, 0, 345, 344, 345, + 344, 345, 344, 0, 347, 346, 345, 344, 346, 0, + 0, 349, 0, 348, 347, 346, 347, 346, 347, 346, + 348, 347, 0, 347, 346, 0, 349, 0, 0, 0, + 348, 0, 348, 0, 348, 0, 349, 351, 349, 348, + 349, 0, 0, 0, 0, 349, 0, 351, 352, 351, + 0, 351, 0, 0, 353, 351, 351, 0, 352, 0, + 352, 0, 352, 0, 353, 355, 353, 352, 353, 0, + + 0, 0, 0, 353, 0, 355, 356, 355, 0, 355, + 0, 355, 357, 356, 355, 0, 356, 0, 356, 0, + 356, 0, 357, 358, 357, 356, 357, 0, 0, 0, + 0, 357, 0, 358, 0, 358, 360, 358, 0, 361, + 0, 358, 358, 360, 0, 0, 360, 362, 360, 361, + 360, 361, 362, 361, 0, 360, 0, 362, 361, 362, + 363, 362, 0, 0, 0, 0, 362, 0, 0, 0, + 363, 365, 363, 0, 363, 0, 0, 367, 365, 363, + 0, 365, 363, 365, 0, 365, 0, 367, 0, 367, + 365, 367, 368, 369, 0, 368, 367, 0, 0, 0, + + 0, 0, 368, 369, 368, 369, 368, 369, 371, 369, + 0, 368, 369, 0, 379, 0, 0, 0, 371, 0, + 371, 0, 371, 0, 379, 0, 379, 371, 379, 380, + 380, 381, 381, 379, 0, 0, 0, 0, 0, 380, + 382, 380, 381, 380, 381, 0, 381, 0, 380, 0, + 382, 381, 382, 371, 382, 384, 0, 0, 382, 382, + 0, 385, 0, 0, 0, 384, 0, 384, 0, 384, + 0, 385, 386, 385, 384, 385, 0, 0, 387, 385, + 385, 387, 386, 0, 386, 0, 386, 0, 387, 388, + 387, 386, 387, 0, 0, 389, 388, 387, 0, 388, + + 0, 388, 0, 388, 0, 389, 390, 389, 388, 389, + 0, 0, 0, 0, 389, 0, 390, 391, 390, 391, + 390, 0, 0, 392, 390, 390, 0, 391, 0, 391, + 0, 391, 0, 392, 0, 392, 391, 392, 0, 0, + 393, 392, 392, 393, 0, 0, 394, 0, 394, 0, + 393, 0, 393, 0, 393, 0, 394, 0, 394, 393, + 394, 395, 395, 396, 0, 394, 0, 0, 0, 0, + 0, 0, 395, 396, 395, 396, 395, 396, 397, 398, + 0, 395, 396, 0, 0, 397, 0, 0, 397, 398, + 397, 398, 397, 398, 399, 0, 398, 397, 398, 400, + + 400, 399, 0, 0, 399, 0, 399, 0, 399, 0, + 400, 404, 400, 399, 400, 404, 0, 405, 0, 400, + 0, 404, 0, 404, 405, 404, 0, 405, 0, 405, + 404, 405, 406, 407, 406, 0, 405, 0, 0, 0, + 0, 0, 406, 407, 406, 407, 406, 407, 0, 0, + 407, 406, 407, 408, 409, 409, 408, 0, 0, 0, + 0, 0, 0, 408, 409, 408, 409, 408, 409, 410, + 0, 0, 408, 409, 0, 0, 0, 411, 0, 410, + 411, 410, 0, 410, 0, 410, 0, 411, 410, 411, + 412, 411, 0, 0, 0, 0, 411, 0, 413, 0, + + 412, 415, 412, 0, 412, 413, 0, 412, 413, 412, + 413, 415, 413, 415, 0, 415, 418, 413, 416, 416, + 415, 0, 419, 0, 0, 0, 418, 0, 418, 416, + 418, 416, 419, 416, 419, 418, 419, 420, 416, 0, + 421, 419, 0, 421, 0, 0, 0, 420, 423, 420, + 421, 420, 421, 0, 421, 420, 420, 0, 423, 421, + 423, 0, 423, 424, 424, 0, 425, 423, 423, 426, + 0, 0, 0, 424, 0, 424, 425, 424, 425, 426, + 425, 426, 424, 426, 428, 425, 428, 430, 426, 0, + 431, 0, 0, 0, 428, 0, 428, 430, 428, 430, + + 431, 430, 431, 428, 431, 440, 430, 431, 441, 431, + 0, 0, 0, 0, 0, 440, 0, 440, 441, 440, + 441, 442, 441, 440, 440, 0, 441, 441, 442, 444, + 0, 442, 0, 442, 0, 442, 0, 0, 0, 444, + 442, 444, 445, 444, 0, 445, 0, 0, 444, 0, + 446, 0, 445, 447, 445, 0, 445, 0, 0, 0, + 446, 445, 446, 447, 446, 447, 448, 447, 0, 446, + 0, 0, 447, 448, 449, 0, 448, 450, 448, 0, + 448, 0, 0, 0, 449, 448, 449, 450, 449, 450, + 451, 450, 0, 449, 0, 0, 450, 451, 453, 0, + + 451, 452, 451, 452, 451, 0, 0, 0, 453, 451, + 453, 452, 453, 452, 454, 452, 0, 453, 0, 0, + 452, 0, 0, 0, 454, 455, 454, 0, 454, 0, + 0, 0, 454, 454, 0, 455, 456, 455, 0, 455, + 0, 0, 457, 455, 455, 0, 456, 0, 456, 0, + 456, 0, 457, 458, 457, 456, 457, 0, 0, 462, + 0, 457, 0, 458, 0, 458, 462, 458, 0, 462, + 463, 462, 458, 462, 0, 0, 0, 0, 462, 0, + 463, 464, 463, 0, 463, 0, 0, 465, 463, 463, + 0, 464, 0, 464, 0, 464, 0, 465, 466, 465, + + 464, 465, 0, 0, 467, 0, 465, 467, 466, 0, + 466, 0, 466, 0, 467, 466, 467, 466, 467, 468, + 469, 469, 0, 467, 0, 0, 0, 0, 0, 468, + 469, 468, 469, 468, 469, 470, 471, 0, 468, 469, + 0, 0, 0, 0, 0, 470, 471, 470, 471, 470, + 471, 473, 475, 0, 470, 471, 0, 0, 0, 0, + 0, 473, 475, 473, 475, 473, 475, 0, 0, 476, + 473, 475, 477, 476, 0, 478, 0, 0, 0, 476, + 470, 476, 477, 476, 477, 478, 477, 478, 476, 478, + 480, 477, 0, 480, 478, 0, 481, 0, 0, 481, + + 480, 0, 480, 0, 480, 0, 481, 0, 481, 480, + 481, 483, 0, 494, 483, 481, 485, 485, 0, 0, + 0, 483, 0, 483, 0, 483, 0, 485, 494, 485, + 483, 485, 0, 0, 495, 0, 485, 0, 494, 0, + 494, 495, 494, 0, 495, 0, 495, 494, 495, 496, + 496, 0, 0, 495, 0, 498, 0, 0, 0, 496, + 0, 496, 0, 496, 0, 498, 499, 498, 496, 498, + 0, 498, 0, 0, 498, 0, 499, 0, 499, 500, + 499, 0, 500, 0, 499, 499, 0, 501, 0, 500, + 502, 500, 0, 500, 0, 0, 0, 501, 500, 501, + + 502, 501, 502, 502, 502, 503, 501, 0, 504, 502, + 0, 504, 0, 0, 0, 503, 505, 503, 504, 503, + 504, 0, 504, 0, 503, 0, 505, 504, 505, 506, + 505, 0, 507, 0, 0, 505, 506, 0, 0, 506, + 0, 506, 507, 506, 507, 0, 507, 512, 506, 0, + 512, 507, 0, 513, 0, 0, 0, 512, 0, 512, + 0, 512, 0, 513, 514, 513, 512, 513, 0, 0, + 515, 0, 513, 0, 514, 0, 514, 0, 514, 0, + 515, 516, 515, 514, 515, 0, 0, 0, 0, 515, + 0, 516, 518, 516, 0, 516, 518, 0, 520, 516, + + 516, 0, 518, 0, 518, 524, 518, 0, 520, 522, + 520, 518, 520, 0, 0, 0, 522, 520, 0, 522, + 524, 522, 0, 522, 0, 0, 525, 0, 522, 0, + 524, 0, 524, 0, 524, 0, 525, 527, 525, 524, + 525, 0, 0, 529, 0, 525, 0, 527, 0, 527, + 0, 527, 0, 529, 537, 529, 527, 529, 0, 0, + 0, 0, 529, 0, 537, 538, 537, 0, 537, 0, + 0, 537, 0, 537, 0, 538, 539, 538, 538, 538, + 0, 0, 541, 0, 538, 0, 539, 0, 539, 0, + 539, 0, 541, 542, 541, 539, 541, 0, 0, 0, + + 0, 541, 0, 542, 543, 542, 543, 542, 0, 0, + 542, 0, 542, 0, 543, 544, 543, 0, 543, 0, + 544, 545, 0, 543, 0, 544, 0, 544, 0, 544, + 0, 545, 0, 545, 544, 545, 546, 547, 546, 0, + 545, 0, 0, 0, 0, 0, 546, 547, 546, 547, + 546, 547, 552, 553, 0, 546, 547, 0, 0, 0, + 553, 0, 552, 553, 552, 553, 552, 553, 552, 555, + 558, 552, 553, 0, 0, 0, 555, 0, 0, 555, + 558, 555, 558, 555, 558, 560, 0, 0, 555, 558, + 0, 562, 0, 0, 0, 560, 0, 560, 560, 560, + + 0, 562, 564, 562, 560, 562, 0, 0, 0, 562, + 562, 0, 564, 0, 564, 0, 564, 570, 570, 570, + 0, 564, 0, 0, 0, 0, 572, 573, 0, 570, + 570, 570, 570, 570, 570, 570, 572, 573, 572, 573, + 572, 573, 574, 575, 0, 572, 573, 0, 0, 572, + 0, 0, 574, 575, 574, 575, 574, 575, 576, 577, + 0, 574, 575, 0, 0, 0, 0, 0, 576, 577, + 576, 577, 576, 577, 578, 579, 577, 576, 577, 0, + 0, 0, 579, 0, 578, 579, 578, 579, 578, 579, + 583, 0, 0, 578, 579, 0, 0, 0, 584, 0, + + 583, 0, 583, 0, 583, 0, 586, 0, 584, 583, + 584, 584, 584, 0, 589, 0, 586, 584, 586, 0, + 586, 589, 591, 0, 589, 586, 589, 0, 589, 591, + 592, 0, 591, 589, 591, 0, 591, 592, 0, 0, + 592, 591, 592, 0, 592, 0, 0, 601, 602, 592, + 599, 599, 599, 599, 599, 599, 599, 601, 602, 601, + 602, 601, 602, 603, 0, 0, 601, 602, 0, 0, + 0, 604, 0, 603, 0, 603, 0, 603, 0, 0, + 0, 604, 603, 604, 608, 604, 0, 0, 599, 604, + 604, 0, 610, 0, 608, 613, 608, 0, 608, 610, + + 0, 0, 610, 608, 610, 613, 610, 613, 615, 613, + 615, 610, 0, 613, 613, 0, 0, 0, 615, 616, + 615, 0, 615, 616, 0, 0, 0, 615, 0, 616, + 0, 616, 0, 616, 623, 623, 623, 0, 616, 0, + 0, 0, 0, 624, 625, 0, 623, 623, 623, 623, + 623, 623, 623, 624, 625, 624, 625, 624, 625, 629, + 0, 624, 624, 625, 0, 631, 0, 625, 0, 629, + 0, 629, 0, 629, 0, 631, 634, 631, 629, 631, + 0, 0, 636, 631, 631, 0, 634, 0, 634, 0, + 634, 0, 636, 637, 636, 634, 636, 0, 0, 634, + + 637, 636, 0, 637, 0, 637, 644, 637, 643, 643, + 0, 0, 637, 0, 0, 0, 644, 648, 644, 643, + 644, 643, 0, 643, 0, 644, 0, 648, 643, 648, + 0, 648, 651, 0, 0, 653, 648, 0, 653, 0, + 648, 0, 651, 0, 651, 653, 651, 653, 0, 653, + 0, 651, 0, 0, 653, 658, 658, 658, 0, 0, + 0, 0, 0, 0, 659, 661, 0, 658, 658, 658, + 658, 658, 658, 658, 659, 661, 659, 661, 659, 661, + 664, 667, 0, 659, 661, 0, 659, 0, 0, 0, + 664, 667, 664, 667, 664, 667, 664, 671, 0, 664, + + 667, 0, 0, 0, 0, 0, 0, 671, 0, 671, + 0, 671, 0, 0, 0, 0, 671, 675, 675, 675, + 675, 675, 675, 675, 675, 675, 675, 675, 675, 676, + 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, + 676, 677, 677, 677, 677, 677, 677, 677, 677, 677, + 677, 677, 677, 678, 678, 678, 678, 678, 678, 678, + 678, 678, 678, 678, 678, 679, 679, 679, 679, 679, + 679, 679, 679, 679, 679, 679, 679, 680, 680, 680, + 0, 680, 680, 680, 680, 680, 680, 680, 680, 681, + 681, 0, 0, 681, 0, 681, 682, 0, 682, 683, + + 683, 0, 683, 683, 684, 684, 0, 684, 684, 684, + 0, 684, 684, 684, 684, 684, 685, 685, 685, 0, + 685, 685, 685, 685, 685, 685, 685, 685, 686, 686, + 686, 686, 686, 686, 686, 686, 0, 686, 686, 687, + 0, 0, 687, 0, 687, 687, 687, 687, 687, 687, + 688, 688, 0, 688, 688, 689, 689, 0, 689, 689, + 690, 690, 0, 690, 690, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674, 674, 674, 674, 674, 674, 674, + 674, 674, 674, 674 + } ; + +extern int yy_flex_debug; +int yy_flex_debug = 1; + +static yyconst short int yy_rule_linenum[123] = + { 0, + 101, 104, 106, 107, 108, 111, 113, 114, 115, 127, + 134, 141, 147, 156, 164, 172, 173, 175, 194, 200, + 207, 214, 221, 231, 265, 272, 273, 274, 275, 283, + 284, 285, 286, 287, 292, 293, 294, 295, 296, 297, + 298, 299, 300, 301, 302, 311, 312, 313, 314, 315, + 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, + 326, 327, 328, 329, 330, 331, 332, 333, 334, 335, + 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, + 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, + 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, + + 366, 367, 372, 373, 378, 379, 380, 383, 389, 396, + 405, 416, 422, 424, 425, 427, 429, 431, 444, 450, + 456, 464 + } ; + +static yy_state_type yy_state_buf[YY_BUF_SIZE + 2], *yy_state_ptr; +static char *yy_full_match; +static int yy_lp; +#define REJECT \ +{ \ +*yy_cp = yy_hold_char; /* undo effects of setting up yytext */ \ +yy_cp = yy_full_match; /* restore poss. backed-over text */ \ +++yy_lp; \ +goto find_rule; \ +} +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *yytext; +#line 1 "asn1p_l.l" +#define INITIAL 0 +#line 2 "asn1p_l.l" + +#include +#include +#include + +#include "asn1parser.h" +#include "asn1p_y.h" + +int asn1p_lex(void); +void asn1p_lexer_hack_push_opaque_state(void); /* Used in .y */ +void asn1p_lexer_hack_enable_with_syntax(void); /* Used in .y */ + +#define YY_FATAL_ERROR(msg) do { \ + fprintf(stderr, \ + "lexer error at line %d, " \ + "text \"%s\"\n", \ + yylineno, yytext); \ + exit(1); \ + } while(0) + +int asn1p_lexer_pedantic_1990 = 0; +int asn1p_lexer_types_year = 0; +int asn1p_lexer_constructs_year = 0; +static int _check_dashes(char *ptr); +static asn1_integer_t asn1p_atoi(char *ptr); /* errno is either 0 or ERANGE */ + +/* + * Check that the type is defined in the year of the standard choosen. + */ +#define TYPE_LIFETIME(fyr, lyr) \ + (!asn1p_lexer_types_year \ + || (fyr && fyr <= asn1p_lexer_types_year) \ + || (lyr && lyr > asn1p_lexer_types_year)) + +/* + * Check the the construction (or concept, i.e. CLASS) is defined in + * a given year. + */ +#define CONSTRUCT_LIFETIME(fyr, lyr) \ + (!asn1p_lexer_constructs_year \ + || (fyr && fyr <= asn1p_lexer_constructs_year) \ + || (lyr && lyr > asn1p_lexer_constructs_year)) + +/* + * Make sure that the label is compliant with the naming rules. + */ +#define CHECK_DASHES do { \ + if(_check_dashes(yytext)) { \ + fprintf(stderr, \ + "%s: Identifier format invalid: " \ + "Improper dash location\n", yytext); \ + return -1; \ + } } while(0) + +/* + * Append quoted string. + */ +#define QAPPEND(text, tlen) do { \ + char *prev_text = asn1p_lval.tv_opaque.buf; \ + int prev_len = asn1p_lval.tv_opaque.len; \ + char *p; \ + \ + p = malloc((tlen) + prev_len + 1); \ + if(p == NULL) return -1; \ + \ + if(prev_text) memcpy(p, prev_text, prev_len); \ + memcpy(p + prev_len, text, tlen); \ + p[prev_len + (tlen)] = '\0'; \ + \ + free(asn1p_lval.tv_opaque.buf); \ + asn1p_lval.tv_opaque.buf = p; \ + asn1p_lval.tv_opaque.len = (tlen) + prev_len; \ + } while(0) + +#define YY_NEVER_INTERACTIVE 1 +#define YY_NO_INPUT 1 +#define YY_NO_UNPUT 1 +#define YY_STACK_USED 1 +/* Performance penalty is OK */ +/* Controlled from within application */ +#define dash_comment 1 + +#define cpp_comment 2 + +#define quoted 3 + +#define opaque 4 + +#define with_syntax 5 + +/* Newline */ +/* White-space */ +#line 1806 "lex.yy.c" + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int yywrap YY_PROTO(( void )); +#else +extern int yywrap YY_PROTO(( void )); +#endif +#endif + +#ifndef YY_NO_UNPUT +static void yyunput YY_PROTO(( int c, char *buf_ptr )); +#endif + +#ifndef yytext_ptr +static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int )); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen YY_PROTO(( yyconst char * )); +#endif + +#ifndef YY_NO_INPUT +#ifdef __cplusplus +static int yyinput YY_PROTO(( void )); +#else +static int input YY_PROTO(( void )); +#endif +#endif + +#if YY_STACK_USED +static int yy_start_stack_ptr = 0; +static int yy_start_stack_depth = 0; +static int *yy_start_stack = 0; +#ifndef YY_NO_PUSH_STATE +static void yy_push_state YY_PROTO(( int new_state )); +#endif +#ifndef YY_NO_POP_STATE +static void yy_pop_state YY_PROTO(( void )); +#endif +#ifndef YY_NO_TOP_STATE +static int yy_top_state YY_PROTO(( void )); +#endif + +#else +#define YY_NO_PUSH_STATE 1 +#define YY_NO_POP_STATE 1 +#define YY_NO_TOP_STATE 1 +#endif + +#ifdef YY_MALLOC_DECL +YY_MALLOC_DECL +#else +#if __STDC__ +#ifndef __cplusplus +#include +#endif +#else +/* Just try to get by without declaring the routines. This will fail + * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int) + * or sizeof(void*) != sizeof(int). + */ +#endif +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ + +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO (void) fwrite( yytext, yyleng, 1, yyout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( yy_current_buffer->yy_is_interactive ) \ + { \ + int c = '*', n; \ + for ( n = 0; n < max_size && \ + (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \ + && ferror( yyin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL int yylex YY_PROTO(( void )) +#endif + +/* Code executed at the beginning of each rule, after yytext and yyleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +YY_DECL + { + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + +#line 99 "asn1p_l.l" + + +#line 1960 "lex.yy.c" + + if ( yy_init ) + { + yy_init = 0; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! yy_start ) + yy_start = 1; /* first start state */ + + if ( ! yyin ) + yyin = stdin; + + if ( ! yyout ) + yyout = stdout; + + if ( ! yy_current_buffer ) + yy_current_buffer = + yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_load_buffer_state(); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = yy_c_buf_p; + + /* Support of yytext. */ + *yy_cp = yy_hold_char; + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = yy_start; + yy_state_ptr = yy_state_buf; + *yy_state_ptr++ = yy_current_state; +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 675 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *yy_state_ptr++ = yy_current_state; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 4166 ); + +yy_find_action: + yy_current_state = *--yy_state_ptr; + yy_lp = yy_accept[yy_current_state]; +find_rule: /* we branch to this label when backing up */ + for ( ; ; ) /* until we find what rule we matched */ + { + if ( yy_lp && yy_lp < yy_accept[yy_current_state + 1] ) + { + yy_act = yy_acclist[yy_lp]; + { + yy_full_match = yy_cp; + break; + } + } + --yy_cp; + yy_current_state = *--yy_state_ptr; + yy_lp = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + + if ( yy_act != YY_END_OF_BUFFER ) + { + int yyl; + for ( yyl = 0; yyl < yyleng; ++yyl ) + if ( yytext[yyl] == '\n' ) + ++yylineno; + } + +do_action: /* This label is used only to access EOF actions. */ + + if ( yy_flex_debug ) + { + if ( yy_act == 0 ) + fprintf( stderr, "--scanner backing up\n" ); + else if ( yy_act < 123 ) + fprintf( stderr, "--accepting rule at line %d (\"%s\")\n", + yy_rule_linenum[yy_act], yytext ); + else if ( yy_act == 123 ) + fprintf( stderr, "--accepting default rule (\"%s\")\n", + yytext ); + else if ( yy_act == 124 ) + fprintf( stderr, "--(end of buffer or a NUL)\n" ); + else + fprintf( stderr, "--EOF (start condition %d)\n", YY_START ); + } + + switch ( yy_act ) + { /* beginning of action switch */ +case 1: +YY_RULE_SETUP +#line 101 "asn1p_l.l" +yy_push_state(dash_comment); + YY_BREAK + +case 2: +YY_RULE_SETUP +#line 104 "asn1p_l.l" +yy_pop_state(); + YY_BREAK +case 3: +YY_RULE_SETUP +#line 106 "asn1p_l.l" +yy_pop_state(); /* End of comment */ + YY_BREAK +case 4: +YY_RULE_SETUP +#line 107 "asn1p_l.l" +/* Eat single dash */ + YY_BREAK +case 5: +YY_RULE_SETUP +#line 108 "asn1p_l.l" +/* Eat */ + YY_BREAK + +case 6: +YY_RULE_SETUP +#line 111 "asn1p_l.l" +yy_push_state(cpp_comment); + YY_BREAK + +case 7: +YY_RULE_SETUP +#line 113 "asn1p_l.l" +/* Eat */ + YY_BREAK +case 8: +YY_RULE_SETUP +#line 114 "asn1p_l.l" +yy_pop_state(); + YY_BREAK +case 9: +YY_RULE_SETUP +#line 115 "asn1p_l.l" +/* Eat */ + YY_BREAK + +/* + * This is state is being set from corresponding .y module when + * higher-level data is necessary to make proper parsing of the + * underlying data. Thus, we enter the state and save + * everything for later processing. + */ + +case 10: +YY_RULE_SETUP +#line 127 "asn1p_l.l" +{ + yy_push_state(opaque); + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + YY_BREAK +case 11: +YY_RULE_SETUP +#line 134 "asn1p_l.l" +{ + yy_pop_state(); + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + YY_BREAK +case 12: +YY_RULE_SETUP +#line 141 "asn1p_l.l" +{ + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + YY_BREAK +case 13: +YY_RULE_SETUP +#line 147 "asn1p_l.l" +{ + fprintf(stderr, + "ASN.1 Parser syncronization failure: " + "\"%s\" at line %d must not appear " + "inside value definition\n", + yytext, yylineno); + return -1; + } + YY_BREAK +case 14: +YY_RULE_SETUP +#line 156 "asn1p_l.l" +{ + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + YY_BREAK + +case 15: +YY_RULE_SETUP +#line 164 "asn1p_l.l" +{ + asn1p_lval.tv_opaque.buf = 0; + asn1p_lval.tv_opaque.len = 0; + QAPPEND(yytext+1, yyleng-1); + yy_push_state(quoted); + } + YY_BREAK + +case 16: +YY_RULE_SETUP +#line 172 "asn1p_l.l" +{ QAPPEND(yytext, yyleng-1); } /* Add a single quote */ + YY_BREAK +case 17: +YY_RULE_SETUP +#line 173 "asn1p_l.l" +{ QAPPEND(yytext, yyleng); } + YY_BREAK +case 18: +YY_RULE_SETUP +#line 175 "asn1p_l.l" +{ + yy_pop_state(); + /* Do not append last quote: + // QAPPEND(yytext, yyleng); */ + + if(asn1p_lexer_pedantic_1990 + && strchr(yytext, '\n')) { + fprintf(stderr, "%s: " + "Newlines are prohibited by ASN.1:1990\n", + asn1p_lval.tv_opaque.buf); + return -1; + } + + return TOK_cstring; + } + YY_BREAK + +case 19: +YY_RULE_SETUP +#line 194 "asn1p_l.l" +{ + /* " \t\r\n" weren't allowed in ASN.1:1990. */ + asn1p_lval.tv_str = yytext; + return TOK_hstring; + } + YY_BREAK +case 20: +YY_RULE_SETUP +#line 200 "asn1p_l.l" +{ + /* " \t\r\n" weren't allowed in ASN.1:1990. */ + asn1p_lval.tv_str = strdup(yytext); + return TOK_bstring; + } + YY_BREAK +case 21: +YY_RULE_SETUP +#line 207 "asn1p_l.l" +{ + asn1p_lval.a_int = asn1p_atoi(yytext); + if(errno == ERANGE) + return -1; + return TOK_number_negative; + } + YY_BREAK +case 22: +YY_RULE_SETUP +#line 214 "asn1p_l.l" +{ + asn1p_lval.a_int = asn1p_atoi(yytext); + if(errno == ERANGE) + return -1; + return TOK_number; + } + YY_BREAK +case 23: +YY_RULE_SETUP +#line 221 "asn1p_l.l" +{ + asn1p_lval.a_int = asn1p_atoi(yytext); + if(errno == ERANGE) + return -1; + return TOK_number; + } + YY_BREAK +/* + * Tags + */ +case 24: +YY_RULE_SETUP +#line 231 "asn1p_l.l" +{ + char *p; + memset(&asn1p_lval.a_tag, 0, sizeof(asn1p_lval.a_tag)); + switch(yytext[1]) { + case 'U': + asn1p_lval.a_tag.tag_class = TC_UNIVERSAL; + p = yytext + sizeof("UNIVERSAL") + 1; + break; + case 'A': + asn1p_lval.a_tag.tag_class = TC_APPLICATION; + p = yytext + sizeof("APPLICATION") + 1; + break; + case 'P': + asn1p_lval.a_tag.tag_class = TC_PRIVATE; + p = yytext + sizeof("PRIVATE") + 1; + break; + default: + assert(yytext[1] >= '0' && yytext[1] <= '9'); + asn1p_lval.a_tag.tag_class = TC_CONTEXT_SPECIFIC; + p = yytext + 1; + break; + } + asn1p_lval.a_tag.tag_value = asn1p_atoi(p); + if(*p == '0' && asn1p_lval.a_tag.tag_value) { + fprintf(stderr, + "Tag value at line %d " + "cannot start with zero " + "and have multiple digits: \"%s\"\n", + yylineno, yytext); + return -1; + } + return TOK_tag; + } + YY_BREAK +case 25: +YY_RULE_SETUP +#line 265 "asn1p_l.l" +{ + fprintf(stderr, + "Unsupported tag syntax at line %d: \"%s\"\n", + yylineno, yytext); + return -1; + } + YY_BREAK +case 26: +YY_RULE_SETUP +#line 272 "asn1p_l.l" +return TOK_ABSENT; + YY_BREAK +case 27: +YY_RULE_SETUP +#line 273 "asn1p_l.l" +return TOK_ABSTRACT_SYNTAX; + YY_BREAK +case 28: +YY_RULE_SETUP +#line 274 "asn1p_l.l" +return TOK_ALL; + YY_BREAK +case 29: +YY_RULE_SETUP +#line 275 "asn1p_l.l" +{ + /* Appeared in 1990, removed in 1997 */ + if(TYPE_LIFETIME(1990, 1997)) + return TOK_ANY; + fprintf(stderr, "Keyword \"%s\" at line %d " + "is obsolete\n", yytext, yylineno); + REJECT; + } + YY_BREAK +case 30: +YY_RULE_SETUP +#line 283 "asn1p_l.l" +return TOK_APPLICATION; + YY_BREAK +case 31: +YY_RULE_SETUP +#line 284 "asn1p_l.l" +return TOK_AUTOMATIC; + YY_BREAK +case 32: +YY_RULE_SETUP +#line 285 "asn1p_l.l" +return TOK_BEGIN; + YY_BREAK +case 33: +YY_RULE_SETUP +#line 286 "asn1p_l.l" +return TOK_BIT; + YY_BREAK +case 34: +YY_RULE_SETUP +#line 287 "asn1p_l.l" +{ + if(TYPE_LIFETIME(1994, 0)) + return TOK_BMPString; + REJECT; + } + YY_BREAK +case 35: +YY_RULE_SETUP +#line 292 "asn1p_l.l" +return TOK_BOOLEAN; + YY_BREAK +case 36: +YY_RULE_SETUP +#line 293 "asn1p_l.l" +return TOK_BY; + YY_BREAK +case 37: +YY_RULE_SETUP +#line 294 "asn1p_l.l" +return TOK_CHARACTER; + YY_BREAK +case 38: +YY_RULE_SETUP +#line 295 "asn1p_l.l" +return TOK_CHOICE; + YY_BREAK +case 39: +YY_RULE_SETUP +#line 296 "asn1p_l.l" +return TOK_CLASS; + YY_BREAK +case 40: +YY_RULE_SETUP +#line 297 "asn1p_l.l" +return TOK_COMPONENT; + YY_BREAK +case 41: +YY_RULE_SETUP +#line 298 "asn1p_l.l" +return TOK_COMPONENTS; + YY_BREAK +case 42: +YY_RULE_SETUP +#line 299 "asn1p_l.l" +return TOK_CONSTRAINED; + YY_BREAK +case 43: +YY_RULE_SETUP +#line 300 "asn1p_l.l" +return TOK_CONTAINING; + YY_BREAK +case 44: +YY_RULE_SETUP +#line 301 "asn1p_l.l" +return TOK_DEFAULT; + YY_BREAK +case 45: +YY_RULE_SETUP +#line 302 "asn1p_l.l" +{ + /* Appeared in 1990, removed in 1997 */ + if(TYPE_LIFETIME(1990, 1997)) + return TOK_DEFINED; + fprintf(stderr, "Keyword \"%s\" at line %d " + "is obsolete\n", yytext, yylineno); + /* Deprecated since */ + REJECT; + } + YY_BREAK +case 46: +YY_RULE_SETUP +#line 311 "asn1p_l.l" +return TOK_DEFINITIONS; + YY_BREAK +case 47: +YY_RULE_SETUP +#line 312 "asn1p_l.l" +return TOK_EMBEDDED; + YY_BREAK +case 48: +YY_RULE_SETUP +#line 313 "asn1p_l.l" +return TOK_ENCODED; + YY_BREAK +case 49: +YY_RULE_SETUP +#line 314 "asn1p_l.l" +return TOK_END; + YY_BREAK +case 50: +YY_RULE_SETUP +#line 315 "asn1p_l.l" +return TOK_ENUMERATED; + YY_BREAK +case 51: +YY_RULE_SETUP +#line 316 "asn1p_l.l" +return TOK_EXCEPT; + YY_BREAK +case 52: +YY_RULE_SETUP +#line 317 "asn1p_l.l" +return TOK_EXPLICIT; + YY_BREAK +case 53: +YY_RULE_SETUP +#line 318 "asn1p_l.l" +return TOK_EXPORTS; + YY_BREAK +case 54: +YY_RULE_SETUP +#line 319 "asn1p_l.l" +return TOK_EXTENSIBILITY; + YY_BREAK +case 55: +YY_RULE_SETUP +#line 320 "asn1p_l.l" +return TOK_EXTERNAL; + YY_BREAK +case 56: +YY_RULE_SETUP +#line 321 "asn1p_l.l" +return TOK_FALSE; + YY_BREAK +case 57: +YY_RULE_SETUP +#line 322 "asn1p_l.l" +return TOK_FROM; + YY_BREAK +case 58: +YY_RULE_SETUP +#line 323 "asn1p_l.l" +return TOK_GeneralizedTime; + YY_BREAK +case 59: +YY_RULE_SETUP +#line 324 "asn1p_l.l" +return TOK_GeneralString; + YY_BREAK +case 60: +YY_RULE_SETUP +#line 325 "asn1p_l.l" +return TOK_GraphicString; + YY_BREAK +case 61: +YY_RULE_SETUP +#line 326 "asn1p_l.l" +return TOK_IA5String; + YY_BREAK +case 62: +YY_RULE_SETUP +#line 327 "asn1p_l.l" +return TOK_IDENTIFIER; + YY_BREAK +case 63: +YY_RULE_SETUP +#line 328 "asn1p_l.l" +return TOK_IMPLICIT; + YY_BREAK +case 64: +YY_RULE_SETUP +#line 329 "asn1p_l.l" +return TOK_IMPLIED; + YY_BREAK +case 65: +YY_RULE_SETUP +#line 330 "asn1p_l.l" +return TOK_IMPORTS; + YY_BREAK +case 66: +YY_RULE_SETUP +#line 331 "asn1p_l.l" +return TOK_INCLUDES; + YY_BREAK +case 67: +YY_RULE_SETUP +#line 332 "asn1p_l.l" +return TOK_INSTANCE; + YY_BREAK +case 68: +YY_RULE_SETUP +#line 333 "asn1p_l.l" +return TOK_INTEGER; + YY_BREAK +case 69: +YY_RULE_SETUP +#line 334 "asn1p_l.l" +return TOK_INTERSECTION; + YY_BREAK +case 70: +YY_RULE_SETUP +#line 335 "asn1p_l.l" +return TOK_ISO646String; + YY_BREAK +case 71: +YY_RULE_SETUP +#line 336 "asn1p_l.l" +return TOK_MAX; + YY_BREAK +case 72: +YY_RULE_SETUP +#line 337 "asn1p_l.l" +return TOK_MIN; + YY_BREAK +case 73: +YY_RULE_SETUP +#line 338 "asn1p_l.l" +return TOK_MINUS_INFINITY; + YY_BREAK +case 74: +YY_RULE_SETUP +#line 339 "asn1p_l.l" +return TOK_NULL; + YY_BREAK +case 75: +YY_RULE_SETUP +#line 340 "asn1p_l.l" +return TOK_NumericString; + YY_BREAK +case 76: +YY_RULE_SETUP +#line 341 "asn1p_l.l" +return TOK_OBJECT; + YY_BREAK +case 77: +YY_RULE_SETUP +#line 342 "asn1p_l.l" +return TOK_ObjectDescriptor; + YY_BREAK +case 78: +YY_RULE_SETUP +#line 343 "asn1p_l.l" +return TOK_OCTET; + YY_BREAK +case 79: +YY_RULE_SETUP +#line 344 "asn1p_l.l" +return TOK_OF; + YY_BREAK +case 80: +YY_RULE_SETUP +#line 345 "asn1p_l.l" +return TOK_OPTIONAL; + YY_BREAK +case 81: +YY_RULE_SETUP +#line 346 "asn1p_l.l" +return TOK_PATTERN; + YY_BREAK +case 82: +YY_RULE_SETUP +#line 347 "asn1p_l.l" +return TOK_PDV; + YY_BREAK +case 83: +YY_RULE_SETUP +#line 348 "asn1p_l.l" +return TOK_PLUS_INFINITY; + YY_BREAK +case 84: +YY_RULE_SETUP +#line 349 "asn1p_l.l" +return TOK_PRESENT; + YY_BREAK +case 85: +YY_RULE_SETUP +#line 350 "asn1p_l.l" +return TOK_PrintableString; + YY_BREAK +case 86: +YY_RULE_SETUP +#line 351 "asn1p_l.l" +return TOK_PRIVATE; + YY_BREAK +case 87: +YY_RULE_SETUP +#line 352 "asn1p_l.l" +return TOK_REAL; + YY_BREAK +case 88: +YY_RULE_SETUP +#line 353 "asn1p_l.l" +return TOK_RELATIVE_OID; + YY_BREAK +case 89: +YY_RULE_SETUP +#line 354 "asn1p_l.l" +return TOK_SEQUENCE; + YY_BREAK +case 90: +YY_RULE_SETUP +#line 355 "asn1p_l.l" +return TOK_SET; + YY_BREAK +case 91: +YY_RULE_SETUP +#line 356 "asn1p_l.l" +return TOK_SIZE; + YY_BREAK +case 92: +YY_RULE_SETUP +#line 357 "asn1p_l.l" +return TOK_STRING; + YY_BREAK +case 93: +YY_RULE_SETUP +#line 358 "asn1p_l.l" +return TOK_SYNTAX; + YY_BREAK +case 94: +YY_RULE_SETUP +#line 359 "asn1p_l.l" +return TOK_T61String; + YY_BREAK +case 95: +YY_RULE_SETUP +#line 360 "asn1p_l.l" +return TOK_TAGS; + YY_BREAK +case 96: +YY_RULE_SETUP +#line 361 "asn1p_l.l" +return TOK_TeletexString; + YY_BREAK +case 97: +YY_RULE_SETUP +#line 362 "asn1p_l.l" +return TOK_TRUE; + YY_BREAK +case 98: +YY_RULE_SETUP +#line 363 "asn1p_l.l" +return TOK_TYPE_IDENTIFIER; + YY_BREAK +case 99: +YY_RULE_SETUP +#line 364 "asn1p_l.l" +return TOK_UNION; + YY_BREAK +case 100: +YY_RULE_SETUP +#line 365 "asn1p_l.l" +return TOK_UNIQUE; + YY_BREAK +case 101: +YY_RULE_SETUP +#line 366 "asn1p_l.l" +return TOK_UNIVERSAL; + YY_BREAK +case 102: +YY_RULE_SETUP +#line 367 "asn1p_l.l" +{ + if(TYPE_LIFETIME(1994, 0)) + return TOK_UniversalString; + REJECT; + } + YY_BREAK +case 103: +YY_RULE_SETUP +#line 372 "asn1p_l.l" +return TOK_UTCTime; + YY_BREAK +case 104: +YY_RULE_SETUP +#line 373 "asn1p_l.l" +{ + if(TYPE_LIFETIME(1994, 0)) + return TOK_UTF8String; + REJECT; + } + YY_BREAK +case 105: +YY_RULE_SETUP +#line 378 "asn1p_l.l" +return TOK_VideotexString; + YY_BREAK +case 106: +YY_RULE_SETUP +#line 379 "asn1p_l.l" +return TOK_VisibleString; + YY_BREAK +case 107: +YY_RULE_SETUP +#line 380 "asn1p_l.l" +return TOK_WITH; + YY_BREAK +case 108: +YY_RULE_SETUP +#line 383 "asn1p_l.l" +{ + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_typefieldreference; + } + YY_BREAK +case 109: +YY_RULE_SETUP +#line 389 "asn1p_l.l" +{ + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_valuefieldreference; + } + YY_BREAK +case 110: +YY_RULE_SETUP +#line 396 "asn1p_l.l" +{ + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_identifier; + } + YY_BREAK +/* + * objectclassreference + */ +case 111: +YY_RULE_SETUP +#line 405 "asn1p_l.l" +{ + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_objectclassreference; + } + YY_BREAK +/* + * typereference, modulereference + * NOTE: TOK_objectclassreference must be combined + * with this token to produce true typereference. + */ +case 112: +YY_RULE_SETUP +#line 416 "asn1p_l.l" +{ + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_typereference; + } + YY_BREAK +case 113: +YY_RULE_SETUP +#line 422 "asn1p_l.l" +return TOK_PPEQ; + YY_BREAK +case 114: +YY_RULE_SETUP +#line 424 "asn1p_l.l" +return TOK_ThreeDots; + YY_BREAK +case 115: +YY_RULE_SETUP +#line 425 "asn1p_l.l" +return TOK_TwoDots; + YY_BREAK +case 116: +YY_RULE_SETUP +#line 427 "asn1p_l.l" +return yytext[0]; + YY_BREAK +case 117: +YY_RULE_SETUP +#line 429 "asn1p_l.l" +/* Ignore whitespace */ + YY_BREAK +case 118: +YY_RULE_SETUP +#line 431 "asn1p_l.l" +{ + if(TYPE_LIFETIME(1994, 0)) + fprintf(stderr, "ERROR: "); + fprintf(stderr, + "Symbol '%c' at line %d is prohibited " + "by ASN.1:1994 and ASN.1:1997\n", + yytext[0], yylineno); + if(TYPE_LIFETIME(1994, 0)) + return -1; + } + YY_BREAK + +case 119: +YY_RULE_SETUP +#line 444 "asn1p_l.l" +{ + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + YY_BREAK +case 120: +YY_RULE_SETUP +#line 450 "asn1p_l.l" +{ + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + YY_BREAK +case 121: +YY_RULE_SETUP +#line 456 "asn1p_l.l" +{ + yy_pop_state(); + return '}'; + } + YY_BREAK + +case 122: +YY_RULE_SETUP +#line 464 "asn1p_l.l" +{ + fprintf(stderr, + "Unexpected token at line %d: \"%s\"\n", + yylineno, yytext); + while(YYSTATE != INITIAL) + yy_pop_state(); + yy_top_state(); /* Just to use this function. */ + yyterminate(); + yy_fatal_error("Unexpected token"); + return -1; +} + YY_BREAK +case YY_STATE_EOF(INITIAL): +case YY_STATE_EOF(dash_comment): +case YY_STATE_EOF(cpp_comment): +case YY_STATE_EOF(quoted): +case YY_STATE_EOF(opaque): +case YY_STATE_EOF(with_syntax): +#line 476 "asn1p_l.l" +{ + while(YYSTATE != INITIAL) + yy_pop_state(); + yyterminate(); + } + YY_BREAK +case 123: +YY_RULE_SETUP +#line 483 "asn1p_l.l" +YY_FATAL_ERROR( "flex scanner jammed" ); + YY_BREAK +#line 2902 "lex.yy.c" + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = yy_hold_char; + YY_RESTORE_YY_MORE_OFFSET + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed yyin at a new source and called + * yylex(). If so, then we have to assure + * consistency between yy_current_buffer and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + yy_n_chars = yy_current_buffer->yy_n_chars; + yy_current_buffer->yy_input_file = yyin; + yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = yytext_ptr + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++yy_c_buf_p; + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = yy_c_buf_p; + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer() ) + { + case EOB_ACT_END_OF_FILE: + { + yy_did_buffer_switch_on_eof = 0; + + if ( yywrap() ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * yytext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + yy_c_buf_p = yytext_ptr + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = + yytext_ptr + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + yy_c_buf_p = + &yy_current_buffer->yy_ch_buf[yy_n_chars]; + + yy_current_state = yy_get_previous_state(); + + yy_cp = yy_c_buf_p; + yy_bp = yytext_ptr + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ + } /* end of yylex */ + + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ + +static int yy_get_next_buffer() + { + register char *dest = yy_current_buffer->yy_ch_buf; + register char *source = yytext_ptr; + register int number_to_move, i; + int ret_val; + + if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( yy_current_buffer->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + yy_current_buffer->yy_n_chars = yy_n_chars = 0; + + else + { + int num_to_read = + yy_current_buffer->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ +#ifdef YY_USES_REJECT + YY_FATAL_ERROR( +"input buffer overflow, can't enlarge buffer because scanner uses REJECT" ); +#else + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = yy_current_buffer; + + int yy_c_buf_p_offset = + (int) (yy_c_buf_p - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + yy_flex_realloc( (void *) b->yy_ch_buf, + b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = yy_current_buffer->yy_buf_size - + number_to_move - 1; +#endif + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]), + yy_n_chars, num_to_read ); + + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + if ( yy_n_chars == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + yyrestart( yyin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + yy_current_buffer->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + yy_n_chars += number_to_move; + yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR; + yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR; + + yytext_ptr = &yy_current_buffer->yy_ch_buf[0]; + + return ret_val; + } + + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + +static yy_state_type yy_get_previous_state() + { + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = yy_start; + yy_state_ptr = yy_state_buf; + *yy_state_ptr++ = yy_current_state; + + for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 675 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + *yy_state_ptr++ = yy_current_state; + } + + return yy_current_state; + } + + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + +#ifdef YY_USE_PROTOS +static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state ) +#else +static yy_state_type yy_try_NUL_trans( yy_current_state ) +yy_state_type yy_current_state; +#endif + { + register int yy_is_jam; + + register YY_CHAR yy_c = 1; + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 675 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 674); + if ( ! yy_is_jam ) + *yy_state_ptr++ = yy_current_state; + + return yy_is_jam ? 0 : yy_current_state; + } + + +#ifndef YY_NO_UNPUT +#ifdef YY_USE_PROTOS +static void yyunput( int c, register char *yy_bp ) +#else +static void yyunput( c, yy_bp ) +int c; +register char *yy_bp; +#endif + { + register char *yy_cp = yy_c_buf_p; + + /* undo effects of setting up yytext */ + *yy_cp = yy_hold_char; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = yy_n_chars + 2; + register char *dest = &yy_current_buffer->yy_ch_buf[ + yy_current_buffer->yy_buf_size + 2]; + register char *source = + &yy_current_buffer->yy_ch_buf[number_to_move]; + + while ( source > yy_current_buffer->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + yy_current_buffer->yy_n_chars = + yy_n_chars = yy_current_buffer->yy_buf_size; + + if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + if ( c == '\n' ) + --yylineno; + + yytext_ptr = yy_bp; + yy_hold_char = *yy_cp; + yy_c_buf_p = yy_cp; + } +#endif /* ifndef YY_NO_UNPUT */ + + +#ifdef __cplusplus +static int yyinput() +#else +static int input() +#endif + { + int c; + + *yy_c_buf_p = yy_hold_char; + + if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] ) + /* This was really a NUL. */ + *yy_c_buf_p = '\0'; + + else + { /* need more input */ + int offset = yy_c_buf_p - yytext_ptr; + ++yy_c_buf_p; + + switch ( yy_get_next_buffer() ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + yyrestart( yyin ); + + /* fall through */ + + case EOB_ACT_END_OF_FILE: + { + if ( yywrap() ) + return EOF; + + if ( ! yy_did_buffer_switch_on_eof ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + yy_c_buf_p = yytext_ptr + offset; + break; + } + } + } + + c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */ + *yy_c_buf_p = '\0'; /* preserve yytext */ + yy_hold_char = *++yy_c_buf_p; + + if ( c == '\n' ) + ++yylineno; + + return c; + } + + +#ifdef YY_USE_PROTOS +void yyrestart( FILE *input_file ) +#else +void yyrestart( input_file ) +FILE *input_file; +#endif + { + if ( ! yy_current_buffer ) + yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); + + yy_init_buffer( yy_current_buffer, input_file ); + yy_load_buffer_state(); + } + + +#ifdef YY_USE_PROTOS +void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer ) +#else +void yy_switch_to_buffer( new_buffer ) +YY_BUFFER_STATE new_buffer; +#endif + { + if ( yy_current_buffer == new_buffer ) + return; + + if ( yy_current_buffer ) + { + /* Flush out information for old buffer. */ + *yy_c_buf_p = yy_hold_char; + yy_current_buffer->yy_buf_pos = yy_c_buf_p; + yy_current_buffer->yy_n_chars = yy_n_chars; + } + + yy_current_buffer = new_buffer; + yy_load_buffer_state(); + + /* We don't actually know whether we did this switch during + * EOF (yywrap()) processing, but the only time this flag + * is looked at is after yywrap() is called, so it's safe + * to go ahead and always set it. + */ + yy_did_buffer_switch_on_eof = 1; + } + + +#ifdef YY_USE_PROTOS +void yy_load_buffer_state( void ) +#else +void yy_load_buffer_state() +#endif + { + yy_n_chars = yy_current_buffer->yy_n_chars; + yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos; + yyin = yy_current_buffer->yy_input_file; + yy_hold_char = *yy_c_buf_p; + } + + +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_create_buffer( FILE *file, int size ) +#else +YY_BUFFER_STATE yy_create_buffer( file, size ) +FILE *file; +int size; +#endif + { + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + yy_init_buffer( b, file ); + + return b; + } + + +#ifdef YY_USE_PROTOS +void yy_delete_buffer( YY_BUFFER_STATE b ) +#else +void yy_delete_buffer( b ) +YY_BUFFER_STATE b; +#endif + { + if ( ! b ) + return; + + if ( b == yy_current_buffer ) + yy_current_buffer = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + yy_flex_free( (void *) b->yy_ch_buf ); + + yy_flex_free( (void *) b ); + } + + +#ifndef YY_ALWAYS_INTERACTIVE +#ifndef YY_NEVER_INTERACTIVE +extern int isatty YY_PROTO(( int )); +#endif +#endif + +#ifdef YY_USE_PROTOS +void yy_init_buffer( YY_BUFFER_STATE b, FILE *file ) +#else +void yy_init_buffer( b, file ) +YY_BUFFER_STATE b; +FILE *file; +#endif + + + { + yy_flush_buffer( b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + +#if YY_ALWAYS_INTERACTIVE + b->yy_is_interactive = 1; +#else +#if YY_NEVER_INTERACTIVE + b->yy_is_interactive = 0; +#else + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; +#endif +#endif + } + + +#ifdef YY_USE_PROTOS +void yy_flush_buffer( YY_BUFFER_STATE b ) +#else +void yy_flush_buffer( b ) +YY_BUFFER_STATE b; +#endif + + { + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == yy_current_buffer ) + yy_load_buffer_state(); + } + + +#ifndef YY_NO_SCAN_BUFFER +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size ) +#else +YY_BUFFER_STATE yy_scan_buffer( base, size ) +char *base; +yy_size_t size; +#endif + { + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + yy_switch_to_buffer( b ); + + return b; + } +#endif + + +#ifndef YY_NO_SCAN_STRING +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str ) +#else +YY_BUFFER_STATE yy_scan_string( yy_str ) +yyconst char *yy_str; +#endif + { + int len; + for ( len = 0; yy_str[len]; ++len ) + ; + + return yy_scan_bytes( yy_str, len ); + } +#endif + + +#ifndef YY_NO_SCAN_BYTES +#ifdef YY_USE_PROTOS +YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len ) +#else +YY_BUFFER_STATE yy_scan_bytes( bytes, len ) +yyconst char *bytes; +int len; +#endif + { + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = len + 2; + buf = (char *) yy_flex_alloc( n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" ); + + for ( i = 0; i < len; ++i ) + buf[i] = bytes[i]; + + buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR; + + b = yy_scan_buffer( buf, n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; + } +#endif + + +#ifndef YY_NO_PUSH_STATE +#ifdef YY_USE_PROTOS +static void yy_push_state( int new_state ) +#else +static void yy_push_state( new_state ) +int new_state; +#endif + { + if ( yy_start_stack_ptr >= yy_start_stack_depth ) + { + yy_size_t new_size; + + yy_start_stack_depth += YY_START_STACK_INCR; + new_size = yy_start_stack_depth * sizeof( int ); + + if ( ! yy_start_stack ) + yy_start_stack = (int *) yy_flex_alloc( new_size ); + + else + yy_start_stack = (int *) yy_flex_realloc( + (void *) yy_start_stack, new_size ); + + if ( ! yy_start_stack ) + YY_FATAL_ERROR( + "out of memory expanding start-condition stack" ); + } + + yy_start_stack[yy_start_stack_ptr++] = YY_START; + + BEGIN(new_state); + } +#endif + + +#ifndef YY_NO_POP_STATE +static void yy_pop_state() + { + if ( --yy_start_stack_ptr < 0 ) + YY_FATAL_ERROR( "start-condition stack underflow" ); + + BEGIN(yy_start_stack[yy_start_stack_ptr]); + } +#endif + + +#ifndef YY_NO_TOP_STATE +static int yy_top_state() + { + return yy_start_stack[yy_start_stack_ptr - 1]; + } +#endif + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +#ifdef YY_USE_PROTOS +static void yy_fatal_error( yyconst char msg[] ) +#else +static void yy_fatal_error( msg ) +char msg[]; +#endif + { + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); + } + + + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up yytext. */ \ + yytext[yyleng] = yy_hold_char; \ + yy_c_buf_p = yytext + n; \ + yy_hold_char = *yy_c_buf_p; \ + *yy_c_buf_p = '\0'; \ + yyleng = n; \ + } \ + while ( 0 ) + + +/* Internal utility routines. */ + +#ifndef yytext_ptr +#ifdef YY_USE_PROTOS +static void yy_flex_strncpy( char *s1, yyconst char *s2, int n ) +#else +static void yy_flex_strncpy( s1, s2, n ) +char *s1; +yyconst char *s2; +int n; +#endif + { + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; + } +#endif + +#ifdef YY_NEED_STRLEN +#ifdef YY_USE_PROTOS +static int yy_flex_strlen( yyconst char *s ) +#else +static int yy_flex_strlen( s ) +yyconst char *s; +#endif + { + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; + } +#endif + + +#ifdef YY_USE_PROTOS +static void *yy_flex_alloc( yy_size_t size ) +#else +static void *yy_flex_alloc( size ) +yy_size_t size; +#endif + { + return (void *) malloc( size ); + } + +#ifdef YY_USE_PROTOS +static void *yy_flex_realloc( void *ptr, yy_size_t size ) +#else +static void *yy_flex_realloc( ptr, size ) +void *ptr; +yy_size_t size; +#endif + { + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); + } + +#ifdef YY_USE_PROTOS +static void yy_flex_free( void *ptr ) +#else +static void yy_flex_free( ptr ) +void *ptr; +#endif + { + free( ptr ); + } + +#if YY_MAIN +int main() + { + yylex(); + return 0; + } +#endif +#line 483 "asn1p_l.l" + + +/* + * Very dirty but wonderful hack allowing to rule states from within .y file. + */ +void +asn1p_lexer_hack_push_opaque_state() { + yy_push_state(opaque); +} + +/* + * Another hack which disables recognizing some tokens when inside WITH SYNTAX. + */ +void +asn1p_lexer_hack_enable_with_syntax() { + yy_push_state(with_syntax); +} + +/* + * Check that a token does not end with dash and does not contain + * several dashes in succession. + * "Name", "Type-Id", "T-y-p-e-i-d" are OK + * "end-", "vustom--value" are INVALID + */ +static int +_check_dashes(char *ptr) { + int prev_dash = 0; + + assert(*ptr != '-'); + + for(;; ptr++) { + switch(*ptr) { + case '-': + if(prev_dash++) /* No double dashes */ + return -1; + continue; + case '\0': + if(prev_dash) /* No dashes at the end */ + return -1; + break; + default: + prev_dash = 0; + continue; + } + break; + } + + return 0; +} + +static asn1_integer_t +asn1p_atoi(char *ptr) { + asn1_integer_t value; + errno = 0; /* Clear the error code */ + + if(sizeof(value) <= sizeof(int)) { + value = strtol(ptr, 0, 10); + } else { +#ifdef HAVE_STRTOIMAX + value = strtoimax(ptr, 0, 10); +#elif HAVE_STRTOLL + value = strtoll(ptr, 0, 10); +#else + value = strtol(ptr, 0, 10); +#endif + } + + if(errno == ERANGE) { + fprintf(stderr, + "Value \"%s\" at line %d is too large " + "for this compiler! Please contact the vendor.", + ptr, yylineno); + errno = ERANGE; /* Restore potentially clobbered errno */ + } + + return value; +} + diff --git a/libasn1parser/asn1p_l.l b/libasn1parser/asn1p_l.l new file mode 100644 index 00000000..0d86cb74 --- /dev/null +++ b/libasn1parser/asn1p_l.l @@ -0,0 +1,560 @@ +%{ + +#include +#include +#include + +#include "asn1parser.h" +#include "asn1p_y.h" + +int asn1p_lex(void); +void asn1p_lexer_hack_push_opaque_state(void); /* Used in .y */ +void asn1p_lexer_hack_enable_with_syntax(void); /* Used in .y */ + +#define YY_FATAL_ERROR(msg) do { \ + fprintf(stderr, \ + "lexer error at line %d, " \ + "text \"%s\"\n", \ + yylineno, yytext); \ + exit(1); \ + } while(0) + +int asn1p_lexer_pedantic_1990 = 0; +int asn1p_lexer_types_year = 0; +int asn1p_lexer_constructs_year = 0; +static int _check_dashes(char *ptr); +static asn1_integer_t asn1p_atoi(char *ptr); /* errno is either 0 or ERANGE */ + +/* + * Check that the type is defined in the year of the standard choosen. + */ +#define TYPE_LIFETIME(fyr, lyr) \ + (!asn1p_lexer_types_year \ + || (fyr && fyr <= asn1p_lexer_types_year) \ + || (lyr && lyr > asn1p_lexer_types_year)) + +/* + * Check the the construction (or concept, i.e. CLASS) is defined in + * a given year. + */ +#define CONSTRUCT_LIFETIME(fyr, lyr) \ + (!asn1p_lexer_constructs_year \ + || (fyr && fyr <= asn1p_lexer_constructs_year) \ + || (lyr && lyr > asn1p_lexer_constructs_year)) + +/* + * Make sure that the label is compliant with the naming rules. + */ +#define CHECK_DASHES do { \ + if(_check_dashes(yytext)) { \ + fprintf(stderr, \ + "%s: Identifier format invalid: " \ + "Improper dash location\n", yytext); \ + return -1; \ + } } while(0) + +/* + * Append quoted string. + */ +#define QAPPEND(text, tlen) do { \ + char *prev_text = asn1p_lval.tv_opaque.buf; \ + int prev_len = asn1p_lval.tv_opaque.len; \ + char *p; \ + \ + p = malloc((tlen) + prev_len + 1); \ + if(p == NULL) return -1; \ + \ + if(prev_text) memcpy(p, prev_text, prev_len); \ + memcpy(p + prev_len, text, tlen); \ + p[prev_len + (tlen)] = '\0'; \ + \ + free(asn1p_lval.tv_opaque.buf); \ + asn1p_lval.tv_opaque.buf = p; \ + asn1p_lval.tv_opaque.len = (tlen) + prev_len; \ + } while(0) + +%} + +%option never-interactive +%option noinput nounput +%option noyywrap stack +/* Performance penalty is OK */ +%option yylineno +/* Controlled from within application */ +%option debug + +%pointer + +%x dash_comment +%x cpp_comment +%x quoted +%x opaque +%x with_syntax + +/* Newline */ +NL [\r\v\f\n] +/* White-space */ +WSP [\t\r\v\f\n ] + +%% + +"--" yy_push_state(dash_comment); +{ + + {NL} yy_pop_state(); + + -- yy_pop_state(); /* End of comment */ + - /* Eat single dash */ + [^\r\v\f\n-]+ /* Eat */ + +} +"/*" yy_push_state(cpp_comment); +{ + [^*/] /* Eat */ + "*/" yy_pop_state(); + . /* Eat */ +} + + + /* + * This is state is being set from corresponding .y module when + * higher-level data is necessary to make proper parsing of the + * underlying data. Thus, we enter the state and save + * everything for later processing. + */ +{ + + "{" { + yy_push_state(opaque); + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + + "}" { + yy_pop_state(); + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + + [^{}:=]+ { + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + + "::=" { + fprintf(stderr, + "ASN.1 Parser syncronization failure: " + "\"%s\" at line %d must not appear " + "inside value definition\n", + yytext, yylineno); + return -1; + } + + [:=] { + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + + } + +\"[^\"]* { + asn1p_lval.tv_opaque.buf = 0; + asn1p_lval.tv_opaque.len = 0; + QAPPEND(yytext+1, yyleng-1); + yy_push_state(quoted); + } +{ + + \"\" { QAPPEND(yytext, yyleng-1); } /* Add a single quote */ + [^\"]+ { QAPPEND(yytext, yyleng); } + + \" { + yy_pop_state(); + /* Do not append last quote: + // QAPPEND(yytext, yyleng); */ + + if(asn1p_lexer_pedantic_1990 + && strchr(yytext, '\n')) { + fprintf(stderr, "%s: " + "Newlines are prohibited by ASN.1:1990\n", + asn1p_lval.tv_opaque.buf); + return -1; + } + + return TOK_cstring; + } + + } + + +'[0-9A-F \t\r\v\f\n]+'H { + /* " \t\r\n" weren't allowed in ASN.1:1990. */ + asn1p_lval.tv_str = yytext; + return TOK_hstring; + } + +'[01 \t\r\v\f\n]+'B { + /* " \t\r\n" weren't allowed in ASN.1:1990. */ + asn1p_lval.tv_str = strdup(yytext); + return TOK_bstring; + } + + +-[1-9][0-9]* { + asn1p_lval.a_int = asn1p_atoi(yytext); + if(errno == ERANGE) + return -1; + return TOK_number_negative; + } + +[1-9][0-9]* { + asn1p_lval.a_int = asn1p_atoi(yytext); + if(errno == ERANGE) + return -1; + return TOK_number; + } + +"0" { + asn1p_lval.a_int = asn1p_atoi(yytext); + if(errno == ERANGE) + return -1; + return TOK_number; + } + + /* + * Tags + */ +\[(UNIVERSAL[ \t\r\v\f\n]+|APPLICATION[ \t\r\v\f\n]+|PRIVATE[ \t\r\v\f\n]+)?[0-9]+\] { + char *p; + memset(&asn1p_lval.a_tag, 0, sizeof(asn1p_lval.a_tag)); + switch(yytext[1]) { + case 'U': + asn1p_lval.a_tag.tag_class = TC_UNIVERSAL; + p = yytext + sizeof("UNIVERSAL") + 1; + break; + case 'A': + asn1p_lval.a_tag.tag_class = TC_APPLICATION; + p = yytext + sizeof("APPLICATION") + 1; + break; + case 'P': + asn1p_lval.a_tag.tag_class = TC_PRIVATE; + p = yytext + sizeof("PRIVATE") + 1; + break; + default: + assert(yytext[1] >= '0' && yytext[1] <= '9'); + asn1p_lval.a_tag.tag_class = TC_CONTEXT_SPECIFIC; + p = yytext + 1; + break; + } + asn1p_lval.a_tag.tag_value = asn1p_atoi(p); + if(*p == '0' && asn1p_lval.a_tag.tag_value) { + fprintf(stderr, + "Tag value at line %d " + "cannot start with zero " + "and have multiple digits: \"%s\"\n", + yylineno, yytext); + return -1; + } + return TOK_tag; + } + +\[[A-Z]+[ \t\r\v\f\n]+[0-9]+\] { + fprintf(stderr, + "Unsupported tag syntax at line %d: \"%s\"\n", + yylineno, yytext); + return -1; + } + +ABSENT return TOK_ABSENT; +ABSTRACT-SYNTAX return TOK_ABSTRACT_SYNTAX; +ALL return TOK_ALL; +ANY { + /* Appeared in 1990, removed in 1997 */ + if(TYPE_LIFETIME(1990, 1997)) + return TOK_ANY; + fprintf(stderr, "Keyword \"%s\" at line %d " + "is obsolete\n", yytext, yylineno); + REJECT; + } +APPLICATION return TOK_APPLICATION; +AUTOMATIC return TOK_AUTOMATIC; +BEGIN return TOK_BEGIN; +BIT return TOK_BIT; +BMPString { + if(TYPE_LIFETIME(1994, 0)) + return TOK_BMPString; + REJECT; + } +BOOLEAN return TOK_BOOLEAN; +BY return TOK_BY; +CHARACTER return TOK_CHARACTER; +CHOICE return TOK_CHOICE; +CLASS return TOK_CLASS; +COMPONENT return TOK_COMPONENT; +COMPONENTS return TOK_COMPONENTS; +CONSRAINED return TOK_CONSTRAINED; +CONTAINING return TOK_CONTAINING; +DEFAULT return TOK_DEFAULT; +DEFINED { + /* Appeared in 1990, removed in 1997 */ + if(TYPE_LIFETIME(1990, 1997)) + return TOK_DEFINED; + fprintf(stderr, "Keyword \"%s\" at line %d " + "is obsolete\n", yytext, yylineno); + /* Deprecated since */ + REJECT; + } +DEFINITIONS return TOK_DEFINITIONS; +EMBEDDED return TOK_EMBEDDED; +ENCODED return TOK_ENCODED; +END return TOK_END; +ENUMERATED return TOK_ENUMERATED; +EXCEPT return TOK_EXCEPT; +EXPLICIT return TOK_EXPLICIT; +EXPORTS return TOK_EXPORTS; +EXTENSIBILITY return TOK_EXTENSIBILITY; +EXTERNAL return TOK_EXTERNAL; +FALSE return TOK_FALSE; +FROM return TOK_FROM; +GeneralizedTime return TOK_GeneralizedTime; +GeneralString return TOK_GeneralString; +GraphicString return TOK_GraphicString; +IA5String return TOK_IA5String; +IDENTIFIER return TOK_IDENTIFIER; +IMPLICIT return TOK_IMPLICIT; +IMPLIED return TOK_IMPLIED; +IMPORTS return TOK_IMPORTS; +INCLUDES return TOK_INCLUDES; +INSTANCE return TOK_INSTANCE; +INTEGER return TOK_INTEGER; +INTERSECTION return TOK_INTERSECTION; +ISO646String return TOK_ISO646String; +MAX return TOK_MAX; +MIN return TOK_MIN; +MINUS-INFINITY return TOK_MINUS_INFINITY; +NULL return TOK_NULL; +NumericString return TOK_NumericString; +OBJECT return TOK_OBJECT; +ObjectDescriptor return TOK_ObjectDescriptor; +OCTET return TOK_OCTET; +OF return TOK_OF; +OPTIONAL return TOK_OPTIONAL; +PATTERN return TOK_PATTERN; +PDV return TOK_PDV; +PLUS-INFINITY return TOK_PLUS_INFINITY; +PRESENT return TOK_PRESENT; +PrintableString return TOK_PrintableString; +PRIVATE return TOK_PRIVATE; +REAL return TOK_REAL; +RELATIVE-OID return TOK_RELATIVE_OID; +SEQUENCE return TOK_SEQUENCE; +SET return TOK_SET; +SIZE return TOK_SIZE; +STRING return TOK_STRING; +SYNTAX return TOK_SYNTAX; +T61String return TOK_T61String; +TAGS return TOK_TAGS; +TeletexString return TOK_TeletexString; +TRUE return TOK_TRUE; +TYPE-IDENTIFIER return TOK_TYPE_IDENTIFIER; +UNION return TOK_UNION; +UNIQUE return TOK_UNIQUE; +UNIVERSAL return TOK_UNIVERSAL; +UniversalString { + if(TYPE_LIFETIME(1994, 0)) + return TOK_UniversalString; + REJECT; + } +UTCTime return TOK_UTCTime; +UTF8String { + if(TYPE_LIFETIME(1994, 0)) + return TOK_UTF8String; + REJECT; + } +VideotexString return TOK_VideotexString; +VisibleString return TOK_VisibleString; +WITH return TOK_WITH; + + +&[A-Z][A-Za-z0-9-]* { + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_typefieldreference; + } + +&[a-z][a-zA-Z0-9-]* { + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_valuefieldreference; + } + + +[a-z][a-zA-Z0-9-]* { + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_identifier; + } + + /* + * objectclassreference + */ +[A-Z][A-Z0-9-]* { + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_objectclassreference; + } + + /* + * typereference, modulereference + * NOTE: TOK_objectclassreference must be combined + * with this token to produce true typereference. + */ +[A-Z][A-Za-z0-9-]* { + CHECK_DASHES; + asn1p_lval.tv_str = strdup(yytext); + return TOK_typereference; + } + +"::=" return TOK_PPEQ; + +"..." return TOK_ThreeDots; +".." return TOK_TwoDots; + +[(){},;:|!.&@\[\]] return yytext[0]; + +{WSP}+ /* Ignore whitespace */ + +[^A-Za-z0-9:=,{}<.@()[]'\"|&^*;!-] { + if(TYPE_LIFETIME(1994, 0)) + fprintf(stderr, "ERROR: "); + fprintf(stderr, + "Symbol '%c' at line %d is prohibited " + "by ASN.1:1994 and ASN.1:1997\n", + yytext[0], yylineno); + if(TYPE_LIFETIME(1994, 0)) + return -1; + } + +{ + + [^&{} \t\r\v\f\n]+ { + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + + {WSP}+ { + asn1p_lval.tv_opaque.buf = strdup(yytext); + asn1p_lval.tv_opaque.len = yyleng; + return TOK_opaque; + } + + "}" { + yy_pop_state(); + return '}'; + } + +} + + +<*>. { + fprintf(stderr, + "Unexpected token at line %d: \"%s\"\n", + yylineno, yytext); + while(YYSTATE != INITIAL) + yy_pop_state(); + yy_top_state(); /* Just to use this function. */ + yyterminate(); + yy_fatal_error("Unexpected token"); + return -1; +} + +<*><> { + while(YYSTATE != INITIAL) + yy_pop_state(); + yyterminate(); + } + + +%% + +/* + * Very dirty but wonderful hack allowing to rule states from within .y file. + */ +void +asn1p_lexer_hack_push_opaque_state() { + yy_push_state(opaque); +} + +/* + * Another hack which disables recognizing some tokens when inside WITH SYNTAX. + */ +void +asn1p_lexer_hack_enable_with_syntax() { + yy_push_state(with_syntax); +} + +/* + * Check that a token does not end with dash and does not contain + * several dashes in succession. + * "Name", "Type-Id", "T-y-p-e-i-d" are OK + * "end-", "vustom--value" are INVALID + */ +static int +_check_dashes(char *ptr) { + int prev_dash = 0; + + assert(*ptr != '-'); + + for(;; ptr++) { + switch(*ptr) { + case '-': + if(prev_dash++) /* No double dashes */ + return -1; + continue; + case '\0': + if(prev_dash) /* No dashes at the end */ + return -1; + break; + default: + prev_dash = 0; + continue; + } + break; + } + + return 0; +} + +static asn1_integer_t +asn1p_atoi(char *ptr) { + asn1_integer_t value; + errno = 0; /* Clear the error code */ + + if(sizeof(value) <= sizeof(int)) { + value = strtol(ptr, 0, 10); + } else { +#ifdef HAVE_STRTOIMAX + value = strtoimax(ptr, 0, 10); +#elif HAVE_STRTOLL + value = strtoll(ptr, 0, 10); +#else + value = strtol(ptr, 0, 10); +#endif + } + + if(errno == ERANGE) { + fprintf(stderr, + "Value \"%s\" at line %d is too large " + "for this compiler! Please contact the vendor.", + ptr, yylineno); + errno = ERANGE; /* Restore potentially clobbered errno */ + } + + return value; +} + diff --git a/libasn1parser/asn1p_list.h b/libasn1parser/asn1p_list.h new file mode 100644 index 00000000..1f808780 --- /dev/null +++ b/libasn1parser/asn1p_list.h @@ -0,0 +1,57 @@ +/* + * Singly linked tail queue support. + */ +#ifndef ASN1_PARSER_LIST_H +#define ASN1_PARSER_LIST_H + +#define TQ_HEAD(type) \ + struct { \ + type *tq_head; \ + type**tq_tail; \ + } + +#define TQ_HEAD_COPY(to, from) \ + do { (to)->tq_head = (from)->tq_head; \ + (to)->tq_tail = (from)->tq_tail; } while(0) + +#define TQ_ENTRY(type) \ + struct { \ + type *tq_next; \ + } + +#define TQ_FIRST(headp) ((headp)->tq_head) +#define TQ_NEXT(el, field) ((el)->field.tq_next) + +#define TQ_INIT(head) do { \ + TQ_FIRST((head)) = 0; \ + (head)->tq_tail = &TQ_FIRST((head)); \ + } while(0) + +#define TQ_FOR(var, head, field) \ + for((var) = TQ_FIRST((head)); \ + (var); (var) = TQ_NEXT((var), field)) + +#define TQ_ADD(head, xel, field) do { \ + typeof(xel) __el = xel; \ + assert(TQ_NEXT((__el), field) == 0); \ + *(head)->tq_tail = (__el); \ + (head)->tq_tail = &TQ_NEXT((__el), field); \ + } while(0) + +/* + * Remove the first element and return it. + */ +#define TQ_REMOVE(head, field) ({ \ + typeof(TQ_FIRST((head))) __fel; \ + __fel = TQ_FIRST((head)); \ + if(__fel == 0 \ + || (TQ_FIRST((head)) = TQ_NEXT(__fel, field)) \ + == 0) { \ + (head)->tq_tail = &TQ_FIRST((head)); \ + } else { \ + TQ_NEXT(__fel, field) = 0; \ + } \ + __fel; }) + + +#endif /* ASN1_PARSER_LIST_H */ diff --git a/libasn1parser/asn1p_module.c b/libasn1parser/asn1p_module.c new file mode 100644 index 00000000..d430844e --- /dev/null +++ b/libasn1parser/asn1p_module.c @@ -0,0 +1,62 @@ +#include +#include + +#include "asn1parser.h" + +/* + * Construct a new empty module. + */ +asn1p_module_t * +asn1p_module_new() { + asn1p_module_t *mod; + + mod = calloc(1, sizeof *mod); + if(mod) { + TQ_INIT(&(mod->imports)); + TQ_INIT(&(mod->exports)); + TQ_INIT(&(mod->members)); + } + return mod; +} + +/* + * Destroy the module. + */ +void +asn1p_module_free(asn1p_module_t *mod) { + if(mod) { + asn1p_expr_t *expr; + + if(mod->Identifier) + free(mod->Identifier); + + if(mod->module_oid) + asn1p_oid_free(mod->module_oid); + + while((expr = TQ_REMOVE(&(mod->members), next))) + asn1p_expr_free(expr); + + free(mod); + } +} + +asn1p_t * +asn1p_new() { + asn1p_t *asn; + asn = calloc(1, sizeof(*asn)); + if(asn) { + TQ_INIT(&(asn->modules)); + } + return asn; +} + + +void +asn1p_free(asn1p_t *asn) { + if(asn) { + asn1p_module_t *mod; + while((mod = TQ_REMOVE(&(asn->modules), mod_next))) + asn1p_module_free(mod); + free(asn); + } +} diff --git a/libasn1parser/asn1p_module.h b/libasn1parser/asn1p_module.h new file mode 100644 index 00000000..906c784a --- /dev/null +++ b/libasn1parser/asn1p_module.h @@ -0,0 +1,88 @@ +/* + * A Module definition structure used by the ASN.1 parser. + */ +#ifndef ASN1_PARSER_MODULE_H +#define ASN1_PARSER_MODULE_H + +/* + * Flags specific to a module. + */ +typedef enum asn1p_module_flags { + MSF_NOFLAGS, + MSF_EXPLICIT_TAGS = 0x1, + MSF_IMPLICIT_TAGS = 0x2, + MSF_AUTOMATIC_TAGS = 0x4, + MSF_EXTENSIBILITY_IMPLIED = 0x8, +} asn1p_module_flags_e; + +/* + * === EXAMPLE === + * MySyntax DEFINITIONS AUTOMATIC TAGS ::= + * BEGIN + * ... + * END + * === EOF === + */ +typedef struct asn1p_module_s { + + /* + * Name of the source file. + */ + char *source_file_name; + + /* + * Human-readable module identifier. + */ + char *Identifier; /* Module name */ + + /* + * Unique module identifier, OID. + */ + asn1p_oid_t *module_oid; /* Optional OID of the module */ + + /* + * Module flags. + */ + asn1p_module_flags_e module_flags; /* AUTOMATIC TAGS? */ + + /* + * List of everything that this module IMPORTS. + */ + TQ_HEAD(struct asn1p_xports_s) imports; + + /* + * List of everything that this module EXPORTS. + */ + TQ_HEAD(struct asn1p_xports_s) exports; + + /* + * List of everything that this module defines itself. + */ + TQ_HEAD(struct asn1p_expr_s) members; + + /* + * Next module in the list. + */ + TQ_ENTRY(struct asn1p_module_s) + mod_next; + +} asn1p_module_t; + +/* + * Constructor and destructor. + */ +asn1p_module_t *asn1p_module_new(void); +void asn1p_module_free(asn1p_module_t *mod); + +/* + * No more than a container for several modules. + */ +typedef struct asn1p_s { + TQ_HEAD(struct asn1p_module_s) modules; +} asn1p_t; + +asn1p_t *asn1p_new(void); +void asn1p_free(asn1p_t *asn); + + +#endif /* ASN1_PARSER_MODULE_H */ diff --git a/libasn1parser/asn1p_oid.c b/libasn1parser/asn1p_oid.c new file mode 100644 index 00000000..2c22b0fd --- /dev/null +++ b/libasn1parser/asn1p_oid.c @@ -0,0 +1,95 @@ +#include +#include +#include + +#include "asn1parser.h" + +asn1p_oid_t * +asn1p_oid_new() { + return calloc(1, sizeof(asn1p_oid_t)); +} + +int +asn1p_oid_add_arc(asn1p_oid_t *oid, asn1p_oid_arc_t *template) { + void *p; + p = realloc(oid->arcs, (oid->arcs_count + 1) * sizeof(oid->arcs[0])); + if(p) { + oid->arcs = p; + oid->arcs[oid->arcs_count].name + = template->name?strdup(template->name):0; + oid->arcs[oid->arcs_count].number = template->number; + oid->arcs_count++; + return 0; + } else { + return -1; + } +} + +void +asn1p_oid_free(asn1p_oid_t *oid) { + if(oid) { + if(oid->arcs) { + while(oid->arcs_count--) { + if(oid->arcs[oid->arcs_count].name) + free(oid->arcs[oid->arcs_count].name); + } + } + free(oid); + } +} + +asn1p_oid_arc_t * +asn1p_oid_arc_new(const char *optName, asn1_integer_t optNumber /* = -1 */) { + asn1p_oid_arc_t *arc; + + arc = calloc(1, sizeof *arc); + if(arc) { + if(optName) + arc->name = strdup(optName); + arc->number = optNumber; + } + + return arc; +} + +void +asn1p_oid_arc_free(asn1p_oid_arc_t *arc) { + if(arc) { + if(arc->name) + free(arc->name); + free(arc); + } +} + +int +asn1p_oid_compare(asn1p_oid_t *a, asn1p_oid_t *b) { + int i; + + for(i = 0; ; i++) { + asn1_integer_t cmp; + + if(b->arcs_count > i) { + if(a->arcs_count <= i) + return -1; + } else if(a->arcs_count > i) { + if(b->arcs_count <= i) + return 1; + } else if(b->arcs_count <= i && a->arcs_count <= i) { + cmp = b->arcs_count - a->arcs_count; + if(cmp < 0) + return -1; + else if(cmp > 0) + return 1; + return 0; + } + + cmp = b->arcs[i].number - a->arcs[i].number; + if(cmp < 0) + return -1; + else if(cmp > 0) + return 1; + } + +} + + diff --git a/libasn1parser/asn1p_oid.h b/libasn1parser/asn1p_oid.h new file mode 100644 index 00000000..cbb6b079 --- /dev/null +++ b/libasn1parser/asn1p_oid.h @@ -0,0 +1,66 @@ +/* + * Object Identifier definition. + */ +#ifndef ASN1_PARSER_OID_H +#define ASN1_PARSER_OID_H + +/******************************** + * Single Object Identifier Arc * + ********************************/ + +/* + * Object identifier arc (one number in the hierarchy). + */ +typedef struct asn1p_oid_arc_s { + asn1_integer_t number; /* -1 if not yet defined */ + char *name; /* 0 if not defined */ +} asn1p_oid_arc_t; + + +/* + * Arc constructor. + */ +asn1p_oid_arc_t *asn1p_oid_arc_new( + const char *optName, asn1_integer_t optNumber /* = -1 */); +/* + * Arc destructor. + */ +void asn1p_oid_arc_free(asn1p_oid_arc_t *); + + +/************************************************** + * Object Identifier itself, a collection of arcs * + **************************************************/ + +/* + * Object Identifier as a collection of arcs. + */ +typedef struct asn1p_oid_s { + asn1p_oid_arc_t *arcs; + int arcs_count; +} asn1p_oid_t; + +/* + * OID constructor. + */ +asn1p_oid_t *asn1p_oid_new(void); + +/* + * Add another arc using given one as a template + */ +int asn1p_oid_add_arc(asn1p_oid_t *, asn1p_oid_arc_t *template); + +/* + * OID destructor. + */ +void asn1p_oid_free(asn1p_oid_t *); + +/* + * RETURN VALUES: + * 0: The specified OIDs are equal. + * -1 or 1 otherwise. + */ +int asn1p_oid_compare(asn1p_oid_t *a, asn1p_oid_t *b); + + +#endif /* ASN1_PARSER_OID_H */ diff --git a/libasn1parser/asn1p_param.c b/libasn1parser/asn1p_param.c new file mode 100644 index 00000000..f7082241 --- /dev/null +++ b/libasn1parser/asn1p_param.c @@ -0,0 +1,111 @@ +#include +#include +#include +#include +#include + +#include "asn1parser.h" + +/* + * Construct a new empty parameters list. + */ +asn1p_paramlist_t * +asn1p_paramlist_new(int _lineno) { + asn1p_paramlist_t *pl; + + pl = calloc(1, sizeof *pl); + if(pl) { + pl->_lineno = _lineno; + } + + return pl; +} + +void +asn1p_paramlist_free(asn1p_paramlist_t *pl) { + if(pl) { + if(pl->params) { + int i = pl->params_count; + while(i--) { + if(pl->params[i].governor) + asn1p_ref_free(pl->params[i].governor); + if(pl->params[i].argument) + free(pl->params[i].argument); + pl->params[i].governor = 0; + pl->params[i].argument = 0; + } + free(pl->params); + pl->params = 0; + } + + free(pl); + } +} + +int +asn1p_paramlist_add_param(asn1p_paramlist_t *pl, asn1p_ref_t *gov, char *arg) { + + if(!pl || !arg) { + errno = EINVAL; + return -1; + } + + /* + * Make sure there's enough space to insert a new element. + */ + if(pl->params_count == pl->params_size) { + int newsize = pl->params_size?pl->params_size<<2:4; + void *p; + p = realloc(pl->params, + newsize * sizeof(pl->params[0])); + if(p) { + pl->params = p; + pl->params_size = newsize; + } else { + return -1; + } + + } + + if(gov) { + pl->params[pl->params_count].governor = asn1p_ref_clone(gov); + if(pl->params[pl->params_count].governor == NULL) { + return -1; + } + } else { + pl->params[pl->params_count].governor = 0; + } + + pl->params[pl->params_count].argument = strdup(arg); + if(pl->params[pl->params_count].argument) { + pl->params_count++; + return 0; + } else { + if(pl->params[pl->params_count].governor) + asn1p_ref_free(pl->params[pl->params_count].governor); + return -1; + } +} + +asn1p_paramlist_t * +asn1p_paramlist_clone(asn1p_paramlist_t *pl) { + asn1p_paramlist_t *newpl; + + newpl = asn1p_paramlist_new(pl->_lineno); + if(newpl) { + int i; + for(i = 0; i < pl->params_count; i++) { + if(asn1p_paramlist_add_param(newpl, + pl->params[i].governor, + pl->params[i].argument + )) { + asn1p_paramlist_free(newpl); + newpl = NULL; + break; + } + } + } + + return newpl; +} + diff --git a/libasn1parser/asn1p_param.h b/libasn1parser/asn1p_param.h new file mode 100644 index 00000000..c9c20c23 --- /dev/null +++ b/libasn1parser/asn1p_param.h @@ -0,0 +1,30 @@ +/* + * Structures and prototypes related to parametrization + */ +#ifndef ASN1_PARSER_PARAMETRIZATION_H +#define ASN1_PARSER_PARAMETRIZATION_H + +typedef struct asn1p_paramlist_s { + struct asn1p_param_s { + asn1p_ref_t *governor; + char *argument; + } *params; + int params_count; + int params_size; + + int _lineno; +} asn1p_paramlist_t; + +/* + * Constructor and destructor. + */ +asn1p_paramlist_t *asn1p_paramlist_new(int _lineno); +void asn1p_paramlist_free(asn1p_paramlist_t *); + +asn1p_paramlist_t *asn1p_paramlist_clone(asn1p_paramlist_t *ref); + +int asn1p_paramlist_add_param(asn1p_paramlist_t *, + asn1p_ref_t *opt_gov, char *arg); + + +#endif /* ASN1_PARSER_PARAMETRIZATION_H */ diff --git a/libasn1parser/asn1p_ref.c b/libasn1parser/asn1p_ref.c new file mode 100644 index 00000000..4ac2b32d --- /dev/null +++ b/libasn1parser/asn1p_ref.c @@ -0,0 +1,137 @@ +#include +#include +#include +#include +#include + +#include "asn1parser.h" + +/* + * Construct a new empty reference. + */ +asn1p_ref_t * +asn1p_ref_new(int _lineno) { + asn1p_ref_t *ref; + + ref = calloc(1, sizeof *ref); + if(ref) { + ref->_lineno = _lineno; + } + + return ref; +} + +void +asn1p_ref_free(asn1p_ref_t *ref) { + if(ref) { + if(ref->components) { + int i = ref->comp_count; + while(i--) { + if(ref->components[i].name) + free(ref->components[i].name); + ref->components[i].name = 0; + } + free(ref->components); + ref->components = 0; + } + + free(ref); + } +} + +static enum asn1p_ref_lex_type_e +asn1p_ref_name2lextype(char *name) { + enum asn1p_ref_lex_type_e lex_type; + int has_lowercase = 0; + + if(*name == '&') { + if(name[1] >= 'A' && name[1] <= 'Z') { + lex_type = RLT_AmpUppercase; + } else { + lex_type = RLT_Amplowercase; + } + } else if(*name >= 'A' && *name <= 'Z') { + char *p; + + for(p = name; *p; p++) { + if(*p >= 'a' && *p <= 'z') { + has_lowercase = 1; + break; + } + } + + if(has_lowercase) { + lex_type = RLT_Uppercase; + } else { + lex_type = RLT_CAPITALS; + } + } else if(*name == '@') { + if(name[1] == '.') + lex_type = RLT_AtDotlowercase; + else + lex_type = RLT_Atlowercase; + } else { + lex_type = RLT_lowercase; + } + + return lex_type; +} + +int +asn1p_ref_add_component(asn1p_ref_t *ref, char *name, enum asn1p_ref_lex_type_e lex_type) { + + if(!ref || !name || lex_type < RLT_UNKNOWN || lex_type >= RLT_MAX) { + errno = EINVAL; + return -1; + } + + if(ref->comp_count == ref->comp_size) { + int newsize = ref->comp_size?(ref->comp_size<<2):4; + void *p = realloc(ref->components, + newsize * sizeof(ref->components[0])); + if(p) { + ref->components = p; + ref->comp_size = newsize; + } else { + return -1; + } + + } + + if(lex_type == RLT_UNKNOWN) { + lex_type = asn1p_ref_name2lextype(name); + } else { + assert(lex_type == asn1p_ref_name2lextype(name)); + } + + ref->components[ref->comp_count].name = strdup(name); + ref->components[ref->comp_count].lex_type = lex_type; + if(ref->components[ref->comp_count].name) { + ref->comp_count++; + return 0; + } else { + return -1; + } +} + +asn1p_ref_t * +asn1p_ref_clone(asn1p_ref_t *ref) { + asn1p_ref_t *newref; + + newref = asn1p_ref_new(ref->_lineno); + if(newref) { + int i; + for(i = 0; i < ref->comp_count; i++) { + if(asn1p_ref_add_component(newref, + ref->components[i].name, + ref->components[i].lex_type + )) { + asn1p_ref_free(newref); + newref = NULL; + break; + } + } + } + + return newref; +} diff --git a/libasn1parser/asn1p_ref.h b/libasn1parser/asn1p_ref.h new file mode 100644 index 00000000..dc7a7165 --- /dev/null +++ b/libasn1parser/asn1p_ref.h @@ -0,0 +1,62 @@ +/* + * Generic reference to the yet unknown type defined elsewhere. + */ +#ifndef ASN1_PARSER_REFERENCE_H +#define ASN1_PARSER_REFERENCE_H + +typedef struct asn1p_ref_s { + + /* + * A set of reference name components. + * A reference name consists of several components separated by dots: + * "OBJECT-CLASS.&Algorithm.&id" + */ + struct asn1p_ref_component_s { + enum asn1p_ref_lex_type_e { + RLT_UNKNOWN, /* Invalid? */ + /* + * Object class reference "OCLASS1", + * type reference "Type1", + * value reference "id", + * type field reference "&Type1", + * value field reference "&id", + * "OBJECT-CLASS" + */ + RLT_CAPITALS, + RLT_Uppercase, + RLT_lowercase, + RLT_AmpUppercase, + RLT_Amplowercase, + RLT_Atlowercase, + RLT_AtDotlowercase, + RLT_MAX + } lex_type; /* Inferred lexical type of the identifier */ + char *name; /* An identifier */ + } *components; + + int comp_count; /* Number of the components in the reference name. */ + int comp_size; /* Number of allocated structures */ + + int _lineno; /* Number of line in the file */ +} asn1p_ref_t; + +/* + * Constructor and destructor. + */ +asn1p_ref_t *asn1p_ref_new(int _lineno); +void asn1p_ref_free(asn1p_ref_t *); + +asn1p_ref_t *asn1p_ref_clone(asn1p_ref_t *ref); + +/* + * Add a new reference component to the existing reference structure. + * + * RETURN VALUES: + * 0: All clear. + * -1/EINVAL: Invalid arguments + * -1/ENOMEM: Memory allocation failed + */ +int asn1p_ref_add_component(asn1p_ref_t *, + char *name, enum asn1p_ref_lex_type_e); + +#endif /* ASN1_PARSER_REFERENCE_H */ diff --git a/libasn1parser/asn1p_value.c b/libasn1parser/asn1p_value.c new file mode 100644 index 00000000..fb3a9453 --- /dev/null +++ b/libasn1parser/asn1p_value.c @@ -0,0 +1,178 @@ +#include +#include +#include +#include + +#include "asn1parser.h" + + +asn1p_value_t * +asn1p_value_fromref(asn1p_ref_t *ref, int do_copy) { + if(ref) { + asn1p_value_t *v = calloc(1, sizeof *v); + if(v) { + if(do_copy) { + v->value.reference = asn1p_ref_clone(ref); + if(v->value.reference == NULL) { + free(v); + return NULL; + } + } else { + v->value.reference = ref; + } + v->type = ATV_REFERENCED; + } + return v; + } else { + errno = EINVAL; + return NULL; + } +} + +asn1p_value_t * +asn1p_value_frombits(uint8_t *bits, int size_in_bits, int do_copy) { + if(bits) { + asn1p_value_t *v = calloc(1, sizeof *v); + assert(size_in_bits >= 0); + if(v) { + if(do_copy) { + int size = ((size_in_bits + 7) >> 3); + void *p; + p = malloc(size + 1); + if(p) { + memcpy(p, bits, size); + ((char *)p)[size] = '\0'; /* JIC */ + } else { + free(v); + return NULL; + } + v->value.binary_vector.bits = p; + } else { + v->value.binary_vector.bits = (void *)bits; + } + v->value.binary_vector.size_in_bits = size_in_bits; + v->type = ATV_BITVECTOR; + } + return v; + } else { + errno = EINVAL; + return NULL; + } +} +asn1p_value_t * +asn1p_value_frombuf(char *buffer, int size, int do_copy) { + if(buffer) { + asn1p_value_t *v = calloc(1, sizeof *v); + assert(size >= 0); + if(v) { + if(do_copy) { + void *p = malloc(size + 1); + if(p) { + memcpy(p, buffer, size); + ((char *)p)[size] = '\0'; /* JIC */ + } else { + free(v); + return NULL; + } + v->value.string.buf = p; + } else { + v->value.string.buf = buffer; + } + v->value.string.size = size; + v->type = ATV_STRING; + } + return v; + } else { + errno = EINVAL; + return NULL; + } +} + +asn1p_value_t * +asn1p_value_fromdouble(double d) { + asn1p_value_t *v = calloc(1, sizeof *v); + if(v) { + v->value.v_double = d; + v->type = ATV_REAL; + } + return v; +} + +asn1p_value_t * +asn1p_value_fromint(asn1_integer_t i) { + asn1p_value_t *v = calloc(1, sizeof *v); + if(v) { + v->value.v_integer = i; + v->type = ATV_INTEGER; + } + return v; +} + +asn1p_value_t * +asn1p_value_clone(asn1p_value_t *v) { + asn1p_value_t *clone; + if(v) { + switch(v->type) { + case ATV_NOVALUE: + return calloc(1, sizeof(*v)); + case ATV_REFERENCED: + return asn1p_value_fromref(v->value.reference, 1); + case ATV_REAL: + return asn1p_value_fromdouble(v->value.v_double); + case ATV_INTEGER: + case ATV_MIN: + case ATV_MAX: + case ATV_FALSE: + case ATV_TRUE: + clone = asn1p_value_fromint(v->value.v_integer); + if(clone) clone->type = v->type; + return clone; + case ATV_STRING: + clone = asn1p_value_frombuf(v->value.string.buf, + v->value.string.size, 1); + if(clone) clone->type = v->type; + return clone; + case ATV_UNPARSED: + clone = asn1p_value_frombuf(v->value.string.buf, + v->value.string.size, 1); + if(clone) clone->type = ATV_UNPARSED; + return clone; + case ATV_BITVECTOR: + return asn1p_value_frombuf(v->value.binary_vector.bits, + v->value.binary_vector.size_in_bits, 1); + } + } + return v; +} + +void +asn1p_value_free(asn1p_value_t *v) { + if(v) { + switch(v->type) { + case ATV_NOVALUE: + break; + case ATV_REFERENCED: + asn1p_ref_free(v->value.reference); + break; + case ATV_INTEGER: + case ATV_MIN: + case ATV_MAX: + case ATV_FALSE: + case ATV_TRUE: + case ATV_REAL: + /* No freeing necessary */ + break; + case ATV_STRING: + case ATV_UNPARSED: + assert(v->value.string.buf); + free(v->value.string.buf); + break; + case ATV_BITVECTOR: + assert(v->value.binary_vector.bits); + free(v->value.binary_vector.bits); + break; + } + free(v); + } +} + diff --git a/libasn1parser/asn1p_value.h b/libasn1parser/asn1p_value.h new file mode 100644 index 00000000..c9dabfcd --- /dev/null +++ b/libasn1parser/asn1p_value.h @@ -0,0 +1,60 @@ +/* + * A generic value of different syntaxes. + */ +#ifndef ASN1_PARSER_VALUE_H +#define ASN1_PARSER_VALUE_H + +/* + * A wrapper around various kinds of values. + */ +typedef struct asn1p_value_s { + /* + * The value of the element. + */ + enum { + ATV_NOVALUE, + ATV_REFERENCED, + ATV_REAL, + ATV_INTEGER, + ATV_MIN, + ATV_MAX, + ATV_FALSE, + ATV_TRUE, + ATV_STRING, + ATV_UNPARSED, + ATV_BITVECTOR, + } type; /* Value type and location */ + + union { + asn1p_ref_t *reference; + asn1_integer_t v_integer; + double v_double; + /* + * Binary bits vector. + */ + struct { + uint8_t *buf; + int size; + } string; + struct { + uint8_t *bits; + int size_in_bits; + } binary_vector; + } value; +} asn1p_value_t; + +/* + * Constructors and destructor for value. + * If ref, bits or buffer are omitted, the corresponding function returns + * (asn1p_value_t *)0 with errno = EINVAL. + * Allocated value (where applicable) is guaranteed to be NUL-terminated. + */ +asn1p_value_t *asn1p_value_fromref(asn1p_ref_t *ref, int do_copy); +asn1p_value_t *asn1p_value_frombits(uint8_t *bits, int size_in_bits, int dc); +asn1p_value_t *asn1p_value_frombuf(char *buffer, int size, int do_copy); +asn1p_value_t *asn1p_value_fromdouble(double); +asn1p_value_t *asn1p_value_fromint(asn1_integer_t); +asn1p_value_t *asn1p_value_clone(asn1p_value_t *); +void asn1p_value_free(asn1p_value_t *); + +#endif /* ASN1_PARSER_VALUE_H */ diff --git a/libasn1parser/asn1p_xports.c b/libasn1parser/asn1p_xports.c new file mode 100644 index 00000000..cfc9fa4f --- /dev/null +++ b/libasn1parser/asn1p_xports.c @@ -0,0 +1,34 @@ +#include +#include + +#include "asn1parser.h" + +/* + * Construct a new structure that would hold the EXPORTS or IMPORTS + * clause data. + */ +asn1p_xports_t * +asn1p_xports_new() { + asn1p_xports_t *xp; + + xp = calloc(1, sizeof *xp); + if(xp) { + TQ_INIT(&(xp->members)); + } + + return xp; +} + +/* + * Destroy the xports structure. + */ +void +asn1p_xports_free(asn1p_xports_t *xp) { + if(xp) { + if(xp->from) + free(xp->from); + if(xp->from_oid) + asn1p_oid_free(xp->from_oid); + free(xp); + } +} diff --git a/libasn1parser/asn1p_xports.h b/libasn1parser/asn1p_xports.h new file mode 100644 index 00000000..8f4fade3 --- /dev/null +++ b/libasn1parser/asn1p_xports.h @@ -0,0 +1,40 @@ +/* + * Imports and exports structure. + */ +#ifndef ASN1_PARSE_XPORTS_H +#define ASN1_PARSE_XPORTS_H + + +typedef struct asn1p_xports_s { + /* + * Type of the xports structure. + */ + enum asn1p_xports { + XPT_IMPORTS, + XPT_EXPORTS, + } xports_type; + + /* + * Module name and optional OID, occur after FROM. + */ + char *from; /* Name of the module */ + asn1p_oid_t *from_oid; /* Optional OID of the module */ + + /* + * Number of entities to import. + */ + TQ_HEAD(struct asn1p_expr_s) members; + + /* + * Pointer to the next xports structure in whatever list. + */ + TQ_ENTRY(struct asn1p_xports_s) xp_next; +} asn1p_xports_t; + +/* + * Constructor and destructor. + */ +asn1p_xports_t *asn1p_xports_new(void); +void asn1p_xports_free(asn1p_xports_t *); + +#endif /* ASN1_PARSE_XPORTS_H */ diff --git a/libasn1parser/asn1p_y.c b/libasn1parser/asn1p_y.c new file mode 100644 index 00000000..095c9041 --- /dev/null +++ b/libasn1parser/asn1p_y.c @@ -0,0 +1,3484 @@ + +/* A Bison parser, made from asn1p_y.y + by GNU Bison version 1.28 */ + +#define YYBISON 1 /* Identify Bison output. */ + +#define yyparse asn1p_parse +#define yylex asn1p_lex +#define yyerror asn1p_error +#define yylval asn1p_lval +#define yychar asn1p_char +#define yydebug asn1p_debug +#define yynerrs asn1p_nerrs +#define TOK_PPEQ 257 +#define TOK_opaque 258 +#define TOK_bstring 259 +#define TOK_cstring 260 +#define TOK_hstring 261 +#define TOK_identifier 262 +#define TOK_number 263 +#define TOK_number_negative 264 +#define TOK_typereference 265 +#define TOK_objectclassreference 266 +#define TOK_typefieldreference 267 +#define TOK_valuefieldreference 268 +#define TOK_ABSENT 269 +#define TOK_ABSTRACT_SYNTAX 270 +#define TOK_ALL 271 +#define TOK_ANY 272 +#define TOK_APPLICATION 273 +#define TOK_AUTOMATIC 274 +#define TOK_BEGIN 275 +#define TOK_BIT 276 +#define TOK_BMPString 277 +#define TOK_BOOLEAN 278 +#define TOK_BY 279 +#define TOK_CHARACTER 280 +#define TOK_CHOICE 281 +#define TOK_CLASS 282 +#define TOK_COMPONENT 283 +#define TOK_COMPONENTS 284 +#define TOK_CONSTRAINED 285 +#define TOK_CONTAINING 286 +#define TOK_DEFAULT 287 +#define TOK_DEFINITIONS 288 +#define TOK_DEFINED 289 +#define TOK_EMBEDDED 290 +#define TOK_ENCODED 291 +#define TOK_END 292 +#define TOK_ENUMERATED 293 +#define TOK_EXPLICIT 294 +#define TOK_EXPORTS 295 +#define TOK_EXTENSIBILITY 296 +#define TOK_EXTERNAL 297 +#define TOK_FALSE 298 +#define TOK_FROM 299 +#define TOK_GeneralizedTime 300 +#define TOK_GeneralString 301 +#define TOK_GraphicString 302 +#define TOK_IA5String 303 +#define TOK_IDENTIFIER 304 +#define TOK_IMPLICIT 305 +#define TOK_IMPLIED 306 +#define TOK_IMPORTS 307 +#define TOK_INCLUDES 308 +#define TOK_INSTANCE 309 +#define TOK_INTEGER 310 +#define TOK_ISO646String 311 +#define TOK_MAX 312 +#define TOK_MIN 313 +#define TOK_MINUS_INFINITY 314 +#define TOK_NULL 315 +#define TOK_NumericString 316 +#define TOK_OBJECT 317 +#define TOK_ObjectDescriptor 318 +#define TOK_OCTET 319 +#define TOK_OF 320 +#define TOK_OPTIONAL 321 +#define TOK_PATTERN 322 +#define TOK_PDV 323 +#define TOK_PLUS_INFINITY 324 +#define TOK_PRESENT 325 +#define TOK_PrintableString 326 +#define TOK_PRIVATE 327 +#define TOK_REAL 328 +#define TOK_RELATIVE_OID 329 +#define TOK_SEQUENCE 330 +#define TOK_SET 331 +#define TOK_SIZE 332 +#define TOK_STRING 333 +#define TOK_SYNTAX 334 +#define TOK_T61String 335 +#define TOK_TAGS 336 +#define TOK_TeletexString 337 +#define TOK_TRUE 338 +#define TOK_TYPE_IDENTIFIER 339 +#define TOK_UNIQUE 340 +#define TOK_UNIVERSAL 341 +#define TOK_UniversalString 342 +#define TOK_UTCTime 343 +#define TOK_UTF8String 344 +#define TOK_VideotexString 345 +#define TOK_VisibleString 346 +#define TOK_WITH 347 +#define TOK_UNION 348 +#define TOK_INTERSECTION 349 +#define TOK_EXCEPT 350 +#define TOK_TwoDots 351 +#define TOK_ThreeDots 352 +#define TOK_tag 353 + +#line 1 "asn1p_y.y" + + +#include +#include +#include +#include +#include + +#include "asn1parser.h" + +#define YYPARSE_PARAM param +#define YYERROR_VERBOSE + +int yylex(void); +int yyerror(const char *msg); +void asn1p_lexer_hack_push_opaque_state(void); +void asn1p_lexer_hack_enable_with_syntax(void); +#define yylineno asn1p_lineno +extern int asn1p_lineno; + + +static asn1p_value_t * + _convert_bitstring2binary(char *str, int base); + +#define checkmem(ptr) do { \ + if(!(ptr)) \ + return yyerror("Memory failure"); \ + } while(0) + +#define CONSTRAINT_INSERT(root, constr_type, arg1, arg2) do { \ + if(arg1->type != constr_type) { \ + int __ret; \ + root = asn1p_constraint_new(yylineno); \ + checkmem(root); \ + root->type = constr_type; \ + __ret = asn1p_constraint_insert(root, \ + arg1); \ + checkmem(__ret == 0); \ + } else { \ + root = arg1; \ + } \ + if(arg2) { \ + int __ret \ + = asn1p_constraint_insert(root, arg2); \ + checkmem(__ret == 0); \ + } \ + } while(0) + + +#line 57 "asn1p_y.y" +typedef union { + asn1p_t *a_grammar; + asn1p_module_flags_e a_module_flags; + asn1p_module_t *a_module; + asn1p_expr_type_e a_type; /* ASN.1 Type */ + asn1p_expr_t *a_expr; /* Constructed collection */ + asn1p_constraint_t *a_constr; /* Constraint */ + enum asn1p_constraint_type_e a_ctype;/* Constraint type */ + asn1p_xports_t *a_xports; /* IMports/EXports */ + asn1p_oid_t *a_oid; /* Object Identifier */ + asn1p_oid_arc_t a_oid_arc; /* Single OID's arc */ + struct asn1p_type_tag_s a_tag; /* A tag */ + asn1p_ref_t *a_ref; /* Reference to custom type */ + asn1p_wsyntx_t *a_wsynt; /* WITH SYNTAX contents */ + asn1p_wsyntx_chunk_t *a_wchunk; /* WITH SYNTAX chunk */ + struct asn1p_ref_component_s a_refcomp; /* Component of a reference */ + asn1p_value_t *a_value; /* Number, DefinedValue, etc */ + struct asn1p_param_s a_parg; /* A parameter argument */ + asn1p_paramlist_t *a_plist; /* A pargs list */ + enum asn1p_expr_marker_e a_marker; /* OPTIONAL/DEFAULT */ + enum asn1p_constr_pres_e a_pres; /* PRESENT/ABSENT/OPTIONAL */ + asn1_integer_t a_int; + char *tv_str; + struct { + char *buf; + int len; + } tv_opaque; + struct { + char *name; + struct asn1p_type_tag_s tag; + } tv_nametag; +} YYSTYPE; +#include + +#ifndef __cplusplus +#ifndef __STDC__ +#define const +#endif +#endif + + + +#define YYFINAL 375 +#define YYFLAG -32768 +#define YYNTBASE 113 + +#define YYTRANSLATE(x) ((unsigned)(x) <= 353 ? yytranslate[x] : 211) + +static const char yytranslate[] = { 0, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 109, 2, 2, 2, 2, 2, 2, 104, + 105, 2, 2, 107, 2, 110, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 108, 106, 111, + 2, 2, 2, 112, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 96, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 102, 94, 103, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 1, 3, 4, 5, 6, + 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, + 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, + 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, + 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, + 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, + 87, 88, 89, 90, 91, 92, 93, 95, 97, 98, + 99, 100, 101 +}; + +#if YYDEBUG != 0 +static const short yyprhs[] = { 0, + 0, 2, 4, 7, 16, 17, 19, 23, 26, 28, + 31, 33, 38, 40, 41, 43, 45, 48, 51, 54, + 57, 60, 61, 63, 65, 68, 70, 72, 74, 76, + 78, 80, 84, 87, 89, 92, 97, 99, 103, 105, + 107, 111, 115, 118, 120, 124, 126, 128, 135, 137, + 139, 140, 142, 147, 152, 156, 163, 165, 169, 171, + 175, 179, 181, 185, 187, 189, 191, 195, 201, 202, + 204, 206, 210, 213, 217, 222, 223, 225, 226, 233, + 235, 238, 240, 242, 245, 247, 251, 253, 257, 261, + 263, 265, 267, 272, 274, 278, 280, 284, 288, 290, + 294, 296, 300, 302, 304, 306, 308, 313, 314, 318, + 320, 322, 324, 326, 328, 330, 334, 336, 339, 341, + 343, 345, 347, 350, 353, 355, 357, 360, 363, 365, + 367, 369, 371, 374, 376, 379, 381, 383, 385, 387, + 389, 391, 393, 395, 397, 399, 401, 403, 405, 407, + 412, 417, 422, 427, 432, 434, 439, 440, 442, 444, + 446, 448, 450, 452, 457, 459, 462, 466, 468, 472, + 478, 480, 484, 486, 488, 492, 494, 498, 500, 504, + 506, 510, 515, 517, 519, 521, 524, 527, 531, 533, + 535, 537, 539, 541, 543, 545, 547, 549, 555, 557, + 561, 563, 567, 568, 570, 572, 574, 576, 578, 580, + 584, 589, 591, 595, 598, 602, 604, 608, 609, 611, + 613, 616, 618, 620, 621, 625, 628, 632, 634, 638, + 640, 645, 650, 652, 654, 656, 658, 659, 661, 663, + 666, 669, 671, 673, 675, 677, 679 +}; + +static const short yyrhs[] = { 114, + 0, 115, 0, 114, 115, 0, 207, 116, 34, 120, + 3, 21, 123, 38, 0, 0, 117, 0, 102, 118, + 103, 0, 102, 103, 0, 119, 0, 118, 119, 0, + 209, 0, 209, 104, 9, 105, 0, 9, 0, 0, + 121, 0, 122, 0, 121, 122, 0, 40, 82, 0, + 51, 82, 0, 20, 82, 0, 42, 52, 0, 0, + 124, 0, 125, 0, 124, 125, 0, 126, 0, 131, + 0, 137, 0, 161, 0, 134, 0, 169, 0, 53, + 127, 106, 0, 53, 45, 0, 128, 0, 127, 128, + 0, 129, 45, 207, 116, 0, 130, 0, 129, 107, + 130, 0, 207, 0, 209, 0, 41, 132, 106, 0, + 41, 17, 106, 0, 41, 106, 0, 133, 0, 132, + 107, 133, 0, 207, 0, 209, 0, 207, 135, 3, + 102, 136, 103, 0, 156, 0, 166, 0, 0, 177, + 0, 207, 3, 205, 85, 0, 207, 3, 205, 153, + 0, 207, 3, 143, 0, 207, 102, 138, 103, 3, + 153, 0, 139, 0, 138, 107, 139, 0, 207, 0, + 207, 108, 209, 0, 166, 108, 209, 0, 141, 0, + 140, 107, 141, 0, 155, 0, 209, 0, 152, 0, + 142, 107, 152, 0, 28, 102, 145, 103, 147, 0, + 0, 86, 0, 146, 0, 145, 107, 146, 0, 159, + 197, 0, 159, 153, 144, 0, 159, 159, 197, 144, + 0, 0, 148, 0, 0, 93, 80, 102, 149, 150, + 103, 0, 151, 0, 150, 151, 0, 4, 0, 159, + 0, 210, 153, 0, 154, 0, 155, 171, 197, 0, + 100, 0, 100, 109, 164, 0, 100, 109, 204, 0, + 168, 0, 169, 0, 170, 0, 207, 102, 140, 103, + 0, 156, 0, 55, 66, 156, 0, 11, 0, 11, + 110, 207, 0, 11, 110, 209, 0, 208, 0, 208, + 110, 157, 0, 158, 0, 157, 110, 158, 0, 160, + 0, 160, 0, 13, 0, 14, 0, 209, 135, 3, + 162, 0, 0, 102, 163, 165, 0, 5, 0, 7, + 0, 6, 0, 204, 0, 164, 0, 209, 0, 207, + 110, 209, 0, 4, 0, 165, 4, 0, 24, 0, + 61, 0, 74, 0, 167, 0, 65, 79, 0, 63, + 50, 0, 75, 0, 43, 0, 36, 69, 0, 26, + 79, 0, 89, 0, 46, 0, 56, 0, 39, 0, + 22, 79, 0, 166, 0, 167, 201, 0, 23, 0, + 47, 0, 48, 0, 49, 0, 57, 0, 62, 0, + 72, 0, 81, 0, 83, 0, 88, 0, 90, 0, + 91, 0, 92, 0, 64, 0, 27, 102, 142, 103, + 0, 76, 102, 142, 103, 0, 77, 102, 142, 103, + 0, 76, 171, 66, 155, 0, 77, 171, 66, 155, + 0, 18, 0, 18, 35, 25, 209, 0, 0, 175, + 0, 94, 0, 95, 0, 96, 0, 97, 0, 98, + 0, 78, 104, 177, 105, 0, 176, 0, 175, 176, + 0, 104, 177, 105, 0, 178, 0, 178, 107, 100, + 0, 178, 107, 100, 107, 178, 0, 100, 0, 100, + 107, 178, 0, 179, 0, 180, 0, 179, 172, 180, + 0, 181, 0, 180, 173, 181, 0, 182, 0, 181, + 174, 182, 0, 185, 0, 185, 183, 185, 0, 184, + 104, 177, 105, 0, 191, 0, 186, 0, 99, 0, + 99, 111, 0, 111, 99, 0, 111, 99, 111, 0, + 78, 0, 45, 0, 204, 0, 209, 0, 6, 0, + 59, 0, 58, 0, 44, 0, 84, 0, 93, 30, + 102, 187, 103, 0, 188, 0, 187, 107, 188, 0, + 100, 0, 209, 171, 189, 0, 0, 190, 0, 71, + 0, 15, 0, 67, 0, 192, 0, 193, 0, 102, + 207, 103, 0, 192, 102, 194, 103, 0, 195, 0, + 194, 107, 195, 0, 112, 196, 0, 112, 110, 196, + 0, 209, 0, 196, 110, 209, 0, 0, 198, 0, + 67, 0, 33, 199, 0, 185, 0, 166, 0, 0, + 102, 200, 165, 0, 102, 103, 0, 102, 202, 103, + 0, 203, 0, 202, 107, 203, 0, 209, 0, 209, + 104, 204, 105, 0, 209, 104, 164, 105, 0, 204, + 0, 100, 0, 9, 0, 10, 0, 0, 206, 0, + 101, 0, 101, 51, 0, 101, 40, 0, 11, 0, + 12, 0, 12, 0, 8, 0, 209, 0, 209, 206, + 0 +}; + +#endif + +#if YYDEBUG != 0 +static const short yyrline[] = { 0, + 297, 303, 309, 325, 350, 352, 355, 359, 364, 371, + 379, 384, 388, 397, 399, 407, 411, 419, 423, 426, + 429, 437, 439, 448, 452, 477, 481, 490, 497, 510, + 521, 534, 541, 546, 552, 558, 567, 573, 579, 586, + 594, 598, 601, 608, 614, 620, 627, 636, 646, 654, + 662, 664, 676, 688, 695, 711, 721, 731, 741, 746, + 753, 763, 769, 775, 779, 791, 797, 803, 813, 815, + 818, 826, 832, 841, 846, 863, 865, 870, 874, 879, + 884, 890, 894, 919, 926, 931, 939, 948, 957, 968, + 972, 978, 986, 1010, 1017, 1031, 1040, 1050, 1060, 1068, + 1089, 1098, 1107, 1108, 1110, 1117, 1129, 1139, 1141, 1146, + 1150, 1154, 1158, 1161, 1166, 1178, 1194, 1205, 1219, 1221, + 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, 1230, 1231, + 1237, 1239, 1240, 1243, 1250, 1262, 1264, 1268, 1272, 1273, + 1274, 1275, 1276, 1280, 1281, 1282, 1283, 1287, 1288, 1291, + 1298, 1304, 1310, 1318, 1326, 1332, 1348, 1350, 1353, 1353, + 1354, 1354, 1355, 1357, 1370, 1373, 1378, 1384, 1388, 1395, + 1403, 1408, 1417, 1419, 1421, 1426, 1428, 1434, 1436, 1441, + 1448, 1455, 1463, 1466, 1471, 1473, 1474, 1475, 1478, 1482, + 1487, 1491, 1502, 1506, 1511, 1516, 1521, 1528, 1534, 1538, + 1543, 1549, 1561, 1563, 1566, 1570, 1573, 1578, 1582, 1590, + 1605, 1611, 1618, 1631, 1643, 1658, 1662, 1679, 1681, 1684, + 1688, 1694, 1697, 1699, 1699, 1719, 1724, 1729, 1735, 1741, + 1749, 1757, 1765, 1772, 1782, 1787, 1817, 1819, 1822, 1827, + 1831, 1837, 1842, 1848, 1855, 1862, 1867 +}; +#endif + + +#if YYDEBUG != 0 || defined (YYERROR_VERBOSE) + +static const char * const yytname[] = { "$","error","$undefined.","TOK_PPEQ", +"TOK_opaque","TOK_bstring","TOK_cstring","TOK_hstring","TOK_identifier","TOK_number", +"TOK_number_negative","TOK_typereference","TOK_objectclassreference","TOK_typefieldreference", +"TOK_valuefieldreference","TOK_ABSENT","TOK_ABSTRACT_SYNTAX","TOK_ALL","TOK_ANY", +"TOK_APPLICATION","TOK_AUTOMATIC","TOK_BEGIN","TOK_BIT","TOK_BMPString","TOK_BOOLEAN", +"TOK_BY","TOK_CHARACTER","TOK_CHOICE","TOK_CLASS","TOK_COMPONENT","TOK_COMPONENTS", +"TOK_CONSTRAINED","TOK_CONTAINING","TOK_DEFAULT","TOK_DEFINITIONS","TOK_DEFINED", +"TOK_EMBEDDED","TOK_ENCODED","TOK_END","TOK_ENUMERATED","TOK_EXPLICIT","TOK_EXPORTS", +"TOK_EXTENSIBILITY","TOK_EXTERNAL","TOK_FALSE","TOK_FROM","TOK_GeneralizedTime", +"TOK_GeneralString","TOK_GraphicString","TOK_IA5String","TOK_IDENTIFIER","TOK_IMPLICIT", +"TOK_IMPLIED","TOK_IMPORTS","TOK_INCLUDES","TOK_INSTANCE","TOK_INTEGER","TOK_ISO646String", +"TOK_MAX","TOK_MIN","TOK_MINUS_INFINITY","TOK_NULL","TOK_NumericString","TOK_OBJECT", +"TOK_ObjectDescriptor","TOK_OCTET","TOK_OF","TOK_OPTIONAL","TOK_PATTERN","TOK_PDV", +"TOK_PLUS_INFINITY","TOK_PRESENT","TOK_PrintableString","TOK_PRIVATE","TOK_REAL", +"TOK_RELATIVE_OID","TOK_SEQUENCE","TOK_SET","TOK_SIZE","TOK_STRING","TOK_SYNTAX", +"TOK_T61String","TOK_TAGS","TOK_TeletexString","TOK_TRUE","TOK_TYPE_IDENTIFIER", +"TOK_UNIQUE","TOK_UNIVERSAL","TOK_UniversalString","TOK_UTCTime","TOK_UTF8String", +"TOK_VideotexString","TOK_VisibleString","TOK_WITH","'|'","TOK_UNION","'^'", +"TOK_INTERSECTION","TOK_EXCEPT","TOK_TwoDots","TOK_ThreeDots","TOK_tag","'{'", +"'}'","'('","')'","';'","','","':'","'!'","'.'","'<'","'@'","ParsedGrammar", +"ModuleList","ModuleSpecification","optObjectIdentifier","ObjectIdentifier", +"ObjectIdentifierBody","ObjectIdentifierElement","optModuleSpecificationFlags", +"ModuleSpecificationFlags","ModuleSpecificationFlag","optModuleSpecificationBody", +"ModuleSpecificationBody","ModuleSpecificationElement","ImportsDefinition","ImportsBundleSet", +"ImportsBundle","ImportsList","ImportsElement","ExportsDefinition","ExportsBody", +"ExportsElement","ValueSetDefinition","DefinedTypeRef","optValueSetBody","DataTypeReference", +"ParameterArgumentList","ParameterArgumentName","ActualParameterList","ActualParameter", +"ConstructedDataTypeDefinition","ClassDeclaration","optUnique","ClassFieldList", +"ClassField","optWithSyntax","WithSyntax","@1","WithSyntaxFormat","WithSyntaxFormatToken", +"DataTypeMember","ConstrainedTypeDeclaration","ExtensionAndException","TypeDeclaration", +"ComplexTypeReference","ComplexTypeReferenceAmpList","ComplexTypeReferenceElement", +"ClassFieldIdentifier","ClassFieldName","ValueDefinition","InlineOrDefinedValue", +"@2","DefinedValue","Opaque","BasicTypeId","BasicTypeId_UniverationCompatible", +"BasicType","BasicString","ConstructedType","optConstraints","Union","Intersection", +"Except","Constraints","SingleConstraint","ConstraintElementSet","ConstraintElement", +"ConstraintElementUnion","ConstraintElementIntersection","ConstraintElementException", +"ConstraintSubtypeElement","ConstraintRangeSpec","ConstraintSpec","ConstraintValue", +"WithComponents","WithComponentsList","WithComponentsElement","optPresenceConstraint", +"PresenceConstraint","TableConstraint","SimpleTableConstraint","ComponentRelationConstraint", +"AtNotationList","AtNotationElement","ComponentIdList","optMarker","Marker", +"DefaultValue","@3","UniverationDefinition","UniverationList","UniverationElement", +"SignedNumber","optTag","Tag","TypeRefName","ObjectClassReference","Identifier", +"TaggedIdentifier", NULL +}; +#endif + +static const short yyr1[] = { 0, + 113, 114, 114, 115, 116, 116, 117, 117, 118, 118, + 119, 119, 119, 120, 120, 121, 121, 122, 122, 122, + 122, 123, 123, 124, 124, 125, 125, 125, 125, 125, + 125, 126, 126, 127, 127, 128, 129, 129, 130, 130, + 131, 131, 131, 132, 132, 133, 133, 134, 135, 135, + 136, 136, 137, 137, 137, 137, 138, 138, 139, 139, + 139, 140, 140, 141, 141, 142, 142, 143, 144, 144, + 145, 145, 146, 146, 146, 147, 147, 149, 148, 150, + 150, 151, 151, 152, 152, 153, 154, 154, 154, 155, + 155, 155, 155, 155, 155, 156, 156, 156, 156, 156, + 157, 157, 158, 159, 160, 160, 161, 163, 162, 162, + 162, 162, 162, 162, 164, 164, 165, 165, 166, 166, + 166, 166, 166, 166, 166, 166, 166, 166, 166, 166, + 167, 167, 167, 168, 168, 169, 169, 169, 169, 169, + 169, 169, 169, 169, 169, 169, 169, 169, 169, 170, + 170, 170, 170, 170, 170, 170, 171, 171, 172, 172, + 173, 173, 174, 175, 175, 175, 176, 177, 177, 177, + 177, 177, 178, 179, 179, 180, 180, 181, 181, 182, + 182, 182, 182, 182, 183, 183, 183, 183, 184, 184, + 185, 185, 185, 185, 185, 185, 185, 186, 187, 187, + 188, 188, 189, 189, 190, 190, 190, 191, 191, 192, + 193, 194, 194, 195, 195, 196, 196, 197, 197, 198, + 198, 199, 199, 200, 199, 201, 201, 202, 202, 203, + 203, 203, 203, 203, 204, 204, 205, 205, 206, 206, + 206, 207, 207, 208, 209, 210, 210 +}; + +static const short yyr2[] = { 0, + 1, 1, 2, 8, 0, 1, 3, 2, 1, 2, + 1, 4, 1, 0, 1, 1, 2, 2, 2, 2, + 2, 0, 1, 1, 2, 1, 1, 1, 1, 1, + 1, 3, 2, 1, 2, 4, 1, 3, 1, 1, + 3, 3, 2, 1, 3, 1, 1, 6, 1, 1, + 0, 1, 4, 4, 3, 6, 1, 3, 1, 3, + 3, 1, 3, 1, 1, 1, 3, 5, 0, 1, + 1, 3, 2, 3, 4, 0, 1, 0, 6, 1, + 2, 1, 1, 2, 1, 3, 1, 3, 3, 1, + 1, 1, 4, 1, 3, 1, 3, 3, 1, 3, + 1, 3, 1, 1, 1, 1, 4, 0, 3, 1, + 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, + 1, 1, 2, 2, 1, 1, 2, 2, 1, 1, + 1, 1, 2, 1, 2, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, + 4, 4, 4, 4, 1, 4, 0, 1, 1, 1, + 1, 1, 1, 4, 1, 2, 3, 1, 3, 5, + 1, 3, 1, 1, 3, 1, 3, 1, 3, 1, + 3, 4, 1, 1, 1, 2, 2, 3, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 5, 1, 3, + 1, 3, 0, 1, 1, 1, 1, 1, 1, 3, + 4, 1, 3, 2, 3, 1, 3, 0, 1, 1, + 2, 1, 1, 0, 3, 2, 3, 1, 3, 1, + 4, 4, 1, 1, 1, 1, 0, 1, 1, 2, + 2, 1, 1, 1, 1, 1, 2 +}; + +static const short yydefact[] = { 0, + 242, 243, 1, 2, 5, 3, 0, 0, 6, 245, + 13, 8, 0, 9, 11, 14, 7, 10, 0, 0, + 0, 0, 0, 0, 15, 16, 0, 20, 18, 21, + 19, 0, 17, 12, 22, 136, 0, 137, 138, 139, + 0, 140, 141, 149, 142, 143, 144, 145, 146, 147, + 148, 0, 23, 24, 26, 27, 30, 28, 29, 31, + 0, 0, 0, 43, 0, 44, 46, 47, 33, 0, + 34, 0, 37, 39, 40, 4, 25, 237, 96, 244, + 0, 119, 0, 0, 132, 126, 130, 131, 120, 0, + 0, 121, 125, 129, 0, 0, 49, 50, 122, 99, + 0, 42, 41, 0, 32, 35, 0, 0, 0, 239, + 55, 0, 238, 0, 133, 128, 127, 124, 123, 0, + 57, 0, 59, 0, 0, 0, 45, 5, 38, 0, + 241, 240, 96, 244, 155, 0, 0, 157, 157, 53, + 54, 157, 94, 134, 122, 90, 91, 92, 0, 97, + 98, 0, 0, 0, 0, 51, 105, 106, 100, 101, + 103, 110, 112, 111, 235, 236, 108, 107, 114, 113, + 0, 115, 36, 0, 71, 218, 104, 0, 0, 0, + 0, 0, 0, 0, 158, 165, 0, 0, 218, 0, + 135, 0, 0, 58, 61, 60, 193, 196, 190, 195, + 194, 189, 197, 0, 171, 0, 0, 52, 168, 173, + 174, 176, 178, 0, 180, 184, 183, 208, 209, 191, + 192, 0, 0, 0, 76, 0, 0, 220, 69, 218, + 73, 219, 0, 87, 0, 66, 85, 246, 0, 95, + 0, 0, 0, 0, 166, 0, 0, 86, 234, 226, + 0, 228, 233, 230, 0, 62, 64, 65, 56, 0, + 0, 0, 48, 0, 159, 160, 0, 161, 162, 0, + 163, 0, 0, 185, 0, 0, 0, 102, 117, 109, + 116, 0, 68, 77, 72, 224, 223, 222, 221, 70, + 74, 69, 156, 0, 150, 0, 247, 84, 0, 151, + 167, 153, 152, 154, 227, 0, 0, 93, 0, 0, + 172, 210, 169, 175, 177, 179, 0, 186, 187, 181, + 0, 0, 212, 118, 0, 0, 75, 88, 89, 67, + 164, 229, 0, 0, 63, 201, 0, 199, 157, 0, + 182, 188, 0, 214, 216, 211, 0, 78, 225, 232, + 231, 198, 0, 203, 170, 215, 0, 213, 0, 200, + 206, 207, 205, 202, 204, 217, 82, 0, 80, 83, + 79, 81, 0, 0, 0 +}; + +static const short yydefgoto[] = { 373, + 3, 4, 8, 9, 13, 14, 24, 25, 26, 52, + 53, 54, 55, 70, 71, 72, 73, 56, 65, 66, + 57, 96, 207, 58, 120, 121, 255, 256, 235, 111, + 291, 174, 175, 283, 284, 359, 368, 369, 236, 141, + 237, 142, 143, 159, 160, 176, 177, 59, 168, 223, + 169, 280, 144, 145, 146, 147, 148, 184, 267, 270, + 272, 185, 186, 208, 209, 210, 211, 212, 213, 276, + 214, 215, 216, 337, 338, 364, 365, 217, 218, 219, + 322, 323, 344, 231, 232, 289, 326, 191, 251, 252, + 220, 112, 113, 149, 100, 221, 239 +}; + +static const short yypact[] = { 81, +-32768,-32768, 81,-32768, -45,-32768, 23, 70,-32768,-32768, +-32768,-32768, 47,-32768, 31, 190,-32768,-32768, 132, 61, + 69, 108, 86, 176, 190,-32768, 76,-32768,-32768,-32768, +-32768, 166,-32768,-32768, 442,-32768, 32,-32768,-32768,-32768, + 121,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, 168, 442,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + 179, 732, 103,-32768, 52,-32768,-32768,-32768,-32768, 39, +-32768, 16,-32768,-32768,-32768,-32768,-32768, -11, 111,-32768, + 150,-32768, 152, 142,-32768,-32768,-32768,-32768,-32768, 184, + 159,-32768,-32768,-32768, 748, 240,-32768,-32768,-32768, 135, + 243,-32768,-32768, 141,-32768,-32768, 81, 141, 145, 60, +-32768, 599,-32768, 141,-32768,-32768,-32768,-32768,-32768, -1, +-32768, 143, 144, 147, 206, 68,-32768, -45,-32768, 206, +-32768,-32768, -42, 148, 221, 161, 198, 40, 53,-32768, +-32768, -37,-32768,-32768, 163,-32768,-32768,-32768, 164,-32768, +-32768, 264, 748, 261, 261, 155,-32768,-32768, 160,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + 162,-32768,-32768, 64,-32768, 524,-32768, 246, 21, 212, + 169, 21, 155, 208, 171,-32768, 21, 210, 2, 17, +-32768, 383, 674,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768,-32768,-32768, 247, 172, 81, 175,-32768, 173, 133, + 140, 185,-32768, 178, 35,-32768,-32768, 182,-32768,-32768, +-32768, 206, 281, 261, 193, 206, 301,-32768, 202, 2, +-32768,-32768, 261, 181, 66,-32768,-32768, 191, 674,-32768, + 155, 71, 186, 674,-32768, 89, 674,-32768,-32768,-32768, + 90,-32768,-32768, 189, 91,-32768,-32768,-32768,-32768, 192, + 309, 194,-32768, 196,-32768,-32768, 309,-32768,-32768, 309, +-32768, 309, 155, 187, 205, 78, 200,-32768,-32768, 297, +-32768, 225,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, +-32768, 202,-32768, 250,-32768, 21,-32768,-32768, 201,-32768, +-32768,-32768,-32768,-32768,-32768, 56, 250,-32768, 383, 25, +-32768,-32768, 209, 140, 185,-32768, 215,-32768, 211,-32768, + 6, 101,-32768,-32768, 219, 281,-32768,-32768,-32768,-32768, +-32768,-32768, 223, 224,-32768,-32768, 109,-32768, -37, 309, +-32768,-32768, 261, 203,-32768,-32768, 200,-32768, 297,-32768, +-32768,-32768, 25, 24,-32768, 203, 261,-32768, 126,-32768, +-32768,-32768,-32768,-32768,-32768,-32768,-32768, 9,-32768,-32768, +-32768,-32768, 324, 326,-32768 +}; + +static const short yypgoto[] = {-32768, +-32768, 327, 204,-32768,-32768, 318,-32768,-32768, 308,-32768, +-32768, 282,-32768,-32768, 268,-32768, 226,-32768,-32768, 235, +-32768, 279,-32768,-32768,-32768, 195,-32768, 33, -129,-32768, + 51,-32768, 123,-32768,-32768,-32768,-32768, -17, 59, -156, +-32768, -185, -52,-32768, 130, -173, -109,-32768,-32768,-32768, + -209, 30, -50, -43,-32768, 46,-32768, -137,-32768,-32768, +-32768,-32768, 180, -159, -246,-32768, 94, 88, 97,-32768, +-32768, -206,-32768,-32768, 10,-32768,-32768,-32768,-32768,-32768, +-32768, 26, 27, -141,-32768,-32768,-32768,-32768,-32768, 65, + -118,-32768, 134, 1,-32768, -7,-32768 +}; + + +#define YYLAST 837 + + +static const short yytable[] = { 15, + 5, 188, 230, 5, 189, 15, 257, 170, 97, 97, + 98, 98, 367, 10, 311, 161, 109, 99, 99, 229, + 288, 157, 158, 243, 10, 165, 166, 62, 10, 68, + 10, 11, 10, 75, 227, 61, 259, 67, 361, 10, + 181, 74, 1, 2, 122, 62, 10, 248, 63, 1, + 2, 99, 242, 61, 10, 11, 7, 246, 302, -242, + 107, 304, 75, 10, 165, 166, 183, 114, 228, 320, + 74, 253, 162, 163, 164, 10, 165, 166, 1, 2, + 60, 299, 298, 197, 328, 10, 165, 166, 292, 110, + 362, 1, 2, 355, 363, 123, 68, 333, 60, 131, + 75, 152, 122, 16, 67, 153, 151, 128, 74, 99, + 132, 371, 161, 317, 150, 343, 249, 181, 172, 250, + 234, 198, 108, 257, 336, 12, 171, 240, 10, 367, + 181, 1, 2, 274, 19, 200, 201, 64, 157, 158, + 27, 182, 28, 183, 105, 275, 195, 196, 10, 17, + 29, 1, 2, 123, 187, 249, 183, 103, 104, 30, + 197, 203, 10, 165, 166, 69, 225, 31, 295, 167, + 226, 238, 296, 300, 238, 329, 287, 296, 32, 238, + 34, 78, 254, 99, 258, 370, 35, 253, 334, 79, + 80, 303, 305, 308, 370, 296, 306, 309, 198, 199, + 81, 354, 82, 346, 83, 76, 262, 347, 102, 20, + 117, 352, 200, 201, 84, 353, 281, 85, 157, 158, + 114, 86, 79, 80, 87, 293, 265, 266, 115, 21, + 116, 22, 202, 118, 88, 268, 269, 119, 203, 89, + 23, 90, 124, 91, 125, 126, 130, 204, 156, -243, + 154, 155, 92, 93, 205, 178, 206, 10, 165, 166, + 1, 2, 179, 180, 190, 192, 193, 94, 10, 222, + 233, 224, 241, 244, 183, 247, 260, 263, 261, 264, + 95, 273, 271, 277, 279, 282, 172, 290, 238, 294, + 301, 110, 307, 310, 171, 313, 312, 318, 254, 172, + 324, 258, 339, 319, 325, 331, 197, 171, 10, 165, + 166, 321, 357, 345, 197, 340, 10, 165, 166, 341, + 348, 342, 81, 374, 82, 375, 83, 350, 351, 6, + 18, 173, 33, 129, 77, 345, 84, 106, 127, 85, + 101, 335, 327, 86, 198, 339, 87, 194, 285, 366, + 372, 278, 198, 199, 330, 349, 88, 315, 200, 201, + 314, 89, 360, 90, 245, 91, 200, 201, 316, 356, + 332, 297, 358, 0, 92, 93, 0, 0, 0, 0, + 0, 0, 0, 0, 203, 0, 202, 0, 0, 94, + 10, 0, 203, 133, 134, 0, 0, 0, 0, 0, + 135, 204, 286, 0, 81, 36, 82, 0, 83, 136, + 206, 0, 0, 0, 0, 0, 0, 0, 84, 0, + 0, 85, 0, 0, 0, 86, 0, 0, 87, 38, + 39, 40, 0, 0, 0, 0, 0, 137, 88, 42, + 0, 0, 0, 89, 43, 90, 44, 91, 0, 10, + 0, 0, 1, 2, 45, 0, 92, 93, 138, 139, + 0, 0, 0, 46, 36, 47, 0, 0, 0, 0, + 48, 94, 49, 50, 51, 0, 0, 0, 0, 0, + 0, 0, 37, 0, 0, 0, 0, 0, 38, 39, + 40, 0, 0, 0, 41, 0, 0, 0, 42, 0, + 0, 0, 0, 43, 0, 44, 0, 0, 0, 0, + 0, 0, 0, 45, 0, 0, 0, 0, 0, 0, + 0, 0, 46, 0, 47, 0, 0, 0, 0, 48, + 0, 49, 50, 51, 133, 134, 157, 158, 0, 0, + 0, 135, 0, 0, 0, 81, 36, 82, 0, 83, + 136, 0, 0, 0, 0, 0, 227, 0, 0, 84, + 0, 0, 85, 0, 0, 0, 86, 0, 0, 87, + 38, 39, 40, 0, 0, 0, 0, 0, 137, 88, + 42, 0, 0, 0, 89, 43, 90, 44, 91, 0, + 228, 0, 0, 0, 0, 45, 0, 92, 93, 138, + 139, 0, 0, 0, 46, 0, 47, 0, 0, 133, + 134, 48, 94, 49, 50, 51, 135, 0, 0, 0, + 81, 36, 82, 0, 83, 136, 0, 0, 0, 0, + 0, 0, 0, 0, 84, 0, 0, 85, 0, 0, + 0, 86, 0, 0, 87, 38, 39, 40, 0, 0, + 0, 0, 0, 137, 88, 42, 0, 0, 0, 89, + 43, 90, 44, 91, 0, 0, 0, 0, 0, 0, + 45, 0, 92, 93, 138, 139, 0, 0, 0, 46, + 0, 47, 0, 140, 133, 134, 48, 94, 49, 50, + 51, 135, 0, 0, 0, 81, 36, 82, 0, 83, + 136, 0, 0, 0, 0, 0, 0, 0, 0, 84, + 0, 0, 85, 0, 0, 0, 86, 0, 0, 87, + 38, 39, 40, 0, 0, 0, 0, 0, 137, 88, + 42, 0, 0, 0, 89, 43, 90, 44, 91, 0, + 0, 0, 79, 80, 0, 45, 0, 92, 93, 138, + 139, 0, 0, 81, 46, 82, 47, 83, 1, 2, + 0, 48, 94, 49, 50, 51, 0, 84, 0, 81, + 85, 82, 0, 83, 86, 0, 0, 87, 0, 0, + 0, 0, 0, 84, 0, 0, 85, 88, 0, 0, + 86, 0, 89, 87, 90, 0, 91, 0, 0, 0, + 0, 0, 0, 88, 0, 92, 93, 0, 89, 0, + 90, 0, 91, 0, 0, 0, 0, 0, 0, 0, + 94, 92, 93, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 94 +}; + +static const short yycheck[] = { 7, + 0, 139, 176, 3, 142, 13, 192, 126, 61, 62, + 61, 62, 4, 8, 261, 125, 28, 61, 62, 176, + 227, 13, 14, 183, 8, 9, 10, 35, 8, 37, + 8, 9, 8, 41, 33, 35, 193, 37, 15, 8, + 78, 41, 11, 12, 95, 53, 8, 189, 17, 11, + 12, 95, 182, 53, 8, 9, 102, 187, 244, 102, + 45, 247, 70, 8, 9, 10, 104, 110, 67, 276, + 70, 190, 5, 6, 7, 8, 9, 10, 11, 12, + 35, 241, 239, 6, 294, 8, 9, 10, 230, 101, + 67, 11, 12, 340, 71, 95, 104, 307, 53, 40, + 108, 103, 153, 34, 104, 107, 114, 107, 108, 153, + 51, 103, 222, 273, 114, 110, 100, 78, 126, 103, + 100, 44, 107, 309, 100, 103, 126, 180, 8, 4, + 78, 11, 12, 99, 104, 58, 59, 106, 13, 14, + 9, 102, 82, 104, 106, 111, 154, 155, 8, 103, + 82, 11, 12, 153, 102, 100, 104, 106, 107, 52, + 6, 84, 8, 9, 10, 45, 103, 82, 103, 102, + 107, 179, 107, 103, 182, 294, 227, 107, 3, 187, + 105, 3, 190, 227, 192, 359, 21, 306, 307, 11, + 12, 103, 103, 103, 368, 107, 107, 107, 44, 45, + 22, 339, 24, 103, 26, 38, 206, 107, 106, 20, + 69, 103, 58, 59, 36, 107, 224, 39, 13, 14, + 110, 43, 11, 12, 46, 233, 94, 95, 79, 40, + 79, 42, 78, 50, 56, 96, 97, 79, 84, 61, + 51, 63, 3, 65, 110, 3, 102, 93, 102, 102, + 108, 108, 74, 75, 100, 35, 102, 8, 9, 10, + 11, 12, 102, 66, 102, 102, 3, 89, 8, 110, + 25, 110, 104, 66, 104, 66, 30, 103, 107, 107, + 102, 104, 98, 102, 4, 93, 294, 86, 296, 109, + 105, 101, 104, 102, 294, 100, 103, 111, 306, 307, + 4, 309, 310, 99, 80, 105, 6, 307, 8, 9, + 10, 112, 110, 321, 6, 107, 8, 9, 10, 105, + 102, 111, 22, 0, 24, 0, 26, 105, 105, 3, + 13, 128, 25, 108, 53, 343, 36, 70, 104, 39, + 62, 309, 292, 43, 44, 353, 46, 153, 226, 357, + 368, 222, 44, 45, 296, 326, 56, 270, 58, 59, + 267, 61, 353, 63, 185, 65, 58, 59, 272, 343, + 306, 238, 347, -1, 74, 75, -1, -1, -1, -1, + -1, -1, -1, -1, 84, -1, 78, -1, -1, 89, + 8, -1, 84, 11, 12, -1, -1, -1, -1, -1, + 18, 93, 102, -1, 22, 23, 24, -1, 26, 27, + 102, -1, -1, -1, -1, -1, -1, -1, 36, -1, + -1, 39, -1, -1, -1, 43, -1, -1, 46, 47, + 48, 49, -1, -1, -1, -1, -1, 55, 56, 57, + -1, -1, -1, 61, 62, 63, 64, 65, -1, 8, + -1, -1, 11, 12, 72, -1, 74, 75, 76, 77, + -1, -1, -1, 81, 23, 83, -1, -1, -1, -1, + 88, 89, 90, 91, 92, -1, -1, -1, -1, -1, + -1, -1, 41, -1, -1, -1, -1, -1, 47, 48, + 49, -1, -1, -1, 53, -1, -1, -1, 57, -1, + -1, -1, -1, 62, -1, 64, -1, -1, -1, -1, + -1, -1, -1, 72, -1, -1, -1, -1, -1, -1, + -1, -1, 81, -1, 83, -1, -1, -1, -1, 88, + -1, 90, 91, 92, 11, 12, 13, 14, -1, -1, + -1, 18, -1, -1, -1, 22, 23, 24, -1, 26, + 27, -1, -1, -1, -1, -1, 33, -1, -1, 36, + -1, -1, 39, -1, -1, -1, 43, -1, -1, 46, + 47, 48, 49, -1, -1, -1, -1, -1, 55, 56, + 57, -1, -1, -1, 61, 62, 63, 64, 65, -1, + 67, -1, -1, -1, -1, 72, -1, 74, 75, 76, + 77, -1, -1, -1, 81, -1, 83, -1, -1, 11, + 12, 88, 89, 90, 91, 92, 18, -1, -1, -1, + 22, 23, 24, -1, 26, 27, -1, -1, -1, -1, + -1, -1, -1, -1, 36, -1, -1, 39, -1, -1, + -1, 43, -1, -1, 46, 47, 48, 49, -1, -1, + -1, -1, -1, 55, 56, 57, -1, -1, -1, 61, + 62, 63, 64, 65, -1, -1, -1, -1, -1, -1, + 72, -1, 74, 75, 76, 77, -1, -1, -1, 81, + -1, 83, -1, 85, 11, 12, 88, 89, 90, 91, + 92, 18, -1, -1, -1, 22, 23, 24, -1, 26, + 27, -1, -1, -1, -1, -1, -1, -1, -1, 36, + -1, -1, 39, -1, -1, -1, 43, -1, -1, 46, + 47, 48, 49, -1, -1, -1, -1, -1, 55, 56, + 57, -1, -1, -1, 61, 62, 63, 64, 65, -1, + -1, -1, 11, 12, -1, 72, -1, 74, 75, 76, + 77, -1, -1, 22, 81, 24, 83, 26, 11, 12, + -1, 88, 89, 90, 91, 92, -1, 36, -1, 22, + 39, 24, -1, 26, 43, -1, -1, 46, -1, -1, + -1, -1, -1, 36, -1, -1, 39, 56, -1, -1, + 43, -1, 61, 46, 63, -1, 65, -1, -1, -1, + -1, -1, -1, 56, -1, 74, 75, -1, 61, -1, + 63, -1, 65, -1, -1, -1, -1, -1, -1, -1, + 89, 74, 75, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 89 +}; +/* -*-C-*- Note some compilers choke on comments on `#line' lines. */ +#line 3 "/usr/share/bison.simple" +/* This file comes from bison-1.28. */ + +/* Skeleton output parser for bison, + Copyright (C) 1984, 1989, 1990 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +/* As a special exception, when this file is copied by Bison into a + Bison output file, you may use that output file without restriction. + This special exception was added by the Free Software Foundation + in version 1.24 of Bison. */ + +/* This is the parser code that is written into each bison parser + when the %semantic_parser declaration is not specified in the grammar. + It was written by Richard Stallman by simplifying the hairy parser + used when %semantic_parser is specified. */ + +#ifndef YYSTACK_USE_ALLOCA +#ifdef alloca +#define YYSTACK_USE_ALLOCA +#else /* alloca not defined */ +#ifdef __GNUC__ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#else /* not GNU C. */ +#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386)) +#define YYSTACK_USE_ALLOCA +#include +#else /* not sparc */ +/* We think this test detects Watcom and Microsoft C. */ +/* This used to test MSDOS, but that is a bad idea + since that symbol is in the user namespace. */ +#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__) +#if 0 /* No need for malloc.h, which pollutes the namespace; + instead, just don't use alloca. */ +#include +#endif +#else /* not MSDOS, or __TURBOC__ */ +#if defined(_AIX) +/* I don't know what this was needed for, but it pollutes the namespace. + So I turned it off. rms, 2 May 1997. */ +/* #include */ + #pragma alloca +#define YYSTACK_USE_ALLOCA +#else /* not MSDOS, or __TURBOC__, or _AIX */ +#if 0 +#ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up, + and on HPUX 10. Eventually we can turn this on. */ +#define YYSTACK_USE_ALLOCA +#define alloca __builtin_alloca +#endif /* __hpux */ +#endif +#endif /* not _AIX */ +#endif /* not MSDOS, or __TURBOC__ */ +#endif /* not sparc */ +#endif /* not GNU C */ +#endif /* alloca not defined */ +#endif /* YYSTACK_USE_ALLOCA not defined */ + +#ifdef YYSTACK_USE_ALLOCA +#define YYSTACK_ALLOC alloca +#else +#define YYSTACK_ALLOC malloc +#endif + +/* Note: there must be only one dollar sign in this file. + It is replaced by the list of actions, each action + as one case of the switch. */ + +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY -2 +#define YYEOF 0 +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrlab1 +/* Like YYERROR except do call yyerror. + This remains here temporarily to ease the + transition to the new meaning of YYERROR, for GCC. + Once GCC version 2 has supplanted version 1, this can go. */ +#define YYFAIL goto yyerrlab +#define YYRECOVERING() (!!yyerrstatus) +#define YYBACKUP(token, value) \ +do \ + if (yychar == YYEMPTY && yylen == 1) \ + { yychar = (token), yylval = (value); \ + yychar1 = YYTRANSLATE (yychar); \ + YYPOPSTACK; \ + goto yybackup; \ + } \ + else \ + { yyerror ("syntax error: cannot back up"); YYERROR; } \ +while (0) + +#define YYTERROR 1 +#define YYERRCODE 256 + +#ifndef YYPURE +#define YYLEX yylex() +#endif + +#ifdef YYPURE +#ifdef YYLSP_NEEDED +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval, &yylloc) +#endif +#else /* not YYLSP_NEEDED */ +#ifdef YYLEX_PARAM +#define YYLEX yylex(&yylval, YYLEX_PARAM) +#else +#define YYLEX yylex(&yylval) +#endif +#endif /* not YYLSP_NEEDED */ +#endif + +/* If nonreentrant, generate the variables here */ + +#ifndef YYPURE + +int yychar; /* the lookahead symbol */ +YYSTYPE yylval; /* the semantic value of the */ + /* lookahead symbol */ + +#ifdef YYLSP_NEEDED +YYLTYPE yylloc; /* location data for the lookahead */ + /* symbol */ +#endif + +int yynerrs; /* number of parse errors so far */ +#endif /* not YYPURE */ + +#if YYDEBUG != 0 +int yydebug; /* nonzero means print parse trace */ +/* Since this is uninitialized, it does not stop multiple parsers + from coexisting. */ +#endif + +/* YYINITDEPTH indicates the initial size of the parser's stacks */ + +#ifndef YYINITDEPTH +#define YYINITDEPTH 200 +#endif + +/* YYMAXDEPTH is the maximum size the stacks can grow to + (effective only if the built-in stack extension method is used). */ + +#if YYMAXDEPTH == 0 +#undef YYMAXDEPTH +#endif + +#ifndef YYMAXDEPTH +#define YYMAXDEPTH 10000 +#endif + +/* Define __yy_memcpy. Note that the size argument + should be passed with type unsigned int, because that is what the non-GCC + definitions require. With GCC, __builtin_memcpy takes an arg + of type size_t, but it can handle unsigned int. */ + +#if __GNUC__ > 1 /* GNU C and GNU C++ define this. */ +#define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT) +#else /* not GNU C or C++ */ +#ifndef __cplusplus + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (to, from, count) + char *to; + char *from; + unsigned int count; +{ + register char *f = from; + register char *t = to; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#else /* __cplusplus */ + +/* This is the most reliable way to avoid incompatibilities + in available built-in functions on various systems. */ +static void +__yy_memcpy (char *to, char *from, unsigned int count) +{ + register char *t = to; + register char *f = from; + register int i = count; + + while (i-- > 0) + *t++ = *f++; +} + +#endif +#endif + +#line 217 "/usr/share/bison.simple" + +/* The user can define YYPARSE_PARAM as the name of an argument to be passed + into yyparse. The argument should have type void *. + It should actually point to an object. + Grammar actions can access the variable by casting it + to the proper pointer type. */ + +#ifdef YYPARSE_PARAM +#ifdef __cplusplus +#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM +#define YYPARSE_PARAM_DECL +#else /* not __cplusplus */ +#define YYPARSE_PARAM_ARG YYPARSE_PARAM +#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM; +#endif /* not __cplusplus */ +#else /* not YYPARSE_PARAM */ +#define YYPARSE_PARAM_ARG +#define YYPARSE_PARAM_DECL +#endif /* not YYPARSE_PARAM */ + +/* Prevent warning if -Wstrict-prototypes. */ +#ifdef __GNUC__ +#ifdef YYPARSE_PARAM +int yyparse (void *); +#else +int yyparse (void); +#endif +#endif + +int +yyparse(YYPARSE_PARAM_ARG) + YYPARSE_PARAM_DECL +{ + register int yystate; + register int yyn; + register short *yyssp; + register YYSTYPE *yyvsp; + int yyerrstatus; /* number of tokens to shift before error messages enabled */ + int yychar1 = 0; /* lookahead token as an internal (translated) token number */ + + short yyssa[YYINITDEPTH]; /* the state stack */ + YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */ + + short *yyss = yyssa; /* refer to the stacks thru separate pointers */ + YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */ + +#ifdef YYLSP_NEEDED + YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */ + YYLTYPE *yyls = yylsa; + YYLTYPE *yylsp; + +#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--) +#else +#define YYPOPSTACK (yyvsp--, yyssp--) +#endif + + int yystacksize = YYINITDEPTH; + int yyfree_stacks = 0; + +#ifdef YYPURE + int yychar; + YYSTYPE yylval; + int yynerrs; +#ifdef YYLSP_NEEDED + YYLTYPE yylloc; +#endif +#endif + + YYSTYPE yyval; /* the variable used to return */ + /* semantic values from the action */ + /* routines */ + + int yylen; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Starting parse\n"); +#endif + + yystate = 0; + yyerrstatus = 0; + yynerrs = 0; + yychar = YYEMPTY; /* Cause a token to be read. */ + + /* Initialize stack pointers. + Waste one element of value and location stack + so that they stay on the same level as the state stack. + The wasted elements are never initialized. */ + + yyssp = yyss - 1; + yyvsp = yyvs; +#ifdef YYLSP_NEEDED + yylsp = yyls; +#endif + +/* Push a new state, which is found in yystate . */ +/* In all cases, when you get here, the value and location stacks + have just been pushed. so pushing a state here evens the stacks. */ +yynewstate: + + *++yyssp = yystate; + + if (yyssp >= yyss + yystacksize - 1) + { + /* Give user a chance to reallocate the stack */ + /* Use copies of these so that the &'s don't force the real ones into memory. */ + YYSTYPE *yyvs1 = yyvs; + short *yyss1 = yyss; +#ifdef YYLSP_NEEDED + YYLTYPE *yyls1 = yyls; +#endif + + /* Get the current used size of the three stacks, in elements. */ + int size = yyssp - yyss + 1; + +#ifdef yyoverflow + /* Each stack pointer address is followed by the size of + the data in use in that stack, in bytes. */ +#ifdef YYLSP_NEEDED + /* This used to be a conditional around just the two extra args, + but that might be undefined if yyoverflow is a macro. */ + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yyls1, size * sizeof (*yylsp), + &yystacksize); +#else + yyoverflow("parser stack overflow", + &yyss1, size * sizeof (*yyssp), + &yyvs1, size * sizeof (*yyvsp), + &yystacksize); +#endif + + yyss = yyss1; yyvs = yyvs1; +#ifdef YYLSP_NEEDED + yyls = yyls1; +#endif +#else /* no yyoverflow */ + /* Extend the stack our own way. */ + if (yystacksize >= YYMAXDEPTH) + { + yyerror("parser stack overflow"); + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 2; + } + yystacksize *= 2; + if (yystacksize > YYMAXDEPTH) + yystacksize = YYMAXDEPTH; +#ifndef YYSTACK_USE_ALLOCA + yyfree_stacks = 1; +#endif + yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp)); + __yy_memcpy ((char *)yyss, (char *)yyss1, + size * (unsigned int) sizeof (*yyssp)); + yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp)); + __yy_memcpy ((char *)yyvs, (char *)yyvs1, + size * (unsigned int) sizeof (*yyvsp)); +#ifdef YYLSP_NEEDED + yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp)); + __yy_memcpy ((char *)yyls, (char *)yyls1, + size * (unsigned int) sizeof (*yylsp)); +#endif +#endif /* no yyoverflow */ + + yyssp = yyss + size - 1; + yyvsp = yyvs + size - 1; +#ifdef YYLSP_NEEDED + yylsp = yyls + size - 1; +#endif + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Stack size increased to %d\n", yystacksize); +#endif + + if (yyssp >= yyss + yystacksize - 1) + YYABORT; + } + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Entering state %d\n", yystate); +#endif + + goto yybackup; + yybackup: + +/* Do appropriate processing given the current state. */ +/* Read a lookahead token if we need one and don't already have one. */ +/* yyresume: */ + + /* First try to decide what to do without reference to lookahead token. */ + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yydefault; + + /* Not known => get a lookahead token if don't already have one. */ + + /* yychar is either YYEMPTY or YYEOF + or a valid token in external form. */ + + if (yychar == YYEMPTY) + { +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Reading a token: "); +#endif + yychar = YYLEX; + } + + /* Convert token to internal form (in yychar1) for indexing tables with */ + + if (yychar <= 0) /* This means end of input. */ + { + yychar1 = 0; + yychar = YYEOF; /* Don't call YYLEX any more */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Now at end of input.\n"); +#endif + } + else + { + yychar1 = YYTRANSLATE(yychar); + +#if YYDEBUG != 0 + if (yydebug) + { + fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]); + /* Give the individual parser a way to print the precise meaning + of a token, for further debugging info. */ +#ifdef YYPRINT + YYPRINT (stderr, yychar, yylval); +#endif + fprintf (stderr, ")\n"); + } +#endif + } + + yyn += yychar1; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1) + goto yydefault; + + yyn = yytable[yyn]; + + /* yyn is what to do for this token type in this state. + Negative => reduce, -yyn is rule number. + Positive => shift, yyn is new state. + New state is final state => don't bother to shift, + just return success. + 0, or most negative number => error. */ + + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrlab; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrlab; + + if (yyn == YYFINAL) + YYACCEPT; + + /* Shift the lookahead token. */ + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]); +#endif + + /* Discard the token being shifted unless it is eof. */ + if (yychar != YYEOF) + yychar = YYEMPTY; + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + /* count tokens shifted since error; after three, turn off error status. */ + if (yyerrstatus) yyerrstatus--; + + yystate = yyn; + goto yynewstate; + +/* Do the default action for the current state. */ +yydefault: + + yyn = yydefact[yystate]; + if (yyn == 0) + goto yyerrlab; + +/* Do a reduction. yyn is the number of a rule to reduce with. */ +yyreduce: + yylen = yyr2[yyn]; + if (yylen > 0) + yyval = yyvsp[1-yylen]; /* implement default value of the action */ + +#if YYDEBUG != 0 + if (yydebug) + { + int i; + + fprintf (stderr, "Reducing via rule %d (line %d), ", + yyn, yyrline[yyn]); + + /* Print the symbols being reduced, and their result. */ + for (i = yyprhs[yyn]; yyrhs[i] > 0; i++) + fprintf (stderr, "%s ", yytname[yyrhs[i]]); + fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]); + } +#endif + + + switch (yyn) { + +case 1: +#line 298 "asn1p_y.y" +{ + *(void **)param = yyvsp[0].a_grammar; + ; + break;} +case 2: +#line 304 "asn1p_y.y" +{ + yyval.a_grammar = asn1p_new(); + checkmem(yyval.a_grammar); + TQ_ADD(&(yyval.a_grammar->modules), yyvsp[0].a_module, mod_next); + ; + break;} +case 3: +#line 309 "asn1p_y.y" +{ + yyval.a_grammar = yyvsp[-1].a_grammar; + TQ_ADD(&(yyval.a_grammar->modules), yyvsp[0].a_module, mod_next); + ; + break;} +case 4: +#line 330 "asn1p_y.y" +{ + + if(yyvsp[-1].a_module) { + yyval.a_module = yyvsp[-1].a_module; + } else { + /* There's a chance that a module is just plain empty */ + yyval.a_module = asn1p_module_new(); + } + checkmem(yyval.a_module); + + yyval.a_module->Identifier = yyvsp[-7].tv_str; + yyval.a_module->module_oid = yyvsp[-6].a_oid; + yyval.a_module->module_flags = yyvsp[-4].a_module_flags; + ; + break;} +case 5: +#line 351 "asn1p_y.y" +{ yyval.a_oid = 0; ; + break;} +case 6: +#line 352 "asn1p_y.y" +{ yyval.a_oid = yyvsp[0].a_oid; ; + break;} +case 7: +#line 356 "asn1p_y.y" +{ + yyval.a_oid = yyvsp[-1].a_oid; + ; + break;} +case 8: +#line 359 "asn1p_y.y" +{ + yyval.a_oid = 0; + ; + break;} +case 9: +#line 365 "asn1p_y.y" +{ + yyval.a_oid = asn1p_oid_new(); + asn1p_oid_add_arc(yyval.a_oid, &yyvsp[0].a_oid_arc); + if(yyvsp[0].a_oid_arc.name) + free(yyvsp[0].a_oid_arc.name); + ; + break;} +case 10: +#line 371 "asn1p_y.y" +{ + yyval.a_oid = yyvsp[-1].a_oid; + asn1p_oid_add_arc(yyval.a_oid, &yyvsp[0].a_oid_arc); + if(yyvsp[0].a_oid_arc.name) + free(yyvsp[0].a_oid_arc.name); + ; + break;} +case 11: +#line 380 "asn1p_y.y" +{ /* iso */ + yyval.a_oid_arc.name = yyvsp[0].tv_str; + yyval.a_oid_arc.number = -1; + ; + break;} +case 12: +#line 384 "asn1p_y.y" +{ /* iso(1) */ + yyval.a_oid_arc.name = yyvsp[-3].tv_str; + yyval.a_oid_arc.number = yyvsp[-1].a_int; + ; + break;} +case 13: +#line 388 "asn1p_y.y" +{ /* 1 */ + yyval.a_oid_arc.name = 0; + yyval.a_oid_arc.number = yyvsp[0].a_int; + ; + break;} +case 14: +#line 398 "asn1p_y.y" +{ yyval.a_module_flags = MSF_NOFLAGS; ; + break;} +case 15: +#line 399 "asn1p_y.y" +{ + yyval.a_module_flags = yyvsp[0].a_module_flags; + ; + break;} +case 16: +#line 408 "asn1p_y.y" +{ + yyval.a_module_flags = yyvsp[0].a_module_flags; + ; + break;} +case 17: +#line 411 "asn1p_y.y" +{ + yyval.a_module_flags = yyvsp[-1].a_module_flags | yyvsp[0].a_module_flags; + ; + break;} +case 18: +#line 420 "asn1p_y.y" +{ + yyval.a_module_flags = MSF_EXPLICIT_TAGS; + ; + break;} +case 19: +#line 423 "asn1p_y.y" +{ + yyval.a_module_flags = MSF_IMPLICIT_TAGS; + ; + break;} +case 20: +#line 426 "asn1p_y.y" +{ + yyval.a_module_flags = MSF_AUTOMATIC_TAGS; + ; + break;} +case 21: +#line 429 "asn1p_y.y" +{ + yyval.a_module_flags = MSF_EXTENSIBILITY_IMPLIED; + ; + break;} +case 22: +#line 438 "asn1p_y.y" +{ yyval.a_module = 0; ; + break;} +case 23: +#line 439 "asn1p_y.y" +{ + assert(yyvsp[0].a_module); + yyval.a_module = yyvsp[0].a_module; + ; + break;} +case 24: +#line 449 "asn1p_y.y" +{ + yyval.a_module = yyvsp[0].a_module; + ; + break;} +case 25: +#line 452 "asn1p_y.y" +{ + yyval.a_module = yyvsp[-1].a_module; + +#ifdef MY_IMPORT +#error MY_IMPORT DEFINED ELSEWHERE! +#endif +#define MY_IMPORT(foo,field) do { \ + if(TQ_FIRST(&(yyvsp[0].a_module->foo))) { \ + TQ_ADD(&(yyval.a_module->foo), \ + TQ_REMOVE(&(yyvsp[0].a_module->foo), field), \ + field); \ + assert(TQ_FIRST(&(yyvsp[0].a_module->foo)) == 0); \ + } } while(0) + + MY_IMPORT(imports, xp_next); + MY_IMPORT(exports, xp_next); + MY_IMPORT(members, next); +#undef MY_IMPORT + + ; + break;} +case 26: +#line 478 "asn1p_y.y" +{ + yyval.a_module = yyvsp[0].a_module; + ; + break;} +case 27: +#line 481 "asn1p_y.y" +{ + yyval.a_module = asn1p_module_new(); + checkmem(yyval.a_module); + if(yyvsp[0].a_xports) { + TQ_ADD(&(yyval.a_module->exports), yyvsp[0].a_xports, xp_next); + } else { + /* "EXPORTS ALL;" ? */ + } + ; + break;} +case 28: +#line 490 "asn1p_y.y" +{ + yyval.a_module = asn1p_module_new(); + checkmem(yyval.a_module); + assert(yyvsp[0].a_expr->expr_type != A1TC_INVALID); + assert(yyvsp[0].a_expr->meta_type != AMT_INVALID); + TQ_ADD(&(yyval.a_module->members), yyvsp[0].a_expr, next); + ; + break;} +case 29: +#line 497 "asn1p_y.y" +{ + yyval.a_module = asn1p_module_new(); + checkmem(yyval.a_module); + assert(yyvsp[0].a_expr->expr_type != A1TC_INVALID); + assert(yyvsp[0].a_expr->meta_type != AMT_INVALID); + TQ_ADD(&(yyval.a_module->members), yyvsp[0].a_expr, next); + ; + break;} +case 30: +#line 510 "asn1p_y.y" +{ + yyval.a_module = asn1p_module_new(); + checkmem(yyval.a_module); + assert(yyvsp[0].a_expr->expr_type != A1TC_INVALID); + assert(yyvsp[0].a_expr->meta_type != AMT_INVALID); + TQ_ADD(&(yyval.a_module->members), yyvsp[0].a_expr, next); + ; + break;} +case 31: +#line 521 "asn1p_y.y" +{ + return yyerror( + "Attempt to redefine a standard basic type, " + "use -ftypesXY to switch back " + "to older version of ASN.1 standard"); + ; + break;} +case 32: +#line 535 "asn1p_y.y" +{ + yyval.a_module = yyvsp[-1].a_module; + ; + break;} +case 33: +#line 541 "asn1p_y.y" +{ + return yyerror("Empty IMPORTS list"); + ; + break;} +case 34: +#line 547 "asn1p_y.y" +{ + yyval.a_module = asn1p_module_new(); + checkmem(yyval.a_module); + TQ_ADD(&(yyval.a_module->imports), yyvsp[0].a_xports, xp_next); + ; + break;} +case 35: +#line 552 "asn1p_y.y" +{ + yyval.a_module = yyvsp[-1].a_module; + TQ_ADD(&(yyval.a_module->imports), yyvsp[0].a_xports, xp_next); + ; + break;} +case 36: +#line 559 "asn1p_y.y" +{ + yyval.a_xports = yyvsp[-3].a_xports; + yyval.a_xports->from = yyvsp[-1].tv_str; + yyval.a_xports->from_oid = yyvsp[0].a_oid; + checkmem(yyval.a_xports); + ; + break;} +case 37: +#line 568 "asn1p_y.y" +{ + yyval.a_xports = asn1p_xports_new(); + checkmem(yyval.a_xports); + TQ_ADD(&(yyval.a_xports->members), yyvsp[0].a_expr, next); + ; + break;} +case 38: +#line 573 "asn1p_y.y" +{ + yyval.a_xports = yyvsp[-2].a_xports; + TQ_ADD(&(yyval.a_xports->members), yyvsp[0].a_expr, next); + ; + break;} +case 39: +#line 580 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[0].tv_str; + yyval.a_expr->expr_type = A1TC_REFERENCE; + ; + break;} +case 40: +#line 586 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[0].tv_str; + yyval.a_expr->expr_type = A1TC_REFERENCE; + ; + break;} +case 41: +#line 595 "asn1p_y.y" +{ + yyval.a_xports = yyvsp[-1].a_xports; + ; + break;} +case 42: +#line 598 "asn1p_y.y" +{ + yyval.a_xports = 0; + ; + break;} +case 43: +#line 601 "asn1p_y.y" +{ + /* Empty EXPORTS clause effectively prohibits export. */ + yyval.a_xports = asn1p_xports_new(); + checkmem(yyval.a_xports); + ; + break;} +case 44: +#line 609 "asn1p_y.y" +{ + yyval.a_xports = asn1p_xports_new(); + assert(yyval.a_xports); + TQ_ADD(&(yyval.a_xports->members), yyvsp[0].a_expr, next); + ; + break;} +case 45: +#line 614 "asn1p_y.y" +{ + yyval.a_xports = yyvsp[-2].a_xports; + TQ_ADD(&(yyval.a_xports->members), yyvsp[0].a_expr, next); + ; + break;} +case 46: +#line 621 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[0].tv_str; + yyval.a_expr->expr_type = A1TC_EXPORTVAR; + ; + break;} +case 47: +#line 627 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[0].tv_str; + yyval.a_expr->expr_type = A1TC_EXPORTVAR; + ; + break;} +case 48: +#line 637 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-4].a_expr; + assert(yyval.a_expr->Identifier == 0); + yyval.a_expr->Identifier = yyvsp[-5].tv_str; + yyval.a_expr->meta_type = AMT_VALUESET; + // take care of optValueSetBody + ; + break;} +case 49: +#line 647 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->reference = yyvsp[0].a_ref; + yyval.a_expr->expr_type = A1TC_REFERENCE; + yyval.a_expr->meta_type = AMT_TYPEREF; + ; + break;} +case 50: +#line 654 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = yyvsp[0].a_type; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 51: +#line 663 "asn1p_y.y" +{ ; + break;} +case 52: +#line 664 "asn1p_y.y" +{ + ; + break;} +case 53: +#line 680 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[-3].tv_str; + yyval.a_expr->tag = yyvsp[-1].a_tag; + yyval.a_expr->expr_type = A1TC_TYPEID; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 54: +#line 688 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + yyval.a_expr->Identifier = yyvsp[-3].tv_str; + yyval.a_expr->tag = yyvsp[-1].a_tag; + assert(yyval.a_expr->expr_type); + assert(yyval.a_expr->meta_type); + ; + break;} +case 55: +#line 695 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + yyval.a_expr->Identifier = yyvsp[-2].tv_str; + assert(yyval.a_expr->expr_type == A1TC_CLASSDEF); + assert(yyval.a_expr->meta_type == AMT_OBJECT); + ; + break;} +case 56: +#line 712 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + assert(yyval.a_expr->Identifier == 0); + yyval.a_expr->Identifier = yyvsp[-5].tv_str; + yyval.a_expr->params = yyvsp[-3].a_plist; + yyval.a_expr->meta_type = AMT_PARAMTYPE; + ; + break;} +case 57: +#line 722 "asn1p_y.y" +{ + int ret; + yyval.a_plist = asn1p_paramlist_new(yylineno); + checkmem(yyval.a_plist); + ret = asn1p_paramlist_add_param(yyval.a_plist, yyvsp[0].a_parg.governor, yyvsp[0].a_parg.argument); + checkmem(ret == 0); + if(yyvsp[0].a_parg.governor) asn1p_ref_free(yyvsp[0].a_parg.governor); + if(yyvsp[0].a_parg.argument) free(yyvsp[0].a_parg.argument); + ; + break;} +case 58: +#line 731 "asn1p_y.y" +{ + int ret; + yyval.a_plist = yyvsp[-2].a_plist; + ret = asn1p_paramlist_add_param(yyval.a_plist, yyvsp[0].a_parg.governor, yyvsp[0].a_parg.argument); + checkmem(ret == 0); + if(yyvsp[0].a_parg.governor) asn1p_ref_free(yyvsp[0].a_parg.governor); + if(yyvsp[0].a_parg.argument) free(yyvsp[0].a_parg.argument); + ; + break;} +case 59: +#line 742 "asn1p_y.y" +{ + yyval.a_parg.governor = NULL; + yyval.a_parg.argument = yyvsp[0].tv_str; + ; + break;} +case 60: +#line 746 "asn1p_y.y" +{ + int ret; + yyval.a_parg.governor = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component(yyval.a_parg.governor, yyvsp[-2].tv_str, 0); + checkmem(ret == 0); + yyval.a_parg.argument = yyvsp[0].tv_str; + ; + break;} +case 61: +#line 753 "asn1p_y.y" +{ + int ret; + yyval.a_parg.governor = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component(yyval.a_parg.governor, + ASN_EXPR_TYPE2STR(yyvsp[-2].a_type), 1); + checkmem(ret == 0); + yyval.a_parg.argument = yyvsp[0].tv_str; + ; + break;} +case 62: +#line 764 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 63: +#line 769 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 64: +#line 776 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + ; + break;} +case 65: +#line 779 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[0].tv_str; + yyval.a_expr->expr_type = A1TC_REFERENCE; + yyval.a_expr->meta_type = AMT_VALUE; + ; + break;} +case 66: +#line 792 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 67: +#line 797 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 68: +#line 804 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + checkmem(yyval.a_expr); + yyval.a_expr->with_syntax = yyvsp[0].a_wsynt; + assert(yyval.a_expr->expr_type == A1TC_CLASSDEF); + assert(yyval.a_expr->meta_type == AMT_OBJECT); + ; + break;} +case 69: +#line 814 "asn1p_y.y" +{ yyval.a_int = 0; ; + break;} +case 70: +#line 815 "asn1p_y.y" +{ yyval.a_int = 1; ; + break;} +case 71: +#line 819 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = A1TC_CLASSDEF; + yyval.a_expr->meta_type = AMT_OBJECT; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 72: +#line 826 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 73: +#line 833 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[-1].a_refcomp.name; + yyval.a_expr->expr_type = A1TC_CLASSFIELD; + yyval.a_expr->meta_type = AMT_OBJECTFIELD; + yyval.a_expr->marker = yyvsp[0].a_marker; + ; + break;} +case 74: +#line 841 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-1].a_expr; + yyval.a_expr->Identifier = yyvsp[-2].a_refcomp.name; + yyval.a_expr->unique = yyvsp[0].a_int; + ; + break;} +case 75: +#line 846 "asn1p_y.y" +{ + int ret; + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = yyvsp[-3].a_refcomp.name; + yyval.a_expr->reference = asn1p_ref_new(yylineno); + checkmem(yyval.a_expr->reference); + ret = asn1p_ref_add_component(yyval.a_expr->reference, + yyvsp[-2].a_refcomp.name, yyvsp[-2].a_refcomp.lex_type); + checkmem(ret == 0); + yyval.a_expr->expr_type = A1TC_CLASSFIELD; + yyval.a_expr->meta_type = AMT_OBJECTFIELD; + yyval.a_expr->marker = yyvsp[-1].a_marker; + yyval.a_expr->unique = yyvsp[0].a_int; + ; + break;} +case 76: +#line 864 "asn1p_y.y" +{ yyval.a_wsynt = 0; ; + break;} +case 77: +#line 865 "asn1p_y.y" +{ + yyval.a_wsynt = yyvsp[0].a_wsynt; + ; + break;} +case 78: +#line 872 "asn1p_y.y" +{ asn1p_lexer_hack_enable_with_syntax(); ; + break;} +case 79: +#line 874 "asn1p_y.y" +{ + yyval.a_wsynt = yyvsp[-1].a_wsynt; + ; + break;} +case 80: +#line 880 "asn1p_y.y" +{ + yyval.a_wsynt = asn1p_wsyntx_new(); + TQ_ADD(&(yyval.a_wsynt->chunks), yyvsp[0].a_wchunk, next); + ; + break;} +case 81: +#line 884 "asn1p_y.y" +{ + yyval.a_wsynt = yyvsp[-1].a_wsynt; + TQ_ADD(&(yyval.a_wsynt->chunks), yyvsp[0].a_wchunk, next); + ; + break;} +case 82: +#line 891 "asn1p_y.y" +{ + yyval.a_wchunk = asn1p_wsyntx_chunk_frombuf(yyvsp[0].tv_opaque.buf, yyvsp[0].tv_opaque.len, 0); + ; + break;} +case 83: +#line 894 "asn1p_y.y" +{ + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, yyvsp[0].a_refcomp.name, yyvsp[0].a_refcomp.lex_type); + checkmem(ret == 0); + yyval.a_wchunk = asn1p_wsyntx_chunk_fromref(ref, 0); + ; + break;} +case 84: +#line 920 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + assert(yyval.a_expr->Identifier == 0); + yyval.a_expr->Identifier = yyvsp[-1].tv_nametag.name; + yyval.a_expr->tag = yyvsp[-1].tv_nametag.tag; + ; + break;} +case 85: +#line 926 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + ; + break;} +case 86: +#line 932 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + yyval.a_expr->constraints = yyvsp[-1].a_constr; + yyval.a_expr->marker = yyvsp[0].a_marker; + ; + break;} +case 87: +#line 940 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = strdup("..."); + checkmem(yyval.a_expr->Identifier); + yyval.a_expr->expr_type = A1TC_EXTENSIBLE; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 88: +#line 948 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = strdup("..."); + checkmem(yyval.a_expr->Identifier); + yyval.a_expr->value = yyvsp[0].a_value; + yyval.a_expr->expr_type = A1TC_EXTENSIBLE; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 89: +#line 957 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = strdup("..."); + yyval.a_expr->value = yyvsp[0].a_value; + checkmem(yyval.a_expr->Identifier); + yyval.a_expr->expr_type = A1TC_EXTENSIBLE; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 90: +#line 969 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + ; + break;} +case 91: +#line 972 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = yyvsp[0].a_type; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 92: +#line 978 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[0].a_expr; + checkmem(yyval.a_expr); + assert(yyval.a_expr->meta_type); + ; + break;} +case 93: +#line 986 "asn1p_y.y" +{ + int ret; + yyval.a_expr = yyvsp[-1].a_expr; + assert(yyval.a_expr->expr_type == 0); + assert(yyval.a_expr->meta_type == 0); + assert(yyval.a_expr->reference == 0); + yyval.a_expr->reference = asn1p_ref_new(yylineno); + checkmem(yyval.a_expr->reference); + ret = asn1p_ref_add_component(yyval.a_expr->reference, yyvsp[-3].tv_str, RLT_UNKNOWN); + checkmem(ret == 0); + free(yyvsp[-3].tv_str); + yyval.a_expr->expr_type = A1TC_PARAMETRIZED; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 94: +#line 1010 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->reference = yyvsp[0].a_ref; + yyval.a_expr->expr_type = A1TC_REFERENCE; + yyval.a_expr->meta_type = AMT_TYPEREF; + ; + break;} +case 95: +#line 1017 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(yylineno); + checkmem(yyval.a_expr); + yyval.a_expr->reference = yyvsp[0].a_ref; + yyval.a_expr->expr_type = A1TC_INSTANCE; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 96: +#line 1032 "asn1p_y.y" +{ + int ret; + yyval.a_ref = asn1p_ref_new(yylineno); + checkmem(yyval.a_ref); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[0].tv_str, RLT_UNKNOWN); + checkmem(ret == 0); + free(yyvsp[0].tv_str); + ; + break;} +case 97: +#line 1040 "asn1p_y.y" +{ + int ret; + yyval.a_ref = asn1p_ref_new(yylineno); + checkmem(yyval.a_ref); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[-2].tv_str, RLT_UNKNOWN); + checkmem(ret == 0); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[0].tv_str, RLT_UNKNOWN); + checkmem(ret == 0); + free(yyvsp[-2].tv_str); + ; + break;} +case 98: +#line 1050 "asn1p_y.y" +{ + int ret; + yyval.a_ref = asn1p_ref_new(yylineno); + checkmem(yyval.a_ref); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[-2].tv_str, RLT_UNKNOWN); + checkmem(ret == 0); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[0].tv_str, RLT_lowercase); + checkmem(ret == 0); + free(yyvsp[-2].tv_str); + ; + break;} +case 99: +#line 1060 "asn1p_y.y" +{ + int ret; + yyval.a_ref = asn1p_ref_new(yylineno); + checkmem(yyval.a_ref); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[0].tv_str, RLT_CAPITALS); + free(yyvsp[0].tv_str); + checkmem(ret == 0); + ; + break;} +case 100: +#line 1068 "asn1p_y.y" +{ + int ret; + yyval.a_ref = yyvsp[0].a_ref; + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[-2].tv_str, RLT_CAPITALS); + free(yyvsp[-2].tv_str); + checkmem(ret == 0); + /* + * Move the last element infront. + */ + { + struct asn1p_ref_component_s tmp_comp; + tmp_comp = yyval.a_ref->components[yyval.a_ref->comp_count-1]; + memmove(&yyval.a_ref->components[1], + &yyval.a_ref->components[0], + sizeof(yyval.a_ref->components[0]) + * (yyval.a_ref->comp_count - 1)); + yyval.a_ref->components[0] = tmp_comp; + } + ; + break;} +case 101: +#line 1090 "asn1p_y.y" +{ + int ret; + yyval.a_ref = asn1p_ref_new(yylineno); + checkmem(yyval.a_ref); + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[0].a_refcomp.name, yyvsp[0].a_refcomp.lex_type); + free(yyvsp[0].a_refcomp.name); + checkmem(ret == 0); + ; + break;} +case 102: +#line 1098 "asn1p_y.y" +{ + int ret; + yyval.a_ref = yyvsp[-2].a_ref; + ret = asn1p_ref_add_component(yyval.a_ref, yyvsp[0].a_refcomp.name, yyvsp[0].a_refcomp.lex_type); + free(yyvsp[0].a_refcomp.name); + checkmem(ret == 0); + ; + break;} +case 105: +#line 1112 "asn1p_y.y" +{ + yyval.a_refcomp.lex_type = RLT_AmpUppercase; + yyval.a_refcomp.name = yyvsp[0].tv_str; + ; + break;} +case 106: +#line 1117 "asn1p_y.y" +{ + yyval.a_refcomp.lex_type = RLT_Amplowercase; + yyval.a_refcomp.name = yyvsp[0].tv_str; + ; + break;} +case 107: +#line 1130 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + assert(yyval.a_expr->Identifier == NULL); + yyval.a_expr->Identifier = yyvsp[-3].tv_str; + yyval.a_expr->meta_type = AMT_VALUE; + yyval.a_expr->value = yyvsp[0].a_value; + ; + break;} +case 108: +#line 1140 "asn1p_y.y" +{ asn1p_lexer_hack_push_opaque_state(); ; + break;} +case 109: +#line 1141 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_frombuf(yyvsp[0].tv_opaque.buf, yyvsp[0].tv_opaque.len, 0); + checkmem(yyval.a_value); + yyval.a_value->type = ATV_UNPARSED; + ; + break;} +case 110: +#line 1146 "asn1p_y.y" +{ + yyval.a_value = _convert_bitstring2binary(yyvsp[0].tv_str, 'B'); + checkmem(yyval.a_value); + ; + break;} +case 111: +#line 1150 "asn1p_y.y" +{ + yyval.a_value = _convert_bitstring2binary(yyvsp[0].tv_str, 'H'); + checkmem(yyval.a_value); + ; + break;} +case 112: +#line 1154 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_frombuf(yyvsp[0].tv_opaque.buf, yyvsp[0].tv_opaque.len, 0); + checkmem(yyval.a_value); + ; + break;} +case 113: +#line 1158 "asn1p_y.y" +{ + yyval.a_value = yyvsp[0].a_value; + ; + break;} +case 114: +#line 1161 "asn1p_y.y" +{ + yyval.a_value = yyvsp[0].a_value; + ; + break;} +case 115: +#line 1167 "asn1p_y.y" +{ + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, yyvsp[0].tv_str, RLT_lowercase); + checkmem(ret == 0); + yyval.a_value = asn1p_value_fromref(ref, 0); + checkmem(yyval.a_value); + free(yyvsp[0].tv_str); + ; + break;} +case 116: +#line 1178 "asn1p_y.y" +{ + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, yyvsp[-2].tv_str, RLT_UNKNOWN); + checkmem(ret == 0); + ret = asn1p_ref_add_component(ref, yyvsp[0].tv_str, RLT_lowercase); + checkmem(ret == 0); + yyval.a_value = asn1p_value_fromref(ref, 0); + checkmem(yyval.a_value); + free(yyvsp[-2].tv_str); + free(yyvsp[0].tv_str); + ; + break;} +case 117: +#line 1195 "asn1p_y.y" +{ + yyval.tv_opaque.len = yyvsp[0].tv_opaque.len + 2; + yyval.tv_opaque.buf = malloc(yyval.tv_opaque.len + 1); + checkmem(yyval.tv_opaque.buf); + yyval.tv_opaque.buf[0] = '{'; + yyval.tv_opaque.buf[1] = ' '; + memcpy(yyval.tv_opaque.buf + 2, yyvsp[0].tv_opaque.buf, yyvsp[0].tv_opaque.len); + yyval.tv_opaque.buf[yyval.tv_opaque.len] = '\0'; + free(yyvsp[0].tv_opaque.buf); + ; + break;} +case 118: +#line 1205 "asn1p_y.y" +{ + int newsize = yyvsp[-1].tv_opaque.len + yyvsp[0].tv_opaque.len; + char *p = malloc(newsize + 1); + checkmem(p); + memcpy(p , yyvsp[-1].tv_opaque.buf, yyvsp[-1].tv_opaque.len); + memcpy(p + yyvsp[-1].tv_opaque.len, yyvsp[0].tv_opaque.buf, yyvsp[0].tv_opaque.len); + p[newsize] = '\0'; + free(yyvsp[-1].tv_opaque.buf); + free(yyvsp[0].tv_opaque.buf); + yyval.tv_opaque.buf = p; + yyval.tv_opaque.len = newsize; + ; + break;} +case 119: +#line 1220 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_BOOLEAN; ; + break;} +case 120: +#line 1221 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_NULL; ; + break;} +case 121: +#line 1222 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_REAL; ; + break;} +case 122: +#line 1223 "asn1p_y.y" +{ yyval.a_type = yyvsp[0].a_type; ; + break;} +case 123: +#line 1224 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_OCTET_STRING; ; + break;} +case 124: +#line 1225 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_OBJECT_IDENTIFIER; ; + break;} +case 125: +#line 1226 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_RELATIVE_OID; ; + break;} +case 126: +#line 1227 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_EXTERNAL; ; + break;} +case 127: +#line 1228 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_EMBEDDED_PDV; ; + break;} +case 128: +#line 1229 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_CHARACTER_STRING; ; + break;} +case 129: +#line 1230 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_UTCTime; ; + break;} +case 130: +#line 1231 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_GeneralizedTime; ; + break;} +case 131: +#line 1238 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_INTEGER; ; + break;} +case 132: +#line 1239 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_ENUMERATED; ; + break;} +case 133: +#line 1240 "asn1p_y.y" +{ yyval.a_type = ASN_BASIC_BIT_STRING; ; + break;} +case 134: +#line 1244 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = yyvsp[0].a_type; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 135: +#line 1250 "asn1p_y.y" +{ + if(yyvsp[0].a_expr) { + yyval.a_expr = yyvsp[0].a_expr; + } else { + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + } + yyval.a_expr->expr_type = yyvsp[-1].a_type; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 136: +#line 1263 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_BMPString; ; + break;} +case 137: +#line 1264 "asn1p_y.y" +{ + yyval.a_type = ASN_STRING_GeneralString; + return yyerror("GeneralString is not supported"); + ; + break;} +case 138: +#line 1268 "asn1p_y.y" +{ + yyval.a_type = ASN_STRING_GraphicString; + return yyerror("GraphicString is not supported"); + ; + break;} +case 139: +#line 1272 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_IA5String; ; + break;} +case 140: +#line 1273 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_ISO646String; ; + break;} +case 141: +#line 1274 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_NumericString; ; + break;} +case 142: +#line 1275 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_PrintableString; ; + break;} +case 143: +#line 1276 "asn1p_y.y" +{ + yyval.a_type = ASN_STRING_T61String; + return yyerror("T61String not implemented yet"); + ; + break;} +case 144: +#line 1280 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_TeletexString; ; + break;} +case 145: +#line 1281 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_UniversalString; ; + break;} +case 146: +#line 1282 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_UTF8String; ; + break;} +case 147: +#line 1283 "asn1p_y.y" +{ + yyval.a_type = ASN_STRING_VideotexString; + return yyerror("VideotexString is no longer supported"); + ; + break;} +case 148: +#line 1287 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_VisibleString; ; + break;} +case 149: +#line 1288 "asn1p_y.y" +{ yyval.a_type = ASN_STRING_ObjectDescriptor; ; + break;} +case 150: +#line 1292 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-1].a_expr; + assert(yyval.a_expr->expr_type == A1TC_INVALID); + yyval.a_expr->expr_type = ASN_CONSTR_CHOICE; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 151: +#line 1298 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-1].a_expr; + assert(yyval.a_expr->expr_type == A1TC_INVALID); + yyval.a_expr->expr_type = ASN_CONSTR_SEQUENCE; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 152: +#line 1304 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-1].a_expr; + assert(yyval.a_expr->expr_type == A1TC_INVALID); + yyval.a_expr->expr_type = ASN_CONSTR_SET; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 153: +#line 1310 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->constraints = yyvsp[-2].a_constr; + yyval.a_expr->expr_type = ASN_CONSTR_SEQUENCE_OF; + yyval.a_expr->meta_type = AMT_TYPE; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 154: +#line 1318 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->constraints = yyvsp[-2].a_constr; + yyval.a_expr->expr_type = ASN_CONSTR_SET_OF; + yyval.a_expr->meta_type = AMT_TYPE; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 155: +#line 1326 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = ASN_CONSTR_ANY; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 156: +#line 1332 "asn1p_y.y" +{ + int ret; + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->reference = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component(yyval.a_expr->reference, + yyvsp[0].tv_str, RLT_lowercase); + checkmem(ret == 0); + yyval.a_expr->expr_type = ASN_CONSTR_ANY; + yyval.a_expr->meta_type = AMT_TYPE; + ; + break;} +case 157: +#line 1349 "asn1p_y.y" +{ yyval.a_constr = 0; ; + break;} +case 158: +#line 1350 "asn1p_y.y" +{ yyval.a_constr = yyvsp[0].a_constr; ; + break;} +case 164: +#line 1358 "asn1p_y.y" +{ + /* + * This is a special case, for compatibility purposes. + * It goes without parenthesis. + */ + int ret; + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = ACT_CT_SIZE; + ret = asn1p_constraint_insert(yyval.a_constr, yyvsp[-1].a_constr); + checkmem(ret == 0); + ; + break;} +case 165: +#line 1370 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_SET, yyvsp[0].a_constr, 0); + ; + break;} +case 166: +#line 1373 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_SET, yyvsp[-1].a_constr, yyvsp[0].a_constr); + ; + break;} +case 167: +#line 1379 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[-1].a_constr; + ; + break;} +case 168: +#line 1385 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[0].a_constr; + ; + break;} +case 169: +#line 1388 "asn1p_y.y" +{ + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_EXT; + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CSV, yyvsp[-2].a_constr, ct); + ; + break;} +case 170: +#line 1395 "asn1p_y.y" +{ + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_EXT; + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CSV, yyvsp[-4].a_constr, ct); + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CSV, yyvsp[-4].a_constr, yyvsp[0].a_constr); + ; + break;} +case 171: +#line 1403 "asn1p_y.y" +{ + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = ACT_EL_EXT; + ; + break;} +case 172: +#line 1408 "asn1p_y.y" +{ + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_EXT; + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CSV, ct, yyvsp[0].a_constr); + ; + break;} +case 173: +#line 1417 "asn1p_y.y" +{ yyval.a_constr = yyvsp[0].a_constr; ; + break;} +case 174: +#line 1420 "asn1p_y.y" +{ yyval.a_constr = yyvsp[0].a_constr; ; + break;} +case 175: +#line 1421 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_UNI, yyvsp[-2].a_constr, yyvsp[0].a_constr); + ; + break;} +case 176: +#line 1427 "asn1p_y.y" +{ yyval.a_constr = yyvsp[0].a_constr; ; + break;} +case 177: +#line 1429 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_INT, yyvsp[-2].a_constr, yyvsp[0].a_constr); + ; + break;} +case 178: +#line 1435 "asn1p_y.y" +{ yyval.a_constr = yyvsp[0].a_constr; ; + break;} +case 179: +#line 1436 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_EXC, yyvsp[-2].a_constr, yyvsp[0].a_constr); + ; + break;} +case 180: +#line 1442 "asn1p_y.y" +{ + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = ACT_EL_VALUE; + yyval.a_constr->value = yyvsp[0].a_value; + ; + break;} +case 181: +#line 1448 "asn1p_y.y" +{ + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = yyvsp[-1].a_ctype; + yyval.a_constr->range_start = yyvsp[-2].a_value; + yyval.a_constr->range_stop = yyvsp[0].a_value; + ; + break;} +case 182: +#line 1455 "asn1p_y.y" +{ + int ret; + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = yyvsp[-3].a_ctype; + ret = asn1p_constraint_insert(yyval.a_constr, yyvsp[-1].a_constr); + checkmem(ret == 0); + ; + break;} +case 183: +#line 1463 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[0].a_constr; + ; + break;} +case 184: +#line 1466 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[0].a_constr; + ; + break;} +case 185: +#line 1472 "asn1p_y.y" +{ yyval.a_ctype = ACT_EL_RANGE; ; + break;} +case 186: +#line 1473 "asn1p_y.y" +{ yyval.a_ctype = ACT_EL_RLRANGE; ; + break;} +case 187: +#line 1474 "asn1p_y.y" +{ yyval.a_ctype = ACT_EL_LLRANGE; ; + break;} +case 188: +#line 1475 "asn1p_y.y" +{ yyval.a_ctype = ACT_EL_ULRANGE; ; + break;} +case 189: +#line 1479 "asn1p_y.y" +{ + yyval.a_ctype = ACT_CT_SIZE; + ; + break;} +case 190: +#line 1482 "asn1p_y.y" +{ + yyval.a_ctype = ACT_CT_FROM; + ; + break;} +case 191: +#line 1488 "asn1p_y.y" +{ + yyval.a_value = yyvsp[0].a_value; + ; + break;} +case 192: +#line 1491 "asn1p_y.y" +{ + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, yyvsp[0].tv_str, RLT_lowercase); + checkmem(ret == 0); + yyval.a_value = asn1p_value_fromref(ref, 0); + checkmem(yyval.a_value); + free(yyvsp[0].tv_str); + ; + break;} +case 193: +#line 1502 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_frombuf(yyvsp[0].tv_opaque.buf, yyvsp[0].tv_opaque.len, 0); + checkmem(yyval.a_value); + ; + break;} +case 194: +#line 1506 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_fromint(123); + checkmem(yyval.a_value); + yyval.a_value->type = ATV_MIN; + ; + break;} +case 195: +#line 1511 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_fromint(321); + checkmem(yyval.a_value); + yyval.a_value->type = ATV_MAX; + ; + break;} +case 196: +#line 1516 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_fromint(0); + checkmem(yyval.a_value); + yyval.a_value->type = ATV_FALSE; + ; + break;} +case 197: +#line 1521 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_fromint(1); + checkmem(yyval.a_value); + yyval.a_value->type = ATV_TRUE; + ; + break;} +case 198: +#line 1529 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CT_WCOMPS, yyvsp[-1].a_constr, 0); + ; + break;} +case 199: +#line 1535 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[0].a_constr; + ; + break;} +case 200: +#line 1538 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CT_WCOMPS, yyvsp[-2].a_constr, yyvsp[0].a_constr); + ; + break;} +case 201: +#line 1544 "asn1p_y.y" +{ + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = ACT_EL_EXT; + ; + break;} +case 202: +#line 1549 "asn1p_y.y" +{ + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = ACT_EL_VALUE; + yyval.a_constr->value = asn1p_value_frombuf(yyvsp[-2].tv_str, strlen(yyvsp[-2].tv_str), 0); + yyval.a_constr->presence = yyvsp[0].a_pres; + ; + break;} +case 203: +#line 1562 "asn1p_y.y" +{ yyval.a_pres = ACPRES_DEFAULT; ; + break;} +case 204: +#line 1563 "asn1p_y.y" +{ yyval.a_pres = yyvsp[0].a_pres; ; + break;} +case 205: +#line 1567 "asn1p_y.y" +{ + yyval.a_pres = ACPRES_PRESENT; + ; + break;} +case 206: +#line 1570 "asn1p_y.y" +{ + yyval.a_pres = ACPRES_ABSENT; + ; + break;} +case 207: +#line 1573 "asn1p_y.y" +{ + yyval.a_pres = ACPRES_OPTIONAL; + ; + break;} +case 208: +#line 1579 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[0].a_constr; + ; + break;} +case 209: +#line 1582 "asn1p_y.y" +{ + yyval.a_constr = yyvsp[0].a_constr; + ; + break;} +case 210: +#line 1591 "asn1p_y.y" +{ + asn1p_ref_t *ref = asn1p_ref_new(yylineno); + asn1p_constraint_t *ct; + int ret; + ret = asn1p_ref_add_component(ref, yyvsp[-1].tv_str, 0); + checkmem(ret == 0); + ct = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + ct->type = ACT_EL_VALUE; + ct->value = asn1p_value_fromref(ref, 0); + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CRC, ct, 0); + ; + break;} +case 211: +#line 1606 "asn1p_y.y" +{ + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CRC, yyvsp[-3].a_constr, yyvsp[-1].a_constr); + ; + break;} +case 212: +#line 1612 "asn1p_y.y" +{ + yyval.a_constr = asn1p_constraint_new(yylineno); + checkmem(yyval.a_constr); + yyval.a_constr->type = ACT_EL_VALUE; + yyval.a_constr->value = asn1p_value_fromref(yyvsp[0].a_ref, 0); + ; + break;} +case 213: +#line 1618 "asn1p_y.y" +{ + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_VALUE; + ct->value = asn1p_value_fromref(yyvsp[0].a_ref, 0); + CONSTRAINT_INSERT(yyval.a_constr, ACT_CA_CSV, yyvsp[-2].a_constr, ct); + ; + break;} +case 214: +#line 1632 "asn1p_y.y" +{ + char *p = malloc(strlen(yyvsp[0].tv_str) + 2); + int ret; + *p = '@'; + strcpy(p + 1, yyvsp[0].tv_str); + yyval.a_ref = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component(yyval.a_ref, p, 0); + checkmem(ret == 0); + free(p); + free(yyvsp[0].tv_str); + ; + break;} +case 215: +#line 1643 "asn1p_y.y" +{ + char *p = malloc(strlen(yyvsp[0].tv_str) + 3); + int ret; + p[0] = '@'; + p[1] = '.'; + strcpy(p + 2, yyvsp[0].tv_str); + yyval.a_ref = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component(yyval.a_ref, p, 0); + checkmem(ret == 0); + free(p); + free(yyvsp[0].tv_str); + ; + break;} +case 216: +#line 1659 "asn1p_y.y" +{ + yyval.tv_str = yyvsp[0].tv_str; + ; + break;} +case 217: +#line 1662 "asn1p_y.y" +{ + int l1 = strlen(yyvsp[-2].tv_str); + int l3 = strlen(yyvsp[0].tv_str); + yyval.tv_str = malloc(l1 + 1 + l3 + 1); + memcpy(yyval.tv_str, yyvsp[-2].tv_str, l1); + yyval.tv_str[l1] = '.'; + memcpy(yyval.tv_str + l1 + 1, yyvsp[0].tv_str, l3); + yyval.tv_str[l1 + 1 + l3] = '\0'; + ; + break;} +case 218: +#line 1680 "asn1p_y.y" +{ yyval.a_marker = EM_NOMARK; ; + break;} +case 219: +#line 1681 "asn1p_y.y" +{ yyval.a_marker = yyvsp[0].a_marker; ; + break;} +case 220: +#line 1685 "asn1p_y.y" +{ + yyval.a_marker = EM_OPTIONAL; + ; + break;} +case 221: +#line 1688 "asn1p_y.y" +{ + yyval.a_marker = EM_DEFAULT; + /* FIXME: store DefaultValue somewhere */ + ; + break;} +case 222: +#line 1695 "asn1p_y.y" +{ + ; + break;} +case 223: +#line 1697 "asn1p_y.y" +{ + ; + break;} +case 224: +#line 1699 "asn1p_y.y" +{ asn1p_lexer_hack_push_opaque_state(); ; + break;} +case 225: +#line 1699 "asn1p_y.y" +{ + ; + break;} +case 226: +#line 1720 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + ; + break;} +case 227: +#line 1724 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-1].a_expr; + ; + break;} +case 228: +#line 1730 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 229: +#line 1735 "asn1p_y.y" +{ + yyval.a_expr = yyvsp[-2].a_expr; + TQ_ADD(&(yyval.a_expr->members), yyvsp[0].a_expr, next); + ; + break;} +case 230: +#line 1742 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = A1TC_UNIVERVAL; + yyval.a_expr->meta_type = AMT_VALUE; + yyval.a_expr->Identifier = yyvsp[0].tv_str; + ; + break;} +case 231: +#line 1749 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = A1TC_UNIVERVAL; + yyval.a_expr->meta_type = AMT_VALUE; + yyval.a_expr->Identifier = yyvsp[-3].tv_str; + yyval.a_expr->value = yyvsp[-1].a_value; + ; + break;} +case 232: +#line 1757 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = A1TC_UNIVERVAL; + yyval.a_expr->meta_type = AMT_VALUE; + yyval.a_expr->Identifier = yyvsp[-3].tv_str; + yyval.a_expr->value = yyvsp[-1].a_value; + ; + break;} +case 233: +#line 1765 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->expr_type = A1TC_UNIVERVAL; + yyval.a_expr->meta_type = AMT_VALUE; + yyval.a_expr->value = yyvsp[0].a_value; + ; + break;} +case 234: +#line 1772 "asn1p_y.y" +{ + yyval.a_expr = asn1p_expr_new(asn1p_lineno); + checkmem(yyval.a_expr); + yyval.a_expr->Identifier = strdup("..."); + checkmem(yyval.a_expr->Identifier); + yyval.a_expr->expr_type = A1TC_EXTENSIBLE; + yyval.a_expr->meta_type = AMT_VALUE; + ; + break;} +case 235: +#line 1783 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_fromint(yyvsp[0].a_int); + checkmem(yyval.a_value); + ; + break;} +case 236: +#line 1787 "asn1p_y.y" +{ + yyval.a_value = asn1p_value_fromint(yyvsp[0].a_int); + checkmem(yyval.a_value); + ; + break;} +case 237: +#line 1818 "asn1p_y.y" +{ memset(&yyval.a_tag, 0, sizeof(yyval.a_tag)); ; + break;} +case 238: +#line 1819 "asn1p_y.y" +{ yyval.a_tag = yyvsp[0].a_tag; ; + break;} +case 239: +#line 1823 "asn1p_y.y" +{ + yyval.a_tag = yyvsp[0].a_tag; + yyval.a_tag.tag_mode = TM_DEFAULT; + ; + break;} +case 240: +#line 1827 "asn1p_y.y" +{ + yyval.a_tag = yyvsp[-1].a_tag; + yyval.a_tag.tag_mode = TM_IMPLICIT; + ; + break;} +case 241: +#line 1831 "asn1p_y.y" +{ + yyval.a_tag = yyvsp[-1].a_tag; + yyval.a_tag.tag_mode = TM_EXPLICIT; + ; + break;} +case 242: +#line 1838 "asn1p_y.y" +{ + checkmem(yyvsp[0].tv_str); + yyval.tv_str = yyvsp[0].tv_str; + ; + break;} +case 243: +#line 1842 "asn1p_y.y" +{ + checkmem(yyvsp[0].tv_str); + yyval.tv_str = yyvsp[0].tv_str; + ; + break;} +case 244: +#line 1849 "asn1p_y.y" +{ + checkmem(yyvsp[0].tv_str); + yyval.tv_str = yyvsp[0].tv_str; + ; + break;} +case 245: +#line 1856 "asn1p_y.y" +{ + checkmem(yyvsp[0].tv_str); + yyval.tv_str = yyvsp[0].tv_str; + ; + break;} +case 246: +#line 1863 "asn1p_y.y" +{ + memset(&yyval.tv_nametag, 0, sizeof(yyval.tv_nametag)); + yyval.tv_nametag.name = yyvsp[0].tv_str; + ; + break;} +case 247: +#line 1867 "asn1p_y.y" +{ + yyval.tv_nametag.name = yyvsp[-1].tv_str; + yyval.tv_nametag.tag = yyvsp[0].a_tag; + ; + break;} +} + /* the action file gets copied in in place of this dollarsign */ +#line 543 "/usr/share/bison.simple" + + yyvsp -= yylen; + yyssp -= yylen; +#ifdef YYLSP_NEEDED + yylsp -= yylen; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + + *++yyvsp = yyval; + +#ifdef YYLSP_NEEDED + yylsp++; + if (yylen == 0) + { + yylsp->first_line = yylloc.first_line; + yylsp->first_column = yylloc.first_column; + yylsp->last_line = (yylsp-1)->last_line; + yylsp->last_column = (yylsp-1)->last_column; + yylsp->text = 0; + } + else + { + yylsp->last_line = (yylsp+yylen-1)->last_line; + yylsp->last_column = (yylsp+yylen-1)->last_column; + } +#endif + + /* Now "shift" the result of the reduction. + Determine what state that goes to, + based on the state we popped back to + and the rule number reduced by. */ + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTBASE] + *yyssp; + if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTBASE]; + + goto yynewstate; + +yyerrlab: /* here on detecting error */ + + if (! yyerrstatus) + /* If not already recovering from an error, report this error. */ + { + ++yynerrs; + +#ifdef YYERROR_VERBOSE + yyn = yypact[yystate]; + + if (yyn > YYFLAG && yyn < YYLAST) + { + int size = 0; + char *msg; + int x, count; + + count = 0; + /* Start X at -yyn if nec to avoid negative indexes in yycheck. */ + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + size += strlen(yytname[x]) + 15, count++; + msg = (char *) malloc(size + 15); + if (msg != 0) + { + strcpy(msg, "parse error"); + + if (count < 5) + { + count = 0; + for (x = (yyn < 0 ? -yyn : 0); + x < (sizeof(yytname) / sizeof(char *)); x++) + if (yycheck[x + yyn] == x) + { + strcat(msg, count == 0 ? ", expecting `" : " or `"); + strcat(msg, yytname[x]); + strcat(msg, "'"); + count++; + } + } + yyerror(msg); + free(msg); + } + else + yyerror ("parse error; also virtual memory exceeded"); + } + else +#endif /* YYERROR_VERBOSE */ + yyerror("parse error"); + } + + goto yyerrlab1; +yyerrlab1: /* here on error raised explicitly by an action */ + + if (yyerrstatus == 3) + { + /* if just tried and failed to reuse lookahead token after an error, discard it. */ + + /* return failure if at end of input */ + if (yychar == YYEOF) + YYABORT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]); +#endif + + yychar = YYEMPTY; + } + + /* Else will try to reuse lookahead token + after shifting the error token. */ + + yyerrstatus = 3; /* Each real token shifted decrements this */ + + goto yyerrhandle; + +yyerrdefault: /* current state does not do anything special for the error token. */ + +#if 0 + /* This is wrong; only states that explicitly want error tokens + should shift them. */ + yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/ + if (yyn) goto yydefault; +#endif + +yyerrpop: /* pop the current state because it cannot handle the error token */ + + if (yyssp == yyss) YYABORT; + yyvsp--; + yystate = *--yyssp; +#ifdef YYLSP_NEEDED + yylsp--; +#endif + +#if YYDEBUG != 0 + if (yydebug) + { + short *ssp1 = yyss - 1; + fprintf (stderr, "Error: state stack now"); + while (ssp1 != yyssp) + fprintf (stderr, " %d", *++ssp1); + fprintf (stderr, "\n"); + } +#endif + +yyerrhandle: + + yyn = yypact[yystate]; + if (yyn == YYFLAG) + goto yyerrdefault; + + yyn += YYTERROR; + if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR) + goto yyerrdefault; + + yyn = yytable[yyn]; + if (yyn < 0) + { + if (yyn == YYFLAG) + goto yyerrpop; + yyn = -yyn; + goto yyreduce; + } + else if (yyn == 0) + goto yyerrpop; + + if (yyn == YYFINAL) + YYACCEPT; + +#if YYDEBUG != 0 + if (yydebug) + fprintf(stderr, "Shifting error token, "); +#endif + + *++yyvsp = yylval; +#ifdef YYLSP_NEEDED + *++yylsp = yylloc; +#endif + + yystate = yyn; + goto yynewstate; + + yyacceptlab: + /* YYACCEPT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 0; + + yyabortlab: + /* YYABORT comes here. */ + if (yyfree_stacks) + { + free (yyss); + free (yyvs); +#ifdef YYLSP_NEEDED + free (yyls); +#endif + } + return 1; +} +#line 1874 "asn1p_y.y" + + + +/* + * Convert Xstring ('0101'B or '5'H) to the binary vector. + */ +static asn1p_value_t * +_convert_bitstring2binary(char *str, int base) { + asn1p_value_t *val; + int slen; + int memlen; + int baselen; + int bits; + uint8_t *binary_vector; + uint8_t *bv_ptr; + uint8_t cur_val; + + assert(str); + assert(str[0] == '\''); + + switch(base) { + case 'B': + baselen = 1; + break; + case 'H': + baselen = 4; + break; + default: + assert(base == 'B' || base == 'H'); + errno = EINVAL; + return NULL; + } + + slen = strlen(str); + assert(str[slen - 1] == base); + assert(str[slen - 2] == '\''); + + memlen = slen / (8 / baselen); /* Conservative estimate */ + + bv_ptr = binary_vector = malloc(memlen + 1); + if(bv_ptr == NULL) + /* ENOMEM */ + return NULL; + + cur_val = 0; + bits = 0; + while(*(++str) != '\'') { + switch(baselen) { + case 1: + switch(*str) { + case '1': + cur_val |= 1 << (7 - (bits % 8)); + case '0': + break; + default: + assert(!"_y UNREACH1"); + case ' ': case '\r': case '\n': + continue; + } + break; + case 4: + switch(*str) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + cur_val |= (*str - '0') << (4 - (bits % 8)); + break; + case 'A': case 'B': case 'C': + case 'D': case 'E': case 'F': + cur_val |= ((*str - 'A') + 10) + << (4 - (bits % 8)); + break; + default: + assert(!"_y UNREACH2"); + case ' ': case '\r': case '\n': + continue; + } + break; + } + + bits += baselen; + if((bits % 8) == 0) { + *bv_ptr++ = cur_val; + cur_val = 0; + } + } + + *bv_ptr = cur_val; + assert((bv_ptr - binary_vector) <= memlen); + + val = asn1p_value_frombits(binary_vector, bits, 0); + if(val == NULL) { + free(binary_vector); + } + + return val; +} + +extern char *asn1p_text; + +int +yyerror(const char *msg) { + fprintf(stderr, + "ASN.1 grammar parse error " + "near line %d (token \"%s\"): %s\n", + asn1p_lineno, asn1p_text, msg); + return -1; +} + + diff --git a/libasn1parser/asn1p_y.h b/libasn1parser/asn1p_y.h new file mode 100644 index 00000000..61679e3d --- /dev/null +++ b/libasn1parser/asn1p_y.h @@ -0,0 +1,132 @@ +typedef union { + asn1p_t *a_grammar; + asn1p_module_flags_e a_module_flags; + asn1p_module_t *a_module; + asn1p_expr_type_e a_type; /* ASN.1 Type */ + asn1p_expr_t *a_expr; /* Constructed collection */ + asn1p_constraint_t *a_constr; /* Constraint */ + enum asn1p_constraint_type_e a_ctype;/* Constraint type */ + asn1p_xports_t *a_xports; /* IMports/EXports */ + asn1p_oid_t *a_oid; /* Object Identifier */ + asn1p_oid_arc_t a_oid_arc; /* Single OID's arc */ + struct asn1p_type_tag_s a_tag; /* A tag */ + asn1p_ref_t *a_ref; /* Reference to custom type */ + asn1p_wsyntx_t *a_wsynt; /* WITH SYNTAX contents */ + asn1p_wsyntx_chunk_t *a_wchunk; /* WITH SYNTAX chunk */ + struct asn1p_ref_component_s a_refcomp; /* Component of a reference */ + asn1p_value_t *a_value; /* Number, DefinedValue, etc */ + struct asn1p_param_s a_parg; /* A parameter argument */ + asn1p_paramlist_t *a_plist; /* A pargs list */ + enum asn1p_expr_marker_e a_marker; /* OPTIONAL/DEFAULT */ + enum asn1p_constr_pres_e a_pres; /* PRESENT/ABSENT/OPTIONAL */ + asn1_integer_t a_int; + char *tv_str; + struct { + char *buf; + int len; + } tv_opaque; + struct { + char *name; + struct asn1p_type_tag_s tag; + } tv_nametag; +} YYSTYPE; +#define TOK_PPEQ 257 +#define TOK_opaque 258 +#define TOK_bstring 259 +#define TOK_cstring 260 +#define TOK_hstring 261 +#define TOK_identifier 262 +#define TOK_number 263 +#define TOK_number_negative 264 +#define TOK_typereference 265 +#define TOK_objectclassreference 266 +#define TOK_typefieldreference 267 +#define TOK_valuefieldreference 268 +#define TOK_ABSENT 269 +#define TOK_ABSTRACT_SYNTAX 270 +#define TOK_ALL 271 +#define TOK_ANY 272 +#define TOK_APPLICATION 273 +#define TOK_AUTOMATIC 274 +#define TOK_BEGIN 275 +#define TOK_BIT 276 +#define TOK_BMPString 277 +#define TOK_BOOLEAN 278 +#define TOK_BY 279 +#define TOK_CHARACTER 280 +#define TOK_CHOICE 281 +#define TOK_CLASS 282 +#define TOK_COMPONENT 283 +#define TOK_COMPONENTS 284 +#define TOK_CONSTRAINED 285 +#define TOK_CONTAINING 286 +#define TOK_DEFAULT 287 +#define TOK_DEFINITIONS 288 +#define TOK_DEFINED 289 +#define TOK_EMBEDDED 290 +#define TOK_ENCODED 291 +#define TOK_END 292 +#define TOK_ENUMERATED 293 +#define TOK_EXPLICIT 294 +#define TOK_EXPORTS 295 +#define TOK_EXTENSIBILITY 296 +#define TOK_EXTERNAL 297 +#define TOK_FALSE 298 +#define TOK_FROM 299 +#define TOK_GeneralizedTime 300 +#define TOK_GeneralString 301 +#define TOK_GraphicString 302 +#define TOK_IA5String 303 +#define TOK_IDENTIFIER 304 +#define TOK_IMPLICIT 305 +#define TOK_IMPLIED 306 +#define TOK_IMPORTS 307 +#define TOK_INCLUDES 308 +#define TOK_INSTANCE 309 +#define TOK_INTEGER 310 +#define TOK_ISO646String 311 +#define TOK_MAX 312 +#define TOK_MIN 313 +#define TOK_MINUS_INFINITY 314 +#define TOK_NULL 315 +#define TOK_NumericString 316 +#define TOK_OBJECT 317 +#define TOK_ObjectDescriptor 318 +#define TOK_OCTET 319 +#define TOK_OF 320 +#define TOK_OPTIONAL 321 +#define TOK_PATTERN 322 +#define TOK_PDV 323 +#define TOK_PLUS_INFINITY 324 +#define TOK_PRESENT 325 +#define TOK_PrintableString 326 +#define TOK_PRIVATE 327 +#define TOK_REAL 328 +#define TOK_RELATIVE_OID 329 +#define TOK_SEQUENCE 330 +#define TOK_SET 331 +#define TOK_SIZE 332 +#define TOK_STRING 333 +#define TOK_SYNTAX 334 +#define TOK_T61String 335 +#define TOK_TAGS 336 +#define TOK_TeletexString 337 +#define TOK_TRUE 338 +#define TOK_TYPE_IDENTIFIER 339 +#define TOK_UNIQUE 340 +#define TOK_UNIVERSAL 341 +#define TOK_UniversalString 342 +#define TOK_UTCTime 343 +#define TOK_UTF8String 344 +#define TOK_VideotexString 345 +#define TOK_VisibleString 346 +#define TOK_WITH 347 +#define TOK_UNION 348 +#define TOK_INTERSECTION 349 +#define TOK_EXCEPT 350 +#define TOK_TwoDots 351 +#define TOK_ThreeDots 352 +#define TOK_tag 353 + + +extern YYSTYPE asn1p_lval; diff --git a/libasn1parser/asn1p_y.y b/libasn1parser/asn1p_y.y new file mode 100644 index 00000000..822a8efb --- /dev/null +++ b/libasn1parser/asn1p_y.y @@ -0,0 +1,1982 @@ +%{ + +#include +#include +#include +#include +#include + +#include "asn1parser.h" + +#define YYPARSE_PARAM param +#define YYERROR_VERBOSE + +int yylex(void); +int yyerror(const char *msg); +void asn1p_lexer_hack_push_opaque_state(void); +void asn1p_lexer_hack_enable_with_syntax(void); +#define yylineno asn1p_lineno +extern int asn1p_lineno; + + +static asn1p_value_t * + _convert_bitstring2binary(char *str, int base); + +#define checkmem(ptr) do { \ + if(!(ptr)) \ + return yyerror("Memory failure"); \ + } while(0) + +#define CONSTRAINT_INSERT(root, constr_type, arg1, arg2) do { \ + if(arg1->type != constr_type) { \ + int __ret; \ + root = asn1p_constraint_new(yylineno); \ + checkmem(root); \ + root->type = constr_type; \ + __ret = asn1p_constraint_insert(root, \ + arg1); \ + checkmem(__ret == 0); \ + } else { \ + root = arg1; \ + } \ + if(arg2) { \ + int __ret \ + = asn1p_constraint_insert(root, arg2); \ + checkmem(__ret == 0); \ + } \ + } while(0) + +%} + + +/* + * Token value definition. + * a_*: ASN-specific types. + * tv_*: Locally meaningful types. + */ +%union { + asn1p_t *a_grammar; + asn1p_module_flags_e a_module_flags; + asn1p_module_t *a_module; + asn1p_expr_type_e a_type; /* ASN.1 Type */ + asn1p_expr_t *a_expr; /* Constructed collection */ + asn1p_constraint_t *a_constr; /* Constraint */ + enum asn1p_constraint_type_e a_ctype;/* Constraint type */ + asn1p_xports_t *a_xports; /* IMports/EXports */ + asn1p_oid_t *a_oid; /* Object Identifier */ + asn1p_oid_arc_t a_oid_arc; /* Single OID's arc */ + struct asn1p_type_tag_s a_tag; /* A tag */ + asn1p_ref_t *a_ref; /* Reference to custom type */ + asn1p_wsyntx_t *a_wsynt; /* WITH SYNTAX contents */ + asn1p_wsyntx_chunk_t *a_wchunk; /* WITH SYNTAX chunk */ + struct asn1p_ref_component_s a_refcomp; /* Component of a reference */ + asn1p_value_t *a_value; /* Number, DefinedValue, etc */ + struct asn1p_param_s a_parg; /* A parameter argument */ + asn1p_paramlist_t *a_plist; /* A pargs list */ + enum asn1p_expr_marker_e a_marker; /* OPTIONAL/DEFAULT */ + enum asn1p_constr_pres_e a_pres; /* PRESENT/ABSENT/OPTIONAL */ + asn1_integer_t a_int; + char *tv_str; + struct { + char *buf; + int len; + } tv_opaque; + struct { + char *name; + struct asn1p_type_tag_s tag; + } tv_nametag; +}; + +/* + * Token types returned by scanner. + */ +%token TOK_PPEQ /* "::=", Pseudo Pascal EQuality */ +%token TOK_opaque /* opaque data (driven from .y) */ +%token TOK_bstring +%token TOK_cstring +%token TOK_hstring +%token TOK_identifier +%token TOK_number +%token TOK_number_negative +%token TOK_typereference +%token TOK_objectclassreference /* "CLASS1" */ +%token TOK_typefieldreference /* "&Pork" */ +%token TOK_valuefieldreference /* "&id" */ + +/* + * Token types representing ASN.1 standard keywords. + */ +%token TOK_ABSENT +%token TOK_ABSTRACT_SYNTAX +%token TOK_ALL +%token TOK_ANY +%token TOK_APPLICATION +%token TOK_AUTOMATIC +%token TOK_BEGIN +%token TOK_BIT +%token TOK_BMPString +%token TOK_BOOLEAN +%token TOK_BY +%token TOK_CHARACTER +%token TOK_CHOICE +%token TOK_CLASS +%token TOK_COMPONENT +%token TOK_COMPONENTS +%token TOK_CONSTRAINED +%token TOK_CONTAINING +%token TOK_DEFAULT +%token TOK_DEFINITIONS +%token TOK_DEFINED +%token TOK_EMBEDDED +%token TOK_ENCODED +%token TOK_END +%token TOK_ENUMERATED +%token TOK_EXPLICIT +%token TOK_EXPORTS +%token TOK_EXTENSIBILITY +%token TOK_EXTERNAL +%token TOK_FALSE +%token TOK_FROM +%token TOK_GeneralizedTime +%token TOK_GeneralString +%token TOK_GraphicString +%token TOK_IA5String +%token TOK_IDENTIFIER +%token TOK_IMPLICIT +%token TOK_IMPLIED +%token TOK_IMPORTS +%token TOK_INCLUDES +%token TOK_INSTANCE +%token TOK_INTEGER +%token TOK_ISO646String +%token TOK_MAX +%token TOK_MIN +%token TOK_MINUS_INFINITY +%token TOK_NULL +%token TOK_NumericString +%token TOK_OBJECT +%token TOK_ObjectDescriptor +%token TOK_OCTET +%token TOK_OF +%token TOK_OPTIONAL +%token TOK_PATTERN +%token TOK_PDV +%token TOK_PLUS_INFINITY +%token TOK_PRESENT +%token TOK_PrintableString +%token TOK_PRIVATE +%token TOK_REAL +%token TOK_RELATIVE_OID +%token TOK_SEQUENCE +%token TOK_SET +%token TOK_SIZE +%token TOK_STRING +%token TOK_SYNTAX +%token TOK_T61String +%token TOK_TAGS +%token TOK_TeletexString +%token TOK_TRUE +%token TOK_TYPE_IDENTIFIER +%token TOK_UNIQUE +%token TOK_UNIVERSAL +%token TOK_UniversalString +%token TOK_UTCTime +%token TOK_UTF8String +%token TOK_VideotexString +%token TOK_VisibleString +%token TOK_WITH + +%left '|' TOK_UNION +%left '^' TOK_INTERSECTION +%left TOK_EXCEPT + +/* Misc tags */ +%token TOK_TwoDots /* .. */ +%token TOK_ThreeDots /* ... */ +%token TOK_tag /* [0] */ + + +/* + * Types defined herein. + */ +%type ModuleList +%type ModuleSpecification +%type ModuleSpecificationBody +%type ModuleSpecificationElement +%type optModuleSpecificationBody /* Optional */ +%type optModuleSpecificationFlags +%type ModuleSpecificationFlags /* Set of FL */ +%type ModuleSpecificationFlag /* Single FL */ +%type ImportsDefinition +%type ImportsBundleSet +%type ImportsBundle +%type ImportsList +%type ExportsDefinition +%type ExportsBody +%type ImportsElement +%type ExportsElement +%type DataTypeMember +%type ExtensionAndException +%type TypeDeclaration +%type ComplexTypeReference +%type ComplexTypeReferenceAmpList +%type ComplexTypeReferenceElement +%type ClassFieldIdentifier +%type ClassFieldName +%type ClassFieldList +%type ClassField +%type ClassDeclaration +%type ConstrainedTypeDeclaration +%type DataTypeReference /* Type1 ::= Type2 */ +%type DefinedTypeRef +%type ValueSetDefinition /* Val INTEGER ::= {1|2} */ +%type ValueDefinition /* val INTEGER ::= 1*/ +%type optValueSetBody +%type InlineOrDefinedValue +%type DefinedValue +%type SignedNumber +%type ConstructedType +%type ConstructedDataTypeDefinition +//%type optUniverationDefinition +%type UniverationDefinition +%type UniverationList +%type UniverationElement +%type TypeRefName +%type ObjectClassReference +%type TaggedIdentifier +%type Identifier +%type ParameterArgumentName +%type ParameterArgumentList +%type ActualParameter +%type ActualParameterList +%type ObjectIdentifier /* OID */ +%type optObjectIdentifier /* Optional OID */ +%type ObjectIdentifierBody +%type ObjectIdentifierElement +%type BasicType +%type BasicTypeId +%type BasicTypeId_UniverationCompatible +%type BasicString +%type Opaque +//%type StringValue +%type Tag /* [UNIVERSAL 0] IMPLICIT */ +%type optTag /* [UNIVERSAL 0] IMPLICIT */ +%type optConstraints +%type Constraints +%type SingleConstraint /* (SIZE(2)) */ +%type ConstraintElementSet /* 1..2,...,3 */ +%type ConstraintSubtypeElement /* 1..2 */ +%type ConstraintElementIntersection +%type ConstraintElementException +%type ConstraintElementUnion +%type ConstraintElement +%type SimpleTableConstraint +%type TableConstraint +%type WithComponents +%type WithComponentsList +%type WithComponentsElement +%type ComponentRelationConstraint +%type AtNotationList +%type AtNotationElement +%type ConstraintValue +%type ConstraintSpec +%type ConstraintRangeSpec +%type optWithSyntax +%type WithSyntax +%type WithSyntaxFormat +%type WithSyntaxFormatToken +%type optMarker Marker +%type optUnique +%type optPresenceConstraint PresenceConstraint +%type ComponentIdList + + +%% + + +ParsedGrammar: + ModuleList { + *(void **)param = $1; + } + ; + +ModuleList: + ModuleSpecification { + $$ = asn1p_new(); + checkmem($$); + TQ_ADD(&($$->modules), $1, mod_next); + } + | ModuleList ModuleSpecification { + $$ = $1; + TQ_ADD(&($$->modules), $2, mod_next); + } + ; + +/* + * ASN module definition. + * === EXAMPLE === + * MySyntax DEFINITIONS AUTOMATIC TAGS ::= + * BEGIN + * ... + * END + * === EOF === + */ + +ModuleSpecification: + TypeRefName optObjectIdentifier TOK_DEFINITIONS + optModuleSpecificationFlags + TOK_PPEQ TOK_BEGIN + optModuleSpecificationBody + TOK_END { + + if($7) { + $$ = $7; + } else { + /* There's a chance that a module is just plain empty */ + $$ = asn1p_module_new(); + } + checkmem($$); + + $$->Identifier = $1; + $$->module_oid = $2; + $$->module_flags = $4; + } + ; + +/* + * Object Identifier Definition + * { iso member-body(2) 3 } + */ +optObjectIdentifier: + { $$ = 0; } + | ObjectIdentifier { $$ = $1; } + ; + +ObjectIdentifier: + '{' ObjectIdentifierBody '}' { + $$ = $2; + } + | '{' '}' { + $$ = 0; + } + ; + +ObjectIdentifierBody: + ObjectIdentifierElement { + $$ = asn1p_oid_new(); + asn1p_oid_add_arc($$, &$1); + if($1.name) + free($1.name); + } + | ObjectIdentifierBody ObjectIdentifierElement { + $$ = $1; + asn1p_oid_add_arc($$, &$2); + if($2.name) + free($2.name); + } + ; + +ObjectIdentifierElement: + Identifier { /* iso */ + $$.name = $1; + $$.number = -1; + } + | Identifier '(' TOK_number ')' { /* iso(1) */ + $$.name = $1; + $$.number = $3; + } + | TOK_number { /* 1 */ + $$.name = 0; + $$.number = $1; + } + ; + +/* + * Optional module flags. + */ +optModuleSpecificationFlags: + { $$ = MSF_NOFLAGS; } + | ModuleSpecificationFlags { + $$ = $1; + } + ; + +/* + * Module flags. + */ +ModuleSpecificationFlags: + ModuleSpecificationFlag { + $$ = $1; + } + | ModuleSpecificationFlags ModuleSpecificationFlag { + $$ = $1 | $2; + } + ; + +/* + * Single module flag. + */ +ModuleSpecificationFlag: + TOK_EXPLICIT TOK_TAGS { + $$ = MSF_EXPLICIT_TAGS; + } + | TOK_IMPLICIT TOK_TAGS { + $$ = MSF_IMPLICIT_TAGS; + } + | TOK_AUTOMATIC TOK_TAGS { + $$ = MSF_AUTOMATIC_TAGS; + } + | TOK_EXTENSIBILITY TOK_IMPLIED { + $$ = MSF_EXTENSIBILITY_IMPLIED; + } + ; + +/* + * Optional module body. + */ +optModuleSpecificationBody: + { $$ = 0; } + | ModuleSpecificationBody { + assert($1); + $$ = $1; + } + ; + +/* + * ASN.1 Module body. + */ +ModuleSpecificationBody: + ModuleSpecificationElement { + $$ = $1; + } + | ModuleSpecificationBody ModuleSpecificationElement { + $$ = $1; + +#ifdef MY_IMPORT +#error MY_IMPORT DEFINED ELSEWHERE! +#endif +#define MY_IMPORT(foo,field) do { \ + if(TQ_FIRST(&($2->foo))) { \ + TQ_ADD(&($$->foo), \ + TQ_REMOVE(&($2->foo), field), \ + field); \ + assert(TQ_FIRST(&($2->foo)) == 0); \ + } } while(0) + + MY_IMPORT(imports, xp_next); + MY_IMPORT(exports, xp_next); + MY_IMPORT(members, next); +#undef MY_IMPORT + + } + ; + +/* + * One of the elements of ASN.1 module specification. + */ +ModuleSpecificationElement: + ImportsDefinition { + $$ = $1; + } + | ExportsDefinition { + $$ = asn1p_module_new(); + checkmem($$); + if($1) { + TQ_ADD(&($$->exports), $1, xp_next); + } else { + /* "EXPORTS ALL;" ? */ + } + } + | DataTypeReference { + $$ = asn1p_module_new(); + checkmem($$); + assert($1->expr_type != A1TC_INVALID); + assert($1->meta_type != AMT_INVALID); + TQ_ADD(&($$->members), $1, next); + } + | ValueDefinition { + $$ = asn1p_module_new(); + checkmem($$); + assert($1->expr_type != A1TC_INVALID); + assert($1->meta_type != AMT_INVALID); + TQ_ADD(&($$->members), $1, next); + } + /* + * Value set definition + * === EXAMPLE === + * EvenNumbers INTEGER ::= { 2 | 4 | 6 | 8 } + * === EOF === + */ + | ValueSetDefinition { + $$ = asn1p_module_new(); + checkmem($$); + assert($1->expr_type != A1TC_INVALID); + assert($1->meta_type != AMT_INVALID); + TQ_ADD(&($$->members), $1, next); + } + + /* + * Erroneous attemps + */ + | BasicString { + return yyerror( + "Attempt to redefine a standard basic type, " + "use -ftypesXY to switch back " + "to older version of ASN.1 standard"); + } + ; + +/* + * === EXAMPLE === + * IMPORTS Type1, value FROM Module { iso standard(0) } ; + * === EOF === + */ +ImportsDefinition: + TOK_IMPORTS ImportsBundleSet ';' { + $$ = $2; + } + /* + * Some error cases. + */ + | TOK_IMPORTS TOK_FROM /* ... */ { + return yyerror("Empty IMPORTS list"); + } + ; + +ImportsBundleSet: + ImportsBundle { + $$ = asn1p_module_new(); + checkmem($$); + TQ_ADD(&($$->imports), $1, xp_next); + } + | ImportsBundleSet ImportsBundle { + $$ = $1; + TQ_ADD(&($$->imports), $2, xp_next); + } + ; + +ImportsBundle: + ImportsList TOK_FROM TypeRefName optObjectIdentifier { + $$ = $1; + $$->from = $3; + $$->from_oid = $4; + checkmem($$); + } + ; + +ImportsList: + ImportsElement { + $$ = asn1p_xports_new(); + checkmem($$); + TQ_ADD(&($$->members), $1, next); + } + | ImportsList ',' ImportsElement { + $$ = $1; + TQ_ADD(&($$->members), $3, next); + } + ; + +ImportsElement: + TypeRefName { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1; + $$->expr_type = A1TC_REFERENCE; + } + | Identifier { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1; + $$->expr_type = A1TC_REFERENCE; + } + ; + +ExportsDefinition: + TOK_EXPORTS ExportsBody ';' { + $$ = $2; + } + | TOK_EXPORTS TOK_ALL ';' { + $$ = 0; + } + | TOK_EXPORTS ';' { + /* Empty EXPORTS clause effectively prohibits export. */ + $$ = asn1p_xports_new(); + checkmem($$); + } + ; + +ExportsBody: + ExportsElement { + $$ = asn1p_xports_new(); + assert($$); + TQ_ADD(&($$->members), $1, next); + } + | ExportsBody ',' ExportsElement { + $$ = $1; + TQ_ADD(&($$->members), $3, next); + } + ; + +ExportsElement: + TypeRefName { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1; + $$->expr_type = A1TC_EXPORTVAR; + } + | Identifier { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1; + $$->expr_type = A1TC_EXPORTVAR; + } + ; + + +ValueSetDefinition: + TypeRefName DefinedTypeRef TOK_PPEQ '{' optValueSetBody '}' { + $$ = $2; + assert($$->Identifier == 0); + $$->Identifier = $1; + $$->meta_type = AMT_VALUESET; + // take care of optValueSetBody + } + ; + +DefinedTypeRef: + ComplexTypeReference { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->reference = $1; + $$->expr_type = A1TC_REFERENCE; + $$->meta_type = AMT_TYPEREF; + } + | BasicTypeId { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->expr_type = $1; + $$->meta_type = AMT_TYPE; + } + ; + +optValueSetBody: + { } + | ConstraintElementSet { + } + ; + + +/* + * Data Type Reference. + * === EXAMPLE === + * Type3 ::= CHOICE { a Type1, b Type 2 } + * === EOF === + */ + +DataTypeReference: + /* + * Optionally tagged type definition. + */ + TypeRefName TOK_PPEQ optTag TOK_TYPE_IDENTIFIER { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1; + $$->tag = $3; + $$->expr_type = A1TC_TYPEID; + $$->meta_type = AMT_TYPE; + } + | TypeRefName TOK_PPEQ optTag ConstrainedTypeDeclaration { + $$ = $4; + $$->Identifier = $1; + $$->tag = $3; + assert($$->expr_type); + assert($$->meta_type); + } + | TypeRefName TOK_PPEQ ClassDeclaration { + $$ = $3; + $$->Identifier = $1; + assert($$->expr_type == A1TC_CLASSDEF); + assert($$->meta_type == AMT_OBJECT); + } + /* + * Parametrized declaration: + * === EXAMPLE === + * SIGNED { ToBeSigned } ::= SEQUENCE { + * toBeSigned ToBeSigned, + * algorithm AlgorithmIdentifier, + * signature BIT STRING + * } + * === EOF === + */ + | TypeRefName '{' ParameterArgumentList '}' + TOK_PPEQ ConstrainedTypeDeclaration { + $$ = $6; + assert($$->Identifier == 0); + $$->Identifier = $1; + $$->params = $3; + $$->meta_type = AMT_PARAMTYPE; + } + ; + +ParameterArgumentList: + ParameterArgumentName { + int ret; + $$ = asn1p_paramlist_new(yylineno); + checkmem($$); + ret = asn1p_paramlist_add_param($$, $1.governor, $1.argument); + checkmem(ret == 0); + if($1.governor) asn1p_ref_free($1.governor); + if($1.argument) free($1.argument); + } + | ParameterArgumentList ',' ParameterArgumentName { + int ret; + $$ = $1; + ret = asn1p_paramlist_add_param($$, $3.governor, $3.argument); + checkmem(ret == 0); + if($3.governor) asn1p_ref_free($3.governor); + if($3.argument) free($3.argument); + } + ; + +ParameterArgumentName: + TypeRefName { + $$.governor = NULL; + $$.argument = $1; + } + | TypeRefName ':' Identifier { + int ret; + $$.governor = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component($$.governor, $1, 0); + checkmem(ret == 0); + $$.argument = $3; + } + | BasicTypeId ':' Identifier { + int ret; + $$.governor = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component($$.governor, + ASN_EXPR_TYPE2STR($1), 1); + checkmem(ret == 0); + $$.argument = $3; + } + ; + +ActualParameterList: + ActualParameter { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + TQ_ADD(&($$->members), $1, next); + } + | ActualParameterList ',' ActualParameter { + $$ = $1; + TQ_ADD(&($$->members), $3, next); + } + ; + +ActualParameter: + TypeDeclaration { + $$ = $1; + } + | Identifier { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1; + $$->expr_type = A1TC_REFERENCE; + $$->meta_type = AMT_VALUE; + } + ; + +/* + * A collection of constructed data type members. + */ +ConstructedDataTypeDefinition: + DataTypeMember { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + TQ_ADD(&($$->members), $1, next); + } + | ConstructedDataTypeDefinition ',' DataTypeMember { + $$ = $1; + TQ_ADD(&($$->members), $3, next); + } + ; + +ClassDeclaration: + TOK_CLASS '{' ClassFieldList '}' optWithSyntax { + $$ = $3; + checkmem($$); + $$->with_syntax = $5; + assert($$->expr_type == A1TC_CLASSDEF); + assert($$->meta_type == AMT_OBJECT); + } + ; + +optUnique: + { $$ = 0; } + | TOK_UNIQUE { $$ = 1; } + ; + +ClassFieldList: + ClassField { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->expr_type = A1TC_CLASSDEF; + $$->meta_type = AMT_OBJECT; + TQ_ADD(&($$->members), $1, next); + } + | ClassFieldList ',' ClassField { + $$ = $1; + TQ_ADD(&($$->members), $3, next); + } + ; + +ClassField: + ClassFieldIdentifier optMarker { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1.name; + $$->expr_type = A1TC_CLASSFIELD; + $$->meta_type = AMT_OBJECTFIELD; + $$->marker = $2; + } + | ClassFieldIdentifier ConstrainedTypeDeclaration optUnique { + $$ = $2; + $$->Identifier = $1.name; + $$->unique = $3; + } + | ClassFieldIdentifier ClassFieldIdentifier optMarker optUnique { + int ret; + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->Identifier = $1.name; + $$->reference = asn1p_ref_new(yylineno); + checkmem($$->reference); + ret = asn1p_ref_add_component($$->reference, + $2.name, $2.lex_type); + checkmem(ret == 0); + $$->expr_type = A1TC_CLASSFIELD; + $$->meta_type = AMT_OBJECTFIELD; + $$->marker = $3; + $$->unique = $4; + } + ; + +optWithSyntax: + { $$ = 0; } + | WithSyntax { + $$ = $1; + } + ; + +WithSyntax: + TOK_WITH TOK_SYNTAX '{' + { asn1p_lexer_hack_enable_with_syntax(); } + WithSyntaxFormat + '}' { + $$ = $5; + } + ; + +WithSyntaxFormat: + WithSyntaxFormatToken { + $$ = asn1p_wsyntx_new(); + TQ_ADD(&($$->chunks), $1, next); + } + | WithSyntaxFormat WithSyntaxFormatToken { + $$ = $1; + TQ_ADD(&($$->chunks), $2, next); + } + ; + +WithSyntaxFormatToken: + TOK_opaque { + $$ = asn1p_wsyntx_chunk_frombuf($1.buf, $1.len, 0); + } + | ClassFieldIdentifier { + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, $1.name, $1.lex_type); + checkmem(ret == 0); + $$ = asn1p_wsyntx_chunk_fromref(ref, 0); + } + ; + +/* + * A data type member goes like this + * === + * memb1 [0] Type1 { a(1), b(2) } (2) + * === + * Therefore, we propose a split. + * ^^^^^^^^^ ^^^^^^^^^^ + * ^TaggedIdentifier ^TypeDeclaration + * ^ConstrainedTypeDeclaration + */ + +/* + * A member of a constructed data type ("a" or "b" in above example). + */ +DataTypeMember: + TaggedIdentifier ConstrainedTypeDeclaration { + $$ = $2; + assert($$->Identifier == 0); + $$->Identifier = $1.name; + $$->tag = $1.tag; + } + | ExtensionAndException { + $$ = $1; + } + ; + +ConstrainedTypeDeclaration: + TypeDeclaration optConstraints optMarker { + $$ = $1; + $$->constraints = $2; + $$->marker = $3; + } + ; + +ExtensionAndException: + TOK_ThreeDots { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->Identifier = strdup("..."); + checkmem($$->Identifier); + $$->expr_type = A1TC_EXTENSIBLE; + $$->meta_type = AMT_TYPE; + } + | TOK_ThreeDots '!' DefinedValue { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->Identifier = strdup("..."); + checkmem($$->Identifier); + $$->value = $3; + $$->expr_type = A1TC_EXTENSIBLE; + $$->meta_type = AMT_TYPE; + } + | TOK_ThreeDots '!' SignedNumber { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->Identifier = strdup("..."); + $$->value = $3; + checkmem($$->Identifier); + $$->expr_type = A1TC_EXTENSIBLE; + $$->meta_type = AMT_TYPE; + } + ; + +TypeDeclaration: + BasicType { + $$ = $1; + } + | BasicString { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->expr_type = $1; + $$->meta_type = AMT_TYPE; + } + | ConstructedType { + $$ = $1; + checkmem($$); + assert($$->meta_type); + } + /* + * A parametrized assignment. + */ + | TypeRefName '{' ActualParameterList '}' { + int ret; + $$ = $3; + assert($$->expr_type == 0); + assert($$->meta_type == 0); + assert($$->reference == 0); + $$->reference = asn1p_ref_new(yylineno); + checkmem($$->reference); + ret = asn1p_ref_add_component($$->reference, $1, RLT_UNKNOWN); + checkmem(ret == 0); + free($1); + $$->expr_type = A1TC_PARAMETRIZED; + $$->meta_type = AMT_TYPE; + } + /* + * A DefinedType reference. + * "CLASS1.&id.&id2" + * or + * "Module.Type" + * or + * "Module.identifier" + * or + * "Type" + */ + | ComplexTypeReference { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->reference = $1; + $$->expr_type = A1TC_REFERENCE; + $$->meta_type = AMT_TYPEREF; + } + | TOK_INSTANCE TOK_OF ComplexTypeReference { + $$ = asn1p_expr_new(yylineno); + checkmem($$); + $$->reference = $3; + $$->expr_type = A1TC_INSTANCE; + $$->meta_type = AMT_TYPE; + } + ; + +/* + * A type name consisting of several components. + * === EXAMPLE === + * === EOF === + */ +ComplexTypeReference: + TOK_typereference { + int ret; + $$ = asn1p_ref_new(yylineno); + checkmem($$); + ret = asn1p_ref_add_component($$, $1, RLT_UNKNOWN); + checkmem(ret == 0); + free($1); + } + | TOK_typereference '.' TypeRefName { + int ret; + $$ = asn1p_ref_new(yylineno); + checkmem($$); + ret = asn1p_ref_add_component($$, $1, RLT_UNKNOWN); + checkmem(ret == 0); + ret = asn1p_ref_add_component($$, $3, RLT_UNKNOWN); + checkmem(ret == 0); + free($1); + } + | TOK_typereference '.' Identifier { + int ret; + $$ = asn1p_ref_new(yylineno); + checkmem($$); + ret = asn1p_ref_add_component($$, $1, RLT_UNKNOWN); + checkmem(ret == 0); + ret = asn1p_ref_add_component($$, $3, RLT_lowercase); + checkmem(ret == 0); + free($1); + } + | ObjectClassReference { + int ret; + $$ = asn1p_ref_new(yylineno); + checkmem($$); + ret = asn1p_ref_add_component($$, $1, RLT_CAPITALS); + free($1); + checkmem(ret == 0); + } + | ObjectClassReference '.' ComplexTypeReferenceAmpList { + int ret; + $$ = $3; + ret = asn1p_ref_add_component($$, $1, RLT_CAPITALS); + free($1); + checkmem(ret == 0); + /* + * Move the last element infront. + */ + { + struct asn1p_ref_component_s tmp_comp; + tmp_comp = $$->components[$$->comp_count-1]; + memmove(&$$->components[1], + &$$->components[0], + sizeof($$->components[0]) + * ($$->comp_count - 1)); + $$->components[0] = tmp_comp; + } + } + ; + +ComplexTypeReferenceAmpList: + ComplexTypeReferenceElement { + int ret; + $$ = asn1p_ref_new(yylineno); + checkmem($$); + ret = asn1p_ref_add_component($$, $1.name, $1.lex_type); + free($1.name); + checkmem(ret == 0); + } + | ComplexTypeReferenceAmpList '.' ComplexTypeReferenceElement { + int ret; + $$ = $1; + ret = asn1p_ref_add_component($$, $3.name, $3.lex_type); + free($3.name); + checkmem(ret == 0); + } + ; + +ComplexTypeReferenceElement: ClassFieldName; +ClassFieldIdentifier: ClassFieldName; + +ClassFieldName: + /* "&Type1" */ + TOK_typefieldreference { + $$.lex_type = RLT_AmpUppercase; + $$.name = $1; + } + /* "&id" */ + | TOK_valuefieldreference { + $$.lex_type = RLT_Amplowercase; + $$.name = $1; + } + ; + + +/* + * === EXAMPLE === + * value INTEGER ::= 1 + * === EOF === + */ +ValueDefinition: + Identifier DefinedTypeRef TOK_PPEQ InlineOrDefinedValue { + $$ = $2; + assert($$->Identifier == NULL); + $$->Identifier = $1; + $$->meta_type = AMT_VALUE; + $$->value = $4; + } + ; + +InlineOrDefinedValue: + '{' { asn1p_lexer_hack_push_opaque_state(); } + Opaque /* '}' */ { + $$ = asn1p_value_frombuf($3.buf, $3.len, 0); + checkmem($$); + $$->type = ATV_UNPARSED; + } + | TOK_bstring { + $$ = _convert_bitstring2binary($1, 'B'); + checkmem($$); + } + | TOK_hstring { + $$ = _convert_bitstring2binary($1, 'H'); + checkmem($$); + } + | TOK_cstring { + $$ = asn1p_value_frombuf($1.buf, $1.len, 0); + checkmem($$); + } + | SignedNumber { + $$ = $1; + } + | DefinedValue { + $$ = $1; + } + ; + +DefinedValue: + Identifier { + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, $1, RLT_lowercase); + checkmem(ret == 0); + $$ = asn1p_value_fromref(ref, 0); + checkmem($$); + free($1); + } + | TypeRefName '.' Identifier { + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, $1, RLT_UNKNOWN); + checkmem(ret == 0); + ret = asn1p_ref_add_component(ref, $3, RLT_lowercase); + checkmem(ret == 0); + $$ = asn1p_value_fromref(ref, 0); + checkmem($$); + free($1); + free($3); + } + ; + +Opaque: + TOK_opaque { + $$.len = $1.len + 2; + $$.buf = malloc($$.len + 1); + checkmem($$.buf); + $$.buf[0] = '{'; + $$.buf[1] = ' '; + memcpy($$.buf + 2, $1.buf, $1.len); + $$.buf[$$.len] = '\0'; + free($1.buf); + } + | Opaque TOK_opaque { + int newsize = $1.len + $2.len; + char *p = malloc(newsize + 1); + checkmem(p); + memcpy(p , $1.buf, $1.len); + memcpy(p + $1.len, $2.buf, $2.len); + p[newsize] = '\0'; + free($1.buf); + free($2.buf); + $$.buf = p; + $$.len = newsize; + } + ; + +BasicTypeId: + TOK_BOOLEAN { $$ = ASN_BASIC_BOOLEAN; } + | TOK_NULL { $$ = ASN_BASIC_NULL; } + | TOK_REAL { $$ = ASN_BASIC_REAL; } + | BasicTypeId_UniverationCompatible { $$ = $1; } + | TOK_OCTET TOK_STRING { $$ = ASN_BASIC_OCTET_STRING; } + | TOK_OBJECT TOK_IDENTIFIER { $$ = ASN_BASIC_OBJECT_IDENTIFIER; } + | TOK_RELATIVE_OID { $$ = ASN_BASIC_RELATIVE_OID; } + | TOK_EXTERNAL { $$ = ASN_BASIC_EXTERNAL; } + | TOK_EMBEDDED TOK_PDV { $$ = ASN_BASIC_EMBEDDED_PDV; } + | TOK_CHARACTER TOK_STRING { $$ = ASN_BASIC_CHARACTER_STRING; } + | TOK_UTCTime { $$ = ASN_BASIC_UTCTime; } + | TOK_GeneralizedTime { $$ = ASN_BASIC_GeneralizedTime; } + ; + +/* + * A type identifier which may be used with "{ a(1), b(2) }" clause. + */ +BasicTypeId_UniverationCompatible: + TOK_INTEGER { $$ = ASN_BASIC_INTEGER; } + | TOK_ENUMERATED { $$ = ASN_BASIC_ENUMERATED; } + | TOK_BIT TOK_STRING { $$ = ASN_BASIC_BIT_STRING; } + ; + +BasicType: + BasicTypeId { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->expr_type = $1; + $$->meta_type = AMT_TYPE; + } + | BasicTypeId_UniverationCompatible UniverationDefinition { + if($2) { + $$ = $2; + } else { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + } + $$->expr_type = $1; + $$->meta_type = AMT_TYPE; + } + ; + +BasicString: + TOK_BMPString { $$ = ASN_STRING_BMPString; } + | TOK_GeneralString { + $$ = ASN_STRING_GeneralString; + return yyerror("GeneralString is not supported"); + } + | TOK_GraphicString { + $$ = ASN_STRING_GraphicString; + return yyerror("GraphicString is not supported"); + } + | TOK_IA5String { $$ = ASN_STRING_IA5String; } + | TOK_ISO646String { $$ = ASN_STRING_ISO646String; } + | TOK_NumericString { $$ = ASN_STRING_NumericString; } + | TOK_PrintableString { $$ = ASN_STRING_PrintableString; } + | TOK_T61String { + $$ = ASN_STRING_T61String; + return yyerror("T61String not implemented yet"); + } + | TOK_TeletexString { $$ = ASN_STRING_TeletexString; } + | TOK_UniversalString { $$ = ASN_STRING_UniversalString; } + | TOK_UTF8String { $$ = ASN_STRING_UTF8String; } + | TOK_VideotexString { + $$ = ASN_STRING_VideotexString; + return yyerror("VideotexString is no longer supported"); + } + | TOK_VisibleString { $$ = ASN_STRING_VisibleString; } + | TOK_ObjectDescriptor { $$ = ASN_STRING_ObjectDescriptor; } + ; + +ConstructedType: + TOK_CHOICE '{' ConstructedDataTypeDefinition '}' { + $$ = $3; + assert($$->expr_type == A1TC_INVALID); + $$->expr_type = ASN_CONSTR_CHOICE; + $$->meta_type = AMT_TYPE; + } + | TOK_SEQUENCE '{' ConstructedDataTypeDefinition '}' { + $$ = $3; + assert($$->expr_type == A1TC_INVALID); + $$->expr_type = ASN_CONSTR_SEQUENCE; + $$->meta_type = AMT_TYPE; + } + | TOK_SET '{' ConstructedDataTypeDefinition '}' { + $$ = $3; + assert($$->expr_type == A1TC_INVALID); + $$->expr_type = ASN_CONSTR_SET; + $$->meta_type = AMT_TYPE; + } + | TOK_SEQUENCE optConstraints TOK_OF TypeDeclaration { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->constraints = $2; + $$->expr_type = ASN_CONSTR_SEQUENCE_OF; + $$->meta_type = AMT_TYPE; + TQ_ADD(&($$->members), $4, next); + } + | TOK_SET optConstraints TOK_OF TypeDeclaration { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->constraints = $2; + $$->expr_type = ASN_CONSTR_SET_OF; + $$->meta_type = AMT_TYPE; + TQ_ADD(&($$->members), $4, next); + } + | TOK_ANY { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->expr_type = ASN_CONSTR_ANY; + $$->meta_type = AMT_TYPE; + } + | TOK_ANY TOK_DEFINED TOK_BY Identifier { + int ret; + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->reference = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component($$->reference, + $4, RLT_lowercase); + checkmem(ret == 0); + $$->expr_type = ASN_CONSTR_ANY; + $$->meta_type = AMT_TYPE; + } + ; + +/* + * Data type constraints. + */ +optConstraints: + { $$ = 0; } + | Constraints { $$ = $1; } + ; + +Union: '|' | TOK_UNION; +Intersection: '^' | TOK_INTERSECTION; +Except: TOK_EXCEPT; + +Constraints: + TOK_SIZE '(' ConstraintElementSet ')' { + /* + * This is a special case, for compatibility purposes. + * It goes without parenthesis. + */ + int ret; + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = ACT_CT_SIZE; + ret = asn1p_constraint_insert($$, $3); + checkmem(ret == 0); + } + | SingleConstraint { + CONSTRAINT_INSERT($$, ACT_CA_SET, $1, 0); + } + | Constraints SingleConstraint { + CONSTRAINT_INSERT($$, ACT_CA_SET, $1, $2); + } + ; + +SingleConstraint: + '(' ConstraintElementSet ')' { + $$ = $2; + } + ; + +ConstraintElementSet: + ConstraintElement { + $$ = $1; + } + | ConstraintElement ',' TOK_ThreeDots { + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_EXT; + CONSTRAINT_INSERT($$, ACT_CA_CSV, $1, ct); + } + | ConstraintElement ',' TOK_ThreeDots ',' ConstraintElement { + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_EXT; + CONSTRAINT_INSERT($$, ACT_CA_CSV, $1, ct); + CONSTRAINT_INSERT($$, ACT_CA_CSV, $1, $5); + } + | TOK_ThreeDots { + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = ACT_EL_EXT; + } + | TOK_ThreeDots ',' ConstraintElement { + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_EXT; + CONSTRAINT_INSERT($$, ACT_CA_CSV, ct, $3); + } + ; + +ConstraintElement: ConstraintElementUnion { $$ = $1; } ; + +ConstraintElementUnion: + ConstraintElementIntersection { $$ = $1; } + | ConstraintElementUnion Union ConstraintElementIntersection { + CONSTRAINT_INSERT($$, ACT_CA_UNI, $1, $3); + } + ; + +ConstraintElementIntersection: + ConstraintElementException { $$ = $1; } + | ConstraintElementIntersection Intersection + ConstraintElementException { + CONSTRAINT_INSERT($$, ACT_CA_INT, $1, $3); + } + ; + +ConstraintElementException: + ConstraintSubtypeElement { $$ = $1; } + | ConstraintElementException Except ConstraintSubtypeElement { + CONSTRAINT_INSERT($$, ACT_CA_EXC, $1, $3); + } + ; + +ConstraintSubtypeElement: + ConstraintValue { + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = ACT_EL_VALUE; + $$->value = $1; + } + | ConstraintValue ConstraintRangeSpec ConstraintValue { + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = $2; + $$->range_start = $1; + $$->range_stop = $3; + } + | ConstraintSpec '(' ConstraintElementSet ')' { + int ret; + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = $1; + ret = asn1p_constraint_insert($$, $3); + checkmem(ret == 0); + } + | TableConstraint { + $$ = $1; + } + | WithComponents { + $$ = $1; + } + ; + +ConstraintRangeSpec: + TOK_TwoDots { $$ = ACT_EL_RANGE; } + | TOK_TwoDots '<' { $$ = ACT_EL_RLRANGE; } + | '<' TOK_TwoDots { $$ = ACT_EL_LLRANGE; } + | '<' TOK_TwoDots '<' { $$ = ACT_EL_ULRANGE; } + ; + +ConstraintSpec: + TOK_SIZE { + $$ = ACT_CT_SIZE; + } + | TOK_FROM { + $$ = ACT_CT_FROM; + } + ; + +ConstraintValue: + SignedNumber { + $$ = $1; + } + | Identifier { + asn1p_ref_t *ref; + int ret; + ref = asn1p_ref_new(yylineno); + checkmem(ref); + ret = asn1p_ref_add_component(ref, $1, RLT_lowercase); + checkmem(ret == 0); + $$ = asn1p_value_fromref(ref, 0); + checkmem($$); + free($1); + } + | TOK_cstring { + $$ = asn1p_value_frombuf($1.buf, $1.len, 0); + checkmem($$); + } + | TOK_MIN { + $$ = asn1p_value_fromint(123); + checkmem($$); + $$->type = ATV_MIN; + } + | TOK_MAX { + $$ = asn1p_value_fromint(321); + checkmem($$); + $$->type = ATV_MAX; + } + | TOK_FALSE { + $$ = asn1p_value_fromint(0); + checkmem($$); + $$->type = ATV_FALSE; + } + | TOK_TRUE { + $$ = asn1p_value_fromint(1); + checkmem($$); + $$->type = ATV_TRUE; + } + ; + +WithComponents: + TOK_WITH TOK_COMPONENTS '{' WithComponentsList '}' { + CONSTRAINT_INSERT($$, ACT_CT_WCOMPS, $4, 0); + } + ; + +WithComponentsList: + WithComponentsElement { + $$ = $1; + } + | WithComponentsList ',' WithComponentsElement { + CONSTRAINT_INSERT($$, ACT_CT_WCOMPS, $1, $3); + } + ; + +WithComponentsElement: + TOK_ThreeDots { + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = ACT_EL_EXT; + } + | Identifier optConstraints optPresenceConstraint { + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = ACT_EL_VALUE; + $$->value = asn1p_value_frombuf($1, strlen($1), 0); + $$->presence = $3; + } + ; + +/* + * presence constraint for WithComponents + */ +optPresenceConstraint: + { $$ = ACPRES_DEFAULT; } + | PresenceConstraint { $$ = $1; } + ; + +PresenceConstraint: + TOK_PRESENT { + $$ = ACPRES_PRESENT; + } + | TOK_ABSENT { + $$ = ACPRES_ABSENT; + } + | TOK_OPTIONAL { + $$ = ACPRES_OPTIONAL; + } + ; + +TableConstraint: + SimpleTableConstraint { + $$ = $1; + } + | ComponentRelationConstraint { + $$ = $1; + } + ; + +/* + * "{ExtensionSet}" + */ +SimpleTableConstraint: + '{' TypeRefName '}' { + asn1p_ref_t *ref = asn1p_ref_new(yylineno); + asn1p_constraint_t *ct; + int ret; + ret = asn1p_ref_add_component(ref, $2, 0); + checkmem(ret == 0); + ct = asn1p_constraint_new(yylineno); + checkmem($$); + ct->type = ACT_EL_VALUE; + ct->value = asn1p_value_fromref(ref, 0); + CONSTRAINT_INSERT($$, ACT_CA_CRC, ct, 0); + } + ; + +ComponentRelationConstraint: + SimpleTableConstraint '{' AtNotationList '}' { + CONSTRAINT_INSERT($$, ACT_CA_CRC, $1, $3); + } + ; + +AtNotationList: + AtNotationElement { + $$ = asn1p_constraint_new(yylineno); + checkmem($$); + $$->type = ACT_EL_VALUE; + $$->value = asn1p_value_fromref($1, 0); + } + | AtNotationList ',' AtNotationElement { + asn1p_constraint_t *ct; + ct = asn1p_constraint_new(yylineno); + checkmem(ct); + ct->type = ACT_EL_VALUE; + ct->value = asn1p_value_fromref($3, 0); + CONSTRAINT_INSERT($$, ACT_CA_CSV, $1, ct); + } + ; + +/* + * @blah + */ +AtNotationElement: + '@' ComponentIdList { + char *p = malloc(strlen($2) + 2); + int ret; + *p = '@'; + strcpy(p + 1, $2); + $$ = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component($$, p, 0); + checkmem(ret == 0); + free(p); + free($2); + } + | '@' '.' ComponentIdList { + char *p = malloc(strlen($3) + 3); + int ret; + p[0] = '@'; + p[1] = '.'; + strcpy(p + 2, $3); + $$ = asn1p_ref_new(yylineno); + ret = asn1p_ref_add_component($$, p, 0); + checkmem(ret == 0); + free(p); + free($3); + } + ; + +/* identifier "." ... */ +ComponentIdList: + Identifier { + $$ = $1; + } + | ComponentIdList '.' Identifier { + int l1 = strlen($1); + int l3 = strlen($3); + $$ = malloc(l1 + 1 + l3 + 1); + memcpy($$, $1, l1); + $$[l1] = '.'; + memcpy($$ + l1 + 1, $3, l3); + $$[l1 + 1 + l3] = '\0'; + } + ; + + + +/* + * MARKERS + */ + +optMarker: + { $$ = EM_NOMARK; } + | Marker { $$ = $1; } + ; + +Marker: + TOK_OPTIONAL { + $$ = EM_OPTIONAL; + } + | TOK_DEFAULT DefaultValue { + $$ = EM_DEFAULT; + /* FIXME: store DefaultValue somewhere */ + } + ; + +DefaultValue: + ConstraintValue { + } + | BasicTypeId { + } + | '{' { asn1p_lexer_hack_push_opaque_state(); } Opaque /* '}' */ { + } + ; + +/* + * Universal enumeration definition to use in INTEGER and ENUMERATED. + * === EXAMPLE === + * Gender ::= ENUMERATED { unknown(0), male(1), female(2) } + * Temperature ::= INTEGER { absolute-zero(-273), freezing(0), boiling(100) } + * === EOF === + */ +/* +optUniverationDefinition: + { $$ = 0; } + | UniverationDefinition { + $$ = $1; + } + ; +*/ + +UniverationDefinition: + '{' '}' { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + } + | '{' UniverationList '}' { + $$ = $2; + } + ; + +UniverationList: + UniverationElement { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + TQ_ADD(&($$->members), $1, next); + } + | UniverationList ',' UniverationElement { + $$ = $1; + TQ_ADD(&($$->members), $3, next); + } + ; + +UniverationElement: + Identifier { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->expr_type = A1TC_UNIVERVAL; + $$->meta_type = AMT_VALUE; + $$->Identifier = $1; + } + | Identifier '(' SignedNumber ')' { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->expr_type = A1TC_UNIVERVAL; + $$->meta_type = AMT_VALUE; + $$->Identifier = $1; + $$->value = $3; + } + | Identifier '(' DefinedValue ')' { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->expr_type = A1TC_UNIVERVAL; + $$->meta_type = AMT_VALUE; + $$->Identifier = $1; + $$->value = $3; + } + | SignedNumber { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->expr_type = A1TC_UNIVERVAL; + $$->meta_type = AMT_VALUE; + $$->value = $1; + } + | TOK_ThreeDots { + $$ = asn1p_expr_new(asn1p_lineno); + checkmem($$); + $$->Identifier = strdup("..."); + checkmem($$->Identifier); + $$->expr_type = A1TC_EXTENSIBLE; + $$->meta_type = AMT_VALUE; + } + ; + +SignedNumber: + TOK_number { + $$ = asn1p_value_fromint($1); + checkmem($$); + } + | TOK_number_negative { + $$ = asn1p_value_fromint($1); + checkmem($$); + } + ; + +/* + * SEQUENCE definition. + * === EXAMPLE === + * Struct1 ::= SEQUENCE { + * memb1 Struct2, + * memb2 SEQUENCE OF { + * memb2-1 Struct 3 + * } + * } + * === EOF === + */ + + + +/* + * SET definition. + * === EXAMPLE === + * Person ::= SET { + * name [0] PrintableString (SIZE(1..20)), + * country [1] PrintableString (SIZE(1..20)) DEFAULT default-country, + * } + * === EOF === + */ + +optTag: + { memset(&$$, 0, sizeof($$)); } + | Tag { $$ = $1; } + ; + +Tag: + TOK_tag { + $$ = $1; + $$.tag_mode = TM_DEFAULT; + } + | TOK_tag TOK_IMPLICIT { + $$ = $1; + $$.tag_mode = TM_IMPLICIT; + } + | TOK_tag TOK_EXPLICIT { + $$ = $1; + $$.tag_mode = TM_EXPLICIT; + } + ; + +TypeRefName: + TOK_typereference { + checkmem($1); + $$ = $1; + } + | TOK_objectclassreference { + checkmem($1); + $$ = $1; + } + ; + +ObjectClassReference: + TOK_objectclassreference { + checkmem($1); + $$ = $1; + } + ; + +Identifier: + TOK_identifier { + checkmem($1); + $$ = $1; + } + ; + +TaggedIdentifier: + Identifier { + memset(&$$, 0, sizeof($$)); + $$.name = $1; + } + | Identifier Tag { + $$.name = $1; + $$.tag = $2; + } + ; + + +%% + + +/* + * Convert Xstring ('0101'B or '5'H) to the binary vector. + */ +static asn1p_value_t * +_convert_bitstring2binary(char *str, int base) { + asn1p_value_t *val; + int slen; + int memlen; + int baselen; + int bits; + uint8_t *binary_vector; + uint8_t *bv_ptr; + uint8_t cur_val; + + assert(str); + assert(str[0] == '\''); + + switch(base) { + case 'B': + baselen = 1; + break; + case 'H': + baselen = 4; + break; + default: + assert(base == 'B' || base == 'H'); + errno = EINVAL; + return NULL; + } + + slen = strlen(str); + assert(str[slen - 1] == base); + assert(str[slen - 2] == '\''); + + memlen = slen / (8 / baselen); /* Conservative estimate */ + + bv_ptr = binary_vector = malloc(memlen + 1); + if(bv_ptr == NULL) + /* ENOMEM */ + return NULL; + + cur_val = 0; + bits = 0; + while(*(++str) != '\'') { + switch(baselen) { + case 1: + switch(*str) { + case '1': + cur_val |= 1 << (7 - (bits % 8)); + case '0': + break; + default: + assert(!"_y UNREACH1"); + case ' ': case '\r': case '\n': + continue; + } + break; + case 4: + switch(*str) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + cur_val |= (*str - '0') << (4 - (bits % 8)); + break; + case 'A': case 'B': case 'C': + case 'D': case 'E': case 'F': + cur_val |= ((*str - 'A') + 10) + << (4 - (bits % 8)); + break; + default: + assert(!"_y UNREACH2"); + case ' ': case '\r': case '\n': + continue; + } + break; + } + + bits += baselen; + if((bits % 8) == 0) { + *bv_ptr++ = cur_val; + cur_val = 0; + } + } + + *bv_ptr = cur_val; + assert((bv_ptr - binary_vector) <= memlen); + + val = asn1p_value_frombits(binary_vector, bits, 0); + if(val == NULL) { + free(binary_vector); + } + + return val; +} + +extern char *asn1p_text; + +int +yyerror(const char *msg) { + fprintf(stderr, + "ASN.1 grammar parse error " + "near line %d (token \"%s\"): %s\n", + asn1p_lineno, asn1p_text, msg); + return -1; +} + + diff --git a/libasn1parser/asn1parser.c b/libasn1parser/asn1parser.c new file mode 100644 index 00000000..b5d9e1e4 --- /dev/null +++ b/libasn1parser/asn1parser.c @@ -0,0 +1,171 @@ +#include +#include +#include +#include +#include +#include + +#include "asn1parser.h" +#include "asn1p_list.h" + +int asn1p_parse(void **param); + +void *asn1p__scan_bytes(const char *, int len); +void *asn1p__delete_buffer(void *); +void *asn1p_restart(FILE *); + +extern int asn1p_lineno; + +static int _asn1p_set_flags(enum asn1p_flags flags); +static int _asn1p_assign_filename(asn1p_t *a, const char *fname); + +/* + * Parse the given buffer. + */ +asn1p_t * +asn1p_parse_buffer(const char *buffer, int size /* = -1 */, enum asn1p_flags flags) { + asn1p_t *a = 0; + void *ap; + void *ybuf; + int ret; + + if(_asn1p_set_flags(flags)) { + /* EINVAL */ + return 0; + } + + if(size < 0) + size = strlen(buffer); + + ybuf = asn1p__scan_bytes(buffer, size); + if(!ybuf) { + assert(ybuf); + return 0; + } + + asn1p_lineno = 1; + + ap = (void *)&a; + ret = asn1p_parse(ap); + + asn1p__delete_buffer(ybuf); + + if(ret == 0) { + assert(a); + if(_asn1p_assign_filename(a, "-")) + return NULL; /* FIXME: destroy (a) */ + } else { + assert(a == NULL); + } + + return a; +} + + +/* + * Parse the file identified by its name. + */ +asn1p_t * +asn1p_parse_file(const char *filename, enum asn1p_flags flags) { + struct stat sb; + asn1p_t *a = 0; + void *ap; + FILE *fp; + int ret; + + if(_asn1p_set_flags(flags)) { + /* EINVAL */ + return 0; + } + + fp = fopen(filename, "r"); + if(fp == NULL) { + perror(filename); + return NULL; + } + + if(fstat(fileno(fp), &sb) + || !S_ISREG(sb.st_mode)) { + fclose(fp); + fprintf(stderr, "%s file not recognized: Bad file format\n", + filename); + errno = EINVAL; + return NULL; + } + + asn1p_lineno = 1; + + asn1p_restart(fp); + + ap = (void *)&a; + ret = asn1p_parse(ap); + + fclose(fp); + + if(ret == 0) { + assert(a); + if(_asn1p_assign_filename(a, filename)) + return NULL; /* FIXME: destroy (a) */ + } else { + assert(a == NULL); + } + + return a; +} + +extern int asn1p_lexer_types_year; +extern int asn1p_lexer_constructs_year; +extern int asn1p__flex_debug; + +static int +_asn1p_set_flags(enum asn1p_flags flags) { + + asn1p_lexer_types_year = 0; + asn1p_lexer_constructs_year = 0; + asn1p__flex_debug = 0; + + /* + * Enable debugging in lexer. + */ + if(flags & A1P_LEXER_DEBUG) { + flags &= ~A1P_LEXER_DEBUG; + asn1p__flex_debug = 1; + } + + /* + * Restrict embedded types to ASN.1:1988 version of standard. + */ + if(flags & A1P_TYPES_RESTRICT_TO_1988) { + flags &= ~A1P_TYPES_RESTRICT_TO_1988; + asn1p_lexer_types_year = 1988; + } + + /* + * Restrict embedded types to ASN.1:1988 version of standard. + */ + if(flags & A1P_TYPES_RESTRICT_TO_1988) { + flags &= ~A1P_TYPES_RESTRICT_TO_1988; + asn1p_lexer_types_year = 1988; + } + + /* + * Check that we haven't missed an unknown flag. + */ + if(flags) { + errno = EINVAL; + return -1; + } + + return 0; +} + +static int +_asn1p_assign_filename(asn1p_t *a, const char *fname) { + asn1p_module_t *mod; + TQ_FOR(mod, &(a->modules), mod_next) { + mod->source_file_name = strdup(fname); + if(mod->source_file_name == NULL) + return -1; + } + return 0; +} diff --git a/libasn1parser/asn1parser.h b/libasn1parser/asn1parser.h new file mode 100644 index 00000000..b4c72f8b --- /dev/null +++ b/libasn1parser/asn1parser.h @@ -0,0 +1,73 @@ +/* + * This is a parser of the ASN.1 grammar. + */ +#ifndef ASN1PARSER_H +#define ASN1PARSER_H + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#ifdef HAVE_SYS_TYPES_H +#include +#endif /* HAVE_SYS_TYPES_H */ +#ifdef HAVE_INTTYPES_H +#include /* POSIX 1003.1-2001, C99 */ +#else /* HAVE_INTTYPES_H */ +#ifdef HAVE_STDINT_H +#include /* SUSv2+ */ +#endif /* HAVE_STDINT_H */ +#endif /* HAVE_INTTYPES_H */ + +/* + * Basic integer type used in numerous places. + * ASN.1 does not define any limits on this number, so it must be sufficiently + * large to accomodate typical inputs. It does not have to be a dynamically + * allocated type with potentially unlimited width: consider the width of + * an integer defined here as one of the "compiler limitations". + * NOTE: this is NOT a type for ASN.1 "INTEGER" type representation, this + * type is used by the compiler itself to handle large integer values + * specified inside ASN.1 grammar. + */ +typedef intmax_t asn1_integer_t; + +#include +#include /* Object identifiers (OIDs) */ +#include /* References to custom types */ +#include /* Value definition */ +#include /* Parametrization */ +#include /* Type Constraints */ +#include /* IMports/EXports */ +#include /* ASN.1 definition module */ +#include /* CLASS-related stuff */ +#include /* A single ASN.1 expression */ + +/* + * Parser flags. + */ +enum asn1p_flags { + A1P_NOFLAGS, + /* + * Enable verbose debugging output from lexer. + */ + A1P_LEXER_DEBUG = 0x0001, + /* + * Embedded types restricted to ASN.1:1988 + */ + A1P_TYPES_RESTRICT_TO_1988 = 0x0010, + /* + * Embedded constructs (concepts) restricted to ASN.1:1990 + */ + A1P_CONSTRUCTS_RESTRICT_TO_1990 = 0x0020, +}; + +/* + * Perform low-level parsing of ASN.1 module[s] + * and return a list of module trees. + */ +asn1p_t *asn1p_parse_file(const char *filename, + enum asn1p_flags); +asn1p_t *asn1p_parse_buffer(const char *buffer, int size /* = -1 */, + enum asn1p_flags); + +#endif /* ASN1PARSER_H */ diff --git a/libasn1parser/expr-h.pl b/libasn1parser/expr-h.pl new file mode 100755 index 00000000..c00128a0 --- /dev/null +++ b/libasn1parser/expr-h.pl @@ -0,0 +1,49 @@ +#!/usr/bin/perl + + +print<) { + chomp; + next if(/TYPE_MAX/); + next unless(/^[ \t]+(ASN_[A-Z]+_([A-Za-z0-9_]+))/); + + print "\t[ $1 ]\t = "; + + $_ = $2; + if($_ eq "RELATIVE_OID") { + print '"RELATIVE-OID"'; + } else { + s/_/ /; + print '"'.$_.'"'; + } + + print ",\n"; +} + +print<= sizeof(asn1p_expr_type2str) \\ + / sizeof(asn1p_expr_type2str[0])) \\ + ? (char *)0 \\ + : asn1p_expr_type2str[(type)] \\ + ) + +#endif /* ASN1_PARSER_EXPR_STR_H */ +EOM diff --git a/libasn1print/Makefile.am b/libasn1print/Makefile.am new file mode 100644 index 00000000..fb4861a4 --- /dev/null +++ b/libasn1print/Makefile.am @@ -0,0 +1,14 @@ + +AM_CFLAGS = @ADD_CFLAGS@ +AM_CPPFLAGS = -I${top_srcdir}/libasn1parser + +noinst_LTLIBRARIES = libasn1print.la + +libasn1print_la_LDFLAGS = -all-static +libasn1print_la_SOURCES = \ + asn1print.c asn1print.h + +LDADD = ${noinst_LTLIBRARIES} ${libasn1fix_la_LIBADD} +DEPENDENCIES = ${LDADD} + +TESTS = ${check_PROGRAMS} diff --git a/libasn1print/Makefile.in b/libasn1print/Makefile.in new file mode 100644 index 00000000..e1e876e5 --- /dev/null +++ b/libasn1print/Makefile.in @@ -0,0 +1,382 @@ +# Makefile.in generated automatically by automake 1.5 from Makefile.am. + +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +# Free Software Foundation, Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +bindir = @bindir@ +sbindir = @sbindir@ +libexecdir = @libexecdir@ +datadir = @datadir@ +sysconfdir = @sysconfdir@ +sharedstatedir = @sharedstatedir@ +localstatedir = @localstatedir@ +libdir = @libdir@ +infodir = @infodir@ +mandir = @mandir@ +includedir = @includedir@ +oldincludedir = /usr/include +pkgdatadir = $(datadir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +top_builddir = .. + +ACLOCAL = @ACLOCAL@ +AUTOCONF = @AUTOCONF@ +AUTOMAKE = @AUTOMAKE@ +AUTOHEADER = @AUTOHEADER@ + +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_HEADER = $(INSTALL_DATA) +transform = @program_transform_name@ +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_alias = @build_alias@ +build_triplet = @build@ +host_alias = @host_alias@ +host_triplet = @host@ +target_alias = @target_alias@ +target_triplet = @target@ +ADD_CFLAGS = @ADD_CFLAGS@ +AMTAR = @AMTAR@ +AR = @AR@ +AS = @AS@ +AWK = @AWK@ +CC = @CC@ +CONFIGURE_DEPENDS = @CONFIGURE_DEPENDS@ +CPP = @CPP@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +EXEEXT = @EXEEXT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LEX = @LEX@ +LIBTOOL = @LIBTOOL@ +LN_S = @LN_S@ +MAINT = @MAINT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +PACKAGE = @PACKAGE@ +PATH = @PATH@ +RANLIB = @RANLIB@ +VERSION = @VERSION@ +YACC = @YACC@ +am__include = @am__include@ +am__quote = @am__quote@ +install_sh = @install_sh@ + +AM_CFLAGS = @ADD_CFLAGS@ +AM_CPPFLAGS = -I${top_srcdir}/libasn1parser + +noinst_LTLIBRARIES = libasn1print.la + +libasn1print_la_LDFLAGS = -all-static +libasn1print_la_SOURCES = \ + asn1print.c asn1print.h + + +LDADD = ${noinst_LTLIBRARIES} ${libasn1fix_la_LIBADD} +DEPENDENCIES = ${LDADD} + +TESTS = ${check_PROGRAMS} +subdir = libasn1print +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) + +libasn1print_la_LIBADD = +am_libasn1print_la_OBJECTS = asn1print.lo +libasn1print_la_OBJECTS = $(am_libasn1print_la_OBJECTS) + +DEFS = @DEFS@ +DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +depcomp = $(SHELL) $(top_srcdir)/depcomp +@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/asn1print.Plo +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \ + $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ + $(AM_LDFLAGS) $(LDFLAGS) -o $@ +CFLAGS = @CFLAGS@ +DIST_SOURCES = $(libasn1print_la_SOURCES) +DIST_COMMON = README Makefile.am Makefile.in +SOURCES = $(libasn1print_la_SOURCES) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + -rm -f libtool +$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) + cd $(top_srcdir) && \ + $(AUTOMAKE) --gnu libasn1print/Makefile +Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status + cd $(top_builddir) && \ + CONFIG_HEADERS= CONFIG_LINKS= \ + CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) +libasn1print.la: $(libasn1print_la_OBJECTS) $(libasn1print_la_DEPENDENCIES) + $(LINK) $(libasn1print_la_LDFLAGS) $(libasn1print_la_OBJECTS) $(libasn1print_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) core *.core + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/asn1print.Plo@am__quote@ + +distclean-depend: + -rm -rf $(DEPDIR) + +.c.o: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< + +.c.obj: +@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(COMPILE) -c `cygpath -w $<` + +.c.lo: +@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@ +@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ + $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< +CCDEPMODE = @CCDEPMODE@ +uninstall-info-am: + +tags: TAGS + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + mkid -fID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) + +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) $$here + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; \ + srcdir=$(srcdir); export srcdir; \ + list='$(TESTS)'; \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + echo "XPASS: $$tst"; \ + ;; \ + *) \ + echo "PASS: $$tst"; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *" $$tst "*) \ + xfail=`expr $$xfail + 1`; \ + echo "XFAIL: $$tst"; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + echo "FAIL: $$tst"; \ + ;; \ + esac; \ + fi; \ + done; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="All $$all tests passed"; \ + else \ + banner="All $$all tests behaved as expected ($$xfail expected failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all tests failed"; \ + else \ + banner="$$failed of $$all tests did not behave as expected ($$xpass unexpected passes)"; \ + fi; \ + fi; \ + dashes=`echo "$$banner" | sed s/./=/g`; \ + echo "$$dashes"; \ + echo "$$banner"; \ + echo "$$dashes"; \ + test "$$failed" -eq 0; \ + fi + +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) + +top_distdir = .. +distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) + +distdir: $(DISTFILES) + @for file in $(DISTFILES); do \ + if test -f $$file; then d=.; else d=$(srcdir); fi; \ + dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test "$$dir" != "$$file" && test "$$dir" != "."; then \ + $(mkinstalldirs) "$(distdir)/$$dir"; \ + fi; \ + if test -d $$d/$$file; then \ + cp -pR $$d/$$file $(distdir) \ + || exit 1; \ + else \ + test -f $(distdir)/$$file \ + || cp -p $$d/$$file $(distdir)/$$file \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-am +all-am: Makefile $(LTLIBRARIES) + +installdirs: + +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + +distclean-generic: + -rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]* + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + +distclean-am: clean-am distclean-compile distclean-depend \ + distclean-generic distclean-libtool distclean-tags + +dvi: dvi-am + +dvi-am: + +info: info-am + +info-am: + +install-data-am: + +install-exec-am: + +install-info: install-info-am + +install-man: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +uninstall-am: uninstall-info-am + +.PHONY: GTAGS all all-am check check-TESTS check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES distclean \ + distclean-compile distclean-depend distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am info \ + info-am install install-am install-data install-data-am \ + install-exec install-exec-am install-info install-info-am \ + install-man install-strip installcheck installcheck-am \ + installdirs maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool tags uninstall uninstall-am \ + uninstall-info-am + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/libasn1print/README b/libasn1print/README new file mode 100644 index 00000000..5c1071cf --- /dev/null +++ b/libasn1print/README @@ -0,0 +1,4 @@ + +Ad hoc ASN tree printing procedures. Use for debugging purposes, this library +isn't thought through enough to be universally useful or even accurate. + diff --git a/libasn1print/asn1print.c b/libasn1print/asn1print.c new file mode 100644 index 00000000..992dcfa0 --- /dev/null +++ b/libasn1print/asn1print.c @@ -0,0 +1,456 @@ +#include +#include +#include +#include + +#include + +#include "asn1print.h" + +#define INDENT(fmt, args...) do { \ + int __i = level; while(__i--) putchar(' '); \ + printf(fmt, ##args); \ + } while(0) + +static int asn1print_module(asn1p_module_t *mod, enum asn1print_flags_e flags); +static int asn1print_oid(asn1p_oid_t *oid, enum asn1print_flags_e flags); +static int asn1print_ref(asn1p_ref_t *ref, enum asn1print_flags_e flags); +static int asn1print_tag(asn1p_expr_t *tc, enum asn1print_flags_e flags); +static int asn1print_params(asn1p_paramlist_t *pl,enum asn1print_flags_e flags); +static int asn1print_with_syntax(asn1p_wsyntx_t *wx, enum asn1print_flags_e flags); +static int asn1print_constraint(asn1p_constraint_t *, enum asn1print_flags_e); +static int asn1print_value(asn1p_value_t *val, enum asn1print_flags_e flags); +static int asn1print_expr(asn1p_expr_t *tc, enum asn1print_flags_e flags, + int level); + +/* + * Print the contents of the parsed ASN tree. + */ +int +asn1print(asn1p_t *asn, enum asn1print_flags_e flags) { + asn1p_module_t *mod; + + if(asn == NULL) { + errno = EINVAL; + return -1; + } + + TQ_FOR(mod, &(asn->modules), mod_next) { + asn1print_module(mod, flags); + } + + return 0; +} + +static int +asn1print_module(asn1p_module_t *mod, enum asn1print_flags_e flags) { + asn1p_expr_t *tc; + + if(!(flags & APF_NO_SOURCE_COMMENTS)) + printf("\n-- Contents of \"%s\"\n", mod->source_file_name); + + printf("\n%s ", mod->Identifier); + if(mod->module_oid) { + asn1print_oid(mod->module_oid, flags); + printf("\n"); + } + + printf("DEFINITIONS"); + + if(mod->module_flags & MSF_EXPLICIT_TAGS) + printf(" EXPLICIT TAGS"); + if(mod->module_flags & MSF_IMPLICIT_TAGS) + printf(" IMPLICIT TAGS"); + if(mod->module_flags & MSF_AUTOMATIC_TAGS) + printf(" AUTOMATIC TAGS"); + if(mod->module_flags & MSF_EXTENSIBILITY_IMPLIED) + printf(" EXTENSIBILITY IMPLIED"); + + printf(" ::=\n"); + printf("BEGIN\n\n"); + + TQ_FOR(tc, &(mod->members), next) { + asn1print_expr(tc, flags, 0); + printf("\n\n"); + } + + printf("END\n"); + + return 0; +} + +static int +asn1print_oid(asn1p_oid_t *oid, enum asn1print_flags_e flags) { + int ac; + int accum = 0; + + printf("{"); + for(ac = 0; ac < oid->arcs_count; ac++) { + if(accum + strlen(oid->arcs[ac].name?:"") > 50) { + printf("\n\t"); + accum = 0; + } else if(ac) printf(" "); + + if(oid->arcs[ac].name) { + printf("%s(%d)", + oid->arcs[ac].name, + (int)oid->arcs[ac].number); + accum += strlen(oid->arcs[ac].name); + } else { + printf("%d", + (int)oid->arcs[ac].number); + } + accum += 4; + } + printf(" }"); + + return 0; +} + +static int +asn1print_ref(asn1p_ref_t *ref, enum asn1print_flags_e flags) { + int cc; + + for(cc = 0; cc < ref->comp_count; cc++) { + if(cc) printf("."); + printf("%s", ref->components[cc].name); + } + + return 0; +} + +static int +asn1print_tag(asn1p_expr_t *tc, enum asn1print_flags_e flags) { + struct asn1p_type_tag_s *tag = &tc->tag; + + if(tag->tag_class == TC_NOCLASS) + return 0; + + printf("["); + switch(tag->tag_class) { + case TC_NOCLASS: + assert(tag->tag_class != TC_NOCLASS); + break; + case TC_UNIVERSAL: printf("UNIVERSAL "); break; + case TC_PRIVATE: printf("PRIVATE "); break; + case TC_APPLICATION: printf("APPLICATION "); break; + case TC_CONTEXT_SPECIFIC: + break; + } + printf("%lld]", (long long)tag->tag_value); + + switch(tag->tag_mode) { + case TM_DEFAULT: break; + case TM_IMPLICIT: printf(" IMPLICIT"); break; + case TM_EXPLICIT: printf(" EXPLICIT"); break; + } + + return 0; +} + +static int +asn1print_value(asn1p_value_t *val, enum asn1print_flags_e flags) { + + if(val == NULL) + return 0; + + switch(val->type) { + case ATV_NOVALUE: + break; + case ATV_REFERENCED: + return asn1print_ref(val->value.reference, flags); + case ATV_INTEGER: + printf("%lld", (long long)val->value.v_integer); + return 0; + case ATV_MIN: printf("MIN"); return 0; + case ATV_MAX: printf("MAX"); return 0; + case ATV_FALSE: printf("FALSE"); return 0; + case ATV_TRUE: printf("TRUE"); return 0; + case ATV_REAL: + printf("%f", val->value.v_double); + return 0; + case ATV_STRING: + { + char *p = val->value.string.buf; + putchar('"'); + if(strchr(p, '"')) { + /* Mask quotes */ + for(; *p; p++) { + if(*p == '"') + putchar(*p); + putchar(*p); + } + } else { + fputs(p, stdout); + } + putchar('"'); + } + return 0; + case ATV_UNPARSED: + fputs(val->value.string.buf, stdout); + return 0; + case ATV_BITVECTOR: + { + uint8_t *bitvector; + int bits; + int i; + + bitvector = val->value.binary_vector.bits; + bits = val->value.binary_vector.size_in_bits; + + printf("'"); + if(bits%8) { + for(i = 0; i < bits; i++) { + uint8_t uc; + uc = bitvector[i>>3]; + putchar(((uc >> (7-(i%8)))&1)?'1':'0'); + } + printf("'B"); + } else { + char hextable[16] = "0123456789ABCDEF"; + for(i = 0; i < (bits>>3); i++) { + putchar(hextable[bitvector[i] >> 4]); + putchar(hextable[bitvector[i] & 0x0f]); + } + printf("'H"); + } + } + } + + assert(val->type || !"Unknown"); + + return 0; +} + +static int +asn1print_constraint(asn1p_constraint_t *ct, enum asn1print_flags_e flags) { + int symno = 0; + + if(ct == 0) return 0; + + if(ct->type == ACT_CA_SET) + printf("("); + + switch(ct->type) { + case ACT_EL_VALUE: + asn1print_value(ct->value, flags); + break; + case ACT_EL_RANGE: + case ACT_EL_LLRANGE: + case ACT_EL_RLRANGE: + case ACT_EL_ULRANGE: + asn1print_value(ct->range_start, flags); + switch(ct->type) { + case ACT_EL_RANGE: printf(".."); break; + case ACT_EL_LLRANGE: printf("<.."); break; + case ACT_EL_RLRANGE: printf("..<"); break; + case ACT_EL_ULRANGE: printf("<..<"); break; + default: printf("?..?"); break; + } + asn1print_value(ct->range_stop, flags); + break; + case ACT_EL_EXT: + printf("..."); + break; + case ACT_CT_SIZE: + case ACT_CT_FROM: + switch(ct->type) { + case ACT_CT_SIZE: printf("SIZE ("); break; + case ACT_CT_FROM: printf("FROM ("); break; + default: printf("??? ("); break; + } + assert(ct->el_count != 0); + assert(ct->el_count == 1); + asn1print_constraint(ct->elements[0], flags); + printf(")"); + break; + case ACT_CT_WCOMP: + case ACT_CT_WCOMPS: + printf("???"); + break; + case ACT_CA_SET: symno++; + case ACT_CA_CRC: symno++; + case ACT_CA_CSV: symno++; + case ACT_CA_UNI: symno++; + case ACT_CA_INT: symno++; + case ACT_CA_EXC: + { + char *symtable[] = { " EXCEPT ", "^", "|", ",", + "", "(" }; + int i; + for(i = 0; i < ct->el_count; i++) { + enum asn1print_flags_e nflags = flags; + if(i) fputs(symtable[symno], stdout); + if(ct->type == ACT_CA_CRC) fputs("{", stdout); + asn1print_constraint(ct->elements[i], nflags); + if(ct->type == ACT_CA_CRC) fputs("}", stdout); + if(i+1 < ct->el_count + && ct->type == ACT_CA_SET) + fputs(")", stdout); + } + } + break; + case ACT_INVALID: + assert(ct->type != ACT_INVALID); + break; + } + + if(ct->type == ACT_CA_SET) + printf(")"); + + return 0; +} + +static int +asn1print_params(asn1p_paramlist_t *pl, enum asn1print_flags_e flags) { + if(pl) { + int i; + printf("{"); + for(i = 0; i < pl->params_count; i++) { + if(i) printf(", "); + if(pl->params[i].governor) { + asn1print_ref(pl->params[i].governor, flags); + printf(":"); + } + printf("%s", pl->params[i].argument); + } + printf("}"); + } + + return 0; +} + +static int +asn1print_with_syntax(asn1p_wsyntx_t *wx, enum asn1print_flags_e flags) { + if(wx) { + asn1p_wsyntx_chunk_t *wc; + printf(" WITH SYNTAX {"); + TQ_FOR(wc, &(wx->chunks), next) { + if(wc->ref) { + asn1print_ref(wc->ref, flags); + } else { + fwrite(wc->buf, 1, wc->len, stdout); + } + } + printf("}\n"); + } + + return 0; +} + +static int +asn1print_expr(asn1p_expr_t *tc, enum asn1print_flags_e flags, int level) { + + if(flags & APF_LINE_COMMENTS) + INDENT("-- #line %d\n", tc->_lineno); + if(tc->Identifier) + INDENT("%s", tc->Identifier); + + if(tc->params) { + asn1print_params(tc->params, flags); + } + + if(tc->meta_type != AMT_VALUE + && tc->expr_type != A1TC_EXTENSIBLE) { + if(level) { + if(tc->Identifier) + printf("\t"); + } else { + printf(" ::="); + } + } + + if(tc->tag.tag_class) { + printf(" "); + asn1print_tag(tc, flags); + } + + switch(tc->expr_type) { + case A1TC_EXTENSIBLE: + if(tc->value) { + printf("!"); + asn1print_value(tc->value, flags); + } + break; + case A1TC_REFERENCE: + case A1TC_UNIVERVAL: + case A1TC_PARAMETRIZED: + break; + case A1TC_CLASSDEF: + printf(" CLASS"); + break; + case A1TC_CLASSFIELD: + /* Nothing to print here */ + break; + default: + { + char *p = ASN_EXPR_TYPE2STR(tc->expr_type); + printf(" %s", p?p:""); + } + break; + } + + if(tc->reference) { + printf(" "); + asn1print_ref(tc->reference, flags); + } + + /* + * Display the descendants (children) of the current type. + */ + if(TQ_FIRST(&(tc->members))) { + asn1p_expr_t *se; /* SubExpression */ + + if((tc->expr_type != ASN_CONSTR_SEQUENCE_OF + && tc->expr_type != ASN_CONSTR_SET_OF) + || TQ_FIRST(&(tc->members))->expr_type & ASN_CONSTR_MASK) + printf(" {\n"); + + TQ_FOR(se, &(tc->members), next) { + /* + * Print the expression as it were stand-alone type. + */ + asn1print_expr(se, flags, level + 4); + switch(se->marker) { + case EM_NOMARK: break; + case EM_OPTIONAL: printf(" OPTIONAL"); break; + case EM_DEFAULT: printf(" DEFAULT "); break; + } + if(TQ_NEXT(se, next)) { + printf(","); + INDENT("\n"); + } + } + + if((tc->expr_type != ASN_CONSTR_SEQUENCE_OF + && tc->expr_type != ASN_CONSTR_SET_OF) + || TQ_FIRST(&(tc->members))->expr_type & ASN_CONSTR_MASK) { + printf("\n"); + INDENT("}"); + } + } + + if(tc->with_syntax) + asn1print_with_syntax(tc->with_syntax, flags); + + if(tc->constraints) { + printf(" "); + asn1print_constraint(tc->constraints, flags); + } + if(tc->unique) { + printf(" UNIQUE"); + } + + if(tc->meta_type == AMT_VALUE + && tc->expr_type != A1TC_EXTENSIBLE) { + if(tc->expr_type == A1TC_UNIVERVAL) + printf("("); + else + printf(" ::= "); + asn1print_value(tc->value, flags); + if(tc->expr_type == A1TC_UNIVERVAL) + printf(")"); + } + + return 0; +} diff --git a/libasn1print/asn1print.h b/libasn1print/asn1print.h new file mode 100644 index 00000000..73875fb1 --- /dev/null +++ b/libasn1p