Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

325 lines
11 KiB

  1. #ifndef WIN32IOP_H
  2. #define WIN32IOP_H
  3. #ifndef START_EXTERN_C
  4. #ifdef __cplusplus
  5. # define START_EXTERN_C extern "C" {
  6. # define END_EXTERN_C }
  7. # define EXTERN_C extern "C"
  8. #else
  9. # define START_EXTERN_C
  10. # define END_EXTERN_C
  11. # define EXTERN_C
  12. #endif
  13. #endif
  14. #if defined(_MSC_VER) || defined(__MINGW32__)
  15. # include <sys/utime.h>
  16. #else
  17. # include <utime.h>
  18. #endif
  19. /*
  20. * defines for flock emulation
  21. */
  22. #define LOCK_SH 1
  23. #define LOCK_EX 2
  24. #define LOCK_NB 4
  25. #define LOCK_UN 8
  26. /*
  27. * Make this as close to original stdio as possible.
  28. */
  29. /*
  30. * function prototypes for our own win32io layer
  31. */
  32. START_EXTERN_C
  33. DllExport int * win32_errno(void);
  34. DllExport char *** win32_environ(void);
  35. DllExport FILE* win32_stdin(void);
  36. DllExport FILE* win32_stdout(void);
  37. DllExport FILE* win32_stderr(void);
  38. DllExport int win32_ferror(FILE *fp);
  39. DllExport int win32_feof(FILE *fp);
  40. DllExport char* win32_strerror(int e);
  41. DllExport int win32_fprintf(FILE *pf, const char *format, ...);
  42. DllExport int win32_printf(const char *format, ...);
  43. DllExport int win32_vfprintf(FILE *pf, const char *format, va_list arg);
  44. DllExport int win32_vprintf(const char *format, va_list arg);
  45. DllExport size_t win32_fread(void *buf, size_t size, size_t count, FILE *pf);
  46. DllExport size_t win32_fwrite(const void *buf, size_t size, size_t count, FILE *pf);
  47. DllExport FILE* win32_fopen(const char *path, const char *mode);
  48. DllExport FILE* win32_fdopen(int fh, const char *mode);
  49. DllExport FILE* win32_freopen(const char *path, const char *mode, FILE *pf);
  50. DllExport int win32_fclose(FILE *pf);
  51. DllExport int win32_fputs(const char *s,FILE *pf);
  52. DllExport int win32_fputc(int c,FILE *pf);
  53. DllExport int win32_ungetc(int c,FILE *pf);
  54. DllExport int win32_getc(FILE *pf);
  55. DllExport int win32_fileno(FILE *pf);
  56. DllExport void win32_clearerr(FILE *pf);
  57. DllExport int win32_fflush(FILE *pf);
  58. DllExport long win32_ftell(FILE *pf);
  59. DllExport int win32_fseek(FILE *pf,long offset,int origin);
  60. DllExport int win32_fgetpos(FILE *pf,fpos_t *p);
  61. DllExport int win32_fsetpos(FILE *pf,const fpos_t *p);
  62. DllExport void win32_rewind(FILE *pf);
  63. DllExport FILE* win32_tmpfile(void);
  64. DllExport void win32_abort(void);
  65. DllExport int win32_fstat(int fd,struct stat *sbufptr);
  66. DllExport int win32_stat(const char *name,struct stat *sbufptr);
  67. DllExport int win32_pipe( int *phandles, unsigned int psize, int textmode );
  68. DllExport FILE* win32_popen( const char *command, const char *mode );
  69. DllExport int win32_pclose( FILE *pf);
  70. DllExport int win32_rename( const char *oname, const char *newname);
  71. DllExport int win32_setmode( int fd, int mode);
  72. DllExport long win32_lseek( int fd, long offset, int origin);
  73. DllExport long win32_tell( int fd);
  74. DllExport int win32_dup( int fd);
  75. DllExport int win32_dup2(int h1, int h2);
  76. DllExport int win32_open(const char *path, int oflag,...);
  77. DllExport int win32_close(int fd);
  78. DllExport int win32_eof(int fd);
  79. DllExport int win32_read(int fd, void *buf, unsigned int cnt);
  80. DllExport int win32_write(int fd, const void *buf, unsigned int cnt);
  81. DllExport int win32_spawnvp(int mode, const char *cmdname,
  82. const char *const *argv);
  83. DllExport int win32_mkdir(const char *dir, int mode);
  84. DllExport int win32_rmdir(const char *dir);
  85. DllExport int win32_chdir(const char *dir);
  86. DllExport int win32_flock(int fd, int oper);
  87. DllExport int win32_execv(const char *cmdname, const char *const *argv);
  88. DllExport int win32_execvp(const char *cmdname, const char *const *argv);
  89. DllExport void win32_perror(const char *str);
  90. DllExport void win32_setbuf(FILE *pf, char *buf);
  91. DllExport int win32_setvbuf(FILE *pf, char *buf, int type, size_t size);
  92. DllExport int win32_flushall(void);
  93. DllExport int win32_fcloseall(void);
  94. DllExport char* win32_fgets(char *s, int n, FILE *pf);
  95. DllExport char* win32_gets(char *s);
  96. DllExport int win32_fgetc(FILE *pf);
  97. DllExport int win32_putc(int c, FILE *pf);
  98. DllExport int win32_puts(const char *s);
  99. DllExport int win32_getchar(void);
  100. DllExport int win32_putchar(int c);
  101. DllExport void* win32_malloc(size_t size);
  102. DllExport void* win32_calloc(size_t numitems, size_t size);
  103. DllExport void* win32_realloc(void *block, size_t size);
  104. DllExport void win32_free(void *block);
  105. DllExport int win32_open_osfhandle(long handle, int flags);
  106. DllExport long win32_get_osfhandle(int fd);
  107. DllExport DIR* win32_opendir(char *filename);
  108. DllExport struct direct* win32_readdir(DIR *dirp);
  109. DllExport long win32_telldir(DIR *dirp);
  110. DllExport void win32_seekdir(DIR *dirp, long loc);
  111. DllExport void win32_rewinddir(DIR *dirp);
  112. DllExport int win32_closedir(DIR *dirp);
  113. DllExport char* win32_getenv(const char *name);
  114. DllExport int win32_putenv(const char *name);
  115. DllExport unsigned win32_sleep(unsigned int);
  116. DllExport int win32_times(struct tms *timebuf);
  117. DllExport unsigned win32_alarm(unsigned int sec);
  118. DllExport int win32_stat(const char *path, struct stat *buf);
  119. DllExport char* win32_longpath(char *path);
  120. DllExport int win32_ioctl(int i, unsigned int u, char *data);
  121. DllExport int win32_link(const char *oldname, const char *newname);
  122. DllExport int win32_unlink(const char *f);
  123. DllExport int win32_utime(const char *f, struct utimbuf *t);
  124. DllExport int win32_uname(struct utsname *n);
  125. DllExport int win32_wait(int *status);
  126. DllExport int win32_waitpid(int pid, int *status, int flags);
  127. DllExport int win32_kill(int pid, int sig);
  128. DllExport unsigned long win32_os_id(void);
  129. DllExport void* win32_dynaload(const char*filename);
  130. DllExport int win32_access(const char *path, int mode);
  131. DllExport int win32_chmod(const char *path, int mode);
  132. DllExport int win32_getpid(void);
  133. DllExport char * win32_crypt(const char *txt, const char *salt);
  134. DllExport void * win32_get_childenv(void);
  135. DllExport void win32_free_childenv(void* d);
  136. DllExport void win32_clearenv(void);
  137. DllExport char * win32_get_childdir(void);
  138. DllExport void win32_free_childdir(char* d);
  139. END_EXTERN_C
  140. /*
  141. * the following six(6) is #define in stdio.h
  142. */
  143. #ifndef WIN32IO_IS_STDIO
  144. #undef errno
  145. #undef environ
  146. #undef stderr
  147. #undef stdin
  148. #undef stdout
  149. #undef ferror
  150. #undef feof
  151. #undef fclose
  152. #undef pipe
  153. #undef pause
  154. #undef sleep
  155. #undef times
  156. #undef alarm
  157. #undef ioctl
  158. #undef unlink
  159. #undef utime
  160. #undef uname
  161. #undef wait
  162. #ifdef __BORLANDC__
  163. #undef ungetc
  164. #undef getc
  165. #undef putc
  166. #undef getchar
  167. #undef putchar
  168. #undef fileno
  169. #endif
  170. #define stderr win32_stderr()
  171. #define stdout win32_stdout()
  172. #define stdin win32_stdin()
  173. #define feof(f) win32_feof(f)
  174. #define ferror(f) win32_ferror(f)
  175. #define errno (*win32_errno())
  176. #define environ (*win32_environ())
  177. #define strerror win32_strerror
  178. /*
  179. * redirect to our own version
  180. */
  181. #undef fprintf
  182. #define fprintf win32_fprintf
  183. #define vfprintf win32_vfprintf
  184. #define printf win32_printf
  185. #define vprintf win32_vprintf
  186. #define fread(buf,size,count,f) win32_fread(buf,size,count,f)
  187. #define fwrite(buf,size,count,f) win32_fwrite(buf,size,count,f)
  188. #define fopen win32_fopen
  189. #undef fdopen
  190. #define fdopen win32_fdopen
  191. #define freopen win32_freopen
  192. #define fclose(f) win32_fclose(f)
  193. #define fputs(s,f) win32_fputs(s,f)
  194. #define fputc(c,f) win32_fputc(c,f)
  195. #define ungetc(c,f) win32_ungetc(c,f)
  196. #undef getc
  197. #define getc(f) win32_getc(f)
  198. #define fileno(f) win32_fileno(f)
  199. #define clearerr(f) win32_clearerr(f)
  200. #define fflush(f) win32_fflush(f)
  201. #define ftell(f) win32_ftell(f)
  202. #define fseek(f,o,w) win32_fseek(f,o,w)
  203. #define fgetpos(f,p) win32_fgetpos(f,p)
  204. #define fsetpos(f,p) win32_fsetpos(f,p)
  205. #define rewind(f) win32_rewind(f)
  206. #define tmpfile() win32_tmpfile()
  207. #define abort() win32_abort()
  208. #define fstat(fd,bufptr) win32_fstat(fd,bufptr)
  209. #define stat(pth,bufptr) win32_stat(pth,bufptr)
  210. #define longpath(pth) win32_longpath(pth)
  211. #define rename(old,new) win32_rename(old,new)
  212. #define setmode(fd,mode) win32_setmode(fd,mode)
  213. #define lseek(fd,offset,orig) win32_lseek(fd,offset,orig)
  214. #define tell(fd) win32_tell(fd)
  215. #define dup(fd) win32_dup(fd)
  216. #define dup2(fd1,fd2) win32_dup2(fd1,fd2)
  217. #define open win32_open
  218. #define close(fd) win32_close(fd)
  219. #define eof(fd) win32_eof(fd)
  220. #define read(fd,b,s) win32_read(fd,b,s)
  221. #define write(fd,b,s) win32_write(fd,b,s)
  222. #define _open_osfhandle win32_open_osfhandle
  223. #define _get_osfhandle win32_get_osfhandle
  224. #define spawnvp win32_spawnvp
  225. #define mkdir win32_mkdir
  226. #define rmdir win32_rmdir
  227. #define chdir win32_chdir
  228. #define flock(fd,o) win32_flock(fd,o)
  229. #define execv win32_execv
  230. #define execvp win32_execvp
  231. #define perror win32_perror
  232. #define setbuf win32_setbuf
  233. #define setvbuf win32_setvbuf
  234. #undef flushall
  235. #define flushall win32_flushall
  236. #undef fcloseall
  237. #define fcloseall win32_fcloseall
  238. #define fgets win32_fgets
  239. #define gets win32_gets
  240. #define fgetc win32_fgetc
  241. #undef putc
  242. #define putc win32_putc
  243. #define puts win32_puts
  244. #undef getchar
  245. #define getchar win32_getchar
  246. #undef putchar
  247. #define putchar win32_putchar
  248. #define access(p,m) win32_access(p,m)
  249. #define chmod(p,m) win32_chmod(p,m)
  250. #if !defined(MYMALLOC) || !defined(PERL_CORE)
  251. #undef malloc
  252. #undef calloc
  253. #undef realloc
  254. #undef free
  255. #define malloc win32_malloc
  256. #define calloc win32_calloc
  257. #define realloc win32_realloc
  258. #define free win32_free
  259. #endif
  260. #define pipe(fd) win32_pipe((fd), 512, O_BINARY)
  261. #define pause() win32_sleep((32767L << 16) + 32767)
  262. #define sleep win32_sleep
  263. #define times win32_times
  264. #define alarm win32_alarm
  265. #define ioctl win32_ioctl
  266. #define link win32_link
  267. #define unlink win32_unlink
  268. #define utime win32_utime
  269. #define uname win32_uname
  270. #define wait win32_wait
  271. #define waitpid win32_waitpid
  272. #define kill win32_kill
  273. #define opendir win32_opendir
  274. #define readdir win32_readdir
  275. #define telldir win32_telldir
  276. #define seekdir win32_seekdir
  277. #define rewinddir win32_rewinddir
  278. #define closedir win32_closedir
  279. #define os_id win32_os_id
  280. #define getpid win32_getpid
  281. #undef crypt
  282. #define crypt(t,s) win32_crypt(t,s)
  283. #undef get_childenv
  284. #undef free_childenv
  285. #undef clearenv
  286. #undef get_childdir
  287. #undef free_childdir
  288. #define get_childenv() win32_get_childenv()
  289. #define free_childenv(d) win32_free_childenv(d)
  290. #define clearenv() win32_clearenv()
  291. #define get_childdir() win32_get_childdir()
  292. #define free_childdir(d) win32_free_childdir(d)
  293. #undef getenv
  294. #define getenv win32_getenv
  295. #undef putenv
  296. #define putenv win32_putenv
  297. #endif /* WIN32IO_IS_STDIO */
  298. #endif /* WIN32IOP_H */