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