Commit | Line | Data |
---|---|---|
0f4eea8f DL |
1 | /* |
2 | * iperlsys.h - Perl's interface to the system | |
3 | * | |
4 | * This file defines the system level functionality that perl needs. | |
5 | * | |
6 | * When using C, this definition is in the form of a set of macros | |
7 | * that can be #defined to the system-level function (or a wrapper | |
8 | * provided elsewhere). | |
9 | * | |
0f4eea8f DL |
10 | * GSAR 21-JUN-98 |
11 | */ | |
12 | ||
13 | #ifndef __Inc__IPerl___ | |
14 | #define __Inc__IPerl___ | |
15 | ||
16 | /* | |
17 | * PerlXXX_YYY explained - DickH and DougL @ ActiveState.com | |
18 | * | |
19 | * XXX := functional group | |
20 | * YYY := stdlib/OS function name | |
21 | * | |
22 | * Continuing with the theme of PerlIO, all OS functionality was | |
23 | * encapsulated into one of several interfaces. | |
24 | * | |
25 | * PerlIO - stdio | |
26 | * PerlLIO - low level I/O | |
27 | * PerlMem - malloc, realloc, free | |
28 | * PerlDir - directory related | |
29 | * PerlEnv - process environment handling | |
30 | * PerlProc - process control | |
31 | * PerlSock - socket functions | |
32 | * | |
33 | * | |
34 | * The features of this are: | |
35 | * 1. All OS dependant code is in the Perl Host and not the Perl Core. | |
36 | * (At least this is the holy grail goal of this work) | |
37 | * 2. The Perl Host (see perl.h for description) can provide a new and | |
38 | * improved interface to OS functionality if required. | |
39 | * 3. Developers can easily hook into the OS calls for instrumentation | |
40 | * or diagnostic purposes. | |
41 | * | |
42 | * What was changed to do this: | |
43 | * 1. All calls to OS functions were replaced with PerlXXX_YYY | |
44 | * | |
45 | */ | |
46 | ||
0f4eea8f | 47 | /* |
76ced9ad NIS |
48 | Interface for perl stdio functions, or whatever we are Configure-d |
49 | to use. | |
0f4eea8f | 50 | */ |
76ced9ad | 51 | #include "perlio.h" |
0f4eea8f | 52 | |
dc37125b DM |
53 | typedef Signal_t (*Sighandler1_t) (int); |
54 | typedef Signal_t (*Sighandler3_t) (int, Siginfo_t*, void*); | |
55 | ||
d543acb6 | 56 | #ifndef Sighandler_t |
5e7940ce | 57 | # ifdef PERL_USE_3ARG_SIGHANDLER |
dc37125b | 58 | typedef Sighandler3_t Sighandler_t; |
8aad04aa | 59 | # else |
dc37125b | 60 | typedef Sighandler1_t Sighandler_t; |
8aad04aa | 61 | # endif |
d543acb6 GS |
62 | #endif |
63 | ||
c5be433b | 64 | #if defined(PERL_IMPLICIT_SYS) |
0f4eea8f | 65 | |
0cb96387 GS |
66 | /* IPerlStdIO */ |
67 | struct IPerlStdIO; | |
7766f137 | 68 | struct IPerlStdIOInfo; |
eaf8b698 NIS |
69 | typedef FILE* (*LPStdin)(struct IPerlStdIO*); |
70 | typedef FILE* (*LPStdout)(struct IPerlStdIO*); | |
71 | typedef FILE* (*LPStderr)(struct IPerlStdIO*); | |
72 | typedef FILE* (*LPOpen)(struct IPerlStdIO*, const char*, | |
0cb96387 | 73 | const char*); |
eaf8b698 NIS |
74 | typedef int (*LPClose)(struct IPerlStdIO*, FILE*); |
75 | typedef int (*LPEof)(struct IPerlStdIO*, FILE*); | |
76 | typedef int (*LPError)(struct IPerlStdIO*, FILE*); | |
77 | typedef void (*LPClearerr)(struct IPerlStdIO*, FILE*); | |
78 | typedef int (*LPGetc)(struct IPerlStdIO*, FILE*); | |
0934c9d9 | 79 | typedef STDCHAR* (*LPGetBase)(struct IPerlStdIO*, FILE*); |
eaf8b698 NIS |
80 | typedef int (*LPGetBufsiz)(struct IPerlStdIO*, FILE*); |
81 | typedef int (*LPGetCnt)(struct IPerlStdIO*, FILE*); | |
0934c9d9 | 82 | typedef STDCHAR* (*LPGetPtr)(struct IPerlStdIO*, FILE*); |
6d655123 | 83 | typedef char* (*LPGets)(struct IPerlStdIO*, char*, int, FILE*); |
50a4e535 JD |
84 | typedef int (*LPPutc)(struct IPerlStdIO*, int, FILE*); |
85 | typedef int (*LPPuts)(struct IPerlStdIO*, const char *, FILE*); | |
eaf8b698 | 86 | typedef int (*LPFlush)(struct IPerlStdIO*, FILE*); |
adb71456 | 87 | typedef int (*LPUngetc)(struct IPerlStdIO*, int,FILE*); |
eaf8b698 NIS |
88 | typedef int (*LPFileno)(struct IPerlStdIO*, FILE*); |
89 | typedef FILE* (*LPFdopen)(struct IPerlStdIO*, int, const char*); | |
90 | typedef FILE* (*LPReopen)(struct IPerlStdIO*, const char*, | |
91 | const char*, FILE*); | |
adb71456 NIS |
92 | typedef SSize_t (*LPRead)(struct IPerlStdIO*, void*, Size_t, Size_t, FILE *); |
93 | typedef SSize_t (*LPWrite)(struct IPerlStdIO*, const void*, Size_t, Size_t, FILE *); | |
eaf8b698 NIS |
94 | typedef void (*LPSetBuf)(struct IPerlStdIO*, FILE*, char*); |
95 | typedef int (*LPSetVBuf)(struct IPerlStdIO*, FILE*, char*, int, | |
0cb96387 | 96 | Size_t); |
eaf8b698 | 97 | typedef void (*LPSetCnt)(struct IPerlStdIO*, FILE*, int); |
011f1a1a JH |
98 | |
99 | #ifndef NETWARE | |
0934c9d9 | 100 | typedef void (*LPSetPtr)(struct IPerlStdIO*, FILE*, STDCHAR*); |
011f1a1a | 101 | #elif defined(NETWARE) |
0934c9d9 | 102 | typedef void (*LPSetPtr)(struct IPerlStdIO*, FILE*, STDCHAR*, int); |
011f1a1a JH |
103 | #endif |
104 | ||
eaf8b698 NIS |
105 | typedef void (*LPSetlinebuf)(struct IPerlStdIO*, FILE*); |
106 | typedef int (*LPPrintf)(struct IPerlStdIO*, FILE*, const char*, | |
0cb96387 | 107 | ...); |
eaf8b698 | 108 | typedef int (*LPVprintf)(struct IPerlStdIO*, FILE*, const char*, |
0cb96387 | 109 | va_list); |
c623ac67 | 110 | typedef Off_t (*LPTell)(struct IPerlStdIO*, FILE*); |
eaf8b698 NIS |
111 | typedef int (*LPSeek)(struct IPerlStdIO*, FILE*, Off_t, int); |
112 | typedef void (*LPRewind)(struct IPerlStdIO*, FILE*); | |
113 | typedef FILE* (*LPTmpfile)(struct IPerlStdIO*); | |
114 | typedef int (*LPGetpos)(struct IPerlStdIO*, FILE*, Fpos_t*); | |
115 | typedef int (*LPSetpos)(struct IPerlStdIO*, FILE*, | |
0cb96387 GS |
116 | const Fpos_t*); |
117 | typedef void (*LPInit)(struct IPerlStdIO*); | |
118 | typedef void (*LPInitOSExtras)(struct IPerlStdIO*); | |
eaf8b698 | 119 | typedef FILE* (*LPFdupopen)(struct IPerlStdIO*, FILE*); |
0cb96387 GS |
120 | |
121 | struct IPerlStdIO | |
0f4eea8f | 122 | { |
0cb96387 GS |
123 | LPStdin pStdin; |
124 | LPStdout pStdout; | |
125 | LPStderr pStderr; | |
126 | LPOpen pOpen; | |
127 | LPClose pClose; | |
128 | LPEof pEof; | |
129 | LPError pError; | |
130 | LPClearerr pClearerr; | |
131 | LPGetc pGetc; | |
132 | LPGetBase pGetBase; | |
133 | LPGetBufsiz pGetBufsiz; | |
134 | LPGetCnt pGetCnt; | |
135 | LPGetPtr pGetPtr; | |
136 | LPGets pGets; | |
137 | LPPutc pPutc; | |
138 | LPPuts pPuts; | |
139 | LPFlush pFlush; | |
140 | LPUngetc pUngetc; | |
141 | LPFileno pFileno; | |
142 | LPFdopen pFdopen; | |
143 | LPReopen pReopen; | |
144 | LPRead pRead; | |
145 | LPWrite pWrite; | |
146 | LPSetBuf pSetBuf; | |
147 | LPSetVBuf pSetVBuf; | |
148 | LPSetCnt pSetCnt; | |
adb71456 | 149 | LPSetPtr pSetPtr; |
0cb96387 GS |
150 | LPSetlinebuf pSetlinebuf; |
151 | LPPrintf pPrintf; | |
152 | LPVprintf pVprintf; | |
153 | LPTell pTell; | |
154 | LPSeek pSeek; | |
155 | LPRewind pRewind; | |
156 | LPTmpfile pTmpfile; | |
157 | LPGetpos pGetpos; | |
158 | LPSetpos pSetpos; | |
159 | LPInit pInit; | |
160 | LPInitOSExtras pInitOSExtras; | |
7766f137 | 161 | LPFdupopen pFdupopen; |
0f4eea8f DL |
162 | }; |
163 | ||
0cb96387 GS |
164 | struct IPerlStdIOInfo |
165 | { | |
166 | unsigned long nCount; /* number of entries expected */ | |
167 | struct IPerlStdIO perlStdIOList; | |
168 | }; | |
2bd2b9e0 | 169 | |
76ced9ad NIS |
170 | /* These do not belong here ... NI-S, 14 Nov 2000 */ |
171 | ||
2bd2b9e0 | 172 | #ifdef USE_STDIO_PTR |
eaf8b698 | 173 | # define PerlSIO_has_cntptr(f) 1 |
a7ffa9b9 NC |
174 | # ifdef STDIO_PTR_LVALUE |
175 | # ifdef STDIO_CNT_LVALUE | |
eaf8b698 | 176 | # define PerlSIO_canset_cnt(f) 1 |
a7ffa9b9 | 177 | # ifdef STDIO_PTR_LVAL_NOCHANGE_CNT |
eaf8b698 | 178 | # define PerlSIO_fast_gets(f) 1 |
a7ffa9b9 NC |
179 | # endif |
180 | # else /* STDIO_CNT_LVALUE */ | |
eaf8b698 | 181 | # define PerlSIO_canset_cnt(f) 0 |
a7ffa9b9 NC |
182 | # endif |
183 | # else /* STDIO_PTR_LVALUE */ | |
184 | # ifdef STDIO_PTR_LVAL_SETS_CNT | |
eaf8b698 | 185 | # define PerlSIO_fast_gets(f) 1 |
2bd2b9e0 | 186 | # endif |
2bd2b9e0 GS |
187 | # endif |
188 | #else /* USE_STDIO_PTR */ | |
eaf8b698 NIS |
189 | # define PerlSIO_has_cntptr(f) 0 |
190 | # define PerlSIO_canset_cnt(f) 0 | |
2bd2b9e0 GS |
191 | #endif /* USE_STDIO_PTR */ |
192 | ||
eaf8b698 NIS |
193 | #ifndef PerlSIO_fast_gets |
194 | #define PerlSIO_fast_gets(f) 0 | |
2bd2b9e0 GS |
195 | #endif |
196 | ||
197 | #ifdef FILE_base | |
eaf8b698 | 198 | #define PerlSIO_has_base(f) 1 |
2bd2b9e0 | 199 | #else |
eaf8b698 | 200 | #define PerlSIO_has_base(f) 0 |
2bd2b9e0 | 201 | #endif |
0f4eea8f | 202 | |
eaf8b698 | 203 | /* Now take FILE * via function table */ |
76ced9ad | 204 | |
eaf8b698 | 205 | #define PerlSIO_stdin \ |
51371543 | 206 | (*PL_StdIO->pStdin)(PL_StdIO) |
eaf8b698 | 207 | #define PerlSIO_stdout \ |
51371543 | 208 | (*PL_StdIO->pStdout)(PL_StdIO) |
eaf8b698 | 209 | #define PerlSIO_stderr \ |
51371543 | 210 | (*PL_StdIO->pStderr)(PL_StdIO) |
eaf8b698 | 211 | #define PerlSIO_fopen(x,y) \ |
51371543 | 212 | (*PL_StdIO->pOpen)(PL_StdIO, (x),(y)) |
eaf8b698 | 213 | #define PerlSIO_fclose(f) \ |
51371543 | 214 | (*PL_StdIO->pClose)(PL_StdIO, (f)) |
eaf8b698 | 215 | #define PerlSIO_feof(f) \ |
51371543 | 216 | (*PL_StdIO->pEof)(PL_StdIO, (f)) |
eaf8b698 | 217 | #define PerlSIO_ferror(f) \ |
51371543 | 218 | (*PL_StdIO->pError)(PL_StdIO, (f)) |
eaf8b698 | 219 | #define PerlSIO_clearerr(f) \ |
51371543 | 220 | (*PL_StdIO->pClearerr)(PL_StdIO, (f)) |
eaf8b698 | 221 | #define PerlSIO_fgetc(f) \ |
51371543 | 222 | (*PL_StdIO->pGetc)(PL_StdIO, (f)) |
eaf8b698 | 223 | #define PerlSIO_get_base(f) \ |
51371543 | 224 | (*PL_StdIO->pGetBase)(PL_StdIO, (f)) |
eaf8b698 | 225 | #define PerlSIO_get_bufsiz(f) \ |
51371543 | 226 | (*PL_StdIO->pGetBufsiz)(PL_StdIO, (f)) |
eaf8b698 | 227 | #define PerlSIO_get_cnt(f) \ |
51371543 | 228 | (*PL_StdIO->pGetCnt)(PL_StdIO, (f)) |
eaf8b698 | 229 | #define PerlSIO_get_ptr(f) \ |
51371543 | 230 | (*PL_StdIO->pGetPtr)(PL_StdIO, (f)) |
50a4e535 | 231 | #define PerlSIO_fputc(c,f) \ |
634b482c | 232 | (*PL_StdIO->pPutc)(PL_StdIO, (c),(f)) |
50a4e535 | 233 | #define PerlSIO_fputs(s,f) \ |
634b482c | 234 | (*PL_StdIO->pPuts)(PL_StdIO, (s),(f)) |
eaf8b698 | 235 | #define PerlSIO_fflush(f) \ |
51371543 | 236 | (*PL_StdIO->pFlush)(PL_StdIO, (f)) |
6d655123 JD |
237 | #define PerlSIO_fgets(s, n, f) \ |
238 | (*PL_StdIO->pGets)(PL_StdIO, s, n, (f)) | |
adb71456 NIS |
239 | #define PerlSIO_ungetc(c,f) \ |
240 | (*PL_StdIO->pUngetc)(PL_StdIO, (c),(f)) | |
eaf8b698 | 241 | #define PerlSIO_fileno(f) \ |
51371543 | 242 | (*PL_StdIO->pFileno)(PL_StdIO, (f)) |
eaf8b698 | 243 | #define PerlSIO_fdopen(f, s) \ |
51371543 | 244 | (*PL_StdIO->pFdopen)(PL_StdIO, (f),(s)) |
eaf8b698 | 245 | #define PerlSIO_freopen(p, m, f) \ |
51371543 | 246 | (*PL_StdIO->pReopen)(PL_StdIO, (p), (m), (f)) |
eaf8b698 | 247 | #define PerlSIO_fread(buf,sz,count,f) \ |
adb71456 NIS |
248 | (*PL_StdIO->pRead)(PL_StdIO, (buf), (sz), (count), (f)) |
249 | #define PerlSIO_fwrite(buf,sz,count,f) \ | |
250 | (*PL_StdIO->pWrite)(PL_StdIO, (buf), (sz), (count), (f)) | |
eaf8b698 | 251 | #define PerlSIO_setbuf(f,b) \ |
51371543 | 252 | (*PL_StdIO->pSetBuf)(PL_StdIO, (f), (b)) |
eaf8b698 | 253 | #define PerlSIO_setvbuf(f,b,t,s) \ |
51371543 | 254 | (*PL_StdIO->pSetVBuf)(PL_StdIO, (f),(b),(t),(s)) |
eaf8b698 | 255 | #define PerlSIO_set_cnt(f,c) \ |
51371543 | 256 | (*PL_StdIO->pSetCnt)(PL_StdIO, (f), (c)) |
adb71456 NIS |
257 | #define PerlSIO_set_ptr(f,p) \ |
258 | (*PL_StdIO->pSetPtr)(PL_StdIO, (f), (p)) | |
eaf8b698 | 259 | #define PerlSIO_setlinebuf(f) \ |
51371543 | 260 | (*PL_StdIO->pSetlinebuf)(PL_StdIO, (f)) |
eaf8b698 | 261 | #define PerlSIO_printf Perl_fprintf_nocontext |
b0316773 JH |
262 | #define PerlSIO_stdoutf Perl_printf_nocontext |
263 | #define PerlSIO_vprintf(f,fmt,a) \ | |
4a7d1889 | 264 | (*PL_StdIO->pVprintf)(PL_StdIO, (f),(fmt),a) |
eaf8b698 | 265 | #define PerlSIO_ftell(f) \ |
51371543 | 266 | (*PL_StdIO->pTell)(PL_StdIO, (f)) |
eaf8b698 | 267 | #define PerlSIO_fseek(f,o,w) \ |
51371543 | 268 | (*PL_StdIO->pSeek)(PL_StdIO, (f),(o),(w)) |
eaf8b698 | 269 | #define PerlSIO_fgetpos(f,p) \ |
51371543 | 270 | (*PL_StdIO->pGetpos)(PL_StdIO, (f),(p)) |
eaf8b698 | 271 | #define PerlSIO_fsetpos(f,p) \ |
51371543 | 272 | (*PL_StdIO->pSetpos)(PL_StdIO, (f),(p)) |
eaf8b698 | 273 | #define PerlSIO_rewind(f) \ |
51371543 | 274 | (*PL_StdIO->pRewind)(PL_StdIO, (f)) |
eaf8b698 | 275 | #define PerlSIO_tmpfile() \ |
51371543 | 276 | (*PL_StdIO->pTmpfile)(PL_StdIO) |
eaf8b698 | 277 | #define PerlSIO_init() \ |
51371543 | 278 | (*PL_StdIO->pInit)(PL_StdIO) |
0f4eea8f | 279 | #undef init_os_extras |
c5be433b | 280 | #define init_os_extras() \ |
51371543 | 281 | (*PL_StdIO->pInitOSExtras)(PL_StdIO) |
eaf8b698 | 282 | #define PerlSIO_fdupopen(f) \ |
7766f137 | 283 | (*PL_StdIO->pFdupopen)(PL_StdIO, (f)) |
eaf8b698 NIS |
284 | |
285 | #else /* PERL_IMPLICIT_SYS */ | |
286 | ||
287 | #define PerlSIO_stdin stdin | |
288 | #define PerlSIO_stdout stdout | |
289 | #define PerlSIO_stderr stderr | |
290 | #define PerlSIO_fopen(x,y) fopen(x,y) | |
75e258e9 PG |
291 | #ifdef __VOS__ |
292 | /* Work around VOS bug posix-979, wrongly setting errno when at end of file. */ | |
293 | #define PerlSIO_fclose(f) (((errno==1025)?errno=0:0),fclose(f)) | |
294 | #define PerlSIO_feof(f) (((errno==1025)?errno=0:0),feof(f)) | |
295 | #define PerlSIO_ferror(f) (((errno==1025)?errno=0:0),ferror(f)) | |
296 | #else | |
eaf8b698 NIS |
297 | #define PerlSIO_fclose(f) fclose(f) |
298 | #define PerlSIO_feof(f) feof(f) | |
299 | #define PerlSIO_ferror(f) ferror(f) | |
75e258e9 | 300 | #endif |
eaf8b698 NIS |
301 | #define PerlSIO_clearerr(f) clearerr(f) |
302 | #define PerlSIO_fgetc(f) fgetc(f) | |
f7c20d1e | 303 | #ifdef FILE_base |
eaf8b698 NIS |
304 | #define PerlSIO_get_base(f) FILE_base(f) |
305 | #define PerlSIO_get_bufsiz(f) FILE_bufsiz(f) | |
306 | #else | |
307 | #define PerlSIO_get_base(f) NULL | |
308 | #define PerlSIO_get_bufsiz(f) 0 | |
309 | #endif | |
310 | #ifdef USE_STDIO_PTR | |
311 | #define PerlSIO_get_cnt(f) FILE_cnt(f) | |
312 | #define PerlSIO_get_ptr(f) FILE_ptr(f) | |
313 | #else | |
314 | #define PerlSIO_get_cnt(f) 0 | |
315 | #define PerlSIO_get_ptr(f) NULL | |
316 | #endif | |
50a4e535 JD |
317 | #define PerlSIO_fputc(c,f) fputc(c,f) |
318 | #define PerlSIO_fputs(s,f) fputs(s,f) | |
eaf8b698 | 319 | #define PerlSIO_fflush(f) Fflush(f) |
6d655123 | 320 | #define PerlSIO_fgets(s, n, f) fgets(s,n,f) |
5876737a | 321 | #if defined(__VMS) |
486ec47a | 322 | /* Unusual definition of ungetc() here to accommodate fast_sv_gets()' |
a15cef0c | 323 | * belief that it can mix getc/ungetc with reads from stdio buffer */ |
04ce8649 | 324 | START_EXTERN_C |
a15cef0c | 325 | int decc$ungetc(int __c, FILE *__stream); |
04ce8649 | 326 | END_EXTERN_C |
a15cef0c CB |
327 | # define PerlSIO_ungetc(c,f) ((c) == EOF ? EOF : \ |
328 | ((*(f) && !((*(f))->_flag & _IONBF) && \ | |
329 | ((*(f))->_ptr > (*(f))->_base)) ? \ | |
330 | ((*(f))->_cnt++, *(--(*(f))->_ptr) = (c)) : decc$ungetc(c,f))) | |
331 | #else | |
332 | # define PerlSIO_ungetc(c,f) ungetc(c,f) | |
333 | #endif | |
eaf8b698 NIS |
334 | #define PerlSIO_fileno(f) fileno(f) |
335 | #define PerlSIO_fdopen(f, s) fdopen(f,s) | |
336 | #define PerlSIO_freopen(p, m, f) freopen(p,m,f) | |
337 | #define PerlSIO_fread(buf,sz,count,f) fread(buf,sz,count,f) | |
338 | #define PerlSIO_fwrite(buf,sz,count,f) fwrite(buf,sz,count,f) | |
339 | #define PerlSIO_setbuf(f,b) setbuf(f,b) | |
340 | #define PerlSIO_setvbuf(f,b,t,s) setvbuf(f,b,t,s) | |
341 | #if defined(USE_STDIO_PTR) && defined(STDIO_CNT_LVALUE) | |
342 | #define PerlSIO_set_cnt(f,c) FILE_cnt(f) = (c) | |
343 | #else | |
344 | #define PerlSIO_set_cnt(f,c) PerlIOProc_abort() | |
345 | #endif | |
346 | #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE) | |
714c8e96 | 347 | #define PerlSIO_set_ptr(f,p) (FILE_ptr(f) = (p)) |
eaf8b698 NIS |
348 | #else |
349 | #define PerlSIO_set_ptr(f,p) PerlIOProc_abort() | |
350 | #endif | |
351 | #define PerlSIO_setlinebuf(f) setlinebuf(f) | |
079b94bc NIS |
352 | #define PerlSIO_printf fprintf |
353 | #define PerlSIO_stdoutf printf | |
362d0d44 | 354 | #define PerlSIO_vprintf(f,fmt,a) vfprintf(f,fmt,a) |
eaf8b698 NIS |
355 | #define PerlSIO_ftell(f) ftell(f) |
356 | #define PerlSIO_fseek(f,o,w) fseek(f,o,w) | |
357 | #define PerlSIO_fgetpos(f,p) fgetpos(f,p) | |
358 | #define PerlSIO_fsetpos(f,p) fsetpos(f,p) | |
359 | #define PerlSIO_rewind(f) rewind(f) | |
360 | #define PerlSIO_tmpfile() tmpfile() | |
eaf8b698 | 361 | #define PerlSIO_fdupopen(f) (f) |
0f4eea8f | 362 | |
c5be433b | 363 | #endif /* PERL_IMPLICIT_SYS */ |
0f4eea8f | 364 | |
0f4eea8f DL |
365 | /* |
366 | * Interface for directory functions | |
367 | */ | |
368 | ||
c5be433b | 369 | #if defined(PERL_IMPLICIT_SYS) |
0f4eea8f | 370 | |
0cb96387 GS |
371 | /* IPerlDir */ |
372 | struct IPerlDir; | |
7766f137 | 373 | struct IPerlDirInfo; |
0cb96387 GS |
374 | typedef int (*LPMakedir)(struct IPerlDir*, const char*, int); |
375 | typedef int (*LPChdir)(struct IPerlDir*, const char*); | |
376 | typedef int (*LPRmdir)(struct IPerlDir*, const char*); | |
377 | typedef int (*LPDirClose)(struct IPerlDir*, DIR*); | |
0e06f75d | 378 | typedef DIR* (*LPDirOpen)(struct IPerlDir*, const char*); |
0cb96387 GS |
379 | typedef struct direct* (*LPDirRead)(struct IPerlDir*, DIR*); |
380 | typedef void (*LPDirRewind)(struct IPerlDir*, DIR*); | |
381 | typedef void (*LPDirSeek)(struct IPerlDir*, DIR*, long); | |
382 | typedef long (*LPDirTell)(struct IPerlDir*, DIR*); | |
7766f137 GS |
383 | #ifdef WIN32 |
384 | typedef char* (*LPDirMapPathA)(struct IPerlDir*, const char*); | |
385 | typedef WCHAR* (*LPDirMapPathW)(struct IPerlDir*, const WCHAR*); | |
386 | #endif | |
0cb96387 GS |
387 | |
388 | struct IPerlDir | |
0f4eea8f | 389 | { |
0cb96387 GS |
390 | LPMakedir pMakedir; |
391 | LPChdir pChdir; | |
392 | LPRmdir pRmdir; | |
393 | LPDirClose pClose; | |
394 | LPDirOpen pOpen; | |
395 | LPDirRead pRead; | |
396 | LPDirRewind pRewind; | |
397 | LPDirSeek pSeek; | |
398 | LPDirTell pTell; | |
7766f137 GS |
399 | #ifdef WIN32 |
400 | LPDirMapPathA pMapPathA; | |
401 | LPDirMapPathW pMapPathW; | |
402 | #endif | |
0cb96387 GS |
403 | }; |
404 | ||
405 | struct IPerlDirInfo | |
406 | { | |
407 | unsigned long nCount; /* number of entries expected */ | |
408 | struct IPerlDir perlDirList; | |
0f4eea8f DL |
409 | }; |
410 | ||
411 | #define PerlDir_mkdir(name, mode) \ | |
51371543 | 412 | (*PL_Dir->pMakedir)(PL_Dir, (name), (mode)) |
0f4eea8f | 413 | #define PerlDir_chdir(name) \ |
51371543 | 414 | (*PL_Dir->pChdir)(PL_Dir, (name)) |
0f4eea8f | 415 | #define PerlDir_rmdir(name) \ |
51371543 | 416 | (*PL_Dir->pRmdir)(PL_Dir, (name)) |
0f4eea8f | 417 | #define PerlDir_close(dir) \ |
51371543 | 418 | (*PL_Dir->pClose)(PL_Dir, (dir)) |
0f4eea8f | 419 | #define PerlDir_open(name) \ |
51371543 | 420 | (*PL_Dir->pOpen)(PL_Dir, (name)) |
0f4eea8f | 421 | #define PerlDir_read(dir) \ |
51371543 | 422 | (*PL_Dir->pRead)(PL_Dir, (dir)) |
0f4eea8f | 423 | #define PerlDir_rewind(dir) \ |
51371543 | 424 | (*PL_Dir->pRewind)(PL_Dir, (dir)) |
0f4eea8f | 425 | #define PerlDir_seek(dir, loc) \ |
51371543 | 426 | (*PL_Dir->pSeek)(PL_Dir, (dir), (loc)) |
0f4eea8f | 427 | #define PerlDir_tell(dir) \ |
51371543 | 428 | (*PL_Dir->pTell)(PL_Dir, (dir)) |
7766f137 GS |
429 | #ifdef WIN32 |
430 | #define PerlDir_mapA(dir) \ | |
431 | (*PL_Dir->pMapPathA)(PL_Dir, (dir)) | |
432 | #define PerlDir_mapW(dir) \ | |
433 | (*PL_Dir->pMapPathW)(PL_Dir, (dir)) | |
434 | #endif | |
0f4eea8f | 435 | |
c5be433b | 436 | #else /* PERL_IMPLICIT_SYS */ |
0f4eea8f DL |
437 | |
438 | #define PerlDir_mkdir(name, mode) Mkdir((name), (mode)) | |
439 | #ifdef VMS | |
9d4c144b | 440 | # define PerlDir_chdir(n) Chdir((n)) |
6f9d8c32 | 441 | #else |
0f4eea8f DL |
442 | # define PerlDir_chdir(name) chdir((name)) |
443 | #endif | |
444 | #define PerlDir_rmdir(name) rmdir((name)) | |
445 | #define PerlDir_close(dir) closedir((dir)) | |
446 | #define PerlDir_open(name) opendir((name)) | |
447 | #define PerlDir_read(dir) readdir((dir)) | |
448 | #define PerlDir_rewind(dir) rewinddir((dir)) | |
449 | #define PerlDir_seek(dir, loc) seekdir((dir), (loc)) | |
450 | #define PerlDir_tell(dir) telldir((dir)) | |
7766f137 GS |
451 | #ifdef WIN32 |
452 | #define PerlDir_mapA(dir) dir | |
453 | #define PerlDir_mapW(dir) dir | |
454 | #endif | |
0f4eea8f | 455 | |
c5be433b | 456 | #endif /* PERL_IMPLICIT_SYS */ |
0f4eea8f DL |
457 | |
458 | /* | |
459 | Interface for perl environment functions | |
460 | */ | |
461 | ||
c5be433b | 462 | #if defined(PERL_IMPLICIT_SYS) |
0f4eea8f | 463 | |
0cb96387 GS |
464 | /* IPerlEnv */ |
465 | struct IPerlEnv; | |
7766f137 | 466 | struct IPerlEnvInfo; |
0cb96387 GS |
467 | typedef char* (*LPEnvGetenv)(struct IPerlEnv*, const char*); |
468 | typedef int (*LPEnvPutenv)(struct IPerlEnv*, const char*); | |
3075ddba | 469 | typedef char* (*LPEnvGetenv_len)(struct IPerlEnv*, |
0cb96387 GS |
470 | const char *varname, unsigned long *len); |
471 | typedef int (*LPEnvUname)(struct IPerlEnv*, struct utsname *name); | |
472 | typedef void (*LPEnvClearenv)(struct IPerlEnv*); | |
3075ddba GS |
473 | typedef void* (*LPEnvGetChildenv)(struct IPerlEnv*); |
474 | typedef void (*LPEnvFreeChildenv)(struct IPerlEnv*, void* env); | |
475 | typedef char* (*LPEnvGetChilddir)(struct IPerlEnv*); | |
476 | typedef void (*LPEnvFreeChilddir)(struct IPerlEnv*, char* dir); | |
0cb96387 | 477 | #ifdef HAS_ENVGETENV |
3075ddba GS |
478 | typedef char* (*LPENVGetenv)(struct IPerlEnv*, const char *varname); |
479 | typedef char* (*LPENVGetenv_len)(struct IPerlEnv*, | |
0cb96387 GS |
480 | const char *varname, unsigned long *len); |
481 | #endif | |
482 | #ifdef WIN32 | |
3075ddba | 483 | typedef unsigned long (*LPEnvOsID)(struct IPerlEnv*); |
6937817d | 484 | typedef char* (*LPEnvLibPath)(struct IPerlEnv*, WIN32_NO_REGISTRY_M_(const char*) |
e6a0bbf8 NC |
485 | STRLEN *const len); |
486 | typedef char* (*LPEnvSiteLibPath)(struct IPerlEnv*, const char*, | |
487 | STRLEN *const len); | |
488 | typedef char* (*LPEnvVendorLibPath)(struct IPerlEnv*, const char*, | |
489 | STRLEN *const len); | |
635bbe87 | 490 | typedef void (*LPEnvGetChildIO)(struct IPerlEnv*, child_IO_table*); |
0cb96387 GS |
491 | #endif |
492 | ||
493 | struct IPerlEnv | |
0f4eea8f | 494 | { |
0cb96387 GS |
495 | LPEnvGetenv pGetenv; |
496 | LPEnvPutenv pPutenv; | |
497 | LPEnvGetenv_len pGetenv_len; | |
498 | LPEnvUname pEnvUname; | |
499 | LPEnvClearenv pClearenv; | |
3075ddba GS |
500 | LPEnvGetChildenv pGetChildenv; |
501 | LPEnvFreeChildenv pFreeChildenv; | |
502 | LPEnvGetChilddir pGetChilddir; | |
503 | LPEnvFreeChilddir pFreeChilddir; | |
a6c40364 | 504 | #ifdef HAS_ENVGETENV |
0cb96387 GS |
505 | LPENVGetenv pENVGetenv; |
506 | LPENVGetenv_len pENVGetenv_len; | |
507 | #endif | |
508 | #ifdef WIN32 | |
509 | LPEnvOsID pEnvOsID; | |
510 | LPEnvLibPath pLibPath; | |
511 | LPEnvSiteLibPath pSiteLibPath; | |
4ea817c6 | 512 | LPEnvVendorLibPath pVendorLibPath; |
635bbe87 | 513 | LPEnvGetChildIO pGetChildIO; |
a6c40364 | 514 | #endif |
0f4eea8f DL |
515 | }; |
516 | ||
0cb96387 GS |
517 | struct IPerlEnvInfo |
518 | { | |
519 | unsigned long nCount; /* number of entries expected */ | |
520 | struct IPerlEnv perlEnvList; | |
521 | }; | |
522 | ||
523 | #define PerlEnv_putenv(str) \ | |
51371543 | 524 | (*PL_Env->pPutenv)(PL_Env,(str)) |
0cb96387 | 525 | #define PerlEnv_getenv(str) \ |
51371543 | 526 | (*PL_Env->pGetenv)(PL_Env,(str)) |
0cb96387 | 527 | #define PerlEnv_getenv_len(str,l) \ |
51371543 | 528 | (*PL_Env->pGetenv_len)(PL_Env,(str), (l)) |
3075ddba | 529 | #define PerlEnv_clearenv() \ |
51371543 | 530 | (*PL_Env->pClearenv)(PL_Env) |
3075ddba GS |
531 | #define PerlEnv_get_childenv() \ |
532 | (*PL_Env->pGetChildenv)(PL_Env) | |
533 | #define PerlEnv_free_childenv(e) \ | |
534 | (*PL_Env->pFreeChildenv)(PL_Env, (e)) | |
535 | #define PerlEnv_get_childdir() \ | |
536 | (*PL_Env->pGetChilddir)(PL_Env) | |
537 | #define PerlEnv_free_childdir(d) \ | |
538 | (*PL_Env->pFreeChilddir)(PL_Env, (d)) | |
f675dbe5 | 539 | #ifdef HAS_ENVGETENV |
0cb96387 | 540 | # define PerlEnv_ENVgetenv(str) \ |
51371543 | 541 | (*PL_Env->pENVGetenv)(PL_Env,(str)) |
0cb96387 | 542 | # define PerlEnv_ENVgetenv_len(str,l) \ |
51371543 | 543 | (*PL_Env->pENVGetenv_len)(PL_Env,(str), (l)) |
f675dbe5 | 544 | #else |
0cb96387 GS |
545 | # define PerlEnv_ENVgetenv(str) \ |
546 | PerlEnv_getenv((str)) | |
547 | # define PerlEnv_ENVgetenv_len(str,l) \ | |
548 | PerlEnv_getenv_len((str),(l)) | |
f675dbe5 | 549 | #endif |
0cb96387 | 550 | #define PerlEnv_uname(name) \ |
51371543 | 551 | (*PL_Env->pEnvUname)(PL_Env,(name)) |
0f4eea8f | 552 | #ifdef WIN32 |
0cb96387 | 553 | #define PerlEnv_os_id() \ |
51371543 | 554 | (*PL_Env->pEnvOsID)(PL_Env) |
e6a0bbf8 | 555 | #define PerlEnv_lib_path(str, lenp) \ |
6937817d | 556 | (*PL_Env->pLibPath)(PL_Env,WIN32_NO_REGISTRY_M_(str)(lenp)) |
e6a0bbf8 NC |
557 | #define PerlEnv_sitelib_path(str, lenp) \ |
558 | (*PL_Env->pSiteLibPath)(PL_Env,(str),(lenp)) | |
559 | #define PerlEnv_vendorlib_path(str, lenp) \ | |
560 | (*PL_Env->pVendorLibPath)(PL_Env,(str),(lenp)) | |
635bbe87 GS |
561 | #define PerlEnv_get_child_IO(ptr) \ |
562 | (*PL_Env->pGetChildIO)(PL_Env, ptr) | |
0f4eea8f DL |
563 | #endif |
564 | ||
c5be433b | 565 | #else /* PERL_IMPLICIT_SYS */ |
0f4eea8f DL |
566 | |
567 | #define PerlEnv_putenv(str) putenv((str)) | |
568 | #define PerlEnv_getenv(str) getenv((str)) | |
a6c40364 | 569 | #define PerlEnv_getenv_len(str,l) getenv_len((str), (l)) |
f675dbe5 CB |
570 | #ifdef HAS_ENVGETENV |
571 | # define PerlEnv_ENVgetenv(str) ENVgetenv((str)) | |
a6c40364 | 572 | # define PerlEnv_ENVgetenv_len(str,l) ENVgetenv_len((str), (l)) |
f675dbe5 CB |
573 | #else |
574 | # define PerlEnv_ENVgetenv(str) PerlEnv_getenv((str)) | |
a6c40364 | 575 | # define PerlEnv_ENVgetenv_len(str,l) PerlEnv_getenv_len((str), (l)) |
f675dbe5 | 576 | #endif |
b2af26b1 | 577 | #define PerlEnv_uname(name) uname((name)) |
0f4eea8f | 578 | |
0cb96387 GS |
579 | #ifdef WIN32 |
580 | #define PerlEnv_os_id() win32_os_id() | |
6937817d | 581 | #define PerlEnv_lib_path(str, lenp) win32_get_privlib(WIN32_NO_REGISTRY_M_(str) lenp) |
e6a0bbf8 NC |
582 | #define PerlEnv_sitelib_path(str, lenp) win32_get_sitelib(str, lenp) |
583 | #define PerlEnv_vendorlib_path(str, lenp) win32_get_vendorlib(str, lenp) | |
635bbe87 | 584 | #define PerlEnv_get_child_IO(ptr) win32_get_child_IO(ptr) |
df3728a2 JH |
585 | #define PerlEnv_clearenv() win32_clearenv() |
586 | #define PerlEnv_get_childenv() win32_get_childenv() | |
587 | #define PerlEnv_free_childenv(e) win32_free_childenv((e)) | |
588 | #define PerlEnv_get_childdir() win32_get_childdir() | |
589 | #define PerlEnv_free_childdir(d) win32_free_childdir((d)) | |
590 | #else | |
591 | #define PerlEnv_clearenv() clearenv() | |
592 | #define PerlEnv_get_childenv() get_childenv() | |
593 | #define PerlEnv_free_childenv(e) free_childenv((e)) | |
594 | #define PerlEnv_get_childdir() get_childdir() | |
595 | #define PerlEnv_free_childdir(d) free_childdir((d)) | |
0cb96387 GS |
596 | #endif |
597 | ||
c5be433b | 598 | #endif /* PERL_IMPLICIT_SYS */ |
0f4eea8f DL |
599 | |
600 | /* | |
601 | Interface for perl low-level IO functions | |
602 | */ | |
603 | ||
c5be433b | 604 | #if defined(PERL_IMPLICIT_SYS) |
0f4eea8f | 605 | |
4d0c87b7 TC |
606 | struct utimbuf; /* prevent gcc warning about the use below */ |
607 | ||
0cb96387 GS |
608 | /* IPerlLIO */ |
609 | struct IPerlLIO; | |
7766f137 | 610 | struct IPerlLIOInfo; |
0cb96387 GS |
611 | typedef int (*LPLIOAccess)(struct IPerlLIO*, const char*, int); |
612 | typedef int (*LPLIOChmod)(struct IPerlLIO*, const char*, int); | |
613 | typedef int (*LPLIOChown)(struct IPerlLIO*, const char*, uid_t, | |
614 | gid_t); | |
4a9d6100 | 615 | typedef int (*LPLIOChsize)(struct IPerlLIO*, int, Off_t); |
0cb96387 GS |
616 | typedef int (*LPLIOClose)(struct IPerlLIO*, int); |
617 | typedef int (*LPLIODup)(struct IPerlLIO*, int); | |
618 | typedef int (*LPLIODup2)(struct IPerlLIO*, int, int); | |
619 | typedef int (*LPLIOFlock)(struct IPerlLIO*, int, int); | |
c623ac67 | 620 | typedef int (*LPLIOFileStat)(struct IPerlLIO*, int, Stat_t*); |
0cb96387 GS |
621 | typedef int (*LPLIOIOCtl)(struct IPerlLIO*, int, unsigned int, |
622 | char*); | |
623 | typedef int (*LPLIOIsatty)(struct IPerlLIO*, int); | |
6b980173 JD |
624 | typedef int (*LPLIOLink)(struct IPerlLIO*, const char*, |
625 | const char *); | |
c623ac67 | 626 | typedef Off_t (*LPLIOLseek)(struct IPerlLIO*, int, Off_t, int); |
0cb96387 | 627 | typedef int (*LPLIOLstat)(struct IPerlLIO*, const char*, |
c623ac67 | 628 | Stat_t*); |
0cb96387 GS |
629 | typedef char* (*LPLIOMktemp)(struct IPerlLIO*, char*); |
630 | typedef int (*LPLIOOpen)(struct IPerlLIO*, const char*, int); | |
631 | typedef int (*LPLIOOpen3)(struct IPerlLIO*, const char*, int, int); | |
632 | typedef int (*LPLIORead)(struct IPerlLIO*, int, void*, unsigned int); | |
633 | typedef int (*LPLIORename)(struct IPerlLIO*, const char*, | |
634 | const char*); | |
2986a63f JH |
635 | #ifdef NETWARE |
636 | typedef int (*LPLIOSetmode)(struct IPerlLIO*, FILE*, int); | |
637 | #else | |
0cb96387 | 638 | typedef int (*LPLIOSetmode)(struct IPerlLIO*, int, int); |
2986a63f | 639 | #endif /* NETWARE */ |
0cb96387 | 640 | typedef int (*LPLIONameStat)(struct IPerlLIO*, const char*, |
c623ac67 | 641 | Stat_t*); |
0cb96387 GS |
642 | typedef char* (*LPLIOTmpnam)(struct IPerlLIO*, char*); |
643 | typedef int (*LPLIOUmask)(struct IPerlLIO*, int); | |
644 | typedef int (*LPLIOUnlink)(struct IPerlLIO*, const char*); | |
c3ff6b30 | 645 | typedef int (*LPLIOUtime)(struct IPerlLIO*, const char*, struct utimbuf*); |
0cb96387 GS |
646 | typedef int (*LPLIOWrite)(struct IPerlLIO*, int, const void*, |
647 | unsigned int); | |
648 | ||
649 | struct IPerlLIO | |
650 | { | |
651 | LPLIOAccess pAccess; | |
652 | LPLIOChmod pChmod; | |
653 | LPLIOChown pChown; | |
654 | LPLIOChsize pChsize; | |
655 | LPLIOClose pClose; | |
656 | LPLIODup pDup; | |
657 | LPLIODup2 pDup2; | |
658 | LPLIOFlock pFlock; | |
659 | LPLIOFileStat pFileStat; | |
660 | LPLIOIOCtl pIOCtl; | |
661 | LPLIOIsatty pIsatty; | |
6b980173 | 662 | LPLIOLink pLink; |
0cb96387 GS |
663 | LPLIOLseek pLseek; |
664 | LPLIOLstat pLstat; | |
665 | LPLIOMktemp pMktemp; | |
666 | LPLIOOpen pOpen; | |
667 | LPLIOOpen3 pOpen3; | |
668 | LPLIORead pRead; | |
669 | LPLIORename pRename; | |
670 | LPLIOSetmode pSetmode; | |
671 | LPLIONameStat pNameStat; | |
672 | LPLIOTmpnam pTmpnam; | |
673 | LPLIOUmask pUmask; | |
674 | LPLIOUnlink pUnlink; | |
675 | LPLIOUtime pUtime; | |
676 | LPLIOWrite pWrite; | |
677 | }; | |
678 | ||
679 | struct IPerlLIOInfo | |
0f4eea8f | 680 | { |
0cb96387 GS |
681 | unsigned long nCount; /* number of entries expected */ |
682 | struct IPerlLIO perlLIOList; | |
0f4eea8f DL |
683 | }; |
684 | ||
685 | #define PerlLIO_access(file, mode) \ | |
51371543 | 686 | (*PL_LIO->pAccess)(PL_LIO, (file), (mode)) |
0f4eea8f | 687 | #define PerlLIO_chmod(file, mode) \ |
51371543 | 688 | (*PL_LIO->pChmod)(PL_LIO, (file), (mode)) |
0f4eea8f | 689 | #define PerlLIO_chown(file, owner, group) \ |
51371543 | 690 | (*PL_LIO->pChown)(PL_LIO, (file), (owner), (group)) |
0f4eea8f | 691 | #define PerlLIO_chsize(fd, size) \ |
51371543 | 692 | (*PL_LIO->pChsize)(PL_LIO, (fd), (size)) |
0f4eea8f | 693 | #define PerlLIO_close(fd) \ |
51371543 | 694 | (*PL_LIO->pClose)(PL_LIO, (fd)) |
0f4eea8f | 695 | #define PerlLIO_dup(fd) \ |
51371543 | 696 | (*PL_LIO->pDup)(PL_LIO, (fd)) |
0f4eea8f | 697 | #define PerlLIO_dup2(fd1, fd2) \ |
51371543 | 698 | (*PL_LIO->pDup2)(PL_LIO, (fd1), (fd2)) |
0f4eea8f | 699 | #define PerlLIO_flock(fd, op) \ |
51371543 | 700 | (*PL_LIO->pFlock)(PL_LIO, (fd), (op)) |
0f4eea8f | 701 | #define PerlLIO_fstat(fd, buf) \ |
51371543 | 702 | (*PL_LIO->pFileStat)(PL_LIO, (fd), (buf)) |
0f4eea8f | 703 | #define PerlLIO_ioctl(fd, u, buf) \ |
51371543 | 704 | (*PL_LIO->pIOCtl)(PL_LIO, (fd), (u), (buf)) |
0f4eea8f | 705 | #define PerlLIO_isatty(fd) \ |
51371543 | 706 | (*PL_LIO->pIsatty)(PL_LIO, (fd)) |
6b980173 JD |
707 | #define PerlLIO_link(oldname, newname) \ |
708 | (*PL_LIO->pLink)(PL_LIO, (oldname), (newname)) | |
0f4eea8f | 709 | #define PerlLIO_lseek(fd, offset, mode) \ |
51371543 | 710 | (*PL_LIO->pLseek)(PL_LIO, (fd), (offset), (mode)) |
0f4eea8f | 711 | #define PerlLIO_lstat(name, buf) \ |
51371543 | 712 | (*PL_LIO->pLstat)(PL_LIO, (name), (buf)) |
0f4eea8f | 713 | #define PerlLIO_mktemp(file) \ |
51371543 | 714 | (*PL_LIO->pMktemp)(PL_LIO, (file)) |
0f4eea8f | 715 | #define PerlLIO_open(file, flag) \ |
51371543 | 716 | (*PL_LIO->pOpen)(PL_LIO, (file), (flag)) |
0f4eea8f | 717 | #define PerlLIO_open3(file, flag, perm) \ |
51371543 | 718 | (*PL_LIO->pOpen3)(PL_LIO, (file), (flag), (perm)) |
0f4eea8f | 719 | #define PerlLIO_read(fd, buf, count) \ |
51371543 | 720 | (*PL_LIO->pRead)(PL_LIO, (fd), (buf), (count)) |
8d9b2e3c | 721 | #define PerlLIO_rename(oname, newname) \ |
51371543 | 722 | (*PL_LIO->pRename)(PL_LIO, (oname), (newname)) |
0f4eea8f | 723 | #define PerlLIO_setmode(fd, mode) \ |
51371543 | 724 | (*PL_LIO->pSetmode)(PL_LIO, (fd), (mode)) |
0f4eea8f | 725 | #define PerlLIO_stat(name, buf) \ |
51371543 | 726 | (*PL_LIO->pNameStat)(PL_LIO, (name), (buf)) |
0f4eea8f | 727 | #define PerlLIO_tmpnam(str) \ |
51371543 | 728 | (*PL_LIO->pTmpnam)(PL_LIO, (str)) |
0f4eea8f | 729 | #define PerlLIO_umask(mode) \ |
51371543 | 730 | (*PL_LIO->pUmask)(PL_LIO, (mode)) |
0f4eea8f | 731 | #define PerlLIO_unlink(file) \ |
51371543 | 732 | (*PL_LIO->pUnlink)(PL_LIO, (file)) |
0f4eea8f | 733 | #define PerlLIO_utime(file, time) \ |
51371543 | 734 | (*PL_LIO->pUtime)(PL_LIO, (file), (time)) |
0f4eea8f | 735 | #define PerlLIO_write(fd, buf, count) \ |
51371543 | 736 | (*PL_LIO->pWrite)(PL_LIO, (fd), (buf), (count)) |
0f4eea8f | 737 | |
c5be433b | 738 | #else /* PERL_IMPLICIT_SYS */ |
0f4eea8f DL |
739 | |
740 | #define PerlLIO_access(file, mode) access((file), (mode)) | |
741 | #define PerlLIO_chmod(file, mode) chmod((file), (mode)) | |
742 | #define PerlLIO_chown(file, owner, grp) chown((file), (owner), (grp)) | |
58e24eff SH |
743 | #if defined(HAS_TRUNCATE) |
744 | # define PerlLIO_chsize(fd, size) ftruncate((fd), (size)) | |
745 | #elif defined(HAS_CHSIZE) | |
746 | # define PerlLIO_chsize(fd, size) chsize((fd), (size)) | |
747 | #else | |
748 | # define PerlLIO_chsize(fd, size) my_chsize((fd), (size)) | |
749 | #endif | |
0f4eea8f DL |
750 | #define PerlLIO_close(fd) close((fd)) |
751 | #define PerlLIO_dup(fd) dup((fd)) | |
752 | #define PerlLIO_dup2(fd1, fd2) dup2((fd1), (fd2)) | |
753 | #define PerlLIO_flock(fd, op) FLOCK((fd), (op)) | |
754 | #define PerlLIO_fstat(fd, buf) Fstat((fd), (buf)) | |
755 | #define PerlLIO_ioctl(fd, u, buf) ioctl((fd), (u), (buf)) | |
756 | #define PerlLIO_isatty(fd) isatty((fd)) | |
6b980173 | 757 | #define PerlLIO_link(oldname, newname) link((oldname), (newname)) |
0f4eea8f | 758 | #define PerlLIO_lseek(fd, offset, mode) lseek((fd), (offset), (mode)) |
1f47e8e2 | 759 | #define PerlLIO_stat(name, buf) Stat((name), (buf)) |
9423c6fc | 760 | #ifdef HAS_LSTAT |
1f47e8e2 | 761 | # define PerlLIO_lstat(name, buf) lstat((name), (buf)) |
9423c6fc | 762 | #else |
1f47e8e2 | 763 | # define PerlLIO_lstat(name, buf) PerlLIO_stat((name), (buf)) |
9423c6fc | 764 | #endif |
0f4eea8f | 765 | #define PerlLIO_mktemp(file) mktemp((file)) |
0f4eea8f DL |
766 | #define PerlLIO_open(file, flag) open((file), (flag)) |
767 | #define PerlLIO_open3(file, flag, perm) open((file), (flag), (perm)) | |
768 | #define PerlLIO_read(fd, buf, count) read((fd), (buf), (count)) | |
769 | #define PerlLIO_rename(old, new) rename((old), (new)) | |
770 | #define PerlLIO_setmode(fd, mode) setmode((fd), (mode)) | |
0f4eea8f DL |
771 | #define PerlLIO_tmpnam(str) tmpnam((str)) |
772 | #define PerlLIO_umask(mode) umask((mode)) | |
773 | #define PerlLIO_unlink(file) unlink((file)) | |
774 | #define PerlLIO_utime(file, time) utime((file), (time)) | |
775 | #define PerlLIO_write(fd, buf, count) write((fd), (buf), (count)) | |
776 | ||
c5be433b | 777 | #endif /* PERL_IMPLICIT_SYS */ |
0f4eea8f DL |
778 | |
779 | /* | |
780 | Interface for perl memory allocation | |
781 | */ | |
782 | ||
c5be433b | 783 | #if defined(PERL_IMPLICIT_SYS) |
0f4eea8f | 784 | |
0cb96387 GS |
785 | /* IPerlMem */ |
786 | struct IPerlMem; | |
7766f137 | 787 | struct IPerlMemInfo; |
0cb96387 GS |
788 | typedef void* (*LPMemMalloc)(struct IPerlMem*, size_t); |
789 | typedef void* (*LPMemRealloc)(struct IPerlMem*, void*, size_t); | |
790 | typedef void (*LPMemFree)(struct IPerlMem*, void*); | |
7766f137 GS |
791 | typedef void* (*LPMemCalloc)(struct IPerlMem*, size_t, size_t); |
792 | typedef void (*LPMemGetLock)(struct IPerlMem*); | |
793 | typedef void (*LPMemFreeLock)(struct IPerlMem*); | |
794 | typedef int (*LPMemIsLocked)(struct IPerlMem*); | |
0cb96387 GS |
795 | |
796 | struct IPerlMem | |
0f4eea8f | 797 | { |
0cb96387 GS |
798 | LPMemMalloc pMalloc; |
799 | LPMemRealloc pRealloc; | |
800 | LPMemFree pFree; | |
7766f137 GS |
801 | LPMemCalloc pCalloc; |
802 | LPMemGetLock pGetLock; | |
803 | LPMemFreeLock pFreeLock; | |
804 | LPMemIsLocked pIsLocked; | |
0f4eea8f DL |
805 | }; |
806 | ||
0cb96387 GS |
807 | struct IPerlMemInfo |
808 | { | |
809 | unsigned long nCount; /* number of entries expected */ | |
810 | struct IPerlMem perlMemList; | |
811 | }; | |
812 | ||
7766f137 | 813 | /* Interpreter specific memory macros */ |
0cb96387 | 814 | #define PerlMem_malloc(size) \ |
51371543 | 815 | (*PL_Mem->pMalloc)(PL_Mem, (size)) |
0cb96387 | 816 | #define PerlMem_realloc(buf, size) \ |
51371543 | 817 | (*PL_Mem->pRealloc)(PL_Mem, (buf), (size)) |
0cb96387 | 818 | #define PerlMem_free(buf) \ |
51371543 | 819 | (*PL_Mem->pFree)(PL_Mem, (buf)) |
7766f137 GS |
820 | #define PerlMem_calloc(num, size) \ |
821 | (*PL_Mem->pCalloc)(PL_Mem, (num), (size)) | |
822 | #define PerlMem_get_lock() \ | |
823 | (*PL_Mem->pGetLock)(PL_Mem) | |
824 | #define PerlMem_free_lock() \ | |
825 | (*PL_Mem->pFreeLock)(PL_Mem) | |
826 | #define PerlMem_is_locked() \ | |
827 | (*PL_Mem->pIsLocked)(PL_Mem) | |
828 | ||
829 | /* Shared memory macros */ | |
083fcd59 | 830 | #ifdef NETWARE |
362d0d44 | 831 | |
7e4e8c89 | 832 | #define PerlMemShared_malloc(size) \ |
083fcd59 JH |
833 | (*PL_Mem->pMalloc)(PL_Mem, (size)) |
834 | #define PerlMemShared_realloc(buf, size) \ | |
835 | (*PL_Mem->pRealloc)(PL_Mem, (buf), (size)) | |
836 | #define PerlMemShared_free(buf) \ | |
837 | (*PL_Mem->pFree)(PL_Mem, (buf)) | |
838 | #define PerlMemShared_calloc(num, size) \ | |
839 | (*PL_Mem->pCalloc)(PL_Mem, (num), (size)) | |
840 | #define PerlMemShared_get_lock() \ | |
841 | (*PL_Mem->pGetLock)(PL_Mem) | |
842 | #define PerlMemShared_free_lock() \ | |
843 | (*PL_Mem->pFreeLock)(PL_Mem) | |
844 | #define PerlMemShared_is_locked() \ | |
845 | (*PL_Mem->pIsLocked)(PL_Mem) | |
846 | ||
847 | #else | |
848 | ||
7766f137 | 849 | #define PerlMemShared_malloc(size) \ |
0a77e2d7 | 850 | (*PL_MemShared->pMalloc)(PL_MemShared, (size)) |
7766f137 | 851 | #define PerlMemShared_realloc(buf, size) \ |
0a77e2d7 | 852 | (*PL_MemShared->pRealloc)(PL_MemShared, (buf), (size)) |
7766f137 | 853 | #define PerlMemShared_free(buf) \ |
0a77e2d7 | 854 | (*PL_MemShared->pFree)(PL_MemShared, (buf)) |
7766f137 | 855 | #define PerlMemShared_calloc(num, size) \ |
0a77e2d7 | 856 | (*PL_MemShared->pCalloc)(PL_MemShared, (num), (size)) |
7766f137 | 857 | #define PerlMemShared_get_lock() \ |
0a77e2d7 | 858 | (*PL_MemShared->pGetLock)(PL_MemShared) |
7766f137 | 859 | #define PerlMemShared_free_lock() \ |
0a77e2d7 | 860 | (*PL_MemShared->pFreeLock)(PL_MemShared) |
7766f137 | 861 | #define PerlMemShared_is_locked() \ |
0a77e2d7 | 862 | (*PL_MemShared->pIsLocked)(PL_MemShared) |
7766f137 | 863 | |
083fcd59 | 864 | #endif |
7766f137 GS |
865 | |
866 | /* Parse tree memory macros */ | |
867 | #define PerlMemParse_malloc(size) \ | |
0a77e2d7 | 868 | (*PL_MemParse->pMalloc)(PL_MemParse, (size)) |
7766f137 | 869 | #define PerlMemParse_realloc(buf, size) \ |
0a77e2d7 | 870 | (*PL_MemParse->pRealloc)(PL_MemParse, (buf), (size)) |
7766f137 | 871 | #define PerlMemParse_free(buf) \ |
0a77e2d7 | 872 | (*PL_MemParse->pFree)(PL_MemParse, (buf)) |
7766f137 | 873 | #define PerlMemParse_calloc(num, size) \ |
0a77e2d7 | 874 | (*PL_MemParse->pCalloc)(PL_MemParse, (num), (size)) |
7766f137 | 875 | #define PerlMemParse_get_lock() \ |
0a77e2d7 | 876 | (*PL_MemParse->pGetLock)(PL_MemParse) |
7766f137 | 877 | #define PerlMemParse_free_lock() \ |
0a77e2d7 | 878 | (*PL_MemParse->pFreeLock)(PL_MemParse) |
7766f137 | 879 | #define PerlMemParse_is_locked() \ |
0a77e2d7 | 880 | (*PL_MemParse->pIsLocked)(PL_MemParse) |
7766f137 | 881 | |
0f4eea8f | 882 | |
c5be433b | 883 | #else /* PERL_IMPLICIT_SYS */ |
0f4eea8f | 884 | |
7766f137 | 885 | /* Interpreter specific memory macros */ |
0f4eea8f DL |
886 | #define PerlMem_malloc(size) malloc((size)) |
887 | #define PerlMem_realloc(buf, size) realloc((buf), (size)) | |
888 | #define PerlMem_free(buf) free((buf)) | |
7766f137 GS |
889 | #define PerlMem_calloc(num, size) calloc((num), (size)) |
890 | #define PerlMem_get_lock() | |
891 | #define PerlMem_free_lock() | |
892 | #define PerlMem_is_locked() 0 | |
893 | ||
894 | /* Shared memory macros */ | |
895 | #define PerlMemShared_malloc(size) malloc((size)) | |
896 | #define PerlMemShared_realloc(buf, size) realloc((buf), (size)) | |
897 | #define PerlMemShared_free(buf) free((buf)) | |
898 | #define PerlMemShared_calloc(num, size) calloc((num), (size)) | |
899 | #define PerlMemShared_get_lock() | |
900 | #define PerlMemShared_free_lock() | |
901 | #define PerlMemShared_is_locked() 0 | |
902 | ||
903 | /* Parse tree memory macros */ | |
904 | #define PerlMemParse_malloc(size) malloc((size)) | |
905 | #define PerlMemParse_realloc(buf, size) realloc((buf), (size)) | |
906 | #define PerlMemParse_free(buf) free((buf)) | |
907 | #define PerlMemParse_calloc(num, size) calloc((num), (size)) | |
908 | #define PerlMemParse_get_lock() | |
909 | #define PerlMemParse_free_lock() | |
910 | #define PerlMemParse_is_locked() 0 | |
0f4eea8f | 911 | |
c5be433b | 912 | #endif /* PERL_IMPLICIT_SYS */ |
0f4eea8f DL |
913 | |
914 | /* | |
915 | Interface for perl process functions | |
916 | */ | |
917 | ||
918 | ||
c5be433b | 919 | #if defined(PERL_IMPLICIT_SYS) |
0f4eea8f | 920 | |
0f4eea8f DL |
921 | #ifndef jmp_buf |
922 | #include <setjmp.h> | |
923 | #endif | |
924 | ||
0cb96387 GS |
925 | /* IPerlProc */ |
926 | struct IPerlProc; | |
7766f137 | 927 | struct IPerlProcInfo; |
0cb96387 GS |
928 | typedef void (*LPProcAbort)(struct IPerlProc*); |
929 | typedef char* (*LPProcCrypt)(struct IPerlProc*, const char*, | |
930 | const char*); | |
d951c358 SH |
931 | typedef void (*LPProcExit)(struct IPerlProc*, int) |
932 | __attribute__noreturn__; | |
933 | typedef void (*LPProc_Exit)(struct IPerlProc*, int) | |
934 | __attribute__noreturn__; | |
0cb96387 GS |
935 | typedef int (*LPProcExecl)(struct IPerlProc*, const char*, |
936 | const char*, const char*, const char*, | |
937 | const char*); | |
938 | typedef int (*LPProcExecv)(struct IPerlProc*, const char*, | |
939 | const char*const*); | |
940 | typedef int (*LPProcExecvp)(struct IPerlProc*, const char*, | |
941 | const char*const*); | |
dfff4baf BF |
942 | typedef Uid_t (*LPProcGetuid)(struct IPerlProc*); |
943 | typedef Uid_t (*LPProcGeteuid)(struct IPerlProc*); | |
944 | typedef Gid_t (*LPProcGetgid)(struct IPerlProc*); | |
945 | typedef Gid_t (*LPProcGetegid)(struct IPerlProc*); | |
0cb96387 GS |
946 | typedef char* (*LPProcGetlogin)(struct IPerlProc*); |
947 | typedef int (*LPProcKill)(struct IPerlProc*, int, int); | |
948 | typedef int (*LPProcKillpg)(struct IPerlProc*, int, int); | |
949 | typedef int (*LPProcPauseProc)(struct IPerlProc*); | |
950 | typedef PerlIO* (*LPProcPopen)(struct IPerlProc*, const char*, | |
951 | const char*); | |
8c0134a8 NIS |
952 | typedef PerlIO* (*LPProcPopenList)(struct IPerlProc*, const char*, |
953 | IV narg, SV **args); | |
0cb96387 GS |
954 | typedef int (*LPProcPclose)(struct IPerlProc*, PerlIO*); |
955 | typedef int (*LPProcPipe)(struct IPerlProc*, int*); | |
956 | typedef int (*LPProcSetuid)(struct IPerlProc*, uid_t); | |
957 | typedef int (*LPProcSetgid)(struct IPerlProc*, gid_t); | |
958 | typedef int (*LPProcSleep)(struct IPerlProc*, unsigned int); | |
959 | typedef int (*LPProcTimes)(struct IPerlProc*, struct tms*); | |
960 | typedef int (*LPProcWait)(struct IPerlProc*, int*); | |
961 | typedef int (*LPProcWaitpid)(struct IPerlProc*, int, int*, int); | |
962 | typedef Sighandler_t (*LPProcSignal)(struct IPerlProc*, int, Sighandler_t); | |
7766f137 GS |
963 | typedef int (*LPProcFork)(struct IPerlProc*); |
964 | typedef int (*LPProcGetpid)(struct IPerlProc*); | |
0cb96387 | 965 | #ifdef WIN32 |
7766f137 | 966 | typedef void* (*LPProcDynaLoader)(struct IPerlProc*, const char*); |
0cb96387 GS |
967 | typedef void (*LPProcGetOSError)(struct IPerlProc*, |
968 | SV* sv, DWORD dwErr); | |
0cb96387 GS |
969 | typedef int (*LPProcSpawnvp)(struct IPerlProc*, int, const char*, |
970 | const char*const*); | |
0cb96387 | 971 | #endif |
5f1a76d0 | 972 | typedef int (*LPProcLastHost)(struct IPerlProc*); |
57ab3dfe GS |
973 | typedef int (*LPProcGetTimeOfDay)(struct IPerlProc*, |
974 | struct timeval*, void*); | |
0cb96387 GS |
975 | |
976 | struct IPerlProc | |
0f4eea8f | 977 | { |
0cb96387 GS |
978 | LPProcAbort pAbort; |
979 | LPProcCrypt pCrypt; | |
980 | LPProcExit pExit; | |
981 | LPProc_Exit p_Exit; | |
982 | LPProcExecl pExecl; | |
983 | LPProcExecv pExecv; | |
984 | LPProcExecvp pExecvp; | |
985 | LPProcGetuid pGetuid; | |
986 | LPProcGeteuid pGeteuid; | |
987 | LPProcGetgid pGetgid; | |
988 | LPProcGetegid pGetegid; | |
989 | LPProcGetlogin pGetlogin; | |
990 | LPProcKill pKill; | |
991 | LPProcKillpg pKillpg; | |
992 | LPProcPauseProc pPauseProc; | |
993 | LPProcPopen pPopen; | |
994 | LPProcPclose pPclose; | |
995 | LPProcPipe pPipe; | |
996 | LPProcSetuid pSetuid; | |
997 | LPProcSetgid pSetgid; | |
998 | LPProcSleep pSleep; | |
999 | LPProcTimes pTimes; | |
1000 | LPProcWait pWait; | |
1001 | LPProcWaitpid pWaitpid; | |
1002 | LPProcSignal pSignal; | |
7766f137 GS |
1003 | LPProcFork pFork; |
1004 | LPProcGetpid pGetpid; | |
0f4eea8f | 1005 | #ifdef WIN32 |
0cb96387 GS |
1006 | LPProcDynaLoader pDynaLoader; |
1007 | LPProcGetOSError pGetOSError; | |
0cb96387 | 1008 | LPProcSpawnvp pSpawnvp; |
0f4eea8f | 1009 | #endif |
5f1a76d0 | 1010 | LPProcLastHost pLastHost; |
8c0134a8 | 1011 | LPProcPopenList pPopenList; |
57ab3dfe | 1012 | LPProcGetTimeOfDay pGetTimeOfDay; |
0f4eea8f DL |
1013 | }; |
1014 | ||
0cb96387 GS |
1015 | struct IPerlProcInfo |
1016 | { | |
1017 | unsigned long nCount; /* number of entries expected */ | |
1018 | struct IPerlProc perlProcList; | |
1019 | }; | |
1020 | ||
1021 | #define PerlProc_abort() \ | |
51371543 | 1022 | (*PL_Proc->pAbort)(PL_Proc) |
0cb96387 | 1023 | #define PerlProc_crypt(c,s) \ |
51371543 | 1024 | (*PL_Proc->pCrypt)(PL_Proc, (c), (s)) |
0cb96387 | 1025 | #define PerlProc_exit(s) \ |
51371543 | 1026 | (*PL_Proc->pExit)(PL_Proc, (s)) |
0cb96387 | 1027 | #define PerlProc__exit(s) \ |
51371543 | 1028 | (*PL_Proc->p_Exit)(PL_Proc, (s)) |
0f4eea8f | 1029 | #define PerlProc_execl(c, w, x, y, z) \ |
51371543 | 1030 | (*PL_Proc->pExecl)(PL_Proc, (c), (w), (x), (y), (z)) |
0cb96387 | 1031 | #define PerlProc_execv(c, a) \ |
51371543 | 1032 | (*PL_Proc->pExecv)(PL_Proc, (c), (a)) |
0cb96387 | 1033 | #define PerlProc_execvp(c, a) \ |
51371543 | 1034 | (*PL_Proc->pExecvp)(PL_Proc, (c), (a)) |
0cb96387 | 1035 | #define PerlProc_getuid() \ |
51371543 | 1036 | (*PL_Proc->pGetuid)(PL_Proc) |
0cb96387 | 1037 | #define PerlProc_geteuid() \ |
51371543 | 1038 | (*PL_Proc->pGeteuid)(PL_Proc) |
0cb96387 | 1039 | #define PerlProc_getgid() \ |
51371543 | 1040 | (*PL_Proc->pGetgid)(PL_Proc) |
0cb96387 | 1041 | #define PerlProc_getegid() \ |
51371543 | 1042 | (*PL_Proc->pGetegid)(PL_Proc) |
0cb96387 | 1043 | #define PerlProc_getlogin() \ |
51371543 | 1044 | (*PL_Proc->pGetlogin)(PL_Proc) |
0cb96387 | 1045 | #define PerlProc_kill(i, a) \ |
51371543 | 1046 | (*PL_Proc->pKill)(PL_Proc, (i), (a)) |
0cb96387 | 1047 | #define PerlProc_killpg(i, a) \ |
51371543 | 1048 | (*PL_Proc->pKillpg)(PL_Proc, (i), (a)) |
0cb96387 | 1049 | #define PerlProc_pause() \ |
51371543 | 1050 | (*PL_Proc->pPauseProc)(PL_Proc) |
0cb96387 | 1051 | #define PerlProc_popen(c, m) \ |
51371543 | 1052 | (*PL_Proc->pPopen)(PL_Proc, (c), (m)) |
4a7d1889 NIS |
1053 | #define PerlProc_popen_list(m, n, a) \ |
1054 | (*PL_Proc->pPopenList)(PL_Proc, (m), (n), (a)) | |
0cb96387 | 1055 | #define PerlProc_pclose(f) \ |
51371543 | 1056 | (*PL_Proc->pPclose)(PL_Proc, (f)) |
0cb96387 | 1057 | #define PerlProc_pipe(fd) \ |
51371543 | 1058 | (*PL_Proc->pPipe)(PL_Proc, (fd)) |
0cb96387 | 1059 | #define PerlProc_setuid(u) \ |
51371543 | 1060 | (*PL_Proc->pSetuid)(PL_Proc, (u)) |
0cb96387 | 1061 | #define PerlProc_setgid(g) \ |
51371543 | 1062 | (*PL_Proc->pSetgid)(PL_Proc, (g)) |
0cb96387 | 1063 | #define PerlProc_sleep(t) \ |
51371543 | 1064 | (*PL_Proc->pSleep)(PL_Proc, (t)) |
0cb96387 | 1065 | #define PerlProc_times(t) \ |
51371543 | 1066 | (*PL_Proc->pTimes)(PL_Proc, (t)) |
0cb96387 | 1067 | #define PerlProc_wait(t) \ |
51371543 | 1068 | (*PL_Proc->pWait)(PL_Proc, (t)) |
0cb96387 | 1069 | #define PerlProc_waitpid(p,s,f) \ |
51371543 | 1070 | (*PL_Proc->pWaitpid)(PL_Proc, (p), (s), (f)) |
0cb96387 | 1071 | #define PerlProc_signal(n, h) \ |
51371543 | 1072 | (*PL_Proc->pSignal)(PL_Proc, (n), (h)) |
7766f137 GS |
1073 | #define PerlProc_fork() \ |
1074 | (*PL_Proc->pFork)(PL_Proc) | |
1075 | #define PerlProc_getpid() \ | |
1076 | (*PL_Proc->pGetpid)(PL_Proc) | |
0cb96387 GS |
1077 | #define PerlProc_setjmp(b, n) Sigsetjmp((b), (n)) |
1078 | #define PerlProc_longjmp(b, n) Siglongjmp((b), (n)) | |
0f4eea8f DL |
1079 | |
1080 | #ifdef WIN32 | |
0cb96387 | 1081 | #define PerlProc_DynaLoad(f) \ |
51371543 | 1082 | (*PL_Proc->pDynaLoader)(PL_Proc, (f)) |
0cb96387 | 1083 | #define PerlProc_GetOSError(s,e) \ |
51371543 | 1084 | (*PL_Proc->pGetOSError)(PL_Proc, (s), (e)) |
54725af6 | 1085 | #define PerlProc_spawnvp(m, c, a) \ |
51371543 | 1086 | (*PL_Proc->pSpawnvp)(PL_Proc, (m), (c), (a)) |
0f4eea8f | 1087 | #endif |
5f1a76d0 NIS |
1088 | #define PerlProc_lasthost() \ |
1089 | (*PL_Proc->pLastHost)(PL_Proc) | |
57ab3dfe GS |
1090 | #define PerlProc_gettimeofday(t,z) \ |
1091 | (*PL_Proc->pGetTimeOfDay)(PL_Proc,(t),(z)) | |
0f4eea8f | 1092 | |
c5be433b | 1093 | #else /* PERL_IMPLICIT_SYS */ |
0f4eea8f DL |
1094 | |
1095 | #define PerlProc_abort() abort() | |
ff95b63e | 1096 | #define PerlProc_crypt(c,s) crypt((c), (s)) |
0f4eea8f DL |
1097 | #define PerlProc_exit(s) exit((s)) |
1098 | #define PerlProc__exit(s) _exit((s)) | |
1099 | #define PerlProc_execl(c,w,x,y,z) \ | |
1100 | execl((c), (w), (x), (y), (z)) | |
1101 | #define PerlProc_execv(c, a) execv((c), (a)) | |
1102 | #define PerlProc_execvp(c, a) execvp((c), (a)) | |
1103 | #define PerlProc_getuid() getuid() | |
1104 | #define PerlProc_geteuid() geteuid() | |
1105 | #define PerlProc_getgid() getgid() | |
1106 | #define PerlProc_getegid() getegid() | |
1107 | #define PerlProc_getlogin() getlogin() | |
1108 | #define PerlProc_kill(i, a) kill((i), (a)) | |
1109 | #define PerlProc_killpg(i, a) killpg((i), (a)) | |
1110 | #define PerlProc_pause() Pause() | |
1111 | #define PerlProc_popen(c, m) my_popen((c), (m)) | |
4a7d1889 | 1112 | #define PerlProc_popen_list(m,n,a) my_popen_list((m),(n),(a)) |
0f4eea8f DL |
1113 | #define PerlProc_pclose(f) my_pclose((f)) |
1114 | #define PerlProc_pipe(fd) pipe((fd)) | |
1115 | #define PerlProc_setuid(u) setuid((u)) | |
1116 | #define PerlProc_setgid(g) setgid((g)) | |
1117 | #define PerlProc_sleep(t) sleep((t)) | |
1118 | #define PerlProc_times(t) times((t)) | |
1119 | #define PerlProc_wait(t) wait((t)) | |
1120 | #define PerlProc_waitpid(p,s,f) waitpid((p), (s), (f)) | |
1121 | #define PerlProc_setjmp(b, n) Sigsetjmp((b), (n)) | |
1122 | #define PerlProc_longjmp(b, n) Siglongjmp((b), (n)) | |
1123 | #define PerlProc_signal(n, h) signal((n), (h)) | |
52e18b1f | 1124 | #define PerlProc_fork() my_fork() |
7766f137 | 1125 | #define PerlProc_getpid() getpid() |
57ab3dfe | 1126 | #define PerlProc_gettimeofday(t,z) gettimeofday((t),(z)) |
0f4eea8f | 1127 | |
0cb96387 GS |
1128 | #ifdef WIN32 |
1129 | #define PerlProc_DynaLoad(f) \ | |
c5be433b | 1130 | win32_dynaload((f)) |
0cb96387 | 1131 | #define PerlProc_GetOSError(s,e) \ |
c5be433b | 1132 | win32_str_os_error((s), (e)) |
54725af6 GS |
1133 | #define PerlProc_spawnvp(m, c, a) \ |
1134 | win32_spawnvp((m), (c), (a)) | |
b410b86c MB |
1135 | #undef PerlProc_signal |
1136 | #define PerlProc_signal(n, h) win32_signal((n), (h)) | |
0cb96387 | 1137 | #endif |
c5be433b | 1138 | #endif /* PERL_IMPLICIT_SYS */ |
0f4eea8f DL |
1139 | |
1140 | /* | |
1141 | Interface for perl socket functions | |
1142 | */ | |
1143 | ||
c5be433b | 1144 | #if defined(PERL_IMPLICIT_SYS) |
0f4eea8f | 1145 | |
0cb96387 GS |
1146 | /* PerlSock */ |
1147 | struct IPerlSock; | |
7766f137 | 1148 | struct IPerlSockInfo; |
0cb96387 GS |
1149 | typedef u_long (*LPHtonl)(struct IPerlSock*, u_long); |
1150 | typedef u_short (*LPHtons)(struct IPerlSock*, u_short); | |
1151 | typedef u_long (*LPNtohl)(struct IPerlSock*, u_long); | |
1152 | typedef u_short (*LPNtohs)(struct IPerlSock*, u_short); | |
1153 | typedef SOCKET (*LPAccept)(struct IPerlSock*, SOCKET, | |
1154 | struct sockaddr*, int*); | |
1155 | typedef int (*LPBind)(struct IPerlSock*, SOCKET, | |
1156 | const struct sockaddr*, int); | |
1157 | typedef int (*LPConnect)(struct IPerlSock*, SOCKET, | |
1158 | const struct sockaddr*, int); | |
1159 | typedef void (*LPEndhostent)(struct IPerlSock*); | |
1160 | typedef void (*LPEndnetent)(struct IPerlSock*); | |
1161 | typedef void (*LPEndprotoent)(struct IPerlSock*); | |
1162 | typedef void (*LPEndservent)(struct IPerlSock*); | |
1163 | typedef int (*LPGethostname)(struct IPerlSock*, char*, int); | |
1164 | typedef int (*LPGetpeername)(struct IPerlSock*, SOCKET, | |
1165 | struct sockaddr*, int*); | |
1166 | typedef struct hostent* (*LPGethostbyaddr)(struct IPerlSock*, const char*, | |
1167 | int, int); | |
1168 | typedef struct hostent* (*LPGethostbyname)(struct IPerlSock*, const char*); | |
1169 | typedef struct hostent* (*LPGethostent)(struct IPerlSock*); | |
1170 | typedef struct netent* (*LPGetnetbyaddr)(struct IPerlSock*, long, int); | |
1171 | typedef struct netent* (*LPGetnetbyname)(struct IPerlSock*, const char*); | |
1172 | typedef struct netent* (*LPGetnetent)(struct IPerlSock*); | |
1173 | typedef struct protoent*(*LPGetprotobyname)(struct IPerlSock*, const char*); | |
1174 | typedef struct protoent*(*LPGetprotobynumber)(struct IPerlSock*, int); | |
1175 | typedef struct protoent*(*LPGetprotoent)(struct IPerlSock*); | |
1176 | typedef struct servent* (*LPGetservbyname)(struct IPerlSock*, const char*, | |
1177 | const char*); | |
1178 | typedef struct servent* (*LPGetservbyport)(struct IPerlSock*, int, | |
1179 | const char*); | |
1180 | typedef struct servent* (*LPGetservent)(struct IPerlSock*); | |
1181 | typedef int (*LPGetsockname)(struct IPerlSock*, SOCKET, | |
1182 | struct sockaddr*, int*); | |
1183 | typedef int (*LPGetsockopt)(struct IPerlSock*, SOCKET, int, int, | |
1184 | char*, int*); | |
1185 | typedef unsigned long (*LPInetAddr)(struct IPerlSock*, const char*); | |
1186 | typedef char* (*LPInetNtoa)(struct IPerlSock*, struct in_addr); | |
1187 | typedef int (*LPListen)(struct IPerlSock*, SOCKET, int); | |
1188 | typedef int (*LPRecv)(struct IPerlSock*, SOCKET, char*, int, int); | |
1189 | typedef int (*LPRecvfrom)(struct IPerlSock*, SOCKET, char*, int, | |
1190 | int, struct sockaddr*, int*); | |
1191 | typedef int (*LPSelect)(struct IPerlSock*, int, char*, char*, | |
1192 | char*, const struct timeval*); | |
1193 | typedef int (*LPSend)(struct IPerlSock*, SOCKET, const char*, int, | |
6f9d8c32 | 1194 | int); |
0cb96387 GS |
1195 | typedef int (*LPSendto)(struct IPerlSock*, SOCKET, const char*, |
1196 | int, int, const struct sockaddr*, int); | |
1197 | typedef void (*LPSethostent)(struct IPerlSock*, int); | |
1198 | typedef void (*LPSetnetent)(struct IPerlSock*, int); | |
1199 | typedef void (*LPSetprotoent)(struct IPerlSock*, int); | |
1200 | typedef void (*LPSetservent)(struct IPerlSock*, int); | |
1201 | typedef int (*LPSetsockopt)(struct IPerlSock*, SOCKET, int, int, | |
1202 | const char*, int); | |
1203 | typedef int (*LPShutdown)(struct IPerlSock*, SOCKET, int); | |
1204 | typedef SOCKET (*LPSocket)(struct IPerlSock*, int, int, int); | |
1205 | typedef int (*LPSocketpair)(struct IPerlSock*, int, int, int, | |
1206 | int*); | |
1207 | #ifdef WIN32 | |
1208 | typedef int (*LPClosesocket)(struct IPerlSock*, SOCKET s); | |
1209 | #endif | |
1210 | ||
1211 | struct IPerlSock | |
0f4eea8f | 1212 | { |
0cb96387 GS |
1213 | LPHtonl pHtonl; |
1214 | LPHtons pHtons; | |
1215 | LPNtohl pNtohl; | |
1216 | LPNtohs pNtohs; | |
1217 | LPAccept pAccept; | |
1218 | LPBind pBind; | |
1219 | LPConnect pConnect; | |
1220 | LPEndhostent pEndhostent; | |
1221 | LPEndnetent pEndnetent; | |
1222 | LPEndprotoent pEndprotoent; | |
1223 | LPEndservent pEndservent; | |
1224 | LPGethostname pGethostname; | |
1225 | LPGetpeername pGetpeername; | |
1226 | LPGethostbyaddr pGethostbyaddr; | |
1227 | LPGethostbyname pGethostbyname; | |
1228 | LPGethostent pGethostent; | |
1229 | LPGetnetbyaddr pGetnetbyaddr; | |
1230 | LPGetnetbyname pGetnetbyname; | |
1231 | LPGetnetent pGetnetent; | |
1232 | LPGetprotobyname pGetprotobyname; | |
1233 | LPGetprotobynumber pGetprotobynumber; | |
1234 | LPGetprotoent pGetprotoent; | |
1235 | LPGetservbyname pGetservbyname; | |
1236 | LPGetservbyport pGetservbyport; | |
1237 | LPGetservent pGetservent; | |
1238 | LPGetsockname pGetsockname; | |
1239 | LPGetsockopt pGetsockopt; | |
1240 | LPInetAddr pInetAddr; | |
1241 | LPInetNtoa pInetNtoa; | |
1242 | LPListen pListen; | |
1243 | LPRecv pRecv; | |
1244 | LPRecvfrom pRecvfrom; | |
1245 | LPSelect pSelect; | |
1246 | LPSend pSend; | |
1247 | LPSendto pSendto; | |
1248 | LPSethostent pSethostent; | |
1249 | LPSetnetent pSetnetent; | |
1250 | LPSetprotoent pSetprotoent; | |
1251 | LPSetservent pSetservent; | |
1252 | LPSetsockopt pSetsockopt; | |
1253 | LPShutdown pShutdown; | |
1254 | LPSocket pSocket; | |
1255 | LPSocketpair pSocketpair; | |
0f4eea8f | 1256 | #ifdef WIN32 |
0cb96387 | 1257 | LPClosesocket pClosesocket; |
0f4eea8f DL |
1258 | #endif |
1259 | }; | |
1260 | ||
0cb96387 GS |
1261 | struct IPerlSockInfo |
1262 | { | |
1263 | unsigned long nCount; /* number of entries expected */ | |
1264 | struct IPerlSock perlSockList; | |
1265 | }; | |
1266 | ||
1267 | #define PerlSock_htonl(x) \ | |
51371543 | 1268 | (*PL_Sock->pHtonl)(PL_Sock, x) |
0cb96387 | 1269 | #define PerlSock_htons(x) \ |
51371543 | 1270 | (*PL_Sock->pHtons)(PL_Sock, x) |
0cb96387 | 1271 | #define PerlSock_ntohl(x) \ |
51371543 | 1272 | (*PL_Sock->pNtohl)(PL_Sock, x) |
0cb96387 | 1273 | #define PerlSock_ntohs(x) \ |
51371543 | 1274 | (*PL_Sock->pNtohs)(PL_Sock, x) |
0cb96387 | 1275 | #define PerlSock_accept(s, a, l) \ |
51371543 | 1276 | (*PL_Sock->pAccept)(PL_Sock, s, a, l) |
0cb96387 | 1277 | #define PerlSock_bind(s, n, l) \ |
51371543 | 1278 | (*PL_Sock->pBind)(PL_Sock, s, n, l) |
0cb96387 | 1279 | #define PerlSock_connect(s, n, l) \ |
51371543 | 1280 | (*PL_Sock->pConnect)(PL_Sock, s, n, l) |
0cb96387 | 1281 | #define PerlSock_endhostent() \ |
51371543 | 1282 | (*PL_Sock->pEndhostent)(PL_Sock) |
0cb96387 | 1283 | #define PerlSock_endnetent() \ |
51371543 | 1284 | (*PL_Sock->pEndnetent)(PL_Sock) |
0cb96387 | 1285 | #define PerlSock_endprotoent() \ |
51371543 | 1286 | (*PL_Sock->pEndprotoent)(PL_Sock) |
0cb96387 | 1287 | #define PerlSock_endservent() \ |
51371543 | 1288 | (*PL_Sock->pEndservent)(PL_Sock) |
0cb96387 | 1289 | #define PerlSock_gethostbyaddr(a, l, t) \ |
51371543 | 1290 | (*PL_Sock->pGethostbyaddr)(PL_Sock, a, l, t) |
0cb96387 | 1291 | #define PerlSock_gethostbyname(n) \ |
51371543 | 1292 | (*PL_Sock->pGethostbyname)(PL_Sock, n) |
0cb96387 | 1293 | #define PerlSock_gethostent() \ |
51371543 | 1294 | (*PL_Sock->pGethostent)(PL_Sock) |
0cb96387 | 1295 | #define PerlSock_gethostname(n, l) \ |
51371543 | 1296 | (*PL_Sock->pGethostname)(PL_Sock, n, l) |
0cb96387 | 1297 | #define PerlSock_getnetbyaddr(n, t) \ |
51371543 | 1298 | (*PL_Sock->pGetnetbyaddr)(PL_Sock, n, t) |
0cb96387 | 1299 | #define PerlSock_getnetbyname(c) \ |
51371543 | 1300 | (*PL_Sock->pGetnetbyname)(PL_Sock, c) |
0cb96387 | 1301 | #define PerlSock_getnetent() \ |
51371543 | 1302 | (*PL_Sock->pGetnetent)(PL_Sock) |
0cb96387 | 1303 | #define PerlSock_getpeername(s, n, l) \ |
51371543 | 1304 | (*PL_Sock->pGetpeername)(PL_Sock, s, n, l) |
0cb96387 | 1305 | #define PerlSock_getprotobyname(n) \ |
51371543 | 1306 | (*PL_Sock->pGetprotobyname)(PL_Sock, n) |
0cb96387 | 1307 | #define PerlSock_getprotobynumber(n) \ |
51371543 | 1308 | (*PL_Sock->pGetprotobynumber)(PL_Sock, n) |
0cb96387 | 1309 | #define PerlSock_getprotoent() \ |
51371543 | 1310 | (*PL_Sock->pGetprotoent)(PL_Sock) |
0cb96387 | 1311 | #define PerlSock_getservbyname(n, p) \ |
51371543 | 1312 | (*PL_Sock->pGetservbyname)(PL_Sock, n, p) |
0cb96387 | 1313 | #define PerlSock_getservbyport(port, p) \ |
51371543 | 1314 | (*PL_Sock->pGetservbyport)(PL_Sock, port, p) |
0cb96387 | 1315 | #define PerlSock_getservent() \ |
51371543 | 1316 | (*PL_Sock->pGetservent)(PL_Sock) |
0cb96387 | 1317 | #define PerlSock_getsockname(s, n, l) \ |
51371543 | 1318 | (*PL_Sock->pGetsockname)(PL_Sock, s, n, l) |
0cb96387 | 1319 | #define PerlSock_getsockopt(s,l,n,v,i) \ |
51371543 | 1320 | (*PL_Sock->pGetsockopt)(PL_Sock, s, l, n, v, i) |
0cb96387 | 1321 | #define PerlSock_inet_addr(c) \ |
51371543 | 1322 | (*PL_Sock->pInetAddr)(PL_Sock, c) |
0cb96387 | 1323 | #define PerlSock_inet_ntoa(i) \ |
51371543 | 1324 | (*PL_Sock->pInetNtoa)(PL_Sock, i) |
0cb96387 | 1325 | #define PerlSock_listen(s, b) \ |
51371543 | 1326 | (*PL_Sock->pListen)(PL_Sock, s, b) |
0cb96387 | 1327 | #define PerlSock_recv(s, b, l, f) \ |
51371543 | 1328 | (*PL_Sock->pRecv)(PL_Sock, s, b, l, f) |
0f4eea8f | 1329 | #define PerlSock_recvfrom(s,b,l,f,from,fromlen) \ |
51371543 | 1330 | (*PL_Sock->pRecvfrom)(PL_Sock, s, b, l, f, from, fromlen) |
0f4eea8f | 1331 | #define PerlSock_select(n, r, w, e, t) \ |
51371543 | 1332 | (*PL_Sock->pSelect)(PL_Sock, n, (char*)r, (char*)w, (char*)e, t) |
0cb96387 | 1333 | #define PerlSock_send(s, b, l, f) \ |
51371543 | 1334 | (*PL_Sock->pSend)(PL_Sock, s, b, l, f) |
0f4eea8f | 1335 | #define PerlSock_sendto(s, b, l, f, t, tlen) \ |
51371543 | 1336 | (*PL_Sock->pSendto)(PL_Sock, s, b, l, f, t, tlen) |
0cb96387 | 1337 | #define PerlSock_sethostent(f) \ |
51371543 | 1338 | (*PL_Sock->pSethostent)(PL_Sock, f) |
0cb96387 | 1339 | #define PerlSock_setnetent(f) \ |
51371543 | 1340 | (*PL_Sock->pSetnetent)(PL_Sock, f) |
0cb96387 | 1341 | #define PerlSock_setprotoent(f) \ |
51371543 | 1342 | (*PL_Sock->pSetprotoent)(PL_Sock, f) |
0cb96387 | 1343 | #define PerlSock_setservent(f) \ |
51371543 | 1344 | (*PL_Sock->pSetservent)(PL_Sock, f) |
0f4eea8f | 1345 | #define PerlSock_setsockopt(s, l, n, v, len) \ |
51371543 | 1346 | (*PL_Sock->pSetsockopt)(PL_Sock, s, l, n, v, len) |
0cb96387 | 1347 | #define PerlSock_shutdown(s, h) \ |
51371543 | 1348 | (*PL_Sock->pShutdown)(PL_Sock, s, h) |
0cb96387 | 1349 | #define PerlSock_socket(a, t, p) \ |
51371543 | 1350 | (*PL_Sock->pSocket)(PL_Sock, a, t, p) |
0cb96387 | 1351 | #define PerlSock_socketpair(a, t, p, f) \ |
51371543 | 1352 | (*PL_Sock->pSocketpair)(PL_Sock, a, t, p, f) |
0cb96387 GS |
1353 | |
1354 | #ifdef WIN32 | |
1355 | #define PerlSock_closesocket(s) \ | |
51371543 | 1356 | (*PL_Sock->pClosesocket)(PL_Sock, s) |
0cb96387 | 1357 | #endif |
0f4eea8f | 1358 | |
c5be433b | 1359 | #else /* PERL_IMPLICIT_SYS */ |
0f4eea8f DL |
1360 | |
1361 | #define PerlSock_htonl(x) htonl(x) | |
1362 | #define PerlSock_htons(x) htons(x) | |
1363 | #define PerlSock_ntohl(x) ntohl(x) | |
1364 | #define PerlSock_ntohs(x) ntohs(x) | |
1365 | #define PerlSock_accept(s, a, l) accept(s, a, l) | |
1366 | #define PerlSock_bind(s, n, l) bind(s, n, l) | |
1367 | #define PerlSock_connect(s, n, l) connect(s, n, l) | |
1368 | ||
1369 | #define PerlSock_gethostbyaddr(a, l, t) gethostbyaddr(a, l, t) | |
1370 | #define PerlSock_gethostbyname(n) gethostbyname(n) | |
1371 | #define PerlSock_gethostent gethostent | |
1372 | #define PerlSock_endhostent endhostent | |
1373 | #define PerlSock_gethostname(n, l) gethostname(n, l) | |
1374 | ||
1375 | #define PerlSock_getnetbyaddr(n, t) getnetbyaddr(n, t) | |
1376 | #define PerlSock_getnetbyname(n) getnetbyname(n) | |
1377 | #define PerlSock_getnetent getnetent | |
1378 | #define PerlSock_endnetent endnetent | |
1379 | #define PerlSock_getpeername(s, n, l) getpeername(s, n, l) | |
1380 | ||
1381 | #define PerlSock_getprotobyname(n) getprotobyname(n) | |
1382 | #define PerlSock_getprotobynumber(n) getprotobynumber(n) | |
1383 | #define PerlSock_getprotoent getprotoent | |
1384 | #define PerlSock_endprotoent endprotoent | |
1385 | ||
1386 | #define PerlSock_getservbyname(n, p) getservbyname(n, p) | |
1387 | #define PerlSock_getservbyport(port, p) getservbyport(port, p) | |
1388 | #define PerlSock_getservent getservent | |
1389 | #define PerlSock_endservent endservent | |
1390 | ||
1391 | #define PerlSock_getsockname(s, n, l) getsockname(s, n, l) | |
1392 | #define PerlSock_getsockopt(s,l,n,v,i) getsockopt(s, l, n, v, i) | |
1393 | #define PerlSock_inet_addr(c) inet_addr(c) | |
1394 | #define PerlSock_inet_ntoa(i) inet_ntoa(i) | |
1395 | #define PerlSock_listen(s, b) listen(s, b) | |
c6af7a1a | 1396 | #define PerlSock_recv(s, b, l, f) recv(s, b, l, f) |
0f4eea8f DL |
1397 | #define PerlSock_recvfrom(s, b, l, f, from, fromlen) \ |
1398 | recvfrom(s, b, l, f, from, fromlen) | |
1399 | #define PerlSock_select(n, r, w, e, t) select(n, r, w, e, t) | |
1400 | #define PerlSock_send(s, b, l, f) send(s, b, l, f) | |
1401 | #define PerlSock_sendto(s, b, l, f, t, tlen) \ | |
1402 | sendto(s, b, l, f, t, tlen) | |
1403 | #define PerlSock_sethostent(f) sethostent(f) | |
1404 | #define PerlSock_setnetent(f) setnetent(f) | |
1405 | #define PerlSock_setprotoent(f) setprotoent(f) | |
1406 | #define PerlSock_setservent(f) setservent(f) | |
1407 | #define PerlSock_setsockopt(s, l, n, v, len) \ | |
1408 | setsockopt(s, l, n, v, len) | |
1409 | #define PerlSock_shutdown(s, h) shutdown(s, h) | |
1410 | #define PerlSock_socket(a, t, p) socket(a, t, p) | |
1411 | #define PerlSock_socketpair(a, t, p, f) socketpair(a, t, p, f) | |
1412 | ||
0cb96387 GS |
1413 | #ifdef WIN32 |
1414 | #define PerlSock_closesocket(s) closesocket(s) | |
1415 | #endif | |
0f4eea8f | 1416 | |
c5be433b | 1417 | #endif /* PERL_IMPLICIT_SYS */ |
0f4eea8f DL |
1418 | |
1419 | #endif /* __Inc__IPerl___ */ | |
1420 | ||
e9a8c099 | 1421 | /* |
14d04a33 | 1422 | * ex: set ts=8 sts=4 sw=4 et: |
e9a8c099 | 1423 | */ |