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