| 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 | * GSAR 21-JUN-98
|
|---|
| 11 | */
|
|---|
| 12 |
|
|---|
| 13 | #ifndef __Inc__IPerl___
|
|---|
| 14 | #define __Inc__IPerl___
|
|---|
| 15 |
|
|---|
| 16 | /*
|
|---|
| 17 | * PerlXXX_YYY explained - DickH and DougL @ ActiveState.com
|
|---|
| 18 | *
|
|---|
| 19 | * XXX := functional group
|
|---|
| 20 | * YYY := stdlib/OS function name
|
|---|
| 21 | *
|
|---|
| 22 | * Continuing with the theme of PerlIO, all OS functionality was
|
|---|
| 23 | * encapsulated into one of several interfaces.
|
|---|
| 24 | *
|
|---|
| 25 | * PerlIO - stdio
|
|---|
| 26 | * PerlLIO - low level I/O
|
|---|
| 27 | * PerlMem - malloc, realloc, free
|
|---|
| 28 | * PerlDir - directory related
|
|---|
| 29 | * PerlEnv - process environment handling
|
|---|
| 30 | * PerlProc - process control
|
|---|
| 31 | * PerlSock - socket functions
|
|---|
| 32 | *
|
|---|
| 33 | *
|
|---|
| 34 | * The features of this are:
|
|---|
| 35 | * 1. All OS dependant code is in the Perl Host and not the Perl Core.
|
|---|
| 36 | * (At least this is the holy grail goal of this work)
|
|---|
| 37 | * 2. The Perl Host (see perl.h for description) can provide a new and
|
|---|
| 38 | * improved interface to OS functionality if required.
|
|---|
| 39 | * 3. Developers can easily hook into the OS calls for instrumentation
|
|---|
| 40 | * or diagnostic purposes.
|
|---|
| 41 | *
|
|---|
| 42 | * What was changed to do this:
|
|---|
| 43 | * 1. All calls to OS functions were replaced with PerlXXX_YYY
|
|---|
| 44 | *
|
|---|
| 45 | */
|
|---|
| 46 |
|
|---|
| 47 | /*
|
|---|
| 48 | Interface for perl stdio functions, or whatever we are Configure-d
|
|---|
| 49 | to use.
|
|---|
| 50 | */
|
|---|
| 51 | #include "perlio.h"
|
|---|
| 52 |
|
|---|
| 53 | #ifndef Sighandler_t
|
|---|
| 54 | typedef Signal_t (*Sighandler_t) (int);
|
|---|
| 55 | #endif
|
|---|
| 56 |
|
|---|
| 57 | #if defined(PERL_IMPLICIT_SYS)
|
|---|
| 58 |
|
|---|
| 59 | /* IPerlStdIO */
|
|---|
| 60 | struct IPerlStdIO;
|
|---|
| 61 | struct IPerlStdIOInfo;
|
|---|
| 62 | typedef FILE* (*LPStdin)(struct IPerlStdIO*);
|
|---|
| 63 | typedef FILE* (*LPStdout)(struct IPerlStdIO*);
|
|---|
| 64 | typedef FILE* (*LPStderr)(struct IPerlStdIO*);
|
|---|
| 65 | typedef FILE* (*LPOpen)(struct IPerlStdIO*, const char*,
|
|---|
| 66 | const char*);
|
|---|
| 67 | typedef int (*LPClose)(struct IPerlStdIO*, FILE*);
|
|---|
| 68 | typedef int (*LPEof)(struct IPerlStdIO*, FILE*);
|
|---|
| 69 | typedef int (*LPError)(struct IPerlStdIO*, FILE*);
|
|---|
| 70 | typedef void (*LPClearerr)(struct IPerlStdIO*, FILE*);
|
|---|
| 71 | typedef int (*LPGetc)(struct IPerlStdIO*, FILE*);
|
|---|
| 72 | typedef char* (*LPGetBase)(struct IPerlStdIO*, FILE*);
|
|---|
| 73 | typedef int (*LPGetBufsiz)(struct IPerlStdIO*, FILE*);
|
|---|
| 74 | typedef int (*LPGetCnt)(struct IPerlStdIO*, FILE*);
|
|---|
| 75 | typedef char* (*LPGetPtr)(struct IPerlStdIO*, FILE*);
|
|---|
| 76 | typedef char* (*LPGets)(struct IPerlStdIO*, FILE*, char*, int);
|
|---|
| 77 | typedef int (*LPPutc)(struct IPerlStdIO*, FILE*, int);
|
|---|
| 78 | typedef int (*LPPuts)(struct IPerlStdIO*, FILE*, const char*);
|
|---|
| 79 | typedef int (*LPFlush)(struct IPerlStdIO*, FILE*);
|
|---|
| 80 | typedef int (*LPUngetc)(struct IPerlStdIO*, int,FILE*);
|
|---|
| 81 | typedef int (*LPFileno)(struct IPerlStdIO*, FILE*);
|
|---|
| 82 | typedef FILE* (*LPFdopen)(struct IPerlStdIO*, int, const char*);
|
|---|
| 83 | typedef FILE* (*LPReopen)(struct IPerlStdIO*, const char*,
|
|---|
| 84 | const char*, FILE*);
|
|---|
| 85 | typedef SSize_t (*LPRead)(struct IPerlStdIO*, void*, Size_t, Size_t, FILE *);
|
|---|
| 86 | typedef SSize_t (*LPWrite)(struct IPerlStdIO*, const void*, Size_t, Size_t, FILE *);
|
|---|
| 87 | typedef void (*LPSetBuf)(struct IPerlStdIO*, FILE*, char*);
|
|---|
| 88 | typedef int (*LPSetVBuf)(struct IPerlStdIO*, FILE*, char*, int,
|
|---|
| 89 | Size_t);
|
|---|
| 90 | typedef void (*LPSetCnt)(struct IPerlStdIO*, FILE*, int);
|
|---|
| 91 |
|
|---|
| 92 | #ifndef NETWARE
|
|---|
| 93 | typedef void (*LPSetPtr)(struct IPerlStdIO*, FILE*, char*);
|
|---|
| 94 | #elif defined(NETWARE)
|
|---|
| 95 | typedef void (*LPSetPtr)(struct IPerlStdIO*, FILE*, char*, int);
|
|---|
| 96 | #endif
|
|---|
| 97 |
|
|---|
| 98 | typedef void (*LPSetlinebuf)(struct IPerlStdIO*, FILE*);
|
|---|
| 99 | typedef int (*LPPrintf)(struct IPerlStdIO*, FILE*, const char*,
|
|---|
| 100 | ...);
|
|---|
| 101 | typedef int (*LPVprintf)(struct IPerlStdIO*, FILE*, const char*,
|
|---|
| 102 | va_list);
|
|---|
| 103 | typedef Off_t (*LPTell)(struct IPerlStdIO*, FILE*);
|
|---|
| 104 | typedef int (*LPSeek)(struct IPerlStdIO*, FILE*, Off_t, int);
|
|---|
| 105 | typedef void (*LPRewind)(struct IPerlStdIO*, FILE*);
|
|---|
| 106 | typedef FILE* (*LPTmpfile)(struct IPerlStdIO*);
|
|---|
| 107 | typedef int (*LPGetpos)(struct IPerlStdIO*, FILE*, Fpos_t*);
|
|---|
| 108 | typedef int (*LPSetpos)(struct IPerlStdIO*, FILE*,
|
|---|
| 109 | const Fpos_t*);
|
|---|
| 110 | typedef void (*LPInit)(struct IPerlStdIO*);
|
|---|
| 111 | typedef void (*LPInitOSExtras)(struct IPerlStdIO*);
|
|---|
| 112 | typedef FILE* (*LPFdupopen)(struct IPerlStdIO*, FILE*);
|
|---|
| 113 |
|
|---|
| 114 | struct IPerlStdIO
|
|---|
| 115 | {
|
|---|
| 116 | LPStdin pStdin;
|
|---|
| 117 | LPStdout pStdout;
|
|---|
| 118 | LPStderr pStderr;
|
|---|
| 119 | LPOpen pOpen;
|
|---|
| 120 | LPClose pClose;
|
|---|
| 121 | LPEof pEof;
|
|---|
| 122 | LPError pError;
|
|---|
| 123 | LPClearerr pClearerr;
|
|---|
| 124 | LPGetc pGetc;
|
|---|
| 125 | LPGetBase pGetBase;
|
|---|
| 126 | LPGetBufsiz pGetBufsiz;
|
|---|
| 127 | LPGetCnt pGetCnt;
|
|---|
| 128 | LPGetPtr pGetPtr;
|
|---|
| 129 | LPGets pGets;
|
|---|
| 130 | LPPutc pPutc;
|
|---|
| 131 | LPPuts pPuts;
|
|---|
| 132 | LPFlush pFlush;
|
|---|
| 133 | LPUngetc pUngetc;
|
|---|
| 134 | LPFileno pFileno;
|
|---|
| 135 | LPFdopen pFdopen;
|
|---|
| 136 | LPReopen pReopen;
|
|---|
| 137 | LPRead pRead;
|
|---|
| 138 | LPWrite pWrite;
|
|---|
| 139 | LPSetBuf pSetBuf;
|
|---|
| 140 | LPSetVBuf pSetVBuf;
|
|---|
| 141 | LPSetCnt pSetCnt;
|
|---|
| 142 | LPSetPtr pSetPtr;
|
|---|
| 143 | LPSetlinebuf pSetlinebuf;
|
|---|
| 144 | LPPrintf pPrintf;
|
|---|
| 145 | LPVprintf pVprintf;
|
|---|
| 146 | LPTell pTell;
|
|---|
| 147 | LPSeek pSeek;
|
|---|
| 148 | LPRewind pRewind;
|
|---|
| 149 | LPTmpfile pTmpfile;
|
|---|
| 150 | LPGetpos pGetpos;
|
|---|
| 151 | LPSetpos pSetpos;
|
|---|
| 152 | LPInit pInit;
|
|---|
| 153 | LPInitOSExtras pInitOSExtras;
|
|---|
| 154 | LPFdupopen pFdupopen;
|
|---|
| 155 | };
|
|---|
| 156 |
|
|---|
| 157 | struct IPerlStdIOInfo
|
|---|
| 158 | {
|
|---|
| 159 | unsigned long nCount; /* number of entries expected */
|
|---|
| 160 | struct IPerlStdIO perlStdIOList;
|
|---|
| 161 | };
|
|---|
| 162 |
|
|---|
| 163 | /* These do not belong here ... NI-S, 14 Nov 2000 */
|
|---|
| 164 |
|
|---|
| 165 | #ifdef USE_STDIO_PTR
|
|---|
| 166 | # define PerlSIO_has_cntptr(f) 1
|
|---|
| 167 | # ifdef STDIO_PTR_LVALUE
|
|---|
| 168 | # ifdef STDIO_CNT_LVALUE
|
|---|
| 169 | # define PerlSIO_canset_cnt(f) 1
|
|---|
| 170 | # ifdef STDIO_PTR_LVAL_NOCHANGE_CNT
|
|---|
| 171 | # define PerlSIO_fast_gets(f) 1
|
|---|
| 172 | # endif
|
|---|
| 173 | # else /* STDIO_CNT_LVALUE */
|
|---|
| 174 | # define PerlSIO_canset_cnt(f) 0
|
|---|
| 175 | # endif
|
|---|
| 176 | # else /* STDIO_PTR_LVALUE */
|
|---|
| 177 | # ifdef STDIO_PTR_LVAL_SETS_CNT
|
|---|
| 178 | # define PerlSIO_fast_gets(f) 1
|
|---|
| 179 | # endif
|
|---|
| 180 | # endif
|
|---|
| 181 | #else /* USE_STDIO_PTR */
|
|---|
| 182 | # define PerlSIO_has_cntptr(f) 0
|
|---|
| 183 | # define PerlSIO_canset_cnt(f) 0
|
|---|
| 184 | #endif /* USE_STDIO_PTR */
|
|---|
| 185 |
|
|---|
| 186 | #ifndef PerlSIO_fast_gets
|
|---|
| 187 | #define PerlSIO_fast_gets(f) 0
|
|---|
| 188 | #endif
|
|---|
| 189 |
|
|---|
| 190 | #ifdef FILE_base
|
|---|
| 191 | #define PerlSIO_has_base(f) 1
|
|---|
| 192 | #else
|
|---|
| 193 | #define PerlSIO_has_base(f) 0
|
|---|
| 194 | #endif
|
|---|
| 195 |
|
|---|
| 196 | /* Now take FILE * via function table */
|
|---|
| 197 |
|
|---|
| 198 | #define PerlSIO_stdin \
|
|---|
| 199 | (*PL_StdIO->pStdin)(PL_StdIO)
|
|---|
| 200 | #define PerlSIO_stdout \
|
|---|
| 201 | (*PL_StdIO->pStdout)(PL_StdIO)
|
|---|
| 202 | #define PerlSIO_stderr \
|
|---|
| 203 | (*PL_StdIO->pStderr)(PL_StdIO)
|
|---|
| 204 | #define PerlSIO_fopen(x,y) \
|
|---|
| 205 | (*PL_StdIO->pOpen)(PL_StdIO, (x),(y))
|
|---|
| 206 | #define PerlSIO_fclose(f) \
|
|---|
| 207 | (*PL_StdIO->pClose)(PL_StdIO, (f))
|
|---|
| 208 | #define PerlSIO_feof(f) \
|
|---|
| 209 | (*PL_StdIO->pEof)(PL_StdIO, (f))
|
|---|
| 210 | #define PerlSIO_ferror(f) \
|
|---|
| 211 | (*PL_StdIO->pError)(PL_StdIO, (f))
|
|---|
| 212 | #define PerlSIO_clearerr(f) \
|
|---|
| 213 | (*PL_StdIO->pClearerr)(PL_StdIO, (f))
|
|---|
| 214 | #define PerlSIO_fgetc(f) \
|
|---|
| 215 | (*PL_StdIO->pGetc)(PL_StdIO, (f))
|
|---|
| 216 | #define PerlSIO_get_base(f) \
|
|---|
| 217 | (*PL_StdIO->pGetBase)(PL_StdIO, (f))
|
|---|
| 218 | #define PerlSIO_get_bufsiz(f) \
|
|---|
| 219 | (*PL_StdIO->pGetBufsiz)(PL_StdIO, (f))
|
|---|
| 220 | #define PerlSIO_get_cnt(f) \
|
|---|
| 221 | (*PL_StdIO->pGetCnt)(PL_StdIO, (f))
|
|---|
| 222 | #define PerlSIO_get_ptr(f) \
|
|---|
| 223 | (*PL_StdIO->pGetPtr)(PL_StdIO, (f))
|
|---|
| 224 | #define PerlSIO_fputc(f,c) \
|
|---|
| 225 | (*PL_StdIO->pPutc)(PL_StdIO, (f),(c))
|
|---|
| 226 | #define PerlSIO_fputs(f,s) \
|
|---|
| 227 | (*PL_StdIO->pPuts)(PL_StdIO, (f),(s))
|
|---|
| 228 | #define PerlSIO_fflush(f) \
|
|---|
| 229 | (*PL_StdIO->pFlush)(PL_StdIO, (f))
|
|---|
| 230 | #define PerlSIO_fgets(s, n, fp) \
|
|---|
| 231 | (*PL_StdIO->pGets)(PL_StdIO, (fp), s, n)
|
|---|
| 232 | #define PerlSIO_ungetc(c,f) \
|
|---|
| 233 | (*PL_StdIO->pUngetc)(PL_StdIO, (c),(f))
|
|---|
| 234 | #define PerlSIO_fileno(f) \
|
|---|
| 235 | (*PL_StdIO->pFileno)(PL_StdIO, (f))
|
|---|
| 236 | #define PerlSIO_fdopen(f, s) \
|
|---|
| 237 | (*PL_StdIO->pFdopen)(PL_StdIO, (f),(s))
|
|---|
| 238 | #define PerlSIO_freopen(p, m, f) \
|
|---|
| 239 | (*PL_StdIO->pReopen)(PL_StdIO, (p), (m), (f))
|
|---|
| 240 | #define PerlSIO_fread(buf,sz,count,f) \
|
|---|
| 241 | (*PL_StdIO->pRead)(PL_StdIO, (buf), (sz), (count), (f))
|
|---|
| 242 | #define PerlSIO_fwrite(buf,sz,count,f) \
|
|---|
| 243 | (*PL_StdIO->pWrite)(PL_StdIO, (buf), (sz), (count), (f))
|
|---|
| 244 | #define PerlSIO_setbuf(f,b) \
|
|---|
| 245 | (*PL_StdIO->pSetBuf)(PL_StdIO, (f), (b))
|
|---|
| 246 | #define PerlSIO_setvbuf(f,b,t,s) \
|
|---|
| 247 | (*PL_StdIO->pSetVBuf)(PL_StdIO, (f),(b),(t),(s))
|
|---|
| 248 | #define PerlSIO_set_cnt(f,c) \
|
|---|
| 249 | (*PL_StdIO->pSetCnt)(PL_StdIO, (f), (c))
|
|---|
| 250 | #define PerlSIO_set_ptr(f,p) \
|
|---|
| 251 | (*PL_StdIO->pSetPtr)(PL_StdIO, (f), (p))
|
|---|
| 252 | #define PerlSIO_setlinebuf(f) \
|
|---|
| 253 | (*PL_StdIO->pSetlinebuf)(PL_StdIO, (f))
|
|---|
| 254 | #define PerlSIO_printf Perl_fprintf_nocontext
|
|---|
| 255 | #define PerlSIO_stdoutf Perl_printf_nocontext
|
|---|
| 256 | #define PerlSIO_vprintf(f,fmt,a) \
|
|---|
| 257 | (*PL_StdIO->pVprintf)(PL_StdIO, (f),(fmt),a)
|
|---|
| 258 | #define PerlSIO_ftell(f) \
|
|---|
| 259 | (*PL_StdIO->pTell)(PL_StdIO, (f))
|
|---|
| 260 | #define PerlSIO_fseek(f,o,w) \
|
|---|
| 261 | (*PL_StdIO->pSeek)(PL_StdIO, (f),(o),(w))
|
|---|
| 262 | #define PerlSIO_fgetpos(f,p) \
|
|---|
| 263 | (*PL_StdIO->pGetpos)(PL_StdIO, (f),(p))
|
|---|
| 264 | #define PerlSIO_fsetpos(f,p) \
|
|---|
| 265 | (*PL_StdIO->pSetpos)(PL_StdIO, (f),(p))
|
|---|
| 266 | #define PerlSIO_rewind(f) \
|
|---|
| 267 | (*PL_StdIO->pRewind)(PL_StdIO, (f))
|
|---|
| 268 | #define PerlSIO_tmpfile() \
|
|---|
| 269 | (*PL_StdIO->pTmpfile)(PL_StdIO)
|
|---|
| 270 | #define PerlSIO_init() \
|
|---|
| 271 | (*PL_StdIO->pInit)(PL_StdIO)
|
|---|
| 272 | #undef init_os_extras
|
|---|
| 273 | #define init_os_extras() \
|
|---|
| 274 | (*PL_StdIO->pInitOSExtras)(PL_StdIO)
|
|---|
| 275 | #define PerlSIO_fdupopen(f) \
|
|---|
| 276 | (*PL_StdIO->pFdupopen)(PL_StdIO, (f))
|
|---|
| 277 |
|
|---|
| 278 | #else /* PERL_IMPLICIT_SYS */
|
|---|
| 279 |
|
|---|
| 280 | #define PerlSIO_stdin stdin
|
|---|
| 281 | #define PerlSIO_stdout stdout
|
|---|
| 282 | #define PerlSIO_stderr stderr
|
|---|
| 283 | #define PerlSIO_fopen(x,y) fopen(x,y)
|
|---|
| 284 | #ifdef __VOS__
|
|---|
| 285 | /* Work around VOS bug posix-979, wrongly setting errno when at end of file. */
|
|---|
| 286 | #define PerlSIO_fclose(f) (((errno==1025)?errno=0:0),fclose(f))
|
|---|
| 287 | #define PerlSIO_feof(f) (((errno==1025)?errno=0:0),feof(f))
|
|---|
| 288 | #define PerlSIO_ferror(f) (((errno==1025)?errno=0:0),ferror(f))
|
|---|
| 289 | #else
|
|---|
| 290 | #define PerlSIO_fclose(f) fclose(f)
|
|---|
| 291 | #define PerlSIO_feof(f) feof(f)
|
|---|
| 292 | #define PerlSIO_ferror(f) ferror(f)
|
|---|
| 293 | #endif
|
|---|
| 294 | #define PerlSIO_clearerr(f) clearerr(f)
|
|---|
| 295 | #define PerlSIO_fgetc(f) fgetc(f)
|
|---|
| 296 | #ifdef FILE_base
|
|---|
| 297 | #define PerlSIO_get_base(f) FILE_base(f)
|
|---|
| 298 | #define PerlSIO_get_bufsiz(f) FILE_bufsiz(f)
|
|---|
| 299 | #else
|
|---|
| 300 | #define PerlSIO_get_base(f) NULL
|
|---|
| 301 | #define PerlSIO_get_bufsiz(f) 0
|
|---|
| 302 | #endif
|
|---|
| 303 | #ifdef USE_STDIO_PTR
|
|---|
| 304 | #define PerlSIO_get_cnt(f) FILE_cnt(f)
|
|---|
| 305 | #define PerlSIO_get_ptr(f) FILE_ptr(f)
|
|---|
| 306 | #else
|
|---|
| 307 | #define PerlSIO_get_cnt(f) 0
|
|---|
| 308 | #define PerlSIO_get_ptr(f) NULL
|
|---|
| 309 | #endif
|
|---|
| 310 | #define PerlSIO_fputc(f,c) fputc(c,f)
|
|---|
| 311 | #define PerlSIO_fputs(f,s) fputs(s,f)
|
|---|
| 312 | #define PerlSIO_fflush(f) Fflush(f)
|
|---|
| 313 | #define PerlSIO_fgets(s, n, fp) fgets(s,n,fp)
|
|---|
| 314 | #if defined(VMS) && defined(__DECC)
|
|---|
| 315 | /* Unusual definition of ungetc() here to accomodate fast_sv_gets()'
|
|---|
| 316 | * belief that it can mix getc/ungetc with reads from stdio buffer */
|
|---|
| 317 | int decc$ungetc(int __c, FILE *__stream);
|
|---|
| 318 | # define PerlSIO_ungetc(c,f) ((c) == EOF ? EOF : \
|
|---|
| 319 | ((*(f) && !((*(f))->_flag & _IONBF) && \
|
|---|
| 320 | ((*(f))->_ptr > (*(f))->_base)) ? \
|
|---|
| 321 | ((*(f))->_cnt++, *(--(*(f))->_ptr) = (c)) : decc$ungetc(c,f)))
|
|---|
| 322 | #else
|
|---|
| 323 | # define PerlSIO_ungetc(c,f) ungetc(c,f)
|
|---|
| 324 | #endif
|
|---|
| 325 | #define PerlSIO_fileno(f) fileno(f)
|
|---|
| 326 | #define PerlSIO_fdopen(f, s) fdopen(f,s)
|
|---|
| 327 | #define PerlSIO_freopen(p, m, f) freopen(p,m,f)
|
|---|
| 328 | #define PerlSIO_fread(buf,sz,count,f) fread(buf,sz,count,f)
|
|---|
| 329 | #define PerlSIO_fwrite(buf,sz,count,f) fwrite(buf,sz,count,f)
|
|---|
| 330 | #define PerlSIO_setbuf(f,b) setbuf(f,b)
|
|---|
| 331 | #define PerlSIO_setvbuf(f,b,t,s) setvbuf(f,b,t,s)
|
|---|
| 332 | #if defined(USE_STDIO_PTR) && defined(STDIO_CNT_LVALUE)
|
|---|
| 333 | #define PerlSIO_set_cnt(f,c) FILE_cnt(f) = (c)
|
|---|
| 334 | #else
|
|---|
| 335 | #define PerlSIO_set_cnt(f,c) PerlIOProc_abort()
|
|---|
| 336 | #endif
|
|---|
| 337 | #if defined(USE_STDIO_PTR) && defined(STDIO_PTR_LVALUE)
|
|---|
| 338 | #define PerlSIO_set_ptr(f,p) FILE_ptr(f) = (p)
|
|---|
| 339 | #else
|
|---|
| 340 | #define PerlSIO_set_ptr(f,p) PerlIOProc_abort()
|
|---|
| 341 | #endif
|
|---|
| 342 | #define PerlSIO_setlinebuf(f) setlinebuf(f)
|
|---|
| 343 | #define PerlSIO_printf fprintf
|
|---|
| 344 | #define PerlSIO_stdoutf printf
|
|---|
| 345 | #define PerlSIO_vprintf(f,fmt,a) vfprintf(f,fmt,a)
|
|---|
| 346 | #define PerlSIO_ftell(f) ftell(f)
|
|---|
| 347 | #define PerlSIO_fseek(f,o,w) fseek(f,o,w)
|
|---|
| 348 | #define PerlSIO_fgetpos(f,p) fgetpos(f,p)
|
|---|
| 349 | #define PerlSIO_fsetpos(f,p) fsetpos(f,p)
|
|---|
| 350 | #define PerlSIO_rewind(f) rewind(f)
|
|---|
| 351 | #define PerlSIO_tmpfile() tmpfile()
|
|---|
| 352 | #define PerlSIO_fdupopen(f) (f)
|
|---|
| 353 |
|
|---|
| 354 | #endif /* PERL_IMPLICIT_SYS */
|
|---|
| 355 |
|
|---|
| 356 | /*
|
|---|
| 357 | * Interface for directory functions
|
|---|
| 358 | */
|
|---|
| 359 |
|
|---|
| 360 | #if defined(PERL_IMPLICIT_SYS)
|
|---|
| 361 |
|
|---|
| 362 | /* IPerlDir */
|
|---|
| 363 | struct IPerlDir;
|
|---|
| 364 | struct IPerlDirInfo;
|
|---|
| 365 | typedef int (*LPMakedir)(struct IPerlDir*, const char*, int);
|
|---|
| 366 | typedef int (*LPChdir)(struct IPerlDir*, const char*);
|
|---|
| 367 | typedef int (*LPRmdir)(struct IPerlDir*, const char*);
|
|---|
| 368 | typedef int (*LPDirClose)(struct IPerlDir*, DIR*);
|
|---|
| 369 | typedef DIR* (*LPDirOpen)(struct IPerlDir*, char*);
|
|---|
| 370 | typedef struct direct* (*LPDirRead)(struct IPerlDir*, DIR*);
|
|---|
| 371 | typedef void (*LPDirRewind)(struct IPerlDir*, DIR*);
|
|---|
| 372 | typedef void (*LPDirSeek)(struct IPerlDir*, DIR*, long);
|
|---|
| 373 | typedef long (*LPDirTell)(struct IPerlDir*, DIR*);
|
|---|
| 374 | #ifdef WIN32
|
|---|
| 375 | typedef char* (*LPDirMapPathA)(struct IPerlDir*, const char*);
|
|---|
| 376 | typedef WCHAR* (*LPDirMapPathW)(struct IPerlDir*, const WCHAR*);
|
|---|
| 377 | #endif
|
|---|
| 378 |
|
|---|
| 379 | struct IPerlDir
|
|---|
| 380 | {
|
|---|
| 381 | LPMakedir pMakedir;
|
|---|
| 382 | LPChdir pChdir;
|
|---|
| 383 | LPRmdir pRmdir;
|
|---|
| 384 | LPDirClose pClose;
|
|---|
| 385 | LPDirOpen pOpen;
|
|---|
| 386 | LPDirRead pRead;
|
|---|
| 387 | LPDirRewind pRewind;
|
|---|
| 388 | LPDirSeek pSeek;
|
|---|
| 389 | LPDirTell pTell;
|
|---|
| 390 | #ifdef WIN32
|
|---|
| 391 | LPDirMapPathA pMapPathA;
|
|---|
| 392 | LPDirMapPathW pMapPathW;
|
|---|
| 393 | #endif
|
|---|
| 394 | };
|
|---|
| 395 |
|
|---|
| 396 | struct IPerlDirInfo
|
|---|
| 397 | {
|
|---|
| 398 | unsigned long nCount; /* number of entries expected */
|
|---|
| 399 | struct IPerlDir perlDirList;
|
|---|
| 400 | };
|
|---|
| 401 |
|
|---|
| 402 | #define PerlDir_mkdir(name, mode) \
|
|---|
| 403 | (*PL_Dir->pMakedir)(PL_Dir, (name), (mode))
|
|---|
| 404 | #define PerlDir_chdir(name) \
|
|---|
| 405 | (*PL_Dir->pChdir)(PL_Dir, (name))
|
|---|
| 406 | #define PerlDir_rmdir(name) \
|
|---|
| 407 | (*PL_Dir->pRmdir)(PL_Dir, (name))
|
|---|
| 408 | #define PerlDir_close(dir) \
|
|---|
| 409 | (*PL_Dir->pClose)(PL_Dir, (dir))
|
|---|
| 410 | #define PerlDir_open(name) \
|
|---|
| 411 | (*PL_Dir->pOpen)(PL_Dir, (name))
|
|---|
| 412 | #define PerlDir_read(dir) \
|
|---|
| 413 | (*PL_Dir->pRead)(PL_Dir, (dir))
|
|---|
| 414 | #define PerlDir_rewind(dir) \
|
|---|
| 415 | (*PL_Dir->pRewind)(PL_Dir, (dir))
|
|---|
| 416 | #define PerlDir_seek(dir, loc) \
|
|---|
| 417 | (*PL_Dir->pSeek)(PL_Dir, (dir), (loc))
|
|---|
| 418 | #define PerlDir_tell(dir) \
|
|---|
| 419 | (*PL_Dir->pTell)(PL_Dir, (dir))
|
|---|
| 420 | #ifdef WIN32
|
|---|
| 421 | #define PerlDir_mapA(dir) \
|
|---|
| 422 | (*PL_Dir->pMapPathA)(PL_Dir, (dir))
|
|---|
| 423 | #define PerlDir_mapW(dir) \
|
|---|
| 424 | (*PL_Dir->pMapPathW)(PL_Dir, (dir))
|
|---|
| 425 | #endif
|
|---|
| 426 |
|
|---|
| 427 | #else /* PERL_IMPLICIT_SYS */
|
|---|
| 428 |
|
|---|
| 429 | #define PerlDir_mkdir(name, mode) Mkdir((name), (mode))
|
|---|
| 430 | #ifdef VMS
|
|---|
| 431 | # define PerlDir_chdir(n) Chdir((n))
|
|---|
| 432 | #else
|
|---|
| 433 | # define PerlDir_chdir(name) chdir((name))
|
|---|
| 434 | #endif
|
|---|
| 435 | #define PerlDir_rmdir(name) rmdir((name))
|
|---|
| 436 | #define PerlDir_close(dir) closedir((dir))
|
|---|
| 437 | #define PerlDir_open(name) opendir((name))
|
|---|
| 438 | #define PerlDir_read(dir) readdir((dir))
|
|---|
| 439 | #define PerlDir_rewind(dir) rewinddir((dir))
|
|---|
| 440 | #define PerlDir_seek(dir, loc) seekdir((dir), (loc))
|
|---|
| 441 | #define PerlDir_tell(dir) telldir((dir))
|
|---|
| 442 | #ifdef WIN32
|
|---|
| 443 | #define PerlDir_mapA(dir) dir
|
|---|
| 444 | #define PerlDir_mapW(dir) dir
|
|---|
| 445 | #endif
|
|---|
| 446 |
|
|---|
| 447 | #endif /* PERL_IMPLICIT_SYS */
|
|---|
| 448 |
|
|---|
| 449 | /*
|
|---|
| 450 | Interface for perl environment functions
|
|---|
| 451 | */
|
|---|
| 452 |
|
|---|
| 453 | #if defined(PERL_IMPLICIT_SYS)
|
|---|
| 454 |
|
|---|
| 455 | /* IPerlEnv */
|
|---|
| 456 | struct IPerlEnv;
|
|---|
| 457 | struct IPerlEnvInfo;
|
|---|
| 458 | typedef char* (*LPEnvGetenv)(struct IPerlEnv*, const char*);
|
|---|
| 459 | typedef int (*LPEnvPutenv)(struct IPerlEnv*, const char*);
|
|---|
| 460 | typedef char* (*LPEnvGetenv_len)(struct IPerlEnv*,
|
|---|
| 461 | const char *varname, unsigned long *len);
|
|---|
| 462 | typedef int (*LPEnvUname)(struct IPerlEnv*, struct utsname *name);
|
|---|
| 463 | typedef void (*LPEnvClearenv)(struct IPerlEnv*);
|
|---|
| 464 | typedef void* (*LPEnvGetChildenv)(struct IPerlEnv*);
|
|---|
| 465 | typedef void (*LPEnvFreeChildenv)(struct IPerlEnv*, void* env);
|
|---|
| 466 | typedef char* (*LPEnvGetChilddir)(struct IPerlEnv*);
|
|---|
| 467 | typedef void (*LPEnvFreeChilddir)(struct IPerlEnv*, char* dir);
|
|---|
| 468 | #ifdef HAS_ENVGETENV
|
|---|
| 469 | typedef char* (*LPENVGetenv)(struct IPerlEnv*, const char *varname);
|
|---|
| 470 | typedef char* (*LPENVGetenv_len)(struct IPerlEnv*,
|
|---|
| 471 | const char *varname, unsigned long *len);
|
|---|
| 472 | #endif
|
|---|
| 473 | #ifdef WIN32
|
|---|
| 474 | typedef unsigned long (*LPEnvOsID)(struct IPerlEnv*);
|
|---|
| 475 | typedef char* (*LPEnvLibPath)(struct IPerlEnv*, const char*);
|
|---|
| 476 | typedef char* (*LPEnvSiteLibPath)(struct IPerlEnv*, const char*);
|
|---|
| 477 | typedef char* (*LPEnvVendorLibPath)(struct IPerlEnv*, const char*);
|
|---|
| 478 | typedef void (*LPEnvGetChildIO)(struct IPerlEnv*, child_IO_table*);
|
|---|
| 479 | #endif
|
|---|
| 480 |
|
|---|
| 481 | struct IPerlEnv
|
|---|
| 482 | {
|
|---|
| 483 | LPEnvGetenv pGetenv;
|
|---|
| 484 | LPEnvPutenv pPutenv;
|
|---|
| 485 | LPEnvGetenv_len pGetenv_len;
|
|---|
| 486 | LPEnvUname pEnvUname;
|
|---|
| 487 | LPEnvClearenv pClearenv;
|
|---|
| 488 | LPEnvGetChildenv pGetChildenv;
|
|---|
| 489 | LPEnvFreeChildenv pFreeChildenv;
|
|---|
| 490 | LPEnvGetChilddir pGetChilddir;
|
|---|
| 491 | LPEnvFreeChilddir pFreeChilddir;
|
|---|
| 492 | #ifdef HAS_ENVGETENV
|
|---|
| 493 | LPENVGetenv pENVGetenv;
|
|---|
| 494 | LPENVGetenv_len pENVGetenv_len;
|
|---|
| 495 | #endif
|
|---|
| 496 | #ifdef WIN32
|
|---|
| 497 | LPEnvOsID pEnvOsID;
|
|---|
| 498 | LPEnvLibPath pLibPath;
|
|---|
| 499 | LPEnvSiteLibPath pSiteLibPath;
|
|---|
| 500 | LPEnvVendorLibPath pVendorLibPath;
|
|---|
| 501 | LPEnvGetChildIO pGetChildIO;
|
|---|
| 502 | #endif
|
|---|
| 503 | };
|
|---|
| 504 |
|
|---|
| 505 | struct IPerlEnvInfo
|
|---|
| 506 | {
|
|---|
| 507 | unsigned long nCount; /* number of entries expected */
|
|---|
| 508 | struct IPerlEnv perlEnvList;
|
|---|
| 509 | };
|
|---|
| 510 |
|
|---|
| 511 | #define PerlEnv_putenv(str) \
|
|---|
| 512 | (*PL_Env->pPutenv)(PL_Env,(str))
|
|---|
| 513 | #define PerlEnv_getenv(str) \
|
|---|
| 514 | (*PL_Env->pGetenv)(PL_Env,(str))
|
|---|
| 515 | #define PerlEnv_getenv_len(str,l) \
|
|---|
| 516 | (*PL_Env->pGetenv_len)(PL_Env,(str), (l))
|
|---|
| 517 | #define PerlEnv_clearenv() \
|
|---|
| 518 | (*PL_Env->pClearenv)(PL_Env)
|
|---|
| 519 | #define PerlEnv_get_childenv() \
|
|---|
| 520 | (*PL_Env->pGetChildenv)(PL_Env)
|
|---|
| 521 | #define PerlEnv_free_childenv(e) \
|
|---|
| 522 | (*PL_Env->pFreeChildenv)(PL_Env, (e))
|
|---|
| 523 | #define PerlEnv_get_childdir() \
|
|---|
| 524 | (*PL_Env->pGetChilddir)(PL_Env)
|
|---|
| 525 | #define PerlEnv_free_childdir(d) \
|
|---|
| 526 | (*PL_Env->pFreeChilddir)(PL_Env, (d))
|
|---|
| 527 | #ifdef HAS_ENVGETENV
|
|---|
| 528 | # define PerlEnv_ENVgetenv(str) \
|
|---|
| 529 | (*PL_Env->pENVGetenv)(PL_Env,(str))
|
|---|
| 530 | # define PerlEnv_ENVgetenv_len(str,l) \
|
|---|
| 531 | (*PL_Env->pENVGetenv_len)(PL_Env,(str), (l))
|
|---|
| 532 | #else
|
|---|
| 533 | # define PerlEnv_ENVgetenv(str) \
|
|---|
| 534 | PerlEnv_getenv((str))
|
|---|
| 535 | # define PerlEnv_ENVgetenv_len(str,l) \
|
|---|
| 536 | PerlEnv_getenv_len((str),(l))
|
|---|
| 537 | #endif
|
|---|
| 538 | #define PerlEnv_uname(name) \
|
|---|
| 539 | (*PL_Env->pEnvUname)(PL_Env,(name))
|
|---|
| 540 | #ifdef WIN32
|
|---|
| 541 | #define PerlEnv_os_id() \
|
|---|
| 542 | (*PL_Env->pEnvOsID)(PL_Env)
|
|---|
| 543 | #define PerlEnv_lib_path(str) \
|
|---|
| 544 | (*PL_Env->pLibPath)(PL_Env,(str))
|
|---|
| 545 | #define PerlEnv_sitelib_path(str) \
|
|---|
| 546 | (*PL_Env->pSiteLibPath)(PL_Env,(str))
|
|---|
| 547 | #define PerlEnv_vendorlib_path(str) \
|
|---|
| 548 | (*PL_Env->pVendorLibPath)(PL_Env,(str))
|
|---|
| 549 | #define PerlEnv_get_child_IO(ptr) \
|
|---|
| 550 | (*PL_Env->pGetChildIO)(PL_Env, ptr)
|
|---|
| 551 | #endif
|
|---|
| 552 |
|
|---|
| 553 | #else /* PERL_IMPLICIT_SYS */
|
|---|
| 554 |
|
|---|
| 555 | #define PerlEnv_putenv(str) putenv((str))
|
|---|
| 556 | #define PerlEnv_getenv(str) getenv((str))
|
|---|
| 557 | #define PerlEnv_getenv_len(str,l) getenv_len((str), (l))
|
|---|
| 558 | #ifdef HAS_ENVGETENV
|
|---|
| 559 | # define PerlEnv_ENVgetenv(str) ENVgetenv((str))
|
|---|
| 560 | # define PerlEnv_ENVgetenv_len(str,l) ENVgetenv_len((str), (l))
|
|---|
| 561 | #else
|
|---|
| 562 | # define PerlEnv_ENVgetenv(str) PerlEnv_getenv((str))
|
|---|
| 563 | # define PerlEnv_ENVgetenv_len(str,l) PerlEnv_getenv_len((str), (l))
|
|---|
| 564 | #endif
|
|---|
| 565 | #define PerlEnv_uname(name) uname((name))
|
|---|
| 566 |
|
|---|
| 567 | #ifdef WIN32
|
|---|
| 568 | #define PerlEnv_os_id() win32_os_id()
|
|---|
| 569 | #define PerlEnv_lib_path(str) win32_get_privlib(str)
|
|---|
| 570 | #define PerlEnv_sitelib_path(str) win32_get_sitelib(str)
|
|---|
|
|---|