Re: question about retlen in utf8.c:Perl_utf8_to_uv()
[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 #if O_BINARY != O_TEXT
671 #define PerlLIO_setmode(fd, mode)       setmode((fd), (mode))
672 #else
673 /* Until we have a "host" on UNIX to supply a stub #define it out */
674 #define PerlLIO_setmode(fd, mode)       0
675 #endif
676 #define PerlLIO_tmpnam(str)             tmpnam((str))
677 #define PerlLIO_umask(mode)             umask((mode))
678 #define PerlLIO_unlink(file)            unlink((file))
679 #define PerlLIO_utime(file, time)       utime((file), (time))
680 #define PerlLIO_write(fd, buf, count)   write((fd), (buf), (count))
681
682 #endif  /* PERL_IMPLICIT_SYS */
683
684 /*
685     Interface for perl memory allocation
686 */
687
688 #if defined(PERL_IMPLICIT_SYS)
689
690 /* IPerlMem             */
691 struct IPerlMem;
692 struct IPerlMemInfo;
693 typedef void*           (*LPMemMalloc)(struct IPerlMem*, size_t);
694 typedef void*           (*LPMemRealloc)(struct IPerlMem*, void*, size_t);
695 typedef void            (*LPMemFree)(struct IPerlMem*, void*);
696 typedef void*           (*LPMemCalloc)(struct IPerlMem*, size_t, size_t);
697 typedef void            (*LPMemGetLock)(struct IPerlMem*);
698 typedef void            (*LPMemFreeLock)(struct IPerlMem*);
699 typedef int             (*LPMemIsLocked)(struct IPerlMem*);
700
701 struct IPerlMem
702 {
703     LPMemMalloc         pMalloc;
704     LPMemRealloc        pRealloc;
705     LPMemFree           pFree;
706     LPMemCalloc         pCalloc;
707     LPMemGetLock        pGetLock;
708     LPMemFreeLock       pFreeLock;
709     LPMemIsLocked       pIsLocked;
710 };
711
712 struct IPerlMemInfo
713 {
714     unsigned long       nCount;     /* number of entries expected */
715     struct IPerlMem     perlMemList;
716 };
717
718 /* Interpreter specific memory macros */
719 #define PerlMem_malloc(size)                                \
720         (*PL_Mem->pMalloc)(PL_Mem, (size))
721 #define PerlMem_realloc(buf, size)                          \
722         (*PL_Mem->pRealloc)(PL_Mem, (buf), (size))
723 #define PerlMem_free(buf)                                   \
724         (*PL_Mem->pFree)(PL_Mem, (buf))
725 #define PerlMem_calloc(num, size)                           \
726         (*PL_Mem->pCalloc)(PL_Mem, (num), (size))
727 #define PerlMem_get_lock()                                  \
728         (*PL_Mem->pGetLock)(PL_Mem)
729 #define PerlMem_free_lock()                                 \
730         (*PL_Mem->pFreeLock)(PL_Mem)
731 #define PerlMem_is_locked()                                 \
732         (*PL_Mem->pIsLocked)(PL_Mem)
733
734 /* Shared memory macros */
735 #define PerlMemShared_malloc(size)                          \
736         (*PL_MemShared->pMalloc)(PL_Mem, (size))
737 #define PerlMemShared_realloc(buf, size)                    \
738         (*PL_MemShared->pRealloc)(PL_Mem, (buf), (size))
739 #define PerlMemShared_free(buf)                             \
740         (*PL_MemShared->pFree)(PL_Mem, (buf))
741 #define PerlMemShared_calloc(num, size)                     \
742         (*PL_MemShared->pCalloc)(PL_Mem, (num), (size))
743 #define PerlMemShared_get_lock()                            \
744         (*PL_MemShared->pGetLock)(PL_Mem)
745 #define PerlMemShared_free_lock()                           \
746         (*PL_MemShared->pFreeLock)(PL_Mem)
747 #define PerlMemShared_is_locked()                           \
748         (*PL_MemShared->pIsLocked)(PL_Mem)
749
750
751 /* Parse tree memory macros */
752 #define PerlMemParse_malloc(size)                           \
753         (*PL_MemParse->pMalloc)(PL_Mem, (size))
754 #define PerlMemParse_realloc(buf, size)                     \
755         (*PL_MemParse->pRealloc)(PL_Mem, (buf), (size))
756 #define PerlMemParse_free(buf)                              \
757         (*PL_MemParse->pFree)(PL_Mem, (buf))
758 #define PerlMemParse_calloc(num, size)                      \
759         (*PL_MemParse->pCalloc)(PL_Mem, (num), (size))
760 #define PerlMemParse_get_lock()                             \
761         (*PL_MemParse->pGetLock)(PL_Mem)
762 #define PerlMemParse_free_lock()                            \
763         (*PL_MemParse->pFreeLock)(PL_Mem)
764 #define PerlMemParse_is_locked()                            \
765         (*PL_MemParse->pIsLocked)(PL_Mem)
766
767
768 #else   /* PERL_IMPLICIT_SYS */
769
770 /* Interpreter specific memory macros */
771 #define PerlMem_malloc(size)            malloc((size))
772 #define PerlMem_realloc(buf, size)      realloc((buf), (size))
773 #define PerlMem_free(buf)               free((buf))
774 #define PerlMem_calloc(num, size)       calloc((num), (size))
775 #define PerlMem_get_lock()              
776 #define PerlMem_free_lock()
777 #define PerlMem_is_locked()             0
778
779 /* Shared memory macros */
780 #define PerlMemShared_malloc(size)              malloc((size))
781 #define PerlMemShared_realloc(buf, size)        realloc((buf), (size))
782 #define PerlMemShared_free(buf)                 free((buf))
783 #define PerlMemShared_calloc(num, size)         calloc((num), (size))
784 #define PerlMemShared_get_lock()                
785 #define PerlMemShared_free_lock()
786 #define PerlMemShared_is_locked()               0
787
788 /* Parse tree memory macros */
789 #define PerlMemParse_malloc(size)       malloc((size))
790 #define PerlMemParse_realloc(buf, size) realloc((buf), (size))
791 #define PerlMemParse_free(buf)          free((buf))
792 #define PerlMemParse_calloc(num, size)  calloc((num), (size))
793 #define PerlMemParse_get_lock()         
794 #define PerlMemParse_free_lock()
795 #define PerlMemParse_is_locked()        0
796
797 #endif  /* PERL_IMPLICIT_SYS */
798
799 /*
800     Interface for perl process functions
801 */
802
803
804 #if defined(PERL_IMPLICIT_SYS)
805
806 #ifndef jmp_buf
807 #include <setjmp.h>
808 #endif
809
810 /* IPerlProc            */
811 struct IPerlProc;
812 struct IPerlProcInfo;
813 typedef void            (*LPProcAbort)(struct IPerlProc*);
814 typedef char*           (*LPProcCrypt)(struct IPerlProc*, const char*,
815                             const char*);
816 typedef void            (*LPProcExit)(struct IPerlProc*, int);
817 typedef void            (*LPProc_Exit)(struct IPerlProc*, int);
818 typedef int             (*LPProcExecl)(struct IPerlProc*, const char*,
819                             const char*, const char*, const char*,
820                             const char*);
821 typedef int             (*LPProcExecv)(struct IPerlProc*, const char*,
822                             const char*const*);
823 typedef int             (*LPProcExecvp)(struct IPerlProc*, const char*,
824                             const char*const*);
825 typedef uid_t           (*LPProcGetuid)(struct IPerlProc*);
826 typedef uid_t           (*LPProcGeteuid)(struct IPerlProc*);
827 typedef gid_t           (*LPProcGetgid)(struct IPerlProc*);
828 typedef gid_t           (*LPProcGetegid)(struct IPerlProc*);
829 typedef char*           (*LPProcGetlogin)(struct IPerlProc*);
830 typedef int             (*LPProcKill)(struct IPerlProc*, int, int);
831 typedef int             (*LPProcKillpg)(struct IPerlProc*, int, int);
832 typedef int             (*LPProcPauseProc)(struct IPerlProc*);
833 typedef PerlIO*         (*LPProcPopen)(struct IPerlProc*, const char*,
834                             const char*);
835 typedef int             (*LPProcPclose)(struct IPerlProc*, PerlIO*);
836 typedef int             (*LPProcPipe)(struct IPerlProc*, int*);
837 typedef int             (*LPProcSetuid)(struct IPerlProc*, uid_t);
838 typedef int             (*LPProcSetgid)(struct IPerlProc*, gid_t);
839 typedef int             (*LPProcSleep)(struct IPerlProc*, unsigned int);
840 typedef int             (*LPProcTimes)(struct IPerlProc*, struct tms*);
841 typedef int             (*LPProcWait)(struct IPerlProc*, int*);
842 typedef int             (*LPProcWaitpid)(struct IPerlProc*, int, int*, int);
843 typedef Sighandler_t    (*LPProcSignal)(struct IPerlProc*, int, Sighandler_t);
844 typedef int             (*LPProcFork)(struct IPerlProc*);
845 typedef int             (*LPProcGetpid)(struct IPerlProc*);
846 #ifdef WIN32
847 typedef void*           (*LPProcDynaLoader)(struct IPerlProc*, const char*);
848 typedef void            (*LPProcGetOSError)(struct IPerlProc*,
849                             SV* sv, DWORD dwErr);
850 typedef void            (*LPProcFreeBuf)(struct IPerlProc*, char*);
851 typedef BOOL            (*LPProcDoCmd)(struct IPerlProc*, char*);
852 typedef int             (*LPProcSpawn)(struct IPerlProc*, char*);
853 typedef int             (*LPProcSpawnvp)(struct IPerlProc*, int, const char*,
854                             const char*const*);
855 typedef int             (*LPProcASpawn)(struct IPerlProc*, void*, void**, void**);
856 #endif
857
858 struct IPerlProc
859 {
860     LPProcAbort         pAbort;
861     LPProcCrypt         pCrypt;
862     LPProcExit          pExit;
863     LPProc_Exit         p_Exit;
864     LPProcExecl         pExecl;
865     LPProcExecv         pExecv;
866     LPProcExecvp        pExecvp;
867     LPProcGetuid        pGetuid;
868     LPProcGeteuid       pGeteuid;
869     LPProcGetgid        pGetgid;
870     LPProcGetegid       pGetegid;
871     LPProcGetlogin      pGetlogin;
872     LPProcKill          pKill;
873     LPProcKillpg        pKillpg;
874     LPProcPauseProc     pPauseProc;
875     LPProcPopen         pPopen;
876     LPProcPclose        pPclose;
877     LPProcPipe          pPipe;
878     LPProcSetuid        pSetuid;
879     LPProcSetgid        pSetgid;
880     LPProcSleep         pSleep;
881     LPProcTimes         pTimes;
882     LPProcWait          pWait;
883     LPProcWaitpid       pWaitpid;
884     LPProcSignal        pSignal;
885     LPProcFork          pFork;
886     LPProcGetpid        pGetpid;
887 #ifdef WIN32
888     LPProcDynaLoader    pDynaLoader;
889     LPProcGetOSError    pGetOSError;
890     LPProcDoCmd         pDoCmd;
891     LPProcSpawn         pSpawn;
892     LPProcSpawnvp       pSpawnvp;
893     LPProcASpawn        pASpawn;
894 #endif
895 };
896
897 struct IPerlProcInfo
898 {
899     unsigned long       nCount;     /* number of entries expected */
900     struct IPerlProc    perlProcList;
901 };
902
903 #define PerlProc_abort()                                                \
904         (*PL_Proc->pAbort)(PL_Proc)
905 #define PerlProc_crypt(c,s)                                             \
906         (*PL_Proc->pCrypt)(PL_Proc, (c), (s))
907 #define PerlProc_exit(s)                                                \
908         (*PL_Proc->pExit)(PL_Proc, (s))
909 #define PerlProc__exit(s)                                               \
910         (*PL_Proc->p_Exit)(PL_Proc, (s))
911 #define PerlProc_execl(c, w, x, y, z)                                   \
912         (*PL_Proc->pExecl)(PL_Proc, (c), (w), (x), (y), (z))
913 #define PerlProc_execv(c, a)                                            \
914         (*PL_Proc->pExecv)(PL_Proc, (c), (a))
915 #define PerlProc_execvp(c, a)                                           \
916         (*PL_Proc->pExecvp)(PL_Proc, (c), (a))
917 #define PerlProc_getuid()                                               \
918         (*PL_Proc->pGetuid)(PL_Proc)
919 #define PerlProc_geteuid()                                              \
920         (*PL_Proc->pGeteuid)(PL_Proc)
921 #define PerlProc_getgid()                                               \
922         (*PL_Proc->pGetgid)(PL_Proc)
923 #define PerlProc_getegid()                                              \
924         (*PL_Proc->pGetegid)(PL_Proc)
925 #define PerlProc_getlogin()                                             \
926         (*PL_Proc->pGetlogin)(PL_Proc)
927 #define PerlProc_kill(i, a)                                             \
928         (*PL_Proc->pKill)(PL_Proc, (i), (a))
929 #define PerlProc_killpg(i, a)                                           \
930         (*PL_Proc->pKillpg)(PL_Proc, (i), (a))
931 #define PerlProc_pause()                                                \
932         (*PL_Proc->pPauseProc)(PL_Proc)
933 #define PerlProc_popen(c, m)                                            \
934         (*PL_Proc->pPopen)(PL_Proc, (c), (m))
935 #define PerlProc_pclose(f)                                              \
936         (*PL_Proc->pPclose)(PL_Proc, (f))
937 #define PerlProc_pipe(fd)                                               \
938         (*PL_Proc->pPipe)(PL_Proc, (fd))
939 #define PerlProc_setuid(u)                                              \
940         (*PL_Proc->pSetuid)(PL_Proc, (u))
941 #define PerlProc_setgid(g)                                              \
942         (*PL_Proc->pSetgid)(PL_Proc, (g))
943 #define PerlProc_sleep(t)                                               \
944         (*PL_Proc->pSleep)(PL_Proc, (t))
945 #define PerlProc_times(t)                                               \
946         (*PL_Proc->pTimes)(PL_Proc, (t))
947 #define PerlProc_wait(t)                                                \
948         (*PL_Proc->pWait)(PL_Proc, (t))
949 #define PerlProc_waitpid(p,s,f)                                         \
950         (*PL_Proc->pWaitpid)(PL_Proc, (p), (s), (f))
951 #define PerlProc_signal(n, h)                                           \
952         (*PL_Proc->pSignal)(PL_Proc, (n), (h))
953 #define PerlProc_fork()                                                 \
954         (*PL_Proc->pFork)(PL_Proc)
955 #define PerlProc_getpid()                                               \
956         (*PL_Proc->pGetpid)(PL_Proc)
957 #define PerlProc_setjmp(b, n) Sigsetjmp((b), (n))
958 #define PerlProc_longjmp(b, n) Siglongjmp((b), (n))
959
960 #ifdef WIN32
961 #define PerlProc_DynaLoad(f)                                            \
962         (*PL_Proc->pDynaLoader)(PL_Proc, (f))
963 #define PerlProc_GetOSError(s,e)                                        \
964         (*PL_Proc->pGetOSError)(PL_Proc, (s), (e))
965 #define PerlProc_Cmd(s)                                                 \
966         (*PL_Proc->pDoCmd)(PL_Proc, (s))
967 #define do_spawn(s)                                                     \
968         (*PL_Proc->pSpawn)(PL_Proc, (s))
969 #define do_spawnvp(m, c, a)                                             \
970         (*PL_Proc->pSpawnvp)(PL_Proc, (m), (c), (a))
971 #define PerlProc_aspawn(m,c,a)                                          \
972         (*PL_Proc->pASpawn)(PL_Proc, (m), (c), (a))
973 #endif
974
975 #else   /* PERL_IMPLICIT_SYS */
976
977 #define PerlProc_abort()        abort()
978 #define PerlProc_crypt(c,s)     crypt((c), (s))
979 #define PerlProc_exit(s)        exit((s))
980 #define PerlProc__exit(s)       _exit((s))
981 #define PerlProc_execl(c,w,x,y,z)                                       \
982         execl((c), (w), (x), (y), (z))
983 #define PerlProc_execv(c, a)    execv((c), (a))
984 #define PerlProc_execvp(c, a)   execvp((c), (a))
985 #define PerlProc_getuid()       getuid()
986 #define PerlProc_geteuid()      geteuid()
987 #define PerlProc_getgid()       getgid()
988 #define PerlProc_getegid()      getegid()
989 #define PerlProc_getlogin()     getlogin()
990 #define PerlProc_kill(i, a)     kill((i), (a))
991 #define PerlProc_killpg(i, a)   killpg((i), (a))
992 #define PerlProc_pause()        Pause()
993 #define PerlProc_popen(c, m)    my_popen((c), (m))
994 #define PerlProc_pclose(f)      my_pclose((f))
995 #define PerlProc_pipe(fd)       pipe((fd))
996 #define PerlProc_setuid(u)      setuid((u))
997 #define PerlProc_setgid(g)      setgid((g))
998 #define PerlProc_sleep(t)       sleep((t))
999 #define PerlProc_times(t)       times((t))
1000 #define PerlProc_wait(t)        wait((t))
1001 #define PerlProc_waitpid(p,s,f) waitpid((p), (s), (f))
1002 #define PerlProc_setjmp(b, n)   Sigsetjmp((b), (n))
1003 #define PerlProc_longjmp(b, n)  Siglongjmp((b), (n))
1004 #define PerlProc_signal(n, h)   signal((n), (h))
1005 #define PerlProc_fork()         fork()
1006 #define PerlProc_getpid()       getpid()
1007
1008 #ifdef WIN32
1009 #define PerlProc_DynaLoad(f)                                            \
1010         win32_dynaload((f))
1011 #define PerlProc_GetOSError(s,e)                                        \
1012         win32_str_os_error((s), (e))
1013 #endif
1014 #endif  /* PERL_IMPLICIT_SYS */
1015
1016 /*
1017     Interface for perl socket functions
1018 */
1019
1020 #if defined(PERL_IMPLICIT_SYS)
1021
1022 /* PerlSock             */
1023 struct IPerlSock;
1024 struct IPerlSockInfo;
1025 typedef u_long          (*LPHtonl)(struct IPerlSock*, u_long);
1026 typedef u_short         (*LPHtons)(struct IPerlSock*, u_short);
1027 typedef u_long          (*LPNtohl)(struct IPerlSock*, u_long);
1028 typedef u_short         (*LPNtohs)(struct IPerlSock*, u_short);
1029 typedef SOCKET          (*LPAccept)(struct IPerlSock*, SOCKET,
1030                             struct sockaddr*, int*);
1031 typedef int             (*LPBind)(struct IPerlSock*, SOCKET,
1032                             const struct sockaddr*, int);
1033 typedef int             (*LPConnect)(struct IPerlSock*, SOCKET,
1034                             const struct sockaddr*, int);
1035 typedef void            (*LPEndhostent)(struct IPerlSock*);
1036 typedef void            (*LPEndnetent)(struct IPerlSock*);
1037 typedef void            (*LPEndprotoent)(struct IPerlSock*);
1038 typedef void            (*LPEndservent)(struct IPerlSock*);
1039 typedef int             (*LPGethostname)(struct IPerlSock*, char*, int);
1040 typedef int             (*LPGetpeername)(struct IPerlSock*, SOCKET,
1041                             struct sockaddr*, int*);
1042 typedef struct hostent* (*LPGethostbyaddr)(struct IPerlSock*, const char*,
1043                             int, int);
1044 typedef struct hostent* (*LPGethostbyname)(struct IPerlSock*, const char*);
1045 typedef struct hostent* (*LPGethostent)(struct IPerlSock*);
1046 typedef struct netent*  (*LPGetnetbyaddr)(struct IPerlSock*, long, int);
1047 typedef struct netent*  (*LPGetnetbyname)(struct IPerlSock*, const char*);
1048 typedef struct netent*  (*LPGetnetent)(struct IPerlSock*);
1049 typedef struct protoent*(*LPGetprotobyname)(struct IPerlSock*, const char*);
1050 typedef struct protoent*(*LPGetprotobynumber)(struct IPerlSock*, int);
1051 typedef struct protoent*(*LPGetprotoent)(struct IPerlSock*);
1052 typedef struct servent* (*LPGetservbyname)(struct IPerlSock*, const char*,
1053                             const char*);
1054 typedef struct servent* (*LPGetservbyport)(struct IPerlSock*, int,
1055                             const char*);
1056 typedef struct servent* (*LPGetservent)(struct IPerlSock*);
1057 typedef int             (*LPGetsockname)(struct IPerlSock*, SOCKET,
1058                             struct sockaddr*, int*);
1059 typedef int             (*LPGetsockopt)(struct IPerlSock*, SOCKET, int, int,
1060                             char*, int*);
1061 typedef unsigned long   (*LPInetAddr)(struct IPerlSock*, const char*);
1062 typedef char*           (*LPInetNtoa)(struct IPerlSock*, struct in_addr);
1063 typedef int             (*LPListen)(struct IPerlSock*, SOCKET, int);
1064 typedef int             (*LPRecv)(struct IPerlSock*, SOCKET, char*, int, int);
1065 typedef int             (*LPRecvfrom)(struct IPerlSock*, SOCKET, char*, int,
1066                             int, struct sockaddr*, int*);
1067 typedef int             (*LPSelect)(struct IPerlSock*, int, char*, char*,
1068                             char*, const struct timeval*);
1069 typedef int             (*LPSend)(struct IPerlSock*, SOCKET, const char*, int,
1070                             int);
1071 typedef int             (*LPSendto)(struct IPerlSock*, SOCKET, const char*,
1072                             int, int, const struct sockaddr*, int);
1073 typedef void            (*LPSethostent)(struct IPerlSock*, int);
1074 typedef void            (*LPSetnetent)(struct IPerlSock*, int);
1075 typedef void            (*LPSetprotoent)(struct IPerlSock*, int);
1076 typedef void            (*LPSetservent)(struct IPerlSock*, int);
1077 typedef int             (*LPSetsockopt)(struct IPerlSock*, SOCKET, int, int,
1078                             const char*, int);
1079 typedef int             (*LPShutdown)(struct IPerlSock*, SOCKET, int);
1080 typedef SOCKET          (*LPSocket)(struct IPerlSock*, int, int, int);
1081 typedef int             (*LPSocketpair)(struct IPerlSock*, int, int, int,
1082                             int*);
1083 #ifdef WIN32
1084 typedef int             (*LPClosesocket)(struct IPerlSock*, SOCKET s);
1085 #endif
1086
1087 struct IPerlSock
1088 {
1089     LPHtonl             pHtonl;
1090     LPHtons             pHtons;
1091     LPNtohl             pNtohl;
1092     LPNtohs             pNtohs;
1093     LPAccept            pAccept;
1094     LPBind              pBind;
1095     LPConnect           pConnect;
1096     LPEndhostent        pEndhostent;
1097     LPEndnetent         pEndnetent;
1098     LPEndprotoent       pEndprotoent;
1099     LPEndservent        pEndservent;
1100     LPGethostname       pGethostname;
1101     LPGetpeername       pGetpeername;
1102     LPGethostbyaddr     pGethostbyaddr;
1103     LPGethostbyname     pGethostbyname;
1104     LPGethostent        pGethostent;
1105     LPGetnetbyaddr      pGetnetbyaddr;
1106     LPGetnetbyname      pGetnetbyname;
1107     LPGetnetent         pGetnetent;
1108     LPGetprotobyname    pGetprotobyname;
1109     LPGetprotobynumber  pGetprotobynumber;
1110     LPGetprotoent       pGetprotoent;
1111     LPGetservbyname     pGetservbyname;
1112     LPGetservbyport     pGetservbyport;
1113     LPGetservent        pGetservent;
1114     LPGetsockname       pGetsockname;
1115     LPGetsockopt        pGetsockopt;
1116     LPInetAddr          pInetAddr;
1117     LPInetNtoa          pInetNtoa;
1118     LPListen            pListen;
1119     LPRecv              pRecv;
1120     LPRecvfrom          pRecvfrom;
1121     LPSelect            pSelect;
1122     LPSend              pSend;
1123     LPSendto            pSendto;
1124     LPSethostent        pSethostent;
1125     LPSetnetent         pSetnetent;
1126     LPSetprotoent       pSetprotoent;
1127     LPSetservent        pSetservent;
1128     LPSetsockopt        pSetsockopt;
1129     LPShutdown          pShutdown;
1130     LPSocket            pSocket;
1131     LPSocketpair        pSocketpair;
1132 #ifdef WIN32
1133     LPClosesocket       pClosesocket;
1134 #endif
1135 };
1136
1137 struct IPerlSockInfo
1138 {
1139     unsigned long       nCount;     /* number of entries expected */
1140     struct IPerlSock    perlSockList;
1141 };
1142
1143 #define PerlSock_htonl(x)                                               \
1144         (*PL_Sock->pHtonl)(PL_Sock, x)
1145 #define PerlSock_htons(x)                                               \
1146         (*PL_Sock->pHtons)(PL_Sock, x)
1147 #define PerlSock_ntohl(x)                                               \
1148         (*PL_Sock->pNtohl)(PL_Sock, x)
1149 #define PerlSock_ntohs(x)                                               \
1150         (*PL_Sock->pNtohs)(PL_Sock, x)
1151 #define PerlSock_accept(s, a, l)                                        \
1152         (*PL_Sock->pAccept)(PL_Sock, s, a, l)
1153 #define PerlSock_bind(s, n, l)                                          \
1154         (*PL_Sock->pBind)(PL_Sock, s, n, l)
1155 #define PerlSock_connect(s, n, l)                                       \
1156         (*PL_Sock->pConnect)(PL_Sock, s, n, l)
1157 #define PerlSock_endhostent()                                           \
1158         (*PL_Sock->pEndhostent)(PL_Sock)
1159 #define PerlSock_endnetent()                                            \
1160         (*PL_Sock->pEndnetent)(PL_Sock)
1161 #define PerlSock_endprotoent()                                          \
1162         (*PL_Sock->pEndprotoent)(PL_Sock)
1163 #define PerlSock_endservent()                                           \
1164         (*PL_Sock->pEndservent)(PL_Sock)
1165 #define PerlSock_gethostbyaddr(a, l, t)                                 \
1166         (*PL_Sock->pGethostbyaddr)(PL_Sock, a, l, t)
1167 #define PerlSock_gethostbyname(n)                                       \
1168         (*PL_Sock->pGethostbyname)(PL_Sock, n)
1169 #define PerlSock_gethostent()                                           \
1170         (*PL_Sock->pGethostent)(PL_Sock)
1171 #define PerlSock_gethostname(n, l)                                      \
1172         (*PL_Sock->pGethostname)(PL_Sock, n, l)
1173 #define PerlSock_getnetbyaddr(n, t)                                     \
1174         (*PL_Sock->pGetnetbyaddr)(PL_Sock, n, t)
1175 #define PerlSock_getnetbyname(c)                                        \
1176         (*PL_Sock->pGetnetbyname)(PL_Sock, c)
1177 #define PerlSock_getnetent()                                            \
1178         (*PL_Sock->pGetnetent)(PL_Sock)
1179 #define PerlSock_getpeername(s, n, l)                                   \
1180         (*PL_Sock->pGetpeername)(PL_Sock, s, n, l)
1181 #define PerlSock_getprotobyname(n)                                      \
1182         (*PL_Sock->pGetprotobyname)(PL_Sock, n)
1183 #define PerlSock_getprotobynumber(n)                                    \
1184         (*PL_Sock->pGetprotobynumber)(PL_Sock, n)
1185 #define PerlSock_getprotoent()                                          \
1186         (*PL_Sock->pGetprotoent)(PL_Sock)
1187 #define PerlSock_getservbyname(n, p)                                    \
1188         (*PL_Sock->pGetservbyname)(PL_Sock, n, p)
1189 #define PerlSock_getservbyport(port, p)                                 \
1190         (*PL_Sock->pGetservbyport)(PL_Sock, port, p)
1191 #define PerlSock_getservent()                                           \
1192         (*PL_Sock->pGetservent)(PL_Sock)
1193 #define PerlSock_getsockname(s, n, l)                                   \
1194         (*PL_Sock->pGetsockname)(PL_Sock, s, n, l)
1195 #define PerlSock_getsockopt(s,l,n,v,i)                                  \
1196         (*PL_Sock->pGetsockopt)(PL_Sock, s, l, n, v, i)
1197 #define PerlSock_inet_addr(c)                                           \
1198         (*PL_Sock->pInetAddr)(PL_Sock, c)
1199 #define PerlSock_inet_ntoa(i)                                           \
1200         (*PL_Sock->pInetNtoa)(PL_Sock, i)
1201 #define PerlSock_listen(s, b)                                           \
1202         (*PL_Sock->pListen)(PL_Sock, s, b)
1203 #define PerlSock_recv(s, b, l, f)                                       \
1204         (*PL_Sock->pRecv)(PL_Sock, s, b, l, f)
1205 #define PerlSock_recvfrom(s,b,l,f,from,fromlen)                         \
1206         (*PL_Sock->pRecvfrom)(PL_Sock, s, b, l, f, from, fromlen)
1207 #define PerlSock_select(n, r, w, e, t)                                  \
1208         (*PL_Sock->pSelect)(PL_Sock, n, (char*)r, (char*)w, (char*)e, t)
1209 #define PerlSock_send(s, b, l, f)                                       \
1210         (*PL_Sock->pSend)(PL_Sock, s, b, l, f)
1211 #define PerlSock_sendto(s, b, l, f, t, tlen)                            \
1212         (*PL_Sock->pSendto)(PL_Sock, s, b, l, f, t, tlen)
1213 #define PerlSock_sethostent(f)                                          \
1214         (*PL_Sock->pSethostent)(PL_Sock, f)
1215 #define PerlSock_setnetent(f)                                           \
1216         (*PL_Sock->pSetnetent)(PL_Sock, f)
1217 #define PerlSock_setprotoent(f)                                         \
1218         (*PL_Sock->pSetprotoent)(PL_Sock, f)
1219 #define PerlSock_setservent(f)                                          \
1220         (*PL_Sock->pSetservent)(PL_Sock, f)
1221 #define PerlSock_setsockopt(s, l, n, v, len)                            \
1222         (*PL_Sock->pSetsockopt)(PL_Sock, s, l, n, v, len)
1223 #define PerlSock_shutdown(s, h)                                         \
1224         (*PL_Sock->pShutdown)(PL_Sock, s, h)
1225 #define PerlSock_socket(a, t, p)                                        \
1226         (*PL_Sock->pSocket)(PL_Sock, a, t, p)
1227 #define PerlSock_socketpair(a, t, p, f)                                 \
1228         (*PL_Sock->pSocketpair)(PL_Sock, a, t, p, f)
1229
1230 #ifdef WIN32
1231 #define PerlSock_closesocket(s)                                         \
1232         (*PL_Sock->pClosesocket)(PL_Sock, s)
1233 #endif
1234
1235 #else   /* PERL_IMPLICIT_SYS */
1236
1237 #define PerlSock_htonl(x)               htonl(x)
1238 #define PerlSock_htons(x)               htons(x)
1239 #define PerlSock_ntohl(x)               ntohl(x)
1240 #define PerlSock_ntohs(x)               ntohs(x)
1241 #define PerlSock_accept(s, a, l)        accept(s, a, l)
1242 #define PerlSock_bind(s, n, l)          bind(s, n, l)
1243 #define PerlSock_connect(s, n, l)       connect(s, n, l)
1244
1245 #define PerlSock_gethostbyaddr(a, l, t) gethostbyaddr(a, l, t)
1246 #define PerlSock_gethostbyname(n)       gethostbyname(n)
1247 #define PerlSock_gethostent             gethostent
1248 #define PerlSock_endhostent             endhostent
1249 #define PerlSock_gethostname(n, l)      gethostname(n, l)
1250
1251 #define PerlSock_getnetbyaddr(n, t)     getnetbyaddr(n, t)
1252 #define PerlSock_getnetbyname(n)        getnetbyname(n)
1253 #define PerlSock_getnetent              getnetent
1254 #define PerlSock_endnetent              endnetent
1255 #define PerlSock_getpeername(s, n, l)   getpeername(s, n, l)
1256
1257 #define PerlSock_getprotobyname(n)      getprotobyname(n)
1258 #define PerlSock_getprotobynumber(n)    getprotobynumber(n)
1259 #define PerlSock_getprotoent            getprotoent
1260 #define PerlSock_endprotoent            endprotoent
1261
1262 #define PerlSock_getservbyname(n, p)    getservbyname(n, p)
1263 #define PerlSock_getservbyport(port, p) getservbyport(port, p)
1264 #define PerlSock_getservent             getservent
1265 #define PerlSock_endservent             endservent
1266
1267 #define PerlSock_getsockname(s, n, l)   getsockname(s, n, l)
1268 #define PerlSock_getsockopt(s,l,n,v,i)  getsockopt(s, l, n, v, i)
1269 #define PerlSock_inet_addr(c)           inet_addr(c)
1270 #define PerlSock_inet_ntoa(i)           inet_ntoa(i)
1271 #define PerlSock_listen(s, b)           listen(s, b)
1272 #define PerlSock_recv(s, b, l, f)       recv(s, b, l, f)
1273 #define PerlSock_recvfrom(s, b, l, f, from, fromlen)                    \
1274         recvfrom(s, b, l, f, from, fromlen)
1275 #define PerlSock_select(n, r, w, e, t)  select(n, r, w, e, t)
1276 #define PerlSock_send(s, b, l, f)       send(s, b, l, f)
1277 #define PerlSock_sendto(s, b, l, f, t, tlen)                            \
1278         sendto(s, b, l, f, t, tlen)
1279 #define PerlSock_sethostent(f)          sethostent(f)
1280 #define PerlSock_setnetent(f)           setnetent(f)
1281 #define PerlSock_setprotoent(f)         setprotoent(f)
1282 #define PerlSock_setservent(f)          setservent(f)
1283 #define PerlSock_setsockopt(s, l, n, v, len)                            \
1284         setsockopt(s, l, n, v, len)
1285 #define PerlSock_shutdown(s, h)         shutdown(s, h)
1286 #define PerlSock_socket(a, t, p)        socket(a, t, p)
1287 #define PerlSock_socketpair(a, t, p, f) socketpair(a, t, p, f)
1288
1289 #ifdef WIN32
1290 #define PerlSock_closesocket(s)         closesocket(s)
1291 #endif
1292
1293 #endif  /* PERL_IMPLICIT_SYS */
1294
1295 #endif  /* __Inc__IPerl___ */
1296