Commit 7415bffa authored by Lev Walkin's avatar Lev Walkin

-t option and minor changes

parent b4eb8b5f
...@@ -7,6 +7,7 @@ AM_CPPFLAGS = \ ...@@ -7,6 +7,7 @@ AM_CPPFLAGS = \
-I${top_srcdir}/libasn1parser \ -I${top_srcdir}/libasn1parser \
-I${top_srcdir}/libasn1print \ -I${top_srcdir}/libasn1print \
-I${top_srcdir}/libasn1fix \ -I${top_srcdir}/libasn1fix \
-I${top_srcdir}/skeletons \
-DDATADIR=\"${pkgdatadir}\" -DDATADIR=\"${pkgdatadir}\"
LDADD = \ LDADD = \
...@@ -15,6 +16,8 @@ LDADD = \ ...@@ -15,6 +16,8 @@ LDADD = \
${top_builddir}/libasn1print/libasn1print.la \ ${top_builddir}/libasn1print/libasn1print.la \
${top_builddir}/libasn1compiler/libasn1compiler.la ${top_builddir}/libasn1compiler/libasn1compiler.la
asn1c_SOURCES = asn1c.c decoder.c decoder.h
bin_PROGRAMS = asn1c bin_PROGRAMS = asn1c
dist_man1_MANS = asn1c.1 dist_man1_MANS = asn1c.1
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
@SET_MAKE@ @SET_MAKE@
SOURCES = asn1c.c SOURCES = $(asn1c_SOURCES)
srcdir = @srcdir@ srcdir = @srcdir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
...@@ -53,8 +53,8 @@ CONFIG_CLEAN_FILES = ...@@ -53,8 +53,8 @@ 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)
asn1c_SOURCES = asn1c.c am_asn1c_OBJECTS = asn1c.$(OBJEXT) decoder.$(OBJEXT)
asn1c_OBJECTS = asn1c.$(OBJEXT) asn1c_OBJECTS = $(am_asn1c_OBJECTS)
asn1c_LDADD = $(LDADD) asn1c_LDADD = $(LDADD)
asn1c_DEPENDENCIES = ${top_builddir}/libasn1parser/libasn1parser.la \ asn1c_DEPENDENCIES = ${top_builddir}/libasn1parser/libasn1parser.la \
${top_builddir}/libasn1fix/libasn1fix.la \ ${top_builddir}/libasn1fix/libasn1fix.la \
...@@ -63,7 +63,7 @@ asn1c_DEPENDENCIES = ${top_builddir}/libasn1parser/libasn1parser.la \ ...@@ -63,7 +63,7 @@ asn1c_DEPENDENCIES = ${top_builddir}/libasn1parser/libasn1parser.la \
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)/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) \
...@@ -72,8 +72,8 @@ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) \ ...@@ -72,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.c SOURCES = $(asn1c_SOURCES)
DIST_SOURCES = asn1c.c DIST_SOURCES = $(asn1c_SOURCES)
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 \
...@@ -204,6 +204,7 @@ AM_CPPFLAGS = \ ...@@ -204,6 +204,7 @@ AM_CPPFLAGS = \
-I${top_srcdir}/libasn1parser \ -I${top_srcdir}/libasn1parser \
-I${top_srcdir}/libasn1print \ -I${top_srcdir}/libasn1print \
-I${top_srcdir}/libasn1fix \ -I${top_srcdir}/libasn1fix \
-I${top_srcdir}/skeletons \
-DDATADIR=\"${pkgdatadir}\" -DDATADIR=\"${pkgdatadir}\"
LDADD = \ LDADD = \
...@@ -212,6 +213,7 @@ LDADD = \ ...@@ -212,6 +213,7 @@ LDADD = \
${top_builddir}/libasn1print/libasn1print.la \ ${top_builddir}/libasn1print/libasn1print.la \
${top_builddir}/libasn1compiler/libasn1compiler.la ${top_builddir}/libasn1compiler/libasn1compiler.la
asn1c_SOURCES = asn1c.c decoder.c decoder.h
dist_man1_MANS = asn1c.1 dist_man1_MANS = asn1c.1
check_SCRIPTS = check-parsing.sh check_SCRIPTS = check-parsing.sh
TESTS = check-parsing.sh TESTS = check-parsing.sh
...@@ -289,6 +291,7 @@ distclean-compile: ...@@ -289,6 +291,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)/decoder.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 $@ $<; \
......
...@@ -19,14 +19,16 @@ ...@@ -19,14 +19,16 @@
#include <asn1c_compat.h> /* Portable basename(3) and dirname(3) */ #include <asn1c_compat.h> /* Portable basename(3) and dirname(3) */
#include "decoder.h" /* -t: decode TL[V?] string */
static void usage(char *av0); /* Print the Usage screen and exit(EX_USAGE) */ static void usage(char *av0); /* Print the Usage screen and exit(EX_USAGE) */
int int
main(int ac, char **av) { main(int ac, char **av) {
enum asn1p_flags asn1_parser_flags = A1P_NOFLAGS; enum asn1p_flags asn1_parser_flags = A1P_NOFLAGS;
enum asn1f_flags asn1_fixer_flags = A1F_NOFLAGS; enum asn1f_flags asn1_fixer_flags = A1F_NOFLAGS;
enum asn1c_flags asn1_compiler_flags = A1C_NOFLAGS; enum asn1c_flags asn1_compiler_flags= A1C_NOFLAGS;
enum asn1print_flags_e print_arg__flags = APF_NOFLAGS; enum asn1print_flags asn1_print_flags = APF_NOFLAGS;
int print_arg__print_out = 0; /* Don't compile, just print parsed */ int print_arg__print_out = 0; /* Don't compile, just print parsed */
int print_arg__fix_n_print = 0; /* Fix and print */ int print_arg__fix_n_print = 0; /* Fix and print */
int warnings_as_errors = 0; /* Treat warnings as errors */ int warnings_as_errors = 0; /* Treat warnings as errors */
...@@ -39,7 +41,7 @@ main(int ac, char **av) { ...@@ -39,7 +41,7 @@ main(int ac, char **av) {
/* /*
* Process command-line options. * Process command-line options.
*/ */
while((ch = getopt(ac, av, "EFf:LPRS:W:")) != -1) while((ch = getopt(ac, av, "EFf:LPRS:t:W:")) != -1)
switch(ch) { switch(ch) {
case 'E': case 'E':
print_arg__print_out = 1; print_arg__print_out = 1;
...@@ -62,13 +64,16 @@ main(int ac, char **av) { ...@@ -62,13 +64,16 @@ main(int ac, char **av) {
char *known_type = optarg + 18; char *known_type = optarg + 18;
ret = asn1f_make_known_external_type(known_type); ret = asn1f_make_known_external_type(known_type);
assert(ret == 0 || errno == EEXIST); assert(ret == 0 || errno == EEXIST);
} else if(strcmp(optarg, "undoc") == 0) {
/* Enable undocumented operation */
asn1_print_flags |= APF_FULL_CONSTRAINTS;
} else { } else {
fprintf(stderr, "-f%s: Invalid argument\n", optarg); fprintf(stderr, "-f%s: Invalid argument\n", optarg);
exit(EX_USAGE); exit(EX_USAGE);
} }
break; break;
case 'L': case 'L':
print_arg__flags |= APF_LINE_COMMENTS; asn1_print_flags |= APF_LINE_COMMENTS;
break; break;
case 'P': case 'P':
asn1_compiler_flags |= A1C_PRINT_COMPILED; asn1_compiler_flags |= A1C_PRINT_COMPILED;
...@@ -79,6 +84,10 @@ main(int ac, char **av) { ...@@ -79,6 +84,10 @@ 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 'W': case 'W':
if(strcmp(optarg, "error") == 0) { if(strcmp(optarg, "error") == 0) {
warnings_as_errors = 1; warnings_as_errors = 1;
...@@ -151,10 +160,10 @@ main(int ac, char **av) { ...@@ -151,10 +160,10 @@ main(int ac, char **av) {
} }
/* /*
* Dump the parsed ASN.1 tree if -E specified and -F is not given. * 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(print_arg__print_out && !print_arg__fix_n_print) {
if(asn1print(asn, print_arg__flags)) if(asn1print(asn, asn1_print_flags))
exit(EX_SOFTWARE); exit(EX_SOFTWARE);
return 0; return 0;
} }
...@@ -181,7 +190,7 @@ main(int ac, char **av) { ...@@ -181,7 +190,7 @@ main(int ac, char **av) {
* Dump the parsed ASN.1 tree if -E specified and -F is given. * Dump the parsed ASN.1 tree if -E specified and -F is given.
*/ */
if(print_arg__print_out && print_arg__fix_n_print) { if(print_arg__print_out && print_arg__fix_n_print) {
if(asn1print(asn, print_arg__flags)) if(asn1print(asn, asn1_print_flags))
exit(EX_SOFTWARE); exit(EX_SOFTWARE);
return 0; return 0;
} }
...@@ -248,6 +257,8 @@ usage(char *av0) { ...@@ -248,6 +257,8 @@ usage(char *av0) {
"\t \t(Default is \"%s\")\n" "\t \t(Default is \"%s\")\n"
"\t-R \tRestrict output (tables only, no support code)\n" "\t-R \tRestrict output (tables only, no support code)\n"
"\n" "\n"
"\t-t <data>\tDecode the given tag[/length] sequence\n"
"\n"
"\t-ftypes88\tUse only ASN.1:1988 embedded types\n" "\t-ftypes88\tUse only ASN.1:1988 embedded types\n"
/* /*
"\t-fconstr90\tUse only ASN.1:1990 constructs (not available)\n" "\t-fconstr90\tUse only ASN.1:1990 constructs (not available)\n"
......
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