diff options
author | Bjorn Sandell <biorn@cvs.openbsd.org> | 2005-10-16 18:56:36 +0000 |
---|---|---|
committer | Bjorn Sandell <biorn@cvs.openbsd.org> | 2005-10-16 18:56:36 +0000 |
commit | 9b65ff1ed6cf7a1e29a392de0ba9fe5d722eccef (patch) | |
tree | f82203bfbf633ffa333b45fecec06ff9cff005cf /usr.bin/asn1_compile/gen.c | |
parent | 14d3e879f4c504b87ea309e2ae1e198d1572aaa0 (diff) |
sync with heimdal 0.7
Diffstat (limited to 'usr.bin/asn1_compile/gen.c')
-rw-r--r-- | usr.bin/asn1_compile/gen.c | 82 |
1 files changed, 59 insertions, 23 deletions
diff --git a/usr.bin/asn1_compile/gen.c b/usr.bin/asn1_compile/gen.c index 929686bc838..6f43a9a1665 100644 --- a/usr.bin/asn1_compile/gen.c +++ b/usr.bin/asn1_compile/gen.c @@ -34,7 +34,7 @@ #include "gen_locl.h" /* -RCSID("$KTH: gen.c,v 1.50 2003/04/17 07:09:18 lha Exp $"); +RCSID("$KTH: gen.c,v 1.58 2005/03/31 00:08:58 lha Exp $"); */ FILE *headerfile, *codefile, *logfile; @@ -43,7 +43,7 @@ FILE *headerfile, *codefile, *logfile; static const char *orig_filename; static char *header; -static char *headerbase = STEM; +static char *headerbase; /* * list of all IMPORTs @@ -78,14 +78,16 @@ void init_generate (const char *filename, const char *base) { orig_filename = filename; - if(base) + if(base){ if((headerbase = strdup(base)) == NULL) - err(1, NULL); - + err(1, NULL); + }else{ + if((headerbase = strdup(STEM)) == NULL) + err(1, NULL); + } asprintf(&header, "%s.h", headerbase); if(header == NULL) - err(1, NULL); - + err(1, NULL); headerfile = fopen (header, "w"); if (headerfile == NULL) err (1, "open %s", header); @@ -106,18 +108,21 @@ init_generate (const char *filename, const char *base) "#ifndef __asn1_common_definitions__\n" "#define __asn1_common_definitions__\n\n"); fprintf (headerfile, - "typedef struct octet_string {\n" + "typedef struct heim_octet_string {\n" " size_t length;\n" " void *data;\n" - "} octet_string;\n\n"); + "} heim_octet_string;\n\n"); + fprintf (headerfile, + "typedef char *heim_general_string;\n\n" + ); fprintf (headerfile, - "typedef char *general_string;\n\n" + "typedef char *heim_utf8_string;\n\n" ); fprintf (headerfile, - "typedef struct oid {\n" + "typedef struct heim_oid {\n" " size_t length;\n" " unsigned *components;\n" - "} oid;\n\n"); + "} heim_oid;\n\n"); fputs("#define ASN1_MALLOC_ENCODE(T, B, BL, S, L, R) \\\n" " do { \\\n" " (BL) = length_##T((S)); \\\n" @@ -276,13 +281,25 @@ define_asn1 (int level, Type *t) fprintf (headerfile, "[APPLICATION %d] ", t->application); define_asn1 (level, t->subtype); break; + case TBoolean: + space(level); + fprintf (headerfile, "BOOLEAN"); + break; + case TUTF8String: + space(level); + fprintf (headerfile, "UTF8String"); + break; + case TNull: + space(level); + fprintf (headerfile, "NULL"); + break; default: abort (); } } static void -define_type (int level, char *name, Type *t, int typedefp) +define_type (int level, const char *name, Type *t, int typedefp) { switch (t->type) { case TType: @@ -313,11 +330,11 @@ define_type (int level, char *name, Type *t, int typedefp) break; case TOctetString: space(level); - fprintf (headerfile, "octet_string %s;\n", name); + fprintf (headerfile, "heim_octet_string %s;\n", name); break; case TOID : space(level); - fprintf (headerfile, "oid %s;\n", name); + fprintf (headerfile, "heim_oid %s;\n", name); break; case TBitString: { Member *m; @@ -399,7 +416,19 @@ define_type (int level, char *name, Type *t, int typedefp) break; case TGeneralString: space(level); - fprintf (headerfile, "general_string %s;\n", name); + fprintf (headerfile, "heim_general_string %s;\n", name); + break; + case TUTF8String: + space(level); + fprintf (headerfile, "heim_utf8_string %s;\n", name); + break; + case TBoolean: + space(level); + fprintf (headerfile, "int %s;\n", name); + break; + case TNull: + space(level); + fprintf (headerfile, "NULL %s;\n", name); break; case TApplication: define_type (level, name, t->subtype, FALSE); @@ -458,13 +487,20 @@ generate_type (const Symbol *s) "#include <asn1_err.h>\n" "#include <der.h>\n" "#include <parse_units.h>\n\n"); - generate_type_header (s); - generate_type_encode (s); - generate_type_decode (s); - generate_type_free (s); - generate_type_length (s); - generate_type_copy (s); - generate_glue (s); + + if (s->stype == Stype && s->type->type == TChoice) { + fprintf(codefile, + "/* CHOICE */\n" + "int asn1_%s_dummy_holder = 1;\n", s->gen_name); + } else { + generate_type_header (s); + generate_type_encode (s); + generate_type_decode (s); + generate_type_free (s); + generate_type_length (s); + generate_type_copy (s); + generate_glue (s); + } fprintf(headerfile, "\n\n"); fclose(codefile); } |