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