xref: /freebsd/contrib/ntp/libntp/lib/isc/win32/include/isc/dir.h (revision a466cc55373fc3cf86837f09da729535b57e69a1)
1 /*
2  * Copyright (C) 2004, 2007  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2001  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and/or 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.
8  *
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.
16  */
17 
18 /* $Id: dir.h,v 1.15 2007/06/19 23:47:20 tbox Exp $ */
19 
20 /* Principal Authors: DCL */
21 
22 #ifndef ISC_DIR_H
23 #define ISC_DIR_H 1
24 
25 #include <windows.h>
26 #include <stdlib.h>
27 
28 #include <isc/lang.h>
29 #include <isc/boolean.h>
30 #include <isc/result.h>
31 
32 #define ISC_DIR_NAMEMAX _MAX_FNAME
33 #define ISC_DIR_PATHMAX _MAX_PATH
34 
35 typedef struct {
36 	char 		name[ISC_DIR_NAMEMAX];
37 	unsigned int	length;
38 	WIN32_FIND_DATA	find_data;
39 } isc_direntry_t;
40 
41 typedef struct {
42 	unsigned int	magic;
43 	char		dirname[ISC_DIR_PATHMAX];
44 	isc_direntry_t	entry;
45 	isc_boolean_t	entry_filled;
46 	HANDLE        	search_handle;
47 } isc_dir_t;
48 
49 ISC_LANG_BEGINDECLS
50 
51 void
52 isc_dir_init(isc_dir_t *dir);
53 
54 isc_result_t
55 isc_dir_open(isc_dir_t *dir, const char *dirname);
56 
57 isc_result_t
58 isc_dir_read(isc_dir_t *dir);
59 
60 isc_result_t
61 isc_dir_reset(isc_dir_t *dir);
62 
63 void
64 isc_dir_close(isc_dir_t *dir);
65 
66 isc_result_t
67 isc_dir_chdir(const char *dirname);
68 
69 isc_result_t
70 isc_dir_chroot(const char *dirname);
71 
72 isc_result_t
73 isc_dir_createunique(char *templet);
74 /*
75  * Use a templet (such as from isc_file_mktemplate()) to create a uniquely
76  * named, empty directory.  The templet string is modified in place.
77  * If result == ISC_R_SUCCESS, it is the name of the directory that was
78  * created.
79  */
80 
81 ISC_LANG_ENDDECLS
82 
83 #endif /* ISC_DIR_H */
84