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