Annotation of src/external/mpl/bind/dist/lib/dns/gen-unix.h, Revision 1.2
1.2 ! christos 1: /* $NetBSD: gen-unix.h,v 1.1.1.6 2014/12/10 03:34:39 christos Exp $ */
1.1 christos 2:
3: /*
4: * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5: *
6: * This Source Code Form is subject to the terms of the Mozilla Public
7: * License, v. 2.0. If a copy of the MPL was not distributed with this
8: * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9: *
10: * See the COPYRIGHT file distributed with this work for additional
11: * information regarding copyright ownership.
12: */
13:
14:
15: /*! \file
16: * \brief
17: * This file is responsible for defining two operations that are not
18: * directly portable between Unix-like systems and Windows NT, option
19: * parsing and directory scanning. It is here because it was decided
20: * that the "gen" build utility was not to depend on libisc.a, so
21: * the functions declared in isc/commandline.h and isc/dir.h could not
22: * be used.
23: *
24: * The commandline stuff is really just a wrapper around getopt().
25: * The dir stuff was shrunk to fit the needs of gen.c.
26: */
27:
28: #ifndef DNS_GEN_UNIX_H
29: #define DNS_GEN_UNIX_H 1
30:
31: #include <sys/types.h> /* Required on some systems for dirent.h. */
32:
33: #include <dirent.h>
34: #include <unistd.h> /* XXXDCL Required for ?. */
35:
36: #include <isc/boolean.h>
37: #include <isc/lang.h>
38:
39: #ifdef NEED_OPTARG
40: extern char *optarg;
41: #endif
42:
43: #define isc_commandline_parse getopt
44: #define isc_commandline_argument optarg
45:
46: typedef struct {
47: DIR *handle;
48: char *filename;
49: } isc_dir_t;
50:
51: ISC_LANG_BEGINDECLS
52:
53: static isc_boolean_t
54: start_directory(const char *path, isc_dir_t *dir) {
55: dir->handle = opendir(path);
56:
57: if (dir->handle != NULL)
58: return (ISC_TRUE);
59: else
60: return (ISC_FALSE);
61:
62: }
63:
64: static isc_boolean_t
65: next_file(isc_dir_t *dir) {
66: struct dirent *dirent;
67:
68: dir->filename = NULL;
69:
70: if (dir->handle != NULL) {
71: dirent = readdir(dir->handle);
72: if (dirent != NULL)
73: dir->filename = dirent->d_name;
74: }
75:
76: if (dir->filename != NULL)
77: return (ISC_TRUE);
78: else
79: return (ISC_FALSE);
80: }
81:
82: static void
83: end_directory(isc_dir_t *dir) {
84: if (dir->handle != NULL)
85: (void)closedir(dir->handle);
86:
87: dir->handle = NULL;
88: }
89:
90: ISC_LANG_ENDDECLS
91:
92: #endif /* DNS_GEN_UNIX_H */
CVSweb <webmaster@jp.NetBSD.org>