| 1 | /* | 
|---|
| 2 | This file is part of MutekP. | 
|---|
| 3 |  | 
|---|
| 4 | MutekP is free software; you can redistribute it and/or modify it | 
|---|
| 5 | under the terms of the GNU General Public License as published by | 
|---|
| 6 | the Free Software Foundation; either version 2 of the License, or | 
|---|
| 7 | (at your option) any later version. | 
|---|
| 8 |  | 
|---|
| 9 | MutekP is distributed in the hope that it will be useful, but | 
|---|
| 10 | WITHOUT ANY WARRANTY; without even the implied warranty of | 
|---|
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU | 
|---|
| 12 | General Public License for more details. | 
|---|
| 13 |  | 
|---|
| 14 | You should have received a copy of the GNU General Public License | 
|---|
| 15 | along with MutekP; if not, write to the Free Software Foundation, | 
|---|
| 16 | Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 
|---|
| 17 |  | 
|---|
| 18 | UPMC / LIP6 / SOC (c) 2008 | 
|---|
| 19 | Copyright Ghassan Almaless <ghassan.almaless@gmail.com> | 
|---|
| 20 | */ | 
|---|
| 21 |  | 
|---|
| 22 | #ifndef _UNISTD_H_ | 
|---|
| 23 | #define _UNISTD_H_ | 
|---|
| 24 |  | 
|---|
| 25 | #include <sys/types.h> | 
|---|
| 26 | #include <getopt.h> | 
|---|
| 27 |  | 
|---|
| 28 | #define O_DIRECTORY  0x00040000 | 
|---|
| 29 | #define O_APPEND     0x00080000 | 
|---|
| 30 | #define O_RDONLY     0x00100000 | 
|---|
| 31 | #define O_WRONLY     0x00200000 | 
|---|
| 32 | #define O_RDWR       0x00300000 | 
|---|
| 33 | #define O_CREAT      0x00400000 | 
|---|
| 34 | #define O_EXCL       0x00800000 | 
|---|
| 35 | #define O_TRUNC      0x01000000 | 
|---|
| 36 | #define O_SYNC       0x08000000 | 
|---|
| 37 | #define O_DSYNC      O_SYNC | 
|---|
| 38 | #define O_RSYNC      O_SYNC | 
|---|
| 39 |  | 
|---|
| 40 | #define SEEK_SET   0 | 
|---|
| 41 | #define SEEK_CUR   1 | 
|---|
| 42 | #define SEEK_END   2 | 
|---|
| 43 |  | 
|---|
| 44 | #define STDIN_FILENO 0 | 
|---|
| 45 | #define STDOUT_FILENO 1 | 
|---|
| 46 | #define STDERR_FILENO 2 | 
|---|
| 47 |  | 
|---|
| 48 | #define _SC_OPEN_MAX         0 | 
|---|
| 49 | #define _SC_CLK_TCK          1 | 
|---|
| 50 | #define _SC_PAGESIZE         2 | 
|---|
| 51 | #define _SC_ARG_MAX          3 | 
|---|
| 52 | #define _SC_NGROUPS_MAX      4 | 
|---|
| 53 | #define _SC_NPROCESSORS_ONLN 5 | 
|---|
| 54 | #define _SC_PAGE_SIZE        6 | 
|---|
| 55 | #define _SC_CACHE_LINE_SIZE  7 | 
|---|
| 56 | #define _SC_HEAP_MAX_SIZE    8 | 
|---|
| 57 | #define _SC_NCLUSTERS_ONLN   9 | 
|---|
| 58 |  | 
|---|
| 59 | //#define LIBC_DEBUG | 
|---|
| 60 | long sysconf(int name); | 
|---|
| 61 | ssize_t read(int fd, void *buf, size_t count); | 
|---|
| 62 | ssize_t write(int fd, const void *buf, size_t count); | 
|---|
| 63 | off_t lseek(int fd, off_t offset, int whence); | 
|---|
| 64 | int unlink(const char *pathname); | 
|---|
| 65 | int close(int fd); | 
|---|
| 66 | int fsync(int fd); | 
|---|
| 67 | int chdir(const char *path); | 
|---|
| 68 | int rmdir(const char *pathname); | 
|---|
| 69 | char *getcwd(char *buf, size_t size); | 
|---|
| 70 | char *getwd(char *buf); | 
|---|
| 71 | int pipe(int pipefd[2]); | 
|---|
| 72 |  | 
|---|
| 73 | unsigned int sleep (unsigned int nb_sec); | 
|---|
| 74 | int isatty(int fd); | 
|---|
| 75 |  | 
|---|
| 76 | char *crypt(const char *key, const char *salt); | 
|---|
| 77 | void encrypt(char block[64], int edflag); | 
|---|
| 78 | void setkey(const char *key); | 
|---|
| 79 |  | 
|---|
| 80 | pid_t getpid(void); | 
|---|
| 81 | pid_t fork(void); | 
|---|
| 82 |  | 
|---|
| 83 | int execve(const char *filename, char *const argv[], char *const envp[]); | 
|---|
| 84 |  | 
|---|
| 85 | int execl(const char *path, const char *arg, ...); | 
|---|
| 86 | int execlp(const char* file, const char *arg, ...); | 
|---|
| 87 | //int execle(const char *path, ...); | 
|---|
| 88 | int execv(const char *path, char *const argv[]); | 
|---|
| 89 | int execvp(const char *file, char *const argv[]); | 
|---|
| 90 |  | 
|---|
| 91 |  | 
|---|
| 92 | #ifdef LIBC_DEBUG | 
|---|
| 93 | #include <string.h> | 
|---|
| 94 | static char __buff_[128]; | 
|---|
| 95 | #define log_msg(msg, ...)                                       \ | 
|---|
| 96 | ({                                                            \ | 
|---|
| 97 | memset(__buff_, 0, 128);                                    \ | 
|---|
| 98 | write(2,__buff_, sprintf(__buff_, msg, __VA_ARGS__));               \ | 
|---|
| 99 | }) | 
|---|
| 100 | #else | 
|---|
| 101 | #define log_msg(msg, ...) | 
|---|
| 102 | #endif | 
|---|
| 103 |  | 
|---|
| 104 |  | 
|---|
| 105 | #endif  /* _UNISTD_H_ */ | 
|---|