Add BIND 9.2.4rc7.
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / isc / unix / include / isc / dir.h
blob48117448c547b3675b6cedccb999436bbd7f376c
1 /*
2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 1999-2001 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: dir.h,v 1.15.2.1 2004/03/09 06:12:13 marka Exp $ */
20 /* Principal Authors: DCL */
22 #ifndef ISC_DIR_H
23 #define ISC_DIR_H 1
25 #include <sys/types.h> /* Required on some systems. */
26 #include <dirent.h>
28 #include <isc/lang.h>
29 #include <isc/result.h>
31 #define ISC_DIR_NAMEMAX 256
32 #define ISC_DIR_PATHMAX 1024
34 typedef struct isc_direntry {
36 * Ideally, this should be NAME_MAX, but AIX does not define it by
37 * default and dynamically allocating the space based on pathconf()
38 * complicates things undesirably, as does adding special conditionals
39 * just for AIX. So a comfortably sized buffer is chosen instead.
41 char name[ISC_DIR_NAMEMAX];
42 unsigned int length;
43 } isc_direntry_t;
45 typedef struct isc_dir {
46 unsigned int magic;
48 * As with isc_direntry_t->name, making this "right" for all systems
49 * is slightly problematic because AIX does not define PATH_MAX.
51 char dirname[ISC_DIR_PATHMAX];
52 isc_direntry_t entry;
53 DIR * handle;
54 } isc_dir_t;
56 ISC_LANG_BEGINDECLS
58 void
59 isc_dir_init(isc_dir_t *dir);
61 isc_result_t
62 isc_dir_open(isc_dir_t *dir, const char *dirname);
64 isc_result_t
65 isc_dir_read(isc_dir_t *dir);
67 isc_result_t
68 isc_dir_reset(isc_dir_t *dir);
70 void
71 isc_dir_close(isc_dir_t *dir);
73 isc_result_t
74 isc_dir_chdir(const char *dirname);
76 isc_result_t
77 isc_dir_chroot(const char *dirname);
79 isc_result_t
80 isc_dir_current(char *dirname, size_t length, isc_boolean_t end_sep);
82 * Put the absolute name of the current directory into 'dirname', which is a
83 * buffer of at least 'length' characters. If 'end_sep' is true, end the
84 * string with the appropriate path separator, such that the final product
85 * could be concatenated with a relative pathname to make a valid pathname
86 * string.
89 isc_result_t
90 isc_dir_createunique(char *templet);
92 * Use a templet (such as from isc_file_mktemplate()) to create a uniquely
93 * named, empty directory. The templet string is modified in place.
94 * If result == ISC_R_SUCCESS, it is the name of the directory that was
95 * created.
98 ISC_LANG_ENDDECLS
100 #endif /* ISC_DIR_H */