xref: /netbsd-src/external/mpl/dhcp/bind/dist/lib/isc/unix/include/isc/dir.h (revision 4afad4b7fa6d4a0d3dedf41d1587a7250710ae54)
1 /*	$NetBSD: dir.h,v 1.1 2024/02/18 20:57:57 christos Exp $	*/
2 
3 /*
4  * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
5  *
6  * SPDX-License-Identifier: MPL-2.0
7  *
8  * This Source Code Form is subject to the terms of the Mozilla Public
9  * License, v. 2.0. If a copy of the MPL was not distributed with this
10  * file, you can obtain one at https://mozilla.org/MPL/2.0/.
11  *
12  * See the COPYRIGHT file distributed with this work for additional
13  * information regarding copyright ownership.
14  */
15 
16 #ifndef ISC_DIR_H
17 #define ISC_DIR_H 1
18 
19 /*! \file */
20 
21 #include <dirent.h>
22 
23 #include <isc/lang.h>
24 #include <isc/platform.h>
25 #include <isc/result.h>
26 
27 #include <sys/types.h> /* Required on some systems. */
28 
29 /*% Directory Entry */
30 typedef struct isc_direntry {
31 	char	     name[NAME_MAX];
32 	unsigned int length;
33 } isc_direntry_t;
34 
35 /*% Directory */
36 typedef struct isc_dir {
37 	unsigned int   magic;
38 	char	       dirname[PATH_MAX];
39 	isc_direntry_t entry;
40 	DIR	      *handle;
41 } isc_dir_t;
42 
43 ISC_LANG_BEGINDECLS
44 
45 void
46 isc_dir_init(isc_dir_t *dir);
47 
48 isc_result_t
49 isc_dir_open(isc_dir_t *dir, const char *dirname);
50 
51 isc_result_t
52 isc_dir_read(isc_dir_t *dir);
53 
54 isc_result_t
55 isc_dir_reset(isc_dir_t *dir);
56 
57 void
58 isc_dir_close(isc_dir_t *dir);
59 
60 isc_result_t
61 isc_dir_chdir(const char *dirname);
62 
63 isc_result_t
64 isc_dir_chroot(const char *dirname);
65 
66 isc_result_t
67 isc_dir_createunique(char *templet);
68 /*!<
69  * Use a templet (such as from isc_file_mktemplate()) to create a uniquely
70  * named, empty directory.  The templet string is modified in place.
71  * If result == ISC_R_SUCCESS, it is the name of the directory that was
72  * created.
73  */
74 
75 ISC_LANG_ENDDECLS
76 
77 #endif /* ISC_DIR_H */
78