1999-09-23 13:31:59 -04:00
|
|
|
/*
|
2018-02-23 03:53:12 -05:00
|
|
|
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
2000-07-31 21:33:37 -04:00
|
|
|
*
|
2021-06-03 02:37:05 -04:00
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
*
|
2016-06-27 00:56:38 -04:00
|
|
|
* 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
|
2020-09-14 19:20:40 -04:00
|
|
|
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
2018-02-23 03:53:12 -05:00
|
|
|
*
|
|
|
|
|
* See the COPYRIGHT file distributed with this work for additional
|
|
|
|
|
* information regarding copyright ownership.
|
1999-09-23 13:31:59 -04:00
|
|
|
*/
|
|
|
|
|
|
2021-06-10 02:14:57 -04:00
|
|
|
#pragma once
|
1999-09-23 13:31:59 -04:00
|
|
|
|
2005-04-27 00:57:32 -04:00
|
|
|
/*! \file */
|
|
|
|
|
|
1999-09-23 13:31:59 -04:00
|
|
|
#include <dirent.h>
|
2021-06-10 02:14:57 -04:00
|
|
|
#include <limits.h>
|
1999-09-23 13:31:59 -04:00
|
|
|
|
|
|
|
|
#include <isc/lang.h>
|
|
|
|
|
#include <isc/result.h>
|
|
|
|
|
|
2020-03-11 05:19:32 -04:00
|
|
|
#include <sys/types.h> /* Required on some systems. */
|
|
|
|
|
|
2021-06-10 02:14:57 -04:00
|
|
|
#ifndef NAME_MAX
|
|
|
|
|
#define NAME_MAX 256
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifndef PATH_MAX
|
|
|
|
|
#define PATH_MAX 1024
|
|
|
|
|
#endif
|
|
|
|
|
|
2005-04-27 00:57:32 -04:00
|
|
|
/*% Directory Entry */
|
2000-06-22 23:08:18 -04:00
|
|
|
typedef struct isc_direntry {
|
2020-03-11 05:19:32 -04:00
|
|
|
char name[NAME_MAX];
|
2020-02-12 07:59:18 -05:00
|
|
|
unsigned int length;
|
1999-09-23 13:31:59 -04:00
|
|
|
} isc_direntry_t;
|
|
|
|
|
|
2005-04-27 00:57:32 -04:00
|
|
|
/*% Directory */
|
2000-06-22 23:08:18 -04:00
|
|
|
typedef struct isc_dir {
|
2020-03-11 05:19:32 -04:00
|
|
|
unsigned int magic;
|
|
|
|
|
char dirname[PATH_MAX];
|
2020-02-12 07:59:18 -05:00
|
|
|
isc_direntry_t entry;
|
2022-05-31 10:55:01 -04:00
|
|
|
DIR *handle;
|
1999-09-23 13:31:59 -04:00
|
|
|
} isc_dir_t;
|
|
|
|
|
|
2000-04-28 13:46:30 -04:00
|
|
|
ISC_LANG_BEGINDECLS
|
|
|
|
|
|
1999-09-23 13:31:59 -04:00
|
|
|
void
|
|
|
|
|
isc_dir_init(isc_dir_t *dir);
|
|
|
|
|
|
|
|
|
|
isc_result_t
|
1999-10-31 14:08:17 -05:00
|
|
|
isc_dir_open(isc_dir_t *dir, const char *dirname);
|
1999-09-23 13:31:59 -04:00
|
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
|
isc_dir_read(isc_dir_t *dir);
|
|
|
|
|
|
|
|
|
|
isc_result_t
|
|
|
|
|
isc_dir_reset(isc_dir_t *dir);
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
isc_dir_close(isc_dir_t *dir);
|
|
|
|
|
|
1999-10-31 14:08:17 -05:00
|
|
|
isc_result_t
|
|
|
|
|
isc_dir_chdir(const char *dirname);
|
|
|
|
|
|
2001-01-28 22:17:45 -05:00
|
|
|
isc_result_t
|
|
|
|
|
isc_dir_chroot(const char *dirname);
|
|
|
|
|
|
2000-07-26 22:04:36 -04:00
|
|
|
isc_result_t
|
|
|
|
|
isc_dir_createunique(char *templet);
|
2005-04-27 00:57:32 -04:00
|
|
|
/*!<
|
2000-07-26 22:04:36 -04:00
|
|
|
* Use a templet (such as from isc_file_mktemplate()) to create a uniquely
|
|
|
|
|
* named, empty directory. The templet string is modified in place.
|
|
|
|
|
* If result == ISC_R_SUCCESS, it is the name of the directory that was
|
|
|
|
|
* created.
|
|
|
|
|
*/
|
|
|
|
|
|
2000-04-28 13:46:30 -04:00
|
|
|
ISC_LANG_ENDDECLS
|