some types and constants modified for compatibility with Microsoft POSIX
[reactos.git] / posix / include / unistd.h
1 /* $Id: unistd.h,v 1.3 2002/03/22 01:26:28 hyperion Exp $
2 */
3 /*
4 * unistd.h
5 *
6 * standard symbolic constants and types. Conforming to the Single UNIX(r)
7 * Specification Version 2, System Interface & Headers Issue 5
8 *
9 * This file is part of the ReactOS Operating System.
10 *
11 * Contributors:
12 * Created by KJK::Hyperion <noog@libero.it>
13 *
14 * THIS SOFTWARE IS NOT COPYRIGHTED
15 *
16 * This source code is offered for use in the public domain. You may
17 * use, modify or distribute it freely.
18 *
19 * This code is distributed in the hope that it will be useful but
20 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
21 * DISCLAMED. This includes but is not limited to warranties of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23 *
24 */
25 #ifndef __UNISTD_H_INCLUDED__
26 #define __UNISTD_H_INCLUDED__
27
28 /* INCLUDES */
29 #include <sys/types.h>
30 #include <stdio.h>
31 #include <inttypes.h>
32
33 /* OBJECTS */
34 extern char *optarg;
35 extern int optind, opterr, optopt;
36
37 /* TYPES */
38
39 /* CONSTANTS */
40 /* FIXME: set these constants appropriately */
41 /* Integer value indicating version of the ISO POSIX-1 standard (C
42 language binding). */
43 #define _POSIX_VERSION (0)
44
45 /* Integer value indicating version of the ISO POSIX-2 standard
46 (Commands). */
47 #define _POSIX2_VERSION (0)
48
49 /* Integer value indicating version of the ISO POSIX-2 standard (C
50 language binding). */
51 #define _POSIX2_C_VERSION (0)
52
53 /* Integer value indicating version of the X/Open Portability Guide to
54 which the implementation conforms. */
55 #define _XOPEN_VERSION (500)
56
57 /* The version of the XCU specification to which the implementation
58 conforms */
59 /* TODO: set to an appropriate value when commands and utilities will
60 be available */
61 #define _XOPEN_XCU_VERSION (-1)
62
63 #if _XOPEN_XCU_VERSION != -1
64 #error TODO: define these constants
65 #define _POSIX2_C_BIND
66 #define _POSIX2_C_VERSION
67 #define _POSIX2_CHAR_TERM
68 #define _POSIX2_LOCALEDEF
69 #define _POSIX2_UPE
70 #define _POSIX2_VERSION
71 #endif
72
73 #if 0
74 /* TODO: check for conformance to the following specs */
75 #define _XOPEN_XPG2
76 #define _XOPEN_XPG3
77 #define _XOPEN_XPG4
78 #define _XOPEN_UNIX
79 #endif
80
81 #if 0
82 /* TODO: don't forget these features */
83 /* The use of chown() is restricted to a process with appropriate
84 privileges, and to changing the group ID of a file only to the
85 effective group ID of the process or to one of its supplementary
86 group IDs. */
87 #define _POSIX_CHOWN_RESTRICTED
88
89 /* Terminal special characters defined in <termios.h> can be disabled
90 using this character value. */
91 #define _POSIX_VDISABLE
92
93 /* Each process has a saved set-user-ID and a saved set-group-ID. */
94 #define _POSIX_SAVED_IDS
95
96 /* Implementation supports job control. */
97 #define _POSIX_JOB_CONTROL
98
99 #endif
100
101 /* Pathname components longer than {NAME_MAX} generate an error. */
102 #define _POSIX_NO_TRUNC (1)
103
104 /* The implementation supports the threads option. */
105 #define _POSIX_THREADS (1)
106
107 /* FIXME: none of the following is strictly true yet */
108 /* The implementation supports the thread stack address attribute
109 option. */ /* FIXME: not currently implemented. Should be trivial */
110 #define _POSIX_THREAD_ATTR_STACKADDR (1)
111
112 /* The implementation supports the thread stack size attribute
113 option. */ /* FIXME: not currently implemented. Should be trivial */
114 #define _POSIX_THREAD_ATTR_STACKSIZE (1)
115
116 /* The implementation supports the process-shared synchronisation
117 option. */ /* FIXME? not sure */
118 #define _POSIX_THREAD_PROCESS_SHARED (1)
119
120 /* The implementation supports the thread-safe functions option. */
121 /* FIXME: fix errno (currently not thread-safe) */
122 #define _POSIX_THREAD_SAFE_FUNCTIONS (1)
123
124 /*
125  Constants for Options and Feature Groups
126 */
127
128 /* Implementation supports the C Language Binding option. This will
129 always have a value other than -1. */
130 #define _POSIX2_C_BIND (1)
131
132 /* Implementation supports the C Language Development Utilities
133 option. */ /* FIXME: please change this when C compiler and
134 utilities are ported */
135 #define _POSIX2_C_DEV (-1)
136
137 /* Implementation supports at least one terminal type. */ /* FIXME:
138 please change this when terminal emulation is complete */
139 #define _POSIX2_CHAR_TERM (-1)
140
141 /* Implementation supports the FORTRAN Development Utilities option. */
142 /* FIXME: please change this when Fortran compiler and utilities are
143 ported */
144 #define _POSIX2_FORT_DEV (-1)
145
146 /* Implementation supports the FORTRAN Run-time Utilities option. */
147 /* FIXME: please change this when Fortran runtimes are ported */
148 #define _POSIX2_FORT_RUN (-1)
149
150 /* Implementation supports the creation of locales by the localedef
151 utility. */ /* FIXME: please change this when locales are ready */
152 #define _POSIX2_LOCALEDEF (-1)
153
154 /* Implementation supports the Software Development Utilities option. */
155 /* FIXME? */
156 #define _POSIX2_SW_DEV (-1)
157
158 /* The implementation supports the User Portability Utilities option. */
159 /* FIXME? */
160 #define _POSIX2_UPE (-1)
161
162 /* The implementation supports the X/Open Encryption Feature Group. */
163 /* FIXME: please change this when encryption is ready */
164 #define _XOPEN_CRYPT (-1)
165
166 /* The implementation supports the Issue 4, Version 2 Enhanced
167 Internationalisation Feature Group. This is always set to a value
168 other than -1. */ /* TODO: high priority. Support for this feature is
169 needed for a conforming implementation */
170 #define _XOPEN_ENH_I18N (-1)
171
172 /* The implementation supports the Legacy Feature Group. */
173 #define _XOPEN_LEGACY (1)
174
175 /* The implementation supports the X/Open Realtime Feature Group. */
176 /* FIXME? unlikely to be ever supported */
177 #define _XOPEN_REALTIME (-1)
178
179 /* The implementation supports the X/Open Realtime Threads Feature
180 Group. */ /* FIXME? really unlikely to be ever supported */
181 #define _XOPEN_REALTIME_THREADS (-1)
182
183 /* The implementation supports the Issue 4, Version 2 Shared Memory
184 Feature Group. This is always set to a value other than -1. */ /* TODO:
185 high priority. Support for this feature is needed for a conforming
186 implementation */
187 #define _XOPEN_SHM (-1)
188
189 /* Implementation provides a C-language compilation environment with
190 32-bit int, long, pointer and off_t types. */
191 #define _XBS5_ILP32_OFF32 (1)
192
193 /* Implementation provides a C-language compilation environment with
194 32-bit int, long and pointer types and an off_t type using at
195 least 64 bits. */ /* FIXME? check the off_t type */
196 #define _XBS5_ILP32_OFFBIG (1)
197
198 /* Implementation provides a C-language compilation environment with
199 32-bit int and 64-bit long, pointer and off_t types. */ /* FIXME: on
200 some architectures this may be true */
201 #define _XBS5_LP64_OFF64 (-1)
202
203 /* Implementation provides a C-language compilation environment with
204 an int type using at least 32 bits and long, pointer and off_t
205 types using at least 64 bits. */ /* FIXME: on some architectures
206 this may be true */
207 #define _XBS5_LPBIG_OFFBIG (-1)
208
209 /* Implementation supports the File Synchronisation option. */
210 /* TODO: high priority. Implement this */
211 #define _POSIX_FSYNC
212
213 /* Implementation supports the Memory Mapped Files option. */
214 /* TODO: high priority. Implement this */
215 #define _POSIX_MAPPED_FILES
216
217 /* Implementation supports the Memory Protection option. */
218 /* TODO: high priority. Implement this */
219 #define _POSIX_MEMORY_PROTECTION
220
221 #if 0
222 /* Implementation supports the Prioritized Input and Output option. */
223 /* FIXME? unlikely to be ever supported */
224 #define _POSIX_PRIORITIZED_IO
225 #endif
226
227 /* FIXME: these should be implemented */
228 /* Asynchronous input or output operations may be performed for the
229 associated file. */
230 #define _POSIX_ASYNC_IO (-1)
231
232 /* Prioritized input or output operations may be performed for the
233 associated file. */
234 #define _POSIX_PRIO_IO (-1)
235
236 /* Synchronised input or output operations may be performed for the
237 associated file. */
238 #define _POSIX_SYNC_IO (-1)
239
240 /*
241 null pointer
242 */
243 #ifndef NULL
244 /* NULL seems to be defined pretty much everywhere - we prevent
245 redefinition */
246 #define NULL ((void *)(0))
247 #endif
248
249 /*
250 constants for the access() function
251 */
252
253 #define R_OK (0x00000004) /* Test for read permission. */
254 #define W_OK (0x00000002) /* Test for write permission. */
255 #define X_OK (0x00000001) /* Test for execute (search) permission. */
256 #define F_OK (0) /* Test for existence of file. */
257
258 /*
259 constants for the confstr() function
260 */
261 #define _CS_PATH (1)
262 #define _CS_XBS5_ILP32_OFF32_CFLAGS (2)
263 #define _CS_XBS5_ILP32_OFF32_LDFLAGS (3)
264 #define _CS_XBS5_ILP32_OFF32_LIBS (4)
265 #define _CS_XBS5_ILP32_OFF32_LINTFLAGS (5)
266 #define _CS_XBS5_ILP32_OFFBIG_CFLAGS (6)
267 #define _CS_XBS5_ILP32_OFFBIG_LDFLAGS (7)
268 #define _CS_XBS5_ILP32_OFFBIG_LIBS (8)
269 #define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS (9)
270 #define _CS_XBS5_LP64_OFF64_CFLAGS (10)
271 #define _CS_XBS5_LP64_OFF64_LDFLAGS (11)
272 #define _CS_XBS5_LP64_OFF64_LIBS (12)
273 #define _CS_XBS5_LP64_OFF64_LINTFLAGS (13)
274 #define _CS_XBS5_LPBIG_OFFBIG_CFLAGS (14)
275 #define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS (15)
276 #define _CS_XBS5_LPBIG_OFFBIG_LIBS (16)
277 #define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS (17)
278
279 /*
280 constants for the lseek() and fcntl() functions
281 */
282
283 #define SEEK_SET (0) /* Set file offset to offset. */
284 #define SEEK_CUR (1) /* Set file offset to current plus offset. */
285 #define SEEK_END (2) /* Set file offset to EOF plus offset. */
286
287 /*
288 constants for pathconf()
289 */
290 /* constants 1 to 9 are the same as in Microsoft POSIX */
291 #define _PC_LINK_MAX ( 1)
292 #define _PC_MAX_CANON ( 2)
293 #define _PC_MAX_INPUT ( 3)
294 #define _PC_NAME_MAX ( 4)
295 #define _PC_PATH_MAX ( 5)
296 #define _PC_PIPE_BUF ( 6)
297 #define _PC_CHOWN_RESTRICTED ( 7)
298 #define _PC_NO_TRUNC ( 8)
299 #define _PC_VDISABLE ( 9)
300 /* from this point, constants are in no particular order */
301 #define _PC_ALLOC_SIZE_MIN ( 10)
302 #define _PC_ASYNC_IO ( 11)
303 #define _PC_FILESIZEBITS ( 12)
304 #define _PC_PRIO_IO ( 13)
305 #define _PC_REC_INCR_XFER_SIZE ( 14)
306 #define _PC_REC_MAX_XFER_SIZE ( 15)
307 #define _PC_REC_MIN_XFER_SIZE ( 16)
308 #define _PC_REC_XFER_ALIGN ( 17)
309 #define _PC_SYNC_IO ( 18)
310
311 /*
312 constants for sysconf()
313 */
314 /* constants 1 to 10 are the same as in Microsoft POSIX */
315 #define _SC_ARG_MAX ( 1)
316 #define _SC_CHILD_MAX ( 2)
317 #define _SC_CLK_TCK ( 3)
318 #define _SC_NGROUPS_MAX ( 4)
319 #define _SC_OPEN_MAX ( 5)
320 #define _SC_JOB_CONTROL ( 6)
321 #define _SC_SAVED_IDS ( 7)
322 #define _SC_STREAM_MAX ( 8)
323 #define _SC_TZNAME_MAX ( 9)
324 #define _SC_VERSION ( 10)
325 /* from this point, constants are in no particular order */
326 #define _SC_2_C_BIND ( 11)
327 #define _SC_2_C_DEV ( 12)
328 #define _SC_2_C_VERSION ( 13)
329 #define _SC_2_FORT_DEV ( 14)
330 #define _SC_2_FORT_RUN ( 15)
331 #define _SC_2_LOCALEDEF ( 16)
332 #define _SC_2_SW_DEV ( 17)
333 #define _SC_2_UPE ( 18)
334 #define _SC_2_VERSION ( 19)
335 #define _SC_AIO_LISTIO_MAX ( 20)
336 #define _SC_AIO_MAX ( 21)
337 #define _SC_AIO_PRIO_DELTA_MAX ( 22)
338 #define _SC_ASYNCHRONOUS_IO ( 23)
339 #define _SC_ATEXIT_MAX ( 24)
340 #define _SC_BC_BASE_MAX ( 25)
341 #define _SC_BC_DIM_MAX ( 26)
342 #define _SC_BC_SCALE_MAX ( 27)
343 #define _SC_BC_STRING_MAX ( 28)
344 #define _SC_COLL_WEIGHTS_MAX ( 29)
345 #define _SC_DELAYTIMER_MAX ( 30)
346 #define _SC_EXPR_NEST_MAX ( 31)
347 #define _SC_FSYNC ( 32)
348 #define _SC_GETGR_R_SIZE_MAX ( 33)
349 #define _SC_GETPW_R_SIZE_MAX ( 34)
350 #define _SC_IOV_MAX ( 35)
351 #define _SC_LINE_MAX ( 36)
352 #define _SC_LOGIN_NAME_MAX ( 37)
353 #define _SC_MAPPED_FILES ( 38)
354 #define _SC_MEMLOCK ( 39)
355 #define _SC_MEMLOCK_RANGE ( 40)
356 #define _SC_MEMORY_PROTECTION ( 41)
357 #define _SC_MESSAGE_PASSING ( 42)
358 #define _SC_MQ_OPEN_MAX ( 43)
359 #define _SC_MQ_PRIO_MAX ( 44)
360 #define _SC_PAGE_SIZE ( 45)
361 #define _SC_PASS_MAX ( 46) /* LEGACY */
362 #define _SC_PRIORITIZED_IO ( 47)
363 #define _SC_PRIORITY_SCHEDULING ( 48)
364 #define _SC_RE_DUP_MAX ( 49)
365 #define _SC_REALTIME_SIGNALS ( 50)
366 #define _SC_RTSIG_MAX ( 51)
367 #define _SC_SEMAPHORES ( 52)
368 #define _SC_SEM_NSEMS_MAX ( 53)
369 #define _SC_SEM_VALUE_MAX ( 54)
370 #define _SC_SHARED_MEMORY_OBJECTS ( 55)
371 #define _SC_SIGQUEUE_MAX ( 56)
372 #define _SC_SYNCHRONIZED_IO ( 57)
373 #define _SC_THREADS ( 58)
374 #define _SC_THREAD_ATTR_STACKADDR ( 59)
375 #define _SC_THREAD_ATTR_STACKSIZE ( 60)
376 #define _SC_THREAD_DESTRUCTOR_ITERATIONS ( 61)
377 #define _SC_THREAD_KEYS_MAX ( 62)
378 #define _SC_THREAD_PRIORITY_SCHEDULING ( 63)
379 #define _SC_THREAD_PRIO_INHERIT ( 64)
380 #define _SC_THREAD_PRIO_PROTECT ( 65)
381 #define _SC_THREAD_PROCESS_SHARED ( 66)
382 #define _SC_THREAD_SAFE_FUNCTIONS ( 67)
383 #define _SC_THREAD_STACK_MIN ( 68)
384 #define _SC_THREAD_THREADS_MAX ( 69)
385 #define _SC_TIMERS ( 70)
386 #define _SC_TIMER_MAX ( 71)
387 #define _SC_TTY_NAME_MAX ( 72)
388 #define _SC_XOPEN_VERSION ( 73)
389 #define _SC_XOPEN_CRYPT ( 74)
390 #define _SC_XOPEN_ENH_I18N ( 75)
391 #define _SC_XOPEN_SHM ( 76)
392 #define _SC_XOPEN_UNIX ( 77)
393 #define _SC_XOPEN_XCU_VERSION ( 78)
394 #define _SC_XOPEN_LEGACY ( 79)
395 #define _SC_XOPEN_REALTIME ( 80)
396 #define _SC_XOPEN_REALTIME_THREADS ( 81)
397 #define _SC_XBS5_ILP32_OFF32 ( 82)
398 #define _SC_XBS5_ILP32_OFFBIG ( 83)
399 #define _SC_XBS5_LP64_OFF64 ( 84)
400 #define _SC_XBS5_LPBIG_OFFBIG ( 85)
401
402
403 #define _SC_PAGESIZE _SC_PAGE_SIZE
404
405 /* possible values for the function argument to the lockf() function */
406 #define F_LOCK (1) /* Lock a section for exclusive use. */
407 #define F_ULOCK (2) /* Unlock locked sections. */
408 #define F_TEST (3) /* Test section for locks by other processes. */
409 #define F_TLOCK (4) /* Test and lock a section for exclusive use. */
410
411 #define STDIN_FILENO (0) /* File number of stdin. */
412 #define STDOUT_FILENO (1) /* File number of stdout. */
413 #define STDERR_FILENO (2) /* File number of stderr. */
414
415 /* PROTOTYPES */
416 int access(const char *, int);
417 unsigned int alarm(unsigned int);
418 int brk(void *);
419 int chdir(const char *);
420 int chroot(const char *); /* LEGACY */
421 int chown(const char *, uid_t, gid_t);
422 int close(int);
423 size_t confstr(int, char *, size_t);
424 char *crypt(const char *, const char *);
425 char *ctermid(char *);
426 char *cuserid(char *s); /* LEGACY */
427 int dup(int);
428 int dup2(int, int);
429 void encrypt(char[64], int);
430 int execl(const char *, const char *, ...);
431 int execle(const char *, const char *, ...);
432 int execlp(const char *, const char *, ...);
433 int execv(const char *, char *const []);
434 int execve(const char *, char *const [], char *const []);
435 int execvp(const char *, char *const []);
436 void _exit(int);
437 int fchown(int, uid_t, gid_t);
438 int fchdir(int);
439 int fdatasync(int);
440 pid_t fork(void);
441 long int fpathconf(int, int);
442 int fsync(int);
443 int ftruncate(int, off_t);
444 char *getcwd(char *, size_t);
445 int getdtablesize(void); /* LEGACY */
446 gid_t getegid(void);
447 uid_t geteuid(void);
448 gid_t getgid(void);
449 int getgroups(int, gid_t []);
450 long gethostid(void);
451 char *getlogin(void);
452 int getlogin_r(char *, size_t);
453 int getopt(int, char * const [], const char *);
454 int getpagesize(void); /* LEGACY */
455 char *getpass(const char *); /* LEGACY */
456 pid_t getpgid(pid_t);
457 pid_t getpgrp(void);
458 pid_t getpid(void);
459 pid_t getppid(void);
460 pid_t getsid(pid_t);
461 uid_t getuid(void);
462 char *getwd(char *);
463 int isatty(int);
464 int lchown(const char *, uid_t, gid_t);
465 int link(const char *, const char *);
466 int lockf(int, int, off_t);
467 off_t lseek(int, off_t, int);
468 int nice(int);
469 long int pathconf(const char *, int);
470 int pause(void);
471 int pipe(int [2]);
472 ssize_t pread(int, void *, size_t, off_t);
473 int pthread_atfork(void (*)(void), void (*)(void),
474 void(*)(void));
475 ssize_t pwrite(int, const void *, size_t, off_t);
476 ssize_t read(int, void *, size_t);
477 int readlink(const char *, char *, size_t);
478 int rmdir(const char *);
479 void *sbrk(intptr_t);
480 int setgid(gid_t);
481 int setpgid(pid_t, pid_t);
482 pid_t setpgrp(void);
483 int setregid(gid_t, gid_t);
484 int setreuid(uid_t, uid_t);
485 pid_t setsid(void);
486 int setuid(uid_t);
487 unsigned int sleep(unsigned int);
488 void swab(const void *, void *, ssize_t);
489 int symlink(const char *, const char *);
490 void sync(void);
491 long int sysconf(int);
492 pid_t tcgetpgrp(int);
493 int tcsetpgrp(int, pid_t);
494 int truncate(const char *, off_t);
495 char *ttyname(int);
496 int ttyname_r(int, char *, size_t);
497 useconds_t ualarm(useconds_t, useconds_t);
498 int unlink(const char *);
499 int usleep(useconds_t);
500 pid_t vfork(void);
501 ssize_t write(int, const void *, size_t);
502
503 /* MACROS */
504
505 #endif /* __UNISTD_H_INCLUDED__ */
506
507 /* EOF */
508