summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/asn1/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'source4/heimdal/lib/asn1/main.c')
-rw-r--r--source4/heimdal/lib/asn1/main.c41
1 files changed, 35 insertions, 6 deletions
diff --git a/source4/heimdal/lib/asn1/main.c b/source4/heimdal/lib/asn1/main.c
index afa164ea81..088e8ebfa2 100644
--- a/source4/heimdal/lib/asn1/main.c
+++ b/source4/heimdal/lib/asn1/main.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1998, 1999 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997-2005 Kungliga Tekniska Högskolan
* (Royal Institute of Technology, Stockholm, Sweden).
* All rights reserved.
*
@@ -33,14 +33,32 @@
#include "gen_locl.h"
#include <getarg.h>
+#include "lex.h"
-RCSID("$Id: main.c,v 1.13 2005/06/16 20:05:31 lha Exp $");
+RCSID("$Id: main.c,v 1.14 2005/07/12 06:27:34 lha Exp $");
extern FILE *yyin;
+static getarg_strings preserve;
+
+int
+preserve_type(const char *p)
+{
+ int i;
+ for (i = 0; i < preserve.num_strings; i++)
+ if (strcmp(preserve.strings[i], p) == 0)
+ return 1;
+ return 0;
+}
+
+int dce_fix;
+int rfc1510_bitstring;
int version_flag;
int help_flag;
struct getargs args[] = {
+ { "encode-rfc1510-bit-string", 0, arg_flag, &rfc1510_bitstring },
+ { "decode-dce-ber", 0, arg_flag, &dce_fix },
+ { "preserve-binary", 0, arg_strings, &preserve },
{ "version", 0, arg_flag, &version_flag },
{ "help", 0, arg_flag, &help_flag }
};
@@ -53,12 +71,14 @@ usage(int code)
exit(code);
}
+int error_flag;
+
int
main(int argc, char **argv)
{
int ret;
- const char *file;
- const char *name = NULL;
+ char *file;
+ char *name = NULL;
int optidx = 0;
setprogname(argv[0]);
@@ -79,12 +99,21 @@ main(int argc, char **argv)
yyin = fopen (file, "r");
if (yyin == NULL)
err (1, "open %s", file);
- name = argv[optidx + 1];
+ if (argc == optidx + 1) {
+ char *p;
+ name = estrdup(file);
+ p = strrchr(name, '.');
+ if (p)
+ *p = '\0';
+ } else
+ name = argv[optidx + 1];
}
init_generate (file, name);
initsym ();
ret = yyparse ();
+ if(ret != 0 || error_flag != 0)
+ exit(1);
close_generate ();
- return ret;
+ return 0;
}