dir.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2004, 2005, 2007  Internet Systems Consortium, Inc. ("ISC")
00003  * Copyright (C) 1999-2001  Internet Software Consortium.
00004  *
00005  * Permission to use, copy, modify, and/or distribute this software for any
00006  * purpose with or without fee is hereby granted, provided that the above
00007  * copyright notice and this permission notice appear in all copies.
00008  *
00009  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
00010  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
00011  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
00012  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
00013  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
00014  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
00015  * PERFORMANCE OF THIS SOFTWARE.
00016  */
00017 
00018 /* $Id: dir.h,v 1.21 2007/06/19 23:47:19 tbox Exp $ */
00019 
00020 /* Principal Authors: DCL */
00021 
00022 #ifndef ISC_DIR_H
00023 #define ISC_DIR_H 1
00024 
00025 /*! \file */
00026 
00027 #include <sys/types.h>          /* Required on some systems. */
00028 #include <dirent.h>
00029 
00030 #include <isc/lang.h>
00031 #include <isc/result.h>
00032 
00033 #define ISC_DIR_NAMEMAX 256
00034 #define ISC_DIR_PATHMAX 1024
00035 
00036 /*% Directory Entry */
00037 typedef struct isc_direntry {
00038         /*!
00039          * Ideally, this should be NAME_MAX, but AIX does not define it by
00040          * default and dynamically allocating the space based on pathconf()
00041          * complicates things undesirably, as does adding special conditionals
00042          * just for AIX.  So a comfortably sized buffer is chosen instead.
00043          */
00044         char            name[ISC_DIR_NAMEMAX];
00045         unsigned int    length;
00046 } isc_direntry_t;
00047 
00048 /*% Directory */
00049 typedef struct isc_dir {
00050         unsigned int    magic;
00051         /*!
00052          * As with isc_direntry_t->name, making this "right" for all systems
00053          * is slightly problematic because AIX does not define PATH_MAX.
00054          */
00055         char            dirname[ISC_DIR_PATHMAX];
00056         isc_direntry_t  entry;
00057         DIR *           handle;
00058 } isc_dir_t;
00059 
00060 ISC_LANG_BEGINDECLS
00061 
00062 void
00063 isc_dir_init(isc_dir_t *dir);
00064 
00065 isc_result_t
00066 isc_dir_open(isc_dir_t *dir, const char *dirname);
00067 
00068 isc_result_t
00069 isc_dir_read(isc_dir_t *dir);
00070 
00071 isc_result_t
00072 isc_dir_reset(isc_dir_t *dir);
00073 
00074 void
00075 isc_dir_close(isc_dir_t *dir);
00076 
00077 isc_result_t
00078 isc_dir_chdir(const char *dirname);
00079 
00080 isc_result_t
00081 isc_dir_chroot(const char *dirname);
00082 
00083 isc_result_t
00084 isc_dir_createunique(char *templet);
00085 /*!<
00086  * Use a templet (such as from isc_file_mktemplate()) to create a uniquely
00087  * named, empty directory.  The templet string is modified in place.
00088  * If result == ISC_R_SUCCESS, it is the name of the directory that was
00089  * created.
00090  */
00091 
00092 ISC_LANG_ENDDECLS
00093 
00094 #endif /* ISC_DIR_H */

Generated on Tue Apr 28 17:41:05 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha