unistd.h revision 1.67
1/*	$OpenBSD: unistd.h,v 1.67 2012/01/13 13:16:44 nigel 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. 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 *	@(#)unistd.h	5.13 (Berkeley) 6/17/91
33 */
34
35#ifndef _UNISTD_H_
36#define	_UNISTD_H_
37
38#include <sys/cdefs.h>
39#include <sys/types.h>
40#include <sys/unistd.h>
41
42#define	STDIN_FILENO	0	/* standard input file descriptor */
43#define	STDOUT_FILENO	1	/* standard output file descriptor */
44#define	STDERR_FILENO	2	/* standard error file descriptor */
45
46#if __XPG_VISIBLE || __POSIX_VISIBLE >= 200112
47#define F_ULOCK         0	/* unlock locked section */
48#define F_LOCK          1	/* lock a section for exclusive use */
49#define F_TLOCK         2	/* test and lock a section for exclusive use */
50#define F_TEST          3	/* test a section for locks by other procs */
51#endif
52
53#if __POSIX_VISIBLE
54#define _POSIX_REENTRANT_FUNCTIONS	1
55#define _POSIX_THREAD_SAFE_FUNCTIONS	200112L
56#endif
57
58#ifndef NULL
59#ifdef 	__GNUG__
60#define	NULL	__null
61#elif defined(__cplusplus)
62#define	NULL	0L
63#else
64#define	NULL	((void *)0)
65#endif
66#endif
67
68__BEGIN_DECLS
69__dead void	 _exit(int);
70int	 access(const char *, int);
71unsigned int alarm(unsigned int);
72int	 chdir(const char *);
73int	 chown(const char *, uid_t, gid_t);
74int	 close(int);
75int	 dup(int);
76int	 dup2(int, int);
77int	 execl(const char *, const char *, ...)
78	    __attribute__((sentinel));
79int	 execle(const char *, const char *, ...);
80int	 execlp(const char *, const char *, ...)
81	    __attribute__((sentinel));
82int	 execv(const char *, char * const *);
83int	 execve(const char *, char * const *, char * const *);
84int	 execvp(const char *, char * const *);
85pid_t	 fork(void);
86long	 fpathconf(int, int);
87char	*getcwd(char *, size_t)
88		__attribute__((__bounded__(__string__,1,2)));
89gid_t	 getegid(void);
90uid_t	 geteuid(void);
91gid_t	 getgid(void);
92int	 getgroups(int, gid_t *);
93char	*getlogin(void);
94pid_t	 getpgrp(void);
95pid_t	 getpid(void);
96pid_t	 getppid(void);
97uid_t	 getuid(void);
98int	 isatty(int);
99int	 link(const char *, const char *);
100off_t	 lseek(int, off_t, int);
101long	 pathconf(const char *, int);
102int	 pause(void);
103int	 pipe(int *);
104ssize_t	 read(int, void *, size_t)
105		__attribute__((__bounded__(__buffer__,2,3)));
106int	 rmdir(const char *);
107int	 setgid(gid_t);
108int	 setuid(uid_t);
109unsigned int sleep(unsigned int);
110long	 sysconf(int);
111pid_t	 tcgetpgrp(int);
112int	 tcsetpgrp(int, pid_t);
113char	*ttyname(int);
114int	 unlink(const char *);
115ssize_t	 write(int, const void *, size_t)
116		__attribute__((__bounded__(__buffer__,2,3)));
117
118#if __POSIX_VISIBLE || __XPG_VISIBLE >= 300
119pid_t	 setsid(void);
120int	 setpgid(pid_t, pid_t);
121#endif
122
123#if __POSIX_VISIBLE >= 199209 || __XPG_VISIBLE
124size_t	 confstr(int, char *, size_t)
125		__attribute__((__bounded__(__string__,2,3)));
126#ifndef _GETOPT_DEFINED_
127#define _GETOPT_DEFINED_
128int	 getopt(int, char * const *, const char *);
129extern	 char *optarg;			/* getopt(3) external variables */
130extern	 int opterr, optind, optopt, optreset;
131/* XXX - getsubopt does not belong here */
132int	 getsubopt(char **, char * const *, char **);
133extern	 char *suboptarg;		/* getsubopt(3) external variable */
134#endif /* _GETOPT_DEFINED_ */
135#endif
136
137#if __POSIX_VISIBLE >= 199506 || __XPG_VISIBLE
138int	 fsync(int);
139int	 ftruncate(int, off_t);
140int	 getlogin_r(char *, size_t)
141		__attribute__((__bounded__(__string__,1,2)));
142#endif
143
144#if __XPG_VISIBLE || __BSD_VISIBLE
145char	*crypt(const char *, const char *);
146int	 encrypt(char *, int);
147int	 fchdir(int);
148int	 fchown(int, uid_t, gid_t);
149long	 gethostid(void);
150char	*getwd(char *)
151		__attribute__ ((__bounded__(__minbytes__,1,1024)));
152int	 lchown(const char *, uid_t, gid_t);
153int	 mkstemp(char *);
154char	*mktemp(char *);
155int	 nice(int);
156int	 readlink(const char *, char *, size_t)
157		__attribute__ ((__bounded__(__string__,2,3)));
158int	 setkey(const char *);
159int	 setpgrp(pid_t pid, pid_t pgrp);	/* obsoleted by setpgid() */
160int	 setregid(gid_t, gid_t);
161int	 setreuid(uid_t, uid_t);
162void	 swab(const void *, void *, size_t);
163void	 sync(void);
164int	 truncate(const char *, off_t);
165unsigned int	 ualarm(unsigned int, unsigned int);
166int	 usleep(useconds_t);
167pid_t	 vfork(void);
168#endif
169
170#if __XPG_VISIBLE >= 420
171pid_t	 getpgid(pid_t);
172pid_t	 getsid(pid_t);
173#endif
174
175#if __XPG_VISIBLE >= 500
176ssize_t  pread(int, void *, size_t, off_t);
177ssize_t  pwrite(int, const void *, size_t, off_t);
178int	 ttyname_r(int, char *, size_t)
179	    __attribute__((__bounded__(__string__,2,3)));
180#endif
181
182#if __BSD_VISIBLE ||  __XPG_VISIBLE <= 500
183/* Interfaces withdrawn by X/Open Issue 5 Version 0 */
184int	 brk(void *);
185int	 chroot(const char *);
186int	 getdtablesize(void);
187int	 getpagesize(void);
188char	*getpass(const char *);
189void	*sbrk(int);
190#endif
191
192#if __POSIX_VISIBLE >= 200112 || __XPG_VISIBLE >= 420
193int     lockf(int, int, off_t);
194#endif
195
196#if __POSIX_VISIBLE >= 200112 || __XPG_VISIBLE >= 420 || __BSD_VISIBLE
197int	 symlink(const char *, const char *);
198int	 gethostname(char *, size_t)
199		__attribute__ ((__bounded__(__string__,1,2)));
200int	 setegid(gid_t);
201int	 seteuid(uid_t);
202#endif
203
204#if __POSIX_VISIBLE >= 200809
205int	faccessat(int, const char *, int, int);
206int	fchownat(int, const char *, uid_t, gid_t, int);
207int	linkat(int, const char *, int, const char *, int);
208ssize_t	readlinkat(int, const char *, char *, size_t);
209int	symlinkat(const char *, int, const char *);
210int	unlinkat(int, const char *, int);
211#endif
212
213#if __BSD_VISIBLE
214int	 acct(const char *);
215int	 closefrom(int);
216int	 des_cipher(const char *, char *, int32_t, int);
217int	 des_setkey(const char *);
218void	 endusershell(void);
219int	 exect(const char *, char * const *, char * const *);
220char	*fflagstostr(u_int32_t);
221int	 getdomainname(char *, size_t)
222		__attribute__ ((__bounded__(__string__,1,2)));
223int	 getgrouplist(const char *, gid_t, gid_t *, int *);
224mode_t	 getmode(const void *, mode_t);
225int	 getresgid(gid_t *, gid_t *, gid_t *);
226int	 getresuid(uid_t *, uid_t *, uid_t *);
227char	*getusershell(void);
228int	 initgroups(const char *, gid_t);
229int	 iruserok(u_int32_t, int, const char *, const char *);
230int	 iruserok_sa(const void *, int, int, const char *, const char *);
231int	 issetugid(void);
232char	*mkdtemp(char *);
233int	 mkstemps(char *, int);
234int	 nfssvc(int, void *);
235int	 profil(char *, size_t, unsigned long, unsigned int)
236		__attribute__ ((__bounded__(__string__,1,2)));
237int	 quotactl(const char *, int, int, char *);
238int	 rcmd(char **, int, const char *,
239	    const char *, const char *, int *);
240int	 rcmd_af(char **, int, const char *,
241	    const char *, const char *, int *, int);
242int	 rcmdsh(char **, int, const char *,
243	    const char *, const char *, char *);
244char	*re_comp(const char *);
245int	 re_exec(const char *);
246int	 reboot(int);
247int	 revoke(const char *);
248int	 rfork(int opts);
249int	 rresvport(int *);
250int	 rresvport_af(int *, int);
251int	 ruserok(const char *, int, const char *, const char *);
252#ifndef _SELECT_DEFINED_
253#define _SELECT_DEFINED_
254struct timeval;
255int	 select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
256#endif
257int	 setdomainname(const char *, size_t);
258int	 setgroups(int, const gid_t *);
259int	 sethostid(long);
260int	 sethostname(const char *, size_t);
261int	 setlogin(const char *);
262void	*setmode(const char *);
263int	 setresgid(gid_t, gid_t, gid_t);
264int	 setresuid(uid_t, uid_t, uid_t);
265int	 setrgid(gid_t);
266int	 setruid(uid_t);
267void	 setusershell(void);
268int	 strtofflags(char **, u_int32_t *, u_int32_t *);
269int	 swapctl(int cmd, const void *arg, int misc);
270int	 syscall(int, ...);
271#endif /* __BSD_VISIBLE */
272__END_DECLS
273
274#endif /* !_UNISTD_H_ */
275