fixed code to determine file inode - should work now
[reactos.git] / posix / include / unistd.h
1 /* $Id: unistd.h,v 1.2 2002/02/20 09:17:55 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 /* Test for read permission. */
254 #define R_OK (0x00000001)
255 /* Test for write permission. */
256 #define W_OK (0x00000002)
257 /* Test for execute (search) permission. */
258 #define X_OK (0x00000004)
259 /* Test for existence of file. */
260 #define F_OK (0)
261
262 /*
263 constants for the confstr() function
264 */
265 #define _CS_PATH (1)
266 #define _CS_XBS5_ILP32_OFF32_CFLAGS (2)
267 #define _CS_XBS5_ILP32_OFF32_LDFLAGS (3)
268 #define _CS_XBS5_ILP32_OFF32_LIBS (4)
269 #define _CS_XBS5_ILP32_OFF32_LINTFLAGS (5)
270 #define _CS_XBS5_ILP32_OFFBIG_CFLAGS (6)
271 #define _CS_XBS5_ILP32_OFFBIG_LDFLAGS (7)
272 #define _CS_XBS5_ILP32_OFFBIG_LIBS (8)
273 #define _CS_XBS5_ILP32_OFFBIG_LINTFLAGS (9)
274 #define _CS_XBS5_LP64_OFF64_CFLAGS (10)
275 #define _CS_XBS5_LP64_OFF64_LDFLAGS (11)
276 #define _CS_XBS5_LP64_OFF64_LIBS (12)
277 #define _CS_XBS5_LP64_OFF64_LINTFLAGS (13)
278 #define _CS_XBS5_LPBIG_OFFBIG_CFLAGS (14)
279 #define _CS_XBS5_LPBIG_OFFBIG_LDFLAGS (15)
280 #define _CS_XBS5_LPBIG_OFFBIG_LIBS (16)
281 #define _CS_XBS5_LPBIG_OFFBIG_LINTFLAGS (17)
282
283 /*
284 constants for the lseek() and fcntl() functions
285 */
286
287 #define SEEK_SET (1) /* Set file offset to offset. */
288 #define SEEK_CUR (2) /* Set file offset to current plus offset. */
289 #define SEEK_END (3) /* Set file offset to EOF plus offset. */
290
291 /*
292 constants for sysconf()
293 */
294 #define _SC_2_C_BIND (1)
295 #define _SC_2_C_DEV (2)
296 #define _SC_2_C_VERSION (3)
297 #define _SC_2_FORT_DEV (4)
298 #define _SC_2_FORT_RUN (5)
299 #define _SC_2_LOCALEDEF (6)
300 #define _SC_2_SW_DEV (7)
301 #define _SC_2_UPE (8)
302 #define _SC_2_VERSION (9)
303 #define _SC_ARG_MAX (10)
304 #define _SC_AIO_LISTIO_MAX (11)
305 #define _SC_AIO_MAX (12)
306 #define _SC_AIO_PRIO_DELTA_MAX (13)
307 #define _SC_ASYNCHRONOUS_IO (14)
308 #define _SC_ATEXIT_MAX (15)
309 #define _SC_BC_BASE_MAX (16)
310 #define _SC_BC_DIM_MAX (17)
311 #define _SC_BC_SCALE_MAX (18)
312 #define _SC_BC_STRING_MAX (19)
313 #define _SC_CHILD_MAX (20)
314 #define _SC_CLK_TCK (21)
315 #define _SC_COLL_WEIGHTS_MAX (22)
316 #define _SC_DELAYTIMER_MAX (23)
317 #define _SC_EXPR_NEST_MAX (24)
318 #define _SC_FSYNC (25)
319 #define _SC_GETGR_R_SIZE_MAX (26)
320 #define _SC_GETPW_R_SIZE_MAX (27)
321 #define _SC_IOV_MAX (28)
322 #define _SC_JOB_CONTROL (29)
323 #define _SC_LINE_MAX (30)
324 #define _SC_LOGIN_NAME_MAX (31)
325 #define _SC_MAPPED_FILES (32)
326 #define _SC_MEMLOCK (33)
327 #define _SC_MEMLOCK_RANGE (34)
328 #define _SC_MEMORY_PROTECTION (35)
329 #define _SC_MESSAGE_PASSING (36)
330 #define _SC_MQ_OPEN_MAX (37)
331 #define _SC_MQ_PRIO_MAX (38)
332 #define _SC_NGROUPS_MAX (39)
333 #define _SC_OPEN_MAX (40)
334 #define _SC_PAGE_SIZE (41)
335 #define _SC_PASS_MAX (42) /* LEGACY */
336 #define _SC_PRIORITIZED_IO (43)
337 #define _SC_PRIORITY_SCHEDULING (44)
338 #define _SC_RE_DUP_MAX (45)
339 #define _SC_REALTIME_SIGNALS (46)
340 #define _SC_RTSIG_MAX (47)
341 #define _SC_SAVED_IDS (48)
342 #define _SC_SEMAPHORES (49)
343 #define _SC_SEM_NSEMS_MAX (50)
344 #define _SC_SEM_VALUE_MAX (51)
345 #define _SC_SHARED_MEMORY_OBJECTS (52)
346 #define _SC_SIGQUEUE_MAX (53)
347 #define _SC_STREAM_MAX (54)
348 #define _SC_SYNCHRONIZED_IO (55)
349 #define _SC_THREADS (56)
350 #define _SC_THREAD_ATTR_STACKADDR (57)
351 #define _SC_THREAD_ATTR_STACKSIZE (58)
352 #define _SC_THREAD_DESTRUCTOR_ITERATIONS (59)
353 #define _SC_THREAD_KEYS_MAX (60)
354 #define _SC_THREAD_PRIORITY_SCHEDULING (61)
355 #define _SC_THREAD_PRIO_INHERIT (62)
356 #define _SC_THREAD_PRIO_PROTECT (63)
357 #define _SC_THREAD_PROCESS_SHARED (64)
358 #define _SC_THREAD_SAFE_FUNCTIONS (65)
359 #define _SC_THREAD_STACK_MIN (66)
360 #define _SC_THREAD_THREADS_MAX (67)
361 #define _SC_TIMERS (68)
362 #define _SC_TIMER_MAX (69)
363 #define _SC_TTY_NAME_MAX (70)
364 #define _SC_TZNAME_MAX (71)
365 #define _SC_VERSION (72)
366 #define _SC_XOPEN_VERSION (73)
367 #define _SC_XOPEN_CRYPT (74)
368 #define _SC_XOPEN_ENH_I18N (75)
369 #define _SC_XOPEN_SHM (76)
370 #define _SC_XOPEN_UNIX (77)
371 #define _SC_XOPEN_XCU_VERSION (78)
372 #define _SC_XOPEN_LEGACY (79)
373 #define _SC_XOPEN_REALTIME (80)
374 #define _SC_XOPEN_REALTIME_THREADS (81)
375 #define _SC_XBS5_ILP32_OFF32 (82)
376 #define _SC_XBS5_ILP32_OFFBIG (83)
377 #define _SC_XBS5_LP64_OFF64 (84)
378 #define _SC_XBS5_LPBIG_OFFBIG (85)
379
380 #define _SC_PAGESIZE _SC_PAGE_SIZE
381
382 /* possible values for the function argument to the lockf() function */
383 /* Lock a section for exclusive use. */
384 #define F_LOCK (1)
385 /* Unlock locked sections. */
386 #define F_ULOCK (2)
387 /* Test section for locks by other processes. */
388 #define F_TEST (3)
389 /* Test and lock a section for exclusive use. */
390 #define F_TLOCK (4)
391
392 /* File number of stdin. It is 0. */
393 #define STDIN_FILENO (0)
394 /* File number of stdout. It is 1. */
395 #define STDOUT_FILENO (1)
396 /* File number of stderr. It is 2. */
397 #define STDERR_FILENO (2)
398
399 /* PROTOTYPES */
400 int access(const char *, int);
401 unsigned int alarm(unsigned int);
402 int brk(void *);
403 int chdir(const char *);
404 int chroot(const char *); /* LEGACY */
405 int chown(const char *, uid_t, gid_t);
406 int close(int);
407 size_t confstr(int, char *, size_t);
408 char *crypt(const char *, const char *);
409 char *ctermid(char *);
410 char *cuserid(char *s); /* LEGACY */
411 int dup(int);
412 int dup2(int, int);
413 void encrypt(char[64], int);
414 int execl(const char *, const char *, ...);
415 int execle(const char *, const char *, ...);
416 int execlp(const char *, const char *, ...);
417 int execv(const char *, char *const []);
418 int execve(const char *, char *const [], char *const []);
419 int execvp(const char *, char *const []);
420 void _exit(int);
421 int fchown(int, uid_t, gid_t);
422 int fchdir(int);
423 int fdatasync(int);
424 pid_t fork(void);
425 long int fpathconf(int, int);
426 int fsync(int);
427 int ftruncate(int, off_t);
428 char *getcwd(char *, size_t);
429 int getdtablesize(void); /* LEGACY */
430 gid_t getegid(void);
431 uid_t geteuid(void);
432 gid_t getgid(void);
433 int getgroups(int, gid_t []);
434 long gethostid(void);
435 char *getlogin(void);
436 int getlogin_r(char *, size_t);
437 int getopt(int, char * const [], const char *);
438 int getpagesize(void); /* LEGACY */
439 char *getpass(const char *); /* LEGACY */
440 pid_t getpgid(pid_t);
441 pid_t getpgrp(void);
442 pid_t getpid(void);
443 pid_t getppid(void);
444 pid_t getsid(pid_t);
445 uid_t getuid(void);
446 char *getwd(char *);
447 int isatty(int);
448 int lchown(const char *, uid_t, gid_t);
449 int link(const char *, const char *);
450 int lockf(int, int, off_t);
451 off_t lseek(int, off_t, int);
452 int nice(int);
453 long int pathconf(const char *, int);
454 int pause(void);
455 int pipe(int [2]);
456 ssize_t pread(int, void *, size_t, off_t);
457 int pthread_atfork(void (*)(void), void (*)(void),
458 void(*)(void));
459 ssize_t pwrite(int, const void *, size_t, off_t);
460 ssize_t read(int, void *, size_t);
461 int readlink(const char *, char *, size_t);
462 int rmdir(const char *);
463 void *sbrk(intptr_t);
464 int setgid(gid_t);
465 int setpgid(pid_t, pid_t);
466 pid_t setpgrp(void);
467 int setregid(gid_t, gid_t);
468 int setreuid(uid_t, uid_t);
469 pid_t setsid(void);
470 int setuid(uid_t);
471 unsigned int sleep(unsigned int);
472 void swab(const void *, void *, ssize_t);
473 int symlink(const char *, const char *);
474 void sync(void);
475 long int sysconf(int);
476 pid_t tcgetpgrp(int);
477 int tcsetpgrp(int, pid_t);
478 int truncate(const char *, off_t);
479 char *ttyname(int);
480 int ttyname_r(int, char *, size_t);
481 useconds_t ualarm(useconds_t, useconds_t);
482 int unlink(const char *);
483 int usleep(useconds_t);
484 pid_t vfork(void);
485 ssize_t write(int, const void *, size_t);
486
487 /* MACROS */
488
489 #endif /* __UNISTD_H_INCLUDED__ */
490
491 /* EOF */
492