OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 // Partial <unistd.h>-lookalike-ish. Note that this is a C header, so that | |
6 // crappy (and non-crappy) C programs can use it. | |
7 // | |
8 // In general, functions/types/macros are given "mojio_"/"MOJIO_"/etc. prefixes. | |
9 // There are a handful of exceptions (noted below). | |
10 | |
11 #ifndef MOJO_SERVICES_FILES_PUBLIC_C_MOJIO_UNISTD_H_ | |
12 #define MOJO_SERVICES_FILES_PUBLIC_C_MOJIO_UNISTD_H_ | |
13 | |
14 // Includes -------------------------------------------------------------------- | |
15 | |
16 // <unistd.h> is required to define |NULL| (as a macro) and |size_t|. We don't | |
17 // define our own (with prefixes), and just use the standard ones from | |
18 // <stddef.h>. | |
19 #include <stddef.h> | |
20 | |
21 // <unistd.h> is required to |ssize_t|, |uid_t|, |gid_t|, |off_t|, |pid_t|, and | |
22 // |useconds_t| from <sys/types.h>, so we may as well define our versions by | |
23 // inclusion. | |
24 #include "files/public/c/mojio_sys_types.h" | |
25 | |
26 // Macros ---------------------------------------------------------------------- | |
27 | |
28 // "Whence". These are duplicated (verbatim) in mojio_stdio.h. | |
29 #define MOJIO_SEEK_SET 0 | |
30 #define MOJIO_SEEK_CUR 1 | |
31 #define MOJIO_SEEK_END 2 | |
32 | |
33 // TODO(vtl): Nothing else here yet. | |
34 | |
35 // Types ----------------------------------------------------------------------- | |
36 | |
37 // We don't use the "standard" |intptr_t| (it's not required by the C/C++ | |
38 // standards), since we don't want to include <inttypes.h> (nor <stdint.h>, | |
39 // which need not define it except on XSI-compliant systems). | |
40 // TODO(vtl): We may need to define this differently sometimes? (But how?) | |
41 typedef long int mojio_intptr_t; | |
42 | |
43 // TODO(vtl): Nothing else here yet. | |
44 | |
45 // Functions ------------------------------------------------------------------- | |
46 | |
47 #ifdef __cplusplus | |
48 extern "C" { | |
49 #endif | |
50 | |
51 // TODO(vtl): Below is a complete list of functions in <unistd.h> (according to | |
52 // POSIX.1-2008, 2013 edition). Figure out which ones we want/need to support. | |
53 // | |
54 // int access(const char*, int); | |
55 // unsigned alarm(unsigned); | |
56 // [DONE] int chdir(const char*); | |
57 // int chown(const char*, uid_t, gid_t); | |
58 // [DONE] int close(int); | |
59 // size_t confstr(int, char*, size_t); | |
60 // [XSI] char* crypt(const char*, const char*); | |
61 // [DONE] int dup(int); | |
62 // int dup2(int, int); | |
63 // void _exit(int); | |
64 // [XSI] void encrypt(char [64], int); | |
65 // int execl(const char*, const char*, ...); | |
66 // int execle(const char*, const char*, ...); | |
67 // int execlp(const char*, const char*, ...); | |
68 // int execv(const char*, char* const []); | |
69 // int execve(const char*, char* const [], char* const []); | |
70 // int execvp(const char*, char* const []); | |
71 // int faccessat(int, const char*, int, int); | |
72 // int fchdir(int); | |
73 // int fchown(int, uid_t, gid_t); | |
74 // int fchownat(int, const char*, uid_t, gid_t, int); | |
75 // [SIO] int fdatasync(int); | |
76 // int fexecve(int, char* const [], char* const []); | |
77 // pid_t fork(void); | |
78 // long fpathconf(int, int); | |
79 // [FSC] int fsync(int); | |
80 // [DONE] int ftruncate(int, off_t); | |
81 // char* getcwd(char*, size_t); | |
82 // gid_t getegid(void); | |
83 // uid_t geteuid(void); | |
84 // gid_t getgid(void); | |
85 // int getgroups(int, gid_t []); | |
86 // [XSI] long gethostid(void); | |
87 // int gethostname(char*, size_t); | |
88 // char* getlogin(void); | |
89 // int getlogin_r(char*, size_t); | |
90 // int getopt(int, char* const [], const char*); | |
91 // pid_t getpgid(pid_t); | |
92 // pid_t getpgrp(void); | |
93 // pid_t getpid(void); | |
94 // pid_t getppid(void); | |
95 // pid_t getsid(pid_t); | |
96 // uid_t getuid(void); | |
97 // int isatty(int); | |
98 // int lchown(const char*, uid_t, gid_t); | |
99 // int link(const char*, const char*); | |
100 // int linkat(int, const char*, int, const char*, int); | |
101 // [XSI] int lockf(int, int, off_t); | |
102 // [DONE] off_t lseek(int, off_t, int); | |
103 // [XSI] int nice(int); | |
104 // long pathconf(const char*, int); | |
105 // int pause(void); | |
106 // int pipe(int [2]); | |
107 // ssize_t pread(int, void*, size_t, off_t); | |
108 // ssize_t pwrite(int, const void*, size_t, off_t); | |
109 // [DONE] ssize_t read(int, void*, size_t); | |
110 // ssize_t readlink(const char* restrict, char* restrict, size_t); | |
111 // ssize_t readlinkat(int, const char* restrict, char* restrict, size_t); | |
112 // int rmdir(const char*); | |
113 // int setegid(gid_t); | |
114 // int seteuid(uid_t); | |
115 // int setgid(gid_t); | |
116 // int setpgid(pid_t, pid_t); | |
117 // [Obsolete XSI] pid_t setpgrp(void); | |
118 // [XSI] int setregid(gid_t, gid_t); | |
119 // [XSI] int setreuid(uid_t, uid_t); | |
120 // pid_t setsid(void); | |
121 // int setuid(uid_t); | |
122 // unsigned sleep(unsigned); | |
123 // [XSI] void swab(const void* restrict, void* restrict, ssize_t); | |
124 // int symlink(const char*, const char*); | |
125 // int symlinkat(const char*, int, const char*); | |
126 // [XSI] void sync(void); | |
127 // long sysconf(int); | |
128 // pid_t tcgetpgrp(int); | |
129 // int tcsetpgrp(int, pid_t); | |
130 // int truncate(const char*, off_t); | |
131 // char* ttyname(int); | |
132 // int ttyname_r(int, char*, size_t); | |
133 // int unlink(const char*); | |
134 // int unlinkat(int, const char*, int); | |
135 // [DONE] ssize_t write(int, const void*, size_t); | |
136 | |
137 int mojio_chdir(const char* path); | |
138 int mojio_close(int fd); | |
139 int mojio_dup(int fd); | |
140 int mojio_ftruncate(int fd, mojio_off_t length); | |
141 mojio_off_t mojio_lseek(int fd, mojio_off_t offset, int whence); | |
142 mojio_ssize_t mojio_read(int fd, void* buf, size_t count); | |
143 mojio_ssize_t mojio_write(int fd, const void* buf, size_t count); | |
144 | |
145 // TODO(vtl): Some of the others. | |
146 | |
147 // Globals --------------------------------------------------------------------- | |
148 | |
149 // TODO(vtl): Nothing here yet. | |
150 | |
151 #ifdef __cplusplus | |
152 } // extern "C" | |
153 #endif | |
154 | |
155 #endif // MOJO_SERVICES_FILES_PUBLIC_C_MOJIO_UNISTD_H_ | |
OLD | NEW |