Commit | Line | Data |
---|---|---|
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 | 74 | extern void PerlIO_init (void); |
0f4eea8f DL |
75 | #endif |
76 | ||
77 | #ifdef PERL_OBJECT | |
78 | ||
79 | #ifndef PerlIO | |
80 | typedef struct _PerlIO PerlIO; | |
81 | #endif | |
82 | ||
83 | class IPerlStdIO | |
84 | { | |
85 | public: | |
86 | virtual PerlIO * Stdin(void) = 0; | |
87 | virtual PerlIO * Stdout(void) = 0; | |
88 | virtual PerlIO * Stderr(void) = 0; | |
89 | virtual PerlIO * Open(const char *, const char *, int &err) = 0; | |
90 | virtual int Close(PerlIO*, int &err) = 0; | |
91 | virtual int Eof(PerlIO*, int &err) = 0; | |
92 | virtual int Error(PerlIO*, int &err) = 0; | |
93 | virtual void Clearerr(PerlIO*, int &err) = 0; | |
94 | virtual int Getc(PerlIO*, int &err) = 0; | |
95 | virtual char * GetBase(PerlIO *, int &err) = 0; | |
96 | virtual int GetBufsiz(PerlIO *, int &err) = 0; | |
97 | virtual int GetCnt(PerlIO *, int &err) = 0; | |
98 | virtual char * GetPtr(PerlIO *, int &err) = 0; | |
99 | virtual char * Gets(PerlIO*, char*, int, int& err) = 0; | |
100 | virtual int Putc(PerlIO*, int, int &err) = 0; | |
101 | virtual int Puts(PerlIO*, const char *, int &err) = 0; | |
102 | virtual int Flush(PerlIO*, int &err) = 0; | |
103 | virtual int Ungetc(PerlIO*,int, int &err) = 0; | |
104 | virtual int Fileno(PerlIO*, int &err) = 0; | |
105 | virtual PerlIO * Fdopen(int, const char *, int &err) = 0; | |
106 | virtual PerlIO * Reopen(const char*, const char*, PerlIO*, int &err) = 0; | |
107 | virtual SSize_t Read(PerlIO*,void *,Size_t, int &err) = 0; | |
108 | virtual SSize_t Write(PerlIO*,const void *,Size_t, int &err) = 0; | |
109 | virtual void SetBuf(PerlIO *, char*, int &err) = 0; | |
110 | virtual int SetVBuf(PerlIO *, char*, int, Size_t, int &err) = 0; | |
111 | virtual void SetCnt(PerlIO *, int, int &err) = 0; | |
112 | virtual void SetPtrCnt(PerlIO *, char *, int, int& err) = 0; | |
113 | virtual void Setlinebuf(PerlIO*, int &err) = 0; | |
114 | virtual int Printf(PerlIO*, int &err, const char *,...) = 0; | |
115 | virtual int Vprintf(PerlIO*, int &err, const char *, va_list) = 0; | |
116 | virtual long Tell(PerlIO*, int &err) = 0; | |
c78749f2 | 117 | virtual int Seek(PerlIO*, Off_t, int, int &err) = 0; |
0f4eea8f DL |
118 | virtual void Rewind(PerlIO*, int &err) = 0; |
119 | virtual PerlIO * Tmpfile(int &err) = 0; | |
120 | virtual int Getpos(PerlIO*, Fpos_t *, int &err) = 0; | |
121 | virtual int Setpos(PerlIO*, const Fpos_t *, int &err) = 0; | |
122 | virtual void Init(int &err) = 0; | |
123 | virtual void InitOSExtras(void* p) = 0; | |
124 | #ifdef WIN32 | |
125 | virtual int OpenOSfhandle(long osfhandle, int flags) = 0; | |
126 | virtual int GetOSfhandle(int filenum) = 0; | |
127 | #endif | |
128 | }; | |
129 | ||
2bd2b9e0 GS |
130 | |
131 | ||
132 | #ifdef USE_STDIO_PTR | |
133 | # define PerlIO_has_cntptr(f) 1 | |
134 | # ifdef STDIO_CNT_LVALUE | |
135 | # define PerlIO_canset_cnt(f) 1 | |
136 | # ifdef STDIO_PTR_LVALUE | |
137 | # define PerlIO_fast_gets(f) 1 | |
138 | # endif | |
139 | # else | |
140 | # define PerlIO_canset_cnt(f) 0 | |
141 | # endif | |
142 | #else /* USE_STDIO_PTR */ | |
143 | # define PerlIO_has_cntptr(f) 0 | |
144 | # define PerlIO_canset_cnt(f) 0 | |
145 | #endif /* USE_STDIO_PTR */ | |
146 | ||
147 | #ifndef PerlIO_fast_gets | |
148 | #define PerlIO_fast_gets(f) 0 | |
149 | #endif | |
150 | ||
151 | #ifdef FILE_base | |
152 | #define PerlIO_has_base(f) 1 | |
153 | #else | |
154 | #define PerlIO_has_base(f) 0 | |
155 | #endif | |
0f4eea8f | 156 | |
4c2891ed GS |
157 | #define PerlIO_stdin() PL_piStdIO->Stdin() |
158 | #define PerlIO_stdout() PL_piStdIO->Stdout() | |
159 | #define PerlIO_stderr() PL_piStdIO->Stderr() | |
160 | #define PerlIO_open(x,y) PL_piStdIO->Open((x),(y), ErrorNo()) | |
161 | #define PerlIO_close(f) PL_piStdIO->Close((f), ErrorNo()) | |
162 | #define PerlIO_eof(f) PL_piStdIO->Eof((f), ErrorNo()) | |
163 | #define PerlIO_error(f) PL_piStdIO->Error((f), ErrorNo()) | |
164 | #define PerlIO_clearerr(f) PL_piStdIO->Clearerr((f), ErrorNo()) | |
165 | #define PerlIO_getc(f) PL_piStdIO->Getc((f), ErrorNo()) | |
166 | #define PerlIO_get_base(f) PL_piStdIO->GetBase((f), ErrorNo()) | |
167 | #define PerlIO_get_bufsiz(f) PL_piStdIO->GetBufsiz((f), ErrorNo()) | |
168 | #define PerlIO_get_cnt(f) PL_piStdIO->GetCnt((f), ErrorNo()) | |
169 | #define PerlIO_get_ptr(f) PL_piStdIO->GetPtr((f), ErrorNo()) | |
170 | #define PerlIO_putc(f,c) PL_piStdIO->Putc((f),(c), ErrorNo()) | |
171 | #define PerlIO_puts(f,s) PL_piStdIO->Puts((f),(s), ErrorNo()) | |
172 | #define PerlIO_flush(f) PL_piStdIO->Flush((f), ErrorNo()) | |
173 | #define PerlIO_gets(s, n, fp) PL_piStdIO->Gets((fp), s, n, ErrorNo()) | |
174 | #define PerlIO_ungetc(f,c) PL_piStdIO->Ungetc((f),(c), ErrorNo()) | |
175 | #define PerlIO_fileno(f) PL_piStdIO->Fileno((f), ErrorNo()) | |
176 | #define PerlIO_fdopen(f, s) PL_piStdIO->Fdopen((f),(s), ErrorNo()) | |
177 | #define PerlIO_reopen(p, m, f) PL_piStdIO->Reopen((p), (m), (f), ErrorNo()) | |
0f4eea8f | 178 | #define PerlIO_read(f,buf,count) \ |
4c2891ed | 179 | (SSize_t)PL_piStdIO->Read((f), (buf), (count), ErrorNo()) |
0f4eea8f | 180 | #define PerlIO_write(f,buf,count) \ |
4c2891ed GS |
181 | PL_piStdIO->Write((f), (buf), (count), ErrorNo()) |
182 | #define PerlIO_setbuf(f,b) PL_piStdIO->SetBuf((f), (b), ErrorNo()) | |
183 | #define PerlIO_setvbuf(f,b,t,s) PL_piStdIO->SetVBuf((f), (b), (t), (s), ErrorNo()) | |
184 | #define PerlIO_set_cnt(f,c) PL_piStdIO->SetCnt((f), (c), ErrorNo()) | |
0f4eea8f | 185 | #define PerlIO_set_ptrcnt(f,p,c) \ |
4c2891ed GS |
186 | PL_piStdIO->SetPtrCnt((f), (p), (c), ErrorNo()) |
187 | #define PerlIO_setlinebuf(f) PL_piStdIO->Setlinebuf((f), ErrorNo()) | |
0f4eea8f | 188 | #define PerlIO_printf fprintf |
4c2891ed GS |
189 | #define PerlIO_stdoutf PL_piStdIO->Printf |
190 | #define PerlIO_vprintf(f,fmt,a) PL_piStdIO->Vprintf((f), ErrorNo(), (fmt),a) | |
191 | #define PerlIO_tell(f) PL_piStdIO->Tell((f), ErrorNo()) | |
192 | #define PerlIO_seek(f,o,w) PL_piStdIO->Seek((f),(o),(w), ErrorNo()) | |
193 | #define PerlIO_getpos(f,p) PL_piStdIO->Getpos((f),(p), ErrorNo()) | |
194 | #define PerlIO_setpos(f,p) PL_piStdIO->Setpos((f),(p), ErrorNo()) | |
195 | #define PerlIO_rewind(f) PL_piStdIO->Rewind((f), ErrorNo()) | |
196 | #define PerlIO_tmpfile() PL_piStdIO->Tmpfile(ErrorNo()) | |
197 | #define PerlIO_init() PL_piStdIO->Init(ErrorNo()) | |
0f4eea8f | 198 | #undef init_os_extras |
4c2891ed | 199 | #define init_os_extras() PL_piStdIO->InitOSExtras(this) |
0f4eea8f DL |
200 | |
201 | #else /* PERL_OBJECT */ | |
202 | ||
203 | #include "perlsdio.h" | |
204 | ||
205 | #endif /* PERL_OBJECT */ | |
206 | ||
207 | #ifndef PERLIO_IS_STDIO | |
208 | #ifdef USE_SFIO | |
209 | #include "perlsfio.h" | |
210 | #endif /* USE_SFIO */ | |
211 | #endif /* PERLIO_IS_STDIO */ | |
212 | ||
213 | #ifndef EOF | |
214 | #define EOF (-1) | |
215 | #endif | |
216 | ||
217 | /* This is to catch case with no stdio */ | |
218 | #ifndef BUFSIZ | |
219 | #define BUFSIZ 1024 | |
220 | #endif | |
221 | ||
222 | #ifndef SEEK_SET | |
223 | #define SEEK_SET 0 | |
224 | #endif | |
225 | ||
226 | #ifndef SEEK_CUR | |
227 | #define SEEK_CUR 1 | |
228 | #endif | |
229 | ||
230 | #ifndef SEEK_END | |
231 | #define SEEK_END 2 | |
232 | #endif | |
233 | ||
234 | #ifndef PerlIO | |
235 | struct _PerlIO; | |
236 | #define PerlIO struct _PerlIO | |
237 | #endif /* No PerlIO */ | |
238 | ||
239 | #ifndef Fpos_t | |
240 | #define Fpos_t long | |
241 | #endif | |
242 | ||
243 | #ifndef NEXT30_NO_ATTRIBUTE | |
244 | #ifndef HASATTRIBUTE /* disable GNU-cc attribute checking? */ | |
245 | #ifdef __attribute__ /* Avoid possible redefinition errors */ | |
246 | #undef __attribute__ | |
247 | #endif | |
248 | #define __attribute__(attr) | |
249 | #endif | |
250 | #endif | |
251 | ||
252 | #ifndef PerlIO_stdoutf | |
20ce7b12 | 253 | extern int PerlIO_stdoutf (const char *,...) |
0f4eea8f DL |
254 | __attribute__((format (printf, 1, 2))); |
255 | #endif | |
256 | #ifndef PerlIO_puts | |
20ce7b12 | 257 | extern int PerlIO_puts (PerlIO *,const char *); |
0f4eea8f DL |
258 | #endif |
259 | #ifndef PerlIO_open | |
20ce7b12 | 260 | extern PerlIO * PerlIO_open (const char *,const char *); |
0f4eea8f DL |
261 | #endif |
262 | #ifndef PerlIO_close | |
20ce7b12 | 263 | extern int PerlIO_close (PerlIO *); |
0f4eea8f DL |
264 | #endif |
265 | #ifndef PerlIO_eof | |
20ce7b12 | 266 | extern int PerlIO_eof (PerlIO *); |
0f4eea8f DL |
267 | #endif |
268 | #ifndef PerlIO_error | |
20ce7b12 | 269 | extern int PerlIO_error (PerlIO *); |
0f4eea8f DL |
270 | #endif |
271 | #ifndef PerlIO_clearerr | |
20ce7b12 | 272 | extern void PerlIO_clearerr (PerlIO *); |
0f4eea8f DL |
273 | #endif |
274 | #ifndef PerlIO_getc | |
20ce7b12 | 275 | extern int PerlIO_getc (PerlIO *); |
0f4eea8f DL |
276 | #endif |
277 | #ifndef PerlIO_putc | |
20ce7b12 | 278 | extern int PerlIO_putc (PerlIO *,int); |
0f4eea8f DL |
279 | #endif |
280 | #ifndef PerlIO_flush | |
20ce7b12 | 281 | extern int PerlIO_flush (PerlIO *); |
0f4eea8f DL |
282 | #endif |
283 | #ifndef PerlIO_ungetc | |
20ce7b12 | 284 | extern int PerlIO_ungetc (PerlIO *,int); |
0f4eea8f DL |
285 | #endif |
286 | #ifndef PerlIO_fileno | |
20ce7b12 | 287 | extern int PerlIO_fileno (PerlIO *); |
0f4eea8f DL |
288 | #endif |
289 | #ifndef PerlIO_fdopen | |
20ce7b12 | 290 | extern PerlIO * PerlIO_fdopen (int, const char *); |
0f4eea8f DL |
291 | #endif |
292 | #ifndef PerlIO_importFILE | |
20ce7b12 | 293 | extern PerlIO * PerlIO_importFILE (FILE *,int); |
0f4eea8f DL |
294 | #endif |
295 | #ifndef PerlIO_exportFILE | |
20ce7b12 | 296 | extern FILE * PerlIO_exportFILE (PerlIO *,int); |
0f4eea8f DL |
297 | #endif |
298 | #ifndef PerlIO_findFILE | |
20ce7b12 | 299 | extern FILE * PerlIO_findFILE (PerlIO *); |
0f4eea8f DL |
300 | #endif |
301 | #ifndef PerlIO_releaseFILE | |
20ce7b12 | 302 | extern void PerlIO_releaseFILE (PerlIO *,FILE *); |
0f4eea8f DL |
303 | #endif |
304 | #ifndef PerlIO_read | |
20ce7b12 | 305 | extern SSize_t PerlIO_read (PerlIO *,void *,Size_t); |
0f4eea8f DL |
306 | #endif |
307 | #ifndef PerlIO_write | |
20ce7b12 | 308 | extern SSize_t PerlIO_write (PerlIO *,const void *,Size_t); |
0f4eea8f DL |
309 | #endif |
310 | #ifndef PerlIO_setlinebuf | |
20ce7b12 | 311 | extern void PerlIO_setlinebuf (PerlIO *); |
0f4eea8f DL |
312 | #endif |
313 | #ifndef PerlIO_printf | |
20ce7b12 | 314 | extern int PerlIO_printf (PerlIO *, const char *,...) |
0f4eea8f DL |
315 | __attribute__((format (printf, 2, 3))); |
316 | #endif | |
317 | #ifndef PerlIO_sprintf | |
20ce7b12 | 318 | extern int PerlIO_sprintf (char *, int, const char *,...) |
0f4eea8f DL |
319 | __attribute__((format (printf, 3, 4))); |
320 | #endif | |
321 | #ifndef PerlIO_vprintf | |
20ce7b12 | 322 | extern int PerlIO_vprintf (PerlIO *, const char *, va_list); |
0f4eea8f DL |
323 | #endif |
324 | #ifndef PerlIO_tell | |
20ce7b12 | 325 | extern Off_t PerlIO_tell (PerlIO *); |
0f4eea8f DL |
326 | #endif |
327 | #ifndef PerlIO_seek | |
20ce7b12 | 328 | extern int PerlIO_seek (PerlIO *, Off_t, int); |
0f4eea8f DL |
329 | #endif |
330 | #ifndef PerlIO_rewind | |
20ce7b12 | 331 | extern void PerlIO_rewind (PerlIO *); |
0f4eea8f DL |
332 | #endif |
333 | #ifndef PerlIO_has_base | |
20ce7b12 | 334 | extern int PerlIO_has_base (PerlIO *); |
0f4eea8f DL |
335 | #endif |
336 | #ifndef PerlIO_has_cntptr | |
20ce7b12 | 337 | extern int PerlIO_has_cntptr (PerlIO *); |
0f4eea8f DL |
338 | #endif |
339 | #ifndef PerlIO_fast_gets | |
20ce7b12 | 340 | extern int PerlIO_fast_gets (PerlIO *); |
0f4eea8f DL |
341 | #endif |
342 | #ifndef PerlIO_canset_cnt | |
20ce7b12 | 343 | extern int PerlIO_canset_cnt (PerlIO *); |
0f4eea8f DL |
344 | #endif |
345 | #ifndef PerlIO_get_ptr | |
20ce7b12 | 346 | extern STDCHAR * PerlIO_get_ptr (PerlIO *); |
0f4eea8f DL |
347 | #endif |
348 | #ifndef PerlIO_get_cnt | |
20ce7b12 | 349 | extern int PerlIO_get_cnt (PerlIO *); |
0f4eea8f DL |
350 | #endif |
351 | #ifndef PerlIO_set_cnt | |
20ce7b12 | 352 | extern void PerlIO_set_cnt (PerlIO *,int); |
0f4eea8f DL |
353 | #endif |
354 | #ifndef PerlIO_set_ptrcnt | |
20ce7b12 | 355 | extern void PerlIO_set_ptrcnt (PerlIO *,STDCHAR *,int); |
0f4eea8f DL |
356 | #endif |
357 | #ifndef PerlIO_get_base | |
20ce7b12 | 358 | extern STDCHAR * PerlIO_get_base (PerlIO *); |
0f4eea8f DL |
359 | #endif |
360 | #ifndef PerlIO_get_bufsiz | |
20ce7b12 | 361 | extern int PerlIO_get_bufsiz (PerlIO *); |
0f4eea8f DL |
362 | #endif |
363 | #ifndef PerlIO_tmpfile | |
20ce7b12 | 364 | extern PerlIO * PerlIO_tmpfile (void); |
0f4eea8f DL |
365 | #endif |
366 | #ifndef PerlIO_stdin | |
20ce7b12 | 367 | extern PerlIO * PerlIO_stdin (void); |
0f4eea8f DL |
368 | #endif |
369 | #ifndef PerlIO_stdout | |
20ce7b12 | 370 | extern PerlIO * PerlIO_stdout (void); |
0f4eea8f DL |
371 | #endif |
372 | #ifndef PerlIO_stderr | |
20ce7b12 | 373 | extern PerlIO * PerlIO_stderr (void); |
0f4eea8f DL |
374 | #endif |
375 | #ifndef PerlIO_getpos | |
20ce7b12 | 376 | extern int PerlIO_getpos (PerlIO *,Fpos_t *); |
0f4eea8f DL |
377 | #endif |
378 | #ifndef PerlIO_setpos | |
20ce7b12 | 379 | extern int PerlIO_setpos (PerlIO *,const Fpos_t *); |
0f4eea8f DL |
380 | #endif |
381 | ||
382 | ||
383 | /* | |
384 | * Interface for directory functions | |
385 | */ | |
386 | ||
387 | #ifdef PERL_OBJECT | |
388 | ||
389 | class IPerlDir | |
390 | { | |
391 | public: | |
392 | virtual int Makedir(const char *dirname, int mode, int &err) = 0; | |
393 | virtual int Chdir(const char *dirname, int &err) = 0; | |
394 | virtual int Rmdir(const char *dirname, int &err) = 0; | |
395 | virtual int Close(DIR *dirp, int &err) = 0; | |
396 | virtual DIR * Open(char *filename, int &err) = 0; | |
397 | virtual struct direct *Read(DIR *dirp, int &err) = 0; | |
398 | virtual void Rewind(DIR *dirp, int &err) = 0; | |
399 | virtual void Seek(DIR *dirp, long loc, int &err) = 0; | |
400 | virtual long Tell(DIR *dirp, int &err) = 0; | |
401 | }; | |
402 | ||
403 | #define PerlDir_mkdir(name, mode) \ | |
4c2891ed | 404 | PL_piDir->Makedir((name), (mode), ErrorNo()) |
0f4eea8f | 405 | #define PerlDir_chdir(name) \ |
4c2891ed | 406 | PL_piDir->Chdir((name), ErrorNo()) |
0f4eea8f | 407 | #define PerlDir_rmdir(name) \ |
4c2891ed | 408 | PL_piDir->Rmdir((name), ErrorNo()) |
0f4eea8f | 409 | #define PerlDir_close(dir) \ |
4c2891ed | 410 | PL_piDir->Close((dir), ErrorNo()) |
0f4eea8f | 411 | #define PerlDir_open(name) \ |
4c2891ed | 412 | PL_piDir->Open((name), ErrorNo()) |
0f4eea8f | 413 | #define PerlDir_read(dir) \ |
4c2891ed | 414 | PL_piDir->Read((dir), ErrorNo()) |
0f4eea8f | 415 | #define PerlDir_rewind(dir) \ |
4c2891ed | 416 | PL_piDir->Rewind((dir), ErrorNo()) |
0f4eea8f | 417 | #define PerlDir_seek(dir, loc) \ |
4c2891ed | 418 | PL_piDir->Seek((dir), (loc), ErrorNo()) |
0f4eea8f | 419 | #define PerlDir_tell(dir) \ |
4c2891ed | 420 | PL_piDir->Tell((dir), ErrorNo()) |
0f4eea8f DL |
421 | |
422 | #else /* PERL_OBJECT */ | |
423 | ||
424 | #define PerlDir_mkdir(name, mode) Mkdir((name), (mode)) | |
425 | #ifdef VMS | |
426 | # define PerlDir_chdir(n) chdir(((n) && *(n)) ? (n) : "SYS$LOGIN") | |
427 | #else | |
428 | # define PerlDir_chdir(name) chdir((name)) | |
429 | #endif | |
430 | #define PerlDir_rmdir(name) rmdir((name)) | |
431 | #define PerlDir_close(dir) closedir((dir)) | |
432 | #define PerlDir_open(name) opendir((name)) | |
433 | #define PerlDir_read(dir) readdir((dir)) | |
434 | #define PerlDir_rewind(dir) rewinddir((dir)) | |
435 | #define PerlDir_seek(dir, loc) seekdir((dir), (loc)) | |
436 | #define PerlDir_tell(dir) telldir((dir)) | |
437 | ||
438 | #endif /* PERL_OBJECT */ | |
439 | ||
440 | /* | |
441 | Interface for perl environment functions | |
442 | */ | |
443 | ||
444 | #ifdef PERL_OBJECT | |
445 | ||
446 | class IPerlEnv | |
447 | { | |
448 | public: | |
449 | virtual char * Getenv(const char *varname, int &err) = 0; | |
450 | virtual int Putenv(const char *envstring, int &err) = 0; | |
451 | virtual char * LibPath(char *patchlevel) =0; | |
452 | virtual char * SiteLibPath(char *patchlevel) =0; | |
b2af26b1 | 453 | virtual int Uname(struct utsname *name, int &err) =0; |
a6c40364 GS |
454 | virtual char * Getenv_len(const char *varname, unsigned long *len, int &err) = 0; |
455 | #ifdef HAS_ENVGETENV | |
456 | virtual char * ENVGetenv(const char *varname, int &err) = 0; | |
457 | virtual char * ENVGetenv_len(const char *varname, unsigned long *len, int &err) = 0; | |
458 | #endif | |
0f4eea8f DL |
459 | }; |
460 | ||
4c2891ed GS |
461 | #define PerlEnv_putenv(str) PL_piENV->Putenv((str), ErrorNo()) |
462 | #define PerlEnv_getenv(str) PL_piENV->Getenv((str), ErrorNo()) | |
a6c40364 | 463 | #define PerlEnv_getenv_len(str,l) PL_piENV->Getenv_len((str), (l), ErrorNo()) |
f675dbe5 CB |
464 | #ifdef HAS_ENVGETENV |
465 | # define PerlEnv_ENVgetenv(str) PL_piENV->ENVGetenv((str), ErrorNo()) | |
a6c40364 | 466 | # define PerlEnv_ENVgetenv_len(str,l) PL_piENV->ENVGetenv_len((str), (l), ErrorNo()) |
f675dbe5 CB |
467 | #else |
468 | # define PerlEnv_ENVgetenv(str) PerlEnv_getenv((str)) | |
a6c40364 | 469 | # define PerlEnv_ENVgetenv_len(str,l) PerlEnv_getenv_len((str),(l)) |
f675dbe5 | 470 | #endif |
b2af26b1 | 471 | #define PerlEnv_uname(name) PL_piENV->Uname((name), ErrorNo()) |
0f4eea8f | 472 | #ifdef WIN32 |
4c2891ed GS |
473 | #define PerlEnv_lib_path(str) PL_piENV->LibPath((str)) |
474 | #define PerlEnv_sitelib_path(str) PL_piENV->SiteLibPath((str)) | |
0f4eea8f DL |
475 | #endif |
476 | ||
477 | #else /* PERL_OBJECT */ | |
478 | ||
479 | #define PerlEnv_putenv(str) putenv((str)) | |
480 | #define PerlEnv_getenv(str) getenv((str)) | |
a6c40364 | 481 | #define PerlEnv_getenv_len(str,l) getenv_len((str), (l)) |
f675dbe5 CB |
482 | #ifdef HAS_ENVGETENV |
483 | # define PerlEnv_ENVgetenv(str) ENVgetenv((str)) | |
a6c40364 | 484 | # define PerlEnv_ENVgetenv_len(str,l) ENVgetenv_len((str), (l)) |
f675dbe5 CB |
485 | #else |
486 | # define PerlEnv_ENVgetenv(str) PerlEnv_getenv((str)) | |
a6c40364 | 487 | # define PerlEnv_ENVgetenv_len(str,l) PerlEnv_getenv_len((str), (l)) |
f675dbe5 | 488 | #endif |
b2af26b1 | 489 | #define PerlEnv_uname(name) uname((name)) |
0f4eea8f DL |
490 | |
491 | #endif /* PERL_OBJECT */ | |
492 | ||
493 | /* | |
494 | Interface for perl low-level IO functions | |
495 | */ | |
496 | ||
497 | #ifdef PERL_OBJECT | |
498 | ||
499 | class IPerlLIO | |
500 | { | |
501 | public: | |
502 | virtual int Access(const char *path, int mode, int &err) = 0; | |
503 | virtual int Chmod(const char *filename, int pmode, int &err) = 0; | |
504 | virtual int Chown(const char *filename, uid_t owner, | |
505 | gid_t group, int &err) = 0; | |
506 | virtual int Chsize(int handle, long size, int &err) = 0; | |
507 | virtual int Close(int handle, int &err) = 0; | |
508 | virtual int Dup(int handle, int &err) = 0; | |
509 | virtual int Dup2(int handle1, int handle2, int &err) = 0; | |
510 | virtual int Flock(int fd, int oper, int &err) = 0; | |
511 | virtual int FileStat(int handle, struct stat *buffer, int &err) = 0; | |
512 | virtual int IOCtl(int i, unsigned int u, char *data, int &err) = 0; | |
513 | virtual int Isatty(int handle, int &err) = 0; | |
514 | virtual long Lseek(int handle, long offset, int origin, int &err) = 0; | |
515 | virtual int Lstat(const char *path, struct stat *buffer, int &err) = 0; | |
516 | virtual char * Mktemp(char *Template, int &err) = 0; | |
517 | virtual int Open(const char *filename, int oflag, int &err) = 0; | |
518 | virtual int Open(const char *filename, int oflag, | |
519 | int pmode, int &err) = 0; | |
520 | virtual int Read(int handle, void *buffer, | |
521 | unsigned int count, int &err) = 0; | |
8d9b2e3c | 522 | virtual int Rename(const char *oname, |
0f4eea8f DL |
523 | const char *newname, int &err) = 0; |
524 | virtual int Setmode(int handle, int mode, int &err) = 0; | |
525 | virtual int NameStat(const char *path, | |
526 | struct stat *buffer, int &err) = 0; | |
527 | virtual char * Tmpnam(char *string, int &err) = 0; | |
528 | virtual int Umask(int pmode, int &err) = 0; | |
529 | virtual int Unlink(const char *filename, int &err) = 0; | |
530 | virtual int Utime(char *filename, struct utimbuf *times, int &err) = 0; | |
531 | virtual int Write(int handle, const void *buffer, | |
532 | unsigned int count, int &err) = 0; | |
533 | }; | |
534 | ||
535 | #define PerlLIO_access(file, mode) \ | |
4c2891ed | 536 | PL_piLIO->Access((file), (mode), ErrorNo()) |
0f4eea8f | 537 | #define PerlLIO_chmod(file, mode) \ |
4c2891ed | 538 | PL_piLIO->Chmod((file), (mode), ErrorNo()) |
0f4eea8f | 539 | #define PerlLIO_chown(file, owner, group) \ |
4c2891ed | 540 | PL_piLIO->Chown((file), (owner), (group), ErrorNo()) |
0f4eea8f | 541 | #define PerlLIO_chsize(fd, size) \ |
4c2891ed | 542 | PL_piLIO->Chsize((fd), (size), ErrorNo()) |
0f4eea8f | 543 | #define PerlLIO_close(fd) \ |
4c2891ed | 544 | PL_piLIO->Close((fd), ErrorNo()) |
0f4eea8f | 545 | #define PerlLIO_dup(fd) \ |
4c2891ed | 546 | PL_piLIO->Dup((fd), ErrorNo()) |
0f4eea8f | 547 | #define PerlLIO_dup2(fd1, fd2) \ |
4c2891ed | 548 | PL_piLIO->Dup2((fd1), (fd2), ErrorNo()) |
0f4eea8f | 549 | #define PerlLIO_flock(fd, op) \ |
4c2891ed | 550 | PL_piLIO->Flock((fd), (op), ErrorNo()) |
0f4eea8f | 551 | #define PerlLIO_fstat(fd, buf) \ |
4c2891ed | 552 | PL_piLIO->FileStat((fd), (buf), ErrorNo()) |
0f4eea8f | 553 | #define PerlLIO_ioctl(fd, u, buf) \ |
4c2891ed | 554 | PL_piLIO->IOCtl((fd), (u), (buf), ErrorNo()) |
0f4eea8f | 555 | #define PerlLIO_isatty(fd) \ |
4c2891ed | 556 | PL_piLIO->Isatty((fd), ErrorNo()) |
0f4eea8f | 557 | #define PerlLIO_lseek(fd, offset, mode) \ |
4c2891ed | 558 | PL_piLIO->Lseek((fd), (offset), (mode), ErrorNo()) |
0f4eea8f | 559 | #define PerlLIO_lstat(name, buf) \ |
4c2891ed | 560 | PL_piLIO->Lstat((name), (buf), ErrorNo()) |
0f4eea8f | 561 | #define PerlLIO_mktemp(file) \ |
4c2891ed | 562 | PL_piLIO->Mktemp((file), ErrorNo()) |
0f4eea8f | 563 | #define PerlLIO_open(file, flag) \ |
4c2891ed | 564 | PL_piLIO->Open((file), (flag), ErrorNo()) |
0f4eea8f | 565 | #define PerlLIO_open3(file, flag, perm) \ |
4c2891ed | 566 | PL_piLIO->Open((file), (flag), (perm), ErrorNo()) |
0f4eea8f | 567 | #define PerlLIO_read(fd, buf, count) \ |
4c2891ed | 568 | PL_piLIO->Read((fd), (buf), (count), ErrorNo()) |
8d9b2e3c | 569 | #define PerlLIO_rename(oname, newname) \ |
4c2891ed | 570 | PL_piLIO->Rename((oname), (newname), ErrorNo()) |
0f4eea8f | 571 | #define PerlLIO_setmode(fd, mode) \ |
4c2891ed | 572 | PL_piLIO->Setmode((fd), (mode), ErrorNo()) |
0f4eea8f | 573 | #define PerlLIO_stat(name, buf) \ |
4c2891ed | 574 | PL_piLIO->NameStat((name), (buf), ErrorNo()) |
0f4eea8f | 575 | #define PerlLIO_tmpnam(str) \ |
4c2891ed | 576 | PL_piLIO->Tmpnam((str), ErrorNo()) |
0f4eea8f | 577 | #define PerlLIO_umask(mode) \ |
4c2891ed | 578 | PL_piLIO->Umask((mode), ErrorNo()) |
0f4eea8f | 579 | #define PerlLIO_unlink(file) \ |
4c2891ed | 580 | PL_piLIO->Unlink((file), ErrorNo()) |
0f4eea8f | 581 | #define PerlLIO_utime(file, time) \ |
4c2891ed | 582 | PL_piLIO->Utime((file), (time), ErrorNo()) |
0f4eea8f | 583 | #define PerlLIO_write(fd, buf, count) \ |
4c2891ed | 584 | PL_piLIO->Write((fd), (buf), (count), ErrorNo()) |
0f4eea8f DL |
585 | |
586 | #else /* PERL_OBJECT */ | |
587 | ||
588 | #define PerlLIO_access(file, mode) access((file), (mode)) | |
589 | #define PerlLIO_chmod(file, mode) chmod((file), (mode)) | |
590 | #define PerlLIO_chown(file, owner, grp) chown((file), (owner), (grp)) | |
591 | #define PerlLIO_chsize(fd, size) chsize((fd), (size)) | |
592 | #define PerlLIO_close(fd) close((fd)) | |
593 | #define PerlLIO_dup(fd) dup((fd)) | |
594 | #define PerlLIO_dup2(fd1, fd2) dup2((fd1), (fd2)) | |
595 | #define PerlLIO_flock(fd, op) FLOCK((fd), (op)) | |
596 | #define PerlLIO_fstat(fd, buf) Fstat((fd), (buf)) | |
597 | #define PerlLIO_ioctl(fd, u, buf) ioctl((fd), (u), (buf)) | |
598 | #define PerlLIO_isatty(fd) isatty((fd)) | |
599 | #define PerlLIO_lseek(fd, offset, mode) lseek((fd), (offset), (mode)) | |
9423c6fc | 600 | #ifdef HAS_LSTAT |
0f4eea8f | 601 | #define PerlLIO_lstat(name, buf) lstat((name), (buf)) |
9423c6fc GS |
602 | #else |
603 | #define PerlLIO_lstat(name, buf) PerlLIO_stat((name), (buf)) | |
604 | #endif | |
0f4eea8f DL |
605 | #define PerlLIO_mktemp(file) mktemp((file)) |
606 | #define PerlLIO_mkstemp(file) mkstemp((file)) | |
607 | #define PerlLIO_open(file, flag) open((file), (flag)) | |
608 | #define PerlLIO_open3(file, flag, perm) open((file), (flag), (perm)) | |
609 | #define PerlLIO_read(fd, buf, count) read((fd), (buf), (count)) | |
610 | #define PerlLIO_rename(old, new) rename((old), (new)) | |
611 | #define PerlLIO_setmode(fd, mode) setmode((fd), (mode)) | |
612 | #define PerlLIO_stat(name, buf) Stat((name), (buf)) | |
613 | #define PerlLIO_tmpnam(str) tmpnam((str)) | |
614 | #define PerlLIO_umask(mode) umask((mode)) | |
615 | #define PerlLIO_unlink(file) unlink((file)) | |
616 | #define PerlLIO_utime(file, time) utime((file), (time)) | |
617 | #define PerlLIO_write(fd, buf, count) write((fd), (buf), (count)) | |
618 | ||
619 | #endif /* PERL_OBJECT */ | |
620 | ||
621 | /* | |
622 | Interface for perl memory allocation | |
623 | */ | |
624 | ||
625 | #ifdef PERL_OBJECT | |
626 | ||
627 | class IPerlMem | |
628 | { | |
629 | public: | |
630 | virtual void * Malloc(size_t) = 0; | |
631 | virtual void * Realloc(void*, size_t) = 0; | |
632 | virtual void Free(void*) = 0; | |
633 | }; | |
634 | ||
4c2891ed GS |
635 | #define PerlMem_malloc(size) PL_piMem->Malloc((size)) |
636 | #define PerlMem_realloc(buf, size) PL_piMem->Realloc((buf), (size)) | |
637 | #define PerlMem_free(buf) PL_piMem->Free((buf)) | |
0f4eea8f DL |
638 | |
639 | #else /* PERL_OBJECT */ | |
640 | ||
641 | #define PerlMem_malloc(size) malloc((size)) | |
642 | #define PerlMem_realloc(buf, size) realloc((buf), (size)) | |
643 | #define PerlMem_free(buf) free((buf)) | |
644 | ||
645 | #endif /* PERL_OBJECT */ | |
646 | ||
647 | /* | |
648 | Interface for perl process functions | |
649 | */ | |
650 | ||
651 | ||
652 | #ifdef PERL_OBJECT | |
653 | ||
654 | #ifndef Sighandler_t | |
20ce7b12 | 655 | typedef Signal_t (*Sighandler_t) (int); |
0f4eea8f DL |
656 | #endif |
657 | #ifndef jmp_buf | |
658 | #include <setjmp.h> | |
659 | #endif | |
660 | ||
661 | class IPerlProc | |
662 | { | |
663 | public: | |
664 | virtual void Abort(void) = 0; | |
ff95b63e | 665 | virtual char * Crypt(const char* clear, const char* salt) = 0; |
0f4eea8f DL |
666 | virtual void Exit(int status) = 0; |
667 | virtual void _Exit(int status) = 0; | |
668 | virtual int Execl(const char *cmdname, const char *arg0, | |
669 | const char *arg1, const char *arg2, | |
670 | const char *arg3) = 0; | |
671 | virtual int Execv(const char *cmdname, const char *const *argv) = 0; | |
672 | virtual int Execvp(const char *cmdname, const char *const *argv) = 0; | |
673 | virtual uid_t Getuid(void) = 0; | |
674 | virtual uid_t Geteuid(void) = 0; | |
675 | virtual gid_t Getgid(void) = 0; | |
676 | virtual gid_t Getegid(void) = 0; | |
677 | virtual char * Getlogin(void) = 0; | |
678 | virtual int Kill(int pid, int sig) = 0; | |
679 | virtual int Killpg(int pid, int sig) = 0; | |
680 | virtual int PauseProc(void) = 0; | |
681 | virtual PerlIO * Popen(const char *command, const char *mode) = 0; | |
682 | virtual int Pclose(PerlIO *stream) = 0; | |
683 | virtual int Pipe(int *phandles) = 0; | |
684 | virtual int Setuid(uid_t uid) = 0; | |
685 | virtual int Setgid(gid_t gid) = 0; | |
686 | virtual int Sleep(unsigned int) = 0; | |
687 | virtual int Times(struct tms *timebuf) = 0; | |
688 | virtual int Wait(int *status) = 0; | |
689 | virtual int Waitpid(int pid, int *status, int flags) = 0; | |
690 | virtual Sighandler_t Signal(int sig, Sighandler_t subcode) = 0; | |
691 | #ifdef WIN32 | |
692 | virtual void GetSysMsg(char*& msg, DWORD& dwLen, DWORD dwErr) = 0; | |
693 | virtual void FreeBuf(char* msg) = 0; | |
694 | virtual BOOL DoCmd(char *cmd) = 0; | |
695 | virtual int Spawn(char*cmds) = 0; | |
696 | virtual int Spawnvp(int mode, const char *cmdname, | |
697 | const char *const *argv) = 0; | |
698 | virtual int ASpawn(void *vreally, void **vmark, void **vsp) = 0; | |
699 | #endif | |
700 | }; | |
701 | ||
4c2891ed | 702 | #define PerlProc_abort() PL_piProc->Abort() |
ff95b63e | 703 | #define PerlProc_crypt(c,s) PL_piProc->Crypt((c), (s)) |
4c2891ed GS |
704 | #define PerlProc_exit(s) PL_piProc->Exit((s)) |
705 | #define PerlProc__exit(s) PL_piProc->_Exit((s)) | |
0f4eea8f | 706 | #define PerlProc_execl(c, w, x, y, z) \ |
4c2891ed GS |
707 | PL_piProc->Execl((c), (w), (x), (y), (z)) |
708 | ||
709 | #define PerlProc_execv(c, a) PL_piProc->Execv((c), (a)) | |
710 | #define PerlProc_execvp(c, a) PL_piProc->Execvp((c), (a)) | |
711 | #define PerlProc_getuid() PL_piProc->Getuid() | |
712 | #define PerlProc_geteuid() PL_piProc->Geteuid() | |
713 | #define PerlProc_getgid() PL_piProc->Getgid() | |
714 | #define PerlProc_getegid() PL_piProc->Getegid() | |
715 | #define PerlProc_getlogin() PL_piProc->Getlogin() | |
716 | #define PerlProc_kill(i, a) PL_piProc->Kill((i), (a)) | |
717 | #define PerlProc_killpg(i, a) PL_piProc->Killpg((i), (a)) | |
718 | #define PerlProc_pause() PL_piProc->PauseProc() | |
719 | #define PerlProc_popen(c, m) PL_piProc->Popen((c), (m)) | |
720 | #define PerlProc_pclose(f) PL_piProc->Pclose((f)) | |
721 | #define PerlProc_pipe(fd) PL_piProc->Pipe((fd)) | |
722 | #define PerlProc_setuid(u) PL_piProc->Setuid((u)) | |
723 | #define PerlProc_setgid(g) PL_piProc->Setgid((g)) | |
724 | #define PerlProc_sleep(t) PL_piProc->Sleep((t)) | |
725 | #define PerlProc_times(t) PL_piProc->Times((t)) | |
726 | #define PerlProc_wait(t) PL_piProc->Wait((t)) | |
727 | #define PerlProc_waitpid(p,s,f) PL_piProc->Waitpid((p), (s), (f)) | |
0f4eea8f DL |
728 | #define PerlProc_setjmp(b, n) Sigsetjmp((b), (n)) |
729 | #define PerlProc_longjmp(b, n) Siglongjmp((b), (n)) | |
4c2891ed | 730 | #define PerlProc_signal(n, h) PL_piProc->Signal((n), (h)) |
0f4eea8f DL |
731 | |
732 | #ifdef WIN32 | |
733 | #define PerlProc_GetSysMsg(s,l,e) \ | |
4c2891ed | 734 | PL_piProc->GetSysMsg((s), (l), (e)) |
0f4eea8f | 735 | |
4c2891ed GS |
736 | #define PerlProc_FreeBuf(s) PL_piProc->FreeBuf((s)) |
737 | #define PerlProc_Cmd(s) PL_piProc->DoCmd((s)) | |
738 | #define do_spawn(s) PL_piProc->Spawn((s)) | |
739 | #define do_spawnvp(m, c, a) PL_piProc->Spawnvp((m), (c), (a)) | |
740 | #define PerlProc_aspawn(m,c,a) PL_piProc->ASpawn((m), (c), (a)) | |
0f4eea8f DL |
741 | #endif |
742 | ||
743 | #else /* PERL_OBJECT */ | |
744 | ||
745 | #define PerlProc_abort() abort() | |
ff95b63e | 746 | #define PerlProc_crypt(c,s) crypt((c), (s)) |
0f4eea8f DL |
747 | #define PerlProc_exit(s) exit((s)) |
748 | #define PerlProc__exit(s) _exit((s)) | |
749 | #define PerlProc_execl(c,w,x,y,z) \ | |
750 | execl((c), (w), (x), (y), (z)) | |
751 | #define PerlProc_execv(c, a) execv((c), (a)) | |
752 | #define PerlProc_execvp(c, a) execvp((c), (a)) | |
753 | #define PerlProc_getuid() getuid() | |
754 | #define PerlProc_geteuid() geteuid() | |
755 | #define PerlProc_getgid() getgid() | |
756 | #define PerlProc_getegid() getegid() | |
757 | #define PerlProc_getlogin() getlogin() | |
758 | #define PerlProc_kill(i, a) kill((i), (a)) | |
759 | #define PerlProc_killpg(i, a) killpg((i), (a)) | |
760 | #define PerlProc_pause() Pause() | |
761 | #define PerlProc_popen(c, m) my_popen((c), (m)) | |
762 | #define PerlProc_pclose(f) my_pclose((f)) | |
763 | #define PerlProc_pipe(fd) pipe((fd)) | |
764 | #define PerlProc_setuid(u) setuid((u)) | |
765 | #define PerlProc_setgid(g) setgid((g)) | |
766 | #define PerlProc_sleep(t) sleep((t)) | |
767 | #define PerlProc_times(t) times((t)) | |
768 | #define PerlProc_wait(t) wait((t)) | |
769 | #define PerlProc_waitpid(p,s,f) waitpid((p), (s), (f)) | |
770 | #define PerlProc_setjmp(b, n) Sigsetjmp((b), (n)) | |
771 | #define PerlProc_longjmp(b, n) Siglongjmp((b), (n)) | |
772 | #define PerlProc_signal(n, h) signal((n), (h)) | |
773 | ||
774 | ||
775 | #endif /* PERL_OBJECT */ | |
776 | ||
777 | /* | |
778 | Interface for perl socket functions | |
779 | */ | |
780 | ||
781 | #ifdef PERL_OBJECT | |
782 | ||
783 | class IPerlSock | |
784 | { | |
785 | public: | |
786 | virtual u_long Htonl(u_long hostlong) = 0; | |
787 | virtual u_short Htons(u_short hostshort) = 0; | |
788 | virtual u_long Ntohl(u_long netlong) = 0; | |
789 | virtual u_short Ntohs(u_short netshort) = 0; | |
790 | virtual SOCKET Accept(SOCKET s, struct sockaddr* addr, | |
791 | int* addrlen, int &err) = 0; | |
792 | virtual int Bind(SOCKET s, const struct sockaddr* name, | |
793 | int namelen, int &err) = 0; | |
794 | virtual int Connect(SOCKET s, const struct sockaddr* name, | |
795 | int namelen, int &err) = 0; | |
796 | virtual void Endhostent(int &err) = 0; | |
797 | virtual void Endnetent(int &err) = 0; | |
798 | virtual void Endprotoent(int &err) = 0; | |
799 | virtual void Endservent(int &err) = 0; | |
800 | virtual int Gethostname(char* name, int namelen, int &err) = 0; | |
801 | virtual int Getpeername(SOCKET s, struct sockaddr* name, | |
802 | int* namelen, int &err) = 0; | |
803 | virtual struct hostent * Gethostbyaddr(const char* addr, int len, | |
804 | int type, int &err) = 0; | |
805 | virtual struct hostent * Gethostbyname(const char* name, int &err) = 0; | |
806 | virtual struct hostent * Gethostent(int &err) = 0; | |
807 | virtual struct netent * Getnetbyaddr(long net, int type, int &err) = 0; | |
808 | virtual struct netent * Getnetbyname(const char *, int &err) = 0; | |
809 | virtual struct netent * Getnetent(int &err) = 0; | |
810 | virtual struct protoent * Getprotobyname(const char* name, int &err) = 0; | |
811 | virtual struct protoent * Getprotobynumber(int number, int &err) = 0; | |
812 | virtual struct protoent * Getprotoent(int &err) = 0; | |
813 | virtual struct servent * Getservbyname(const char* name, | |
814 | const char* proto, int &err) = 0; | |
815 | virtual struct servent * Getservbyport(int port, const char* proto, | |
816 | int &err) = 0; | |
817 | virtual struct servent * Getservent(int &err) = 0; | |
818 | virtual int Getsockname(SOCKET s, struct sockaddr* name, | |
819 | int* namelen, int &err) = 0; | |
820 | virtual int Getsockopt(SOCKET s, int level, int optname, | |
821 | char* optval, int* optlen, int &err) = 0; | |
822 | virtual unsigned long InetAddr(const char* cp, int &err) = 0; | |
823 | virtual char * InetNtoa(struct in_addr in, int &err) = 0; | |
824 | virtual int Listen(SOCKET s, int backlog, int &err) = 0; | |
825 | virtual int Recv(SOCKET s, char* buf, int len, | |
826 | int flags, int &err) = 0; | |
827 | virtual int Recvfrom(SOCKET s, char* buf, int len, int flags, | |
828 | struct sockaddr* from, int* fromlen, int &err) = 0; | |
829 | virtual int Select(int nfds, char* readfds, char* writefds, | |
830 | char* exceptfds, const struct timeval* timeout, | |
831 | int &err) = 0; | |
832 | virtual int Send(SOCKET s, const char* buf, int len, | |
833 | int flags, int &err) = 0; | |
834 | virtual int Sendto(SOCKET s, const char* buf, int len, int flags, | |
835 | const struct sockaddr* to, int tolen, int &err) = 0; | |
836 | virtual void Sethostent(int stayopen, int &err) = 0; | |
837 | virtual void Setnetent(int stayopen, int &err) = 0; | |
838 | virtual void Setprotoent(int stayopen, int &err) = 0; | |
839 | virtual void Setservent(int stayopen, int &err) = 0; | |
840 | virtual int Setsockopt(SOCKET s, int level, int optname, | |
841 | const char* optval, int optlen, int &err) = 0; | |
842 | virtual int Shutdown(SOCKET s, int how, int &err) = 0; | |
843 | virtual SOCKET Socket(int af, int type, int protocol, int &err) = 0; | |
844 | virtual int Socketpair(int domain, int type, int protocol, | |
845 | int* fds, int &err) = 0; | |
846 | #ifdef WIN32 | |
847 | virtual int Closesocket(SOCKET s, int& err) = 0; | |
848 | virtual int Ioctlsocket(SOCKET s, long cmd, u_long *argp, | |
849 | int& err) = 0; | |
850 | #endif | |
851 | }; | |
852 | ||
4c2891ed GS |
853 | #define PerlSock_htonl(x) PL_piSock->Htonl(x) |
854 | #define PerlSock_htons(x) PL_piSock->Htons(x) | |
855 | #define PerlSock_ntohl(x) PL_piSock->Ntohl(x) | |
856 | #define PerlSock_ntohs(x) PL_piSock->Ntohs(x) | |
857 | #define PerlSock_accept(s, a, l) PL_piSock->Accept(s, a, l, ErrorNo()) | |
858 | #define PerlSock_bind(s, n, l) PL_piSock->Bind(s, n, l, ErrorNo()) | |
859 | #define PerlSock_connect(s, n, l) PL_piSock->Connect(s, n, l, ErrorNo()) | |
860 | #define PerlSock_endhostent() PL_piSock->Endhostent(ErrorNo()) | |
861 | #define PerlSock_endnetent() PL_piSock->Endnetent(ErrorNo()) | |
862 | #define PerlSock_endprotoent() PL_piSock->Endprotoent(ErrorNo()) | |
863 | #define PerlSock_endservent() PL_piSock->Endservent(ErrorNo()) | |
864 | #define PerlSock_gethostbyaddr(a, l, t) PL_piSock->Gethostbyaddr(a, l, t, ErrorNo()) | |
865 | #define PerlSock_gethostbyname(n) PL_piSock->Gethostbyname(n, ErrorNo()) | |
866 | #define PerlSock_gethostent() PL_piSock->Gethostent(ErrorNo()) | |
867 | #define PerlSock_gethostname(n, l) PL_piSock->Gethostname(n, l, ErrorNo()) | |
868 | #define PerlSock_getnetbyaddr(n, t) PL_piSock->Getnetbyaddr(n, t, ErrorNo()) | |
869 | #define PerlSock_getnetbyname(c) PL_piSock->Getnetbyname(c, ErrorNo()) | |
870 | #define PerlSock_getnetent() PL_piSock->Getnetent(ErrorNo()) | |
871 | #define PerlSock_getpeername(s, n, l) PL_piSock->Getpeername(s, n, l, ErrorNo()) | |
872 | #define PerlSock_getprotobyname(n) PL_piSock->Getprotobyname(n, ErrorNo()) | |
873 | #define PerlSock_getprotobynumber(n) PL_piSock->Getprotobynumber(n, ErrorNo()) | |
874 | #define PerlSock_getprotoent() PL_piSock->Getprotoent(ErrorNo()) | |
875 | #define PerlSock_getservbyname(n, p) PL_piSock->Getservbyname(n, p, ErrorNo()) | |
876 | #define PerlSock_getservbyport(port, p) PL_piSock->Getservbyport(port, p, ErrorNo()) | |
877 | #define PerlSock_getservent() PL_piSock->Getservent(ErrorNo()) | |
878 | #define PerlSock_getsockname(s, n, l) PL_piSock->Getsockname(s, n, l, ErrorNo()) | |
879 | #define PerlSock_getsockopt(s,l,n,v,i) PL_piSock->Getsockopt(s, l, n, v, i, ErrorNo()) | |
880 | #define PerlSock_inet_addr(c) PL_piSock->InetAddr(c, ErrorNo()) | |
881 | #define PerlSock_inet_ntoa(i) PL_piSock->InetNtoa(i, ErrorNo()) | |
882 | #define PerlSock_listen(s, b) PL_piSock->Listen(s, b, ErrorNo()) | |
883 | #define PerlSock_recv(s, b, l, f) PL_piSock->Recv(s, b, l, f, ErrorNo()) | |
0f4eea8f | 884 | #define PerlSock_recvfrom(s,b,l,f,from,fromlen) \ |
4c2891ed | 885 | PL_piSock->Recvfrom(s, b, l, f, from, fromlen, ErrorNo()) |
0f4eea8f | 886 | #define PerlSock_select(n, r, w, e, t) \ |
4c2891ed GS |
887 | PL_piSock->Select(n, (char*)r, (char*)w, (char*)e, t, ErrorNo()) |
888 | #define PerlSock_send(s, b, l, f) PL_piSock->Send(s, b, l, f, ErrorNo()) | |
0f4eea8f | 889 | #define PerlSock_sendto(s, b, l, f, t, tlen) \ |
4c2891ed GS |
890 | PL_piSock->Sendto(s, b, l, f, t, tlen, ErrorNo()) |
891 | #define PerlSock_sethostent(f) PL_piSock->Sethostent(f, ErrorNo()) | |
892 | #define PerlSock_setnetent(f) PL_piSock->Setnetent(f, ErrorNo()) | |
893 | #define PerlSock_setprotoent(f) PL_piSock->Setprotoent(f, ErrorNo()) | |
894 | #define PerlSock_setservent(f) PL_piSock->Setservent(f, ErrorNo()) | |
0f4eea8f | 895 | #define PerlSock_setsockopt(s, l, n, v, len) \ |
4c2891ed GS |
896 | PL_piSock->Setsockopt(s, l, n, v, len, ErrorNo()) |
897 | #define PerlSock_shutdown(s, h) PL_piSock->Shutdown(s, h, ErrorNo()) | |
898 | #define PerlSock_socket(a, t, p) PL_piSock->Socket(a, t, p, ErrorNo()) | |
899 | #define PerlSock_socketpair(a, t, p, f) PL_piSock->Socketpair(a, t, p, f, ErrorNo()) | |
0f4eea8f DL |
900 | |
901 | #else /* PERL_OBJECT */ | |
902 | ||
903 | #define PerlSock_htonl(x) htonl(x) | |
904 | #define PerlSock_htons(x) htons(x) | |
905 | #define PerlSock_ntohl(x) ntohl(x) | |
906 | #define PerlSock_ntohs(x) ntohs(x) | |
907 | #define PerlSock_accept(s, a, l) accept(s, a, l) | |
908 | #define PerlSock_bind(s, n, l) bind(s, n, l) | |
909 | #define PerlSock_connect(s, n, l) connect(s, n, l) | |
910 | ||
911 | #define PerlSock_gethostbyaddr(a, l, t) gethostbyaddr(a, l, t) | |
912 | #define PerlSock_gethostbyname(n) gethostbyname(n) | |
913 | #define PerlSock_gethostent gethostent | |
914 | #define PerlSock_endhostent endhostent | |
915 | #define PerlSock_gethostname(n, l) gethostname(n, l) | |
916 | ||
917 | #define PerlSock_getnetbyaddr(n, t) getnetbyaddr(n, t) | |
918 | #define PerlSock_getnetbyname(n) getnetbyname(n) | |
919 | #define PerlSock_getnetent getnetent | |
920 | #define PerlSock_endnetent endnetent | |
921 | #define PerlSock_getpeername(s, n, l) getpeername(s, n, l) | |
922 | ||
923 | #define PerlSock_getprotobyname(n) getprotobyname(n) | |
924 | #define PerlSock_getprotobynumber(n) getprotobynumber(n) | |
925 | #define PerlSock_getprotoent getprotoent | |
926 | #define PerlSock_endprotoent endprotoent | |
927 | ||
928 | #define PerlSock_getservbyname(n, p) getservbyname(n, p) | |
929 | #define PerlSock_getservbyport(port, p) getservbyport(port, p) | |
930 | #define PerlSock_getservent getservent | |
931 | #define PerlSock_endservent endservent | |
932 | ||
933 | #define PerlSock_getsockname(s, n, l) getsockname(s, n, l) | |
934 | #define PerlSock_getsockopt(s,l,n,v,i) getsockopt(s, l, n, v, i) | |
935 | #define PerlSock_inet_addr(c) inet_addr(c) | |
936 | #define PerlSock_inet_ntoa(i) inet_ntoa(i) | |
937 | #define PerlSock_listen(s, b) listen(s, b) | |
c6af7a1a | 938 | #define PerlSock_recv(s, b, l, f) recv(s, b, l, f) |
0f4eea8f DL |
939 | #define PerlSock_recvfrom(s, b, l, f, from, fromlen) \ |
940 | recvfrom(s, b, l, f, from, fromlen) | |
941 | #define PerlSock_select(n, r, w, e, t) select(n, r, w, e, t) | |
942 | #define PerlSock_send(s, b, l, f) send(s, b, l, f) | |
943 | #define PerlSock_sendto(s, b, l, f, t, tlen) \ | |
944 | sendto(s, b, l, f, t, tlen) | |
945 | #define PerlSock_sethostent(f) sethostent(f) | |
946 | #define PerlSock_setnetent(f) setnetent(f) | |
947 | #define PerlSock_setprotoent(f) setprotoent(f) | |
948 | #define PerlSock_setservent(f) setservent(f) | |
949 | #define PerlSock_setsockopt(s, l, n, v, len) \ | |
950 | setsockopt(s, l, n, v, len) | |
951 | #define PerlSock_shutdown(s, h) shutdown(s, h) | |
952 | #define PerlSock_socket(a, t, p) socket(a, t, p) | |
953 | #define PerlSock_socketpair(a, t, p, f) socketpair(a, t, p, f) | |
954 | ||
955 | ||
956 | #endif /* PERL_OBJECT */ | |
957 | ||
de4597cb JH |
958 | /* Mention |
959 | ||
960 | HAS_READV | |
961 | HAS_RECVMSG | |
962 | HAS_SENDMSG | |
963 | HAS_WRITEV | |
964 | HAS_STRUCT_MSGHDR | |
965 | HAS_STRUCT_CMSGHDR | |
de4597cb JH |
966 | |
967 | here so that Configure picks them up. Perl core does not | |
6b1016b5 JH |
968 | use them but somebody might want to extend Socket:: or IO:: |
969 | someday. | |
de4597cb JH |
970 | |
971 | Jarkko Hietaniemi November 1998 | |
972 | ||
973 | */ | |
974 | ||
0f4eea8f DL |
975 | #endif /* __Inc__IPerl___ */ |
976 |