$(nodist_libdns_la_SOURCES) \
gen$(BUILD_EXEEXT)
-gen$(BUILD_EXEEXT): gen.c gen.h
- $(CC_FOR_BUILD) -g -I. $(GEN_NEED_OPTARG) $(srcdir)/gen.c -o $@
+gen$(BUILD_EXEEXT): gen.c
+ $(CC_FOR_BUILD) -g -I. $(srcdir)/gen.c -o $@
EXTRA_DIST = \
dnstap.proto \
gen.c \
- gen.h \
rdata/*
include/dns/enumtype.h: gen Makefile
/*! \file */
#include <ctype.h>
+#include <dirent.h>
#include <errno.h>
#include <limits.h>
+#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
+#include <unistd.h>
#ifndef PATH_MAX
#define PATH_MAX 1024
#endif /* ifndef PATH_MAX */
-#include "gen.h"
-
#ifndef ULLONG_MAX
#define ULLONG_MAX (~0ULL)
#endif /* ifndef ULLONG_MAX */
static int maxtype = -1;
+typedef struct {
+ DIR *handle;
+ char *filename;
+} isc_dir_t;
+
static char *
upper(char *);
static char *
static void
insert_into_typenames(int, const char *, const char *);
+static bool
+start_directory(const char *path, isc_dir_t *dir) {
+ dir->handle = opendir(path);
+
+ if (dir->handle != NULL) {
+ return (true);
+ } else {
+ return (false);
+ }
+}
+
+static bool
+next_file(isc_dir_t *dir) {
+ struct dirent *dirent;
+
+ dir->filename = NULL;
+
+ if (dir->handle != NULL) {
+ errno = 0;
+ dirent = readdir(dir->handle);
+ if (dirent != NULL) {
+ dir->filename = dirent->d_name;
+ } else {
+ if (errno != 0) {
+ fprintf(stderr,
+ "Error: reading directory: %s\n",
+ strerror(errno));
+ exit(1);
+ }
+ }
+ }
+
+ if (dir->filename != NULL) {
+ return (true);
+ } else {
+ return (false);
+ }
+}
+
+static void
+end_directory(isc_dir_t *dir) {
+ if (dir->handle != NULL) {
+ (void)closedir(dir->handle);
+ }
+
+ dir->handle = NULL;
+}
+
/*%
* If you use more than 10 of these in, say, a printf(), you'll have problems.
*/
}
srcdir[0] = '\0';
- while ((c = isc_commandline_parse(argc, argv, "cdits:F:P:S:")) != -1) {
+ while ((c = getopt(argc, argv, "cdits:F:P:S:")) != -1) {
switch (c) {
case 'c':
code = 0;
filetype = 'h';
break;
case 's':
- if (strlen(isc_commandline_argument) >
+ if (strlen(optarg) >
PATH_MAX - 2 * TYPECLASSLEN -
sizeof("/rdata/_65535_65535"))
{
- fprintf(stderr, "\"%s\" too long\n",
- isc_commandline_argument);
+ fprintf(stderr, "\"%s\" too long\n", optarg);
exit(1);
}
- n = snprintf(srcdir, sizeof(srcdir), "%s/",
- isc_commandline_argument);
+ n = snprintf(srcdir, sizeof(srcdir), "%s/", optarg);
INSIST(n > 0 && (unsigned)n < sizeof(srcdir));
break;
case 'F':
- file = isc_commandline_argument;
+ file = optarg;
break;
case 'P':
- prefix = isc_commandline_argument;
+ prefix = optarg;
break;
case 'S':
- suffix = isc_commandline_argument;
+ suffix = optarg;
break;
case '?':
exit(1);
+++ /dev/null
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * SPDX-License-Identifier: MPL-2.0
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-/*! \file
- * \brief
- * This file is responsible for defining two operations that are not
- * directly portable between Unix-like systems and Windows NT, option
- * parsing and directory scanning. It is here because it was decided
- * that the "gen" build utility was not to depend on libisc.a, so
- * the functions declared in isc/commandline.h and isc/dir.h could not
- * be used.
- *
- * The commandline stuff is really just a wrapper around getopt().
- * The dir stuff was shrunk to fit the needs of gen.c.
- */
-
-#pragma once
-
-#include <dirent.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <sys/types.h> /* Required on some systems for dirent.h. */
-#include <unistd.h> /* XXXDCL Required for ?. */
-
-#ifdef __cplusplus
-#define ISC_LANG_BEGINDECLS extern "C" {
-#define ISC_LANG_ENDDECLS }
-#else /* ifdef __cplusplus */
-#define ISC_LANG_BEGINDECLS
-#define ISC_LANG_ENDDECLS
-#endif /* ifdef __cplusplus */
-
-#ifdef NEED_OPTARG
-extern char *optarg;
-#endif /* ifdef NEED_OPTARG */
-
-#define isc_commandline_parse getopt
-#define isc_commandline_argument optarg
-
-typedef struct {
- DIR *handle;
- char *filename;
-} isc_dir_t;
-
-ISC_LANG_BEGINDECLS
-
-static bool
-start_directory(const char *path, isc_dir_t *dir) {
- dir->handle = opendir(path);
-
- if (dir->handle != NULL) {
- return (true);
- } else {
- return (false);
- }
-}
-
-static bool
-next_file(isc_dir_t *dir) {
- struct dirent *dirent;
-
- dir->filename = NULL;
-
- if (dir->handle != NULL) {
- errno = 0;
- dirent = readdir(dir->handle);
- if (dirent != NULL) {
- dir->filename = dirent->d_name;
- } else {
- if (errno != 0) {
- exit(1);
- }
- }
- }
-
- if (dir->filename != NULL) {
- return (true);
- } else {
- return (false);
- }
-}
-
-static void
-end_directory(isc_dir_t *dir) {
- if (dir->handle != NULL) {
- (void)closedir(dir->handle);
- }
-
- dir->handle = NULL;
-}
-
-ISC_LANG_ENDDECLS