[inseperable differences up to perl 5.004_02]
[p5sagit/p5-mst-13.2.git] / win32 / win32iop.h
1 #ifndef WIN32IOP_H
2 #define WIN32IOP_H
3
4
5 /*
6  * Make this as close to original stdio as possible.
7  */
8
9 /*
10  * function prototypes for our own win32io layer
11  */
12 EXT int *       win32_errno(void);
13 EXT char ***    win32_environ(void);
14 EXT FILE*       win32_stdin(void);
15 EXT FILE*       win32_stdout(void);
16 EXT FILE*       win32_stderr(void);
17 EXT int         win32_ferror(FILE *fp);
18 EXT int         win32_feof(FILE *fp);
19 EXT char*       win32_strerror(int e);
20
21 EXT int         win32_fprintf(FILE *pf, const char *format, ...);
22 EXT int         win32_printf(const char *format, ...);
23 EXT int         win32_vfprintf(FILE *pf, const char *format, va_list arg);
24 EXT int         win32_vprintf(const char *format, va_list arg);
25 EXT size_t      win32_fread(void *buf, size_t size, size_t count, FILE *pf);
26 EXT size_t      win32_fwrite(const void *buf, size_t size, size_t count, FILE *pf);
27 EXT FILE*       win32_fopen(const char *path, const char *mode);
28 EXT FILE*       win32_fdopen(int fh, const char *mode);
29 EXT FILE*       win32_freopen(const char *path, const char *mode, FILE *pf);
30 EXT int         win32_fclose(FILE *pf);
31 EXT int         win32_fputs(const char *s,FILE *pf);
32 EXT int         win32_fputc(int c,FILE *pf);
33 EXT int         win32_ungetc(int c,FILE *pf);
34 EXT int         win32_getc(FILE *pf);
35 EXT int         win32_fileno(FILE *pf);
36 EXT void        win32_clearerr(FILE *pf);
37 EXT int         win32_fflush(FILE *pf);
38 EXT long        win32_ftell(FILE *pf);
39 EXT int         win32_fseek(FILE *pf,long offset,int origin);
40 EXT int         win32_fgetpos(FILE *pf,fpos_t *p);
41 EXT int         win32_fsetpos(FILE *pf,const fpos_t *p);
42 EXT void        win32_rewind(FILE *pf);
43 EXT FILE*       win32_tmpfile(void);
44 EXT void        win32_abort(void);
45 EXT int         win32_fstat(int fd,struct stat *bufptr);
46 EXT int         win32_stat(const char *name,struct stat *bufptr);
47 EXT int         win32_pipe( int *phandles, unsigned int psize, int textmode );
48 EXT FILE*       win32_popen( const char *command, const char *mode );
49 EXT int         win32_pclose( FILE *pf);
50 EXT int         win32_setmode( int fd, int mode);
51 EXT long        win32_lseek( int fd, long offset, int origin);
52 EXT long        win32_tell( int fd);
53 EXT int         win32_dup( int fd);
54 EXT int         win32_dup2(int h1, int h2);
55 EXT int         win32_open(const char *path, int oflag,...);
56 EXT int         win32_close(int fd);
57 EXT int         win32_eof(int fd);
58 EXT int         win32_read(int fd, void *buf, unsigned int cnt);
59 EXT int         win32_write(int fd, const void *buf, unsigned int cnt);
60 EXT int         win32_spawnvp(int mode, const char *cmdname,
61                               const char *const *argv);
62 EXT int         win32_mkdir(const char *dir, int mode);
63 EXT int         win32_rmdir(const char *dir);
64 EXT int         win32_chdir(const char *dir);
65 EXT int         win32_flock(int fd, int oper);
66 EXT int         win32_execvp(const char *cmdname, const char *const *argv);
67 EXT void        win32_perror(const char *str);
68 EXT void        win32_setbuf(FILE *pf, char *buf);
69 EXT int         win32_setvbuf(FILE *pf, char *buf, int type, size_t size);
70 EXT int         win32_flushall(void);
71 EXT int         win32_fcloseall(void);
72 EXT char*       win32_fgets(char *s, int n, FILE *pf);
73 EXT char*       win32_gets(char *s);
74 EXT int         win32_fgetc(FILE *pf);
75 EXT int         win32_putc(int c, FILE *pf);
76 EXT int         win32_puts(const char *s);
77 EXT int         win32_getchar(void);
78 EXT int         win32_putchar(int c);
79 EXT void*       win32_malloc(size_t size);
80 EXT void*       win32_calloc(size_t numitems, size_t size);
81 EXT void*       win32_realloc(void *block, size_t size);
82 EXT void        win32_free(void *block);
83
84 /*
85  * these two are win32 specific but still io related
86  */
87 int             stolen_open_osfhandle(long handle, int flags);
88 long            stolen_get_osfhandle(int fd);
89
90 /*
91  * defines for flock emulation
92  */
93 #define LOCK_SH 1
94 #define LOCK_EX 2
95 #define LOCK_NB 4
96 #define LOCK_UN 8
97
98 #include <win32io.h>    /* pull in the io sub system structure */
99
100 EXT PWIN32_IOSUBSYSTEM  SetIOSubSystem(void     *piosubsystem);
101 EXT PWIN32_IOSUBSYSTEM  GetIOSubSystem(void);
102
103 /*
104  * the following six(6) is #define in stdio.h
105  */
106 #ifndef WIN32IO_IS_STDIO
107 #undef errno
108 #undef environ
109 #undef stderr
110 #undef stdin
111 #undef stdout
112 #undef ferror
113 #undef feof
114
115 #ifdef __BORLANDC__
116 #undef ungetc
117 #undef getc
118 #undef putc
119 #undef getchar
120 #undef putchar
121 #undef fileno
122 #endif
123
124 #define stderr                          win32_stderr()
125 #define stdout                          win32_stdout()
126 #define stdin                           win32_stdin()
127 #define feof(f)                         win32_feof(f)
128 #define ferror(f)                       win32_ferror(f)
129 #define errno                           (*win32_errno())
130 #define environ                         (*win32_environ())
131 #define strerror                        win32_strerror
132
133 /*
134  * redirect to our own version
135  */
136 #define fprintf                 win32_fprintf
137 #define vfprintf                win32_vfprintf
138 #define printf                  win32_printf
139 #define vprintf                 win32_vprintf
140 #define fread(buf,size,count,f) win32_fread(buf,size,count,f)
141 #define fwrite(buf,size,count,f)        win32_fwrite(buf,size,count,f)
142 #define fopen                   win32_fopen
143 #define fdopen                  win32_fdopen
144 #define freopen                 win32_freopen
145 #define fclose(f)               win32_fclose(f)
146 #define fputs(s,f)              win32_fputs(s,f)
147 #define fputc(c,f)              win32_fputc(c,f)
148 #define ungetc(c,f)             win32_ungetc(c,f)
149 #define getc(f)                 win32_getc(f)
150 #define fileno(f)               win32_fileno(f)
151 #define clearerr(f)             win32_clearerr(f)
152 #define fflush(f)               win32_fflush(f)
153 #define ftell(f)                win32_ftell(f)
154 #define fseek(f,o,w)            win32_fseek(f,o,w)
155 #define fgetpos(f,p)            win32_fgetpos(f,p)
156 #define fsetpos(f,p)            win32_fsetpos(f,p)
157 #define rewind(f)               win32_rewind(f)
158 #define tmpfile()               win32_tmpfile()
159 #define abort()                 win32_abort()
160 #define fstat(fd,bufptr)        win32_fstat(fd,bufptr)
161 #define stat(pth,bufptr)        win32_stat(pth,bufptr)
162 #define setmode(fd,mode)        win32_setmode(fd,mode)
163 #define lseek(fd,offset,orig)   win32_lseek(fd,offset,orig)
164 #define tell(fd)                win32_tell(fd)
165 #define dup(fd)                 win32_dup(fd)
166 #define dup2(fd1,fd2)           win32_dup2(fd1,fd2)
167 #define open                    win32_open
168 #define close(fd)               win32_close(fd)
169 #define eof(fd)                 win32_eof(fd)
170 #define read(fd,b,s)            win32_read(fd,b,s)
171 #define write(fd,b,s)           win32_write(fd,b,s)
172 #define _open_osfhandle         stolen_open_osfhandle
173 #define _get_osfhandle          stolen_get_osfhandle
174 #define spawnvp                 win32_spawnvp
175 #define mkdir                   win32_mkdir
176 #define rmdir                   win32_rmdir
177 #define chdir                   win32_chdir
178 #define flock(fd,o)             win32_flock(fd,o)
179 #define execvp                  win32_execvp
180 #define perror                  win32_perror
181 #define setbuf                  win32_setbuf
182 #define setvbuf                 win32_setvbuf
183 #define flushall                win32_flushall
184 #define fcloseall               win32_fcloseall
185 #define fgets                   win32_fgets
186 #define gets                    win32_gets
187 #define fgetc                   win32_fgetc
188 #define putc                    win32_putc
189 #define puts                    win32_puts
190 #define getchar                 win32_getchar
191 #define putchar                 win32_putchar
192 #define fscanf                  (GetIOSubSystem()->pfnfscanf)
193 #define scanf                   (GetIOSubSystem()->pfnscanf)
194 #define malloc                  win32_malloc
195 #define calloc                  win32_calloc
196 #define realloc                 win32_realloc
197 #define free                    win32_free
198 #endif /* WIN32IO_IS_STDIO */
199
200 #endif /* WIN32IOP_H */