This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
run/locale.t: Add explanation for when tests fail
[perl5.git] / win32 / win32iop.h
CommitLineData
0a753a76 1#ifndef WIN32IOP_H
2#define WIN32IOP_H
3
326b05e3
GS
4#ifndef START_EXTERN_C
5#ifdef __cplusplus
6# define START_EXTERN_C extern "C" {
7# define END_EXTERN_C }
8# define EXTERN_C extern "C"
9#else
3fadfdf1
NIS
10# define START_EXTERN_C
11# define END_EXTERN_C
326b05e3
GS
12# define EXTERN_C
13#endif
14#endif
15
4eab039d 16#include <sys/utime.h>
3b405fc5 17
d55594ae
GS
18/*
19 * defines for flock emulation
20 */
21#define LOCK_SH 1
22#define LOCK_EX 2
23#define LOCK_NB 4
24#define LOCK_UN 8
25
0a753a76 26/*
27 * Make this as close to original stdio as possible.
28 */
68dc0745 29
30/*
31 * function prototypes for our own win32io layer
32 */
d55594ae
GS
33START_EXTERN_C
34
22239a37
NIS
35DllExport int * win32_errno(void);
36DllExport char *** win32_environ(void);
37DllExport FILE* win32_stdin(void);
38DllExport FILE* win32_stdout(void);
39DllExport FILE* win32_stderr(void);
40DllExport int win32_ferror(FILE *fp);
41DllExport int win32_feof(FILE *fp);
42DllExport char* win32_strerror(int e);
43
44DllExport int win32_fprintf(FILE *pf, const char *format, ...);
45DllExport int win32_printf(const char *format, ...);
46DllExport int win32_vfprintf(FILE *pf, const char *format, va_list arg);
47DllExport int win32_vprintf(const char *format, va_list arg);
48DllExport size_t win32_fread(void *buf, size_t size, size_t count, FILE *pf);
49DllExport size_t win32_fwrite(const void *buf, size_t size, size_t count, FILE *pf);
50DllExport FILE* win32_fopen(const char *path, const char *mode);
51DllExport FILE* win32_fdopen(int fh, const char *mode);
52DllExport FILE* win32_freopen(const char *path, const char *mode, FILE *pf);
53DllExport int win32_fclose(FILE *pf);
54DllExport int win32_fputs(const char *s,FILE *pf);
55DllExport int win32_fputc(int c,FILE *pf);
56DllExport int win32_ungetc(int c,FILE *pf);
57DllExport int win32_getc(FILE *pf);
58DllExport int win32_fileno(FILE *pf);
26618a56 59DllExport void win32_clearerr(FILE *pf);
22239a37 60DllExport int win32_fflush(FILE *pf);
c623ac67
GS
61DllExport Off_t win32_ftell(FILE *pf);
62DllExport int win32_fseek(FILE *pf,Off_t offset,int origin);
22239a37
NIS
63DllExport int win32_fgetpos(FILE *pf,fpos_t *p);
64DllExport int win32_fsetpos(FILE *pf,const fpos_t *p);
26618a56 65DllExport void win32_rewind(FILE *pf);
2941a2e1 66DllExport int win32_tmpfd(void);
22239a37 67DllExport FILE* win32_tmpfile(void);
26618a56 68DllExport void win32_abort(void);
c623ac67
GS
69DllExport int win32_fstat(int fd,Stat_t *sbufptr);
70DllExport int win32_stat(const char *name,Stat_t *sbufptr);
22239a37 71DllExport int win32_pipe( int *phandles, unsigned int psize, int textmode );
adb71456 72DllExport PerlIO* win32_popen( const char *command, const char *mode );
8c0134a8 73DllExport PerlIO* win32_popenlist(const char *mode, IV narg, SV **args);
adb71456 74DllExport int win32_pclose( PerlIO *pf);
8d9b2e3c 75DllExport int win32_rename( const char *oname, const char *newname);
22239a37 76DllExport int win32_setmode( int fd, int mode);
4a9d6100 77DllExport int win32_chsize(int fd, Off_t size);
c623ac67
GS
78DllExport Off_t win32_lseek( int fd, Off_t offset, int origin);
79DllExport Off_t win32_tell( int fd);
22239a37
NIS
80DllExport int win32_dup( int fd);
81DllExport int win32_dup2(int h1, int h2);
82DllExport int win32_open(const char *path, int oflag,...);
83DllExport int win32_close(int fd);
84DllExport int win32_eof(int fd);
4342f4d6 85DllExport int win32_isatty(int fd);
22239a37
NIS
86DllExport int win32_read(int fd, void *buf, unsigned int cnt);
87DllExport int win32_write(int fd, const void *buf, unsigned int cnt);
88DllExport int win32_spawnvp(int mode, const char *cmdname,
3e3baf6d 89 const char *const *argv);
22239a37
NIS
90DllExport int win32_mkdir(const char *dir, int mode);
91DllExport int win32_rmdir(const char *dir);
92DllExport int win32_chdir(const char *dir);
93DllExport int win32_flock(int fd, int oper);
eb62e965 94DllExport int win32_execv(const char *cmdname, const char *const *argv);
22239a37 95DllExport int win32_execvp(const char *cmdname, const char *const *argv);
26618a56
GS
96DllExport void win32_perror(const char *str);
97DllExport void win32_setbuf(FILE *pf, char *buf);
22239a37
NIS
98DllExport int win32_setvbuf(FILE *pf, char *buf, int type, size_t size);
99DllExport int win32_flushall(void);
100DllExport int win32_fcloseall(void);
101DllExport char* win32_fgets(char *s, int n, FILE *pf);
102DllExport char* win32_gets(char *s);
103DllExport int win32_fgetc(FILE *pf);
104DllExport int win32_putc(int c, FILE *pf);
105DllExport int win32_puts(const char *s);
106DllExport int win32_getchar(void);
107DllExport int win32_putchar(int c);
108DllExport void* win32_malloc(size_t size);
109DllExport void* win32_calloc(size_t numitems, size_t size);
110DllExport void* win32_realloc(void *block, size_t size);
26618a56 111DllExport void win32_free(void *block);
22239a37 112
c623ac67
GS
113DllExport int win32_open_osfhandle(intptr_t handle, int flags);
114DllExport intptr_t win32_get_osfhandle(int fd);
6e21dc91 115DllExport FILE* win32_fdupopen(FILE *pf);
0a753a76 116
0e06f75d 117DllExport DIR* win32_opendir(const char *filename);
c5be433b
GS
118DllExport struct direct* win32_readdir(DIR *dirp);
119DllExport long win32_telldir(DIR *dirp);
120DllExport void win32_seekdir(DIR *dirp, long loc);
121DllExport void win32_rewinddir(DIR *dirp);
122DllExport int win32_closedir(DIR *dirp);
60b22aca 123DllExport DIR* win32_dirp_dup(DIR *const dirp, CLONE_PARAMS *const param);
c5be433b 124
4f46e52b 125DllExport char* win32_getenvironmentstrings(void);
2c8ca683 126/* also see win32_freeenvironmentstrings macro */
22239a37 127DllExport char* win32_getenv(const char *name);
ac5c734f 128DllExport int win32_putenv(const char *name);
f3986ebb 129
26618a56
GS
130DllExport unsigned win32_sleep(unsigned int);
131DllExport int win32_times(struct tms *timebuf);
132DllExport unsigned win32_alarm(unsigned int sec);
c623ac67 133DllExport int win32_stat(const char *path, Stat_t *buf);
8ac9c18d 134DllExport char* win32_longpath(char *path);
aa2b96ec 135DllExport char* win32_ansipath(const WCHAR *path);
f998180f 136DllExport int win32_ioctl(int i, unsigned int u, char *data);
6b980173 137DllExport int win32_link(const char *oldname, const char *newname);
7766f137 138DllExport int win32_unlink(const char *f);
3b405fc5 139DllExport int win32_utime(const char *f, struct utimbuf *t);
57ab3dfe 140DllExport int win32_gettimeofday(struct timeval *tp, void *not_used);
b2af26b1 141DllExport int win32_uname(struct utsname *n);
2d7a9237 142DllExport int win32_wait(int *status);
f55ee38a
GS
143DllExport int win32_waitpid(int pid, int *status, int flags);
144DllExport int win32_kill(int pid, int sig);
0cb96387
GS
145DllExport unsigned long win32_os_id(void);
146DllExport void* win32_dynaload(const char*filename);
7766f137
GS
147DllExport int win32_access(const char *path, int mode);
148DllExport int win32_chmod(const char *path, int mode);
149DllExport int win32_getpid(void);
26618a56 150
26618a56 151DllExport char * win32_crypt(const char *txt, const char *salt);
0a753a76 152
df3728a2
JH
153DllExport void * win32_get_childenv(void);
154DllExport void win32_free_childenv(void* d);
155DllExport void win32_clearenv(void);
156DllExport char * win32_get_childdir(void);
157DllExport void win32_free_childdir(char* d);
3fadfdf1
NIS
158DllExport Sighandler_t win32_signal(int sig, Sighandler_t subcode);
159
df3728a2 160
d55594ae
GS
161END_EXTERN_C
162
2c8ca683
DD
163/* see comment in win32_getenvironmentstrings */
164#define win32_freeenvironmentstrings(x) win32_free(x)
8fb3fcfb 165#undef alarm
364d54ba
JD
166#define alarm win32_alarm
167#undef strerror
168#define strerror win32_strerror
8fb3fcfb 169
68dc0745 170/*
171 * the following six(6) is #define in stdio.h
172 */
0a753a76 173#ifndef WIN32IO_IS_STDIO
174#undef errno
dcb2879a 175#undef environ
0a753a76 176#undef stderr
177#undef stdin
178#undef stdout
179#undef ferror
180#undef feof
390b85e7 181#undef fclose
f3986ebb
GS
182#undef pipe
183#undef pause
184#undef sleep
185#undef times
f998180f 186#undef ioctl
7766f137 187#undef unlink
ad0751ec 188#undef utime
57ab3dfe 189#undef gettimeofday
b2af26b1 190#undef uname
2d7a9237 191#undef wait
0a753a76 192
378eeda7 193#if defined(__MINGW32__)
3e3baf6d
TB
194#undef fileno
195#endif
196
0a753a76 197#define stderr win32_stderr()
198#define stdout win32_stdout()
199#define stdin win32_stdin()
c15fa9d5
GS
200#define feof(f) win32_feof(f)
201#define ferror(f) win32_ferror(f)
0a753a76 202#define errno (*win32_errno())
dcb2879a 203#define environ (*win32_environ())
0a753a76 204
68dc0745 205/*
206 * redirect to our own version
207 */
76e3520e 208#undef fprintf
0a753a76 209#define fprintf win32_fprintf
27329181
DD
210#ifdef UNDER_CE /* celib also makes these be macros to celib's x* symbols */
211# undef vfprintf
212#endif
0a753a76 213#define vfprintf win32_vfprintf
27329181
DD
214#ifdef UNDER_CE
215# undef printf
216#endif
0a753a76 217#define printf win32_printf
27329181
DD
218#ifdef UNDER_CE
219# undef vprintf
220#endif
96e4d5b1 221#define vprintf win32_vprintf
27329181
DD
222#ifdef UNDER_CE
223# undef fread
224#endif
c15fa9d5 225#define fread(buf,size,count,f) win32_fread(buf,size,count,f)
27329181
DD
226#ifdef UNDER_CE
227# undef fwrite
228#endif
c15fa9d5 229#define fwrite(buf,size,count,f) win32_fwrite(buf,size,count,f)
27329181
DD
230#ifdef UNDER_CE
231# undef fopen
232#endif
0a753a76 233#define fopen win32_fopen
a835ef8a 234#undef fdopen
0a753a76 235#define fdopen win32_fdopen
27329181
DD
236#ifdef UNDER_CE
237# undef freopen
238#endif
0a753a76 239#define freopen win32_freopen
c15fa9d5 240#define fclose(f) win32_fclose(f)
27329181
DD
241#ifdef UNDER_CE
242# undef fputs
243#endif
c15fa9d5 244#define fputs(s,f) win32_fputs(s,f)
27329181
DD
245#ifdef UNDER_CE
246# undef fputc
247#endif
c15fa9d5 248#define fputc(c,f) win32_fputc(c,f)
27329181
DD
249#ifdef UNDER_CE
250# undef ungetc
251#endif
c15fa9d5 252#define ungetc(c,f) win32_ungetc(c,f)
76e3520e 253#undef getc
c15fa9d5 254#define getc(f) win32_getc(f)
27329181
DD
255#ifdef UNDER_CE
256# undef fileno
257#endif
c15fa9d5 258#define fileno(f) win32_fileno(f)
27329181
DD
259#ifdef UNDER_CE
260# undef clearerr
261#endif
c15fa9d5 262#define clearerr(f) win32_clearerr(f)
27329181
DD
263#ifdef UNDER_CE
264# undef fflush
265#endif
c15fa9d5 266#define fflush(f) win32_fflush(f)
27329181
DD
267#ifdef UNDER_CE
268# undef ftell
269#endif
c15fa9d5 270#define ftell(f) win32_ftell(f)
27329181
DD
271#ifdef UNDER_CE
272# undef fseek
273#endif
c15fa9d5 274#define fseek(f,o,w) win32_fseek(f,o,w)
27329181
DD
275#ifdef UNDER_CE
276# undef fgetpos
277#endif
c15fa9d5 278#define fgetpos(f,p) win32_fgetpos(f,p)
27329181
DD
279#ifdef UNDER_CE
280# undef fsetpos
281#endif
c15fa9d5 282#define fsetpos(f,p) win32_fsetpos(f,p)
27329181
DD
283#ifdef UNDER_CE
284# undef rewind
285#endif
c15fa9d5
GS
286#define rewind(f) win32_rewind(f)
287#define tmpfile() win32_tmpfile()
27329181
DD
288#ifdef UNDER_CE
289# undef abort
290#endif
c15fa9d5 291#define abort() win32_abort()
27329181
DD
292#ifdef UNDER_CE
293# undef fstat
294#endif
c15fa9d5 295#define fstat(fd,bufptr) win32_fstat(fd,bufptr)
27329181
DD
296#ifdef UNDER_CE
297# undef stat
298#endif
c15fa9d5 299#define stat(pth,bufptr) win32_stat(pth,bufptr)
8ac9c18d 300#define longpath(pth) win32_longpath(pth)
aa2b96ec 301#define ansipath(pth) win32_ansipath(pth)
27329181
DD
302#ifdef UNDER_CE
303# undef rename
304#endif
e24c7c18 305#define rename(old,new) win32_rename(old,new)
27329181
DD
306#ifdef UNDER_CE
307# undef setmode
308#endif
c15fa9d5 309#define setmode(fd,mode) win32_setmode(fd,mode)
4a9d6100 310#define chsize(fd,sz) win32_chsize(fd,sz)
27329181
DD
311#ifdef UNDER_CE
312# undef lseek
313#endif
c15fa9d5
GS
314#define lseek(fd,offset,orig) win32_lseek(fd,offset,orig)
315#define tell(fd) win32_tell(fd)
27329181
DD
316#ifdef UNDER_CE
317# undef dup
318#endif
c15fa9d5 319#define dup(fd) win32_dup(fd)
27329181
DD
320#ifdef UNDER_CE
321# undef dup2
322#endif
c15fa9d5 323#define dup2(fd1,fd2) win32_dup2(fd1,fd2)
27329181
DD
324#ifdef UNDER_CE
325# undef open
326#endif
0a753a76 327#define open win32_open
27329181
DD
328#ifdef UNDER_CE
329# undef close
330#endif
c15fa9d5
GS
331#define close(fd) win32_close(fd)
332#define eof(fd) win32_eof(fd)
27329181
DD
333#ifdef UNDER_CE
334# undef isatty
335#endif
4342f4d6 336#define isatty(fd) win32_isatty(fd)
27329181
DD
337#ifdef UNDER_CE
338# undef read
339#endif
c15fa9d5 340#define read(fd,b,s) win32_read(fd,b,s)
27329181
DD
341#ifdef UNDER_CE
342# undef write
343#endif
c15fa9d5 344#define write(fd,b,s) win32_write(fd,b,s)
65e48ea9 345#define _open_osfhandle win32_open_osfhandle
27329181
DD
346#ifdef UNDER_CE
347# undef _get_osfhandle
348#endif
65e48ea9 349#define _get_osfhandle win32_get_osfhandle
3e3baf6d 350#define spawnvp win32_spawnvp
27329181
DD
351#ifdef UNDER_CE
352# undef mkdir
353#endif
5aabfad6 354#define mkdir win32_mkdir
27329181
DD
355#ifdef UNDER_CE
356# undef rmdir
357#endif
5aabfad6 358#define rmdir win32_rmdir
27329181
DD
359#ifdef UNDER_CE
360# undef chdir
361#endif
5aabfad6 362#define chdir win32_chdir
c15fa9d5 363#define flock(fd,o) win32_flock(fd,o)
27329181
DD
364#ifdef UNDER_CE
365# undef execv
366#endif
eb62e965 367#define execv win32_execv
27329181
DD
368#ifdef UNDER_CE
369# undef execvp
370#endif
6890e559 371#define execvp win32_execvp
27329181
DD
372#ifdef UNDER_CE
373# undef perror
374#endif
84902520
TB
375#define perror win32_perror
376#define setbuf win32_setbuf
27329181
DD
377#ifdef UNDER_CE
378# undef setvbuf
379#endif
84902520 380#define setvbuf win32_setvbuf
5b0d9cbe 381#undef flushall
84902520 382#define flushall win32_flushall
5b0d9cbe 383#undef fcloseall
84902520 384#define fcloseall win32_fcloseall
27329181
DD
385#ifdef UNDER_CE
386# undef fgets
387#endif
84902520 388#define fgets win32_fgets
27329181
DD
389#ifdef UNDER_CE
390# undef gets
391#endif
84902520 392#define gets win32_gets
27329181
DD
393#ifdef UNDER_CE
394# undef fgetc
395#endif
84902520 396#define fgetc win32_fgetc
76e3520e 397#undef putc
84902520 398#define putc win32_putc
27329181
DD
399#ifdef UNDER_CE
400# undef puts
401#endif
84902520 402#define puts win32_puts
76e3520e 403#undef getchar
84902520 404#define getchar win32_getchar
76e3520e 405#undef putchar
84902520 406#define putchar win32_putchar
27329181
DD
407#ifdef UNDER_CE
408# undef access
409#endif
7766f137 410#define access(p,m) win32_access(p,m)
27329181
DD
411#ifdef UNDER_CE
412# undef chmod
413#endif
7766f137
GS
414#define chmod(p,m) win32_chmod(p,m)
415
bbc8f9de 416
c31fac66 417#if !defined(MYMALLOC) || !defined(PERL_CORE)
bbc8f9de
NIS
418#undef malloc
419#undef calloc
420#undef realloc
421#undef free
84902520
TB
422#define malloc win32_malloc
423#define calloc win32_calloc
424#define realloc win32_realloc
425#define free win32_free
bbc8f9de 426#endif
0a753a76 427
364d54ba
JD
428/* XXX Why are APIs like sleep(), times() etc. inside a block
429 * XXX guarded by "#ifndef WIN32IO_IS_STDIO"?
430 */
431
f3986ebb
GS
432#define pipe(fd) win32_pipe((fd), 512, O_BINARY)
433#define pause() win32_sleep((32767L << 16) + 32767)
434#define sleep win32_sleep
435#define times win32_times
f998180f 436#define ioctl win32_ioctl
6b980173 437#define link win32_link
7766f137 438#define unlink win32_unlink
ad0751ec 439#define utime win32_utime
27329181
DD
440#ifdef UNDER_CE
441# undef gettimeofday
442#endif
57ab3dfe 443#define gettimeofday win32_gettimeofday
b2af26b1 444#define uname win32_uname
2d7a9237 445#define wait win32_wait
f55ee38a 446#define waitpid win32_waitpid
27329181
DD
447#ifdef UNDER_CE
448# undef kill
449#endif
f55ee38a 450#define kill win32_kill
721b2674
DD
451#ifdef UNDER_CE
452# undef killpg
453#endif
454#define killpg(pid, sig) win32_kill(pid, -(sig))
455
f3986ebb 456
27329181
DD
457#ifdef UNDER_CE
458# undef opendir
459#endif
ce2e26e5 460#define opendir win32_opendir
27329181
DD
461#ifdef UNDER_CE
462# undef readdir
463#endif
ce2e26e5
GS
464#define readdir win32_readdir
465#define telldir win32_telldir
466#define seekdir win32_seekdir
467#define rewinddir win32_rewinddir
27329181
DD
468#ifdef UNDER_CE
469# undef closedir
470#endif
ce2e26e5 471#define closedir win32_closedir
0cb96387 472#define os_id win32_os_id
27329181
DD
473#ifdef UNDER_CE
474# undef getpid
475#endif
7766f137 476#define getpid win32_getpid
ce2e26e5 477
26618a56 478#undef crypt
25dbdbbc 479#define crypt(t,s) win32_crypt(t,s)
26618a56 480
df3728a2
JH
481#undef get_childenv
482#undef free_childenv
483#undef clearenv
484#undef get_childdir
485#undef free_childdir
486#define get_childenv() win32_get_childenv()
487#define free_childenv(d) win32_free_childenv(d)
488#define clearenv() win32_clearenv()
489#define get_childdir() win32_get_childdir()
490#define free_childdir(d) win32_free_childdir(d)
491
f3986ebb
GS
492#undef getenv
493#define getenv win32_getenv
ac5c734f
GS
494#undef putenv
495#define putenv win32_putenv
f3986ebb
GS
496
497#endif /* WIN32IO_IS_STDIO */
68dc0745 498#endif /* WIN32IOP_H */