[BACK]Return to dirent.h CVS log [TXT][DIR] Up to [local] / src / include

Annotation of src/include/dirent.h, Revision 1.25

1.25    ! matthew     1: /*     $OpenBSD: dirent.h,v 1.24 2011/07/18 17:29:49 matthew Exp $     */
1.1       deraadt     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.
1.10      millert    16:  * 3. Neither the name of the University nor the names of its contributors
1.1       deraadt    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:
1.15      millert    38: #include <sys/cdefs.h>
                     39:
1.1       deraadt    40: /*
1.2       deraadt    41:  * POSIX doesn't mandate this, but X/Open XPG 4.2 does.
                     42:  */
1.15      millert    43: #if __BSD_VISIBLE || __XPG_VISIBLE >= 420
1.2       deraadt    44: #include <sys/types.h>
                     45: #endif
                     46:
                     47: /*
1.1       deraadt    48:  * The kernel defines the format of directory entries returned by
                     49:  * the getdirentries(2) system call.
                     50:  */
                     51: #include <sys/dirent.h>
                     52:
1.15      millert    53: #if __BSD_VISIBLE || __XPG_VISIBLE
                     54: #define        d_ino           d_fileno        /* backward compatibility */
                     55: #endif
1.1       deraadt    56:
1.20      guenther   57: #if __BSD_VISIBLE || __XPG_VISIBLE > 600
                     58: #define        dirfd(dirp)     ((dirp)->dd_fd)
                     59: #endif
                     60:
1.15      millert    61: #if __BSD_VISIBLE
1.1       deraadt    62:
                     63: /* definitions for library routines operating on directories. */
                     64: #define        DIRBLKSIZ       1024
                     65:
1.16      otto       66: struct _telldir;
1.1       deraadt    67: /* structure describing an open directory. */
                     68: typedef struct _dirdesc {
                     69:        int     dd_fd;          /* file descriptor associated with directory */
                     70:        long    dd_loc;         /* offset in current buffer */
                     71:        long    dd_size;        /* amount of data returned by getdirentries */
                     72:        char    *dd_buf;        /* data buffer */
                     73:        int     dd_len;         /* size of data buffer */
1.19      millert    74:        off_t   dd_seek;        /* magic cookie returned by getdirentries */
                     75:        off_t   dd_rewind;      /* magic cookie for rewinding */
1.23      deraadt    76:        int     dd_unused;      /* was flags for readdir */
1.16      otto       77:        struct _telldir *dd_td; /* telldir position recording */
1.18      kurt       78:        void    *dd_lock;       /* mutex to protect struct */
1.1       deraadt    79: } DIR;
                     80:
                     81: #ifndef NULL
1.5       espie      82: #ifdef         __GNUG__
1.6       espie      83: #define        NULL    __null
1.22      jsg        84: #elif defined(__cplusplus)
                     85: #define        NULL    0L
1.5       espie      86: #else
1.21      miod       87: #define        NULL    ((void *)0)
1.15      millert    88: #endif /* __GNUG__ */
                     89: #endif /* !NULL */
1.1       deraadt    90:
1.15      millert    91: #else /* !__BSD_VISIBLE */
1.1       deraadt    92:
1.15      millert    93: typedef void * DIR;
1.1       deraadt    94:
1.15      millert    95: #endif /* !__BSD_VISIBLE */
1.1       deraadt    96:
1.15      millert    97: #ifndef _KERNEL
1.1       deraadt    98: __BEGIN_DECLS
1.7       millert    99: DIR *opendir(const char *);
1.24      matthew   100: #if __POSIX_VISIBLE >= 200809
                    101: DIR *fdopendir(int);
                    102: #endif
1.7       millert   103: struct dirent *readdir(DIR *);
                    104: void rewinddir(DIR *);
                    105: int closedir(DIR *);
1.15      millert   106: #if __BSD_VISIBLE
1.19      millert   107: int getdirentries(int, char *, int, off_t *)
1.13      avsm      108:                __attribute__ ((__bounded__(__string__,2,3)));
1.15      millert   109: #endif /* __BSD_VISIBLE */
                    110: #if __XPG_VISIBLE
1.16      otto      111: long telldir(DIR *);
1.15      millert   112: void seekdir(DIR *, long);
                    113: #endif
                    114: #if __POSIX_VISIBLE >= 199506 || __XPG_VISIBLE >= 500
1.7       millert   115: int readdir_r(DIR *, struct dirent *, struct dirent **);
1.20      guenther  116: #endif
                    117: #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809
                    118: int scandir(const char *, struct dirent ***,
                    119:     int (*)(struct dirent *), int (*)(const void *, const void *));
                    120: int alphasort(const void *, const void *);
1.25    ! matthew   121: #endif
        !           122: #if __POSIX_VISIBLE >= 200809 || __XPG_VISIBLE > 600
        !           123: int (dirfd)(DIR *);
1.15      millert   124: #endif
1.1       deraadt   125: __END_DECLS
                    126:
                    127: #endif /* !_KERNEL */
                    128:
                    129: #endif /* !_DIRENT_H_ */