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