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