1 /* $OpenBSD: dirent.h,v 1.33 2013/12/13 18:09:27 zhuk Exp $ */ 2 /* $NetBSD: dirent.h,v 1.9 1995/03/26 20:13:37 jtc Exp $ */ 3 4 /*- 5 * Copyright (c) 1989, 1993 6 * The Regents of the University of California. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 3. Neither the name of the University nor the names of its contributors 17 * may be used to endorse or promote products derived from this software 18 * without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30 * SUCH DAMAGE. 31 * 32 * @(#)dirent.h 8.2 (Berkeley) 7/28/94 33 */ 34 35 #ifndef _DIRENT_H_ 36 #define _DIRENT_H_ 37 38 #include <sys/cdefs.h> 39 40 /* 41 * POSIX doesn't mandate this, but X/Open XPG 4.2 does. 42 */ 43 #if __BSD_VISIBLE || __XPG_VISIBLE >= 400 44 #include <sys/types.h> 45 #else 46 #include <sys/_types.h> 47 #endif 48 49 /* 50 * The kernel defines the format of directory entries returned by 51 * the getdents(2) system call. 52 */ 53 #include <sys/dirent.h> 54 55 #if __BSD_VISIBLE || __XPG_VISIBLE 56 #define d_ino d_fileno /* backward compatibility */ 57 #endif 58 59 typedef struct _dirdesc DIR; 60 61 #if __BSD_VISIBLE 62 63 /* definitions for library routines operating on directories. */ 64 #define DIRBLKSIZ 1024 65 66 #ifndef NULL 67 #ifdef __GNUG__ 68 #define NULL __null 69 #elif defined(__cplusplus) 70 #define NULL 0L 71 #else 72 #define NULL ((void *)0) 73 #endif /* __GNUG__ */ 74 #endif /* !NULL */ 75 76 #endif /* __BSD_VISIBLE */ 77 78 __BEGIN_DECLS 79 DIR *opendir(const char *); 80 #if __POSIX_VISIBLE >= 200809 81 DIR *fdopendir(int); 82 #endif 83 struct dirent *readdir(DIR *); 84 void rewinddir(DIR *); 85 int closedir(DIR *); 86 #if __BSD_VISIBLE 87 int getdents(int, void *, size_t) 88 __attribute__ ((__bounded__(__string__,2,3))); 89 #endif /* __BSD_VISIBLE */ 90 #if __XPG_VISIBLE 91 long telldir(DIR *); 92 void seekdir(DIR *, long); 93 #endif 94 #if __POSIX_VISIBLE >= 199506 || __XPG_VISIBLE >= 500 95 int readdir_r(DIR *__restrict, struct dirent *__restrict, 96 struct dirent **__restrict); 97 #endif 98 #if __POSIX_VISIBLE >= 200809 99 int scandir(const char *, struct dirent ***, int (*)(const struct dirent *), 100 int (*)(const struct dirent **, const struct dirent **)); 101 int alphasort(const struct dirent **, const struct dirent **); 102 #elif __BSD_VISIBLE 103 int scandir(const char *, struct dirent ***, int (*)(struct dirent *), 104 int (*)(const void *, const void *)); 105 int alphasort(const void *, const void *); 106 #endif 107 #if __POSIX_VISIBLE >= 200809 || __XPG_VISIBLE > 600 108 int dirfd(DIR *); 109 #endif 110 __END_DECLS 111 112 #endif /* !_DIRENT_H_ */ 113