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