1 | /*
|
---|
2 | * Copyright (c) 2011 Jiri Zarevucky
|
---|
3 | * Copyright (c) 2011 Petr Koupy
|
---|
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 | */
|
---|
29 |
|
---|
30 | /** @addtogroup libposix
|
---|
31 | * @{
|
---|
32 | */
|
---|
33 | /** @file Miscellaneous standard definitions.
|
---|
34 | */
|
---|
35 |
|
---|
36 | #ifndef POSIX_UNISTD_H_
|
---|
37 | #define POSIX_UNISTD_H_
|
---|
38 |
|
---|
39 | #include "libc/unistd.h"
|
---|
40 | #include "sys/types.h"
|
---|
41 |
|
---|
42 | /* Process Termination */
|
---|
43 | #define _exit exit
|
---|
44 |
|
---|
45 | /* Option Arguments */
|
---|
46 | extern char *optarg;
|
---|
47 | extern int optind, opterr, optopt;
|
---|
48 | extern int getopt(int, char * const [], const char *);
|
---|
49 |
|
---|
50 | /* Environment */
|
---|
51 | extern char **posix_environ;
|
---|
52 |
|
---|
53 | /* Login Information */
|
---|
54 | extern char *posix_getlogin(void);
|
---|
55 | extern int posix_getlogin_r(char *name, size_t namesize);
|
---|
56 |
|
---|
57 | /* Identifying Terminals */
|
---|
58 | extern int posix_isatty(int fd);
|
---|
59 |
|
---|
60 | /* Working Directory */
|
---|
61 | extern char *posix_getcwd(char *buf, size_t size);
|
---|
62 |
|
---|
63 | /* Query Memory Parameters */
|
---|
64 | extern int posix_getpagesize(void);
|
---|
65 |
|
---|
66 | /* Process Identification */
|
---|
67 | extern posix_pid_t posix_getpid(void);
|
---|
68 | extern posix_uid_t posix_getuid(void);
|
---|
69 | extern posix_gid_t posix_getgid(void);
|
---|
70 |
|
---|
71 | /* File Input/Output */
|
---|
72 | extern ssize_t posix_read(int fildes, void *buf, size_t nbyte);
|
---|
73 |
|
---|
74 | /* Deleting Files */
|
---|
75 | extern int posix_unlink(const char *path);
|
---|
76 |
|
---|
77 | /* Standard Streams */
|
---|
78 | #undef STDIN_FILENO
|
---|
79 | #define STDIN_FILENO (fileno(stdin))
|
---|
80 | #undef STDOUT_FILENO
|
---|
81 | #define STDOUT_FILENO (fileno(stdout))
|
---|
82 | #undef STDERR_FILENO
|
---|
83 | #define STDERR_FILENO (fileno(stderr))
|
---|
84 |
|
---|
85 | /* File Accessibility */
|
---|
86 | #undef F_OK
|
---|
87 | #undef X_OK
|
---|
88 | #undef W_OK
|
---|
89 | #undef R_OK
|
---|
90 | #define F_OK 0 /* Test for existence. */
|
---|
91 | #define X_OK 1 /* Test for execute permission. */
|
---|
92 | #define W_OK 2 /* Test for write permission. */
|
---|
93 | #define R_OK 4 /* Test for read permission. */
|
---|
94 | extern int posix_access(const char *path, int amode);
|
---|
95 |
|
---|
96 | /* System Parameters */
|
---|
97 | enum {
|
---|
98 | _SC_PHYS_PAGES,
|
---|
99 | _SC_AVPHYS_PAGES,
|
---|
100 | _SC_PAGESIZE,
|
---|
101 | _SC_CLK_TCK
|
---|
102 | };
|
---|
103 | extern long posix_sysconf(int name);
|
---|
104 |
|
---|
105 | /* Path Configuration Parameters */
|
---|
106 | enum {
|
---|
107 | _PC_2_SYMLINKS,
|
---|
108 | _PC_ALLOC_SIZE_MIN,
|
---|
109 | _PC_ASYNC_IO,
|
---|
110 | _PC_CHOWN_RESTRICTED,
|
---|
111 | _PC_FILESIZEBITS,
|
---|
112 | _PC_LINK_MAX,
|
---|
113 | _PC_MAX_CANON,
|
---|
114 | _PC_MAX_INPUT,
|
---|
115 | _PC_NAME_MAX,
|
---|
116 | _PC_NO_TRUNC,
|
---|
117 | _PC_PATH_MAX,
|
---|
118 | _PC_PIPE_BUF,
|
---|
119 | _PC_PRIO_IO,
|
---|
120 | _PC_REC_INCR_XFER_SIZE,
|
---|
121 | _PC_REC_MIN_XFER_SIZE,
|
---|
122 | _PC_REC_XFER_ALIGN,
|
---|
123 | _PC_SYMLINK_MAX,
|
---|
124 | _PC_SYNC_IO,
|
---|
125 | _PC_VDISABLE
|
---|
126 | };
|
---|
127 | extern long posix_pathconf(const char *path, int name);
|
---|
128 |
|
---|
129 | /* Creating a Process */
|
---|
130 | extern posix_pid_t posix_fork(void);
|
---|
131 |
|
---|
132 | /* Executing a File */
|
---|
133 | extern int posix_execv(const char *path, char *const argv[]);
|
---|
134 | extern int posix_execvp(const char *file, char *const argv[]);
|
---|
135 |
|
---|
136 | /* Creating a Pipe */
|
---|
137 | extern int posix_pipe(int fildes[2]);
|
---|
138 |
|
---|
139 | #ifndef LIBPOSIX_INTERNAL
|
---|
140 | #define environ posix_environ
|
---|
141 |
|
---|
142 | #define getlogin posix_getlogin
|
---|
143 | #define getlogin_r posix_getlogin_r
|
---|
144 |
|
---|
145 | #define getcwd posix_getcwd
|
---|
146 |
|
---|
147 | #define isatty posix_isatty
|
---|
148 |
|
---|
149 | #undef getpagesize
|
---|
150 | #define getpagesize posix_getpagesize
|
---|
151 |
|
---|
152 | #define getpid posix_getpid
|
---|
153 | #define getuid posix_getuid
|
---|
154 | #define getgid posix_getgid
|
---|
155 |
|
---|
156 | #define read posix_read
|
---|
157 |
|
---|
158 | #define unlink posix_unlink
|
---|
159 |
|
---|
160 | #define access posix_access
|
---|
161 |
|
---|
162 | #define sysconf posix_sysconf
|
---|
163 |
|
---|
164 | #define pathconf posix_pathconf
|
---|
165 |
|
---|
166 | #define fork posix_fork
|
---|
167 |
|
---|
168 | #define execv posix_execv
|
---|
169 | #define execvp posix_execvp
|
---|
170 |
|
---|
171 | #define pipe posix_pipe
|
---|
172 | #endif
|
---|
173 |
|
---|
174 | #endif /* POSIX_UNISTD_H_ */
|
---|
175 |
|
---|
176 | /** @}
|
---|
177 | */
|
---|