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