source: trunk/src/emx/include/unistd.h@ 1036

Last change on this file since 1036 was 928, checked in by bird, 22 years ago

getopt & getopt_long with dependencies from FreeBSD 5.1

  • Property cvs2svn:cvs-rev set to 1.13
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 16.4 KB
Line 
1/*-
2 * Copyright (c) 1991, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)unistd.h 8.12 (Berkeley) 4/27/95
34 * $FreeBSD: src/include/unistd.h,v 1.66 2002/12/29 01:07:55 mike Exp $
35 */
36
37/** @file
38 * EMX/FreeBSD 5.1
39 *
40 * @changed Commented out stuff which isn't implemented, TCPIP stuff at bottom.
41 * @todo Several man-years.. ;) Serious, complete the FreeBSD 5.1 merge and
42 * implement all the functions. Currently there is a bunch of POSIX
43 * #defines missing.
44 */
45
46#ifndef _UNISTD_H_
47#define _UNISTD_H_
48#define _UNISTD_H /* bird: emx */
49
50
51#include <sys/cdefs.h>
52#include <sys/types.h> /* XXX adds too much pollution. */
53/** @todo port FreeBSD sys/unistd.h: #include <sys/unistd.h> */
54#include <sys/_types.h>
55
56#if !defined(_GID_T_DECLARED) && !defined(_GID_T) /* bird: emx */
57typedef __gid_t gid_t; /* group id */
58#define _GID_T_DECLARED
59#define _GID_T /* bird: emx */
60#endif
61
62#if !defined(_OFF_T_DECLARED) && !defined(_OFF_T) /* bird:emx */
63typedef __off_t off_t; /* file offset */
64#define _OFF_T_DECLARED
65#define _OFF_T /* bird: emx */
66#endif
67
68#if !defined(_PID_T_DECLARED) && !defined(_PID_T) /* bird:emx */
69typedef __pid_t pid_t; /* process id */
70#define _PID_T_DECLARED
71#define _PID_T /* bird: emx */
72#endif
73
74#if !defined(_SIZE_T_DECLARED) && !defined(_SIZE_T) /* bird: emx */
75typedef __size_t size_t;
76#define _SIZE_T_DECLARED
77#define _SIZE_T /* bird: emx */
78#endif
79
80#if !defined(_SSIZE_T_DECLARED) && !defined(_SSIZE_T) /* bird: emx */
81typedef __ssize_t ssize_t;
82#define _SSIZE_T_DECLARED
83#define _SSIZE_T /* bird: emx */
84#endif
85
86#if !defined(_UID_T_DECLARED) && !defined(_UID_T) /* bird: emx */
87typedef __uid_t uid_t; /* user id */
88#define _UID_T_DECLARED
89#define _UID_T /* bird: emx */
90#endif
91
92#ifndef _USECONDS_T_DECLARED
93typedef __useconds_t useconds_t; /* microseconds (unsigned) */
94#define _USECONDS_T_DECLARED
95#endif
96
97#if !defined(STDIN_FILENO) /* bird: emx */
98#define STDIN_FILENO 0 /* standard input file descriptor */
99#define STDOUT_FILENO 1 /* standard output file descriptor */
100#define STDERR_FILENO 2 /* standard error file descriptor */
101#endif
102
103#ifndef NULL
104#define NULL 0 /* null pointer constant */
105#endif
106
107#if __XSI_VISIBLE || __POSIX_VISIBLE >= 200112
108#define F_ULOCK 0 /* unlock locked section */
109#define F_LOCK 1 /* lock a section for exclusive use */
110#define F_TLOCK 2 /* test and lock a section for exclusive use */
111#define F_TEST 3 /* test a section for locks by other procs */
112#endif
113
114
115/** @todo: big todo to get in all the POSIX defines. */
116
117#if !defined (F_OK)
118#define F_OK 0
119#define X_OK 1
120#define W_OK 2
121#define R_OK 4
122#endif
123
124#if !defined (SEEK_SET)
125#define SEEK_SET 0
126#define SEEK_CUR 1
127#define SEEK_END 2
128#endif
129
130#if !defined (_PC_LINK_MAX)
131#define _PC_LINK_MAX 1
132#define _PC_MAX_CANON 2
133#define _PC_MAX_INPUT 3
134#define _PC_NAME_MAX 4
135#define _PC_PATH_MAX 5
136#define _PC_PIPE_BUF 6
137#define _PC_CHOWN_RESTRICTED 7
138#define _PC_NO_TRUNC 8
139#define _PC_VDISABLE 9
140#endif
141
142#if !defined (_SC_ARG_MAX)
143#define _SC_ARG_MAX 1
144#define _SC_CHILD_MAX 2
145#define _SC_CLK_TCK 3
146#define _SC_NGROUPS_MAX 4
147#define _SC_OPEN_MAX 5
148#define _SC_STREAM_MAX 6
149#define _SC_TZNAME_MAX 7
150#define _SC_JOB_CONTROL 8
151#define _SC_SAVED_IDS 9
152#define _SC_VERSION 10
153#endif
154
155#if !defined (_POSIX_VERSION)
156#define _POSIX_VERSION 199009L
157#endif
158
159
160__BEGIN_DECLS
161/* 1003.1-1990 */
162void _exit(int) __dead2;
163int access(const char *, int);
164unsigned int alarm(unsigned int);
165int chdir(const char *);
166/** @todo int chown(const char *, uid_t, gid_t); */
167int close(int);
168char * cuserid(char *); /* bird: emx/todo/obosolete? */
169int dup(int);
170int dup2(int, int);
171/** @todo int eaccess(const char *, int); */
172int execl(const char *, const char *, ...);
173int execle(const char *, const char *, ...);
174int execlp(const char *, const char *, ...);
175int execv(const char *, char * const *);
176int execve(const char *, char * const *, char * const *);
177int execvp(const char *, char * const *);
178pid_t fork(void);
179long fpathconf(int, int);
180char *getcwd(char *, size_t);
181gid_t getegid(void);
182uid_t geteuid(void);
183gid_t getgid(void);
184int getgroups(int, gid_t []);
185char *getlogin(void);
186pid_t getpgrp(void);
187pid_t getpid(void);
188pid_t getppid(void);
189uid_t getuid(void);
190int isatty(int);
191/** @todo int link(const char *, const char *);*/
192#ifndef _LSEEK_DECLARED
193#define _LSEEK_DECLARED
194off_t lseek(int, off_t, int);
195#endif
196long pathconf(const char *, int);
197int pause(void);
198int pipe(int *);
199ssize_t read(int, void *, size_t);
200int rmdir(const char *);
201int setgid(gid_t);
202/** @todo void setproctitle(const char *_fmt, ...) __printf0like(1, 2); */
203int setpgid(pid_t, pid_t);
204pid_t setsid(void);
205int setuid(uid_t);
206unsigned sleep(unsigned);
207long sysconf(int);
208pid_t tcgetpgrp(int);
209int tcsetpgrp(int, pid_t);
210char *ttyname(int);
211int unlink(const char *);
212int write(int, const void *, size_t);
213
214/* 1003.2-1992 */
215#if __POSIX_VISIBLE >= 199209 || __XSI_VISIBLE
216/** @todo size_t confstr(int, char *, size_t);*/
217int getopt(int, char * const [], const char *);
218
219extern char *optarg; /* getopt(3) external variables */
220extern int optind, opterr, optopt;
221#endif
222
223/* ISO/IEC 9945-1: 1996 */
224#if __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE
225int fsync(int);
226
227/*
228 * ftruncate() was in the POSIX Realtime Extension (it's used for shared
229 * memory), but truncate() was not.
230 */
231#ifndef _FTRUNCATE_DECLARED
232#define _FTRUNCATE_DECLARED
233int ftruncate(int, off_t);
234#endif
235#endif
236
237#if __POSIX_VISIBLE >= 199506
238/** @todo int getlogin_r(char *, int); */
239#endif
240
241/* 1003.1-2001 */
242#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE
243/** @todo int fchown(int, uid_t, gid_t); */
244/** @todo int readlink(const char *, char *, int); */
245#endif
246#if __POSIX_VISIBLE >= 200112
247/* tcpip: int gethostname(char *, int / * socklen_t * /); */
248/** @todo int setegid(gid_t); */
249/** @todo int seteuid(uid_t); */
250#endif
251
252/*
253 * symlink() was originally in POSIX.1a, which was withdrawn after
254 * being overtaken by events (1003.1-2001). It was in XPG4.2, and of
255 * course has been in BSD since 4.2.
256 */
257#if __POSIX_VISIBLE >= 200112 || __XSI_VISIBLE >= 402 || __BSD_VISIBLE
258/** @todo int symlink(const char * __restrict, const char * __restrict); */
259#endif
260
261/* X/Open System Interfaces */
262#if __XSI_VISIBLE
263/** @todo char *crypt(const char *, const char *); */
264/** @todo char *ctermid(char *); */ /* XXX ??? */
265/** @todo int encrypt(char *, int); */
266/** @todo int fchdir(int); */
267/* tcpip: long gethostid(void); */
268/** @todo int getpgid(pid_t _pid); */
269/** @todo int getsid(pid_t _pid); */
270char *getwd(char *); /* LEGACY: obsoleted by getcwd() */
271/** @todo int lchown(const char *, uid_t, gid_t); */
272int lockf(int, int, off_t);
273/** @todo int nice(int); */
274/** @todo ssize_t pread(int, void *, size_t, off_t); */
275/** @todo ssize_t pwrite(int, const void *, size_t, off_t); */
276/** @todo int setpgrp(pid_t _pid, pid_t _pgrp); */ /* obsoleted by setpgid() */
277/** @todo int setregid(gid_t, gid_t); */
278/** @todo int setreuid(uid_t, uid_t); */
279/* void swab(const void * __restrict, void * __restrict, ssize_t); */
280/** @todo void sync(void); */
281/** @todo useconds_t ualarm(useconds_t, useconds_t); */
282/** @todo int usleep(useconds_t); */
283/** @todo pid_t vfork(void); */
284
285/* See comment at ftruncate() above. */
286#ifndef _TRUNCATE_DECLARED
287#define _TRUNCATE_DECLARED
288int truncate(const char *, off_t);
289#endif
290#endif /* __XSI_VISIBLE */
291
292#if __XSI_VISIBLE <= 500 || __BSD_VISIBLE
293int brk(const void *);
294/** @todo int chroot(const char *); */
295/** @todo int getdtablesize(void); */
296int getpagesize(void) __pure2;
297char *getpass(const char *);
298char *_getpass1(const char *); /* bird: emx stuff */
299char *_getpass2(const char *, int); /* bird: emx stuff */
300void *sbrk(intptr_t);
301#endif
302
303#if __BSD_VISIBLE
304struct timeval; /* select(2) */
305/** @todo int acct(const char *); */
306/** @todo int async_daemon(void); */
307/** @todo int check_utility_compat(const char *); */
308/** @todo const char *
309 crypt_get_format(void); */
310/** @todo int crypt_set_format(const char *); */
311/** @todo int des_cipher(const char *, char *, long, int); */
312/** @todo int des_setkey(const char *key); */
313/** @todo void endusershell(void); */
314/** @todo int exect(const char *, char * const *, char * const *); */
315/** @todo char *fflagstostr(u_long); */
316/** @todo int getdomainname(char *, int); */
317/** @todo int getgrouplist(const char *, gid_t, gid_t *, int *); */
318/** @todo mode_t getmode(const void *, mode_t); */
319/** @todo int getpeereid(int, uid_t *, gid_t *); */
320/** @todo int getresgid(gid_t *, gid_t *, gid_t *); */
321/** @todo int getresuid(uid_t *, uid_t *, uid_t *); */
322/** @todo char *getusershell(void); */
323/** @todo int initgroups(const char *, gid_t); */
324/** @todo int iruserok(unsigned long, int, const char *, const char *); */
325/** @todo int iruserok_sa(const void *, int, int, const char *, const char *); */
326/** @todo int issetugid(void); */
327/** @todo char *mkdtemp(char *); */
328/** @todo int mknod(const char *, mode_t, dev_t); */
329#ifndef _MKSTEMP_DECLARED
330int mkstemp(char *);
331#define _MKSTEMP_DECLARED
332#endif
333/** @todo int mkstemps(char *, int); */
334#ifndef _MKTEMP_DECLARED
335char *mktemp(char *);
336#define _MKTEMP_DECLARED
337#endif
338/** @todo int nfsclnt(int, void *); */
339/** @todo int nfssvc(int, void *); */
340/** @todo int profil(char *, size_t, vm_offset_t, int); */
341/** @todo int rcmd(char **, int, const char *, const char *, const char *, int *); */
342/** @todo int rcmd_af(char **, int, const char *,
343 const char *, const char *, int *, int); */
344/** @todo int rcmdsh(char **, int, const char *,
345 const char *, const char *, const char *); */
346char *re_comp(const char *);
347int re_exec(const char *);
348/** @todo int reboot(int); */
349/** @todo int revoke(const char *); */
350/** @todo pid_t rfork(int); */
351/** @todo pid_t rfork_thread(int, void *, int (*)(void *), void *); */
352/** @todo int rresvport(int *); */
353/** @todo int rresvport_af(int *, int); */
354/** @todo int ruserok(const char *, int, const char *, const char *); */
355#if __BSD_VISIBLE
356#ifndef _SELECT_DECLARED
357#define _SELECT_DECLARED
358int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
359#endif
360#endif
361/** @todo int setdomainname(const char *, int); */
362/** @todo int setgroups(int, const gid_t *); */
363/** @todo void sethostid(long); */
364/** @todo int sethostname(const char *, int); */
365/** @todo #ifndef _SETKEY_DECLARED */
366/** @todo int setkey(const char *); */
367/** @todo #define _SETKEY_DECLARED */
368/** @todo #endif */
369/** @todo int setlogin(const char *); */
370/* crash with DOS: void *setmode(const char *); */
371/** @todo int setresgid(gid_t, gid_t, gid_t); */
372/** @todo int setresuid(uid_t, uid_t, uid_t); */
373/** @todo int setrgid(gid_t); */
374/** @todo int setruid(uid_t); */
375/** @todo void setusershell(void); */
376/** @todo int strtofflags(char **, u_long *, u_long *); */
377/** @todo int swapon(const char *); */
378/** @todo int swapoff(const char *); */
379/** @todo int syscall(int, ...); */
380/** @todo off_t __syscall(quad_t, ...); */
381/** @todo int ttyslot(void); */
382/** @todo int undelete(const char *); */
383/** @todo int unwhiteout(const char *); */
384/** @todo void *valloc(size_t); */ /* obsoleted by malloc() */
385
386/** @todo extern char *suboptarg; */ /* getsubopt(3) external variable */
387/** @todo #ifndef _GETSUBOPT_DECLARED */
388/** @todo int getsubopt(char **, char * const *, char **); */
389/** @todo #define _GETSUBOPT_DECLARED */
390/** @todo #endif */
391extern int optreset; /* getopt(3) external variable */
392#endif /* __BSD_VISIBLE */
393
394
395#if !defined(_POSIX_SOURCE)
396
397
398#endif
399
400
401#if !defined(_POSIX_SOURCE) || defined(_WITH_UNDERSCORE)
402/** @todo update this section to match the one without underscores as far as needed! */
403void __exit(int) __dead2;
404int _access(const char *, int);
405unsigned int _alarm(unsigned int);
406int _chdir(const char *);
407/** @todo int _chown(const char *, uid_t, gid_t); */
408int _close(int);
409char *_cuserid(char *);
410int _dup(int);
411int _dup2(int, int);
412/** @todo int _eaccess(const char *, int); */
413int _execl(const char *, const char *, ...);
414int _execle(const char *, const char *, ...);
415int _execlp(const char *, const char *, ...);
416int _execv(const char *, char * const *);
417int _execve(const char *, char * const *, char * const *);
418int _execvp(const char *, char * const *);
419pid_t _fork(void);
420long _fpathconf(int, int);
421char *_getcwd(char *, size_t);
422gid_t _getegid(void);
423uid_t _geteuid(void);
424gid_t _getgid(void);
425int _getgroups(int, gid_t []);
426char *_getlogin(void);
427pid_t _getpgrp(void);
428pid_t _getpid(void);
429pid_t _getppid(void);
430uid_t _getuid(void);
431int _isatty(int);
432/** @todo int _link(const char *, const char *);*/
433#ifndef __LSEEK_DECLARED
434#define __LSEEK_DECLARED
435off_t _lseek(int, off_t, int);
436#endif
437long _pathconf(const char *, int);
438int _pause(void);
439int _pipe(int *);
440ssize_t _read(int, void *, size_t);
441int _rmdir(const char *);
442int _setgid(gid_t);
443/** @todo void _setproctitle(const char *_fmt, ...) __printf0like(1, 2); */
444int _setpgid(pid_t, pid_t);
445pid_t _setsid(void);
446int _setuid(uid_t);
447unsigned _sleep(unsigned);
448long _sysconf(int);
449pid_t _tcgetpgrp(int);
450pid_t _tcsetpgrp(int, int);
451char *_ttyname(int);
452int _unlink(const char *);
453int _write(int, const void *, size_t);
454
455int _brk(const void *);
456char *_getpass(const char *);
457char *_getpass1(const char *);
458char *_getpass2(const char *, int);
459int _mkstemp(char *);
460char *_mktemp(char *);
461void *_sbrk(intptr_t);
462/** @todo int _profil(void *, unsigned, unsigned, unsigned); */
463
464/* 1003.2-1992 */
465extern char *_optarg;
466extern int _optind;
467extern int _opterr;
468extern int _optopt;
469int _getopt(int, char **, const char *);
470
471#endif
472
473/* Toolkit compatibility */
474#ifndef TCPCALL
475#define TCPCALL _System
476#endif
477
478#include <sys/cdefs.h>
479#include <sys/types.h>
480int TCPCALL soclose(int);
481#ifndef _POSIX_SOURCE
482int TCPCALL gethostid(void);
483int TCPCALL gethostname(char *, int);
484#ifndef TCPV40HDRS
485int TCPCALL iruserok(unsigned long, int, const char *, const char *);
486int TCPCALL rcmd(char **, int, const char *, const char *, const char *, int *);
487int TCPCALL rresvport(int *);
488int TCPCALL ruserok(const char *, int, const char *, const char *);
489#include <sys/select.h>
490#endif /* !TCP40HDRS */
491#endif /* !_POSIX_SOURCE */
492
493__END_DECLS
494
495#endif /* not _UNISTD_H */
Note: See TracBrowser for help on using the repository browser.