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