2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 21:47:59 +00:00

revert to 1.25 (unix only)

This commit is contained in:
Bob Halley 1999-10-07 02:55:00 +00:00
parent 83e8c58817
commit c44989e64a

View File

@ -15,22 +15,21 @@
* SOFTWARE. * SOFTWARE.
*/ */
/* $Id: gen.c,v 1.26 1999/10/06 19:55:29 tale Exp $ */ /* $Id: gen.c,v 1.27 1999/10/07 02:55:00 halley Exp $ */
#include <config.h> #include <config.h>
#include <sys/types.h> #include <sys/types.h>
#include <ctype.h> #include <ctype.h>
#include <dirent.h>
#include <malloc.h> #include <malloc.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <time.h> #include <time.h>
#include <unistd.h>
#include <isc/commandline.h>
#include <isc/dir.h>
#include <isc/result.h>
#define FROMTEXTDECL "dns_rdataclass_t rdclass, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target" #define FROMTEXTDECL "dns_rdataclass_t rdclass, dns_rdatatype_t type, isc_lex_t *lexer, dns_name_t *origin, isc_boolean_t downcase, isc_buffer_t *target"
#define FROMTEXTARGS "rdclass, type, lexer, origin, downcase, target" #define FROMTEXTARGS "rdclass, type, lexer, origin, downcase, target"
@ -324,41 +323,40 @@ add(int rdclass, char *classname, int type, char *typename, char *dirname) {
} }
void void
sd(int rdclass, char *classname, char *dirname, char filetype) { sd(int rdclass, char *classname, char *dir, char filetype) {
char buf[sizeof "0123456789_65535.h"]; char buf[sizeof "0123456789_65535.h"];
char fmt[sizeof "%10[-0-9a-z]_%d.h"]; char fmt[sizeof "%10[-0-9a-z]_%d.h"];
DIR *d;
int type; int type;
char typename[11]; char typename[11];
isc_dir_t dir; struct dirent *dp;
isc_dir_init(&dir); if ((d = opendir(dir)) == NULL)
if (isc_dir_open(dirname, &dir) != ISC_R_SUCCESS)
return; return;
sprintf(fmt,"%s%c", "%10[-0-9a-z]_%d.", filetype); sprintf(fmt,"%s%c", "%10[-0-9a-z]_%d.", filetype);
while ((dp = readdir(d)) != NULL) {
while (isc_dir_read(&dir) == ISC_R_SUCCESS) { if (sscanf(dp->d_name, fmt, typename, &type) != 2)
if (sscanf(dir.entry.name, fmt, typename, &type) != 2)
continue; continue;
if ((type > 65535) || (type < 0)) if ((type > 65535) || (type < 0))
continue; continue;
sprintf(buf, "%s_%d.%c", typename, type, filetype); sprintf(buf, "%s_%d.%c", typename, type, filetype);
if (strcmp(buf, dir.entry.name) != 0) if (strcmp(buf, dp->d_name) != 0)
continue; continue;
add(rdclass, classname, type, typename, dirname); add(rdclass, classname, type, typename, dir);
} }
closedir(d);
isc_dir_close(&dir);
} }
int int
main(int argc, char **argv) { main(int argc, char **argv) {
DIR *d;
char buf[256]; /* XXX Should be max path length */ char buf[256]; /* XXX Should be max path length */
char srcdir[256]; /* XXX Should be max path length */ char srcdir[256]; /* XXX Should be max path length */
isc_dir_t dir;
int rdclass; int rdclass;
char classname[11]; char classname[11];
struct dirent *dp;
struct tt *tt; struct tt *tt;
struct cc *cc; struct cc *cc;
struct tm *tm; struct tm *tm;
@ -377,7 +375,7 @@ main(int argc, char **argv) {
char *suffix = NULL; char *suffix = NULL;
strcpy(srcdir, ""); strcpy(srcdir, "");
while ((c = isc_commandline_parse(argc, argv, "cits:P:S:")) != -1) while ((c = getopt(argc, argv, "cits:P:S:")) != -1)
switch (c) { switch (c) {
case 'c': case 'c':
code = 0; code = 0;
@ -401,41 +399,35 @@ main(int argc, char **argv) {
filetype = 'h'; filetype = 'h';
break; break;
case 's': case 's':
snprintf(srcdir, sizeof(srcdir), "%s/", sprintf(srcdir, "%s/", optarg);
isc_commandline_argument);
break; break;
case 'P': case 'P':
prefix = isc_commandline_argument; prefix = optarg;
break; break;
case 'S': case 'S':
suffix = isc_commandline_argument; suffix = optarg;
break; break;
case '?': case '?':
exit(1); exit(1);
} }
sprintf(buf, "%srdata", srcdir); sprintf(buf, "%srdata", srcdir);
if ((d = opendir(buf)) == NULL)
isc_dir_init(&dir);
if (isc_dir_open(buf, &dir) != ISC_R_SUCCESS)
exit(1); exit(1);
while (isc_dir_read(&dir) == ISC_R_SUCCESS) { while ((dp = readdir(d)) != NULL) {
if (sscanf(dir.entry.name, "%10[0-9a-z]_%d", if (sscanf(dp->d_name, "%10[0-9a-z]_%d",
classname, &rdclass) != 2) classname, &rdclass) != 2)
continue; continue;
if ((rdclass > 65535) || (rdclass < 0)) if ((rdclass > 65535) || (rdclass < 0))
continue; continue;
sprintf(buf, "%srdata/%s_%d", srcdir, classname, rdclass); sprintf(buf, "%srdata/%s_%d", srcdir, classname, rdclass);
if (strcmp(buf + 6 + strlen(srcdir), dir.entry.name) != 0) if (strcmp(buf + 6 + strlen(srcdir), dp->d_name) != 0)
continue; continue;
sd(rdclass, classname, buf, filetype); sd(rdclass, classname, buf, filetype);
} }
closedir(d);
isc_dir_close(&dir);
sprintf(buf, "%srdata/generic", srcdir); sprintf(buf, "%srdata/generic", srcdir);
sd(0, "", buf, filetype); sd(0, "", buf, filetype);