Assume SOCKS is broken in all 64bitall platforms, not just Solaris.
[p5sagit/p5-mst-13.2.git] / iperlsys.h
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
52 /*
53     Interface for perl stdio functions, or whatever we are Configure-d
54     to use.
55 */
56 #include "perlio.h"
57
58 #ifndef Sighandler_t
59 typedef Signal_t (*Sighandler_t) (int);
60 #endif
61
62 #if defined(PERL_IMPLICIT_SYS)
63
64 /* IPerlStdIO           */
65 struct IPerlStdIO;
66 struct IPerlStdIOInfo;
67 typedef PerlIO*         (*LPStdin)(struct IPerlStdIO*);
68 typedef PerlIO*         (*LPStdout)(struct IPerlStdIO*);
69 typedef PerlIO*         (*LPStderr)(struct IPerlStdIO*);
70 typedef PerlIO*         (*LPOpen)(struct IPerlStdIO*, const char*,
71                             const char*);
72 typedef int             (*LPClose)(struct IPerlStdIO*, PerlIO*);
73 typedef int             (*LPEof)(struct IPerlStdIO*, PerlIO*);
74 typedef int             (*LPError)(struct IPerlStdIO*, PerlIO*);
75 typedef void            (*LPClearerr)(struct IPerlStdIO*, PerlIO*);
76 typedef int             (*LPGetc)(struct IPerlStdIO*, PerlIO*);
77 typedef char*           (*LPGetBase)(struct IPerlStdIO*, PerlIO*);
78 typedef int             (*LPGetBufsiz)(struct IPerlStdIO*, PerlIO*);
79 typedef int             (*LPGetCnt)(struct IPerlStdIO*, PerlIO*);
80 typedef char*           (*LPGetPtr)(struct IPerlStdIO*, PerlIO*);
81 typedef char*           (*LPGets)(struct IPerlStdIO*, PerlIO*, char*, int);
82 typedef int             (*LPPutc)(struct IPerlStdIO*, PerlIO*, int);
83 typedef int             (*LPPuts)(struct IPerlStdIO*, PerlIO*, const char*);
84 typedef int             (*LPFlush)(struct IPerlStdIO*, PerlIO*);
85 typedef int             (*LPUngetc)(struct IPerlStdIO*, PerlIO*,int);
86 typedef int             (*LPFileno)(struct IPerlStdIO*, PerlIO*);
87 typedef PerlIO*         (*LPFdopen)(struct IPerlStdIO*, int, const char*);
88 typedef PerlIO*         (*LPReopen)(struct IPerlStdIO*, const char*,
89                             const char*, PerlIO*);
90 typedef SSize_t         (*LPRead)(struct IPerlStdIO*, PerlIO*, void*, Size_t);
91 typedef SSize_t         (*LPWrite)(struct IPerlStdIO*, PerlIO*, const void*,
92                             Size_t);
93 typedef void            (*LPSetBuf)(struct IPerlStdIO*, PerlIO*, char*);
94 typedef int             (*LPSetVBuf)(struct IPerlStdIO*, PerlIO*, char*, int,
95                             Size_t);
96 typedef void            (*LPSetCnt)(struct IPerlStdIO*, PerlIO*, int);
97 typedef void            (*LPSetPtrCnt)(struct IPerlStdIO*, PerlIO*, char*,
98                             int);
99 typedef void            (*LPSetlinebuf)(struct IPerlStdIO*, PerlIO*);
100 typedef int             (*LPPrintf)(struct IPerlStdIO*, PerlIO*, const char*,
101                             ...);
102 typedef int             (*LPVprintf)(struct IPerlStdIO*, PerlIO*, const char*,
103                             va_list);
104 typedef long            (*LPTell)(struct IPerlStdIO*, PerlIO*);
105 typedef int             (*LPSeek)(struct IPerlStdIO*, PerlIO*, Off_t, int);
106 typedef void            (*LPRewind)(struct IPerlStdIO*, PerlIO*);
107 typedef PerlIO*         (*LPTmpfile)(struct IPerlStdIO*);
108 typedef int             (*LPGetpos)(struct IPerlStdIO*, PerlIO*, Fpos_t*);
109 typedef int             (*LPSetpos)(struct IPerlStdIO*, PerlIO*,
110                             const Fpos_t*);
111 typedef void            (*LPInit)(struct IPerlStdIO*);
112 typedef void            (*LPInitOSExtras)(struct IPerlStdIO*);
113 typedef PerlIO*         (*LPFdupopen)(struct IPerlStdIO*, PerlIO*);
114 typedef int             (*LPIsUtf8)(struct IPerlStdIO*, PerlIO*);
115
116 struct IPerlStdIO
117 {
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;
156     LPFdupopen          pFdupopen;
157     LPIsUtf8            pIsUtf8;
158 };
159
160 struct IPerlStdIOInfo
161 {
162     unsigned long       nCount;     /* number of entries expected */
163     struct IPerlStdIO   perlStdIOList;
164 };
165
166 /* These do not belong here ... NI-S, 14 Nov 2000 */
167
168 #ifdef USE_STDIO_PTR
169 #  define PerlIO_has_cntptr(f)          1
170 #  ifdef STDIO_PTR_LVALUE
171 #    ifdef  STDIO_CNT_LVALUE
172 #      define PerlIO_canset_cnt(f)      1
173 #      ifdef STDIO_PTR_LVAL_NOCHANGE_CNT
174 #        define PerlIO_fast_gets(f)     1
175 #      endif
176 #    else /* STDIO_CNT_LVALUE */
177 #      define PerlIO_canset_cnt(f)      0
178 #    endif
179 #  else /* STDIO_PTR_LVALUE */
180 #    ifdef STDIO_PTR_LVAL_SETS_CNT
181 #      define PerlIO_fast_gets(f)       1
182 #    endif
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
190 #define PerlIO_fast_gets(f)             0
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
198
199 /* Now take PerlIO * via function table */
200
201 #define PerlIO_stdin()                                                  \
202         (*PL_StdIO->pStdin)(PL_StdIO)
203 #define PerlIO_stdout()                                                 \
204         (*PL_StdIO->pStdout)(PL_StdIO)
205 #define PerlIO_stderr()                                                 \
206         (*PL_StdIO->pStderr)(PL_StdIO)
207 #define PerlIO_open(x,y)                                                \
208         (*PL_StdIO->pOpen)(PL_StdIO, (x),(y))
209 #define PerlIO_close(f)                                                 \
210         (*PL_StdIO->pClose)(PL_StdIO, (f))
211 #define PerlIO_eof(f)                                                   \
212         (*PL_StdIO->pEof)(PL_StdIO, (f))
213 #define PerlIO_error(f)                                                 \
214         (*PL_StdIO->pError)(PL_StdIO, (f))
215 #define PerlIO_clearerr(f)                                              \
216         (*PL_StdIO->pClearerr)(PL_StdIO, (f))
217 #define PerlIO_getc(f)                                                  \
218         (*PL_StdIO->pGetc)(PL_StdIO, (f))
219 #define PerlIO_get_base(f)                                              \
220         (*PL_StdIO->pGetBase)(PL_StdIO, (f))
221 #define PerlIO_get_bufsiz(f)                                            \
222         (*PL_StdIO->pGetBufsiz)(PL_StdIO, (f))
223 #define PerlIO_get_cnt(f)                                               \
224         (*PL_StdIO->pGetCnt)(PL_StdIO, (f))
225 #define PerlIO_get_ptr(f)                                               \
226         (*PL_StdIO->pGetPtr)(PL_StdIO, (f))
227 #define PerlIO_putc(f,c)                                                \
228         (*PL_StdIO->pPutc)(PL_StdIO, (f),(c))
229 #define PerlIO_puts(f,s)                                                \
230         (*PL_StdIO->pPuts)(PL_StdIO, (f),(s))
231 #define PerlIO_flush(f)                                                 \
232         (*PL_StdIO->pFlush)(PL_StdIO, (f))
233 #define PerlIO_gets(s, n, fp)                                           \
234         (*PL_StdIO->pGets)(PL_StdIO, (fp), s, n)
235 #define PerlIO_ungetc(f,c)                                              \
236         (*PL_StdIO->pUngetc)(PL_StdIO, (f),(c))
237 #define PerlIO_fileno(f)                                                \
238         (*PL_StdIO->pFileno)(PL_StdIO, (f))
239 #define PerlIO_fdopen(f, s)                                             \
240         (*PL_StdIO->pFdopen)(PL_StdIO, (f),(s))
241 #define PerlIO_reopen(p, m, f)                                          \
242         (*PL_StdIO->pReopen)(PL_StdIO, (p), (m), (f))
243 #define PerlIO_read(f,buf,count)                                        \
244         (SSize_t)(*PL_StdIO->pRead)(PL_StdIO, (f), (buf), (count))
245 #define PerlIO_write(f,buf,count)                                       \
246         (*PL_StdIO->pWrite)(PL_StdIO, (f), (buf), (count))
247 #define PerlIO_setbuf(f,b)                                              \
248         (*PL_StdIO->pSetBuf)(PL_StdIO, (f), (b))
249 #define PerlIO_setvbuf(f,b,t,s)                                         \
250         (*PL_StdIO->pSetVBuf)(PL_StdIO, (f),(b),(t),(s))
251 #define PerlIO_set_cnt(f,c)                                             \
252         (*PL_StdIO->pSetCnt)(PL_StdIO, (f), (c))
253 #define PerlIO_set_ptrcnt(f,p,c)                                        \
254         (*PL_StdIO->pSetPtrCnt)(PL_StdIO, (f), (p), (c))
255 #define PerlIO_setlinebuf(f)                                            \
256         (*PL_StdIO->pSetlinebuf)(PL_StdIO, (f))
257 #define PerlIO_printf           Perl_fprintf_nocontext
258 #define PerlIO_stdoutf          *PL_StdIO->pPrintf
259 #define PerlIO_vprintf(f,fmt,a)                                         \
260         (*PL_StdIO->pVprintf)(PL_StdIO, (f),(fmt),a)
261 #define PerlIO_tell(f)                                                  \
262         (*PL_StdIO->pTell)(PL_StdIO, (f))
263 #define PerlIO_seek(f,o,w)                                              \
264         (*PL_StdIO->pSeek)(PL_StdIO, (f),(o),(w))
265 #define PerlIO_getpos(f,p)                                              \
266         (*PL_StdIO->pGetpos)(PL_StdIO, (f),(p))
267 #define PerlIO_setpos(f,p)                                              \
268         (*PL_StdIO->pSetpos)(PL_StdIO, (f),(p))
269 #define PerlIO_rewind(f)                                                \
270         (*PL_StdIO->pRewind)(PL_StdIO, (f))
271 #define PerlIO_tmpfile()                                                \
272         (*PL_StdIO->pTmpfile)(PL_StdIO)
273 #define PerlIO_init()                                                   \
274         (*PL_StdIO->pInit)(PL_StdIO)
275 #undef  init_os_extras
276 #define init_os_extras()                                                \
277         (*PL_StdIO->pInitOSExtras)(PL_StdIO)
278 #define PerlIO_fdupopen(f)                                              \
279         (*PL_StdIO->pFdupopen)(PL_StdIO, (f))
280 #define PerlIO_isutf8(f)                                                \
281         (*PL_StdIO->pIsUtf8)(PL_StdIO, (f))
282
283 #endif  /* PERL_IMPLICIT_SYS */
284
285 /*
286  *   Interface for directory functions
287  */
288
289 #if defined(PERL_IMPLICIT_SYS)
290
291 /* IPerlDir             */
292 struct IPerlDir;
293 struct IPerlDirInfo;
294 typedef int             (*LPMakedir)(struct IPerlDir*, const char*, int);
295 typedef int             (*LPChdir)(struct IPerlDir*, const char*);
296 typedef int             (*LPRmdir)(struct IPerlDir*, const char*);
297 typedef int             (*LPDirClose)(struct IPerlDir*, DIR*);
298 typedef DIR*            (*LPDirOpen)(struct IPerlDir*, char*);
299 typedef struct direct*  (*LPDirRead)(struct IPerlDir*, DIR*);
300 typedef void            (*LPDirRewind)(struct IPerlDir*, DIR*);
301 typedef void            (*LPDirSeek)(struct IPerlDir*, DIR*, long);
302 typedef long            (*LPDirTell)(struct IPerlDir*, DIR*);
303 #ifdef WIN32
304 typedef char*           (*LPDirMapPathA)(struct IPerlDir*, const char*);
305 typedef WCHAR*          (*LPDirMapPathW)(struct IPerlDir*, const WCHAR*);
306 #endif
307
308 struct IPerlDir
309 {
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;
319 #ifdef WIN32
320     LPDirMapPathA       pMapPathA;
321     LPDirMapPathW       pMapPathW;
322 #endif
323 };
324
325 struct IPerlDirInfo
326 {
327     unsigned long       nCount;     /* number of entries expected */
328     struct IPerlDir     perlDirList;
329 };
330
331 #define PerlDir_mkdir(name, mode)                               \
332         (*PL_Dir->pMakedir)(PL_Dir, (name), (mode))
333 #define PerlDir_chdir(name)                                     \
334         (*PL_Dir->pChdir)(PL_Dir, (name))
335 #define PerlDir_rmdir(name)                                     \
336         (*PL_Dir->pRmdir)(PL_Dir, (name))
337 #define PerlDir_close(dir)                                      \
338         (*PL_Dir->pClose)(PL_Dir, (dir))
339 #define PerlDir_open(name)                                      \
340         (*PL_Dir->pOpen)(PL_Dir, (name))
341 #define PerlDir_read(dir)                                       \
342         (*PL_Dir->pRead)(PL_Dir, (dir))
343 #define PerlDir_rewind(dir)                                     \
344         (*PL_Dir->pRewind)(PL_Dir, (dir))
345 #define PerlDir_seek(dir, loc)                                  \
346         (*PL_Dir->pSeek)(PL_Dir, (dir), (loc))
347 #define PerlDir_tell(dir)                                       \
348         (*PL_Dir->pTell)(PL_Dir, (dir))
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
355
356 #else   /* PERL_IMPLICIT_SYS */
357
358 #define PerlDir_mkdir(name, mode)       Mkdir((name), (mode))
359 #ifdef VMS
360 #  define PerlDir_chdir(n)              Chdir(((n) && *(n)) ? (n) : "SYS$LOGIN")
361 #else
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))
371 #ifdef WIN32
372 #define PerlDir_mapA(dir)               dir
373 #define PerlDir_mapW(dir)               dir
374 #endif
375
376 #endif  /* PERL_IMPLICIT_SYS */
377
378 /*
379     Interface for perl environment functions
380 */
381
382 #if defined(PERL_IMPLICIT_SYS)
383
384 /* IPerlEnv             */
385 struct IPerlEnv;
386 struct IPerlEnvInfo;
387 typedef char*           (*LPEnvGetenv)(struct IPerlEnv*, const char*);
388 typedef int             (*LPEnvPutenv)(struct IPerlEnv*, const char*);
389 typedef char*           (*LPEnvGetenv_len)(struct IPerlEnv*,
390                                     const char *varname, unsigned long *len);
391 typedef int             (*LPEnvUname)(struct IPerlEnv*, struct utsname *name);
392 typedef void            (*LPEnvClearenv)(struct IPerlEnv*);
393 typedef void*           (*LPEnvGetChildenv)(struct IPerlEnv*);
394 typedef void            (*LPEnvFreeChildenv)(struct IPerlEnv*, void* env);
395 typedef char*           (*LPEnvGetChilddir)(struct IPerlEnv*);
396 typedef void            (*LPEnvFreeChilddir)(struct IPerlEnv*, char* dir);
397 #ifdef HAS_ENVGETENV
398 typedef char*           (*LPENVGetenv)(struct IPerlEnv*, const char *varname);
399 typedef char*           (*LPENVGetenv_len)(struct IPerlEnv*,
400                                     const char *varname, unsigned long *len);
401 #endif
402 #ifdef WIN32
403 typedef unsigned long   (*LPEnvOsID)(struct IPerlEnv*);
404 typedef char*           (*LPEnvLibPath)(struct IPerlEnv*, const char*);
405 typedef char*           (*LPEnvSiteLibPath)(struct IPerlEnv*, const char*);
406 typedef char*           (*LPEnvVendorLibPath)(struct IPerlEnv*, const char*);
407 typedef void            (*LPEnvGetChildIO)(struct IPerlEnv*, child_IO_table*);
408 #endif
409
410 struct IPerlEnv
411 {
412     LPEnvGetenv         pGetenv;
413     LPEnvPutenv         pPutenv;
414     LPEnvGetenv_len     pGetenv_len;
415     LPEnvUname          pEnvUname;
416     LPEnvClearenv       pClearenv;
417     LPEnvGetChildenv    pGetChildenv;
418     LPEnvFreeChildenv   pFreeChildenv;
419     LPEnvGetChilddir    pGetChilddir;
420     LPEnvFreeChilddir   pFreeChilddir;
421 #ifdef HAS_ENVGETENV
422     LPENVGetenv         pENVGetenv;
423     LPENVGetenv_len     pENVGetenv_len;
424 #endif
425 #ifdef WIN32
426     LPEnvOsID           pEnvOsID;
427     LPEnvLibPath        pLibPath;
428     LPEnvSiteLibPath    pSiteLibPath;
429     LPEnvVendorLibPath  pVendorLibPath;
430     LPEnvGetChildIO     pGetChildIO;
431 #endif
432 };
433
434 struct IPerlEnvInfo
435 {
436     unsigned long       nCount;     /* number of entries expected */
437     struct IPerlEnv     perlEnvList;
438 };
439
440 #define PerlEnv_putenv(str)                                     \
441         (*PL_Env->pPutenv)(PL_Env,(str))
442 #define PerlEnv_getenv(str)                                     \
443         (*PL_Env->pGetenv)(PL_Env,(str))
444 #define PerlEnv_getenv_len(str,l)                               \
445         (*PL_Env->pGetenv_len)(PL_Env,(str), (l))
446 #define PerlEnv_clearenv()                                      \
447         (*PL_Env->pClearenv)(PL_Env)
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))
456 #ifdef HAS_ENVGETENV
457 #  define PerlEnv_ENVgetenv(str)                                \
458         (*PL_Env->pENVGetenv)(PL_Env,(str))
459 #  define PerlEnv_ENVgetenv_len(str,l)                          \
460         (*PL_Env->pENVGetenv_len)(PL_Env,(str), (l))
461 #else
462 #  define PerlEnv_ENVgetenv(str)                                \
463         PerlEnv_getenv((str))
464 #  define PerlEnv_ENVgetenv_len(str,l)                          \
465         PerlEnv_getenv_len((str),(l))
466 #endif
467 #define PerlEnv_uname(name)                                     \
468         (*PL_Env->pEnvUname)(PL_Env,(name))
469 #ifdef WIN32
470 #define PerlEnv_os_id()                                         \
471         (*PL_Env->pEnvOsID)(PL_Env)
472 #define PerlEnv_lib_path(str)                                   \
473         (*PL_Env->pLibPath)(PL_Env,(str))
474 #define PerlEnv_sitelib_path(str)                               \
475         (*PL_Env->pSiteLibPath)(PL_Env,(str))
476 #define PerlEnv_vendorlib_path(str)                             \
477         (*PL_Env->pVendorLibPath)(PL_Env,(str))
478 #define PerlEnv_get_child_IO(ptr)                               \
479         (*PL_Env->pGetChildIO)(PL_Env, ptr)
480 #endif
481
482 #else   /* PERL_IMPLICIT_SYS */
483
484 #define PerlEnv_putenv(str)             putenv((str))
485 #define PerlEnv_getenv(str)             getenv((str))
486 #define PerlEnv_getenv_len(str,l)       getenv_len((str), (l))
487 #define PerlEnv_clearenv()              clearenv()
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))
492 #ifdef HAS_ENVGETENV
493 #  define PerlEnv_ENVgetenv(str)        ENVgetenv((str))
494 #  define PerlEnv_ENVgetenv_len(str,l)  ENVgetenv_len((str), (l))
495 #else
496 #  define PerlEnv_ENVgetenv(str)        PerlEnv_getenv((str))
497 #  define PerlEnv_ENVgetenv_len(str,l)  PerlEnv_getenv_len((str), (l))
498 #endif
499 #define PerlEnv_uname(name)             uname((name))
500
501 #ifdef WIN32
502 #define PerlEnv_os_id()                 win32_os_id()
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)
506 #define PerlEnv_get_child_IO(ptr)       win32_get_child_IO(ptr)
507 #endif
508
509 #endif  /* PERL_IMPLICIT_SYS */
510
511 /*
512     Interface for perl low-level IO functions
513 */
514
515 #if defined(PERL_IMPLICIT_SYS)
516
517 /* IPerlLIO             */
518 struct IPerlLIO;
519 struct IPerlLIOInfo;
520 typedef int             (*LPLIOAccess)(struct IPerlLIO*, const char*, int);
521 typedef int             (*LPLIOChmod)(struct IPerlLIO*, const char*, int);
522 typedef int             (*LPLIOChown)(struct IPerlLIO*, const char*, uid_t,
523                             gid_t);
524 typedef int             (*LPLIOChsize)(struct IPerlLIO*, int, long);
525 typedef int             (*LPLIOClose)(struct IPerlLIO*, int);
526 typedef int             (*LPLIODup)(struct IPerlLIO*, int);
527 typedef int             (*LPLIODup2)(struct IPerlLIO*, int, int);
528 typedef int             (*LPLIOFlock)(struct IPerlLIO*, int, int);
529 typedef int             (*LPLIOFileStat)(struct IPerlLIO*, int, struct stat*);
530 typedef int             (*LPLIOIOCtl)(struct IPerlLIO*, int, unsigned int,
531                             char*);
532 typedef int             (*LPLIOIsatty)(struct IPerlLIO*, int);
533 typedef int             (*LPLIOLink)(struct IPerlLIO*, const char*,
534                                      const char *);
535 typedef long            (*LPLIOLseek)(struct IPerlLIO*, int, long, int);
536 typedef int             (*LPLIOLstat)(struct IPerlLIO*, const char*,
537                             struct stat*);
538 typedef char*           (*LPLIOMktemp)(struct IPerlLIO*, char*);
539 typedef int             (*LPLIOOpen)(struct IPerlLIO*, const char*, int);       
540 typedef int             (*LPLIOOpen3)(struct IPerlLIO*, const char*, int, int); 
541 typedef int             (*LPLIORead)(struct IPerlLIO*, int, void*, unsigned int);
542 typedef int             (*LPLIORename)(struct IPerlLIO*, const char*,
543                             const char*);
544 typedef int             (*LPLIOSetmode)(struct IPerlLIO*, int, int);
545 typedef int             (*LPLIONameStat)(struct IPerlLIO*, const char*,
546                             struct stat*);
547 typedef char*           (*LPLIOTmpnam)(struct IPerlLIO*, char*);
548 typedef int             (*LPLIOUmask)(struct IPerlLIO*, int);
549 typedef int             (*LPLIOUnlink)(struct IPerlLIO*, const char*);
550 typedef int             (*LPLIOUtime)(struct IPerlLIO*, char*, struct utimbuf*);
551 typedef int             (*LPLIOWrite)(struct IPerlLIO*, int, const void*,
552                             unsigned int);
553
554 struct 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;
567     LPLIOLink           pLink;
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
584 struct IPerlLIOInfo
585 {
586     unsigned long       nCount;     /* number of entries expected */
587     struct IPerlLIO     perlLIOList;
588 };
589
590 #define PerlLIO_access(file, mode)                                      \
591         (*PL_LIO->pAccess)(PL_LIO, (file), (mode))
592 #define PerlLIO_chmod(file, mode)                                       \
593         (*PL_LIO->pChmod)(PL_LIO, (file), (mode))
594 #define PerlLIO_chown(file, owner, group)                               \
595         (*PL_LIO->pChown)(PL_LIO, (file), (owner), (group))
596 #define PerlLIO_chsize(fd, size)                                        \
597         (*PL_LIO->pChsize)(PL_LIO, (fd), (size))
598 #define PerlLIO_close(fd)                                               \
599         (*PL_LIO->pClose)(PL_LIO, (fd))
600 #define PerlLIO_dup(fd)                                                 \
601         (*PL_LIO->pDup)(PL_LIO, (fd))
602 #define PerlLIO_dup2(fd1, fd2)                                          \
603         (*PL_LIO->pDup2)(PL_LIO, (fd1), (fd2))
604 #define PerlLIO_flock(fd, op)                                           \
605         (*PL_LIO->pFlock)(PL_LIO, (fd), (op))
606 #define PerlLIO_fstat(fd, buf)                                          \
607         (*PL_LIO->pFileStat)(PL_LIO, (fd), (buf))
608 #define PerlLIO_ioctl(fd, u, buf)                                       \
609         (*PL_LIO->pIOCtl)(PL_LIO, (fd), (u), (buf))
610 #define PerlLIO_isatty(fd)                                              \
611         (*PL_LIO->pIsatty)(PL_LIO, (fd))
612 #define PerlLIO_link(oldname, newname)                                  \
613         (*PL_LIO->pLink)(PL_LIO, (oldname), (newname))
614 #define PerlLIO_lseek(fd, offset, mode)                                 \
615         (*PL_LIO->pLseek)(PL_LIO, (fd), (offset), (mode))
616 #define PerlLIO_lstat(name, buf)                                        \
617         (*PL_LIO->pLstat)(PL_LIO, (name), (buf))
618 #define PerlLIO_mktemp(file)                                            \
619         (*PL_LIO->pMktemp)(PL_LIO, (file))
620 #define PerlLIO_open(file, flag)                                        \
621         (*PL_LIO->pOpen)(PL_LIO, (file), (flag))
622 #define PerlLIO_open3(file, flag, perm)                                 \
623         (*PL_LIO->pOpen3)(PL_LIO, (file), (flag), (perm))
624 #define PerlLIO_read(fd, buf, count)                                    \
625         (*PL_LIO->pRead)(PL_LIO, (fd), (buf), (count))
626 #define PerlLIO_rename(oname, newname)                                  \
627         (*PL_LIO->pRename)(PL_LIO, (oname), (newname))
628 #define PerlLIO_setmode(fd, mode)                                       \
629         (*PL_LIO->pSetmode)(PL_LIO, (fd), (mode))
630 #define PerlLIO_stat(name, buf)                                         \
631         (*PL_LIO->pNameStat)(PL_LIO, (name), (buf))
632 #define PerlLIO_tmpnam(str)                                             \
633         (*PL_LIO->pTmpnam)(PL_LIO, (str))
634 #define PerlLIO_umask(mode)                                             \
635         (*PL_LIO->pUmask)(PL_LIO, (mode))
636 #define PerlLIO_unlink(file)                                            \
637         (*PL_LIO->pUnlink)(PL_LIO, (file))
638 #define PerlLIO_utime(file, time)                                       \
639         (*PL_LIO->pUtime)(PL_LIO, (file), (time))
640 #define PerlLIO_write(fd, buf, count)                                   \
641         (*PL_LIO->pWrite)(PL_LIO, (fd), (buf), (count))
642
643 #else   /* PERL_IMPLICIT_SYS */
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))
656 #define PerlLIO_link(oldname, newname)  link((oldname), (newname))
657 #define PerlLIO_lseek(fd, offset, mode) lseek((fd), (offset), (mode))
658 #define PerlLIO_stat(name, buf)         Stat((name), (buf))
659 #ifdef HAS_LSTAT
660 #  define PerlLIO_lstat(name, buf)      lstat((name), (buf))
661 #else
662 #  define PerlLIO_lstat(name, buf)      PerlLIO_stat((name), (buf))
663 #endif
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))
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
677 #endif  /* PERL_IMPLICIT_SYS */
678
679 /*
680     Interface for perl memory allocation
681 */
682
683 #if defined(PERL_IMPLICIT_SYS)
684
685 /* IPerlMem             */
686 struct IPerlMem;
687 struct IPerlMemInfo;
688 typedef void*           (*LPMemMalloc)(struct IPerlMem*, size_t);
689 typedef void*           (*LPMemRealloc)(struct IPerlMem*, void*, size_t);
690 typedef void            (*LPMemFree)(struct IPerlMem*, void*);
691 typedef void*           (*LPMemCalloc)(struct IPerlMem*, size_t, size_t);
692 typedef void            (*LPMemGetLock)(struct IPerlMem*);
693 typedef void            (*LPMemFreeLock)(struct IPerlMem*);
694 typedef int             (*LPMemIsLocked)(struct IPerlMem*);
695
696 struct IPerlMem
697 {
698     LPMemMalloc         pMalloc;
699     LPMemRealloc        pRealloc;
700     LPMemFree           pFree;
701     LPMemCalloc         pCalloc;
702     LPMemGetLock        pGetLock;
703     LPMemFreeLock       pFreeLock;
704     LPMemIsLocked       pIsLocked;
705 };
706
707 struct IPerlMemInfo
708 {
709     unsigned long       nCount;     /* number of entries expected */
710     struct IPerlMem     perlMemList;
711 };
712
713 /* Interpreter specific memory macros */
714 #define PerlMem_malloc(size)                                \
715         (*PL_Mem->pMalloc)(PL_Mem, (size))
716 #define PerlMem_realloc(buf, size)                          \
717         (*PL_Mem->pRealloc)(PL_Mem, (buf), (size))
718 #define PerlMem_free(buf)                                   \
719         (*PL_Mem->pFree)(PL_Mem, (buf))
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
762
763 #else   /* PERL_IMPLICIT_SYS */
764
765 /* Interpreter specific memory macros */
766 #define PerlMem_malloc(size)            malloc((size))
767 #define PerlMem_realloc(buf, size)      realloc((buf), (size))
768 #define PerlMem_free(buf)               free((buf))
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
791
792 #endif  /* PERL_IMPLICIT_SYS */
793
794 /*
795     Interface for perl process functions
796 */
797
798
799 #if defined(PERL_IMPLICIT_SYS)
800
801 #ifndef jmp_buf
802 #include <setjmp.h>
803 #endif
804
805 /* IPerlProc            */
806 struct IPerlProc;
807 struct IPerlProcInfo;
808 typedef void            (*LPProcAbort)(struct IPerlProc*);
809 typedef char*           (*LPProcCrypt)(struct IPerlProc*, const char*,
810                             const char*);
811 typedef void            (*LPProcExit)(struct IPerlProc*, int);
812 typedef void            (*LPProc_Exit)(struct IPerlProc*, int);
813 typedef int             (*LPProcExecl)(struct IPerlProc*, const char*,
814                             const char*, const char*, const char*,
815                             const char*);
816 typedef int             (*LPProcExecv)(struct IPerlProc*, const char*,
817                             const char*const*);
818 typedef int             (*LPProcExecvp)(struct IPerlProc*, const char*,
819                             const char*const*);
820 typedef uid_t           (*LPProcGetuid)(struct IPerlProc*);
821 typedef uid_t           (*LPProcGeteuid)(struct IPerlProc*);
822 typedef gid_t           (*LPProcGetgid)(struct IPerlProc*);
823 typedef gid_t           (*LPProcGetegid)(struct IPerlProc*);
824 typedef char*           (*LPProcGetlogin)(struct IPerlProc*);
825 typedef int             (*LPProcKill)(struct IPerlProc*, int, int);
826 typedef int             (*LPProcKillpg)(struct IPerlProc*, int, int);
827 typedef int             (*LPProcPauseProc)(struct IPerlProc*);
828 typedef PerlIO*         (*LPProcPopen)(struct IPerlProc*, const char*,
829                             const char*);
830 typedef int             (*LPProcPclose)(struct IPerlProc*, PerlIO*);
831 typedef int             (*LPProcPipe)(struct IPerlProc*, int*);
832 typedef int             (*LPProcSetuid)(struct IPerlProc*, uid_t);
833 typedef int             (*LPProcSetgid)(struct IPerlProc*, gid_t);
834 typedef int             (*LPProcSleep)(struct IPerlProc*, unsigned int);
835 typedef int             (*LPProcTimes)(struct IPerlProc*, struct tms*);
836 typedef int             (*LPProcWait)(struct IPerlProc*, int*);
837 typedef int             (*LPProcWaitpid)(struct IPerlProc*, int, int*, int);
838 typedef Sighandler_t    (*LPProcSignal)(struct IPerlProc*, int, Sighandler_t);
839 typedef int             (*LPProcFork)(struct IPerlProc*);
840 typedef int             (*LPProcGetpid)(struct IPerlProc*);
841 #ifdef WIN32
842 typedef void*           (*LPProcDynaLoader)(struct IPerlProc*, const char*);
843 typedef void            (*LPProcGetOSError)(struct IPerlProc*,
844                             SV* sv, DWORD dwErr);
845 typedef void            (*LPProcFreeBuf)(struct IPerlProc*, char*);
846 typedef BOOL            (*LPProcDoCmd)(struct IPerlProc*, char*);
847 typedef int             (*LPProcSpawn)(struct IPerlProc*, char*);
848 typedef int             (*LPProcSpawnvp)(struct IPerlProc*, int, const char*,
849                             const char*const*);
850 typedef int             (*LPProcASpawn)(struct IPerlProc*, void*, void**, void**);
851 #endif
852
853 struct IPerlProc
854 {
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;
880     LPProcFork          pFork;
881     LPProcGetpid        pGetpid;
882 #ifdef WIN32
883     LPProcDynaLoader    pDynaLoader;
884     LPProcGetOSError    pGetOSError;
885     LPProcDoCmd         pDoCmd;
886     LPProcSpawn         pSpawn;
887     LPProcSpawnvp       pSpawnvp;
888     LPProcASpawn        pASpawn;
889 #endif
890 };
891
892 struct IPerlProcInfo
893 {
894     unsigned long       nCount;     /* number of entries expected */
895     struct IPerlProc    perlProcList;
896 };
897
898 #define PerlProc_abort()                                                \
899         (*PL_Proc->pAbort)(PL_Proc)
900 #define PerlProc_crypt(c,s)                                             \
901         (*PL_Proc->pCrypt)(PL_Proc, (c), (s))
902 #define PerlProc_exit(s)                                                \
903         (*PL_Proc->pExit)(PL_Proc, (s))
904 #define PerlProc__exit(s)                                               \
905         (*PL_Proc->p_Exit)(PL_Proc, (s))
906 #define PerlProc_execl(c, w, x, y, z)                                   \
907         (*PL_Proc->pExecl)(PL_Proc, (c), (w), (x), (y), (z))
908 #define PerlProc_execv(c, a)                                            \
909         (*PL_Proc->pExecv)(PL_Proc, (c), (a))
910 #define PerlProc_execvp(c, a)                                           \
911         (*PL_Proc->pExecvp)(PL_Proc, (c), (a))
912 #define PerlProc_getuid()                                               \
913         (*PL_Proc->pGetuid)(PL_Proc)
914 #define PerlProc_geteuid()                                              \
915         (*PL_Proc->pGeteuid)(PL_Proc)
916 #define PerlProc_getgid()                                               \
917         (*PL_Proc->pGetgid)(PL_Proc)
918 #define PerlProc_getegid()                                              \
919         (*PL_Proc->pGetegid)(PL_Proc)
920 #define PerlProc_getlogin()                                             \
921         (*PL_Proc->pGetlogin)(PL_Proc)
922 #define PerlProc_kill(i, a)                                             \
923         (*PL_Proc->pKill)(PL_Proc, (i), (a))
924 #define PerlProc_killpg(i, a)                                           \
925         (*PL_Proc->pKillpg)(PL_Proc, (i), (a))
926 #define PerlProc_pause()                                                \
927         (*PL_Proc->pPauseProc)(PL_Proc)
928 #define PerlProc_popen(c, m)                                            \
929         (*PL_Proc->pPopen)(PL_Proc, (c), (m))
930 #define PerlProc_pclose(f)                                              \
931         (*PL_Proc->pPclose)(PL_Proc, (f))
932 #define PerlProc_pipe(fd)                                               \
933         (*PL_Proc->pPipe)(PL_Proc, (fd))
934 #define PerlProc_setuid(u)                                              \
935         (*PL_Proc->pSetuid)(PL_Proc, (u))
936 #define PerlProc_setgid(g)                                              \
937         (*PL_Proc->pSetgid)(PL_Proc, (g))
938 #define PerlProc_sleep(t)                                               \
939         (*PL_Proc->pSleep)(PL_Proc, (t))
940 #define PerlProc_times(t)                                               \
941         (*PL_Proc->pTimes)(PL_Proc, (t))
942 #define PerlProc_wait(t)                                                \
943         (*PL_Proc->pWait)(PL_Proc, (t))
944 #define PerlProc_waitpid(p,s,f)                                         \
945         (*PL_Proc->pWaitpid)(PL_Proc, (p), (s), (f))
946 #define PerlProc_signal(n, h)                                           \
947         (*PL_Proc->pSignal)(PL_Proc, (n), (h))
948 #define PerlProc_fork()                                                 \
949         (*PL_Proc->pFork)(PL_Proc)
950 #define PerlProc_getpid()                                               \
951         (*PL_Proc->pGetpid)(PL_Proc)
952 #define PerlProc_setjmp(b, n) Sigsetjmp((b), (n))
953 #define PerlProc_longjmp(b, n) Siglongjmp((b), (n))
954
955 #ifdef WIN32
956 #define PerlProc_DynaLoad(f)                                            \
957         (*PL_Proc->pDynaLoader)(PL_Proc, (f))
958 #define PerlProc_GetOSError(s,e)                                        \
959         (*PL_Proc->pGetOSError)(PL_Proc, (s), (e))
960 #define PerlProc_Cmd(s)                                                 \
961         (*PL_Proc->pDoCmd)(PL_Proc, (s))
962 #define do_spawn(s)                                                     \
963         (*PL_Proc->pSpawn)(PL_Proc, (s))
964 #define do_spawnvp(m, c, a)                                             \
965         (*PL_Proc->pSpawnvp)(PL_Proc, (m), (c), (a))
966 #define PerlProc_aspawn(m,c,a)                                          \
967         (*PL_Proc->pASpawn)(PL_Proc, (m), (c), (a))
968 #endif
969
970 #else   /* PERL_IMPLICIT_SYS */
971
972 #define PerlProc_abort()        abort()
973 #define PerlProc_crypt(c,s)     crypt((c), (s))
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))
1000 #define PerlProc_fork()         fork()
1001 #define PerlProc_getpid()       getpid()
1002
1003 #ifdef WIN32
1004 #define PerlProc_DynaLoad(f)                                            \
1005         win32_dynaload((f))
1006 #define PerlProc_GetOSError(s,e)                                        \
1007         win32_str_os_error((s), (e))
1008 #endif
1009 #endif  /* PERL_IMPLICIT_SYS */
1010
1011 /*
1012     Interface for perl socket functions
1013 */
1014
1015 #if defined(PERL_IMPLICIT_SYS)
1016
1017 /* PerlSock             */
1018 struct IPerlSock;
1019 struct IPerlSockInfo;
1020 typedef u_long          (*LPHtonl)(struct IPerlSock*, u_long);
1021 typedef u_short         (*LPHtons)(struct IPerlSock*, u_short);
1022 typedef u_long          (*LPNtohl)(struct IPerlSock*, u_long);
1023 typedef u_short         (*LPNtohs)(struct IPerlSock*, u_short);
1024 typedef SOCKET          (*LPAccept)(struct IPerlSock*, SOCKET,
1025                             struct sockaddr*, int*);
1026 typedef int             (*LPBind)(struct IPerlSock*, SOCKET,
1027                             const struct sockaddr*, int);
1028 typedef int             (*LPConnect)(struct IPerlSock*, SOCKET,
1029                             const struct sockaddr*, int);
1030 typedef void            (*LPEndhostent)(struct IPerlSock*);
1031 typedef void            (*LPEndnetent)(struct IPerlSock*);
1032 typedef void            (*LPEndprotoent)(struct IPerlSock*);
1033 typedef void            (*LPEndservent)(struct IPerlSock*);
1034 typedef int             (*LPGethostname)(struct IPerlSock*, char*, int);
1035 typedef int             (*LPGetpeername)(struct IPerlSock*, SOCKET,
1036                             struct sockaddr*, int*);
1037 typedef struct hostent* (*LPGethostbyaddr)(struct IPerlSock*, const char*,
1038                             int, int);
1039 typedef struct hostent* (*LPGethostbyname)(struct IPerlSock*, const char*);
1040 typedef struct hostent* (*LPGethostent)(struct IPerlSock*);
1041 typedef struct netent*  (*LPGetnetbyaddr)(struct IPerlSock*, long, int);
1042 typedef struct netent*  (*LPGetnetbyname)(struct IPerlSock*, const char*);
1043 typedef struct netent*  (*LPGetnetent)(struct IPerlSock*);
1044 typedef struct protoent*(*LPGetprotobyname)(struct IPerlSock*, const char*);
1045 typedef struct protoent*(*LPGetprotobynumber)(struct IPerlSock*, int);
1046 typedef struct protoent*(*LPGetprotoent)(struct IPerlSock*);
1047 typedef struct servent* (*LPGetservbyname)(struct IPerlSock*, const char*,
1048                             const char*);
1049 typedef struct servent* (*LPGetservbyport)(struct IPerlSock*, int,
1050                             const char*);
1051 typedef struct servent* (*LPGetservent)(struct IPerlSock*);
1052 typedef int             (*LPGetsockname)(struct IPerlSock*, SOCKET,
1053                             struct sockaddr*, int*);
1054 typedef int             (*LPGetsockopt)(struct IPerlSock*, SOCKET, int, int,
1055                             char*, int*);
1056 typedef unsigned long   (*LPInetAddr)(struct IPerlSock*, const char*);
1057 typedef char*           (*LPInetNtoa)(struct IPerlSock*, struct in_addr);
1058 typedef int             (*LPListen)(struct IPerlSock*, SOCKET, int);
1059 typedef int             (*LPRecv)(struct IPerlSock*, SOCKET, char*, int, int);
1060 typedef int             (*LPRecvfrom)(struct IPerlSock*, SOCKET, char*, int,
1061                             int, struct sockaddr*, int*);
1062 typedef int             (*LPSelect)(struct IPerlSock*, int, char*, char*,
1063                             char*, const struct timeval*);
1064 typedef int             (*LPSend)(struct IPerlSock*, SOCKET, const char*, int,
1065                             int);
1066 typedef int             (*LPSendto)(struct IPerlSock*, SOCKET, const char*,
1067                             int, int, const struct sockaddr*, int);
1068 typedef void            (*LPSethostent)(struct IPerlSock*, int);
1069 typedef void            (*LPSetnetent)(struct IPerlSock*, int);
1070 typedef void            (*LPSetprotoent)(struct IPerlSock*, int);
1071 typedef void            (*LPSetservent)(struct IPerlSock*, int);
1072 typedef int             (*LPSetsockopt)(struct IPerlSock*, SOCKET, int, int,
1073                             const char*, int);
1074 typedef int             (*LPShutdown)(struct IPerlSock*, SOCKET, int);
1075 typedef SOCKET          (*LPSocket)(struct IPerlSock*, int, int, int);
1076 typedef int             (*LPSocketpair)(struct IPerlSock*, int, int, int,
1077                             int*);
1078 #ifdef WIN32
1079 typedef int             (*LPClosesocket)(struct IPerlSock*, SOCKET s);
1080 #endif
1081
1082 struct IPerlSock
1083 {
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;
1127 #ifdef WIN32
1128     LPClosesocket       pClosesocket;
1129 #endif
1130 };
1131
1132 struct IPerlSockInfo
1133 {
1134     unsigned long       nCount;     /* number of entries expected */
1135     struct IPerlSock    perlSockList;
1136 };
1137
1138 #define PerlSock_htonl(x)                                               \
1139         (*PL_Sock->pHtonl)(PL_Sock, x)
1140 #define PerlSock_htons(x)                                               \
1141         (*PL_Sock->pHtons)(PL_Sock, x)
1142 #define PerlSock_ntohl(x)                                               \
1143         (*PL_Sock->pNtohl)(PL_Sock, x)
1144 #define PerlSock_ntohs(x)                                               \
1145         (*PL_Sock->pNtohs)(PL_Sock, x)
1146 #define PerlSock_accept(s, a, l)                                        \
1147         (*PL_Sock->pAccept)(PL_Sock, s, a, l)
1148 #define PerlSock_bind(s, n, l)                                          \
1149         (*PL_Sock->pBind)(PL_Sock, s, n, l)
1150 #define PerlSock_connect(s, n, l)                                       \
1151         (*PL_Sock->pConnect)(PL_Sock, s, n, l)
1152 #define PerlSock_endhostent()                                           \
1153         (*PL_Sock->pEndhostent)(PL_Sock)
1154 #define PerlSock_endnetent()                                            \
1155         (*PL_Sock->pEndnetent)(PL_Sock)
1156 #define PerlSock_endprotoent()                                          \
1157         (*PL_Sock->pEndprotoent)(PL_Sock)
1158 #define PerlSock_endservent()                                           \
1159         (*PL_Sock->pEndservent)(PL_Sock)
1160 #define PerlSock_gethostbyaddr(a, l, t)                                 \
1161         (*PL_Sock->pGethostbyaddr)(PL_Sock, a, l, t)
1162 #define PerlSock_gethostbyname(n)                                       \
1163         (*PL_Sock->pGethostbyname)(PL_Sock, n)
1164 #define PerlSock_gethostent()                                           \
1165         (*PL_Sock->pGethostent)(PL_Sock)
1166 #define PerlSock_gethostname(n, l)                                      \
1167         (*PL_Sock->pGethostname)(PL_Sock, n, l)
1168 #define PerlSock_getnetbyaddr(n, t)                                     \
1169         (*PL_Sock->pGetnetbyaddr)(PL_Sock, n, t)
1170 #define PerlSock_getnetbyname(c)                                        \
1171         (*PL_Sock->pGetnetbyname)(PL_Sock, c)
1172 #define PerlSock_getnetent()                                            \
1173         (*PL_Sock->pGetnetent)(PL_Sock)
1174 #define PerlSock_getpeername(s, n, l)                                   \
1175         (*PL_Sock->pGetpeername)(PL_Sock, s, n, l)
1176 #define PerlSock_getprotobyname(n)                                      \
1177         (*PL_Sock->pGetprotobyname)(PL_Sock, n)
1178 #define PerlSock_getprotobynumber(n)                                    \
1179         (*PL_Sock->pGetprotobynumber)(PL_Sock, n)
1180 #define PerlSock_getprotoent()                                          \
1181         (*PL_Sock->pGetprotoent)(PL_Sock)
1182 #define PerlSock_getservbyname(n, p)                                    \
1183         (*PL_Sock->pGetservbyname)(PL_Sock, n, p)
1184 #define PerlSock_getservbyport(port, p)                                 \
1185         (*PL_Sock->pGetservbyport)(PL_Sock, port, p)
1186 #define PerlSock_getservent()                                           \
1187         (*PL_Sock->pGetservent)(PL_Sock)
1188 #define PerlSock_getsockname(s, n, l)                                   \
1189         (*PL_Sock->pGetsockname)(PL_Sock, s, n, l)
1190 #define PerlSock_getsockopt(s,l,n,v,i)                                  \
1191         (*PL_Sock->pGetsockopt)(PL_Sock, s, l, n, v, i)
1192 #define PerlSock_inet_addr(c)                                           \
1193         (*PL_Sock->pInetAddr)(PL_Sock, c)
1194 #define PerlSock_inet_ntoa(i)                                           \
1195         (*PL_Sock->pInetNtoa)(PL_Sock, i)
1196 #define PerlSock_listen(s, b)                                           \
1197         (*PL_Sock->pListen)(PL_Sock, s, b)
1198 #define PerlSock_recv(s, b, l, f)                                       \
1199         (*PL_Sock->pRecv)(PL_Sock, s, b, l, f)
1200 #define PerlSock_recvfrom(s,b,l,f,from,fromlen)                         \
1201         (*PL_Sock->pRecvfrom)(PL_Sock, s, b, l, f, from, fromlen)
1202 #define PerlSock_select(n, r, w, e, t)                                  \
1203         (*PL_Sock->pSelect)(PL_Sock, n, (char*)r, (char*)w, (char*)e, t)
1204 #define PerlSock_send(s, b, l, f)                                       \
1205         (*PL_Sock->pSend)(PL_Sock, s, b, l, f)
1206 #define PerlSock_sendto(s, b, l, f, t, tlen)                            \
1207         (*PL_Sock->pSendto)(PL_Sock, s, b, l, f, t, tlen)
1208 #define PerlSock_sethostent(f)                                          \
1209         (*PL_Sock->pSethostent)(PL_Sock, f)
1210 #define PerlSock_setnetent(f)                                           \
1211         (*PL_Sock->pSetnetent)(PL_Sock, f)
1212 #define PerlSock_setprotoent(f)                                         \
1213         (*PL_Sock->pSetprotoent)(PL_Sock, f)
1214 #define PerlSock_setservent(f)                                          \
1215         (*PL_Sock->pSetservent)(PL_Sock, f)
1216 #define PerlSock_setsockopt(s, l, n, v, len)                            \
1217         (*PL_Sock->pSetsockopt)(PL_Sock, s, l, n, v, len)
1218 #define PerlSock_shutdown(s, h)                                         \
1219         (*PL_Sock->pShutdown)(PL_Sock, s, h)
1220 #define PerlSock_socket(a, t, p)                                        \
1221         (*PL_Sock->pSocket)(PL_Sock, a, t, p)
1222 #define PerlSock_socketpair(a, t, p, f)                                 \
1223         (*PL_Sock->pSocketpair)(PL_Sock, a, t, p, f)
1224
1225 #ifdef WIN32
1226 #define PerlSock_closesocket(s)                                         \
1227         (*PL_Sock->pClosesocket)(PL_Sock, s)
1228 #endif
1229
1230 #else   /* PERL_IMPLICIT_SYS */
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)
1267 #define PerlSock_recv(s, b, l, f)       recv(s, b, l, f)
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
1284 #ifdef WIN32
1285 #define PerlSock_closesocket(s)         closesocket(s)
1286 #endif
1287
1288 #endif  /* PERL_IMPLICIT_SYS */
1289
1290 #endif  /* __Inc__IPerl___ */
1291