aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2004-06-03 03:38:44 +0000
committerLev Walkin <vlm@lionet.info>2004-06-03 03:38:44 +0000
commitf15320bf6b50a0c02636405561ac8323ae901abd (patch)
tree33461d45122896c6dde35f82f5c7d19b62004a6b /examples
parent746cb60bbccf47019563665f4aec4b6c462c4163 (diff)
Initial revision
Diffstat (limited to 'examples')
-rw-r--r--examples/Makefile.am4
-rw-r--r--examples/Makefile.in246
-rw-r--r--examples/README6
-rwxr-xr-xexamples/clyx2asn1.pl51
-rwxr-xr-xexamples/crfc2asn1.pl86
5 files changed, 393 insertions, 0 deletions
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 <ASN-Module-Name> ...\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(<STDIN>) {
+ 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 <rfc-file.txt> ...\n";
+ print STDERR "Usage: <someprog> | $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;