unistd.h revision 1.46
1/*	$OpenBSD: unistd.h,v 1.46 2003/05/10 17:51:39 miod Exp $ */
2/*	$NetBSD: unistd.h,v 1.26.4.1 1996/05/28 02:31:51 mrg Exp $	*/
3
4/*-
5 * Copyright (c) 1991 The Regents of the University of California.
6 * 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. All advertising materials mentioning features or use of this software
17 *    must display the following acknowledgement:
18 *	This product includes software developed by the University of
19 *	California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 *    may be used to endorse or promote products derived from this software
22 *    without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 *	@(#)unistd.h	5.13 (Berkeley) 6/17/91
37 */
38
39#ifndef _UNISTD_H_
40#define	_UNISTD_H_
41
42#include <sys/cdefs.h>
43#include <sys/types.h>
44#include <sys/unistd.h>
45
46#define	STDIN_FILENO	0	/* standard input file descriptor */
47#define	STDOUT_FILENO	1	/* standard output file descriptor */
48#define	STDERR_FILENO	2	/* standard error file descriptor */
49
50#ifndef NULL
51#ifdef 	__GNUG__
52#define	NULL	__null
53#else
54#define	NULL	0L
55#endif
56#endif
57
58__BEGIN_DECLS
59__dead void	 _exit(int);
60int	 access(const char *, int);
61unsigned int alarm(unsigned int);
62int	 chdir(const char *);
63int	 chown(const char *, uid_t, gid_t);
64int	 close(int);
65size_t	 confstr(int, char *, size_t);
66char	*cuserid(char *);
67int	 dup(int);
68int	 dup2(int, int);
69int	 execl(const char *, const char *, ...)
70	    __attribute__((sentinel));
71int	 execle(const char *, const char *, ...)
72	    __attribute__((sentinel));
73int	 execlp(const char *, const char *, ...)
74	    __attribute__((sentinel));
75int	 execv(const char *, char * const *);
76int	 execve(const char *, char * const *, char * const *);
77int	 execvp(const char *, char * const *);
78pid_t	 fork(void);
79long	 fpathconf(int, int);
80char	*getcwd(char *, size_t);
81gid_t	 getegid(void);
82uid_t	 geteuid(void);
83gid_t	 getgid(void);
84int	 getgroups(int, gid_t *);
85char	*getlogin(void);
86int	 getlogin_r(char *, size_t);
87pid_t	 getpgrp(void);
88pid_t	 getpid(void);
89pid_t	 getpgid(pid_t);
90pid_t	 getppid(void);
91pid_t	 getsid(pid_t);
92uid_t	 getuid(void);
93int	 isatty(int);
94int	 link(const char *, const char *);
95off_t	 lseek(int, off_t, int);
96long	 pathconf(const char *, int);
97int	 pause(void);
98int	 pipe(int *);
99ssize_t	 read(int, void *, size_t);
100int	 rmdir(const char *);
101int	 setgid(gid_t);
102int	 setpgid(pid_t, pid_t);
103pid_t	 setsid(void);
104int	 setuid(uid_t);
105unsigned int sleep(unsigned int);
106long	 sysconf(int);
107pid_t	 tcgetpgrp(int);
108int	 tcsetpgrp(int, pid_t);
109char	*ttyname(int);
110int	 ttyname_r(int, char *, size_t);
111int	 unlink(const char *);
112ssize_t	 write(int, const void *, size_t);
113
114#ifndef	_POSIX_SOURCE
115
116/* structure timeval required for select() */
117#include <sys/time.h>
118
119/*
120 * X/Open CAE Specification Issue 5 Version 2
121 */
122#if (!defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE)) || \
123    (_XOPEN_VERSION - 0) >= 500
124ssize_t  pread(int, void *, size_t, off_t);
125ssize_t  pwrite(int, const void *, size_t, off_t);
126#endif
127
128int	 acct(const char *);
129char	*brk(const char *);
130int	 chroot(const char *);
131char	*crypt(const char *, const char *);
132int	 des_cipher(const char *, char *, long, int);
133int	 des_setkey(const char *key);
134int	 encrypt(char *, int);
135void	 endusershell(void);
136int	 exect(const char *, char * const *, char * const *);
137int	 fchdir(int);
138int	 fchown(int, uid_t, gid_t);
139char	*fflagstostr(u_int32_t);
140int	 fsync(int);
141int	 ftruncate(int, off_t);
142int	 getdomainname(char *, size_t);
143int	 getdtablesize(void);
144int	 getgrouplist(const char *, gid_t, gid_t *, int *);
145long	 gethostid(void);
146int	 gethostname(char *, size_t);
147mode_t	 getmode(const void *, mode_t);
148int	 getpagesize(void);
149int	 getresgid(gid_t *, gid_t *, gid_t *);
150int	 getresuid(uid_t *, uid_t *, uid_t *);
151char	*getpass(const char *);
152char	*getusershell(void);
153char	*getwd(char *);			/* obsoleted by getcwd() */
154int	 initgroups(const char *, gid_t);
155int	 iruserok(u_int32_t, int, const char *, const char *);
156int	 iruserok_sa(const void *, int, int, const char *, const char *);
157int	 lchown(const char *, uid_t, gid_t);
158char	*mkdtemp(char *);
159int	 mkstemp(char *);
160int	 mkstemps(char *, int);
161char	*mktemp(char *);
162int	 nfssvc(int, void *);
163int	 nice(int);
164void	 psignal(unsigned int, const char *);
165extern __const char *__const sys_siglist[];
166int	 profil(char *, size_t, unsigned long, unsigned int);
167int	 rcmd(char **, int, const char *,
168	    const char *, const char *, int *);
169int	 rcmd_af(char **, int, const char *,
170	    const char *, const char *, int *, int);
171int	 rcmdsh(char **, int, const char *,
172	    const char *, const char *, char *);
173char	*re_comp(const char *);
174int	 re_exec(const char *);
175int	 readlink(const char *, char *, size_t);
176int	 reboot(int);
177int	 revoke(const char *);
178int	 rfork(int opts);
179int	 rresvport(int *);
180int	 rresvport_af(int *, int);
181int	 ruserok(const char *, int, const char *, const char *);
182int	 quotactl(const char *, int, int, char *);
183char	*sbrk(int);
184
185#if !defined(_XOPEN_SOURCE)
186int	 select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
187#endif
188
189int	 setdomainname(const char *, size_t);
190int	 setegid(gid_t);
191int	 seteuid(uid_t);
192int	 setgroups(int, const gid_t *);
193int	 sethostid(long);
194int	 sethostname(const char *, size_t);
195int	 setkey(const char *);
196int	 setlogin(const char *);
197void	*setmode(const char *);
198int	 setpgrp(pid_t pid, pid_t pgrp);	/* obsoleted by setpgid() */
199int	 setregid(gid_t, gid_t);
200int	 setresgid(gid_t, gid_t, gid_t);
201int	 setresuid(uid_t, uid_t, uid_t);
202int	 setreuid(uid_t, uid_t);
203int	 setrgid(gid_t);
204int	 setruid(uid_t);
205void	 setusershell(void);
206int	 strtofflags(char **, u_int32_t *, u_int32_t *);
207void	 swab(const void *, void *, size_t);
208int	 swapctl(int cmd, const void *arg, int misc);
209int	 symlink(const char *, const char *);
210void	 sync(void);
211int	 syscall(int, ...);
212int	 truncate(const char *, off_t);
213int	 ttyslot(void);
214unsigned int	 ualarm(unsigned int, unsigned int);
215int	 undelete(const char *);
216int	 usleep(useconds_t);
217void	*valloc(size_t);		/* obsoleted by malloc() */
218pid_t	 vfork(void);
219int	 issetugid(void);
220
221#ifndef _GETOPT_DEFINED_
222#define _GETOPT_DEFINED_
223int	 getopt(int, char * const *, const char *);
224extern	 char *optarg;			/* getopt(3) external variables */
225extern	 int opterr;
226extern	 int optind;
227extern	 int optopt;
228extern	 int optreset;
229int	 getsubopt(char **, char * const *, char **);
230extern	 char *suboptarg;		/* getsubopt(3) external variable */
231#endif /* _GETOPT_DEFINED_ */
232#endif /* !_POSIX_SOURCE */
233
234#if (!defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE) && \
235     !defined(_XOPEN_SOURCE)) || \
236    (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1)
237#define F_ULOCK         0
238#define F_LOCK          1
239#define F_TLOCK         2
240#define F_TEST          3
241int     lockf(int, int, off_t);
242#endif /* (!defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE)) || ... */
243__END_DECLS
244
245#endif /* !_UNISTD_H_ */
246