[a16210b5] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Jiri Zarevucky
|
---|
[4f4b4e7] | 3 | * Copyright (c) 2011 Petr Koupy
|
---|
[a16210b5] | 4 | * All rights reserved.
|
---|
| 5 | *
|
---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
---|
| 7 | * modification, are permitted provided that the following conditions
|
---|
| 8 | * are met:
|
---|
| 9 | *
|
---|
| 10 | * - Redistributions of source code must retain the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | * documentation and/or other materials provided with the distribution.
|
---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
---|
| 16 | * derived from this software without specific prior written permission.
|
---|
| 17 | *
|
---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | */
|
---|
[4f4b4e7] | 29 |
|
---|
| 30 | /** @addtogroup libposix
|
---|
| 31 | * @{
|
---|
| 32 | */
|
---|
| 33 | /** @file
|
---|
| 34 | */
|
---|
| 35 |
|
---|
[a16210b5] | 36 | #ifndef POSIX_UNISTD_H_
|
---|
| 37 | #define POSIX_UNISTD_H_
|
---|
| 38 |
|
---|
| 39 | #include "libc/unistd.h"
|
---|
[59f799b] | 40 | #include "sys/types.h"
|
---|
[a16210b5] | 41 |
|
---|
[4f4b4e7] | 42 | /* Process Termination */
|
---|
| 43 | #define _exit exit
|
---|
[a16210b5] | 44 |
|
---|
[4f4b4e7] | 45 | /* Option Arguments */
|
---|
[a16210b5] | 46 | extern char *optarg;
|
---|
| 47 | extern int optind, opterr, optopt;
|
---|
| 48 | extern int getopt(int, char * const [], const char *);
|
---|
| 49 |
|
---|
[244d6fd] | 50 | /* Environment */
|
---|
[b4d6252] | 51 | extern char **posix_environ;
|
---|
| 52 |
|
---|
[244d6fd] | 53 | extern char *posix_getlogin(void);
|
---|
| 54 | extern int posix_getlogin_r(char *name, size_t namesize);
|
---|
| 55 |
|
---|
[4f4b4e7] | 56 | /* Identifying Terminals */
|
---|
| 57 | extern int posix_isatty(int fd);
|
---|
[a16210b5] | 58 |
|
---|
[72ec8cc] | 59 | /* Query Memory Parameters */
|
---|
| 60 | extern int posix_getpagesize(void);
|
---|
| 61 |
|
---|
[4f4b4e7] | 62 | /* Process Identification */
|
---|
[823a929] | 63 | extern posix_pid_t posix_getpid(void);
|
---|
[59f799b] | 64 | extern posix_uid_t posix_getuid(void);
|
---|
| 65 | extern posix_gid_t posix_getgid(void);
|
---|
[a16210b5] | 66 |
|
---|
[4f4b4e7] | 67 | /* Standard Streams */
|
---|
| 68 | #undef STDIN_FILENO
|
---|
[a16210b5] | 69 | #define STDIN_FILENO (fileno(stdin))
|
---|
[4f4b4e7] | 70 | #undef STDOUT_FILENO
|
---|
[a16210b5] | 71 | #define STDOUT_FILENO (fileno(stdout))
|
---|
[4f4b4e7] | 72 | #undef STDERR_FILENO
|
---|
[a16210b5] | 73 | #define STDERR_FILENO (fileno(stderr))
|
---|
| 74 |
|
---|
[b08ef1fd] | 75 | /* File Accessibility */
|
---|
| 76 | #undef F_OK
|
---|
| 77 | #undef X_OK
|
---|
| 78 | #undef W_OK
|
---|
| 79 | #undef R_OK
|
---|
| 80 | #define F_OK 0 /* Test for existence. */
|
---|
| 81 | #define X_OK 1 /* Test for execute permission. */
|
---|
| 82 | #define W_OK 2 /* Test for write permission. */
|
---|
| 83 | #define R_OK 4 /* Test for read permission. */
|
---|
| 84 | extern int posix_access(const char *path, int amode);
|
---|
| 85 |
|
---|
[59f799b] | 86 | /* System Parameters */
|
---|
| 87 | enum {
|
---|
| 88 | _SC_PHYS_PAGES,
|
---|
| 89 | _SC_AVPHYS_PAGES,
|
---|
| 90 | _SC_PAGESIZE,
|
---|
| 91 | _SC_CLK_TCK
|
---|
| 92 | };
|
---|
| 93 | extern long posix_sysconf(int name);
|
---|
| 94 |
|
---|
[72ec8cc] | 95 | /* Path Configuration Parameters */
|
---|
| 96 | enum {
|
---|
| 97 | _PC_2_SYMLINKS,
|
---|
| 98 | _PC_ALLOC_SIZE_MIN,
|
---|
| 99 | _PC_ASYNC_IO,
|
---|
| 100 | _PC_CHOWN_RESTRICTED,
|
---|
| 101 | _PC_FILESIZEBITS,
|
---|
| 102 | _PC_LINK_MAX,
|
---|
| 103 | _PC_MAX_CANON,
|
---|
| 104 | _PC_MAX_INPUT,
|
---|
| 105 | _PC_NAME_MAX,
|
---|
| 106 | _PC_NO_TRUNC,
|
---|
| 107 | _PC_PATH_MAX,
|
---|
| 108 | _PC_PIPE_BUF,
|
---|
| 109 | _PC_PRIO_IO,
|
---|
| 110 | _PC_REC_INCR_XFER_SIZE,
|
---|
| 111 | _PC_REC_MIN_XFER_SIZE,
|
---|
| 112 | _PC_REC_XFER_ALIGN,
|
---|
| 113 | _PC_SYMLINK_MAX,
|
---|
| 114 | _PC_SYNC_IO,
|
---|
| 115 | _PC_VDISABLE
|
---|
| 116 | };
|
---|
[823a929] | 117 | extern long posix_pathconf(const char *path, int name);
|
---|
| 118 |
|
---|
| 119 | /* Creating a Process */
|
---|
| 120 | extern posix_pid_t posix_fork(void);
|
---|
| 121 |
|
---|
| 122 | /* Executing a File */
|
---|
| 123 | extern int posix_execv(const char *path, char *const argv[]);
|
---|
| 124 | extern int posix_execvp(const char *file, char *const argv[]);
|
---|
| 125 |
|
---|
| 126 | /* Creating a Pipe */
|
---|
| 127 | extern int posix_pipe(int fildes[2]);
|
---|
[72ec8cc] | 128 |
|
---|
[491e1ee] | 129 | #ifndef LIBPOSIX_INTERNAL
|
---|
[b4d6252] | 130 | #define environ posix_environ
|
---|
[244d6fd] | 131 | #define getlogin posix_getlogin
|
---|
| 132 | #define getlogin_r posix_getlogin_r
|
---|
[b4d6252] | 133 |
|
---|
[4f4b4e7] | 134 | #define isatty posix_isatty
|
---|
[b08ef1fd] | 135 |
|
---|
[72ec8cc] | 136 | #undef getpagesize
|
---|
| 137 | #define getpagesize posix_getpagesize
|
---|
| 138 |
|
---|
[823a929] | 139 | #define getpid posix_getpid
|
---|
[59f799b] | 140 | #define getuid posix_getuid
|
---|
| 141 | #define getgid posix_getgid
|
---|
| 142 |
|
---|
[b08ef1fd] | 143 | #define access posix_access
|
---|
[59f799b] | 144 |
|
---|
| 145 | #define sysconf posix_sysconf
|
---|
[823a929] | 146 |
|
---|
| 147 | #define pathconf posix_pathconf
|
---|
| 148 |
|
---|
| 149 | #define fork posix_fork
|
---|
| 150 |
|
---|
| 151 | #define execv posix_execv
|
---|
| 152 | #define execvp posix_execvp
|
---|
| 153 |
|
---|
| 154 | #define pipe posix_pipe
|
---|
[4f4b4e7] | 155 | #endif
|
---|
| 156 |
|
---|
[a16210b5] | 157 | #endif /* POSIX_UNISTD_H_ */
|
---|
| 158 |
|
---|
[4f4b4e7] | 159 | /** @}
|
---|
| 160 | */
|
---|