| 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 | #ifndef __POSIX_DEF__
|
|---|
| 40 | #define __POSIX_DEF__(x) x
|
|---|
| 41 | #endif
|
|---|
| 42 |
|
|---|
| 43 | #include "sys/types.h"
|
|---|
| 44 | #include "stddef.h"
|
|---|
| 45 |
|
|---|
| 46 | /* Process Termination */
|
|---|
| 47 | #define _exit exit
|
|---|
| 48 |
|
|---|
| 49 | extern char *__POSIX_DEF__(optarg);
|
|---|
| 50 | extern int optind, opterr, optopt;
|
|---|
| 51 | extern int __POSIX_DEF__(getopt)(int, char * const [], const char *);
|
|---|
| 52 |
|
|---|
| 53 | /* Environment */
|
|---|
| 54 | extern char **__POSIX_DEF__(environ);
|
|---|
| 55 |
|
|---|
| 56 | /* Login Information */
|
|---|
| 57 | extern char *__POSIX_DEF__(getlogin)(void);
|
|---|
| 58 | extern int __POSIX_DEF__(getlogin_r)(char *name, size_t namesize);
|
|---|
| 59 |
|
|---|
| 60 | /* Identifying Terminals */
|
|---|
| 61 | extern int __POSIX_DEF__(isatty)(int fd);
|
|---|
| 62 |
|
|---|
| 63 | /* Working Directory */
|
|---|
| 64 | extern char *__POSIX_DEF__(getcwd)(char *buf, size_t size);
|
|---|
| 65 | extern int __POSIX_DEF__(chdir)(const char *path);
|
|---|
| 66 |
|
|---|
| 67 | /* Query Memory Parameters */
|
|---|
| 68 | extern int __POSIX_DEF__(getpagesize)(void);
|
|---|
| 69 |
|
|---|
| 70 | /* Process Identification */
|
|---|
| 71 | extern __POSIX_DEF__(pid_t) __POSIX_DEF__(getpid)(void);
|
|---|
| 72 | extern __POSIX_DEF__(uid_t) __POSIX_DEF__(getuid)(void);
|
|---|
| 73 | extern __POSIX_DEF__(gid_t) __POSIX_DEF__(getgid)(void);
|
|---|
| 74 |
|
|---|
| 75 | /* File Manipulation */
|
|---|
| 76 | extern int __POSIX_DEF__(close)(int fildes);
|
|---|
| 77 | extern ssize_t __POSIX_DEF__(read)(int fildes, void *buf, size_t nbyte);
|
|---|
| 78 | extern ssize_t __POSIX_DEF__(write)(int fildes, const void *buf, size_t nbyte);
|
|---|
| 79 | extern int __POSIX_DEF__(fsync)(int fildes);
|
|---|
| 80 | extern int __POSIX_DEF__(ftruncate)(int fildes, __POSIX_DEF__(off_t) length);
|
|---|
| 81 | extern int __POSIX_DEF__(rmdir)(const char *path);
|
|---|
| 82 | extern int __POSIX_DEF__(unlink)(const char *path);
|
|---|
| 83 | extern int __POSIX_DEF__(dup)(int fildes);
|
|---|
| 84 | extern int __POSIX_DEF__(dup2)(int fildes, int fildes2);
|
|---|
| 85 |
|
|---|
| 86 | /* Standard Streams */
|
|---|
| 87 | #undef STDIN_FILENO
|
|---|
| 88 | #define STDIN_FILENO (fileno(stdin))
|
|---|
| 89 | #undef STDOUT_FILENO
|
|---|
| 90 | #define STDOUT_FILENO (fileno(stdout))
|
|---|
| 91 | #undef STDERR_FILENO
|
|---|
| 92 | #define STDERR_FILENO (fileno(stderr))
|
|---|
| 93 |
|
|---|
| 94 | /* File Accessibility */
|
|---|
| 95 | #undef F_OK
|
|---|
| 96 | #undef X_OK
|
|---|
| 97 | #undef W_OK
|
|---|
| 98 | #undef R_OK
|
|---|
| 99 | #define F_OK 0 /* Test for existence. */
|
|---|
| 100 | #define X_OK 1 /* Test for execute permission. */
|
|---|
| 101 | #define W_OK 2 /* Test for write permission. */
|
|---|
| 102 | #define R_OK 4 /* Test for read permission. */
|
|---|
| 103 | extern int __POSIX_DEF__(access)(const char *path, int amode);
|
|---|
| 104 |
|
|---|
| 105 | /* System Parameters */
|
|---|
| 106 | enum {
|
|---|
| 107 | _SC_PHYS_PAGES,
|
|---|
| 108 | _SC_AVPHYS_PAGES,
|
|---|
| 109 | _SC_PAGESIZE,
|
|---|
| 110 | _SC_CLK_TCK
|
|---|
| 111 | };
|
|---|
| 112 | extern long __POSIX_DEF__(sysconf)(int name);
|
|---|
| 113 |
|
|---|
| 114 | /* Path Configuration Parameters */
|
|---|
| 115 | enum {
|
|---|
| 116 | _PC_2_SYMLINKS,
|
|---|
| 117 | _PC_ALLOC_SIZE_MIN,
|
|---|
| 118 | _PC_ASYNC_IO,
|
|---|
| 119 | _PC_CHOWN_RESTRICTED,
|
|---|
| 120 | _PC_FILESIZEBITS,
|
|---|
| 121 | _PC_LINK_MAX,
|
|---|
| 122 | _PC_MAX_CANON,
|
|---|
| 123 | _PC_MAX_INPUT,
|
|---|
| 124 | _PC_NAME_MAX,
|
|---|
| 125 | _PC_NO_TRUNC,
|
|---|
| 126 | _PC_PATH_MAX,
|
|---|
| 127 | _PC_PIPE_BUF,
|
|---|
| 128 | _PC_PRIO_IO,
|
|---|
| 129 | _PC_REC_INCR_XFER_SIZE,
|
|---|
| 130 | _PC_REC_MIN_XFER_SIZE,
|
|---|
| 131 | _PC_REC_XFER_ALIGN,
|
|---|
| 132 | _PC_SYMLINK_MAX,
|
|---|
| 133 | _PC_SYNC_IO,
|
|---|
| 134 | _PC_VDISABLE
|
|---|
| 135 | };
|
|---|
| 136 | extern long __POSIX_DEF__(pathconf)(const char *path, int name);
|
|---|
| 137 |
|
|---|
| 138 | /* Creating a Process */
|
|---|
| 139 | extern __POSIX_DEF__(pid_t) __POSIX_DEF__(fork)(void);
|
|---|
| 140 |
|
|---|
| 141 | /* Executing a File */
|
|---|
| 142 | extern int __POSIX_DEF__(execv)(const char *path, char *const argv[]);
|
|---|
| 143 | extern int __POSIX_DEF__(execvp)(const char *file, char *const argv[]);
|
|---|
| 144 |
|
|---|
| 145 | /* Creating a Pipe */
|
|---|
| 146 | extern int __POSIX_DEF__(pipe)(int fildes[2]);
|
|---|
| 147 |
|
|---|
| 148 | /* Issue alarm signal. */
|
|---|
| 149 | extern unsigned int __POSIX_DEF__(alarm)(unsigned int);
|
|---|
| 150 |
|
|---|
| 151 | #endif /* POSIX_UNISTD_H_ */
|
|---|
| 152 |
|
|---|
| 153 | /** @}
|
|---|
| 154 | */
|
|---|