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