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