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