2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1998-2003 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: gen.c,v 1.65.2.5.2.6 2004/03/15 01:02:54 marka Exp $ */
22 #include <sys/types.h>
32 #include "gen-win32.h"
37 #define FROMTEXTARGS "rdclass, type, lexer, origin, options, target, callbacks"
38 #define FROMTEXTCLASS "rdclass"
39 #define FROMTEXTTYPE "type"
40 #define FROMTEXTDEF "result = DNS_R_UNKNOWN"
42 #define TOTEXTARGS "rdata, tctx, target"
43 #define TOTEXTCLASS "rdata->rdclass"
44 #define TOTEXTTYPE "rdata->type"
45 #define TOTEXTDEF "use_default = ISC_TRUE"
47 #define FROMWIREARGS "rdclass, type, source, dctx, options, target"
48 #define FROMWIRECLASS "rdclass"
49 #define FROMWIRETYPE "type"
50 #define FROMWIREDEF "use_default = ISC_TRUE"
52 #define TOWIREARGS "rdata, cctx, target"
53 #define TOWIRECLASS "rdata->rdclass"
54 #define TOWIRETYPE "rdata->type"
55 #define TOWIREDEF "use_default = ISC_TRUE"
57 #define FROMSTRUCTARGS "rdclass, type, source, target"
58 #define FROMSTRUCTCLASS "rdclass"
59 #define FROMSTRUCTTYPE "type"
60 #define FROMSTRUCTDEF "use_default = ISC_TRUE"
62 #define TOSTRUCTARGS "rdata, target, mctx"
63 #define TOSTRUCTCLASS "rdata->rdclass"
64 #define TOSTRUCTTYPE "rdata->type"
65 #define TOSTRUCTDEF "use_default = ISC_TRUE"
67 #define FREESTRUCTARGS "source"
68 #define FREESTRUCTCLASS "common->rdclass"
69 #define FREESTRUCTTYPE "common->rdtype"
70 #define FREESTRUCTDEF NULL
72 #define COMPAREARGS "rdata1, rdata2"
73 #define COMPARECLASS "rdata1->rdclass"
74 #define COMPARETYPE "rdata1->type"
75 #define COMPAREDEF "use_default = ISC_TRUE"
77 #define ADDITIONALDATAARGS "rdata, add, arg"
78 #define ADDITIONALDATACLASS "rdata->rdclass"
79 #define ADDITIONALDATATYPE "rdata->type"
80 #define ADDITIONALDATADEF "use_default = ISC_TRUE"
82 #define DIGESTARGS "rdata, digest, arg"
83 #define DIGESTCLASS "rdata->rdclass"
84 #define DIGESTTYPE "rdata->type"
85 #define DIGESTDEF "use_default = ISC_TRUE"
87 #define CHECKOWNERARGS "name, rdclass, type, wildcard"
88 #define CHECKOWNERCLASS "rdclass"
89 #define CHECKOWNERTYPE "type"
90 #define CHECKOWNERDEF "result = ISC_TRUE"
92 #define CHECKNAMESARGS "rdata, owner, bad"
93 #define CHECKNAMESCLASS "rdata->rdclass"
94 #define CHECKNAMESTYPE "rdata->type"
95 #define CHECKNAMESDEF "result = ISC_TRUE"
97 const char copyright[] =
99 " * Copyright (C) 2004%s Internet Systems Consortium, Inc. (\"ISC\")\n"
100 " * Copyright (C) 1998-2003 Internet Software Consortium.\n"
102 " * Permission to use, copy, modify, and distribute this software for any\n"
103 " * purpose with or without fee is hereby granted, provided that the above\n"
104 " * copyright notice and this permission notice appear in all copies.\n"
106 " * THE SOFTWARE IS PROVIDED \"AS IS\" AND ISC DISCLAIMS ALL WARRANTIES WITH\n"
107 " * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n"
108 " * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,\n"
109 " * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n"
110 " * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE\n"
111 " * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n"
112 " * PERFORMANCE OF THIS SOFTWARE.\n"
117 " *************** THIS FILE IS AUTOMATICALLY GENERATED BY gen.c.\n"
118 " *************** DO NOT EDIT!\n"
120 " ***************/\n"
123 #define TYPENAMES 256
137 char dirname[256]; /* XXX Should be max path length */
146 } typenames[TYPENAMES];
153 funname(const char *, char *);
155 doswitch(const char *, const char *, const char *, const char *,
156 const char *, const char *);
158 dodecl(char *, char *, char *);
160 add(int, const char *, int, const char *, const char *);
162 sd(int, const char *, const char *, char);
164 insert_into_typenames(int, const char *, const char *);
167 * If you use more than 10 of these in, say, a printf(), you'll have problems.
171 static int buf_to_use = 0;
172 static char buf[10][256];
183 while ((c = (*s++) & 0xff))
184 *b++ = islower(c) ? toupper(c) : c;
186 return (buf[buf_to_use]);
190 funname(const char *s, char *buf) {
195 *b++ = (c == '-') ? '_' : c;
202 doswitch(const char *name, const char *function, const char *args,
203 const char *tsw, const char *csw, const char *res)
209 char buf1[11], buf2[11];
210 const char *result = " result =";
215 for (tt = types; tt != NULL; tt = tt->next) {
217 fprintf(stdout, "\n#define %s \\\n", name);
218 fprintf(stdout, "\tswitch (%s) { \\\n" /*}*/, tsw);
221 if (tt->type != lasttype && subswitch) {
223 fprintf(stdout, "\t\tdefault: break; \\\n");
226 "\t\tdefault: %s; break; \\\n", res);
227 fputs(/*{*/ "\t\t} \\\n", stdout);
228 fputs("\t\tbreak; \\\n", stdout);
231 if (tt->rdclass && tt->type != lasttype) {
232 fprintf(stdout, "\tcase %d: switch (%s) { \\\n" /*}*/,
236 if (tt->rdclass == 0)
238 "\tcase %d:%s %s_%s(%s); break;",
239 tt->type, result, function,
240 funname(tt->typename, buf1), args);
243 "\t\tcase %d:%s %s_%s_%s(%s); break;",
244 tt->rdclass, result, function,
245 funname(tt->classname, buf1),
246 funname(tt->typename, buf2), args);
247 fputs(" \\\n", stdout);
252 fprintf(stdout, "\t\tdefault: break; \\\n");
254 fprintf(stdout, "\t\tdefault: %s; break; \\\n", res);
255 fputs(/*{*/ "\t\t} \\\n", stdout);
256 fputs("\t\tbreak; \\\n", stdout);
260 fprintf(stdout, "\n#define %s\n", name);
262 fprintf(stdout, "\n#define %s %s;\n", name, res);
265 fprintf(stdout, "\tdefault: break; \\\n");
267 fprintf(stdout, "\tdefault: %s; break; \\\n", res);
268 fputs(/*{*/ "\t}\n", stdout);
273 dodecl(char *type, char *function, char *args) {
275 char buf1[11], buf2[11];
278 for (tt = types; tt; tt = tt->next)
281 "static inline %s %s_%s_%s(%s);\n",
283 funname(tt->classname, buf1),
284 funname(tt->typename, buf2), args);
287 "static inline %s %s_%s(%s);\n",
289 funname(tt->typename, buf1), args);
292 static struct ttnam *
293 find_typename(int type) {
296 for (i = 0; i < TYPENAMES; i++) {
297 if (typenames[i].typename[0] != 0 &&
298 typenames[i].type == type)
299 return (&typenames[i]);
305 insert_into_typenames(int type, const char *typename, const char *attr) {
306 struct ttnam *ttn = NULL;
310 for (i = 0; i < TYPENAMES; i++) {
311 if (typenames[i].typename[0] != 0 &&
312 typenames[i].type == type &&
313 strcmp(typename, typenames[i].typename) != 0) {
315 "Error: type %d has two names: %s, %s\n",
316 type, typenames[i].typename, typename);
319 if (typenames[i].typename[0] == 0 && ttn == NULL)
323 fprintf(stderr, "Error: typenames array too small\n");
327 if (strlen(typename) > sizeof(ttn->typename) - 1) {
328 fprintf(stderr, "Error: type name %s is too long\n",
332 strcpy(ttn->typename, typename);
335 strcpy(ttn->macroname, ttn->typename);
336 c = strlen(ttn->macroname);
338 if (ttn->macroname[c - 1] == '-')
339 ttn->macroname[c - 1] = '_';
344 sprintf(tmp, "RRTYPE_%s_ATTRIBUTES", upper(ttn->macroname));
348 if (ttn->attr[0] != 0 && strcmp(attr, ttn->attr) != 0) {
349 fprintf(stderr, "Error: type %d has different attributes: "
350 "%s, %s\n", type, ttn->attr, attr);
354 if (strlen(attr) > sizeof(ttn->attr) - 1) {
355 fprintf(stderr, "Error: attr (%s) [name %s] is too long\n",
359 strcpy(ttn->attr, attr);
366 add(int rdclass, const char *classname, int type, const char *typename,
369 struct tt *newtt = (struct tt *)malloc(sizeof(*newtt));
370 struct tt *tt, *oldtt;
372 struct cc *cc, *oldcc;
374 insert_into_typenames(type, typename, NULL);
377 fprintf(stderr, "malloc() failed\n");
382 newtt->rdclass = rdclass;
384 strcpy(newtt->classname, classname);
385 strcpy(newtt->typename, typename);
386 strcpy(newtt->dirname, dirname);
391 while ((tt != NULL) && (tt->type < type)) {
396 while ((tt != NULL) && (tt->type == type) && (tt->rdclass < rdclass)) {
397 if (strcmp(tt->typename, typename) != 0)
403 if ((tt != NULL) && (tt->type == type) && (tt->rdclass == rdclass))
413 * Do a class switch for this type.
418 newcc = (struct cc *)malloc(sizeof(*newcc));
419 newcc->rdclass = rdclass;
420 strcpy(newcc->classname, classname);
424 while ((cc != NULL) && (cc->rdclass < rdclass)) {
429 if ((cc != NULL) && cc->rdclass == rdclass) {
442 sd(int rdclass, const char *classname, const char *dirname, char filetype) {
443 char buf[sizeof("0123456789_65535.h")];
444 char fmt[sizeof("%10[-0-9a-z]_%d.h")];
449 if (!start_directory(dirname, &dir))
452 sprintf(fmt,"%s%c", "%10[-0-9a-z]_%d.", filetype);
453 while (next_file(&dir)) {
454 if (sscanf(dir.filename, fmt, typename, &type) != 2)
456 if ((type > 65535) || (type < 0))
459 sprintf(buf, "%s_%d.%c", typename, type, filetype);
460 if (strcmp(buf, dir.filename) != 0)
462 add(rdclass, classname, type, typename, dirname);
475 fprintf(stderr, "n == 0?\n");
478 a = tolower((unsigned char)string[0]);
479 b = tolower((unsigned char)string[n - 1]);
481 return ((a + n) * b) % 256;
485 main(int argc, char **argv) {
486 char buf[256]; /* XXX Should be max path length */
487 char srcdir[256]; /* XXX Should be max path length */
492 struct ttnam *ttn, *ttn2;
512 for (i = 0; i < TYPENAMES; i++)
513 memset(&typenames[i], 0, sizeof(typenames[i]));
516 while ((c = isc_commandline_parse(argc, argv, "cdits:F:P:S:")) != -1)
551 sprintf(srcdir, "%s/", isc_commandline_argument);
554 file = isc_commandline_argument;
557 prefix = isc_commandline_argument;
560 suffix = isc_commandline_argument;
566 sprintf(buf, "%srdata", srcdir);
568 if (!start_directory(buf, &dir))
571 while (next_file(&dir)) {
572 if (sscanf(dir.filename, "%10[0-9a-z]_%d",
573 classname, &rdclass) != 2)
575 if ((rdclass > 65535) || (rdclass < 0))
578 sprintf(buf, "%srdata/%s_%d", srcdir, classname, rdclass);
579 if (strcmp(buf + 6 + strlen(srcdir), dir.filename) != 0)
581 sd(rdclass, classname, buf, filetype);
584 sprintf(buf, "%srdata/generic", srcdir);
585 sd(0, "", buf, filetype);
587 if (time(&now) != -1) {
588 if ((tm = localtime(&now)) != NULL && tm->tm_year > 104)
589 sprintf(year, "-%d", tm->tm_year + 1900);
595 if (!depend) fprintf(stdout, copyright, year);
598 fputs("#ifndef DNS_CODE_H\n", stdout);
599 fputs("#define DNS_CODE_H 1\n\n", stdout);
601 fputs("#include <isc/boolean.h>\n", stdout);
602 fputs("#include <isc/result.h>\n\n", stdout);
603 fputs("#include <dns/name.h>\n\n", stdout);
605 for (tt = types; tt != NULL; tt = tt->next)
606 fprintf(stdout, "#include \"%s/%s_%d.c\"\n",
607 tt->dirname, tt->typename, tt->type);
609 fputs("\n\n", stdout);
611 doswitch("FROMTEXTSWITCH", "fromtext", FROMTEXTARGS,
612 FROMTEXTTYPE, FROMTEXTCLASS, FROMTEXTDEF);
613 doswitch("TOTEXTSWITCH", "totext", TOTEXTARGS,
614 TOTEXTTYPE, TOTEXTCLASS, TOTEXTDEF);
615 doswitch("FROMWIRESWITCH", "fromwire", FROMWIREARGS,
616 FROMWIRETYPE, FROMWIRECLASS, FROMWIREDEF);
617 doswitch("TOWIRESWITCH", "towire", TOWIREARGS,
618 TOWIRETYPE, TOWIRECLASS, TOWIREDEF);
619 doswitch("COMPARESWITCH", "compare", COMPAREARGS,
620 COMPARETYPE, COMPARECLASS, COMPAREDEF);
621 doswitch("FROMSTRUCTSWITCH", "fromstruct", FROMSTRUCTARGS,
622 FROMSTRUCTTYPE, FROMSTRUCTCLASS, FROMSTRUCTDEF);
623 doswitch("TOSTRUCTSWITCH", "tostruct", TOSTRUCTARGS,
624 TOSTRUCTTYPE, TOSTRUCTCLASS, TOSTRUCTDEF);
625 doswitch("FREESTRUCTSWITCH", "freestruct", FREESTRUCTARGS,
626 FREESTRUCTTYPE, FREESTRUCTCLASS, FREESTRUCTDEF);
627 doswitch("ADDITIONALDATASWITCH", "additionaldata",
628 ADDITIONALDATAARGS, ADDITIONALDATATYPE,
629 ADDITIONALDATACLASS, ADDITIONALDATADEF);
630 doswitch("DIGESTSWITCH", "digest",
631 DIGESTARGS, DIGESTTYPE,
632 DIGESTCLASS, DIGESTDEF);
633 doswitch("CHECKOWNERSWITCH", "checkowner",
634 CHECKOWNERARGS, CHECKOWNERTYPE,
635 CHECKOWNERCLASS, CHECKOWNERDEF);
636 doswitch("CHECKNAMESSWITCH", "checknames",
637 CHECKNAMESARGS, CHECKNAMESTYPE,
638 CHECKNAMESCLASS, CHECKNAMESDEF);
641 * From here down, we are processing the rdata names and
645 #define PRINT_COMMA(x) (x == maxtype ? "" : ",")
647 #define METANOTQUESTION "DNS_RDATATYPEATTR_META | " \
648 "DNS_RDATATYPEATTR_NOTQUESTION"
649 #define METAQUESTIONONLY "DNS_RDATATYPEATTR_META | " \
650 "DNS_RDATATYPEATTR_QUESTIONONLY"
651 #define RESERVED "DNS_RDATATYPEATTR_RESERVED"
654 * Add in reserved/special types. This will let us
655 * sort them without special cases.
657 insert_into_typenames(0, "reserved0", RESERVED);
658 insert_into_typenames(31, "eid", RESERVED);
659 insert_into_typenames(32, "nimloc", RESERVED);
660 insert_into_typenames(34, "atma", RESERVED);
661 insert_into_typenames(100, "uinfo", RESERVED);
662 insert_into_typenames(101, "uid", RESERVED);
663 insert_into_typenames(102, "gid", RESERVED);
664 insert_into_typenames(251, "ixfr", METAQUESTIONONLY);
665 insert_into_typenames(252, "axfr", METAQUESTIONONLY);
666 insert_into_typenames(253, "mailb", METAQUESTIONONLY);
667 insert_into_typenames(254, "maila", METAQUESTIONONLY);
668 insert_into_typenames(255, "any", METAQUESTIONONLY);
671 * Spit out a quick and dirty hash function. Here,
672 * we walk through the list of type names, and calculate
673 * a hash. This isn't perfect, but it will generate "pretty
674 * good" estimates. Lowercase the characters before
675 * computing in all cases.
677 * Here, walk the list from top to bottom, calculating
678 * the hash (mod 256) for each name.
680 fprintf(stdout, "#define RDATATYPE_COMPARE(_s, _d, _tn, _n, _tp) \\\n");
681 fprintf(stdout, "\tdo { \\\n");
682 fprintf(stdout, "\t\tif (sizeof(_s) - 1 == _n && \\\n"
683 "\t\t strncasecmp(_s,(_tn),"
684 "(sizeof(_s) - 1)) == 0) { \\\n");
685 fprintf(stdout, "\t\t\tif ((dns_rdatatype_attributes(_d) & "
686 "DNS_RDATATYPEATTR_RESERVED) != 0) \\\n");
687 fprintf(stdout, "\t\t\t\treturn (ISC_R_NOTIMPLEMENTED); \\\n");
688 fprintf(stdout, "\t\t\t*(_tp) = _d; \\\n");
689 fprintf(stdout, "\t\t\treturn (ISC_R_SUCCESS); \\\n");
690 fprintf(stdout, "\t\t} \\\n");
691 fprintf(stdout, "\t} while (0)\n\n");
693 fprintf(stdout, "#define RDATATYPE_FROMTEXT_SW(_hash,"
694 "_typename,_length,_typep) \\\n");
695 fprintf(stdout, "\tswitch (_hash) { \\\n");
696 for (i = 0; i <= maxtype; i++) {
697 ttn = find_typename(i);
702 * Skip entries we already processed.
704 if (ttn->sorted != 0)
707 hash = HASH(ttn->typename);
708 fprintf(stdout, "\t\tcase %u: \\\n", hash);
711 * Find all other entries that happen to match
714 for (j = 0; j <= maxtype; j++) {
715 ttn2 = find_typename(j);
718 if (hash == HASH(ttn2->typename)) {
719 fprintf(stdout, "\t\t\tRDATATYPE_COMPARE"
721 "_typename, _length, _typep); \\\n",
722 ttn2->typename, ttn2->type);
726 fprintf(stdout, "\t\t\tbreak; \\\n");
728 fprintf(stdout, "\t}\n");
730 fprintf(stdout, "#define RDATATYPE_ATTRIBUTE_SW \\\n");
731 fprintf(stdout, "\tswitch (type) { \\\n");
732 for (i = 0; i <= maxtype; i++) {
733 ttn = find_typename(i);
736 fprintf(stdout, "\tcase %u: return (%s); \\\n",
737 i, upper(ttn->attr));
739 fprintf(stdout, "\t}\n");
741 fprintf(stdout, "#define RDATATYPE_TOTEXT_SW \\\n");
742 fprintf(stdout, "\tswitch (type) { \\\n");
743 for (i = 0; i <= maxtype; i++) {
744 ttn = find_typename(i);
747 fprintf(stdout, "\tcase %u: return "
748 "(str_totext(\"%s\", target)); \\\n",
749 i, upper(ttn->typename));
751 fprintf(stdout, "\t}\n");
753 fputs("#endif /* DNS_CODE_H */\n", stdout);
754 } else if (type_enum) {
757 fprintf(stdout, "#ifndef DNS_ENUMTYPE_H\n");
758 fprintf(stdout, "#define DNS_ENUMTYPE_H 1\n\n");
760 fprintf(stdout, "enum {\n");
761 fprintf(stdout, "\tdns_rdatatype_none = 0,\n");
764 for (tt = types; tt != NULL; tt = tt->next)
765 if (tt->type != lasttype)
767 "\tdns_rdatatype_%s = %d,\n",
768 funname(tt->typename, buf1),
769 lasttype = tt->type);
771 fprintf(stdout, "\tdns_rdatatype_ixfr = 251,\n");
772 fprintf(stdout, "\tdns_rdatatype_axfr = 252,\n");
773 fprintf(stdout, "\tdns_rdatatype_mailb = 253,\n");
774 fprintf(stdout, "\tdns_rdatatype_maila = 254,\n");
775 fprintf(stdout, "\tdns_rdatatype_any = 255\n");
777 fprintf(stdout, "};\n\n");
779 fprintf(stdout, "#define dns_rdatatype_none\t"
780 "((dns_rdatatype_t)dns_rdatatype_none)\n");
782 for (tt = types; tt != NULL; tt = tt->next)
783 if (tt->type != lasttype) {
784 s = funname(tt->typename, buf1);
786 "#define dns_rdatatype_%s\t%s"
787 "((dns_rdatatype_t)dns_rdatatype_%s)"
789 s, strlen(s) < 2U ? "\t" : "", s);
793 fprintf(stdout, "#define dns_rdatatype_ixfr\t"
794 "((dns_rdatatype_t)dns_rdatatype_ixfr)\n");
795 fprintf(stdout, "#define dns_rdatatype_axfr\t"
796 "((dns_rdatatype_t)dns_rdatatype_axfr)\n");
797 fprintf(stdout, "#define dns_rdatatype_mailb\t"
798 "((dns_rdatatype_t)dns_rdatatype_mailb)\n");
799 fprintf(stdout, "#define dns_rdatatype_maila\t"
800 "((dns_rdatatype_t)dns_rdatatype_maila)\n");
801 fprintf(stdout, "#define dns_rdatatype_any\t"
802 "((dns_rdatatype_t)dns_rdatatype_any)\n");
804 fprintf(stdout, "\n#endif /* DNS_ENUMTYPE_H */\n");
806 } else if (class_enum) {
810 fprintf(stdout, "#ifndef DNS_ENUMCLASS_H\n");
811 fprintf(stdout, "#define DNS_ENUMCLASS_H 1\n\n");
813 fprintf(stdout, "enum {\n");
815 fprintf(stdout, "\tdns_rdataclass_reserved0 = 0,\n");
816 fprintf(stdout, "#define dns_rdataclass_reserved0 \\\n\t\t\t\t"
817 "((dns_rdataclass_t)dns_rdataclass_reserved0)\n");
819 #define PRINTCLASS(name, num) \
821 s = funname(name, buf1); \
823 fprintf(stdout, "\tdns_rdataclass_%s = %d%s\n", s, classnum, \
824 classnum != 255 ? "," : ""); \
825 fprintf(stdout, "#define dns_rdataclass_%s\t" \
826 "((dns_rdataclass_t)dns_rdataclass_%s)\n", s, s); \
829 for (cc = classes; cc != NULL; cc = cc->next) {
830 if (cc->rdclass == 4) {
832 PRINTCLASS("chaos", 3);
834 } else if (cc->rdclass == 255) {
835 PRINTCLASS("none", 254);
837 PRINTCLASS(cc->classname, cc->rdclass);
842 fprintf(stdout, "};\n\n");
843 fprintf(stdout, "#endif /* DNS_ENUMCLASS_H */\n");
844 } else if (structs) {
845 if (prefix != NULL) {
846 if ((fd = fopen(prefix,"r")) != NULL) {
847 while (fgets(buf, sizeof(buf), fd) != NULL)
852 for (tt = types; tt != NULL; tt = tt->next) {
853 sprintf(buf, "%s/%s_%d.h",
854 tt->dirname, tt->typename, tt->type);
855 if ((fd = fopen(buf,"r")) != NULL) {
856 while (fgets(buf, sizeof(buf), fd) != NULL)
861 if (suffix != NULL) {
862 if ((fd = fopen(suffix,"r")) != NULL) {
863 while (fgets(buf, sizeof(buf), fd) != NULL)
869 for (tt = types; tt != NULL; tt = tt->next)
870 fprintf(stdout, "%s:\t%s/%s_%d.h\n", file,
871 tt->dirname, tt->typename, tt->type);
874 if (ferror(stdout) != 0)