No empty .Rs/.Re
[netbsd-mini2440.git] / crypto / dist / heimdal / lib / asn1 / gen.c
bloba00543fa38e6cfa03536c7a14f4331c243040e40
1 /*
2 * Copyright (c) 1997 - 2005 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
34 #include "gen_locl.h"
36 __RCSID("$Heimdal: gen.c 22429 2008-01-13 10:25:50Z lha $"
37 "$NetBSD: gen.c,v 1.10 2008/08/03 07:16:58 veego Exp $");
39 FILE *headerfile, *codefile, *logfile;
41 #define STEM "asn1"
43 static const char *orig_filename;
44 static char *header;
45 static const char *headerbase = STEM;
48 * list of all IMPORTs
51 struct import {
52 const char *module;
53 struct import *next;
56 static struct import *imports = NULL;
58 void
59 add_import (const char *module)
61 struct import *tmp = emalloc (sizeof(*tmp));
63 tmp->module = module;
64 tmp->next = imports;
65 imports = tmp;
67 fprintf (headerfile, "#include <%s_asn1.h>\n", module);
70 const char *
71 get_filename (void)
73 return orig_filename;
76 void
77 init_generate (const char *filename, const char *base)
79 char *fn;
81 orig_filename = filename;
82 if (base != NULL) {
83 headerbase = strdup(base);
84 if (headerbase == NULL)
85 errx(1, "strdup");
87 asprintf(&header, "%s.hx", headerbase);
88 if (header == NULL)
89 errx(1, "malloc");
90 headerfile = fopen (header, "w");
91 if (headerfile == NULL)
92 err (1, "open %s", header);
93 fprintf (headerfile,
94 "/* Generated from %s */\n"
95 "/* Do not edit */\n\n",
96 filename);
97 fprintf (headerfile,
98 "#ifndef __%s_h__\n"
99 "#define __%s_h__\n\n", headerbase, headerbase);
100 fprintf (headerfile,
101 "#include <stddef.h>\n"
102 "#include <time.h>\n\n");
103 fprintf (headerfile,
104 "#ifndef __asn1_common_definitions__\n"
105 "#define __asn1_common_definitions__\n\n");
106 fprintf (headerfile,
107 "typedef struct heim_integer {\n"
108 " size_t length;\n"
109 " void *data;\n"
110 " int negative;\n"
111 "} heim_integer;\n\n");
112 fprintf (headerfile,
113 "typedef struct heim_octet_string {\n"
114 " size_t length;\n"
115 " void *data;\n"
116 "} heim_octet_string;\n\n");
117 fprintf (headerfile,
118 "typedef char *heim_general_string;\n\n"
120 fprintf (headerfile,
121 "typedef char *heim_utf8_string;\n\n"
123 fprintf (headerfile,
124 "typedef char *heim_printable_string;\n\n"
126 fprintf (headerfile,
127 "typedef char *heim_ia5_string;\n\n"
129 fprintf (headerfile,
130 "typedef struct heim_bmp_string {\n"
131 " size_t length;\n"
132 " uint16_t *data;\n"
133 "} heim_bmp_string;\n\n");
134 fprintf (headerfile,
135 "typedef struct heim_universal_string {\n"
136 " size_t length;\n"
137 " uint32_t *data;\n"
138 "} heim_universal_string;\n\n");
139 fprintf (headerfile,
140 "typedef char *heim_visible_string;\n\n"
142 fprintf (headerfile,
143 "typedef struct heim_oid {\n"
144 " size_t length;\n"
145 " unsigned *components;\n"
146 "} heim_oid;\n\n");
147 fprintf (headerfile,
148 "typedef struct heim_bit_string {\n"
149 " size_t length;\n"
150 " void *data;\n"
151 "} heim_bit_string;\n\n");
152 fprintf (headerfile,
153 "typedef struct heim_octet_string heim_any;\n"
154 "typedef struct heim_octet_string heim_any_set;\n\n");
155 fputs("#define ASN1_MALLOC_ENCODE(T, B, BL, S, L, R) \\\n"
156 " do { \\\n"
157 " (BL) = length_##T((S)); \\\n"
158 " (B) = malloc((BL)); \\\n"
159 " if((B) == NULL) { \\\n"
160 " (R) = ENOMEM; \\\n"
161 " } else { \\\n"
162 " (R) = encode_##T(((unsigned char*)(B)) + (BL) - 1, (BL), \\\n"
163 " (S), (L)); \\\n"
164 " if((R) != 0) { \\\n"
165 " free((B)); \\\n"
166 " (B) = NULL; \\\n"
167 " } \\\n"
168 " } \\\n"
169 " } while (0)\n\n",
170 headerfile);
171 fprintf (headerfile, "struct units;\n\n");
172 fprintf (headerfile, "#endif\n\n");
173 asprintf(&fn, "%s_files", base);
174 if (fn == NULL)
175 errx(1, "malloc");
176 logfile = fopen(fn, "w");
177 if (logfile == NULL)
178 err (1, "open %s", fn);
181 void
182 close_generate (void)
184 fprintf (headerfile, "#endif /* __%s_h__ */\n", headerbase);
186 fclose (headerfile);
187 fprintf (logfile, "\n");
188 fclose (logfile);
191 void
192 gen_assign_defval(const char *var, struct value *val)
194 switch(val->type) {
195 case stringvalue:
196 fprintf(codefile, "if((%s = strdup(\"%s\")) == NULL)\nreturn ENOMEM;\n", var, val->u.stringvalue);
197 break;
198 case integervalue:
199 fprintf(codefile, "%s = %d;\n", var, val->u.integervalue);
200 break;
201 case booleanvalue:
202 if(val->u.booleanvalue)
203 fprintf(codefile, "%s = TRUE;\n", var);
204 else
205 fprintf(codefile, "%s = FALSE;\n", var);
206 break;
207 default:
208 abort();
212 void
213 gen_compare_defval(const char *var, struct value *val)
215 switch(val->type) {
216 case stringvalue:
217 fprintf(codefile, "if(strcmp(%s, \"%s\") != 0)\n", var, val->u.stringvalue);
218 break;
219 case integervalue:
220 fprintf(codefile, "if(%s != %d)\n", var, val->u.integervalue);
221 break;
222 case booleanvalue:
223 if(val->u.booleanvalue)
224 fprintf(codefile, "if(!%s)\n", var);
225 else
226 fprintf(codefile, "if(%s)\n", var);
227 break;
228 default:
229 abort();
233 static void
234 generate_header_of_codefile(const char *name)
236 char *filename;
238 if (codefile != NULL)
239 abort();
241 asprintf (&filename, "%s_%s.x", STEM, name);
242 if (filename == NULL)
243 errx(1, "malloc");
244 codefile = fopen (filename, "w");
245 if (codefile == NULL)
246 err (1, "fopen %s", filename);
247 fprintf(logfile, "%s ", filename);
248 free(filename);
249 fprintf (codefile,
250 "/* Generated from %s */\n"
251 "/* Do not edit */\n\n"
252 "#include <stdio.h>\n"
253 "#include <stdlib.h>\n"
254 "#include <time.h>\n"
255 "#include <string.h>\n"
256 "#include <errno.h>\n"
257 "#include <limits.h>\n"
258 "#include <krb5-types.h>\n",
259 orig_filename);
261 fprintf (codefile,
262 "#include <%s.h>\n",
263 headerbase);
264 fprintf (codefile,
265 "#include <asn1_err.h>\n"
266 "#include <der.h>\n"
267 "#include <parse_units.h>\n\n");
271 static void
272 close_codefile(void)
274 if (codefile == NULL)
275 abort();
277 fclose(codefile);
278 codefile = NULL;
282 void
283 generate_constant (const Symbol *s)
285 switch(s->value->type) {
286 case booleanvalue:
287 break;
288 case integervalue:
289 fprintf (headerfile, "enum { %s = %d };\n\n",
290 s->gen_name, s->value->u.integervalue);
291 break;
292 case nullvalue:
293 break;
294 case stringvalue:
295 break;
296 case objectidentifiervalue: {
297 struct objid *o, **list;
298 int i, len;
300 generate_header_of_codefile(s->gen_name);
302 len = 0;
303 for (o = s->value->u.objectidentifiervalue; o != NULL; o = o->next)
304 len++;
305 list = emalloc(sizeof(*list) * len);
307 i = 0;
308 for (o = s->value->u.objectidentifiervalue; o != NULL; o = o->next)
309 list[i++] = o;
311 fprintf (headerfile, "/* OBJECT IDENTIFIER %s ::= { ", s->name);
312 for (i = len - 1 ; i >= 0; i--) {
313 o = list[i];
314 fprintf(headerfile, "%s(%d) ",
315 o->label ? o->label : "label-less", o->value);
318 fprintf (headerfile, "} */\n");
319 fprintf (headerfile, "const heim_oid *oid_%s(void);\n\n",
320 s->gen_name);
322 fprintf (codefile, "static unsigned oid_%s_variable_num[%d] = {",
323 s->gen_name, len);
324 for (i = len - 1 ; i >= 0; i--) {
325 fprintf(codefile, "%d%s ", list[i]->value, i > 0 ? "," : "");
327 fprintf(codefile, "};\n");
329 fprintf (codefile, "static const heim_oid oid_%s_variable = "
330 "{ %d, oid_%s_variable_num };\n\n",
331 s->gen_name, len, s->gen_name);
333 fprintf (codefile, "const heim_oid *oid_%s(void)\n"
334 "{\n"
335 "return &oid_%s_variable;\n"
336 "}\n\n",
337 s->gen_name, s->gen_name);
339 close_codefile();
340 free(list);
342 break;
344 default:
345 abort();
349 static void
350 space(int level)
352 while(level-- > 0)
353 fprintf(headerfile, " ");
356 static const char *
357 last_member_p(struct member *m)
359 struct member *n = ASN1_TAILQ_NEXT(m, members);
360 if (n == NULL)
361 return "";
362 if (n->ellipsis && ASN1_TAILQ_NEXT(n, members) == NULL)
363 return "";
364 return ",";
367 static struct member *
368 have_ellipsis(Type *t)
370 struct member *m;
371 ASN1_TAILQ_FOREACH(m, t->members, members) {
372 if (m->ellipsis)
373 return m;
375 return NULL;
378 static void
379 define_asn1 (int level, Type *t)
381 switch (t->type) {
382 case TType:
383 fprintf (headerfile, "%s", t->symbol->name);
384 break;
385 case TInteger:
386 if(t->members == NULL) {
387 fprintf (headerfile, "INTEGER");
388 if (t->range)
389 fprintf (headerfile, " (%d..%d)",
390 t->range->min, t->range->max);
391 } else {
392 Member *m;
393 fprintf (headerfile, "INTEGER {\n");
394 ASN1_TAILQ_FOREACH(m, t->members, members) {
395 space (level + 1);
396 fprintf(headerfile, "%s(%d)%s\n", m->gen_name, m->val,
397 last_member_p(m));
399 space(level);
400 fprintf (headerfile, "}");
402 break;
403 case TBoolean:
404 fprintf (headerfile, "BOOLEAN");
405 break;
406 case TOctetString:
407 fprintf (headerfile, "OCTET STRING");
408 break;
409 case TEnumerated :
410 case TBitString: {
411 Member *m;
413 space(level);
414 if(t->type == TBitString)
415 fprintf (headerfile, "BIT STRING {\n");
416 else
417 fprintf (headerfile, "ENUMERATED {\n");
418 ASN1_TAILQ_FOREACH(m, t->members, members) {
419 space(level + 1);
420 fprintf (headerfile, "%s(%d)%s\n", m->name, m->val,
421 last_member_p(m));
423 space(level);
424 fprintf (headerfile, "}");
425 break;
427 case TChoice:
428 case TSet:
429 case TSequence: {
430 Member *m;
431 int max_width = 0;
433 if(t->type == TChoice)
434 fprintf(headerfile, "CHOICE {\n");
435 else if(t->type == TSet)
436 fprintf(headerfile, "SET {\n");
437 else
438 fprintf(headerfile, "SEQUENCE {\n");
439 ASN1_TAILQ_FOREACH(m, t->members, members) {
440 if(strlen(m->name) > max_width)
441 max_width = strlen(m->name);
443 max_width += 3;
444 if(max_width < 16) max_width = 16;
445 ASN1_TAILQ_FOREACH(m, t->members, members) {
446 int width = max_width;
447 space(level + 1);
448 if (m->ellipsis) {
449 fprintf (headerfile, "...");
450 } else {
451 width -= fprintf(headerfile, "%s", m->name);
452 fprintf(headerfile, "%*s", width, "");
453 define_asn1(level + 1, m->type);
454 if(m->optional)
455 fprintf(headerfile, " OPTIONAL");
457 if(last_member_p(m))
458 fprintf (headerfile, ",");
459 fprintf (headerfile, "\n");
461 space(level);
462 fprintf (headerfile, "}");
463 break;
465 case TSequenceOf:
466 fprintf (headerfile, "SEQUENCE OF ");
467 define_asn1 (0, t->subtype);
468 break;
469 case TSetOf:
470 fprintf (headerfile, "SET OF ");
471 define_asn1 (0, t->subtype);
472 break;
473 case TGeneralizedTime:
474 fprintf (headerfile, "GeneralizedTime");
475 break;
476 case TGeneralString:
477 fprintf (headerfile, "GeneralString");
478 break;
479 case TTag: {
480 const char *classnames[] = { "UNIVERSAL ", "APPLICATION ",
481 "" /* CONTEXT */, "PRIVATE " };
482 if(t->tag.tagclass != ASN1_C_UNIV)
483 fprintf (headerfile, "[%s%d] ",
484 classnames[t->tag.tagclass],
485 t->tag.tagvalue);
486 if(t->tag.tagenv == TE_IMPLICIT)
487 fprintf (headerfile, "IMPLICIT ");
488 define_asn1 (level, t->subtype);
489 break;
491 case TUTCTime:
492 fprintf (headerfile, "UTCTime");
493 break;
494 case TUTF8String:
495 space(level);
496 fprintf (headerfile, "UTF8String");
497 break;
498 case TPrintableString:
499 space(level);
500 fprintf (headerfile, "PrintableString");
501 break;
502 case TIA5String:
503 space(level);
504 fprintf (headerfile, "IA5String");
505 break;
506 case TBMPString:
507 space(level);
508 fprintf (headerfile, "BMPString");
509 break;
510 case TUniversalString:
511 space(level);
512 fprintf (headerfile, "UniversalString");
513 break;
514 case TVisibleString:
515 space(level);
516 fprintf (headerfile, "VisibleString");
517 break;
518 case TOID :
519 space(level);
520 fprintf(headerfile, "OBJECT IDENTIFIER");
521 break;
522 case TNull:
523 space(level);
524 fprintf (headerfile, "NULL");
525 break;
526 default:
527 abort ();
531 static void
532 define_type (int level, const char *name, Type *t, int typedefp, int preservep)
534 switch (t->type) {
535 case TType:
536 space(level);
537 fprintf (headerfile, "%s %s;\n", t->symbol->gen_name, name);
538 break;
539 case TInteger:
540 space(level);
541 if(t->members) {
542 Member *m;
543 fprintf (headerfile, "enum %s {\n", typedefp ? name : "");
544 ASN1_TAILQ_FOREACH(m, t->members, members) {
545 space (level + 1);
546 fprintf(headerfile, "%s = %d%s\n", m->gen_name, m->val,
547 last_member_p(m));
549 fprintf (headerfile, "} %s;\n", name);
550 } else if (t->range == NULL) {
551 fprintf (headerfile, "heim_integer %s;\n", name);
552 } else if (t->range->min == INT_MIN && t->range->max == INT_MAX) {
553 fprintf (headerfile, "int %s;\n", name);
554 } else if (t->range->min == 0 && t->range->max == UINT_MAX) {
555 fprintf (headerfile, "unsigned int %s;\n", name);
556 } else if (t->range->min == 0 && t->range->max == INT_MAX) {
557 fprintf (headerfile, "unsigned int %s;\n", name);
558 } else
559 errx(1, "%s: unsupported range %d -> %d",
560 name, t->range->min, t->range->max);
561 break;
562 case TBoolean:
563 space(level);
564 fprintf (headerfile, "int %s;\n", name);
565 break;
566 case TOctetString:
567 space(level);
568 fprintf (headerfile, "heim_octet_string %s;\n", name);
569 break;
570 case TBitString: {
571 Member *m;
572 Type i;
573 struct range range = { 0, INT_MAX };
575 i.type = TInteger;
576 i.range = &range;
577 i.members = NULL;
578 i.constraint = NULL;
580 space(level);
581 if(ASN1_TAILQ_EMPTY(t->members))
582 fprintf (headerfile, "heim_bit_string %s;\n", name);
583 else {
584 fprintf (headerfile, "struct %s {\n", typedefp ? name : "");
585 ASN1_TAILQ_FOREACH(m, t->members, members) {
586 char *n;
588 asprintf (&n, "%s:1", m->gen_name);
589 if (n == NULL)
590 errx(1, "malloc");
591 define_type (level + 1, n, &i, FALSE, FALSE);
592 free (n);
594 space(level);
595 fprintf (headerfile, "} %s;\n\n", name);
597 break;
599 case TEnumerated: {
600 Member *m;
602 space(level);
603 fprintf (headerfile, "enum %s {\n", typedefp ? name : "");
604 ASN1_TAILQ_FOREACH(m, t->members, members) {
605 space(level + 1);
606 if (m->ellipsis)
607 fprintf (headerfile, "/* ... */\n");
608 else
609 fprintf (headerfile, "%s = %d%s\n", m->gen_name, m->val,
610 last_member_p(m));
612 space(level);
613 fprintf (headerfile, "} %s;\n\n", name);
614 break;
616 case TSet:
617 case TSequence: {
618 Member *m;
620 space(level);
621 fprintf (headerfile, "struct %s {\n", typedefp ? name : "");
622 if (t->type == TSequence && preservep) {
623 space(level + 1);
624 fprintf(headerfile, "heim_octet_string _save;\n");
626 ASN1_TAILQ_FOREACH(m, t->members, members) {
627 if (m->ellipsis) {
629 } else if (m->optional) {
630 char *n;
632 asprintf (&n, "*%s", m->gen_name);
633 if (n == NULL)
634 errx(1, "malloc");
635 define_type (level + 1, n, m->type, FALSE, FALSE);
636 free (n);
637 } else
638 define_type (level + 1, m->gen_name, m->type, FALSE, FALSE);
640 space(level);
641 fprintf (headerfile, "} %s;\n", name);
642 break;
644 case TSetOf:
645 case TSequenceOf: {
646 Type i;
647 struct range range = { 0, INT_MAX };
649 i.type = TInteger;
650 i.range = &range;
651 i.members = NULL;
652 i.constraint = NULL;
654 space(level);
655 fprintf (headerfile, "struct %s {\n", typedefp ? name : "");
656 define_type (level + 1, "len", &i, FALSE, FALSE);
657 define_type (level + 1, "*val", t->subtype, FALSE, FALSE);
658 space(level);
659 fprintf (headerfile, "} %s;\n", name);
660 break;
662 case TGeneralizedTime:
663 space(level);
664 fprintf (headerfile, "time_t %s;\n", name);
665 break;
666 case TGeneralString:
667 space(level);
668 fprintf (headerfile, "heim_general_string %s;\n", name);
669 break;
670 case TTag:
671 define_type (level, name, t->subtype, typedefp, preservep);
672 break;
673 case TChoice: {
674 int first = 1;
675 Member *m;
677 space(level);
678 fprintf (headerfile, "struct %s {\n", typedefp ? name : "");
679 if (preservep) {
680 space(level + 1);
681 fprintf(headerfile, "heim_octet_string _save;\n");
683 space(level + 1);
684 fprintf (headerfile, "enum {\n");
685 m = have_ellipsis(t);
686 if (m) {
687 space(level + 2);
688 fprintf (headerfile, "%s = 0,\n", m->label);
689 first = 0;
691 ASN1_TAILQ_FOREACH(m, t->members, members) {
692 space(level + 2);
693 if (m->ellipsis)
694 fprintf (headerfile, "/* ... */\n");
695 else
696 fprintf (headerfile, "%s%s%s\n", m->label,
697 first ? " = 1" : "",
698 last_member_p(m));
699 first = 0;
701 space(level + 1);
702 fprintf (headerfile, "} element;\n");
703 space(level + 1);
704 fprintf (headerfile, "union {\n");
705 ASN1_TAILQ_FOREACH(m, t->members, members) {
706 if (m->ellipsis) {
707 space(level + 2);
708 fprintf(headerfile, "heim_octet_string asn1_ellipsis;\n");
709 } else if (m->optional) {
710 char *n;
712 asprintf (&n, "*%s", m->gen_name);
713 if (n == NULL)
714 errx(1, "malloc");
715 define_type (level + 2, n, m->type, FALSE, FALSE);
716 free (n);
717 } else
718 define_type (level + 2, m->gen_name, m->type, FALSE, FALSE);
720 space(level + 1);
721 fprintf (headerfile, "} u;\n");
722 space(level);
723 fprintf (headerfile, "} %s;\n", name);
724 break;
726 case TUTCTime:
727 space(level);
728 fprintf (headerfile, "time_t %s;\n", name);
729 break;
730 case TUTF8String:
731 space(level);
732 fprintf (headerfile, "heim_utf8_string %s;\n", name);
733 break;
734 case TPrintableString:
735 space(level);
736 fprintf (headerfile, "heim_printable_string %s;\n", name);
737 break;
738 case TIA5String:
739 space(level);
740 fprintf (headerfile, "heim_ia5_string %s;\n", name);
741 break;
742 case TBMPString:
743 space(level);
744 fprintf (headerfile, "heim_bmp_string %s;\n", name);
745 break;
746 case TUniversalString:
747 space(level);
748 fprintf (headerfile, "heim_universal_string %s;\n", name);
749 break;
750 case TVisibleString:
751 space(level);
752 fprintf (headerfile, "heim_visible_string %s;\n", name);
753 break;
754 case TOID :
755 space(level);
756 fprintf (headerfile, "heim_oid %s;\n", name);
757 break;
758 case TNull:
759 space(level);
760 fprintf (headerfile, "int %s;\n", name);
761 break;
762 default:
763 abort ();
767 static void
768 generate_type_header (const Symbol *s)
770 int preservep = preserve_type(s->name) ? TRUE : FALSE;
772 fprintf (headerfile, "/*\n");
773 fprintf (headerfile, "%s ::= ", s->name);
774 define_asn1 (0, s->type);
775 fprintf (headerfile, "\n*/\n\n");
777 fprintf (headerfile, "typedef ");
778 define_type (0, s->gen_name, s->type, TRUE, preservep);
780 fprintf (headerfile, "\n");
784 void
785 generate_type (const Symbol *s)
787 generate_header_of_codefile(s->gen_name);
789 generate_type_header (s);
790 generate_type_encode (s);
791 generate_type_decode (s);
792 generate_type_free (s);
793 generate_type_length (s);
794 generate_type_copy (s);
795 generate_type_seq (s);
796 generate_glue (s->type, s->gen_name);
797 fprintf(headerfile, "\n\n");
798 close_codefile();