diff options
Diffstat (limited to '')
-rw-r--r-- | include/mingw.h | 674 |
1 files changed, 674 insertions, 0 deletions
diff --git a/include/mingw.h b/include/mingw.h new file mode 100644 index 000000000..276e40659 --- /dev/null +++ b/include/mingw.h | |||
@@ -0,0 +1,674 @@ | |||
1 | |||
2 | #define NOIMPL(name,...) static inline int name(__VA_ARGS__) { errno = ENOSYS; return -1; } | ||
3 | #define IMPL(name,ret,retval,...) static inline ret name(__VA_ARGS__) { return retval; } | ||
4 | |||
5 | /* Use 64-bit time on 32-bit platforms. */ | ||
6 | #if !defined(_WIN64) | ||
7 | # define time_t __time64_t | ||
8 | # define ctime(t) _ctime64(t) | ||
9 | # define localtime(t) _localtime64(t) | ||
10 | # define time(t) _time64(t) | ||
11 | # define gmtime(t) _gmtime64(t) | ||
12 | # define mktime(t) _mktime64(t) | ||
13 | # define timespec _timespec64 | ||
14 | #endif | ||
15 | |||
16 | /* | ||
17 | * sys/types.h | ||
18 | */ | ||
19 | typedef int gid_t; | ||
20 | typedef int uid_t; | ||
21 | |||
22 | #define DEFAULT_UID 4095 | ||
23 | #define DEFAULT_GID DEFAULT_UID | ||
24 | |||
25 | /* | ||
26 | * arpa/inet.h | ||
27 | */ | ||
28 | static inline unsigned int git_ntohl(unsigned int x) { return (unsigned int)ntohl(x); } | ||
29 | #define ntohl git_ntohl | ||
30 | int inet_aton(const char *cp, struct in_addr *inp); | ||
31 | int inet_pton(int af, const char *src, void *dst); | ||
32 | |||
33 | /* | ||
34 | * fcntl.h | ||
35 | */ | ||
36 | #define F_DUPFD 0 | ||
37 | #define F_GETFD 1 | ||
38 | #define F_SETFD 2 | ||
39 | #define F_GETFL 3 | ||
40 | #define F_SETFL 3 | ||
41 | #define FD_CLOEXEC 0x1 | ||
42 | #define O_NONBLOCK 0 | ||
43 | #define O_NOFOLLOW 0 | ||
44 | #define O_NOCTTY 0 | ||
45 | #define O_DIRECT 0 | ||
46 | #define O_SPECIAL 0x800000 | ||
47 | |||
48 | #define AT_FDCWD -100 | ||
49 | #define AT_SYMLINK_NOFOLLOW 0x100 | ||
50 | |||
51 | /* | ||
52 | * grp.h | ||
53 | */ | ||
54 | |||
55 | struct group { | ||
56 | char *gr_name; | ||
57 | char *gr_passwd; | ||
58 | gid_t gr_gid; | ||
59 | char **gr_mem; | ||
60 | }; | ||
61 | IMPL(getgrnam,struct group *,NULL,const char *name UNUSED_PARAM); | ||
62 | struct group *getgrgid(gid_t gid); | ||
63 | NOIMPL(initgroups,const char *group UNUSED_PARAM,gid_t gid UNUSED_PARAM); | ||
64 | static inline void endgrent(void) {} | ||
65 | int getgrouplist(const char *user, gid_t group, gid_t *groups, int *ngroups); | ||
66 | |||
67 | /* | ||
68 | * limits.h | ||
69 | */ | ||
70 | #define NAME_MAX 255 | ||
71 | #define MAXSYMLINKS 20 | ||
72 | |||
73 | #ifdef LONG_MAX | ||
74 | # if LONG_MAX == 2147483647 | ||
75 | # define LONG_BIT 32 | ||
76 | # else | ||
77 | /* Safe assumption. */ | ||
78 | # define LONG_BIT 64 | ||
79 | # endif | ||
80 | #elif defined __LONG_MAX__ | ||
81 | # if __LONG_MAX__ == 2147483647 | ||
82 | # define LONG_BIT 32 | ||
83 | # else | ||
84 | /* Safe assumption. */ | ||
85 | # define LONG_BIT 64 | ||
86 | # endif | ||
87 | #endif | ||
88 | |||
89 | /* | ||
90 | * netdb.h | ||
91 | */ | ||
92 | |||
93 | typedef int sa_family_t; | ||
94 | |||
95 | /* | ||
96 | * linux/un.h | ||
97 | */ | ||
98 | struct sockaddr_un { | ||
99 | sa_family_t sun_family; | ||
100 | char sun_path[1]; /* to make compiler happy, don't bother */ | ||
101 | }; | ||
102 | |||
103 | /* | ||
104 | * pwd.h | ||
105 | */ | ||
106 | struct passwd { | ||
107 | char *pw_name; | ||
108 | char *pw_passwd; | ||
109 | char *pw_gecos; | ||
110 | char *pw_dir; | ||
111 | char *pw_shell; | ||
112 | uid_t pw_uid; | ||
113 | gid_t pw_gid; | ||
114 | }; | ||
115 | |||
116 | struct passwd *getpwnam(const char *name); | ||
117 | struct passwd *getpwuid(uid_t uid); | ||
118 | static inline void setpwent(void) {} | ||
119 | static inline void endpwent(void) {} | ||
120 | IMPL(getpwent_r,int,ENOENT,struct passwd *pwbuf UNUSED_PARAM,char *buf UNUSED_PARAM,size_t buflen UNUSED_PARAM,struct passwd **pwbufp UNUSED_PARAM); | ||
121 | IMPL(getpwent,struct passwd *,NULL,void) | ||
122 | |||
123 | /* | ||
124 | * signal.h | ||
125 | */ | ||
126 | #define SIGHUP 1 | ||
127 | #define SIGQUIT 3 | ||
128 | #define SIGKILL 9 | ||
129 | #define SIGPIPE 13 | ||
130 | |||
131 | #define SIG_UNBLOCK 1 | ||
132 | |||
133 | typedef void (*sighandler_t)(int); | ||
134 | sighandler_t winansi_signal(int signum, sighandler_t handler); | ||
135 | #define signal(s, h) winansi_signal(s, h) | ||
136 | |||
137 | /* | ||
138 | * stdio.h | ||
139 | */ | ||
140 | #undef fseeko | ||
141 | #define fseeko(f,o,w) fseek(f,o,w) | ||
142 | |||
143 | int fdprintf(int fd, const char *format, ...); | ||
144 | FILE* mingw_fopen(const char *filename, const char *mode); | ||
145 | int mingw_rename(const char*, const char*); | ||
146 | #define fopen mingw_fopen | ||
147 | #define rename mingw_rename | ||
148 | |||
149 | FILE *mingw_popen(const char *cmd, const char *mode); | ||
150 | int mingw_popen_fd(const char *exe, const char *cmd, const char *mode, | ||
151 | int fd0, pid_t *pid); | ||
152 | int mingw_pclose(FILE *fd); | ||
153 | pid_t mingw_fork_compressor(int fd, const char *compressor, const char *mode); | ||
154 | #undef popen | ||
155 | #undef pclose | ||
156 | #define popen mingw_popen | ||
157 | #define pclose mingw_pclose | ||
158 | |||
159 | IMPL(setlinebuf, void, ,FILE *fd UNUSED_PARAM) | ||
160 | |||
161 | /* | ||
162 | * ANSI emulation wrappers | ||
163 | */ | ||
164 | |||
165 | BOOL conToCharBuffA(LPSTR d, DWORD len); | ||
166 | BOOL conToCharA(LPSTR d); | ||
167 | |||
168 | // same as ReadConsoleInputA, but delivers UTF8 regardless of console CP | ||
169 | BOOL readConsoleInput_utf8(HANDLE h, INPUT_RECORD *r, DWORD len, DWORD *got); | ||
170 | |||
171 | void set_title(const char *str); | ||
172 | int get_title(char *buf, int len); | ||
173 | void move_cursor_row(int n); | ||
174 | void reset_screen(void); | ||
175 | int winansi_putchar(int c); | ||
176 | int winansi_puts(const char *s); | ||
177 | size_t winansi_fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream); | ||
178 | int winansi_fputs(const char *str, FILE *stream); | ||
179 | int winansi_fputc(int c, FILE *stream); | ||
180 | int winansi_vsnprintf(char *buf, size_t size, const char *format, va_list list); | ||
181 | int winansi_vfprintf(FILE *stream, const char *format, va_list list); | ||
182 | int winansi_printf(const char *format, ...) __attribute__((format (printf, 1, 2))); | ||
183 | int winansi_fprintf(FILE *stream, const char *format, ...) __attribute__((format (printf, 2, 3))); | ||
184 | int winansi_write(int fd, const void *buf, size_t count); | ||
185 | int winansi_read(int fd, void *buf, size_t count); | ||
186 | size_t winansi_fread(void *ptr, size_t size, size_t nmemb, FILE *stream); | ||
187 | int winansi_getc(FILE *stream); | ||
188 | int winansi_getchar(void); | ||
189 | char *winansi_fgets(char *s, int size, FILE *stream); | ||
190 | void console_write(const char *str, int len); | ||
191 | |||
192 | #define putchar winansi_putchar | ||
193 | #define puts winansi_puts | ||
194 | #define fwrite winansi_fwrite | ||
195 | #define fputs winansi_fputs | ||
196 | #define fputc winansi_fputc | ||
197 | #if !defined(__USE_MINGW_ANSI_STDIO) || !__USE_MINGW_ANSI_STDIO | ||
198 | #define vsnprintf(buf, size, ...) winansi_vsnprintf(buf, size, __VA_ARGS__) | ||
199 | #endif | ||
200 | #define vfprintf(stream, ...) winansi_vfprintf(stream, __VA_ARGS__) | ||
201 | #define vprintf(...) winansi_vfprintf(stdout, __VA_ARGS__) | ||
202 | #define printf(...) winansi_printf(__VA_ARGS__) | ||
203 | #define fprintf(...) winansi_fprintf(__VA_ARGS__) | ||
204 | #define write winansi_write | ||
205 | #define read winansi_read | ||
206 | #define fread winansi_fread | ||
207 | #define getc winansi_getc | ||
208 | #define fgetc winansi_getc | ||
209 | #define getchar winansi_getchar | ||
210 | #define fgets winansi_fgets | ||
211 | |||
212 | /* | ||
213 | * stdlib.h | ||
214 | */ | ||
215 | #define WTERMSIG(x) ((x) & 0x7f) | ||
216 | #define WIFEXITED(x) (WTERMSIG(x) == 0) | ||
217 | #define WEXITSTATUS(x) (((x) & 0xff00) >> 8) | ||
218 | #define WIFSIGNALED(x) (((signed char) (((x) & 0x7f) + 1) >> 1) > 0) | ||
219 | #define WCOREDUMP(x) 0 | ||
220 | #define WIFSTOPPED(x) 0 | ||
221 | |||
222 | int mingw_system(const char *cmd); | ||
223 | #define system mingw_system | ||
224 | |||
225 | int clearenv(void); | ||
226 | char *mingw_getenv(const char *name); | ||
227 | int mingw_putenv(const char *env); | ||
228 | char *mingw_mktemp(char *template); | ||
229 | int mkstemp(char *template); | ||
230 | char *realpath(const char *path, char *resolved_path); | ||
231 | int setenv(const char *name, const char *value, int replace); | ||
232 | int unsetenv(const char *env); | ||
233 | |||
234 | #define getenv mingw_getenv | ||
235 | #define putenv mingw_putenv | ||
236 | #define mktemp mingw_mktemp | ||
237 | |||
238 | /* | ||
239 | * string.h | ||
240 | */ | ||
241 | char *strndup(char const *s, size_t n); | ||
242 | char *mingw_strerror(int errnum); | ||
243 | char *strsignal(int sig); | ||
244 | int strverscmp(const char *s1, const char *s2); | ||
245 | |||
246 | #define strerror mingw_strerror | ||
247 | |||
248 | /* | ||
249 | * strings.h | ||
250 | */ | ||
251 | #if !defined(__GNUC__) | ||
252 | int ffs(int i); | ||
253 | #else | ||
254 | # define ffs(i) __builtin_ffs(i) | ||
255 | #endif | ||
256 | |||
257 | /* | ||
258 | * sys/ioctl.h | ||
259 | */ | ||
260 | |||
261 | #define TIOCGWINSZ 0x5413 | ||
262 | #define TIOCSWINSZ 0x5414 | ||
263 | |||
264 | int ioctl(int fd, int code, ...); | ||
265 | |||
266 | /* | ||
267 | * sys/socket.h | ||
268 | */ | ||
269 | #define hstrerror strerror | ||
270 | |||
271 | #define SHUT_WR SD_SEND | ||
272 | |||
273 | int mingw_socket(int domain, int type, int protocol); | ||
274 | int mingw_connect(int sockfd, const struct sockaddr *sa, size_t sz); | ||
275 | int mingw_bind(int sockfd, struct sockaddr *sa, size_t sz); | ||
276 | int mingw_setsockopt(int sockfd, int lvl, int optname, void *optval, int optlen); | ||
277 | int mingw_shutdown(int sockfd, int how); | ||
278 | int mingw_listen(int sockfd, int backlog); | ||
279 | int mingw_accept(int sockfd1, struct sockaddr *sa, socklen_t *sz); | ||
280 | int mingw_select (int nfds, fd_set *rfds, fd_set *wfds, fd_set *xfds, | ||
281 | struct timeval *timeout); | ||
282 | int mingw_getpeername(int fd, struct sockaddr *sa, socklen_t *sz); | ||
283 | int mingw_gethostname(char *host, int namelen); | ||
284 | int mingw_getaddrinfo(const char *node, const char *service, | ||
285 | const struct addrinfo *hints, struct addrinfo **res); | ||
286 | struct hostent *mingw_gethostbyaddr(const void *addr, socklen_t len, int type); | ||
287 | |||
288 | #define socket mingw_socket | ||
289 | #define connect mingw_connect | ||
290 | #define listen mingw_listen | ||
291 | #define bind mingw_bind | ||
292 | #define setsockopt mingw_setsockopt | ||
293 | #define shutdown mingw_shutdown | ||
294 | #define accept mingw_accept | ||
295 | #define select mingw_select | ||
296 | #define getpeername mingw_getpeername | ||
297 | #define gethostname mingw_gethostname | ||
298 | #define getaddrinfo mingw_getaddrinfo | ||
299 | #define gethostbyaddr mingw_gethostbyaddr | ||
300 | |||
301 | /* | ||
302 | * sys/time.h | ||
303 | */ | ||
304 | #ifndef _TIMESPEC_DEFINED | ||
305 | #define _TIMESPEC_DEFINED | ||
306 | struct timespec { | ||
307 | time_t tv_sec; | ||
308 | long int tv_nsec; | ||
309 | }; | ||
310 | #endif | ||
311 | |||
312 | typedef int clockid_t; | ||
313 | #define CLOCK_REALTIME 0 | ||
314 | |||
315 | time_t timegm(struct tm *tm); | ||
316 | |||
317 | int nanosleep(const struct timespec *req, struct timespec *rem); | ||
318 | int clock_gettime(clockid_t clockid, struct timespec *tp); | ||
319 | int clock_settime(clockid_t clockid, const struct timespec *tp); | ||
320 | |||
321 | /* | ||
322 | * sys/stat.h | ||
323 | */ | ||
324 | #define S_ISUID 04000 | ||
325 | #define S_ISGID 02000 | ||
326 | #define S_ISVTX 01000 | ||
327 | #ifndef S_IRWXU | ||
328 | #define S_IRWXU (S_IRUSR | S_IWUSR | S_IXUSR) | ||
329 | #endif | ||
330 | #define S_IRWXG (S_IRWXU >> 3) | ||
331 | #define S_IRWXO (S_IRWXG >> 3) | ||
332 | |||
333 | #define S_IFSOCK 0140000 | ||
334 | #define S_IFLNK 0120000 /* Symbolic link */ | ||
335 | #define S_ISLNK(x) (((x) & S_IFMT) == S_IFLNK) | ||
336 | #define S_ISSOCK(x) 0 | ||
337 | |||
338 | #define S_IRGRP (S_IRUSR >> 3) | ||
339 | #define S_IWGRP (S_IWUSR >> 3) | ||
340 | #define S_IXGRP (S_IXUSR >> 3) | ||
341 | #define S_IROTH (S_IRGRP >> 3) | ||
342 | #define S_IWOTH (S_IWGRP >> 3) | ||
343 | #define S_IXOTH (S_IXGRP >> 3) | ||
344 | |||
345 | mode_t mingw_umask(mode_t mode); | ||
346 | #define umask mingw_umask | ||
347 | |||
348 | #define DEFAULT_UMASK 0002 | ||
349 | |||
350 | IMPL(fchmod,int,0,int fildes UNUSED_PARAM, mode_t mode UNUSED_PARAM); | ||
351 | NOIMPL(fchown,int fd UNUSED_PARAM, uid_t uid UNUSED_PARAM, gid_t gid UNUSED_PARAM); | ||
352 | int mingw_mkdir(const char *path, int mode); | ||
353 | int mingw_chdir(const char *path); | ||
354 | int mingw_chmod(const char *path, int mode); | ||
355 | |||
356 | #define mkdir mingw_mkdir | ||
357 | #define chdir mingw_chdir | ||
358 | #define chmod mingw_chmod | ||
359 | |||
360 | #if ENABLE_LFS && !defined(__MINGW64_VERSION_MAJOR) | ||
361 | # define off_t off64_t | ||
362 | #endif | ||
363 | |||
364 | typedef int nlink_t; | ||
365 | typedef int blksize_t; | ||
366 | typedef off_t blkcnt_t; | ||
367 | #if ENABLE_FEATURE_EXTRA_FILE_DATA | ||
368 | #define ino_t uint64_t | ||
369 | #endif | ||
370 | |||
371 | struct mingw_stat { | ||
372 | dev_t st_dev; | ||
373 | ino_t st_ino; | ||
374 | mode_t st_mode; | ||
375 | nlink_t st_nlink; | ||
376 | uid_t st_uid; | ||
377 | gid_t st_gid; | ||
378 | dev_t st_rdev; | ||
379 | off_t st_size; | ||
380 | struct timespec st_atim; | ||
381 | struct timespec st_mtim; | ||
382 | struct timespec st_ctim; | ||
383 | blksize_t st_blksize; | ||
384 | blkcnt_t st_blocks; | ||
385 | DWORD st_attr; | ||
386 | DWORD st_tag; | ||
387 | }; | ||
388 | #define st_atime st_atim.tv_sec | ||
389 | #define st_mtime st_mtim.tv_sec | ||
390 | #define st_ctime st_ctim.tv_sec | ||
391 | |||
392 | int count_subdirs(const char *pathname); | ||
393 | int mingw_lstat(const char *file_name, struct mingw_stat *buf); | ||
394 | int mingw_stat(const char *file_name, struct mingw_stat *buf); | ||
395 | int mingw_fstat(int fd, struct mingw_stat *buf); | ||
396 | #undef lstat | ||
397 | #undef stat | ||
398 | #undef fstat | ||
399 | #define lstat mingw_lstat | ||
400 | #define stat mingw_stat | ||
401 | #define fstat mingw_fstat | ||
402 | |||
403 | #define UTIME_NOW ((1l << 30) - 1l) | ||
404 | #define UTIME_OMIT ((1l << 30) - 2l) | ||
405 | |||
406 | int utimensat(int fd, const char *path, const struct timespec times[2], | ||
407 | int flags); | ||
408 | int futimens(int fd, const struct timespec times[2]); | ||
409 | |||
410 | /* | ||
411 | * sys/sysinfo.h | ||
412 | */ | ||
413 | struct sysinfo { | ||
414 | long uptime; /* Seconds since boot */ | ||
415 | unsigned long loads[3]; /* 1, 5, and 15 minute load averages */ | ||
416 | unsigned long totalram; /* Total usable main memory size */ | ||
417 | unsigned long freeram; /* Available memory size */ | ||
418 | unsigned long sharedram; /* Amount of shared memory */ | ||
419 | unsigned long bufferram; /* Memory used by buffers */ | ||
420 | unsigned long totalswap; /* Total swap space size */ | ||
421 | unsigned long freeswap; /* Swap space still available */ | ||
422 | unsigned short procs; /* Number of current processes */ | ||
423 | unsigned long totalhigh; /* Total high memory size */ | ||
424 | unsigned long freehigh; /* Available high memory size */ | ||
425 | unsigned int mem_unit; /* Memory unit size in bytes */ | ||
426 | }; | ||
427 | |||
428 | int sysinfo(struct sysinfo *info); | ||
429 | |||
430 | /* | ||
431 | * sys/sysmacros.h | ||
432 | */ | ||
433 | #define makedev(a,b) 0*(a)*(b) /* avoid unused warning */ | ||
434 | #define minor(x) 0 | ||
435 | #define major(x) 0 | ||
436 | |||
437 | /* | ||
438 | * sys/wait.h | ||
439 | */ | ||
440 | #define WNOHANG 1 | ||
441 | #define WUNTRACED 2 | ||
442 | pid_t waitpid(pid_t pid, int *status, int options); | ||
443 | pid_t mingw_wait3(pid_t pid, int *status, int options, struct rusage *rusage); | ||
444 | |||
445 | /* | ||
446 | * time.h | ||
447 | */ | ||
448 | struct tm *gmtime_r(const time_t *timep, struct tm *result); | ||
449 | struct tm *localtime_r(const time_t *timep, struct tm *result); | ||
450 | char *strptime(const char *s, const char *format, struct tm *tm); | ||
451 | char *mingw_strptime(const char *s, const char *format, struct tm *tm, long *gmt); | ||
452 | size_t mingw_strftime(char *buf, size_t max, const char *format, const struct tm *tm); | ||
453 | |||
454 | #define strftime mingw_strftime | ||
455 | |||
456 | /* | ||
457 | * times.h | ||
458 | */ | ||
459 | #define clock_t long | ||
460 | |||
461 | struct tms { | ||
462 | clock_t tms_utime; /* user CPU time */ | ||
463 | clock_t tms_stime; /* system CPU time */ | ||
464 | clock_t tms_cutime; /* user CPU time of children */ | ||
465 | clock_t tms_cstime; /* system CPU time of children */ | ||
466 | }; | ||
467 | |||
468 | clock_t times(struct tms *buf); | ||
469 | |||
470 | /* | ||
471 | * unistd.h | ||
472 | */ | ||
473 | #define PIPE_BUF 8192 | ||
474 | |||
475 | #define _SC_CLK_TCK 2 | ||
476 | |||
477 | #define TICKS_PER_SECOND 100 | ||
478 | #define MS_PER_TICK 10 | ||
479 | #define HNSEC_PER_TICK 100000 | ||
480 | |||
481 | IMPL(alarm,unsigned int,0,unsigned int seconds UNUSED_PARAM); | ||
482 | IMPL(chown,int,0,const char *path UNUSED_PARAM, uid_t uid UNUSED_PARAM, gid_t gid UNUSED_PARAM); | ||
483 | NOIMPL(chroot,const char *root UNUSED_PARAM); | ||
484 | NOIMPL(fchdir,int fd UNUSED_PARAM); | ||
485 | int mingw_dup2 (int fd, int fdto); | ||
486 | char *mingw_getcwd(char *pointer, int len); | ||
487 | off_t mingw_lseek(int fd, off_t offset, int whence); | ||
488 | |||
489 | |||
490 | int getuid(void); | ||
491 | #define getgid getuid | ||
492 | #define geteuid getuid | ||
493 | #define getegid getuid | ||
494 | int getgroups(int n, gid_t *groups); | ||
495 | pid_t getppid(void); | ||
496 | NOIMPL(getsid,pid_t pid UNUSED_PARAM); | ||
497 | int getlogin_r(char *buf, size_t len); | ||
498 | int fcntl(int fd, int cmd, ...); | ||
499 | int fsync(int fd); | ||
500 | int kill(pid_t pid, int sig); | ||
501 | int link(const char *oldpath, const char *newpath); | ||
502 | NOIMPL(mknod,const char *name UNUSED_PARAM, mode_t mode UNUSED_PARAM, dev_t device UNUSED_PARAM); | ||
503 | /* order of devices must match that in get_dev_type */ | ||
504 | enum {DEV_NULL, DEV_ZERO, DEV_URANDOM, NOT_DEVICE = -1}; | ||
505 | int get_dev_type(const char *filename); | ||
506 | void update_special_fd(int dev, int fd); | ||
507 | int mingw_open (const char *filename, int oflags, ...); | ||
508 | |||
509 | /* functions which add O_SPECIAL to open(2) to allow access to devices */ | ||
510 | int mingw_xopen(const char *filename, int oflags); | ||
511 | ssize_t mingw_open_read_close(const char *fn, void *buf, size_t size) FAST_FUNC; | ||
512 | |||
513 | #ifndef IO_REPARSE_TAG_APPEXECLINK | ||
514 | # define IO_REPARSE_TAG_APPEXECLINK 0x8000001b | ||
515 | #endif | ||
516 | |||
517 | ssize_t mingw_read(int fd, void *buf, size_t count); | ||
518 | int mingw_close(int fd); | ||
519 | int pipe(int filedes[2]); | ||
520 | NOIMPL(setgid,gid_t gid UNUSED_PARAM); | ||
521 | NOIMPL(setegid,gid_t gid UNUSED_PARAM); | ||
522 | NOIMPL(setsid,void); | ||
523 | NOIMPL(setuid,uid_t gid UNUSED_PARAM); | ||
524 | NOIMPL(seteuid,uid_t gid UNUSED_PARAM); | ||
525 | unsigned int sleep(unsigned int seconds); | ||
526 | int symlink(const char *target, const char *linkpath); | ||
527 | int create_junction(const char *oldpath, const char *newpath); | ||
528 | long sysconf(int name); | ||
529 | IMPL(getpagesize,int,4096,void); | ||
530 | NOIMPL(ttyname_r,int fd UNUSED_PARAM, char *buf UNUSED_PARAM, int sz UNUSED_PARAM); | ||
531 | int mingw_unlink(const char *pathname); | ||
532 | int mingw_access(const char *name, int mode); | ||
533 | int mingw_rmdir(const char *name); | ||
534 | void mingw_sync(void); | ||
535 | int mingw_isatty(int fd); | ||
536 | |||
537 | #define dup2 mingw_dup2 | ||
538 | #define getcwd mingw_getcwd | ||
539 | #define lchown chown | ||
540 | #define open mingw_open | ||
541 | #define close mingw_close | ||
542 | #define unlink mingw_unlink | ||
543 | #define rmdir mingw_rmdir | ||
544 | #define sync mingw_sync | ||
545 | #undef lseek | ||
546 | #define lseek mingw_lseek | ||
547 | |||
548 | #undef access | ||
549 | #define access mingw_access | ||
550 | #define isatty mingw_isatty | ||
551 | |||
552 | /* | ||
553 | * utime.h | ||
554 | */ | ||
555 | int utimes(const char *file_name, const struct timeval times[2]); | ||
556 | |||
557 | /* | ||
558 | * Functions with different prototypes in BusyBox and WIN32 | ||
559 | */ | ||
560 | #define itoa bb_itoa | ||
561 | #define strrev bb_strrev | ||
562 | |||
563 | /* | ||
564 | * MinGW specific | ||
565 | */ | ||
566 | #define is_dir_sep(c) ((c) == '/' || (c) == '\\') | ||
567 | #define is_unc_path(x) (strlen(x) > 4 && is_dir_sep(x[0]) && \ | ||
568 | is_dir_sep(x[1]) && !is_dir_sep(x[2])) | ||
569 | |||
570 | typedef struct { | ||
571 | char *path; | ||
572 | char *name; | ||
573 | char *opts; | ||
574 | char buf[100]; | ||
575 | } interp_t; | ||
576 | |||
577 | int FAST_FUNC parse_interpreter(const char *cmd, interp_t *interp); | ||
578 | char ** FAST_FUNC grow_argv(char **argv, int n); | ||
579 | pid_t FAST_FUNC mingw_spawn(char **argv); | ||
580 | intptr_t FAST_FUNC mingw_spawn_detach(char **argv); | ||
581 | intptr_t FAST_FUNC mingw_spawn_proc(const char **argv); | ||
582 | int mingw_execv(const char *cmd, char *const *argv); | ||
583 | int httpd_execv_detach(const char *cmd, char *const *argv); | ||
584 | int mingw_execvp(const char *cmd, char *const *argv); | ||
585 | int mingw_execve(const char *cmd, char *const *argv, char *const *envp); | ||
586 | #define spawn mingw_spawn | ||
587 | #define execvp mingw_execvp | ||
588 | #define execve mingw_execve | ||
589 | #define execv mingw_execv | ||
590 | #define HTTPD_DETACH (8) | ||
591 | |||
592 | #define has_dos_drive_prefix(path) (isalpha(*(path)) && (path)[1] == ':') | ||
593 | |||
594 | BOOL WINAPI kill_child_ctrl_handler(DWORD dwCtrlType); | ||
595 | int FAST_FUNC is_valid_signal(int number); | ||
596 | int exit_code_to_wait_status(DWORD win_exit_code); | ||
597 | int exit_code_to_posix(DWORD win_exit_code); | ||
598 | |||
599 | #define find_mount_point(n, s) find_mount_point(n) | ||
600 | |||
601 | char *is_prefixed_with_case(const char *string, const char *key) FAST_FUNC; | ||
602 | char *is_suffixed_with_case(const char *string, const char *key) FAST_FUNC; | ||
603 | |||
604 | #define VT_OUTPUT 1 | ||
605 | #define VT_INPUT 2 | ||
606 | |||
607 | /* | ||
608 | * helpers | ||
609 | */ | ||
610 | |||
611 | const char *get_busybox_exec_path(void); | ||
612 | void init_winsock(void); | ||
613 | |||
614 | int has_bat_suffix(const char *p); | ||
615 | int has_exe_suffix(const char *p); | ||
616 | int has_exe_suffix_or_dot(const char *name); | ||
617 | char *alloc_ext_space(const char *path); | ||
618 | int add_win32_extension(char *p); | ||
619 | char *file_is_win32_exe(const char *name); | ||
620 | |||
621 | #if ENABLE_UNICODE_SUPPORT | ||
622 | /* | ||
623 | * windows wchar_t is 16 bit, while linux (and busybox expectation) is 32. | ||
624 | * so when (busybox) unicode.h is included, wchar_t is 32 bit. | ||
625 | * Without unicode.h, MINGW_BB_WCHAR_T is busybox wide char (32), | ||
626 | * and wchar_t is Windows wide char (16). | ||
627 | */ | ||
628 | #define MINGW_BB_WCHAR_T uint32_t /* keep in sync with unicode.h */ | ||
629 | |||
630 | MINGW_BB_WCHAR_T *bs_to_slash_u(MINGW_BB_WCHAR_T *p) FAST_FUNC; | ||
631 | #endif | ||
632 | |||
633 | char *bs_to_slash(char *p) FAST_FUNC; | ||
634 | void slash_to_bs(char *p) FAST_FUNC; | ||
635 | void strip_dot_space(char *p) FAST_FUNC; | ||
636 | size_t remove_cr(char *p, size_t len) FAST_FUNC; | ||
637 | |||
638 | int err_win_to_posix(void); | ||
639 | |||
640 | ULONGLONG CompatGetTickCount64(void); | ||
641 | #define GetTickCount64 CompatGetTickCount64 | ||
642 | |||
643 | ssize_t get_random_bytes(void *buf, ssize_t count); | ||
644 | int enumerate_links(const char *file, char *name); | ||
645 | |||
646 | int unc_root_len(const char *dir) FAST_FUNC; | ||
647 | int root_len(const char *path) FAST_FUNC; | ||
648 | const char *get_system_drive(void) FAST_FUNC; | ||
649 | int chdir_system_drive(void); | ||
650 | char *xabsolute_path(char *path) FAST_FUNC; | ||
651 | char *get_drive_cwd(const char *path, char *buffer, int size) FAST_FUNC; | ||
652 | void fix_path_case(char *path) FAST_FUNC; | ||
653 | void make_sparse(int fd, off_t start, off_t end) FAST_FUNC; | ||
654 | int terminal_mode(int reset) FAST_FUNC; | ||
655 | int unix_path(const char *path) FAST_FUNC; | ||
656 | int has_path(const char *file) FAST_FUNC; | ||
657 | int is_relative_path(const char *path) FAST_FUNC; | ||
658 | char *get_last_slash(const char *path) FAST_FUNC; | ||
659 | const char *applet_to_exe(const char *name) FAST_FUNC; | ||
660 | char *get_user_name(void); | ||
661 | char *quote_arg(const char *arg) FAST_FUNC; | ||
662 | char *find_first_executable(const char *name) FAST_FUNC; | ||
663 | char *xappendword(const char *str, const char *word) FAST_FUNC; | ||
664 | int windows_env(void); | ||
665 | void change_critical_error_dialogs(const char *newval) FAST_FUNC; | ||
666 | char *exe_relative_path(const char *tail) FAST_FUNC; | ||
667 | enum { | ||
668 | ELEVATED_PRIVILEGE = 1, | ||
669 | ADMIN_ENABLED = 2 | ||
670 | }; | ||
671 | int elevation_state(void); | ||
672 | void set_interp(int i) FAST_FUNC; | ||
673 | int mingw_shell_execute(SHELLEXECUTEINFO *info); | ||
674 | void mingw_die_if_error(NTSTATUS status, const char *function_name); | ||