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