2 * Copyright (C) 2004, 2006 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.9 2006/10/02 06:31:26 marka Exp $ */
22 * Silence compiler warnings about using strcpy and friends.
24 #define _CRT_SECURE_NO_DEPRECATE 1
27 #include <sys/types.h>
37 #include "gen-win32.h"
42 #define FROMTEXTARGS "rdclass, type, lexer, origin, options, target, callbacks"
43 #define FROMTEXTCLASS "rdclass"
44 #define FROMTEXTTYPE "type"
45 #define FROMTEXTDEF "result = DNS_R_UNKNOWN"
47 #define TOTEXTARGS "rdata, tctx, target"
48 #define TOTEXTCLASS "rdata->rdclass"
49 #define TOTEXTTYPE "rdata->type"
50 #define TOTEXTDEF "use_default = ISC_TRUE"
52 #define FROMWIREARGS "rdclass, type, source, dctx, options, target"
53 #define FROMWIRECLASS "rdclass"
54 #define FROMWIRETYPE "type"
55 #define FROMWIREDEF "use_default = ISC_TRUE"
57 #define TOWIREARGS "rdata, cctx, target"
58 #define TOWIRECLASS "rdata->rdclass"
59 #define TOWIRETYPE "rdata->type"
60 #define TOWIREDEF "use_default = ISC_TRUE"
62 #define FROMSTRUCTARGS "rdclass, type, source, target"
63 #define FROMSTRUCTCLASS "rdclass"
64 #define FROMSTRUCTTYPE "type"
65 #define FROMSTRUCTDEF "use_default = ISC_TRUE"
67 #define TOSTRUCTARGS "rdata, target, mctx"
68 #define TOSTRUCTCLASS "rdata->rdclass"
69 #define TOSTRUCTTYPE "rdata->type"
70 #define TOSTRUCTDEF "use_default = ISC_TRUE"
72 #define FREESTRUCTARGS "source"
73 #define FREESTRUCTCLASS "common->rdclass"
74 #define FREESTRUCTTYPE "common->rdtype"
75 #define FREESTRUCTDEF NULL
77 #define COMPAREARGS "rdata1, rdata2"
78 #define COMPARECLASS "rdata1->rdclass"
79 #define COMPARETYPE "rdata1->type"
80 #define COMPAREDEF "use_default = ISC_TRUE"
82 #define ADDITIONALDATAARGS "rdata, add, arg"
83 #define ADDITIONALDATACLASS "rdata->rdclass"
84 #define ADDITIONALDATATYPE "rdata->type"
85 #define ADDITIONALDATADEF "use_default = ISC_TRUE"
87 #define DIGESTARGS "rdata, digest, arg"
88 #define DIGESTCLASS "rdata->rdclass"
89 #define DIGESTTYPE "rdata->type"
90 #define DIGESTDEF "use_default = ISC_TRUE"
92 #define CHECKOWNERARGS "name, rdclass, type, wildcard"
93 #define CHECKOWNERCLASS "rdclass"
94 #define CHECKOWNERTYPE "type"
95 #define CHECKOWNERDEF "result = ISC_TRUE"
97 #define CHECKNAMESARGS "rdata, owner, bad"
98 #define CHECKNAMESCLASS "rdata->rdclass"
99 #define CHECKNAMESTYPE "rdata->type"
100 #define CHECKNAMESDEF "result = ISC_TRUE"
102 const char copyright[] =
104 " * Copyright (C) 2004%s Internet Systems Consortium, Inc. (\"ISC\")\n"
105 " * Copyright (C) 1998-2003 Internet Software Consortium.\n"
107 " * Permission to use, copy, modify, and distribute this software for any\n"
108 " * purpose with or without fee is hereby granted, provided that the above\n"
109 " * copyright notice and this permission notice appear in all copies.\n"
111 " * THE SOFTWARE IS PROVIDED \"AS IS\" AND ISC DISCLAIMS ALL WARRANTIES WITH\n"
112 " * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\n"
113 " * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,\n"
114 " * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\n"
115 " * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE\n"
116 " * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\n"
117 " * PERFORMANCE OF THIS SOFTWARE.\n"
122 " *************** THIS FILE IS AUTOMATICALLY GENERATED BY gen.c.\n"
123 " *************** DO NOT EDIT!\n"
125 " ***************/\n"
128 #define TYPENAMES 256
142 char dirname[256]; /* XXX Should be max path length */
151 } typenames[TYPENAMES];
158 funname(const char *, char *);
160 doswitch(const char *, const char *, const char *, const char *,
161 const char *, const char *);
163 dodecl(char *, char *, char *);
165 add(int, const char *, int, const char *, const char *);
167 sd(int, const char *, const char *, char);
169 insert_into_typenames(int, const char *, const char *);
172 * If you use more than 10 of these in, say, a printf(), you'll have problems.
176 static int buf_to_use = 0;
177 static char buf[10][256];
188 while ((c = (*s++) & 0xff))
189 *b++ = islower(c) ? toupper(c) : c;
191 return (buf[buf_to_use]);
195 funname(const char *s, char *buf) {
200 *b++ = (c == '-') ? '_' : c;
207 doswitch(const char *name, const char *function, const char *args,
208 const char *tsw, const char *csw, const char *res)
214 char buf1[11], buf2[11];
215 const char *result = " result =";
220 for (tt = types; tt != NULL; tt = tt->next) {
222 fprintf(stdout, "\n#define %s \\\n", name);
223 fprintf(stdout, "\tswitch (%s) { \\\n" /*}*/, tsw);
226 if (tt->type != lasttype && subswitch) {
228 fprintf(stdout, "\t\tdefault: break; \\\n");
231 "\t\tdefault: %s; break; \\\n", res);
232 fputs(/*{*/ "\t\t} \\\n", stdout);
233 fputs("\t\tbreak; \\\n", stdout);
236 if (tt->rdclass && tt->type != lasttype) {
237 fprintf(stdout, "\tcase %d: switch (%s) { \\\n" /*}*/,
241 if (tt->rdclass == 0)
243 "\tcase %d:%s %s_%s(%s); break;",
244 tt->type, result, function,
245 funname(tt->typename, buf1), args);
248 "\t\tcase %d:%s %s_%s_%s(%s); break;",
249 tt->rdclass, result, function,
250 funname(tt->classname, buf1),
251 funname(tt->typename, buf2), args);
252 fputs(" \\\n", stdout);
257 fprintf(stdout, "\t\tdefault: break; \\\n");
259 fprintf(stdout, "\t\tdefault: %s; break; \\\n", res);
260 fputs(/*{*/ "\t\t} \\\n", stdout);
261 fputs("\t\tbreak; \\\n", stdout);
265 fprintf(stdout, "\n#define %s\n", name);
267 fprintf(stdout, "\n#define %s %s;\n", name, res);
270 fprintf(stdout, "\tdefault: break; \\\n");
272 fprintf(stdout, "\tdefault: %s; break; \\\n", res);
273 fputs(/*{*/ "\t}\n", stdout);
278 dodecl(char *type, char *function, char *args) {
280 char buf1[11], buf2[11];
283 for (tt = types; tt; tt = tt->next)
286 "static inline %s %s_%s_%s(%s);\n",
288 funname(tt->classname, buf1),
289 funname(tt->typename, buf2), args);
292 "static inline %s %s_%s(%s);\n",
294 funname(tt->typename, buf1), args);
297 static struct ttnam *
298 find_typename(int type) {
301 for (i = 0; i < TYPENAMES; i++) {
302 if (typenames[i].typename[0] != 0 &&
303 typenames[i].type == type)
304 return (&typenames[i]);
310 insert_into_typenames(int type, const char *typename, const char *attr) {
311 struct ttnam *ttn = NULL;
315 for (i = 0; i < TYPENAMES; i++) {
316 if (typenames[i].typename[0] != 0 &&
317 typenames[i].type == type &&
318 strcmp(typename, typenames[i].typename) != 0) {
320 "Error: type %d has two names: %s, %s\n",
321 type, typenames[i].typename, typename);
324 if (typenames[i].typename[0] == 0 && ttn == NULL)
328 fprintf(stderr, "Error: typenames array too small\n");
332 if (strlen(typename) > sizeof(ttn->typename) - 1) {
333 fprintf(stderr, "Error: type name %s is too long\n",
337 strcpy(ttn->typename, typename);
340 strcpy(ttn->macroname, ttn->typename);
341 c = strlen(ttn->macroname);
343 if (ttn->macroname[c - 1] == '-')
344 ttn->macroname[c - 1] = '_';
349 sprintf(tmp, "RRTYPE_%s_ATTRIBUTES", upper(ttn->macroname));
353 if (ttn->attr[0] != 0 && strcmp(attr, ttn->attr) != 0) {
354 fprintf(stderr, "Error: type %d has different attributes: "
355 "%s, %s\n", type, ttn->attr, attr);
359 if (strlen(attr) > sizeof(ttn->attr) - 1) {
360 fprintf(stderr, "Error: attr (%s) [name %s] is too long\n",
364 strcpy(ttn->attr, attr);
371 add(int rdclass, const char *classname, int type, const char *typename,
374 struct tt *newtt = (struct tt *)malloc(sizeof(*newtt));
375 struct tt *tt, *oldtt;
377 struct cc *cc, *oldcc;
379 insert_into_typenames(type, typename, NULL);
382 fprintf(stderr, "malloc() failed\n");
387 newtt->rdclass = rdclass;
389 strcpy(newtt->classname, classname);
390 strcpy(newtt->typename, typename);
391 strcpy(newtt->dirname, dirname);
396 while ((tt != NULL) && (tt->type < type)) {
401 while ((tt != NULL) && (tt->type == type) && (tt->rdclass < rdclass)) {
402 if (strcmp(tt->typename, typename) != 0)
408 if ((tt != NULL) && (tt->type == type) && (tt->rdclass == rdclass))
418 * Do a class switch for this type.
423 newcc = (struct cc *)malloc(sizeof(*newcc));
424 newcc->rdclass = rdclass;
425 strcpy(newcc->classname, classname);
429 while ((cc != NULL) && (cc->rdclass < rdclass)) {
434 if ((cc != NULL) && cc->rdclass == rdclass) {
447 sd(int rdclass, const char *classname, const char *dirname, char filetype) {
448 char buf[sizeof("0123456789_65535.h")];
449 char fmt[sizeof("%10[-0-9a-z]_%d.h")];
454 if (!start_directory(dirname, &dir))
457 sprintf(fmt,"%s%c", "%10[-0-9a-z]_%d.", filetype);
458 while (next_file(&dir)) {
459 if (sscanf(dir.filename, fmt, typename, &type) != 2)
461 if ((type > 65535) || (type < 0))
464 sprintf(buf, "%s_%d.%c", typename, type, filetype);
465 if (strcmp(buf, dir.filename) != 0)
467 add(rdclass, classname, type, typename, dirname);
480 fprintf(stderr, "n == 0?\n");
483 a = tolower((unsigned char)string[0]);
484 b = tolower((unsigned char)string[n - 1]);
486 return ((a + n) * b) % 256;
490 main(int argc, char **argv) {
491 char buf[256]; /* XXX Should be max path length */
492 char srcdir[256]; /* XXX Should be max path length */
497 struct ttnam *ttn, *ttn2;
517 for (i = 0; i < TYPENAMES; i++)
518 memset(&typenames[i], 0, sizeof(typenames[i]));
521 while ((c = isc_commandline_parse(argc, argv, "cdits:F:P:S:")) != -1)
556 sprintf(srcdir, "%s/", isc_commandline_argument);
559 file = isc_commandline_argument;
562 prefix = isc_commandline_argument;
565 suffix = isc_commandline_argument;
571 sprintf(buf, "%srdata", srcdir);
573 if (!start_directory(buf, &dir))
576 while (next_file(&dir)) {
577 if (sscanf(dir.filename, "%10[0-9a-z]_%d",
578 classname, &rdclass) != 2)
580 if ((rdclass > 65535) || (rdclass < 0))
583 sprintf(buf, "%srdata/%s_%d", srcdir, classname, rdclass);
584 if (strcmp(buf + 6 + strlen(srcdir), dir.filename) != 0)
586 sd(rdclass, classname, buf, filetype);
589 sprintf(buf, "%srdata/generic", srcdir);
590 sd(0, "", buf, filetype);
592 if (time(&now) != -1) {
593 if ((tm = localtime(&now)) != NULL && tm->tm_year > 104)
594 sprintf(year, "-%d", tm->tm_year + 1900);
600 if (!depend) fprintf(stdout, copyright, year);
603 fputs("#ifndef DNS_CODE_H\n", stdout);
604 fputs("#define DNS_CODE_H 1\n\n", stdout);
606 fputs("#include <isc/boolean.h>\n", stdout);
607 fputs("#include <isc/result.h>\n\n", stdout);
608 fputs("#include <dns/name.h>\n\n", stdout);
610 for (tt = types; tt != NULL; tt = tt->next)
611 fprintf(stdout, "#include \"%s/%s_%d.c\"\n",
612 tt->dirname, tt->typename, tt->type);
614 fputs("\n\n", stdout);
616 doswitch("FROMTEXTSWITCH", "fromtext", FROMTEXTARGS,
617 FROMTEXTTYPE, FROMTEXTCLASS, FROMTEXTDEF);
618 doswitch("TOTEXTSWITCH", "totext", TOTEXTARGS,
619 TOTEXTTYPE, TOTEXTCLASS, TOTEXTDEF);
620 doswitch("FROMWIRESWITCH", "fromwire", FROMWIREARGS,
621 FROMWIRETYPE, FROMWIRECLASS, FROMWIREDEF);
622 doswitch("TOWIRESWITCH", "towire", TOWIREARGS,
623 TOWIRETYPE, TOWIRECLASS, TOWIREDEF);
624 doswitch("COMPARESWITCH", "compare", COMPAREARGS,
625 COMPARETYPE, COMPARECLASS, COMPAREDEF);
626 doswitch("FROMSTRUCTSWITCH", "fromstruct", FROMSTRUCTARGS,
627 FROMSTRUCTTYPE, FROMSTRUCTCLASS, FROMSTRUCTDEF);
628 doswitch("TOSTRUCTSWITCH", "tostruct", TOSTRUCTARGS,
629 TOSTRUCTTYPE, TOSTRUCTCLASS, TOSTRUCTDEF);
630 doswitch("FREESTRUCTSWITCH", "freestruct", FREESTRUCTARGS,
631 FREESTRUCTTYPE, FREESTRUCTCLASS, FREESTRUCTDEF);
632 doswitch("ADDITIONALDATASWITCH", "additionaldata",
633 ADDITIONALDATAARGS, ADDITIONALDATATYPE,
634 ADDITIONALDATACLASS, ADDITIONALDATADEF);
635 doswitch("DIGESTSWITCH", "digest",
636 DIGESTARGS, DIGESTTYPE,
637 DIGESTCLASS, DIGESTDEF);
638 doswitch("CHECKOWNERSWITCH", "checkowner",
639 CHECKOWNERARGS, CHECKOWNERTYPE,
640 CHECKOWNERCLASS, CHECKOWNERDEF);
641 doswitch("CHECKNAMESSWITCH", "checknames",
642 CHECKNAMESARGS, CHECKNAMESTYPE,
643 CHECKNAMESCLASS, CHECKNAMESDEF);
646 * From here down, we are processing the rdata names and
650 #define PRINT_COMMA(x) (x == maxtype ? "" : ",")
652 #define METANOTQUESTION "DNS_RDATATYPEATTR_META | " \
653 "DNS_RDATATYPEATTR_NOTQUESTION"
654 #define METAQUESTIONONLY "DNS_RDATATYPEATTR_META | " \
655 "DNS_RDATATYPEATTR_QUESTIONONLY"
656 #define RESERVED "DNS_RDATATYPEATTR_RESERVED"
659 * Add in reserved/special types. This will let us
660 * sort them without special cases.
662 insert_into_typenames(0, "reserved0", RESERVED);
663 insert_into_typenames(31, "eid", RESERVED);
664 insert_into_typenames(32, "nimloc", RESERVED);
665 insert_into_typenames(34, "atma", RESERVED);
666 insert_into_typenames(100, "uinfo", RESERVED);
667 insert_into_typenames(101, "uid", RESERVED);
668 insert_into_typenames(102, "gid", RESERVED);
669 insert_into_typenames(251, "ixfr", METAQUESTIONONLY);
670 insert_into_typenames(252, "axfr", METAQUESTIONONLY);
671 insert_into_typenames(253, "mailb", METAQUESTIONONLY);
672 insert_into_typenames(254, "maila", METAQUESTIONONLY);
673 insert_into_typenames(255, "any", METAQUESTIONONLY);
676 * Spit out a quick and dirty hash function. Here,
677 * we walk through the list of type names, and calculate
678 * a hash. This isn't perfect, but it will generate "pretty
679 * good" estimates. Lowercase the characters before
680 * computing in all cases.
682 * Here, walk the list from top to bottom, calculating
683 * the hash (mod 256) for each name.
685 fprintf(stdout, "#define RDATATYPE_COMPARE(_s, _d, _tn, _n, _tp) \\\n");
686 fprintf(stdout, "\tdo { \\\n");
687 fprintf(stdout, "\t\tif (sizeof(_s) - 1 == _n && \\\n"
688 "\t\t strncasecmp(_s,(_tn),"
689 "(sizeof(_s) - 1)) == 0) { \\\n");
690 fprintf(stdout, "\t\t\tif ((dns_rdatatype_attributes(_d) & "
691 "DNS_RDATATYPEATTR_RESERVED) != 0) \\\n");
692 fprintf(stdout, "\t\t\t\treturn (ISC_R_NOTIMPLEMENTED); \\\n");
693 fprintf(stdout, "\t\t\t*(_tp) = _d; \\\n");
694 fprintf(stdout, "\t\t\treturn (ISC_R_SUCCESS); \\\n");
695 fprintf(stdout, "\t\t} \\\n");
696 fprintf(stdout, "\t} while (0)\n\n");
698 fprintf(stdout, "#define RDATATYPE_FROMTEXT_SW(_hash,"
699 "_typename,_length,_typep) \\\n");
700 fprintf(stdout, "\tswitch (_hash) { \\\n");
701 for (i = 0; i <= maxtype; i++) {
702 ttn = find_typename(i);
707 * Skip entries we already processed.
709 if (ttn->sorted != 0)
712 hash = HASH(ttn->typename);
713 fprintf(stdout, "\t\tcase %u: \\\n", hash);
716 * Find all other entries that happen to match
719 for (j = 0; j <= maxtype; j++) {
720 ttn2 = find_typename(j);
723 if (hash == HASH(ttn2->typename)) {
724 fprintf(stdout, "\t\t\tRDATATYPE_COMPARE"
726 "_typename, _length, _typep); \\\n",
727 ttn2->typename, ttn2->type);
731 fprintf(stdout, "\t\t\tbreak; \\\n");
733 fprintf(stdout, "\t}\n");
735 fprintf(stdout, "#define RDATATYPE_ATTRIBUTE_SW \\\n");
736 fprintf(stdout, "\tswitch (type) { \\\n");
737 for (i = 0; i <= maxtype; i++) {
738 ttn = find_typename(i);
741 fprintf(stdout, "\tcase %u: return (%s); \\\n",
742 i, upper(ttn->attr));
744 fprintf(stdout, "\t}\n");
746 fprintf(stdout, "#define RDATATYPE_TOTEXT_SW \\\n");
747 fprintf(stdout, "\tswitch (type) { \\\n");
748 for (i = 0; i <= maxtype; i++) {
749 ttn = find_typename(i);
752 fprintf(stdout, "\tcase %u: return "
753 "(str_totext(\"%s\", target)); \\\n",
754 i, upper(ttn->typename));
756 fprintf(stdout, "\t}\n");
758 fputs("#endif /* DNS_CODE_H */\n", stdout);
759 } else if (type_enum) {
762 fprintf(stdout, "#ifndef DNS_ENUMTYPE_H\n");
763 fprintf(stdout, "#define DNS_ENUMTYPE_H 1\n\n");
765 fprintf(stdout, "enum {\n");
766 fprintf(stdout, "\tdns_rdatatype_none = 0,\n");
769 for (tt = types; tt != NULL; tt = tt->next)
770 if (tt->type != lasttype)
772 "\tdns_rdatatype_%s = %d,\n",
773 funname(tt->typename, buf1),
774 lasttype = tt->type);
776 fprintf(stdout, "\tdns_rdatatype_ixfr = 251,\n");
777 fprintf(stdout, "\tdns_rdatatype_axfr = 252,\n");
778 fprintf(stdout, "\tdns_rdatatype_mailb = 253,\n");
779 fprintf(stdout, "\tdns_rdatatype_maila = 254,\n");
780 fprintf(stdout, "\tdns_rdatatype_any = 255\n");
782 fprintf(stdout, "};\n\n");
784 fprintf(stdout, "#define dns_rdatatype_none\t"
785 "((dns_rdatatype_t)dns_rdatatype_none)\n");
787 for (tt = types; tt != NULL; tt = tt->next)
788 if (tt->type != lasttype) {
789 s = funname(tt->typename, buf1);
791 "#define dns_rdatatype_%s\t%s"
792 "((dns_rdatatype_t)dns_rdatatype_%s)"
794 s, strlen(s) < 2U ? "\t" : "", s);
798 fprintf(stdout, "#define dns_rdatatype_ixfr\t"
799 "((dns_rdatatype_t)dns_rdatatype_ixfr)\n");
800 fprintf(stdout, "#define dns_rdatatype_axfr\t"
801 "((dns_rdatatype_t)dns_rdatatype_axfr)\n");
802 fprintf(stdout, "#define dns_rdatatype_mailb\t"
803 "((dns_rdatatype_t)dns_rdatatype_mailb)\n");
804 fprintf(stdout, "#define dns_rdatatype_maila\t"
805 "((dns_rdatatype_t)dns_rdatatype_maila)\n");
806 fprintf(stdout, "#define dns_rdatatype_any\t"
807 "((dns_rdatatype_t)dns_rdatatype_any)\n");
809 fprintf(stdout, "\n#endif /* DNS_ENUMTYPE_H */\n");
811 } else if (class_enum) {
815 fprintf(stdout, "#ifndef DNS_ENUMCLASS_H\n");
816 fprintf(stdout, "#define DNS_ENUMCLASS_H 1\n\n");
818 fprintf(stdout, "enum {\n");
820 fprintf(stdout, "\tdns_rdataclass_reserved0 = 0,\n");
821 fprintf(stdout, "#define dns_rdataclass_reserved0 \\\n\t\t\t\t"
822 "((dns_rdataclass_t)dns_rdataclass_reserved0)\n");
824 #define PRINTCLASS(name, num) \
826 s = funname(name, buf1); \
828 fprintf(stdout, "\tdns_rdataclass_%s = %d%s\n", s, classnum, \
829 classnum != 255 ? "," : ""); \
830 fprintf(stdout, "#define dns_rdataclass_%s\t" \
831 "((dns_rdataclass_t)dns_rdataclass_%s)\n", s, s); \
834 for (cc = classes; cc != NULL; cc = cc->next) {
835 if (cc->rdclass == 4) {
837 PRINTCLASS("chaos", 3);
839 } else if (cc->rdclass == 255) {
840 PRINTCLASS("none", 254);
842 PRINTCLASS(cc->classname, cc->rdclass);
847 fprintf(stdout, "};\n\n");
848 fprintf(stdout, "#endif /* DNS_ENUMCLASS_H */\n");
849 } else if (structs) {
850 if (prefix != NULL) {
851 if ((fd = fopen(prefix,"r")) != NULL) {
852 while (fgets(buf, sizeof(buf), fd) != NULL)
857 for (tt = types; tt != NULL; tt = tt->next) {
858 sprintf(buf, "%s/%s_%d.h",
859 tt->dirname, tt->typename, tt->type);
860 if ((fd = fopen(buf,"r")) != NULL) {
861 while (fgets(buf, sizeof(buf), fd) != NULL)
866 if (suffix != NULL) {
867 if ((fd = fopen(suffix,"r")) != NULL) {
868 while (fgets(buf, sizeof(buf), fd) != NULL)
874 for (tt = types; tt != NULL; tt = tt->next)
875 fprintf(stdout, "%s:\t%s/%s_%d.h\n", file,
876 tt->dirname, tt->typename, tt->type);
879 if (ferror(stdout) != 0)