1/*	$OpenBSD: dirent.h,v 1.35 2024/04/15 15:47:58 florian 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
59typedef struct _dirdesc DIR;
60
61#if __BSD_VISIBLE
62
63/* definitions for library routines operating on directories. */
64#define	DIRBLKSIZ	1024
65
66#include <sys/_null.h>
67
68#endif /* __BSD_VISIBLE */
69
70__BEGIN_DECLS
71DIR *opendir(const char *);
72#if __POSIX_VISIBLE >= 200809
73DIR *fdopendir(int);
74#endif
75struct dirent *readdir(DIR *);
76void rewinddir(DIR *);
77int closedir(DIR *);
78#if __BSD_VISIBLE
79int getdents(int, void *, size_t)
80		__attribute__ ((__bounded__(__string__,2,3)));
81#endif /* __BSD_VISIBLE */
82#if __XPG_VISIBLE
83long telldir(DIR *);
84void seekdir(DIR *, long);
85#endif
86#if __POSIX_VISIBLE >= 199506 || __XPG_VISIBLE >= 500
87int readdir_r(DIR *__restrict, struct dirent *__restrict,
88    struct dirent **__restrict);
89#endif
90#if __POSIX_VISIBLE >= 200809
91int scandir(const char *, struct dirent ***, int (*)(const struct dirent *),
92    int (*)(const struct dirent **, const struct dirent **));
93int scandirat(int, const char *, struct dirent ***,
94    int (*)(const struct dirent *),
95    int (*)(const struct dirent **, const struct dirent **));
96int alphasort(const struct dirent **, const struct dirent **);
97#elif __BSD_VISIBLE
98int scandir(const char *, struct dirent ***, int (*)(struct dirent *),
99    int (*)(const void *, const void *));
100int alphasort(const void *, const void *);
101#endif
102#if __POSIX_VISIBLE >= 200809 || __XPG_VISIBLE > 600
103int dirfd(DIR *);
104#endif
105__END_DECLS
106
107#endif /* !_DIRENT_H_ */
108