Commit 06b8d7aa authored by Lev Walkin's avatar Lev Walkin

implemented unber - the ASN.1 BER Decoder

parent 60a1403a
...@@ -10,18 +10,15 @@ AM_CPPFLAGS = \ ...@@ -10,18 +10,15 @@ AM_CPPFLAGS = \
-I${top_srcdir}/skeletons \ -I${top_srcdir}/skeletons \
-DDATADIR=\"$(pkgdatadir)\" -DDATADIR=\"$(pkgdatadir)\"
LDADD = \ asn1c_LDADD = \
$(top_builddir)/libasn1parser/libasn1parser.la \ $(top_builddir)/libasn1parser/libasn1parser.la \
$(top_builddir)/libasn1print/libasn1print.la \ $(top_builddir)/libasn1print/libasn1print.la \
$(top_builddir)/libasn1fix/libasn1fix.la \ $(top_builddir)/libasn1fix/libasn1fix.la \
$(top_builddir)/libasn1compiler/libasn1compiler.la $(top_builddir)/libasn1compiler/libasn1compiler.la
asn1c_SOURCES = asn1c.c \ bin_PROGRAMS = asn1c unber
tlv_decoder.c tlv_decoder.h
bin_PROGRAMS = asn1c dist_man1_MANS = asn1c.1 unber.1
dist_man1_MANS = asn1c.1
check_SCRIPTS = check-parsing.sh check_SCRIPTS = check-parsing.sh
TESTS = check-parsing.sh TESTS = check-parsing.sh
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
@SET_MAKE@ @SET_MAKE@
SOURCES = $(asn1c_SOURCES) SOURCES = asn1c.c unber.c
srcdir = @srcdir@ srcdir = @srcdir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
...@@ -37,7 +37,7 @@ NORMAL_UNINSTALL = : ...@@ -37,7 +37,7 @@ NORMAL_UNINSTALL = :
PRE_UNINSTALL = : PRE_UNINSTALL = :
POST_UNINSTALL = : POST_UNINSTALL = :
host_triplet = @host@ host_triplet = @host@
bin_PROGRAMS = asn1c$(EXEEXT) bin_PROGRAMS = asn1c$(EXEEXT) unber$(EXEEXT)
subdir = asn1c subdir = asn1c
DIST_COMMON = README $(dist_man1_MANS) $(srcdir)/Makefile.am \ DIST_COMMON = README $(dist_man1_MANS) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/Makefile.in
...@@ -51,18 +51,19 @@ CONFIG_CLEAN_FILES = ...@@ -51,18 +51,19 @@ CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS) PROGRAMS = $(bin_PROGRAMS)
am_asn1c_OBJECTS = asn1c.$(OBJEXT) tlv_decoder.$(OBJEXT) asn1c_SOURCES = asn1c.c
asn1c_OBJECTS = $(am_asn1c_OBJECTS) asn1c_OBJECTS = asn1c.$(OBJEXT)
asn1c_LDADD = $(LDADD)
asn1c_DEPENDENCIES = $(top_builddir)/libasn1parser/libasn1parser.la \ asn1c_DEPENDENCIES = $(top_builddir)/libasn1parser/libasn1parser.la \
$(top_builddir)/libasn1print/libasn1print.la \ $(top_builddir)/libasn1print/libasn1print.la \
$(top_builddir)/libasn1fix/libasn1fix.la \ $(top_builddir)/libasn1fix/libasn1fix.la \
$(top_builddir)/libasn1compiler/libasn1compiler.la $(top_builddir)/libasn1compiler/libasn1compiler.la
unber_SOURCES = unber.c
unber_OBJECTS = unber.$(OBJEXT)
unber_LDADD = $(LDADD)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/asn1c.Po \ @AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/asn1c.Po ./$(DEPDIR)/unber.Po
@AMDEP_TRUE@ ./$(DEPDIR)/tlv_decoder.Po
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
...@@ -71,8 +72,8 @@ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \ ...@@ -71,8 +72,8 @@ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \
CCLD = $(CC) CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@ $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(asn1c_SOURCES) SOURCES = asn1c.c unber.c
DIST_SOURCES = $(asn1c_SOURCES) DIST_SOURCES = asn1c.c unber.c
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \ html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \ install-exec-recursive install-info-recursive \
...@@ -205,16 +206,13 @@ AM_CPPFLAGS = \ ...@@ -205,16 +206,13 @@ AM_CPPFLAGS = \
-I${top_srcdir}/skeletons \ -I${top_srcdir}/skeletons \
-DDATADIR=\"$(pkgdatadir)\" -DDATADIR=\"$(pkgdatadir)\"
LDADD = \ asn1c_LDADD = \
$(top_builddir)/libasn1parser/libasn1parser.la \ $(top_builddir)/libasn1parser/libasn1parser.la \
$(top_builddir)/libasn1print/libasn1print.la \ $(top_builddir)/libasn1print/libasn1print.la \
$(top_builddir)/libasn1fix/libasn1fix.la \ $(top_builddir)/libasn1fix/libasn1fix.la \
$(top_builddir)/libasn1compiler/libasn1compiler.la $(top_builddir)/libasn1compiler/libasn1compiler.la
asn1c_SOURCES = asn1c.c \ dist_man1_MANS = asn1c.1 unber.1
tlv_decoder.c tlv_decoder.h
dist_man1_MANS = asn1c.1
check_SCRIPTS = check-parsing.sh check_SCRIPTS = check-parsing.sh
TESTS = check-parsing.sh TESTS = check-parsing.sh
EXTRA_DIST = check-parsing.sh EXTRA_DIST = check-parsing.sh
...@@ -283,6 +281,9 @@ clean-binPROGRAMS: ...@@ -283,6 +281,9 @@ clean-binPROGRAMS:
asn1c$(EXEEXT): $(asn1c_OBJECTS) $(asn1c_DEPENDENCIES) asn1c$(EXEEXT): $(asn1c_OBJECTS) $(asn1c_DEPENDENCIES)
@rm -f asn1c$(EXEEXT) @rm -f asn1c$(EXEEXT)
$(LINK) $(asn1c_LDFLAGS) $(asn1c_OBJECTS) $(asn1c_LDADD) $(LIBS) $(LINK) $(asn1c_LDFLAGS) $(asn1c_OBJECTS) $(asn1c_LDADD) $(LIBS)
unber$(EXEEXT): $(unber_OBJECTS) $(unber_DEPENDENCIES)
@rm -f unber$(EXEEXT)
$(LINK) $(unber_LDFLAGS) $(unber_OBJECTS) $(unber_LDADD) $(LIBS)
mostlyclean-compile: mostlyclean-compile:
-rm -f *.$(OBJEXT) -rm -f *.$(OBJEXT)
...@@ -291,7 +292,7 @@ distclean-compile: ...@@ -291,7 +292,7 @@ distclean-compile:
-rm -f *.tab.c -rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asn1c.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/asn1c.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tlv_decoder.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unber.Po@am__quote@
.c.o: .c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
......
The ASN.1 Compiler asn1c - The ASN.1 Compiler
unber - The ASN.1 BER Decoder
...@@ -4,9 +4,8 @@ ...@@ -4,9 +4,8 @@
.TH ASN1C 1 "\*(Dt" "ASN.1 Compiler" "ASN.1 Compiler" .TH ASN1C 1 "\*(Dt" "ASN.1 Compiler" "ASN.1 Compiler"
.SH NAME .SH NAME
asn1c \- ASN.1 Compiler asn1c \- ASN.1 Compiler
.ND ASN.1 compiler
.SH SYNOPSIS .SH SYNOPSIS
asn1c [\fB\-E\fR [\fB-F\fR] | \fB\-P\fR | \fB\-R\fR | \fB\-t\fR\fIdata-string\fR] asn1c [\fB\-E\fR [\fB-F\fR] | \fB\-P\fR | \fB\-R\fR]
[\fB\-S\fR\fIdir\fR] [\fB\-S\fR\fIdir\fR]
[\fB\-W\fR\fIdebug-\fR...] [\fB\-f\fR\fIoption\fR...] [\fB\-p\fR\fIrint-\fR...] [\fB\-W\fR\fIdebug-\fR...] [\fB\-f\fR\fIoption\fR...] [\fB\-p\fR\fIrint-\fR...]
\fIinfile\fR... \fIinfile\fR...
...@@ -19,7 +18,6 @@ and other encoding standards. ...@@ -19,7 +18,6 @@ and other encoding standards.
\fIOverall Options\fR \fIOverall Options\fR
\fB\-E \-F \-P \-R\fR \fB\-E \-F \-P \-R\fR
.BI "\-S " directory .BI "\-S " directory
.BI "\-t " data-string
.TP .TP
\fIWarning Options\fR \fIWarning Options\fR
.br .br
...@@ -55,10 +53,6 @@ omitting the usual support code. ...@@ -55,10 +53,6 @@ omitting the usual support code.
.TP .TP
\fB\-S\fR \fIdirectory\fR \fB\-S\fR \fIdirectory\fR
Use the specified directory with ASN.1 skeleton files. Use the specified directory with ASN.1 skeleton files.
.TP
\fB\-t\fR \fIdata-string\fR
Interpret the data-string as a sequence of hexadecimal values representing
the start of BER TLV encoding. Print the human readable explanation.
.SH WARNING OPTIONS .SH WARNING OPTIONS
.TP .TP
.B \-Werror .B \-Werror
...@@ -104,5 +98,8 @@ its internal understanding of subtype constraints. ...@@ -104,5 +98,8 @@ its internal understanding of subtype constraints.
.TP .TP
.B \-print-lines .B \-print-lines
Generate "-- #line" comments in \fB-E\fR output. Generate "-- #line" comments in \fB-E\fR output.
.SH SEE ALSO
.TP
\&\fIunber\fR\|(1)
.SH AUTHORS .SH AUTHORS
Lev Walkin <vlm@lionet.info> Lev Walkin <vlm@lionet.info>
...@@ -19,9 +19,7 @@ ...@@ -19,9 +19,7 @@
#include <asn1c_compat.h> /* Portable basename(3) and dirname(3) */ #include <asn1c_compat.h> /* Portable basename(3) and dirname(3) */
#include "tlv_decoder.h" /* -t: decode TL[V?] string */ static void usage(const char *av0); /* Print the Usage screen and exit */
static void usage(char *av0); /* Print the Usage screen and exit(EX_USAGE) */
#undef COPYRIGHT #undef COPYRIGHT
#define COPYRIGHT \ #define COPYRIGHT \
...@@ -45,7 +43,7 @@ main(int ac, char **av) { ...@@ -45,7 +43,7 @@ main(int ac, char **av) {
/* /*
* Process command-line options. * Process command-line options.
*/ */
while((ch = getopt(ac, av, "EFf:hLPp:RS:t:vW:")) != -1) while((ch = getopt(ac, av, "EFf:hLPp:RS:vW:")) != -1)
switch(ch) { switch(ch) {
case 'E': case 'E':
print_arg__print_out = 1; print_arg__print_out = 1;
...@@ -97,10 +95,6 @@ main(int ac, char **av) { ...@@ -97,10 +95,6 @@ main(int ac, char **av) {
case 'S': case 'S':
skeletons_dir = optarg; skeletons_dir = optarg;
break; break;
case 't':
if(decode_tlv_from_string(optarg))
exit(EX_DATAERR);
exit(0);
case 'v': case 'v':
fprintf(stderr, "ASN.1 Compiler, v" VERSION "\n" COPYRIGHT); fprintf(stderr, "ASN.1 Compiler, v" VERSION "\n" COPYRIGHT);
exit(0); exit(0);
...@@ -264,11 +258,11 @@ main(int ac, char **av) { ...@@ -264,11 +258,11 @@ main(int ac, char **av) {
* Print the usage screen and exit(EX_USAGE). * Print the usage screen and exit(EX_USAGE).
*/ */
static void static void
usage(char *av0) { usage(const char *av0) {
fprintf(stderr, fprintf(stderr,
"ASN.1 Compiler, v" VERSION "\n" COPYRIGHT "ASN.1 Compiler, v" VERSION "\n" COPYRIGHT
"Usage: %s [options] infile...\n" "Usage: %s [options] file ...\n"
"Where [options] are:\n" "Options:\n"
" -E Run only the ASN.1 parser and print out the tree\n" " -E Run only the ASN.1 parser and print out the tree\n"
" -F During -E operation, also perform tree fixing\n" " -F During -E operation, also perform tree fixing\n"
"\n" "\n"
...@@ -278,10 +272,6 @@ usage(char *av0) { ...@@ -278,10 +272,6 @@ usage(char *av0) {
" (Default is \"%s\")\n" " (Default is \"%s\")\n"
"\n" "\n"
" -t <data-string> Decode the given tag[/length] sequence\n"
" (e.g. -t \"bf 20\")\n"
"\n"
" -Werror Treat warnings as errors; abort if any warning\n" " -Werror Treat warnings as errors; abort if any warning\n"
" -Wdebug-lexer Enable verbose debugging output from lexer\n" " -Wdebug-lexer Enable verbose debugging output from lexer\n"
" -Wdebug-fixer --//-- semantics processor\n" " -Wdebug-fixer --//-- semantics processor\n"
......
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