1290001Sglebius/* 2290001Sglebius * Copyright (C) 2004, 2005, 2007 Internet Systems Consortium, Inc. ("ISC") 3290001Sglebius * Copyright (C) 1999-2001 Internet Software Consortium. 4290001Sglebius * 5290001Sglebius * Permission to use, copy, modify, and/or distribute this software for any 6290001Sglebius * purpose with or without fee is hereby granted, provided that the above 7290001Sglebius * copyright notice and this permission notice appear in all copies. 8290001Sglebius * 9290001Sglebius * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10290001Sglebius * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11290001Sglebius * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12290001Sglebius * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13290001Sglebius * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14290001Sglebius * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15290001Sglebius * PERFORMANCE OF THIS SOFTWARE. 16290001Sglebius */ 17290001Sglebius 18290001Sglebius/* $Id: dir.h,v 1.21 2007/06/19 23:47:19 tbox Exp $ */ 19290001Sglebius 20290001Sglebius/* Principal Authors: DCL */ 21290001Sglebius 22290001Sglebius#ifndef ISC_DIR_H 23290001Sglebius#define ISC_DIR_H 1 24290001Sglebius 25290001Sglebius/*! \file */ 26290001Sglebius 27290001Sglebius#include <sys/types.h> /* Required on some systems. */ 28290001Sglebius#include <dirent.h> 29290001Sglebius 30290001Sglebius#include <isc/lang.h> 31290001Sglebius#include <isc/result.h> 32290001Sglebius 33290001Sglebius#define ISC_DIR_NAMEMAX 256 34290001Sglebius#define ISC_DIR_PATHMAX 1024 35290001Sglebius 36290001Sglebius/*% Directory Entry */ 37290001Sglebiustypedef struct isc_direntry { 38290001Sglebius /*! 39290001Sglebius * Ideally, this should be NAME_MAX, but AIX does not define it by 40290001Sglebius * default and dynamically allocating the space based on pathconf() 41290001Sglebius * complicates things undesirably, as does adding special conditionals 42290001Sglebius * just for AIX. So a comfortably sized buffer is chosen instead. 43290001Sglebius */ 44290001Sglebius char name[ISC_DIR_NAMEMAX]; 45290001Sglebius unsigned int length; 46290001Sglebius} isc_direntry_t; 47290001Sglebius 48290001Sglebius/*% Directory */ 49290001Sglebiustypedef struct isc_dir { 50290001Sglebius unsigned int magic; 51290001Sglebius /*! 52290001Sglebius * As with isc_direntry_t->name, making this "right" for all systems 53290001Sglebius * is slightly problematic because AIX does not define PATH_MAX. 54290001Sglebius */ 55290001Sglebius char dirname[ISC_DIR_PATHMAX]; 56290001Sglebius isc_direntry_t entry; 57290001Sglebius DIR * handle; 58290001Sglebius} isc_dir_t; 59290001Sglebius 60290001SglebiusISC_LANG_BEGINDECLS 61290001Sglebius 62290001Sglebiusvoid 63290001Sglebiusisc_dir_init(isc_dir_t *dir); 64290001Sglebius 65290001Sglebiusisc_result_t 66290001Sglebiusisc_dir_open(isc_dir_t *dir, const char *dirname); 67290001Sglebius 68290001Sglebiusisc_result_t 69290001Sglebiusisc_dir_read(isc_dir_t *dir); 70290001Sglebius 71290001Sglebiusisc_result_t 72290001Sglebiusisc_dir_reset(isc_dir_t *dir); 73290001Sglebius 74290001Sglebiusvoid 75290001Sglebiusisc_dir_close(isc_dir_t *dir); 76290001Sglebius 77290001Sglebiusisc_result_t 78290001Sglebiusisc_dir_chdir(const char *dirname); 79290001Sglebius 80290001Sglebiusisc_result_t 81290001Sglebiusisc_dir_chroot(const char *dirname); 82290001Sglebius 83290001Sglebiusisc_result_t 84290001Sglebiusisc_dir_createunique(char *templet); 85290001Sglebius/*!< 86290001Sglebius * Use a templet (such as from isc_file_mktemplate()) to create a uniquely 87290001Sglebius * named, empty directory. The templet string is modified in place. 88290001Sglebius * If result == ISC_R_SUCCESS, it is the name of the directory that was 89290001Sglebius * created. 90290001Sglebius */ 91290001Sglebius 92290001SglebiusISC_LANG_ENDDECLS 93290001Sglebius 94290001Sglebius#endif /* ISC_DIR_H */ 95