Commit b4bb2b95 authored by shengyp0929's avatar shengyp0929

commit for asn1c-r1516

parents
*.o
*.la
*.lo
*.libs
*.deps
*.core
# /
/autom4te.cache
/config.h
/config.log
/config.cache
/config.status
/configure.lineno
/local-configure.sh
/libtool
/stamp-h*
/asn1c-*.tar.gz
/asn1c.spec
/Makefile
# /asn1c/
/asn1c/Makefile
/asn1c/asn1c
/asn1c/unber
/asn1c/enber
# /asn1c/tests/
/asn1c/tests/Makefile
/asn1c/tests/test-*
# /doc/
/doc/Makefile
# /doc/docsrc
/doc/docsrc/Makefile
doc/docsrc/*.aux
doc/docsrc/*.dvi
doc/docsrc/*.log
doc/docsrc/*.out
doc/docsrc/*.toc
doc/docsrc/*.xdv
# /examples/
/examples/Makefile
/examples/*.asn1
# /examples/*/
/examples/*/*.c
/examples/*/*.h
/examples/*/*dump
/examples/*/.tmp.*
# /libasn1compiler/
/libasn1compiler/Makefile
/libasn1compiler/check_compiler
# /libasn1fix/
/libasn1fix/Makefile
/libasn1fix/check_fixer
# /libasn1parser/
/libasn1parser/Makefile
/libasn1parser/check_parser
# /libasn1print/
/libasn1print/Makefile
# /skeletons/
/skeletons/Makefile
# /skeletons/standard-modules/
/skeletons/standard-modules/Makefile
# /skeletons/tests/
/skeletons/tests/Makefile
/skeletons/tests/check-*
# /tests/
/tests/Makefile
Lev Walkin <vlm@lionet.info>
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. 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.
2. A MACRO facility is part of obsolete ASN.1 standard, and is not supported.
3. 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
4. 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.
5. Encoding or decoding of structures with combined length greater than 16MB
is not tested.
6. XER codec does not support integer (INTEGER, ENUMERATED) values
outside the signed long range.
/*-
* Copyright (c) 2003, 2004, 2005, 2006, 2007 Lev Walkin <vlm@lionet.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
*/
This diff is collapsed.
1.Q: Is it possible to build the asn1c compiler on Win32?
1.A:
At this point, the asn1c source code is tied to GCC-specific
extensions in several key places. The CYGWIN environment with
gcc compiler may be what are you looking for.
Please also consider using the Online ASN.1 compiler at
http://lionet.info/asn1c
which generates platform-independent code.
2.Q: How to build a simplest BER (XER) encoder or decoder?
2.A:
Please check the "Quick Start Guide" on ./doc/asn1c-quick.pdf
Please check the "Examples" section of ./doc/asn1c-usage.pdf
Also, try the following to build the X.509v3 parser:
cd ./examples/sample.source.PKIX1
make
./x509dump -h
3.Q: Your compiler supplies a der_encode() procedure. How do I encode BER?
3.A:
The DER (and CER) are stricter subsets of a more generic BER encoding
method. If you encode data with DER or CER, all BER-conformant decoders
will easily understand that. Hence, to encode data in the BER format,
simply use the DER encoder, der_encode().
See also: ISO/IEC 8825-1 / X.690:
"ASN.1 encoding rules: Specification of
Basic Encoding Rules (BER),
Canonical Encoding Rules (CER) and
Distinguished Encoding Rules (DER)"
--
Lev Walkin
vlm@lionet.info
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
# PLEASE CONTACT ME IF THIS FAILS ON YOUR PLATFORM!
make install # Install the compiler into standard location
man asn1c # Display the asn1c manual page
QUICK USAGE GUIDE
=================
For usage guide and more information please refer to the README file.
In case of any difficulties with installing the compiler, consider using
the Online ASN.1 Compiler at
http://lionet.info/asn1c
--
Lev Walkin
vlm@lionet.info
libasn1compiler
libasn1parser
libasn1print
libasn1fix
skeletons
examples
tests
asn1c
doc
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = \
libasn1parser libasn1fix \
libasn1print libasn1compiler \
skeletons examples tests \
doc asn1c
docsdir = $(datadir)/doc/asn1c
docs_DATA = README FAQ COPYING ChangeLog BUGS TODO
EXTRA_DIST = asn1c.spec.in FAQ BUGS MANIFEST
CLEANFILES = asn1c.spec
This diff is collapsed.
WHAT TO READ?
=============
If you haven't installed the asn1c yet, read the INSTALL file for
a short installation guide.
For the list of asn1c command line options, see `asn1c -h` or `man asn1c`.
For more complete documentation on this compiler and on using the
results of compilation phase, please look into asn1c-quick.pdf and
asn1c-usage.{pdf,html}.
If you are building the compiler from the sources, these documents reside
in the ./doc directory, otherwise they lie nearby the README file you're
reading right now.
Please also read the FAQ file.
An excellent book on ASN.1 is written by Olivier Dubuisson:
"ASN.1 Communication between heterogeneous systems", ISBN:0-12-6333361-0.
QUICK START (also check out asn1c-quick.pdf)
============================================
After building [and installing] the compiler (see INSTALL), you may use
the asn1c command to compile the ASN.1 specification:
asn1c <module.asn1> # Compile module
If several specifications contain interdependencies, all of them must be
specified:
asn1c <module1.asn1> <module2.asn1> ... # Compile interdependent modules
If you are building the asn1c from the sources, the ./examples directory
contains several ASN.1 modules and a script to extract the ASN.1 modules
from RFC documents. Refer to the README file in that directory.
To compile the X.509 PKI module:
./asn1c/asn1c -P ./examples/rfc3280-*.asn1 # Compile-n-print
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 ASN.1 modules.
This is useful for debugging and test 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 <module-to-test.asn1> # Check semantic validity
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 a process of checking the tree for semantic errors,
accompanied by the tree transformation into the canonical form)
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:
<parser> => print (-E)
<parser> => <fixer> => print (-E -F)
<parser> => <fixer> => <compiler> => print (-P)
<parser> => <fixer> => <compiler> => save-compiled [default]
--
Lev Walkin
vlm@lionet.info
1. MAJOR:
1.1 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.
2. MEDIUM:
2.1 Support for EXTERNAL, EMBEDDED-PDV and CHARACTER STRING types.
Requires something from 1.2 (Information Object Classes).
This diff is collapsed.
#
# $Id$
#
Name: @PACKAGE@
Version: @VERSION@
Release: 2
Copyright: Lev Walkin <vlm@lionet.info>
Source: %{name}-%{version}.tar.gz
Url: http://asn1c.sourceforge.net/
BuildRoot: /var/tmp/%{name}-root
Group: Development/Languages
Summary: The ASN.1 to C compiler
%description
The asn1c compiler turns ASN.1 specifications into C language
source files containing the BER/CER/DER/PER/XER encoders and decoders
for the given abstract notation.
%prep
%setup -q
%build
./configure
%{_make} DESTDIR=$RPM_BUILD_ROOT
%install
rm -rf $RPM_BUILD_ROOT
%{__make} install-exec DESTDIR=$RPM_BUILD_ROOT
(cd skeletons && %{__make} install-data DESTDIR=$RPM_BUILD_ROOT)
(cd asn1c && %{__make} install-man DESTDIR=$RPM_BUILD_ROOT)
%clean
rm -rf $RPM_BUILD_ROOT
%files
%doc README FAQ COPYING ChangeLog BUGS TODO
%doc doc/asn1c-usage.pdf doc/asn1c-usage.html
%attr(755,root,root) %{_bindir}
%attr(644,root,root) %{_datadir}/asn1c
%{_mandir}/man1
%changelog
* Sun Sep 18 2006 Lev Walkin <vlm@lionet.info>
- Added PER support into description
* Sun Sep 26 2004 Lev Walkin <vlm@lionet.info>
- All manuals are now getting installed, including new ones: unber.1 and enber.1
* Tue Sep 18 2004 Lev Walkin <vlm@lionet.info>
- First version of asn1c.spec
SUBDIRS = . tests
AM_CFLAGS = @ADD_CFLAGS@
AM_CPPFLAGS = \
-I${top_srcdir}/libasn1compiler \
-I${top_srcdir}/libasn1parser \
-I${top_srcdir}/libasn1print \
-I${top_srcdir}/libasn1fix \
-I${top_srcdir}/skeletons \
-DDATADIR=\"$(pkgdatadir)\"
asn1c_LDADD = \
$(top_builddir)/libasn1parser/libasn1parser.la \
$(top_builddir)/libasn1print/libasn1print.la \
$(top_builddir)/libasn1fix/libasn1fix.la \
$(top_builddir)/libasn1compiler/libasn1compiler.la
bin_PROGRAMS = asn1c unber enber
noinst_HEADERS = sys-common.h
dist_man1_MANS = asn1c.1 unber.1 enber.1
dist_check_SCRIPTS = check-xxber.sh check-parsing.sh
TESTS = $(dist_check_SCRIPTS)
CLEANFILES = .check-xxber.*.tmp .check-parsing.*.tmp
This diff is collapsed.
asn1c - The ASN.1 Compiler
unber - The ASN.1 BER Decoder
enber - Reverse unber(1) output back into BER
.TH ASN1C 1 "\*(Dt" "ASN.1 Compiler" "ASN.1 Compiler"
.SH NAME
asn1c \- ASN.1 Compiler
.SH SYNOPSIS
asn1c [\fB\-E\fR [\fB-F\fR] | \fB\-P\fR | \fB\-R\fR]
[\fB\-S\fR\fIdir\fR] [\fB-X\fR]
[\fB\-W\fR\fIdebug-\fR...] [\fB\-f\fR\fIoption\fR] [\fB\-gen-\fR\fIoption\fR] [\fB\-pdu=\fR{\fBall\fR|\fBauto\fR|\fIType\fR}\fR]
[\fB\-print-\fR\fIoption\fR]
\fIinfile\fR...
.SH DESCRIPTION
asn1c compiles ASN.1 specifications into a set of
target language (C/C++) encoders and decoders for BER, DER, PER, XER
and other encoding rules.
.SH OPTIONS
.TP
\fIOverall Options\fR
\fB\-E \-F \-P \-R\fR
.BI "\-S " directory
\fB\-X
.TP
\fIWarning Options\fR
.br
\fB\-Werror \-Wdebug-lexer \-Wdebug-fixer \-Wdebug-compiler\fR
.TP
\fILanguage Options\fR
.br
\fB\-fbless-SIZE \-fcompound-names \-findirect-choice
.BI "\-fknown-extern-type="<name>
\fB\-fno-constraints \-fno-include-deps \-funnamed-unions \-fwide-types
.TP
\fICodecs Generation Options\fR
.br
.B \-gen-PER \-pdu=\fR{\fBall\fR|\fBauto\fR|\fIType\fR}
.TP
\fIOutput Options\fR
.br
.B \-print-constraints \-print-lines
.SH OVERALL OPTIONS
.TP
.B \-E
Stop after the parsing stage and print the reconstructed ASN.1
specification code 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 \-P
Dump the compiled output to the standard output instead of creating the
target language files on disk.
.TP
.B \-R
Restrict the compiler to generate only the ASN.1 tables,
omitting the usual support code.
.TP
\fB\-S\fR \fIdirectory\fR
Use the specified directory with ASN.1 skeleton files.
.TP
.B \-X
Generate an XML DTD schema for the specified ASN.1 files.
.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 LANGUAGE OPTIONS
.TP
.B \-fbless-SIZE
Allow SIZE() constraint for INTEGER, ENUMERATED, and other types for which this
constraint is normally prohibited by the standard. This is a violation of
ASN.1 standard, and the compiler may fail to produce a meaningful code.
.TP
.B \-fcompound-names
Using this option prevents name collisions in the target source code
by using complex names for target language structures. (Name collisions
may occur if the ASN.1 module reuses the same identifiers in multiple
contexts).
.TP
.B \-findirect-choice
When generating code for a CHOICE type, compile the CHOICE members as indirect
pointers instead of declaring them inline. Consider using this option
together with
.B \-fno-include-deps
to prevent circular references.
.TP
.BI "\-fknown-extern-type="<name>
Pretend the specified type is known. The compiler will assume the target
language source files for the given type have been provided manually.
.TP
.B \-fno-constraints
Do not generate ASN.1 subtype constraint checking code. This may make a shorter executable.
.TP
.B \-fno-include-deps
Do not generate courtesy #include lines for non-critical type dependencies.
Helps prevent namespace collisions.
.TP
.B \-funnamed-unions
Enable unnamed unions in the definitions of target language's structures.
.TP
.B \-fwide-types
Use the unbounded size data types (INTEGER_t, ENUMERATED_t, REAL_t) by default,
instead of the native machine's data types (long, double).
.SH CODECS GENERATION OPTIONS
.TP
.B \-gen-PER
Generate Packed Encoding Rules (PER) support code.
.TP
.B \-pdu=\fR{\fBall\fR|\fBauto\fR|\fIType\fR}
Create a PDU table for specified types, or discover Protocol Data Units
automatically. In case of -pdu=\fBall\fR, all ASN.1 types defined in
all modules will form a PDU table. In case of -pdu=\fBauto\fR, all types
not referenced by any other type will form a PDU table.
If \fIType\fR is an ASN.1 type identifier, it is added to a PDU table.
The last form may be specified multiple times to add any number of PDUs.
.SH OUTPUT OPTIONS
.TP
.B \-print-constraints
When -EF are also specified, this option forces the compiler to explain
its internal understanding of subtype constraints.
.TP
.B \-print-lines
Generate "-- #line" comments in \fB-E\fR output.
.SH SEE ALSO
.TP
\&\fIunber\fR\|(1), \&\fIenber\fR\|(1)
.SH AUTHORS
Lev Walkin <vlm@lionet.info>
This diff is collapsed.
#!/bin/sh
tmpfile=".check-parsing.$$.tmp"
# Test diff(1) capabilities
diff -a . . 2>/dev/null && diffArgs="-a" # Assume text files
diff -u . . 2>/dev/null && diffArgs="$diffArgs -u" # Unified diff output
ec=0
for ref in ../tests/*.asn1.-*; do
src=`echo "$ref" | sed -e 's/\.-[-a-zA-Z0-9=]*$//'`
flags=`echo "$ref" | sed -e 's/.*\.-//'`
echo "Checking $src against $ref"
./asn1c -S../skeletons "-$flags" "$src" > "$tmpfile" || ec=$?
if [ $? = 0 ]; then
diff $diffArgs "$ref" "$tmpfile" || ec=$?
fi
if [ "$1" != "regenerate" ]; then
rm -f "$tmpfile"
else
mv "$tmpfile" "$ref"
fi
done
exit $ec
#!/bin/sh
ORIG="./.check-xxber.orig.$$.tmp"
TEST="./.check-xxber.test.$$.tmp"
# Test diff(1) capabilities
diff -a . . 2>/dev/null && diffArgs="-a" # Assume text files
diff -u . . 2>/dev/null && diffArgs="$diffArgs -u" # Unified diff output
cat<<EOM > $ORIG
<I O="0" T="[UNIVERSAL 16]" TL="2" V="Indefinite" A="SEQUENCE">
<P O="2" T="[UNIVERSAL 19]" TL="2" V="2" A="PrintableString">&#x55;&#x53;</P>
<C O="6" T="[UNIVERSAL 16]" TL="2" V="22" A="SEQUENCE">
<P O="8" T="[UNIVERSAL 2]" TL="2" V="4" A="INTEGER">&#x31;&#xa6;&#x20;&#x47;</P>
<C O="14" T="[UNIVERSAL 16]" TL="2" V="6" A="SEQUENCE">
<P O="16" T="[UNIVERSAL 2]" TL="2" V="4" A="INTEGER">&#x31;&#xa6;&#x20;&#x47;</P>
</C O="22" T="[UNIVERSAL 16]" A="SEQUENCE" L="8">
<C O="22" T="[UNIVERSAL 16]" TL="2" V="6" A="SEQUENCE">
<P O="24" T="[UNIVERSAL 2]" TL="2" V="4" A="INTEGER">&#x31;&#xa6;&#x20;&#x47;</P>
</C O="30" T="[UNIVERSAL 16]" A="SEQUENCE" L="8">
</C O="30" T="[UNIVERSAL 16]" A="SEQUENCE" L="24">
<I O="30" T="[UNIVERSAL 16]" TL="2" V="Indefinite" A="SEQUENCE">
</I O="32" T="[UNIVERSAL 0]" TL="2" L="4">
EOM
./enber $ORIG | ./unber -p -i 0 - > $TEST 2>&1
diff $diffArgs $ORIG $TEST >/dev/null 2>&1
diffExitCode=$?
if [ "$diffExitCode" = "0" ]; then
echo "FAILED: $0: expected failure, got success"
exit 42;
fi
# Append necessary terminator
echo '</I O="34" T="[UNIVERSAL 0]" TL="2" L="36">' >> $ORIG
# Try trancoding again
./enber $ORIG | ./unber -p -i 0 - > $TEST 2>&1
diff $diffArgs $ORIG $TEST
diffExitCode=$?
rm -f $ORIG $TEST
exit $diffExitCode
.de Vb
.sp
.ft CW
.nf
..
.de Ve
.ft R
.fi
.sp
..
.TH ENBER 1 "\*(Dt" "unber counterpart" "unber counterpart"
.SH NAME
enber \- Convert the unber XML output back into BER
.SH SYNOPSIS
enber [\fB-n\fR] [\fB-\fR] [\fIinfile\fR...]
.SH DESCRIPTION
enber convers the XML-formatted files produced by \fIunber\fR\|(1) back into the BER format.
A single dash denotes the standard input.
.SH OPTIONS
.TP
\fB\-n\fR
Disable input validation. By default, enber performs some basic validity checks
against XML input.
.SH EXAMPLES
Decode a BER sequence and immediately encode it back
.Vb
\& unber \fB-p\fR \fIfilename.ber\fR | enber \fB-\fR > \fIreconstructed.ber\fR
.Ve
.SH FOOTNOTES
This program does not attempt to perform full-fledged XML parsing. It is merely
compatible with \fIunber\fR\|(1)'s output.
In particular, XML style comments are not supported.
A hash "\fB#\fR" or two dashes "\fB--\fR" following a whitespace is treated as a beginning of a comment line, which is ignored completely.
Empty lines are ignored as well.
.P
The following example demostrates the use of comments:
.Vb
\& <C O="0" T="[1]" TL="2" V="2">
\& <I O="2" T="[1]" TL="2" V="Indefinite">
\& \fB--\fR </I O="4" T="[UNIVERSAL 0]" L="4">
\& \fB#\fR Do not terminate:
\& \fB#\fR the absence of end-of-content octets is intentional!
\& </C O="6" T="[1]" L="6">
.Ve
.SH SEE ALSO
.TP
\&\fIunber\fR\|(1), \&\fIasn1c\fR\|(1)
.SH AUTHORS
Lev Walkin <vlm@lionet.info>
This diff is collapsed.
/*-
* Copyright (c) 2005 Lev Walkin <vlm@lionet.info>. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id$
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h> /* for stat(2) */
#endif
#ifndef _WIN32
#include <sysexits.h> /* for EX_USAGE & others */
#else /* _WIN32 */
#ifndef EX_USAGE
#define EX_USAGE 64
#endif
#ifndef EX_DATAERR
#define EX_DATAERR 65
#endif
#ifndef EX_SOFTWARE
#define EX_SOFTWARE 70
#endif
#ifndef EX_OSERR
#define EX_OSERR 71
#endif
#ifndef EX_OSFILE
#define EX_OSFILE 72
#endif
#define alloca _alloca
#define snprintf _snprintf
#endif /* _WIN32 */
AM_CFLAGS = @ADD_CFLAGS@
dist_check_SCRIPTS = check-assembly.sh
TESTS_ENVIRONMENT= CC="${CC}" CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}" ./check-assembly.sh
TESTS = check-*.c
EXTRA_DIST = \
check-*.c* \
data-62 \
data-70 \
data-119 \
data-126
clean-local:
rm -rf test-*
This diff is collapsed.
The name of the check-N.c file is used as a pointer to the file
../../tests/N-*.asn1. That ASN.1 file is compiled together with check-N.c
in a temporary directory. The check-N.c file contains the test engine.
For manual execution of a specific test case:
./check-assembly.sh check-<NN>.c
#undef NDEBUG
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
#include <assert.h>
#include "Enum2.h"
#include "xer_decoder.h"
static char buf[4096];
static int buf_offset;
static int
buf_writer(const void *buffer, size_t size, void *app_key) {
char *b, *bend;
(void)app_key;
assert(buf_offset + size < sizeof(buf));
memcpy(buf + buf_offset, buffer, size);
b = buf + buf_offset;
bend = b + size;
buf_offset += size;
return 0;
}
static void
check_xer(e_Enum2 eval, char *xer_string) {
asn_dec_rval_t rv;
char buf2[128];
Enum2_t *e = 0;
long val;
rv = xer_decode(0, &asn_DEF_Enum2, (void **)&e,
xer_string, strlen(xer_string));
assert(rv.code == RC_OK);
assert(rv.consumed == strlen(xer_string));
asn_INTEGER2long(e, &val);
printf("%s -> %ld == %d\n", xer_string, val, eval);
assert(val == eval);
buf_offset = 0;
xer_encode(&asn_DEF_Enum2, e, XER_F_CANONICAL, buf_writer, 0);
buf[buf_offset] = 0;
sprintf(buf2, "<Enum2>%s</Enum2>", xer_string);
printf("%d -> %s == %s\n", eval, buf, buf2);
assert(0 == strcmp(buf, buf2));
}
int
main() {
check_xer(Enum2_red, "<red/>");
check_xer(Enum2_green, "<green/>");
check_xer(Enum2_blue, "<blue/>");
check_xer(Enum2_orange, "<orange/>");
check_xer(Enum2_alpha, "<alpha/>");
check_xer(Enum2_beta, "<beta/>");
check_xer(Enum2_gamma, "<gamma/>");
return 0;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Mode of operation:
Each of the *.in files is XER-decoded, then converted into PER,
then decoded back from PER, then encoded into XER again,
and finally compared to the original encoding.
Naming conventions:
*-B.in - The file is intentionally broken
*-P.in - Is not PER compatible, PER encoding must fail.
*-E.in - CXER reconstruction should yield byte-wise identical data.
Otherwise, a reconstructed buffer should loosely match the original.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment