PageRenderTime 26ms CodeModel.GetById 32ms RepoModel.GetById 0ms app.codeStats 0ms

/include/unistd.h

https://github.com/ryanbarry/CS170-Project-3
C Header | 228 lines | 180 code | 26 blank | 22 comment | 0 complexity | a08c37cb099e73ab72a3ed6677e5bc13 MD5 | raw file
  1. /* The <unistd.h> header contains a few miscellaneous manifest constants. */
  2. #ifndef _UNISTD_H
  3. #define _UNISTD_H
  4. #ifndef _TYPES_H
  5. #include <minix/types.h>
  6. #endif
  7. #include <sys/ucred.h>
  8. /* Values used by access(). POSIX Table 2-8. */
  9. #define F_OK 0 /* test if file exists */
  10. #define X_OK 1 /* test if file is executable */
  11. #define W_OK 2 /* test if file is writable */
  12. #define R_OK 4 /* test if file is readable */
  13. /* Values used for whence in lseek(fd, offset, whence). POSIX Table 2-9. */
  14. #define SEEK_SET 0 /* offset is absolute */
  15. #define SEEK_CUR 1 /* offset is relative to current position */
  16. #define SEEK_END 2 /* offset is relative to end of file */
  17. /* This value is required by POSIX Table 2-10. */
  18. #define _POSIX_VERSION 199009L /* which standard is being conformed to */
  19. /* These three definitions are required by POSIX Sec. 8.2.1.2. */
  20. #define STDIN_FILENO 0 /* file descriptor for stdin */
  21. #define STDOUT_FILENO 1 /* file descriptor for stdout */
  22. #define STDERR_FILENO 2 /* file descriptor for stderr */
  23. #ifdef _MINIX
  24. /* How to exit the system or stop a server process. */
  25. #define RBT_HALT 0 /* shutdown and return to monitor */
  26. #define RBT_REBOOT 1 /* reboot the system through the monitor */
  27. #define RBT_PANIC 2 /* a server panics */
  28. #define RBT_MONITOR 3 /* let the monitor do this */
  29. #define RBT_RESET 4 /* hard reset the system */
  30. #define RBT_DEFAULT 5 /* return to monitor, reset if not possible */
  31. #define RBT_INVALID 6 /* first invalid reboot flag */
  32. #define _PM_SEG_FLAG (1L << 30) /* for read() and write() to FS by PM */
  33. #endif
  34. /* What system info to retrieve with sysgetinfo(). */
  35. #define SI_KINFO 0 /* get kernel info via PM */
  36. #define SI_PROC_ADDR 1 /* address of process table */
  37. #define SI_PROC_TAB 2 /* copy of entire process table */
  38. #define SI_DMAP_TAB 3 /* get device <-> driver mappings */
  39. #define SI_MEM_ALLOC 4 /* get memory allocation data */
  40. #define SI_DATA_STORE 5 /* get copy of data store mappings */
  41. #define SI_SUBSCRIPTION 6 /* get copy of data store subscriptions */
  42. #define SI_LOADINFO 7 /* get copy of load average structure */
  43. #define SI_KPROC_TAB 8 /* copy of kernel process table */
  44. #define SI_CALL_STATS 9 /* system call statistics */
  45. #define SI_PCI_INFO 10 /* get kernel info via PM */
  46. #define SI_PROCPUB_TAB 11 /* copy of public entries of process table */
  47. /* NULL must be defined in <unistd.h> according to POSIX Sec. 2.7.1. */
  48. #include <sys/null.h>
  49. /* The following relate to configurable system variables. POSIX Table 4-2. */
  50. #define _SC_ARG_MAX 1
  51. #define _SC_CHILD_MAX 2
  52. #define _SC_CLOCKS_PER_SEC 3
  53. #define _SC_CLK_TCK 3
  54. #define _SC_NGROUPS_MAX 4
  55. #define _SC_OPEN_MAX 5
  56. #define _SC_JOB_CONTROL 6
  57. #define _SC_SAVED_IDS 7
  58. #define _SC_VERSION 8
  59. #define _SC_STREAM_MAX 9
  60. #define _SC_TZNAME_MAX 10
  61. #define _SC_PAGESIZE 11
  62. #define _SC_PAGE_SIZE _SC_PAGESIZE
  63. /* The following relate to configurable pathname variables. POSIX Table 5-2. */
  64. #define _PC_LINK_MAX 1 /* link count */
  65. #define _PC_MAX_CANON 2 /* size of the canonical input queue */
  66. #define _PC_MAX_INPUT 3 /* type-ahead buffer size */
  67. #define _PC_NAME_MAX 4 /* file name size */
  68. #define _PC_PATH_MAX 5 /* pathname size */
  69. #define _PC_PIPE_BUF 6 /* pipe size */
  70. #define _PC_NO_TRUNC 7 /* treatment of long name components */
  71. #define _PC_VDISABLE 8 /* tty disable */
  72. #define _PC_CHOWN_RESTRICTED 9 /* chown restricted or not */
  73. /* POSIX defines several options that may be implemented or not, at the
  74. * implementer's whim. This implementer has made the following choices:
  75. *
  76. * _POSIX_JOB_CONTROL not defined: no job control
  77. * _POSIX_SAVED_IDS not defined: no saved uid/gid
  78. * _POSIX_NO_TRUNC defined as -1: long path names are truncated
  79. * _POSIX_CHOWN_RESTRICTED defined: you can't give away files
  80. * _POSIX_VDISABLE defined: tty functions can be disabled
  81. */
  82. #define _POSIX_NO_TRUNC (-1)
  83. #define _POSIX_CHOWN_RESTRICTED 1
  84. /* Function Prototypes. */
  85. _PROTOTYPE( void _exit, (int _status) );
  86. _PROTOTYPE( int access, (const char *_path, int _amode) );
  87. _PROTOTYPE( unsigned int alarm, (unsigned int _seconds) );
  88. _PROTOTYPE( int chdir, (const char *_path) );
  89. _PROTOTYPE( int fchdir, (int fd) );
  90. _PROTOTYPE( int chown, (const char *_path, uid_t _owner, gid_t _group) );
  91. _PROTOTYPE( int fchown, (int fd, uid_t _owner, gid_t _group) );
  92. _PROTOTYPE( int close, (int _fd) );
  93. _PROTOTYPE( char *ctermid, (char *_s) );
  94. _PROTOTYPE( char *cuserid, (char *_s) );
  95. _PROTOTYPE( int dup, (int _fd) );
  96. _PROTOTYPE( int dup2, (int _fd, int _fd2) );
  97. _PROTOTYPE( int execl, (const char *_path, const char *_arg, ...) );
  98. _PROTOTYPE( int execle, (const char *_path, const char *_arg, ...) );
  99. _PROTOTYPE( int execlp, (const char *_file, const char *arg, ...) );
  100. _PROTOTYPE( int execv, (const char *_path, char *const _argv[]) );
  101. _PROTOTYPE( int execve, (const char *_path, char *const _argv[],
  102. char *const _envp[]) );
  103. _PROTOTYPE( int execvp, (const char *_file, char *const _argv[]) );
  104. _PROTOTYPE( pid_t fork, (void) );
  105. _PROTOTYPE( long fpathconf, (int _fd, int _name) );
  106. _PROTOTYPE( char *getcwd, (char *_buf, size_t _size) );
  107. _PROTOTYPE( gid_t getegid, (void) );
  108. _PROTOTYPE( uid_t geteuid, (void) );
  109. _PROTOTYPE( gid_t getgid, (void) );
  110. _PROTOTYPE( int getgroups, (int _gidsetsize, gid_t _grouplist[]) );
  111. _PROTOTYPE( int setgroups, (int _ngroups, gid_t const *grps) );
  112. _PROTOTYPE( char *getlogin, (void) );
  113. _PROTOTYPE( pid_t getpgrp, (void) );
  114. _PROTOTYPE( pid_t getpid, (void) );
  115. _PROTOTYPE( pid_t getppid, (void) );
  116. _PROTOTYPE( uid_t getuid, (void) );
  117. _PROTOTYPE( int isatty, (int _fd) );
  118. _PROTOTYPE( int link, (const char *_existing, const char *_new) );
  119. _PROTOTYPE( off_t lseek, (int _fd, off_t _offset, int _whence) );
  120. _PROTOTYPE( long pathconf, (const char *_path, int _name) );
  121. _PROTOTYPE( int pause, (void) );
  122. _PROTOTYPE( int pipe, (int _fildes[2]) );
  123. _PROTOTYPE( ssize_t read, (int _fd, void *_buf, size_t _n) );
  124. _PROTOTYPE( ssize_t pread, (int, void *, size_t, off_t) );
  125. _PROTOTYPE( int rmdir, (const char *_path) );
  126. _PROTOTYPE( int setgid, (gid_t _gid) );
  127. _PROTOTYPE( int setegid, (gid_t _gid) );
  128. _PROTOTYPE( pid_t setsid, (void) );
  129. _PROTOTYPE( int setuid, (uid_t _uid) );
  130. _PROTOTYPE( int seteuid, (uid_t _uid) );
  131. _PROTOTYPE( unsigned int sleep, (unsigned int _seconds) );
  132. _PROTOTYPE( long sysconf, (int _name) );
  133. _PROTOTYPE( pid_t tcgetpgrp, (int _fd) );
  134. _PROTOTYPE( int tcsetpgrp, (int _fd, pid_t _pgrp_id) );
  135. _PROTOTYPE( char *ttyname, (int _fd) );
  136. _PROTOTYPE( int unlink, (const char *_path) );
  137. _PROTOTYPE( ssize_t write, (int _fd, const void *_buf, size_t _n) );
  138. _PROTOTYPE( ssize_t pwrite, (int _fd, const void *_buf, size_t _n, off_t _offset));
  139. _PROTOTYPE( int truncate, (const char *_path, off_t _length) );
  140. _PROTOTYPE( int ftruncate, (int _fd, off_t _length) );
  141. _PROTOTYPE( int nice, (int _incr) );
  142. _PROTOTYPE( int lsr, (char *path) );
  143. /* Open Group Base Specifications Issue 6 (not complete) */
  144. _PROTOTYPE( int symlink, (const char *path1, const char *path2) );
  145. _PROTOTYPE( int readlink, (const char *, char *, size_t) );
  146. _PROTOTYPE( int getopt, (int _argc, char * const _argv[], char const *_opts) );
  147. extern char *optarg;
  148. extern int optreset; /* Reset getopt state */
  149. extern int optind, opterr, optopt;
  150. _PROTOTYPE( int usleep, (useconds_t _useconds) );
  151. _PROTOTYPE( int brk, (char *_addr) );
  152. _PROTOTYPE( int chroot, (const char *_name) );
  153. _PROTOTYPE( int lseek64, (int _fd, u64_t _offset, int _whence,
  154. u64_t *_newpos) );
  155. _PROTOTYPE( int mknod, (const char *_name, mode_t _mode, dev_t _addr) );
  156. _PROTOTYPE( int mknod4, (const char *_name, mode_t _mode, dev_t _addr,
  157. long _size) );
  158. _PROTOTYPE( char *mktemp, (char *_template) );
  159. _PROTOTYPE( long ptrace, (int _req, pid_t _pid, long _addr, long _data) );
  160. _PROTOTYPE( char *sbrk, (int _incr) );
  161. _PROTOTYPE( int sync, (void) );
  162. _PROTOTYPE( int fsync, (int fd) );
  163. _PROTOTYPE( int reboot, (int _how, ...) );
  164. _PROTOTYPE( int gethostname, (char *_hostname, size_t _len) );
  165. _PROTOTYPE( int getdomainname, (char *_domain, size_t _len) );
  166. /* For compatibility with other Unix systems */
  167. _PROTOTYPE( int getpagesize, (void) );
  168. _PROTOTYPE( int setgroups, (int ngroups, const gid_t *gidset) );
  169. _PROTOTYPE( int initgroups, (const char *name, gid_t basegid) );
  170. _PROTOTYPE( void *setmode, (const char *) );
  171. _PROTOTYPE( mode_t getmode, (const void *, mode_t) );
  172. _PROTOTYPE( void strmode, (mode_t, char *) );
  173. _PROTOTYPE( int ttyslot, (void) );
  174. _PROTOTYPE( int fttyslot, (int _fd) );
  175. _PROTOTYPE( char *crypt, (const char *_key, const char *_salt) );
  176. #ifdef _MINIX
  177. #ifndef _TYPE_H
  178. #include <minix/type.h>
  179. #endif
  180. _PROTOTYPE( int getsysinfo, (endpoint_t who, int what, void *where) );
  181. _PROTOTYPE( int getsigset, (sigset_t *sigset) );
  182. _PROTOTYPE( int getprocnr, (void) );
  183. _PROTOTYPE( int getnprocnr, (pid_t pid) );
  184. _PROTOTYPE( int getpprocnr, (void) );
  185. _PROTOTYPE( int _pm_findproc, (char *proc_name, int *proc_nr) );
  186. _PROTOTYPE( int mapdriver, (char *label, int major, int style,
  187. int flags) );
  188. _PROTOTYPE(int adddma, (endpoint_t proc_e,
  189. phys_bytes start, phys_bytes size) );
  190. _PROTOTYPE(int deldma, (endpoint_t proc_e,
  191. phys_bytes start, phys_bytes size) );
  192. _PROTOTYPE(int getdma, (endpoint_t *procp, phys_bytes *basep,
  193. phys_bytes *sizep) );
  194. _PROTOTYPE( pid_t getnpid, (endpoint_t proc_ep) );
  195. _PROTOTYPE( uid_t getnuid, (endpoint_t proc_ep) );
  196. _PROTOTYPE( gid_t getngid, (endpoint_t proc_ep) );
  197. _PROTOTYPE( int getnucred, (endpoint_t proc_ep, struct ucred *ucred) );
  198. #endif
  199. #ifdef _POSIX_SOURCE
  200. _PROTOTYPE( int getdtablesize, (void) );
  201. #endif
  202. #endif /* _UNISTD_H */