6 # define START_EXTERN_C extern "C" {
7 # define END_EXTERN_C }
8 # define EXTERN_C extern "C"
10 # define START_EXTERN_C
17 * defines for flock emulation
25 * Make this as close to original stdio as possible.
29 * function prototypes for our own win32io layer
33 EXT int * win32_errno(void);
34 EXT char *** win32_environ(void);
35 EXT FILE* win32_stdin(void);
36 EXT FILE* win32_stdout(void);
37 EXT FILE* win32_stderr(void);
38 EXT int win32_ferror(FILE *fp);
39 EXT int win32_feof(FILE *fp);
40 EXT char* win32_strerror(int e);
42 EXT int win32_fprintf(FILE *pf, const char *format, ...);
43 EXT int win32_printf(const char *format, ...);
44 EXT int win32_vfprintf(FILE *pf, const char *format, va_list arg);
45 EXT int win32_vprintf(const char *format, va_list arg);
46 EXT size_t win32_fread(void *buf, size_t size, size_t count, FILE *pf);
47 EXT size_t win32_fwrite(const void *buf, size_t size, size_t count, FILE *pf);
48 EXT FILE* win32_fopen(const char *path, const char *mode);
49 EXT FILE* win32_fdopen(int fh, const char *mode);
50 EXT FILE* win32_freopen(const char *path, const char *mode, FILE *pf);
51 EXT int win32_fclose(FILE *pf);
52 EXT int win32_fputs(const char *s,FILE *pf);
53 EXT int win32_fputc(int c,FILE *pf);
54 EXT int win32_ungetc(int c,FILE *pf);
55 EXT int win32_getc(FILE *pf);
56 EXT int win32_fileno(FILE *pf);
57 EXT void win32_clearerr(FILE *pf);
58 EXT int win32_fflush(FILE *pf);
59 EXT long win32_ftell(FILE *pf);
60 EXT int win32_fseek(FILE *pf,long offset,int origin);
61 EXT int win32_fgetpos(FILE *pf,fpos_t *p);
62 EXT int win32_fsetpos(FILE *pf,const fpos_t *p);
63 EXT void win32_rewind(FILE *pf);
64 EXT FILE* win32_tmpfile(void);
65 EXT void win32_abort(void);
66 EXT int win32_fstat(int fd,struct stat *bufptr);
67 EXT int win32_stat(const char *name,struct stat *bufptr);
68 EXT int win32_pipe( int *phandles, unsigned int psize, int textmode );
69 EXT FILE* win32_popen( const char *command, const char *mode );
70 EXT int win32_pclose( FILE *pf);
71 EXT int win32_setmode( int fd, int mode);
72 EXT long win32_lseek( int fd, long offset, int origin);
73 EXT long win32_tell( int fd);
74 EXT int win32_dup( int fd);
75 EXT int win32_dup2(int h1, int h2);
76 EXT int win32_open(const char *path, int oflag,...);
77 EXT int win32_close(int fd);
78 EXT int win32_eof(int fd);
79 EXT int win32_read(int fd, void *buf, unsigned int cnt);
80 EXT int win32_write(int fd, const void *buf, unsigned int cnt);
81 EXT int win32_spawnvp(int mode, const char *cmdname,
82 const char *const *argv);
83 EXT int win32_mkdir(const char *dir, int mode);
84 EXT int win32_rmdir(const char *dir);
85 EXT int win32_chdir(const char *dir);
86 EXT int win32_flock(int fd, int oper);
87 EXT int win32_execvp(const char *cmdname, const char *const *argv);
88 EXT void win32_perror(const char *str);
89 EXT void win32_setbuf(FILE *pf, char *buf);
90 EXT int win32_setvbuf(FILE *pf, char *buf, int type, size_t size);
91 EXT int win32_flushall(void);
92 EXT int win32_fcloseall(void);
93 EXT char* win32_fgets(char *s, int n, FILE *pf);
94 EXT char* win32_gets(char *s);
95 EXT int win32_fgetc(FILE *pf);
96 EXT int win32_putc(int c, FILE *pf);
97 EXT int win32_puts(const char *s);
98 EXT int win32_getchar(void);
99 EXT int win32_putchar(int c);
100 EXT void* win32_malloc(size_t size);
101 EXT void* win32_calloc(size_t numitems, size_t size);
102 EXT void* win32_realloc(void *block, size_t size);
103 EXT void win32_free(void *block);
105 EXT int win32_open_osfhandle(long handle, int flags);
106 EXT long win32_get_osfhandle(int fd);
108 #ifndef USE_WIN32_RTL_ENV
109 EXT char* win32_getenv(const char *name);
112 EXT unsigned int win32_sleep(unsigned int);
113 EXT int win32_times(struct tms *timebuf);
114 EXT unsigned int win32_alarm(unsigned int sec);
115 EXT int win32_flock(int fd, int oper);
116 EXT int win32_stat(const char *path, struct stat *buf);
121 * the following six(6) is #define in stdio.h
123 #ifndef WIN32IO_IS_STDIO
147 #define stderr win32_stderr()
148 #define stdout win32_stdout()
149 #define stdin win32_stdin()
150 #define feof(f) win32_feof(f)
151 #define ferror(f) win32_ferror(f)
152 #define errno (*win32_errno())
153 #define environ (*win32_environ())
154 #define strerror win32_strerror
157 * redirect to our own version
159 #define fprintf win32_fprintf
160 #define vfprintf win32_vfprintf
161 #define printf win32_printf
162 #define vprintf win32_vprintf
163 #define fread(buf,size,count,f) win32_fread(buf,size,count,f)
164 #define fwrite(buf,size,count,f) win32_fwrite(buf,size,count,f)
165 #define fopen win32_fopen
167 #define fdopen win32_fdopen
168 #define freopen win32_freopen
169 #define fclose(f) win32_fclose(f)
170 #define fputs(s,f) win32_fputs(s,f)
171 #define fputc(c,f) win32_fputc(c,f)
172 #define ungetc(c,f) win32_ungetc(c,f)
173 #define getc(f) win32_getc(f)
174 #define fileno(f) win32_fileno(f)
175 #define clearerr(f) win32_clearerr(f)
176 #define fflush(f) win32_fflush(f)
177 #define ftell(f) win32_ftell(f)
178 #define fseek(f,o,w) win32_fseek(f,o,w)
179 #define fgetpos(f,p) win32_fgetpos(f,p)
180 #define fsetpos(f,p) win32_fsetpos(f,p)
181 #define rewind(f) win32_rewind(f)
182 #define tmpfile() win32_tmpfile()
183 #define abort() win32_abort()
184 #define fstat(fd,bufptr) win32_fstat(fd,bufptr)
185 #define stat(pth,bufptr) win32_stat(pth,bufptr)
186 #define setmode(fd,mode) win32_setmode(fd,mode)
187 #define lseek(fd,offset,orig) win32_lseek(fd,offset,orig)
188 #define tell(fd) win32_tell(fd)
189 #define dup(fd) win32_dup(fd)
190 #define dup2(fd1,fd2) win32_dup2(fd1,fd2)
191 #define open win32_open
192 #define close(fd) win32_close(fd)
193 #define eof(fd) win32_eof(fd)
194 #define read(fd,b,s) win32_read(fd,b,s)
195 #define write(fd,b,s) win32_write(fd,b,s)
196 #define _open_osfhandle win32_open_osfhandle
197 #define _get_osfhandle win32_get_osfhandle
198 #define spawnvp win32_spawnvp
199 #define mkdir win32_mkdir
200 #define rmdir win32_rmdir
201 #define chdir win32_chdir
202 #define flock(fd,o) win32_flock(fd,o)
203 #define execvp win32_execvp
204 #define perror win32_perror
205 #define setbuf win32_setbuf
206 #define setvbuf win32_setvbuf
208 #define flushall win32_flushall
210 #define fcloseall win32_fcloseall
211 #define fgets win32_fgets
212 #define gets win32_gets
213 #define fgetc win32_fgetc
214 #define putc win32_putc
215 #define puts win32_puts
216 #define getchar win32_getchar
217 #define putchar win32_putchar
219 #if !defined(MYMALLOC) || !defined(PERL_CORE)
224 #define malloc win32_malloc
225 #define calloc win32_calloc
226 #define realloc win32_realloc
227 #define free win32_free
230 #define pipe(fd) win32_pipe((fd), 512, O_BINARY)
231 #define pause() win32_sleep((32767L << 16) + 32767)
232 #define sleep win32_sleep
233 #define times win32_times
234 #define alarm win32_alarm
236 #ifndef USE_WIN32_RTL_ENV
238 #define getenv win32_getenv
241 #endif /* WIN32IO_IS_STDIO */
242 #endif /* WIN32IOP_H */