2 * iperlsys.h - Perl's interface to the system
4 * This file defines the system level functionality that perl needs.
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
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.
18 #ifndef __Inc__IPerl___
19 #define __Inc__IPerl___
22 * PerlXXX_YYY explained - DickH and DougL @ ActiveState.com
24 * XXX := functional group
25 * YYY := stdlib/OS function name
27 * Continuing with the theme of PerlIO, all OS functionality was
28 * encapsulated into one of several interfaces.
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
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.
47 * What was changed to do this:
48 * 1. All calls to OS functions were replaced with PerlXXX_YYY
54 Interface for perl stdio functions
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.
65 # define PERLIO_IS_STDIO
68 /* Below is the 5.003_02 stuff. */
70 # ifndef PERLIO_IS_STDIO
71 # define PERLIO_IS_STDIO
74 extern void PerlIO_init (void);
78 typedef Signal_t (*Sighandler_t) (int);
81 #if defined(PERL_IMPLICIT_SYS)
84 typedef struct _PerlIO PerlIOl;
85 typedef PerlIOl *PerlIO;
91 struct IPerlStdIOInfo;
92 typedef PerlIO* (*LPStdin)(struct IPerlStdIO*);
93 typedef PerlIO* (*LPStdout)(struct IPerlStdIO*);
94 typedef PerlIO* (*LPStderr)(struct IPerlStdIO*);
95 typedef PerlIO* (*LPOpen)(struct IPerlStdIO*, const char*,
97 typedef int (*LPClose)(struct IPerlStdIO*, PerlIO*);
98 typedef int (*LPEof)(struct IPerlStdIO*, PerlIO*);
99 typedef int (*LPError)(struct IPerlStdIO*, PerlIO*);
100 typedef void (*LPClearerr)(struct IPerlStdIO*, PerlIO*);
101 typedef int (*LPGetc)(struct IPerlStdIO*, PerlIO*);
102 typedef char* (*LPGetBase)(struct IPerlStdIO*, PerlIO*);
103 typedef int (*LPGetBufsiz)(struct IPerlStdIO*, PerlIO*);
104 typedef int (*LPGetCnt)(struct IPerlStdIO*, PerlIO*);
105 typedef char* (*LPGetPtr)(struct IPerlStdIO*, PerlIO*);
106 typedef char* (*LPGets)(struct IPerlStdIO*, PerlIO*, char*, int);
107 typedef int (*LPPutc)(struct IPerlStdIO*, PerlIO*, int);
108 typedef int (*LPPuts)(struct IPerlStdIO*, PerlIO*, const char*);
109 typedef int (*LPFlush)(struct IPerlStdIO*, PerlIO*);
110 typedef int (*LPUngetc)(struct IPerlStdIO*, PerlIO*,int);
111 typedef int (*LPFileno)(struct IPerlStdIO*, PerlIO*);
112 typedef PerlIO* (*LPFdopen)(struct IPerlStdIO*, int, const char*);
113 typedef PerlIO* (*LPReopen)(struct IPerlStdIO*, const char*,
114 const char*, PerlIO*);
115 typedef SSize_t (*LPRead)(struct IPerlStdIO*, PerlIO*, void*, Size_t);
116 typedef SSize_t (*LPWrite)(struct IPerlStdIO*, PerlIO*, const void*,
118 typedef void (*LPSetBuf)(struct IPerlStdIO*, PerlIO*, char*);
119 typedef int (*LPSetVBuf)(struct IPerlStdIO*, PerlIO*, char*, int,
121 typedef void (*LPSetCnt)(struct IPerlStdIO*, PerlIO*, int);
122 typedef void (*LPSetPtrCnt)(struct IPerlStdIO*, PerlIO*, char*,
124 typedef void (*LPSetlinebuf)(struct IPerlStdIO*, PerlIO*);
125 typedef int (*LPPrintf)(struct IPerlStdIO*, PerlIO*, const char*,
127 typedef int (*LPVprintf)(struct IPerlStdIO*, PerlIO*, const char*,
129 typedef long (*LPTell)(struct IPerlStdIO*, PerlIO*);
130 typedef int (*LPSeek)(struct IPerlStdIO*, PerlIO*, Off_t, int);
131 typedef void (*LPRewind)(struct IPerlStdIO*, PerlIO*);
132 typedef PerlIO* (*LPTmpfile)(struct IPerlStdIO*);
133 typedef int (*LPGetpos)(struct IPerlStdIO*, PerlIO*, Fpos_t*);
134 typedef int (*LPSetpos)(struct IPerlStdIO*, PerlIO*,
136 typedef void (*LPInit)(struct IPerlStdIO*);
137 typedef void (*LPInitOSExtras)(struct IPerlStdIO*);
138 typedef PerlIO* (*LPFdupopen)(struct IPerlStdIO*, PerlIO*);
149 LPClearerr pClearerr;
152 LPGetBufsiz pGetBufsiz;
168 LPSetPtrCnt pSetPtrCnt;
169 LPSetlinebuf pSetlinebuf;
179 LPInitOSExtras pInitOSExtras;
180 LPFdupopen pFdupopen;
183 struct IPerlStdIOInfo
185 unsigned long nCount; /* number of entries expected */
186 struct IPerlStdIO perlStdIOList;
190 # define PerlIO_has_cntptr(f) 1
191 # ifdef STDIO_PTR_LVALUE
192 # ifdef STDIO_CNT_LVALUE
193 # define PerlIO_canset_cnt(f) 1
194 # ifdef STDIO_PTR_LVAL_NOCHANGE_CNT
195 # define PerlIO_fast_gets(f) 1
197 # else /* STDIO_CNT_LVALUE */
198 # define PerlIO_canset_cnt(f) 0
200 # else /* STDIO_PTR_LVALUE */
201 # ifdef STDIO_PTR_LVAL_SETS_CNT
202 # define PerlIO_fast_gets(f) 1
205 #else /* USE_STDIO_PTR */
206 # define PerlIO_has_cntptr(f) 0
207 # define PerlIO_canset_cnt(f) 0
208 #endif /* USE_STDIO_PTR */
210 #ifndef PerlIO_fast_gets
211 #define PerlIO_fast_gets(f) 0
215 #define PerlIO_has_base(f) 1
217 #define PerlIO_has_base(f) 0
220 #define PerlIO_stdin() \
221 (*PL_StdIO->pStdin)(PL_StdIO)
222 #define PerlIO_stdout() \
223 (*PL_StdIO->pStdout)(PL_StdIO)
224 #define PerlIO_stderr() \
225 (*PL_StdIO->pStderr)(PL_StdIO)
226 #define PerlIO_open(x,y) \
227 (*PL_StdIO->pOpen)(PL_StdIO, (x),(y))
228 #define PerlIO_close(f) \
229 (*PL_StdIO->pClose)(PL_StdIO, (f))
230 #define PerlIO_eof(f) \
231 (*PL_StdIO->pEof)(PL_StdIO, (f))
232 #define PerlIO_error(f) \
233 (*PL_StdIO->pError)(PL_StdIO, (f))
234 #define PerlIO_clearerr(f) \
235 (*PL_StdIO->pClearerr)(PL_StdIO, (f))
236 #define PerlIO_getc(f) \
237 (*PL_StdIO->pGetc)(PL_StdIO, (f))
238 #define PerlIO_get_base(f) \
239 (*PL_StdIO->pGetBase)(PL_StdIO, (f))
240 #define PerlIO_get_bufsiz(f) \
241 (*PL_StdIO->pGetBufsiz)(PL_StdIO, (f))
242 #define PerlIO_get_cnt(f) \
243 (*PL_StdIO->pGetCnt)(PL_StdIO, (f))
244 #define PerlIO_get_ptr(f) \
245 (*PL_StdIO->pGetPtr)(PL_StdIO, (f))
246 #define PerlIO_putc(f,c) \
247 (*PL_StdIO->pPutc)(PL_StdIO, (f),(c))
248 #define PerlIO_puts(f,s) \
249 (*PL_StdIO->pPuts)(PL_StdIO, (f),(s))
250 #define PerlIO_flush(f) \
251 (*PL_StdIO->pFlush)(PL_StdIO, (f))
252 #define PerlIO_gets(s, n, fp) \
253 (*PL_StdIO->pGets)(PL_StdIO, (fp), s, n)
254 #define PerlIO_ungetc(f,c) \
255 (*PL_StdIO->pUngetc)(PL_StdIO, (f),(c))
256 #define PerlIO_fileno(f) \
257 (*PL_StdIO->pFileno)(PL_StdIO, (f))
258 #define PerlIO_fdopen(f, s) \
259 (*PL_StdIO->pFdopen)(PL_StdIO, (f),(s))
260 #define PerlIO_reopen(p, m, f) \
261 (*PL_StdIO->pReopen)(PL_StdIO, (p), (m), (f))
262 #define PerlIO_read(f,buf,count) \
263 (SSize_t)(*PL_StdIO->pRead)(PL_StdIO, (f), (buf), (count))
264 #define PerlIO_write(f,buf,count) \
265 (*PL_StdIO->pWrite)(PL_StdIO, (f), (buf), (count))
266 #define PerlIO_setbuf(f,b) \
267 (*PL_StdIO->pSetBuf)(PL_StdIO, (f), (b))
268 #define PerlIO_setvbuf(f,b,t,s) \
269 (*PL_StdIO->pSetVBuf)(PL_StdIO, (f),(b),(t),(s))
270 #define PerlIO_set_cnt(f,c) \
271 (*PL_StdIO->pSetCnt)(PL_StdIO, (f), (c))
272 #define PerlIO_set_ptrcnt(f,p,c) \
273 (*PL_StdIO->pSetPtrCnt)(PL_StdIO, (f), (p), (c))
274 #define PerlIO_setlinebuf(f) \
275 (*PL_StdIO->pSetlinebuf)(PL_StdIO, (f))
276 #define PerlIO_printf Perl_fprintf_nocontext
277 #define PerlIO_stdoutf *PL_StdIO->pPrintf
278 #define PerlIO_vprintf(f,fmt,a) \
279 (*PL_StdIO->pVprintf)(PL_StdIO, (f),(fmt),a)
280 #define PerlIO_tell(f) \
281 (*PL_StdIO->pTell)(PL_StdIO, (f))
282 #define PerlIO_seek(f,o,w) \
283 (*PL_StdIO->pSeek)(PL_StdIO, (f),(o),(w))
284 #define PerlIO_getpos(f,p) \
285 (*PL_StdIO->pGetpos)(PL_StdIO, (f),(p))
286 #define PerlIO_setpos(f,p) \
287 (*PL_StdIO->pSetpos)(PL_StdIO, (f),(p))
288 #define PerlIO_rewind(f) \
289 (*PL_StdIO->pRewind)(PL_StdIO, (f))
290 #define PerlIO_tmpfile() \
291 (*PL_StdIO->pTmpfile)(PL_StdIO)
292 #define PerlIO_init() \
293 (*PL_StdIO->pInit)(PL_StdIO)
294 #undef init_os_extras
295 #define init_os_extras() \
296 (*PL_StdIO->pInitOSExtras)(PL_StdIO)
297 #define PerlIO_fdupopen(f) \
298 (*PL_StdIO->pFdupopen)(PL_StdIO, (f))
300 #else /* PERL_IMPLICIT_SYS */
302 #include "perlsdio.h"
304 #define PerlIO_fdupopen(f) (f)
306 #endif /* PERL_IMPLICIT_SYS */
308 #ifndef PERLIO_IS_STDIO
310 #include "perlsfio.h"
311 #endif /* USE_SFIO */
312 #endif /* PERLIO_IS_STDIO */
318 /* This is to catch case with no stdio */
336 typedef struct _PerlIO PerlIOl;
337 typedef PerlIOl *PerlIO;
338 #define PerlIO PerlIO
339 #endif /* No PerlIO */
345 #ifndef NEXT30_NO_ATTRIBUTE
346 #ifndef HASATTRIBUTE /* disable GNU-cc attribute checking? */
347 #ifdef __attribute__ /* Avoid possible redefinition errors */
350 #define __attribute__(attr)
354 #ifndef PerlIO_stdoutf
355 extern int PerlIO_stdoutf (const char *,...)
356 __attribute__((__format__ (__printf__, 1, 2)));
359 extern int PerlIO_puts (PerlIO *,const char *);
362 extern PerlIO * PerlIO_open (const char *,const char *);
365 extern int PerlIO_close (PerlIO *);
368 extern int PerlIO_eof (PerlIO *);
371 extern int PerlIO_error (PerlIO *);
373 #ifndef PerlIO_clearerr
374 extern void PerlIO_clearerr (PerlIO *);
377 extern int PerlIO_getc (PerlIO *);
380 extern int PerlIO_putc (PerlIO *,int);
383 extern int PerlIO_flush (PerlIO *);
385 #ifndef PerlIO_ungetc
386 extern int PerlIO_ungetc (PerlIO *,int);
388 #ifndef PerlIO_fileno
389 extern int PerlIO_fileno (PerlIO *);
391 #ifndef PerlIO_fdopen
392 extern PerlIO * PerlIO_fdopen (int, const char *);
394 #ifndef PerlIO_importFILE
395 extern PerlIO * PerlIO_importFILE (FILE *,int);
397 #ifndef PerlIO_exportFILE
398 extern FILE * PerlIO_exportFILE (PerlIO *,int);
400 #ifndef PerlIO_findFILE
401 extern FILE * PerlIO_findFILE (PerlIO *);
403 #ifndef PerlIO_releaseFILE
404 extern void PerlIO_releaseFILE (PerlIO *,FILE *);
407 extern SSize_t PerlIO_read (PerlIO *,void *,Size_t);
410 extern SSize_t PerlIO_write (PerlIO *,const void *,Size_t);
412 #ifndef PerlIO_setlinebuf
413 extern void PerlIO_setlinebuf (PerlIO *);
415 #ifndef PerlIO_printf
416 extern int PerlIO_printf (PerlIO *, const char *,...)
417 __attribute__((__format__ (__printf__, 2, 3)));
419 #ifndef PerlIO_sprintf
420 extern int PerlIO_sprintf (char *, int, const char *,...)
421 __attribute__((__format__ (__printf__, 3, 4)));
423 #ifndef PerlIO_vprintf
424 extern int PerlIO_vprintf (PerlIO *, const char *, va_list);
427 extern Off_t PerlIO_tell (PerlIO *);
430 extern int PerlIO_seek (PerlIO *, Off_t, int);
432 #ifndef PerlIO_rewind
433 extern void PerlIO_rewind (PerlIO *);
435 #ifndef PerlIO_has_base
436 extern int PerlIO_has_base (PerlIO *);
438 #ifndef PerlIO_has_cntptr
439 extern int PerlIO_has_cntptr (PerlIO *);
441 #ifndef PerlIO_fast_gets
442 extern int PerlIO_fast_gets (PerlIO *);
444 #ifndef PerlIO_canset_cnt
445 extern int PerlIO_canset_cnt (PerlIO *);
447 #ifndef PerlIO_get_ptr
448 extern STDCHAR * PerlIO_get_ptr (PerlIO *);
450 #ifndef PerlIO_get_cnt
451 extern int PerlIO_get_cnt (PerlIO *);
453 #ifndef PerlIO_set_cnt
454 extern void PerlIO_set_cnt (PerlIO *,int);
456 #ifndef PerlIO_set_ptrcnt
457 extern void PerlIO_set_ptrcnt (PerlIO *,STDCHAR *,int);
459 #ifndef PerlIO_get_base
460 extern STDCHAR * PerlIO_get_base (PerlIO *);
462 #ifndef PerlIO_get_bufsiz
463 extern int PerlIO_get_bufsiz (PerlIO *);
465 #ifndef PerlIO_tmpfile
466 extern PerlIO * PerlIO_tmpfile (void);
469 extern PerlIO * PerlIO_stdin (void);
471 #ifndef PerlIO_stdout
472 extern PerlIO * PerlIO_stdout (void);
474 #ifndef PerlIO_stderr
475 extern PerlIO * PerlIO_stderr (void);
477 #ifndef PerlIO_getpos
478 extern int PerlIO_getpos (PerlIO *,Fpos_t *);
480 #ifndef PerlIO_setpos
481 extern int PerlIO_setpos (PerlIO *,const Fpos_t *);
483 #ifndef PerlIO_fdupopen
484 extern PerlIO * PerlIO_fdupopen (PerlIO *);
489 * Interface for directory functions
492 #if defined(PERL_IMPLICIT_SYS)
497 typedef int (*LPMakedir)(struct IPerlDir*, const char*, int);
498 typedef int (*LPChdir)(struct IPerlDir*, const char*);
499 typedef int (*LPRmdir)(struct IPerlDir*, const char*);
500 typedef int (*LPDirClose)(struct IPerlDir*, DIR*);
501 typedef DIR* (*LPDirOpen)(struct IPerlDir*, char*);
502 typedef struct direct* (*LPDirRead)(struct IPerlDir*, DIR*);
503 typedef void (*LPDirRewind)(struct IPerlDir*, DIR*);
504 typedef void (*LPDirSeek)(struct IPerlDir*, DIR*, long);
505 typedef long (*LPDirTell)(struct IPerlDir*, DIR*);
507 typedef char* (*LPDirMapPathA)(struct IPerlDir*, const char*);
508 typedef WCHAR* (*LPDirMapPathW)(struct IPerlDir*, const WCHAR*);
523 LPDirMapPathA pMapPathA;
524 LPDirMapPathW pMapPathW;
530 unsigned long nCount; /* number of entries expected */
531 struct IPerlDir perlDirList;
534 #define PerlDir_mkdir(name, mode) \
535 (*PL_Dir->pMakedir)(PL_Dir, (name), (mode))
536 #define PerlDir_chdir(name) \
537 (*PL_Dir->pChdir)(PL_Dir, (name))
538 #define PerlDir_rmdir(name) \
539 (*PL_Dir->pRmdir)(PL_Dir, (name))
540 #define PerlDir_close(dir) \
541 (*PL_Dir->pClose)(PL_Dir, (dir))
542 #define PerlDir_open(name) \
543 (*PL_Dir->pOpen)(PL_Dir, (name))
544 #define PerlDir_read(dir) \
545 (*PL_Dir->pRead)(PL_Dir, (dir))
546 #define PerlDir_rewind(dir) \
547 (*PL_Dir->pRewind)(PL_Dir, (dir))
548 #define PerlDir_seek(dir, loc) \
549 (*PL_Dir->pSeek)(PL_Dir, (dir), (loc))
550 #define PerlDir_tell(dir) \
551 (*PL_Dir->pTell)(PL_Dir, (dir))
553 #define PerlDir_mapA(dir) \
554 (*PL_Dir->pMapPathA)(PL_Dir, (dir))
555 #define PerlDir_mapW(dir) \
556 (*PL_Dir->pMapPathW)(PL_Dir, (dir))
559 #else /* PERL_IMPLICIT_SYS */
561 #define PerlDir_mkdir(name, mode) Mkdir((name), (mode))
563 # define PerlDir_chdir(n) Chdir(((n) && *(n)) ? (n) : "SYS$LOGIN")
565 # define PerlDir_chdir(name) chdir((name))
567 #define PerlDir_rmdir(name) rmdir((name))
568 #define PerlDir_close(dir) closedir((dir))
569 #define PerlDir_open(name) opendir((name))
570 #define PerlDir_read(dir) readdir((dir))
571 #define PerlDir_rewind(dir) rewinddir((dir))
572 #define PerlDir_seek(dir, loc) seekdir((dir), (loc))
573 #define PerlDir_tell(dir) telldir((dir))
575 #define PerlDir_mapA(dir) dir
576 #define PerlDir_mapW(dir) dir
579 #endif /* PERL_IMPLICIT_SYS */
582 Interface for perl environment functions
585 #if defined(PERL_IMPLICIT_SYS)
590 typedef char* (*LPEnvGetenv)(struct IPerlEnv*, const char*);
591 typedef int (*LPEnvPutenv)(struct IPerlEnv*, const char*);
592 typedef char* (*LPEnvGetenv_len)(struct IPerlEnv*,
593 const char *varname, unsigned long *len);
594 typedef int (*LPEnvUname)(struct IPerlEnv*, struct utsname *name);
595 typedef void (*LPEnvClearenv)(struct IPerlEnv*);
596 typedef void* (*LPEnvGetChildenv)(struct IPerlEnv*);
597 typedef void (*LPEnvFreeChildenv)(struct IPerlEnv*, void* env);
598 typedef char* (*LPEnvGetChilddir)(struct IPerlEnv*);
599 typedef void (*LPEnvFreeChilddir)(struct IPerlEnv*, char* dir);
601 typedef char* (*LPENVGetenv)(struct IPerlEnv*, const char *varname);
602 typedef char* (*LPENVGetenv_len)(struct IPerlEnv*,
603 const char *varname, unsigned long *len);
606 typedef unsigned long (*LPEnvOsID)(struct IPerlEnv*);
607 typedef char* (*LPEnvLibPath)(struct IPerlEnv*, const char*);
608 typedef char* (*LPEnvSiteLibPath)(struct IPerlEnv*, const char*);
609 typedef char* (*LPEnvVendorLibPath)(struct IPerlEnv*, const char*);
610 typedef void (*LPEnvGetChildIO)(struct IPerlEnv*, child_IO_table*);
617 LPEnvGetenv_len pGetenv_len;
618 LPEnvUname pEnvUname;
619 LPEnvClearenv pClearenv;
620 LPEnvGetChildenv pGetChildenv;
621 LPEnvFreeChildenv pFreeChildenv;
622 LPEnvGetChilddir pGetChilddir;
623 LPEnvFreeChilddir pFreeChilddir;
625 LPENVGetenv pENVGetenv;
626 LPENVGetenv_len pENVGetenv_len;
630 LPEnvLibPath pLibPath;
631 LPEnvSiteLibPath pSiteLibPath;
632 LPEnvVendorLibPath pVendorLibPath;
633 LPEnvGetChildIO pGetChildIO;
639 unsigned long nCount; /* number of entries expected */
640 struct IPerlEnv perlEnvList;
643 #define PerlEnv_putenv(str) \
644 (*PL_Env->pPutenv)(PL_Env,(str))
645 #define PerlEnv_getenv(str) \
646 (*PL_Env->pGetenv)(PL_Env,(str))
647 #define PerlEnv_getenv_len(str,l) \
648 (*PL_Env->pGetenv_len)(PL_Env,(str), (l))
649 #define PerlEnv_clearenv() \
650 (*PL_Env->pClearenv)(PL_Env)
651 #define PerlEnv_get_childenv() \
652 (*PL_Env->pGetChildenv)(PL_Env)
653 #define PerlEnv_free_childenv(e) \
654 (*PL_Env->pFreeChildenv)(PL_Env, (e))
655 #define PerlEnv_get_childdir() \
656 (*PL_Env->pGetChilddir)(PL_Env)
657 #define PerlEnv_free_childdir(d) \
658 (*PL_Env->pFreeChilddir)(PL_Env, (d))
660 # define PerlEnv_ENVgetenv(str) \
661 (*PL_Env->pENVGetenv)(PL_Env,(str))
662 # define PerlEnv_ENVgetenv_len(str,l) \
663 (*PL_Env->pENVGetenv_len)(PL_Env,(str), (l))
665 # define PerlEnv_ENVgetenv(str) \
666 PerlEnv_getenv((str))
667 # define PerlEnv_ENVgetenv_len(str,l) \
668 PerlEnv_getenv_len((str),(l))
670 #define PerlEnv_uname(name) \
671 (*PL_Env->pEnvUname)(PL_Env,(name))
673 #define PerlEnv_os_id() \
674 (*PL_Env->pEnvOsID)(PL_Env)
675 #define PerlEnv_lib_path(str) \
676 (*PL_Env->pLibPath)(PL_Env,(str))
677 #define PerlEnv_sitelib_path(str) \
678 (*PL_Env->pSiteLibPath)(PL_Env,(str))
679 #define PerlEnv_vendorlib_path(str) \
680 (*PL_Env->pVendorLibPath)(PL_Env,(str))
681 #define PerlEnv_get_child_IO(ptr) \
682 (*PL_Env->pGetChildIO)(PL_Env, ptr)
685 #else /* PERL_IMPLICIT_SYS */
687 #define PerlEnv_putenv(str) putenv((str))
688 #define PerlEnv_getenv(str) getenv((str))
689 #define PerlEnv_getenv_len(str,l) getenv_len((str), (l))
690 #define PerlEnv_clearenv() clearenv()
691 #define PerlEnv_get_childenv() get_childenv()
692 #define PerlEnv_free_childenv(e) free_childenv((e))
693 #define PerlEnv_get_childdir() get_childdir()
694 #define PerlEnv_free_childdir(d) free_childdir((d))
696 # define PerlEnv_ENVgetenv(str) ENVgetenv((str))
697 # define PerlEnv_ENVgetenv_len(str,l) ENVgetenv_len((str), (l))
699 # define PerlEnv_ENVgetenv(str) PerlEnv_getenv((str))
700 # define PerlEnv_ENVgetenv_len(str,l) PerlEnv_getenv_len((str), (l))
702 #define PerlEnv_uname(name) uname((name))
705 #define PerlEnv_os_id() win32_os_id()
706 #define PerlEnv_lib_path(str) win32_get_privlib(str)
707 #define PerlEnv_sitelib_path(str) win32_get_sitelib(str)
708 #define PerlEnv_vendorlib_path(str) win32_get_vendorlib(str)
709 #define PerlEnv_get_child_IO(ptr) win32_get_child_IO(ptr)
712 #endif /* PERL_IMPLICIT_SYS */
715 Interface for perl low-level IO functions
718 #if defined(PERL_IMPLICIT_SYS)
723 typedef int (*LPLIOAccess)(struct IPerlLIO*, const char*, int);
724 typedef int (*LPLIOChmod)(struct IPerlLIO*, const char*, int);
725 typedef int (*LPLIOChown)(struct IPerlLIO*, const char*, uid_t,
727 typedef int (*LPLIOChsize)(struct IPerlLIO*, int, long);
728 typedef int (*LPLIOClose)(struct IPerlLIO*, int);
729 typedef int (*LPLIODup)(struct IPerlLIO*, int);
730 typedef int (*LPLIODup2)(struct IPerlLIO*, int, int);
731 typedef int (*LPLIOFlock)(struct IPerlLIO*, int, int);
732 typedef int (*LPLIOFileStat)(struct IPerlLIO*, int, struct stat*);
733 typedef int (*LPLIOIOCtl)(struct IPerlLIO*, int, unsigned int,
735 typedef int (*LPLIOIsatty)(struct IPerlLIO*, int);
736 typedef int (*LPLIOLink)(struct IPerlLIO*, const char*,
738 typedef long (*LPLIOLseek)(struct IPerlLIO*, int, long, int);
739 typedef int (*LPLIOLstat)(struct IPerlLIO*, const char*,
741 typedef char* (*LPLIOMktemp)(struct IPerlLIO*, char*);
742 typedef int (*LPLIOOpen)(struct IPerlLIO*, const char*, int);
743 typedef int (*LPLIOOpen3)(struct IPerlLIO*, const char*, int, int);
744 typedef int (*LPLIORead)(struct IPerlLIO*, int, void*, unsigned int);
745 typedef int (*LPLIORename)(struct IPerlLIO*, const char*,
747 typedef int (*LPLIOSetmode)(struct IPerlLIO*, int, int);
748 typedef int (*LPLIONameStat)(struct IPerlLIO*, const char*,
750 typedef char* (*LPLIOTmpnam)(struct IPerlLIO*, char*);
751 typedef int (*LPLIOUmask)(struct IPerlLIO*, int);
752 typedef int (*LPLIOUnlink)(struct IPerlLIO*, const char*);
753 typedef int (*LPLIOUtime)(struct IPerlLIO*, char*, struct utimbuf*);
754 typedef int (*LPLIOWrite)(struct IPerlLIO*, int, const void*,
767 LPLIOFileStat pFileStat;
778 LPLIOSetmode pSetmode;
779 LPLIONameStat pNameStat;
789 unsigned long nCount; /* number of entries expected */
790 struct IPerlLIO perlLIOList;
793 #define PerlLIO_access(file, mode) \
794 (*PL_LIO->pAccess)(PL_LIO, (file), (mode))
795 #define PerlLIO_chmod(file, mode) \
796 (*PL_LIO->pChmod)(PL_LIO, (file), (mode))
797 #define PerlLIO_chown(file, owner, group) \
798 (*PL_LIO->pChown)(PL_LIO, (file), (owner), (group))
799 #define PerlLIO_chsize(fd, size) \
800 (*PL_LIO->pChsize)(PL_LIO, (fd), (size))
801 #define PerlLIO_close(fd) \
802 (*PL_LIO->pClose)(PL_LIO, (fd))
803 #define PerlLIO_dup(fd) \
804 (*PL_LIO->pDup)(PL_LIO, (fd))
805 #define PerlLIO_dup2(fd1, fd2) \
806 (*PL_LIO->pDup2)(PL_LIO, (fd1), (fd2))
807 #define PerlLIO_flock(fd, op) \
808 (*PL_LIO->pFlock)(PL_LIO, (fd), (op))
809 #define PerlLIO_fstat(fd, buf) \
810 (*PL_LIO->pFileStat)(PL_LIO, (fd), (buf))
811 #define PerlLIO_ioctl(fd, u, buf) \
812 (*PL_LIO->pIOCtl)(PL_LIO, (fd), (u), (buf))
813 #define PerlLIO_isatty(fd) \
814 (*PL_LIO->pIsatty)(PL_LIO, (fd))
815 #define PerlLIO_link(oldname, newname) \
816 (*PL_LIO->pLink)(PL_LIO, (oldname), (newname))
817 #define PerlLIO_lseek(fd, offset, mode) \
818 (*PL_LIO->pLseek)(PL_LIO, (fd), (offset), (mode))
819 #define PerlLIO_lstat(name, buf) \
820 (*PL_LIO->pLstat)(PL_LIO, (name), (buf))
821 #define PerlLIO_mktemp(file) \
822 (*PL_LIO->pMktemp)(PL_LIO, (file))
823 #define PerlLIO_open(file, flag) \
824 (*PL_LIO->pOpen)(PL_LIO, (file), (flag))
825 #define PerlLIO_open3(file, flag, perm) \
826 (*PL_LIO->pOpen3)(PL_LIO, (file), (flag), (perm))
827 #define PerlLIO_read(fd, buf, count) \
828 (*PL_LIO->pRead)(PL_LIO, (fd), (buf), (count))
829 #define PerlLIO_rename(oname, newname) \
830 (*PL_LIO->pRename)(PL_LIO, (oname), (newname))
831 #define PerlLIO_setmode(fd, mode) \
832 (*PL_LIO->pSetmode)(PL_LIO, (fd), (mode))
833 #define PerlLIO_stat(name, buf) \
834 (*PL_LIO->pNameStat)(PL_LIO, (name), (buf))
835 #define PerlLIO_tmpnam(str) \
836 (*PL_LIO->pTmpnam)(PL_LIO, (str))
837 #define PerlLIO_umask(mode) \
838 (*PL_LIO->pUmask)(PL_LIO, (mode))
839 #define PerlLIO_unlink(file) \
840 (*PL_LIO->pUnlink)(PL_LIO, (file))
841 #define PerlLIO_utime(file, time) \
842 (*PL_LIO->pUtime)(PL_LIO, (file), (time))
843 #define PerlLIO_write(fd, buf, count) \
844 (*PL_LIO->pWrite)(PL_LIO, (fd), (buf), (count))
846 #else /* PERL_IMPLICIT_SYS */
848 #define PerlLIO_access(file, mode) access((file), (mode))
849 #define PerlLIO_chmod(file, mode) chmod((file), (mode))
850 #define PerlLIO_chown(file, owner, grp) chown((file), (owner), (grp))
851 #define PerlLIO_chsize(fd, size) chsize((fd), (size))
852 #define PerlLIO_close(fd) close((fd))
853 #define PerlLIO_dup(fd) dup((fd))
854 #define PerlLIO_dup2(fd1, fd2) dup2((fd1), (fd2))
855 #define PerlLIO_flock(fd, op) FLOCK((fd), (op))
856 #define PerlLIO_fstat(fd, buf) Fstat((fd), (buf))
857 #define PerlLIO_ioctl(fd, u, buf) ioctl((fd), (u), (buf))
858 #define PerlLIO_isatty(fd) isatty((fd))
859 #define PerlLIO_link(oldname, newname) link((oldname), (newname))
860 #define PerlLIO_lseek(fd, offset, mode) lseek((fd), (offset), (mode))
861 #define PerlLIO_stat(name, buf) Stat((name), (buf))
863 # define PerlLIO_lstat(name, buf) lstat((name), (buf))
865 # define PerlLIO_lstat(name, buf) PerlLIO_stat((name), (buf))
867 #define PerlLIO_mktemp(file) mktemp((file))
868 #define PerlLIO_mkstemp(file) mkstemp((file))
869 #define PerlLIO_open(file, flag) open((file), (flag))
870 #define PerlLIO_open3(file, flag, perm) open((file), (flag), (perm))
871 #define PerlLIO_read(fd, buf, count) read((fd), (buf), (count))
872 #define PerlLIO_rename(old, new) rename((old), (new))
873 #define PerlLIO_setmode(fd, mode) setmode((fd), (mode))
874 #define PerlLIO_tmpnam(str) tmpnam((str))
875 #define PerlLIO_umask(mode) umask((mode))
876 #define PerlLIO_unlink(file) unlink((file))
877 #define PerlLIO_utime(file, time) utime((file), (time))
878 #define PerlLIO_write(fd, buf, count) write((fd), (buf), (count))
880 #endif /* PERL_IMPLICIT_SYS */
883 Interface for perl memory allocation
886 #if defined(PERL_IMPLICIT_SYS)
891 typedef void* (*LPMemMalloc)(struct IPerlMem*, size_t);
892 typedef void* (*LPMemRealloc)(struct IPerlMem*, void*, size_t);
893 typedef void (*LPMemFree)(struct IPerlMem*, void*);
894 typedef void* (*LPMemCalloc)(struct IPerlMem*, size_t, size_t);
895 typedef void (*LPMemGetLock)(struct IPerlMem*);
896 typedef void (*LPMemFreeLock)(struct IPerlMem*);
897 typedef int (*LPMemIsLocked)(struct IPerlMem*);
902 LPMemRealloc pRealloc;
905 LPMemGetLock pGetLock;
906 LPMemFreeLock pFreeLock;
907 LPMemIsLocked pIsLocked;
912 unsigned long nCount; /* number of entries expected */
913 struct IPerlMem perlMemList;
916 /* Interpreter specific memory macros */
917 #define PerlMem_malloc(size) \
918 (*PL_Mem->pMalloc)(PL_Mem, (size))
919 #define PerlMem_realloc(buf, size) \
920 (*PL_Mem->pRealloc)(PL_Mem, (buf), (size))
921 #define PerlMem_free(buf) \
922 (*PL_Mem->pFree)(PL_Mem, (buf))
923 #define PerlMem_calloc(num, size) \
924 (*PL_Mem->pCalloc)(PL_Mem, (num), (size))
925 #define PerlMem_get_lock() \
926 (*PL_Mem->pGetLock)(PL_Mem)
927 #define PerlMem_free_lock() \
928 (*PL_Mem->pFreeLock)(PL_Mem)
929 #define PerlMem_is_locked() \
930 (*PL_Mem->pIsLocked)(PL_Mem)
932 /* Shared memory macros */
933 #define PerlMemShared_malloc(size) \
934 (*PL_MemShared->pMalloc)(PL_Mem, (size))
935 #define PerlMemShared_realloc(buf, size) \
936 (*PL_MemShared->pRealloc)(PL_Mem, (buf), (size))
937 #define PerlMemShared_free(buf) \
938 (*PL_MemShared->pFree)(PL_Mem, (buf))
939 #define PerlMemShared_calloc(num, size) \
940 (*PL_MemShared->pCalloc)(PL_Mem, (num), (size))
941 #define PerlMemShared_get_lock() \
942 (*PL_MemShared->pGetLock)(PL_Mem)
943 #define PerlMemShared_free_lock() \
944 (*PL_MemShared->pFreeLock)(PL_Mem)
945 #define PerlMemShared_is_locked() \
946 (*PL_MemShared->pIsLocked)(PL_Mem)
949 /* Parse tree memory macros */
950 #define PerlMemParse_malloc(size) \
951 (*PL_MemParse->pMalloc)(PL_Mem, (size))
952 #define PerlMemParse_realloc(buf, size) \
953 (*PL_MemParse->pRealloc)(PL_Mem, (buf), (size))
954 #define PerlMemParse_free(buf) \
955 (*PL_MemParse->pFree)(PL_Mem, (buf))
956 #define PerlMemParse_calloc(num, size) \
957 (*PL_MemParse->pCalloc)(PL_Mem, (num), (size))
958 #define PerlMemParse_get_lock() \
959 (*PL_MemParse->pGetLock)(PL_Mem)
960 #define PerlMemParse_free_lock() \
961 (*PL_MemParse->pFreeLock)(PL_Mem)
962 #define PerlMemParse_is_locked() \
963 (*PL_MemParse->pIsLocked)(PL_Mem)
966 #else /* PERL_IMPLICIT_SYS */
968 /* Interpreter specific memory macros */
969 #define PerlMem_malloc(size) malloc((size))
970 #define PerlMem_realloc(buf, size) realloc((buf), (size))
971 #define PerlMem_free(buf) free((buf))
972 #define PerlMem_calloc(num, size) calloc((num), (size))
973 #define PerlMem_get_lock()
974 #define PerlMem_free_lock()
975 #define PerlMem_is_locked() 0
977 /* Shared memory macros */
978 #define PerlMemShared_malloc(size) malloc((size))
979 #define PerlMemShared_realloc(buf, size) realloc((buf), (size))
980 #define PerlMemShared_free(buf) free((buf))
981 #define PerlMemShared_calloc(num, size) calloc((num), (size))
982 #define PerlMemShared_get_lock()
983 #define PerlMemShared_free_lock()
984 #define PerlMemShared_is_locked() 0
986 /* Parse tree memory macros */
987 #define PerlMemParse_malloc(size) malloc((size))
988 #define PerlMemParse_realloc(buf, size) realloc((buf), (size))
989 #define PerlMemParse_free(buf) free((buf))
990 #define PerlMemParse_calloc(num, size) calloc((num), (size))
991 #define PerlMemParse_get_lock()
992 #define PerlMemParse_free_lock()
993 #define PerlMemParse_is_locked() 0
995 #endif /* PERL_IMPLICIT_SYS */
998 Interface for perl process functions
1002 #if defined(PERL_IMPLICIT_SYS)
1010 struct IPerlProcInfo;
1011 typedef void (*LPProcAbort)(struct IPerlProc*);
1012 typedef char* (*LPProcCrypt)(struct IPerlProc*, const char*,
1014 typedef void (*LPProcExit)(struct IPerlProc*, int);
1015 typedef void (*LPProc_Exit)(struct IPerlProc*, int);
1016 typedef int (*LPProcExecl)(struct IPerlProc*, const char*,
1017 const char*, const char*, const char*,
1019 typedef int (*LPProcExecv)(struct IPerlProc*, const char*,
1021 typedef int (*LPProcExecvp)(struct IPerlProc*, const char*,
1023 typedef uid_t (*LPProcGetuid)(struct IPerlProc*);
1024 typedef uid_t (*LPProcGeteuid)(struct IPerlProc*);
1025 typedef gid_t (*LPProcGetgid)(struct IPerlProc*);
1026 typedef gid_t (*LPProcGetegid)(struct IPerlProc*);
1027 typedef char* (*LPProcGetlogin)(struct IPerlProc*);
1028 typedef int (*LPProcKill)(struct IPerlProc*, int, int);
1029 typedef int (*LPProcKillpg)(struct IPerlProc*, int, int);
1030 typedef int (*LPProcPauseProc)(struct IPerlProc*);
1031 typedef PerlIO* (*LPProcPopen)(struct IPerlProc*, const char*,
1033 typedef int (*LPProcPclose)(struct IPerlProc*, PerlIO*);
1034 typedef int (*LPProcPipe)(struct IPerlProc*, int*);
1035 typedef int (*LPProcSetuid)(struct IPerlProc*, uid_t);
1036 typedef int (*LPProcSetgid)(struct IPerlProc*, gid_t);
1037 typedef int (*LPProcSleep)(struct IPerlProc*, unsigned int);
1038 typedef int (*LPProcTimes)(struct IPerlProc*, struct tms*);
1039 typedef int (*LPProcWait)(struct IPerlProc*, int*);
1040 typedef int (*LPProcWaitpid)(struct IPerlProc*, int, int*, int);
1041 typedef Sighandler_t (*LPProcSignal)(struct IPerlProc*, int, Sighandler_t);
1042 typedef int (*LPProcFork)(struct IPerlProc*);
1043 typedef int (*LPProcGetpid)(struct IPerlProc*);
1045 typedef void* (*LPProcDynaLoader)(struct IPerlProc*, const char*);
1046 typedef void (*LPProcGetOSError)(struct IPerlProc*,
1047 SV* sv, DWORD dwErr);
1048 typedef void (*LPProcFreeBuf)(struct IPerlProc*, char*);
1049 typedef BOOL (*LPProcDoCmd)(struct IPerlProc*, char*);
1050 typedef int (*LPProcSpawn)(struct IPerlProc*, char*);
1051 typedef int (*LPProcSpawnvp)(struct IPerlProc*, int, const char*,
1053 typedef int (*LPProcASpawn)(struct IPerlProc*, void*, void**, void**);
1064 LPProcExecvp pExecvp;
1065 LPProcGetuid pGetuid;
1066 LPProcGeteuid pGeteuid;
1067 LPProcGetgid pGetgid;
1068 LPProcGetegid pGetegid;
1069 LPProcGetlogin pGetlogin;
1071 LPProcKillpg pKillpg;
1072 LPProcPauseProc pPauseProc;
1074 LPProcPclose pPclose;
1076 LPProcSetuid pSetuid;
1077 LPProcSetgid pSetgid;
1081 LPProcWaitpid pWaitpid;
1082 LPProcSignal pSignal;
1084 LPProcGetpid pGetpid;
1086 LPProcDynaLoader pDynaLoader;
1087 LPProcGetOSError pGetOSError;
1090 LPProcSpawnvp pSpawnvp;
1091 LPProcASpawn pASpawn;
1095 struct IPerlProcInfo
1097 unsigned long nCount; /* number of entries expected */
1098 struct IPerlProc perlProcList;
1101 #define PerlProc_abort() \
1102 (*PL_Proc->pAbort)(PL_Proc)
1103 #define PerlProc_crypt(c,s) \
1104 (*PL_Proc->pCrypt)(PL_Proc, (c), (s))
1105 #define PerlProc_exit(s) \
1106 (*PL_Proc->pExit)(PL_Proc, (s))
1107 #define PerlProc__exit(s) \
1108 (*PL_Proc->p_Exit)(PL_Proc, (s))
1109 #define PerlProc_execl(c, w, x, y, z) \
1110 (*PL_Proc->pExecl)(PL_Proc, (c), (w), (x), (y), (z))
1111 #define PerlProc_execv(c, a) \
1112 (*PL_Proc->pExecv)(PL_Proc, (c), (a))
1113 #define PerlProc_execvp(c, a) \
1114 (*PL_Proc->pExecvp)(PL_Proc, (c), (a))
1115 #define PerlProc_getuid() \
1116 (*PL_Proc->pGetuid)(PL_Proc)
1117 #define PerlProc_geteuid() \
1118 (*PL_Proc->pGeteuid)(PL_Proc)
1119 #define PerlProc_getgid() \
1120 (*PL_Proc->pGetgid)(PL_Proc)
1121 #define PerlProc_getegid() \
1122 (*PL_Proc->pGetegid)(PL_Proc)
1123 #define PerlProc_getlogin() \
1124 (*PL_Proc->pGetlogin)(PL_Proc)
1125 #define PerlProc_kill(i, a) \
1126 (*PL_Proc->pKill)(PL_Proc, (i), (a))
1127 #define PerlProc_killpg(i, a) \
1128 (*PL_Proc->pKillpg)(PL_Proc, (i), (a))
1129 #define PerlProc_pause() \
1130 (*PL_Proc->pPauseProc)(PL_Proc)
1131 #define PerlProc_popen(c, m) \
1132 (*PL_Proc->pPopen)(PL_Proc, (c), (m))
1133 #define PerlProc_pclose(f) \
1134 (*PL_Proc->pPclose)(PL_Proc, (f))
1135 #define PerlProc_pipe(fd) \
1136 (*PL_Proc->pPipe)(PL_Proc, (fd))
1137 #define PerlProc_setuid(u) \
1138 (*PL_Proc->pSetuid)(PL_Proc, (u))
1139 #define PerlProc_setgid(g) \
1140 (*PL_Proc->pSetgid)(PL_Proc, (g))
1141 #define PerlProc_sleep(t) \
1142 (*PL_Proc->pSleep)(PL_Proc, (t))
1143 #define PerlProc_times(t) \
1144 (*PL_Proc->pTimes)(PL_Proc, (t))
1145 #define PerlProc_wait(t) \
1146 (*PL_Proc->pWait)(PL_Proc, (t))
1147 #define PerlProc_waitpid(p,s,f) \
1148 (*PL_Proc->pWaitpid)(PL_Proc, (p), (s), (f))
1149 #define PerlProc_signal(n, h) \
1150 (*PL_Proc->pSignal)(PL_Proc, (n), (h))
1151 #define PerlProc_fork() \
1152 (*PL_Proc->pFork)(PL_Proc)
1153 #define PerlProc_getpid() \
1154 (*PL_Proc->pGetpid)(PL_Proc)
1155 #define PerlProc_setjmp(b, n) Sigsetjmp((b), (n))
1156 #define PerlProc_longjmp(b, n) Siglongjmp((b), (n))
1159 #define PerlProc_DynaLoad(f) \
1160 (*PL_Proc->pDynaLoader)(PL_Proc, (f))
1161 #define PerlProc_GetOSError(s,e) \
1162 (*PL_Proc->pGetOSError)(PL_Proc, (s), (e))
1163 #define PerlProc_Cmd(s) \
1164 (*PL_Proc->pDoCmd)(PL_Proc, (s))
1165 #define do_spawn(s) \
1166 (*PL_Proc->pSpawn)(PL_Proc, (s))
1167 #define do_spawnvp(m, c, a) \
1168 (*PL_Proc->pSpawnvp)(PL_Proc, (m), (c), (a))
1169 #define PerlProc_aspawn(m,c,a) \
1170 (*PL_Proc->pASpawn)(PL_Proc, (m), (c), (a))
1173 #else /* PERL_IMPLICIT_SYS */
1175 #define PerlProc_abort() abort()
1176 #define PerlProc_crypt(c,s) crypt((c), (s))
1177 #define PerlProc_exit(s) exit((s))
1178 #define PerlProc__exit(s) _exit((s))
1179 #define PerlProc_execl(c,w,x,y,z) \
1180 execl((c), (w), (x), (y), (z))
1181 #define PerlProc_execv(c, a) execv((c), (a))
1182 #define PerlProc_execvp(c, a) execvp((c), (a))
1183 #define PerlProc_getuid() getuid()
1184 #define PerlProc_geteuid() geteuid()
1185 #define PerlProc_getgid() getgid()
1186 #define PerlProc_getegid() getegid()
1187 #define PerlProc_getlogin() getlogin()
1188 #define PerlProc_kill(i, a) kill((i), (a))
1189 #define PerlProc_killpg(i, a) killpg((i), (a))
1190 #define PerlProc_pause() Pause()
1191 #define PerlProc_popen(c, m) my_popen((c), (m))
1192 #define PerlProc_pclose(f) my_pclose((f))
1193 #define PerlProc_pipe(fd) pipe((fd))
1194 #define PerlProc_setuid(u) setuid((u))
1195 #define PerlProc_setgid(g) setgid((g))
1196 #define PerlProc_sleep(t) sleep((t))
1197 #define PerlProc_times(t) times((t))
1198 #define PerlProc_wait(t) wait((t))
1199 #define PerlProc_waitpid(p,s,f) waitpid((p), (s), (f))
1200 #define PerlProc_setjmp(b, n) Sigsetjmp((b), (n))
1201 #define PerlProc_longjmp(b, n) Siglongjmp((b), (n))
1202 #define PerlProc_signal(n, h) signal((n), (h))
1203 #define PerlProc_fork() fork()
1204 #define PerlProc_getpid() getpid()
1207 #define PerlProc_DynaLoad(f) \
1209 #define PerlProc_GetOSError(s,e) \
1210 win32_str_os_error((s), (e))
1212 #endif /* PERL_IMPLICIT_SYS */
1215 Interface for perl socket functions
1218 #if defined(PERL_IMPLICIT_SYS)
1222 struct IPerlSockInfo;
1223 typedef u_long (*LPHtonl)(struct IPerlSock*, u_long);
1224 typedef u_short (*LPHtons)(struct IPerlSock*, u_short);
1225 typedef u_long (*LPNtohl)(struct IPerlSock*, u_long);
1226 typedef u_short (*LPNtohs)(struct IPerlSock*, u_short);
1227 typedef SOCKET (*LPAccept)(struct IPerlSock*, SOCKET,
1228 struct sockaddr*, int*);
1229 typedef int (*LPBind)(struct IPerlSock*, SOCKET,
1230 const struct sockaddr*, int);
1231 typedef int (*LPConnect)(struct IPerlSock*, SOCKET,
1232 const struct sockaddr*, int);
1233 typedef void (*LPEndhostent)(struct IPerlSock*);
1234 typedef void (*LPEndnetent)(struct IPerlSock*);
1235 typedef void (*LPEndprotoent)(struct IPerlSock*);
1236 typedef void (*LPEndservent)(struct IPerlSock*);
1237 typedef int (*LPGethostname)(struct IPerlSock*, char*, int);
1238 typedef int (*LPGetpeername)(struct IPerlSock*, SOCKET,
1239 struct sockaddr*, int*);
1240 typedef struct hostent* (*LPGethostbyaddr)(struct IPerlSock*, const char*,
1242 typedef struct hostent* (*LPGethostbyname)(struct IPerlSock*, const char*);
1243 typedef struct hostent* (*LPGethostent)(struct IPerlSock*);
1244 typedef struct netent* (*LPGetnetbyaddr)(struct IPerlSock*, long, int);
1245 typedef struct netent* (*LPGetnetbyname)(struct IPerlSock*, const char*);
1246 typedef struct netent* (*LPGetnetent)(struct IPerlSock*);
1247 typedef struct protoent*(*LPGetprotobyname)(struct IPerlSock*, const char*);
1248 typedef struct protoent*(*LPGetprotobynumber)(struct IPerlSock*, int);
1249 typedef struct protoent*(*LPGetprotoent)(struct IPerlSock*);
1250 typedef struct servent* (*LPGetservbyname)(struct IPerlSock*, const char*,
1252 typedef struct servent* (*LPGetservbyport)(struct IPerlSock*, int,
1254 typedef struct servent* (*LPGetservent)(struct IPerlSock*);
1255 typedef int (*LPGetsockname)(struct IPerlSock*, SOCKET,
1256 struct sockaddr*, int*);
1257 typedef int (*LPGetsockopt)(struct IPerlSock*, SOCKET, int, int,
1259 typedef unsigned long (*LPInetAddr)(struct IPerlSock*, const char*);
1260 typedef char* (*LPInetNtoa)(struct IPerlSock*, struct in_addr);
1261 typedef int (*LPListen)(struct IPerlSock*, SOCKET, int);
1262 typedef int (*LPRecv)(struct IPerlSock*, SOCKET, char*, int, int);
1263 typedef int (*LPRecvfrom)(struct IPerlSock*, SOCKET, char*, int,
1264 int, struct sockaddr*, int*);
1265 typedef int (*LPSelect)(struct IPerlSock*, int, char*, char*,
1266 char*, const struct timeval*);
1267 typedef int (*LPSend)(struct IPerlSock*, SOCKET, const char*, int,
1269 typedef int (*LPSendto)(struct IPerlSock*, SOCKET, const char*,
1270 int, int, const struct sockaddr*, int);
1271 typedef void (*LPSethostent)(struct IPerlSock*, int);
1272 typedef void (*LPSetnetent)(struct IPerlSock*, int);
1273 typedef void (*LPSetprotoent)(struct IPerlSock*, int);
1274 typedef void (*LPSetservent)(struct IPerlSock*, int);
1275 typedef int (*LPSetsockopt)(struct IPerlSock*, SOCKET, int, int,
1277 typedef int (*LPShutdown)(struct IPerlSock*, SOCKET, int);
1278 typedef SOCKET (*LPSocket)(struct IPerlSock*, int, int, int);
1279 typedef int (*LPSocketpair)(struct IPerlSock*, int, int, int,
1282 typedef int (*LPClosesocket)(struct IPerlSock*, SOCKET s);
1294 LPEndhostent pEndhostent;
1295 LPEndnetent pEndnetent;
1296 LPEndprotoent pEndprotoent;
1297 LPEndservent pEndservent;
1298 LPGethostname pGethostname;
1299 LPGetpeername pGetpeername;
1300 LPGethostbyaddr pGethostbyaddr;
1301 LPGethostbyname pGethostbyname;
1302 LPGethostent pGethostent;
1303 LPGetnetbyaddr pGetnetbyaddr;
1304 LPGetnetbyname pGetnetbyname;
1305 LPGetnetent pGetnetent;
1306 LPGetprotobyname pGetprotobyname;
1307 LPGetprotobynumber pGetprotobynumber;
1308 LPGetprotoent pGetprotoent;
1309 LPGetservbyname pGetservbyname;
1310 LPGetservbyport pGetservbyport;
1311 LPGetservent pGetservent;
1312 LPGetsockname pGetsockname;
1313 LPGetsockopt pGetsockopt;
1314 LPInetAddr pInetAddr;
1315 LPInetNtoa pInetNtoa;
1318 LPRecvfrom pRecvfrom;
1322 LPSethostent pSethostent;
1323 LPSetnetent pSetnetent;
1324 LPSetprotoent pSetprotoent;
1325 LPSetservent pSetservent;
1326 LPSetsockopt pSetsockopt;
1327 LPShutdown pShutdown;
1329 LPSocketpair pSocketpair;
1331 LPClosesocket pClosesocket;
1335 struct IPerlSockInfo
1337 unsigned long nCount; /* number of entries expected */
1338 struct IPerlSock perlSockList;
1341 #define PerlSock_htonl(x) \
1342 (*PL_Sock->pHtonl)(PL_Sock, x)
1343 #define PerlSock_htons(x) \
1344 (*PL_Sock->pHtons)(PL_Sock, x)
1345 #define PerlSock_ntohl(x) \
1346 (*PL_Sock->pNtohl)(PL_Sock, x)
1347 #define PerlSock_ntohs(x) \
1348 (*PL_Sock->pNtohs)(PL_Sock, x)
1349 #define PerlSock_accept(s, a, l) \
1350 (*PL_Sock->pAccept)(PL_Sock, s, a, l)
1351 #define PerlSock_bind(s, n, l) \
1352 (*PL_Sock->pBind)(PL_Sock, s, n, l)
1353 #define PerlSock_connect(s, n, l) \
1354 (*PL_Sock->pConnect)(PL_Sock, s, n, l)
1355 #define PerlSock_endhostent() \
1356 (*PL_Sock->pEndhostent)(PL_Sock)
1357 #define PerlSock_endnetent() \
1358 (*PL_Sock->pEndnetent)(PL_Sock)
1359 #define PerlSock_endprotoent() \
1360 (*PL_Sock->pEndprotoent)(PL_Sock)
1361 #define PerlSock_endservent() \
1362 (*PL_Sock->pEndservent)(PL_Sock)
1363 #define PerlSock_gethostbyaddr(a, l, t) \
1364 (*PL_Sock->pGethostbyaddr)(PL_Sock, a, l, t)
1365 #define PerlSock_gethostbyname(n) \
1366 (*PL_Sock->pGethostbyname)(PL_Sock, n)
1367 #define PerlSock_gethostent() \
1368 (*PL_Sock->pGethostent)(PL_Sock)
1369 #define PerlSock_gethostname(n, l) \
1370 (*PL_Sock->pGethostname)(PL_Sock, n, l)
1371 #define PerlSock_getnetbyaddr(n, t) \
1372 (*PL_Sock->pGetnetbyaddr)(PL_Sock, n, t)
1373 #define PerlSock_getnetbyname(c) \
1374 (*PL_Sock->pGetnetbyname)(PL_Sock, c)
1375 #define PerlSock_getnetent() \
1376 (*PL_Sock->pGetnetent)(PL_Sock)
1377 #define PerlSock_getpeername(s, n, l) \
1378 (*PL_Sock->pGetpeername)(PL_Sock, s, n, l)
1379 #define PerlSock_getprotobyname(n) \
1380 (*PL_Sock->pGetprotobyname)(PL_Sock, n)
1381 #define PerlSock_getprotobynumber(n) \
1382 (*PL_Sock->pGetprotobynumber)(PL_Sock, n)
1383 #define PerlSock_getprotoent() \
1384 (*PL_Sock->pGetprotoent)(PL_Sock)
1385 #define PerlSock_getservbyname(n, p) \
1386 (*PL_Sock->pGetservbyname)(PL_Sock, n, p)
1387 #define PerlSock_getservbyport(port, p) \
1388 (*PL_Sock->pGetservbyport)(PL_Sock, port, p)
1389 #define PerlSock_getservent() \
1390 (*PL_Sock->pGetservent)(PL_Sock)
1391 #define PerlSock_getsockname(s, n, l) \
1392 (*PL_Sock->pGetsockname)(PL_Sock, s, n, l)
1393 #define PerlSock_getsockopt(s,l,n,v,i) \
1394 (*PL_Sock->pGetsockopt)(PL_Sock, s, l, n, v, i)
1395 #define PerlSock_inet_addr(c) \
1396 (*PL_Sock->pInetAddr)(PL_Sock, c)
1397 #define PerlSock_inet_ntoa(i) \
1398 (*PL_Sock->pInetNtoa)(PL_Sock, i)
1399 #define PerlSock_listen(s, b) \
1400 (*PL_Sock->pListen)(PL_Sock, s, b)
1401 #define PerlSock_recv(s, b, l, f) \
1402 (*PL_Sock->pRecv)(PL_Sock, s, b, l, f)
1403 #define PerlSock_recvfrom(s,b,l,f,from,fromlen) \
1404 (*PL_Sock->pRecvfrom)(PL_Sock, s, b, l, f, from, fromlen)
1405 #define PerlSock_select(n, r, w, e, t) \
1406 (*PL_Sock->pSelect)(PL_Sock, n, (char*)r, (char*)w, (char*)e, t)
1407 #define PerlSock_send(s, b, l, f) \
1408 (*PL_Sock->pSend)(PL_Sock, s, b, l, f)
1409 #define PerlSock_sendto(s, b, l, f, t, tlen) \
1410 (*PL_Sock->pSendto)(PL_Sock, s, b, l, f, t, tlen)
1411 #define PerlSock_sethostent(f) \
1412 (*PL_Sock->pSethostent)(PL_Sock, f)
1413 #define PerlSock_setnetent(f) \
1414 (*PL_Sock->pSetnetent)(PL_Sock, f)
1415 #define PerlSock_setprotoent(f) \
1416 (*PL_Sock->pSetprotoent)(PL_Sock, f)
1417 #define PerlSock_setservent(f) \
1418 (*PL_Sock->pSetservent)(PL_Sock, f)
1419 #define PerlSock_setsockopt(s, l, n, v, len) \
1420 (*PL_Sock->pSetsockopt)(PL_Sock, s, l, n, v, len)
1421 #define PerlSock_shutdown(s, h) \
1422 (*PL_Sock->pShutdown)(PL_Sock, s, h)
1423 #define PerlSock_socket(a, t, p) \
1424 (*PL_Sock->pSocket)(PL_Sock, a, t, p)
1425 #define PerlSock_socketpair(a, t, p, f) \
1426 (*PL_Sock->pSocketpair)(PL_Sock, a, t, p, f)
1429 #define PerlSock_closesocket(s) \
1430 (*PL_Sock->pClosesocket)(PL_Sock, s)
1433 #else /* PERL_IMPLICIT_SYS */
1435 #define PerlSock_htonl(x) htonl(x)
1436 #define PerlSock_htons(x) htons(x)
1437 #define PerlSock_ntohl(x) ntohl(x)
1438 #define PerlSock_ntohs(x) ntohs(x)
1439 #define PerlSock_accept(s, a, l) accept(s, a, l)
1440 #define PerlSock_bind(s, n, l) bind(s, n, l)
1441 #define PerlSock_connect(s, n, l) connect(s, n, l)
1443 #define PerlSock_gethostbyaddr(a, l, t) gethostbyaddr(a, l, t)
1444 #define PerlSock_gethostbyname(n) gethostbyname(n)
1445 #define PerlSock_gethostent gethostent
1446 #define PerlSock_endhostent endhostent
1447 #define PerlSock_gethostname(n, l) gethostname(n, l)
1449 #define PerlSock_getnetbyaddr(n, t) getnetbyaddr(n, t)
1450 #define PerlSock_getnetbyname(n) getnetbyname(n)
1451 #define PerlSock_getnetent getnetent
1452 #define PerlSock_endnetent endnetent
1453 #define PerlSock_getpeername(s, n, l) getpeername(s, n, l)
1455 #define PerlSock_getprotobyname(n) getprotobyname(n)
1456 #define PerlSock_getprotobynumber(n) getprotobynumber(n)
1457 #define PerlSock_getprotoent getprotoent
1458 #define PerlSock_endprotoent endprotoent
1460 #define PerlSock_getservbyname(n, p) getservbyname(n, p)
1461 #define PerlSock_getservbyport(port, p) getservbyport(port, p)
1462 #define PerlSock_getservent getservent
1463 #define PerlSock_endservent endservent
1465 #define PerlSock_getsockname(s, n, l) getsockname(s, n, l)
1466 #define PerlSock_getsockopt(s,l,n,v,i) getsockopt(s, l, n, v, i)
1467 #define PerlSock_inet_addr(c) inet_addr(c)
1468 #define PerlSock_inet_ntoa(i) inet_ntoa(i)
1469 #define PerlSock_listen(s, b) listen(s, b)
1470 #define PerlSock_recv(s, b, l, f) recv(s, b, l, f)
1471 #define PerlSock_recvfrom(s, b, l, f, from, fromlen) \
1472 recvfrom(s, b, l, f, from, fromlen)
1473 #define PerlSock_select(n, r, w, e, t) select(n, r, w, e, t)
1474 #define PerlSock_send(s, b, l, f) send(s, b, l, f)
1475 #define PerlSock_sendto(s, b, l, f, t, tlen) \
1476 sendto(s, b, l, f, t, tlen)
1477 #define PerlSock_sethostent(f) sethostent(f)
1478 #define PerlSock_setnetent(f) setnetent(f)
1479 #define PerlSock_setprotoent(f) setprotoent(f)
1480 #define PerlSock_setservent(f) setservent(f)
1481 #define PerlSock_setsockopt(s, l, n, v, len) \
1482 setsockopt(s, l, n, v, len)
1483 #define PerlSock_shutdown(s, h) shutdown(s, h)
1484 #define PerlSock_socket(a, t, p) socket(a, t, p)
1485 #define PerlSock_socketpair(a, t, p, f) socketpair(a, t, p, f)
1488 #define PerlSock_closesocket(s) closesocket(s)
1491 #endif /* PERL_IMPLICIT_SYS */
1493 #endif /* __Inc__IPerl___ */