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