diff options
author | Andrew Bartlett <abartlet@samba.org> | 2009-06-08 19:06:16 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2009-06-12 07:45:48 +1000 |
commit | 9b261c008a395a323e0516f4cd3f3134aa050577 (patch) | |
tree | 91cf543ba7ccd560313bea52fa8678f0456e8485 /source4/heimdal/lib/asn1/gen.c | |
parent | 5cef57ff7d899773a084d23838b7f18a83f6e79d (diff) | |
download | samba-9b261c008a395a323e0516f4cd3f3134aa050577.tar.gz samba-9b261c008a395a323e0516f4cd3f3134aa050577.tar.bz2 samba-9b261c008a395a323e0516f4cd3f3134aa050577.zip |
s4:heimdal: import lorikeet-heimdal-200906080040 (commit 904d0124b46eed7a8ad6e5b73e892ff34b6865ba)
Also including the supporting changes required to pass make test
A number of heimdal functions and constants have changed since we last
imported a tree (for the better, but inconvenient for us).
Andrew Bartlett
Diffstat (limited to 'source4/heimdal/lib/asn1/gen.c')
-rw-r--r-- | source4/heimdal/lib/asn1/gen.c | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/source4/heimdal/lib/asn1/gen.c b/source4/heimdal/lib/asn1/gen.c index 52fd0d393b..e156c7cefb 100644 --- a/source4/heimdal/lib/asn1/gen.c +++ b/source4/heimdal/lib/asn1/gen.c @@ -83,12 +83,19 @@ init_generate (const char *filename, const char *base) if (headerbase == NULL) errx(1, "strdup"); } + + /* public header file */ asprintf(&header, "%s.h", headerbase); if (header == NULL) errx(1, "malloc"); - headerfile = fopen (header, "w"); + asprintf(&fn, "%s.hx", headerbase); + if (fn == NULL) + errx(1, "malloc"); + headerfile = fopen (fn, "w"); if (headerfile == NULL) - err (1, "open %s", header); + err (1, "open %s", fn); + free(fn); + fprintf (headerfile, "/* Generated from %s */\n" "/* Do not edit */\n\n", @@ -229,7 +236,7 @@ gen_compare_defval(const char *var, struct value *val) } } -static void +void generate_header_of_codefile(const char *name) { char *filename; @@ -267,7 +274,7 @@ generate_header_of_codefile(const char *name) } -static void +void close_codefile(void) { if (codefile == NULL) @@ -296,7 +303,8 @@ generate_constant (const Symbol *s) struct objid *o, **list; unsigned int i, len; - generate_header_of_codefile(s->gen_name); + if (!one_code_file) + generate_header_of_codefile(s->gen_name); len = 0; for (o = s->value->u.objectidentifiervalue; o != NULL; o = o->next) @@ -320,9 +328,13 @@ generate_constant (const Symbol *s) } fprintf (headerfile, "} */\n"); - fprintf (headerfile, "const heim_oid *oid_%s(void);\n\n", + fprintf (headerfile, "const heim_oid *oid_%s(void);\n", + s->gen_name); + fprintf (headerfile, + "extern const heim_oid asn1_oid_%s;\n\n", s->gen_name); + fprintf (codefile, "static unsigned oid_%s_variable_num[%d] = {", s->gen_name, len); for (i = len ; i > 0; i--) { @@ -330,17 +342,20 @@ generate_constant (const Symbol *s) } fprintf(codefile, "};\n"); - fprintf (codefile, "static const heim_oid oid_%s_variable = " + fprintf (codefile, "const heim_oid asn1_oid_%s = " "{ %d, oid_%s_variable_num };\n\n", s->gen_name, len, s->gen_name); fprintf (codefile, "const heim_oid *oid_%s(void)\n" "{\n" - "return &oid_%s_variable;\n" + "return &asn1_oid_%s;\n" "}\n\n", s->gen_name, s->gen_name); - close_codefile(); + free(list); + + if (!one_code_file) + close_codefile(); break; } @@ -587,7 +602,7 @@ define_type (int level, const char *name, Type *t, int typedefp, int preservep) fprintf (headerfile, "struct %s {\n", typedefp ? name : ""); ASN1_TAILQ_FOREACH(m, t->members, members) { char *n; - + asprintf (&n, "%s:1", m->gen_name); if (n == NULL) errx(1, "malloc"); @@ -787,7 +802,8 @@ generate_type_header (const Symbol *s) void generate_type (const Symbol *s) { - generate_header_of_codefile(s->gen_name); + if (!one_code_file) + generate_header_of_codefile(s->gen_name); generate_type_header (s); generate_type_encode (s); @@ -798,5 +814,9 @@ generate_type (const Symbol *s) generate_type_seq (s); generate_glue (s->type, s->gen_name); fprintf(headerfile, "\n\n"); - close_codefile(); + + if (!one_code_file) { + fprintf(codefile, "\n\n"); + close_codefile(); + } } |