This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[inseparable changes from changes to perl-5.004_01-mt2]
[perl5.git] / win32 / win32iop.h
CommitLineData
0a753a76
PP
1#ifndef WIN32IOP_H
2#define WIN32IOP_H
3
4
5/*
6 * Make this as close to original stdio as possible.
7 */
68dc0745
PP
8
9/*
10 * function prototypes for our own win32io layer
11 */
0a753a76 12EXT int * win32_errno();
dcb2879a 13EXT char *** win32_environ();
0a753a76
PP
14EXT FILE* win32_stdin(void);
15EXT FILE* win32_stdout(void);
16EXT FILE* win32_stderr(void);
17EXT int win32_ferror(FILE *fp);
18EXT int win32_feof(FILE *fp);
19EXT char* win32_strerror(int e);
20
68dc0745
PP
21EXT int win32_fprintf(FILE *pf, const char *format, ...);
22EXT int win32_printf(const char *format, ...);
23EXT int win32_vfprintf(FILE *pf, const char *format, va_list arg);
96e4d5b1 24EXT int win32_vprintf(const char *format, va_list arg);
0a753a76
PP
25EXT size_t win32_fread(void *buf, size_t size, size_t count, FILE *pf);
26EXT size_t win32_fwrite(const void *buf, size_t size, size_t count, FILE *pf);
27EXT FILE* win32_fopen(const char *path, const char *mode);
28EXT FILE* win32_fdopen(int fh, const char *mode);
29EXT FILE* win32_freopen(const char *path, const char *mode, FILE *pf);
30EXT int win32_fclose(FILE *pf);
31EXT int win32_fputs(const char *s,FILE *pf);
32EXT int win32_fputc(int c,FILE *pf);
33EXT int win32_ungetc(int c,FILE *pf);
68dc0745 34EXT int win32_getc(FILE *pf);
0a753a76 35EXT int win32_fileno(FILE *pf);
68dc0745 36EXT void win32_clearerr(FILE *pf);
0a753a76
PP
37EXT int win32_fflush(FILE *pf);
38EXT long win32_ftell(FILE *pf);
68dc0745
PP
39EXT int win32_fseek(FILE *pf,long offset,int origin);
40EXT int win32_fgetpos(FILE *pf,fpos_t *p);
41EXT int win32_fsetpos(FILE *pf,const fpos_t *p);
42EXT void win32_rewind(FILE *pf);
43EXT FILE* win32_tmpfile(void);
44EXT void win32_abort(void);
0a753a76
PP
45EXT int win32_fstat(int fd,struct stat *bufptr);
46EXT int win32_stat(const char *name,struct stat *bufptr);
47EXT int win32_pipe( int *phandles, unsigned int psize, int textmode );
48EXT FILE* win32_popen( const char *command, const char *mode );
49EXT int win32_pclose( FILE *pf);
50EXT int win32_setmode( int fd, int mode);
51EXT long win32_lseek( int fd, long offset, int origin);
52EXT long win32_tell( int fd);
53EXT int win32_dup( int fd);
54EXT int win32_dup2(int h1, int h2);
55EXT int win32_open(const char *path, int oflag,...);
56EXT int win32_close(int fd);
57EXT int win32_eof(int fd);
58EXT int win32_read(int fd, void *buf, unsigned int cnt);
59EXT int win32_write(int fd, const void *buf, unsigned int cnt);
68dc0745
PP
60EXT int win32_spawnvpe(int mode, const char *cmdname,
61 const char *const *argv, const char *const *envp);
0a753a76 62EXT int win32_spawnle(int mode, const char *cmdname, const char *,...);
5aabfad6
PP
63EXT int win32_mkdir(const char *dir, int mode);
64EXT int win32_rmdir(const char *dir);
65EXT int win32_chdir(const char *dir);
c90c0ff4 66EXT int win32_flock(int fd, int oper);
0a753a76 67
68dc0745
PP
68/*
69 * these two are win32 specific but still io related
70 */
0a753a76 71int stolen_open_osfhandle(long handle, int flags);
68dc0745 72long stolen_get_osfhandle(int fd);
0a753a76 73
c90c0ff4
PP
74/*
75 * defines for flock emulation
76 */
77#define LOCK_SH 1
78#define LOCK_EX 2
79#define LOCK_NB 4
80#define LOCK_UN 8
81
68dc0745 82#include <win32io.h> /* pull in the io sub system structure */
0a753a76
PP
83
84void * SetIOSubSystem(void *piosubsystem);
68dc0745
PP
85
86/*
87 * the following six(6) is #define in stdio.h
88 */
0a753a76
PP
89#ifndef WIN32IO_IS_STDIO
90#undef errno
dcb2879a 91#undef environ
0a753a76
PP
92#undef stderr
93#undef stdin
94#undef stdout
95#undef ferror
96#undef feof
97
98#define stderr win32_stderr()
99#define stdout win32_stdout()
100#define stdin win32_stdin()
101#define feof(f) win32_feof(f)
102#define ferror(f) win32_ferror(f)
103#define errno (*win32_errno())
dcb2879a 104#define environ (*win32_environ())
0a753a76
PP
105#define strerror win32_strerror
106
68dc0745
PP
107/*
108 * redirect to our own version
109 */
0a753a76
PP
110#define fprintf win32_fprintf
111#define vfprintf win32_vfprintf
112#define printf win32_printf
96e4d5b1 113#define vprintf win32_vprintf
0a753a76
PP
114#define fread(buf,size,count,f) win32_fread(buf,size,count,f)
115#define fwrite(buf,size,count,f) win32_fwrite(buf,size,count,f)
116#define fopen win32_fopen
117#define fdopen win32_fdopen
118#define freopen win32_freopen
119#define fclose(f) win32_fclose(f)
120#define fputs(s,f) win32_fputs(s,f)
121#define fputc(c,f) win32_fputc(c,f)
122#define ungetc(c,f) win32_ungetc(c,f)
123#define getc(f) win32_getc(f)
124#define fileno(f) win32_fileno(f)
125#define clearerr(f) win32_clearerr(f)
126#define fflush(f) win32_fflush(f)
127#define ftell(f) win32_ftell(f)
128#define fseek(f,o,w) win32_fseek(f,o,w)
129#define fgetpos(f,p) win32_fgetpos(f,p)
130#define fsetpos(f,p) win32_fsetpos(f,p)
131#define rewind(f) win32_rewind(f)
132#define tmpfile() win32_tmpfile()
133#define abort() win32_abort()
134#define fstat(fd,bufptr) win32_fstat(fd,bufptr)
135#define setmode(fd,mode) win32_setmode(fd,mode)
136#define lseek(fd,offset,orig) win32_lseek(fd,offset,orig)
137#define tell(fd) win32_tell(fd)
138#define dup(fd) win32_dup(fd)
139#define dup2(fd1,fd2) win32_dup2(fd1,fd2)
140#define open win32_open
141#define close(fd) win32_close(fd)
142#define eof(fd) win32_eof(fd)
143#define read(fd,b,s) win32_read(fd,b,s)
144#define write(fd,b,s) win32_write(fd,b,s)
145#define _open_osfhandle stolen_open_osfhandle
146#define _get_osfhandle stolen_get_osfhandle
68dc0745
PP
147#define spawnvpe win32_spawnvpe
148#define spawnle win32_spawnle
5aabfad6
PP
149#define mkdir win32_mkdir
150#define rmdir win32_rmdir
151#define chdir win32_chdir
c90c0ff4 152#define flock(fd,o) win32_flock(fd,o)
68dc0745 153#endif /* WIN32IO_IS_STDIO */
0a753a76 154
68dc0745 155#endif /* WIN32IOP_H */