Commit | Line | Data |
---|---|---|
e3b8966e GS |
1 | |
2 | # creates a C API file from proto.h | |
3 | # takes one argument, the path to lib/CORE directory. | |
6de196ee | 4 | # creates 2 files: "perlCAPI.cpp" and "perlCAPI.h". |
e3b8966e | 5 | |
6de196ee | 6 | my $hdrfile = "$ARGV[0]\\perlCAPI.h"; |
e3b8966e GS |
7 | my $infile = '..\\proto.h'; |
8 | my $embedfile = '..\\embed.h'; | |
9 | my $separateObj = 0; | |
10 | ||
11 | my %skip_list; | |
12 | my %embed; | |
13 | ||
14 | sub readembed(\%$) { | |
15 | my ($syms, $file) = @_; | |
16 | my ($line, @words); | |
17 | %$syms = (); | |
18 | local (*FILE, $_); | |
19 | open(FILE, "< $file") | |
20 | or die "$0: Can't open $file: $!\n"; | |
21 | while ($line = <FILE>) { | |
22 | chop($line); | |
23 | if ($line =~ /^#define\s+\w+/) { | |
24 | $line =~ s/^#define\s+//; | |
25 | @words = split ' ', $line; | |
26 | # print "$words[0]\t$words[1]\n"; | |
27 | $$syms{$words[0]} = $words[1]; | |
28 | } | |
29 | } | |
30 | close(FILE); | |
31 | } | |
32 | ||
33 | readembed %embed, $embedfile; | |
34 | ||
35 | sub skip_these { | |
36 | my $list = shift; | |
37 | foreach my $symbol (@$list) { | |
38 | $skip_list{$symbol} = 1; | |
39 | } | |
40 | } | |
41 | ||
42 | skip_these [qw( | |
43 | cando | |
44 | cast_ulong | |
45 | my_chsize | |
46 | condpair_magic | |
47 | deb | |
48 | deb_growlevel | |
49 | debprofdump | |
50 | debop | |
51 | debstack | |
52 | debstackptrs | |
58a50f62 GS |
53 | dump_fds |
54 | dump_mstats | |
e3b8966e GS |
55 | fprintf |
56 | find_threadsv | |
57 | magic_mutexfree | |
58a50f62 GS |
58 | my_memcmp |
59 | my_memset | |
e3b8966e GS |
60 | my_pclose |
61 | my_popen | |
62 | my_swap | |
63 | my_htonl | |
64 | my_ntohl | |
65 | new_struct_thread | |
66 | same_dirent | |
67 | unlnk | |
68 | unlock_condpair | |
69 | safexmalloc | |
70 | safexcalloc | |
71 | safexrealloc | |
72 | safexfree | |
73 | Perl_GetVars | |
066ef5b5 | 74 | malloced_size |
e3b8966e GS |
75 | )]; |
76 | ||
77 | ||
78 | ||
79 | if (!open(INFILE, "<$infile")) { | |
80 | print "open of $infile failed: $!\n"; | |
81 | return 1; | |
82 | } | |
83 | ||
6de196ee GS |
84 | if (!open(OUTFILE, ">perlCAPI.cpp")) { |
85 | print "open of perlCAPI.cpp failed: $!\n"; | |
e3b8966e GS |
86 | return 1; |
87 | } | |
88 | ||
b207eff1 GS |
89 | print OUTFILE <<ENDCODE; |
90 | #include "EXTERN.h" | |
91 | #include "perl.h" | |
92 | #include "XSUB.h" | |
93 | ||
94 | #define DESTRUCTORFUNC (void (*)(void*)) | |
95 | ||
96 | ENDCODE | |
97 | ||
98 | print OUTFILE "#ifdef SetCPerlObj_defined\n" unless ($separateObj == 0); | |
99 | ||
100 | print OUTFILE <<ENDCODE; | |
101 | extern "C" void SetCPerlObj(CPerlObj* pP) | |
102 | { | |
103 | pPerl = pP; | |
104 | } | |
105 | ||
106 | ENDCODE | |
107 | ||
e3b8966e GS |
108 | print OUTFILE "#endif\n" unless ($separateObj == 0); |
109 | ||
110 | while () { | |
111 | last unless defined ($_ = <INFILE>); | |
112 | if (/^VIRTUAL\s/) { | |
113 | while (!/;$/) { | |
114 | chomp; | |
115 | $_ .= <INFILE>; | |
116 | } | |
117 | $_ =~ s/^VIRTUAL\s*//; | |
118 | $_ =~ s/\s*__attribute__.*$/;/; | |
119 | if ( /(.*)\s([A-z_]*[0-9A-z_]+\s)_\(\((.*)\)\);/ || | |
120 | /(.*)\*([A-z_]*[0-9A-z_]+\s)_\(\((.*)\)\);/ ) { | |
121 | $type = $1; | |
122 | $name = $2; | |
123 | $args = $3; | |
124 | ||
125 | $name =~ s/\s*$//; | |
126 | $type =~ s/\s*$//; | |
127 | next if (defined $skip_list{$name}); | |
128 | ||
129 | if($args eq "ARGSproto") { | |
130 | $args = "void"; | |
131 | } | |
132 | ||
133 | $return = ($type eq "void" or $type eq "Free_t") ? "\t" : "\treturn"; | |
134 | ||
135 | if(defined $embed{$name}) { | |
136 | $funcName = $embed{$name}; | |
137 | } else { | |
138 | $funcName = $name; | |
139 | } | |
140 | ||
141 | @args = split(',', $args); | |
142 | if ($args[$#args] =~ /\s*\.\.\.\s*/) { | |
143 | if(($name eq "croak") or ($name eq "deb") or ($name eq "die") | |
144 | or ($name eq "form") or ($name eq "warn")) { | |
145 | print OUTFILE "\n#ifdef $name" . "_defined" unless ($separateObj == 0); | |
e3b8966e GS |
146 | $args[0] =~ /(\w+)\W*$/; |
147 | $arg = $1; | |
b207eff1 GS |
148 | print OUTFILE <<ENDCODE; |
149 | ||
150 | #undef $name | |
151 | extern "C" $type $funcName ($args) | |
152 | { | |
153 | char *pstr; | |
154 | char *pmsg; | |
155 | va_list args; | |
156 | va_start(args, $arg); | |
157 | pmsg = pPerl->Perl_mess($arg, &args); | |
158 | New(0, pstr, strlen(pmsg)+1, char); | |
159 | strcpy(pstr, pmsg); | |
160 | $return pPerl->Perl_$name(pstr); | |
161 | va_end(args); | |
162 | } | |
163 | ENDCODE | |
e3b8966e GS |
164 | print OUTFILE "#endif\n" unless ($separateObj == 0); |
165 | } | |
166 | elsif($name eq "newSVpvf") { | |
167 | print OUTFILE "\n#ifdef $name" . "_defined" unless ($separateObj == 0); | |
e3b8966e GS |
168 | $args[0] =~ /(\w+)\W*$/; |
169 | $arg = $1; | |
b207eff1 GS |
170 | print OUTFILE <<ENDCODE; |
171 | ||
172 | #undef $name | |
173 | extern "C" $type $funcName ($args) | |
174 | { | |
175 | SV *sv; | |
176 | va_list args; | |
177 | va_start(args, $arg); | |
178 | sv = pPerl->Perl_newSV(0); | |
179 | pPerl->Perl_sv_vcatpvfn(sv, $arg, strlen($arg), &args, NULL, 0, NULL); | |
180 | va_end(args); | |
181 | return sv; | |
182 | } | |
183 | ENDCODE | |
e3b8966e GS |
184 | print OUTFILE "#endif\n" unless ($separateObj == 0); |
185 | } | |
186 | elsif($name eq "sv_catpvf") { | |
187 | print OUTFILE "\n#ifdef $name" . "_defined" unless ($separateObj == 0); | |
e3b8966e GS |
188 | $args[0] =~ /(\w+)\W*$/; |
189 | $arg0 = $1; | |
190 | $args[1] =~ /(\w+)\W*$/; | |
191 | $arg1 = $1; | |
b207eff1 GS |
192 | print OUTFILE <<ENDCODE; |
193 | ||
194 | #undef $name | |
195 | extern "C" $type $funcName ($args) | |
196 | { | |
197 | va_list args; | |
198 | va_start(args, $arg1); | |
199 | pPerl->Perl_sv_vcatpvfn($arg0, $arg1, strlen($arg1), &args, NULL, 0, NULL); | |
200 | va_end(args); | |
201 | } | |
202 | ENDCODE | |
e3b8966e GS |
203 | print OUTFILE "#endif\n" unless ($separateObj == 0); |
204 | } | |
46d2b8ef GS |
205 | elsif($name eq "sv_catpvf_mg") { |
206 | print OUTFILE "\n#ifdef $name" . "_defined" unless ($separateObj == 0); | |
207 | $args[0] =~ /(\w+)\W*$/; | |
208 | $arg0 = $1; | |
209 | $args[1] =~ /(\w+)\W*$/; | |
210 | $arg1 = $1; | |
211 | print OUTFILE <<ENDCODE; | |
212 | ||
213 | #undef $name | |
214 | #ifndef mg_set | |
215 | #define mg_set pPerl->Perl_mg_set | |
216 | #endif | |
217 | extern "C" $type $funcName ($args) | |
218 | { | |
219 | va_list args; | |
220 | va_start(args, $arg1); | |
221 | pPerl->Perl_sv_vcatpvfn($arg0, $arg1, strlen($arg1), &args, NULL, 0, NULL); | |
222 | va_end(args); | |
223 | SvSETMAGIC(sv); | |
224 | } | |
225 | ENDCODE | |
226 | print OUTFILE "#endif\n" unless ($separateObj == 0); | |
227 | } | |
e3b8966e GS |
228 | elsif($name eq "sv_setpvf") { |
229 | print OUTFILE "\n#ifdef $name" . "_defined" unless ($separateObj == 0); | |
e3b8966e GS |
230 | $args[0] =~ /(\w+)\W*$/; |
231 | $arg0 = $1; | |
232 | $args[1] =~ /(\w+)\W*$/; | |
233 | $arg1 = $1; | |
b207eff1 GS |
234 | print OUTFILE <<ENDCODE; |
235 | ||
236 | #undef $name | |
237 | extern "C" $type $funcName ($args) | |
238 | { | |
239 | va_list args; | |
240 | va_start(args, $arg1); | |
241 | pPerl->Perl_sv_vsetpvfn($arg0, $arg1, strlen($arg1), &args, NULL, 0, NULL); | |
242 | va_end(args); | |
243 | } | |
244 | ENDCODE | |
e3b8966e GS |
245 | print OUTFILE "#endif\n" unless ($separateObj == 0); |
246 | } | |
46d2b8ef GS |
247 | elsif($name eq "sv_setpvf_mg") { |
248 | print OUTFILE "\n#ifdef $name" . "_defined" unless ($separateObj == 0); | |
249 | $args[0] =~ /(\w+)\W*$/; | |
250 | $arg0 = $1; | |
251 | $args[1] =~ /(\w+)\W*$/; | |
252 | $arg1 = $1; | |
253 | print OUTFILE <<ENDCODE; | |
254 | ||
255 | #undef $name | |
256 | #ifndef mg_set | |
257 | #define mg_set pPerl->Perl_mg_set | |
258 | #endif | |
259 | extern "C" $type $funcName ($args) | |
260 | { | |
261 | va_list args; | |
262 | va_start(args, $arg1); | |
263 | pPerl->Perl_sv_vsetpvfn($arg0, $arg1, strlen($arg1), &args, NULL, 0, NULL); | |
264 | va_end(args); | |
265 | SvSETMAGIC(sv); | |
266 | } | |
267 | ENDCODE | |
268 | print OUTFILE "#endif\n" unless ($separateObj == 0); | |
269 | } | |
e3b8966e GS |
270 | elsif($name eq "fprintf") { |
271 | print OUTFILE "\n#ifdef $name" . "_defined" unless ($separateObj == 0); | |
e3b8966e GS |
272 | $args[0] =~ /(\w+)\W*$/; |
273 | $arg0 = $1; | |
274 | $args[1] =~ /(\w+)\W*$/; | |
275 | $arg1 = $1; | |
b207eff1 GS |
276 | print OUTFILE <<ENDCODE; |
277 | ||
278 | #undef $name | |
279 | extern "C" $type $name ($args) | |
280 | { | |
281 | int nRet; | |
282 | va_list args; | |
283 | va_start(args, $arg1); | |
284 | nRet = PerlIO_vprintf($arg0, $arg1, args); | |
285 | va_end(args); | |
286 | return nRet; | |
287 | } | |
288 | ENDCODE | |
e3b8966e GS |
289 | print OUTFILE "#endif\n" unless ($separateObj == 0); |
290 | } else { | |
291 | print "Warning: can't handle varargs function '$name'\n"; | |
292 | } | |
293 | next; | |
294 | } | |
295 | ||
296 | # newXS special case | |
297 | if ($name eq "newXS") { | |
298 | next; | |
299 | } | |
300 | ||
301 | print OUTFILE "\n#ifdef $name" . "defined" unless ($separateObj == 0); | |
302 | ||
303 | # handle specical case for save_destructor | |
304 | if ($name eq "save_destructor") { | |
305 | next; | |
306 | } | |
307 | # handle specical case for sighandler | |
308 | if ($name eq "sighandler") { | |
309 | next; | |
310 | } | |
311 | # handle special case for sv_grow | |
312 | if ($name eq "sv_grow" and $args eq "SV* sv, unsigned long newlen") { | |
313 | next; | |
314 | } | |
315 | # handle special case for newSV | |
316 | if ($name eq "newSV" and $args eq "I32 x, STRLEN len") { | |
317 | next; | |
318 | } | |
319 | # handle special case for perl_parse | |
320 | if ($name eq "perl_parse") { | |
b207eff1 GS |
321 | print OUTFILE <<ENDCODE; |
322 | ||
323 | #undef $name | |
324 | extern "C" $type $name ($args) | |
325 | { | |
326 | return pPerl->perl_parse(xsinit, argc, argv, env); | |
327 | } | |
328 | ENDCODE | |
e3b8966e GS |
329 | print OUTFILE "#endif\n" unless ($separateObj == 0); |
330 | next; | |
331 | } | |
35ff7856 GS |
332 | # handle special case for perl_atexit |
333 | if ($name eq "perl_atexit") { | |
334 | print OUTFILE <<ENDCODE; | |
335 | ||
336 | #undef $name | |
337 | extern "C" $type $name ($args) | |
338 | { | |
58a50f62 | 339 | pPerl->perl_atexit(fn, ptr); |
35ff7856 GS |
340 | } |
341 | ENDCODE | |
342 | print OUTFILE "#endif\n" unless ($separateObj == 0); | |
343 | next; | |
344 | } | |
345 | ||
e3b8966e | 346 | |
9e6b2b00 GS |
347 | if($name eq "byterun" and $args eq "struct bytestream bs") { |
348 | next; | |
349 | } | |
350 | ||
e3b8966e GS |
351 | # foo(void); |
352 | if ($args eq "void") { | |
b207eff1 GS |
353 | print OUTFILE <<ENDCODE; |
354 | ||
355 | #undef $name | |
356 | extern "C" $type $funcName () | |
357 | { | |
358 | $return pPerl->$funcName(); | |
359 | } | |
360 | ||
361 | ENDCODE | |
e3b8966e GS |
362 | print OUTFILE "#endif\n" unless ($separateObj == 0); |
363 | next; | |
364 | } | |
365 | ||
366 | # foo(char *s, const int bar); | |
b207eff1 GS |
367 | print OUTFILE <<ENDCODE; |
368 | ||
369 | #undef $name | |
370 | extern "C" $type $funcName ($args) | |
371 | { | |
b207eff1 | 372 | ENDCODE |
35ff7856 | 373 | print OUTFILE "$return pPerl->$funcName"; |
e3b8966e GS |
374 | $doneone = 0; |
375 | foreach $arg (@args) { | |
376 | if ($arg =~ /(\w+)\W*$/) { | |
377 | if ($doneone) { | |
378 | print OUTFILE ", $1"; | |
379 | } | |
380 | else { | |
381 | print OUTFILE "($1"; | |
382 | $doneone++; | |
383 | } | |
384 | } | |
385 | } | |
386 | print OUTFILE ");\n}\n"; | |
387 | print OUTFILE "#endif\n" unless ($separateObj == 0); | |
388 | } | |
389 | else { | |
390 | print "failed to match $_"; | |
391 | } | |
392 | } | |
393 | } | |
394 | ||
395 | close INFILE; | |
396 | ||
397 | %skip_list = (); | |
398 | ||
399 | skip_these [qw( | |
400 | strchop | |
401 | filemode | |
402 | lastfd | |
403 | oldname | |
404 | curinterp | |
405 | Argv | |
406 | Cmd | |
407 | sortcop | |
408 | sortstash | |
409 | firstgv | |
410 | secondgv | |
411 | sortstack | |
412 | signalstack | |
413 | mystrk | |
414 | dumplvl | |
415 | oldlastpm | |
416 | gensym | |
417 | preambled | |
418 | preambleav | |
419 | Ilaststatval | |
420 | Ilaststype | |
421 | mess_sv | |
422 | ors | |
423 | opsave | |
424 | eval_mutex | |
0c005962 | 425 | strtab_mutex |
e3b8966e GS |
426 | orslen |
427 | ofmt | |
e3b8966e GS |
428 | modcount |
429 | generation | |
430 | DBcv | |
431 | archpat_auto | |
432 | sortcxix | |
433 | lastgotoprobe | |
434 | regdummy | |
77d41b28 | 435 | regcomp_parse |
e3b8966e GS |
436 | regxend |
437 | regcode | |
438 | regnaughty | |
439 | regsawback | |
440 | regprecomp | |
441 | regnpar | |
442 | regsize | |
443 | regflags | |
444 | regseen | |
445 | seen_zerolen | |
77d41b28 | 446 | regcomp_rx |
e3b8966e GS |
447 | extralen |
448 | colorset | |
449 | colors | |
450 | reginput | |
451 | regbol | |
452 | regeol | |
453 | regstartp | |
454 | regendp | |
455 | reglastparen | |
456 | regtill | |
457 | regprev | |
458 | reg_start_tmp | |
459 | reg_start_tmpl | |
460 | regdata | |
461 | bostr | |
462 | reg_flags | |
463 | reg_eval_set | |
464 | regnarrate | |
465 | regprogram | |
466 | regindent | |
467 | regcc | |
468 | in_clean_objs | |
469 | in_clean_all | |
470 | linestart | |
471 | pending_ident | |
472 | statusvalue_vms | |
473 | sublex_info | |
474 | thrsv | |
475 | threadnum | |
4c2891ed GS |
476 | PL_piMem |
477 | PL_piENV | |
478 | PL_piStdIO | |
479 | PL_piLIO | |
480 | PL_piDir | |
481 | PL_piSock | |
482 | PL_piProc | |
e3b8966e GS |
483 | cshname |
484 | threadsv_names | |
485 | thread | |
486 | nthreads | |
487 | thr_key | |
488 | threads_mutex | |
489 | malloc_mutex | |
490 | svref_mutex | |
491 | sv_mutex | |
492 | nthreads_cond | |
493 | eval_cond | |
494 | cryptseen | |
495 | cshlen | |
496 | )]; | |
497 | ||
498 | sub readvars(\%$$) { | |
499 | my ($syms, $file, $pre) = @_; | |
500 | %$syms = (); | |
501 | local (*FILE, $_); | |
502 | open(FILE, "< $file") | |
503 | or die "$0: Can't open $file: $!\n"; | |
504 | while (<FILE>) { | |
505 | s/[ \t]*#.*//; # Delete comments. | |
506 | if (/PERLVARI?C?\($pre(\w+),\s*([^,)]+)/) { | |
507 | $$syms{$1} = $2; | |
508 | } | |
509 | } | |
510 | close(FILE); | |
511 | } | |
512 | ||
513 | my %intrp; | |
514 | my %thread; | |
515 | my %globvar; | |
516 | ||
517 | readvars %intrp, '..\intrpvar.h','I'; | |
518 | readvars %thread, '..\thrdvar.h','T'; | |
519 | readvars %globvar, '..\perlvars.h','G'; | |
520 | ||
521 | open(HDRFILE, ">$hdrfile") or die "$0: Can't open $hdrfile: $!\n"; | |
b207eff1 GS |
522 | print HDRFILE <<ENDCODE; |
523 | void SetCPerlObj(void* pP); | |
524 | CV* Perl_newXS(char* name, void (*subaddr)(CV* cv), char* filename); | |
525 | ||
526 | ENDCODE | |
e3b8966e GS |
527 | |
528 | sub DoVariable($$) { | |
529 | my $name = shift; | |
530 | my $type = shift; | |
531 | ||
532 | return if (defined $skip_list{$name}); | |
533 | return if ($type eq 'struct perl_thread *'); | |
534 | ||
535 | print OUTFILE "\n#ifdef $name" . "_defined" unless ($separateObj == 0); | |
b207eff1 | 536 | print OUTFILE <<ENDCODE; |
4c2891ed GS |
537 | #undef PL_$name |
538 | extern "C" $type * _PL_$name () | |
b207eff1 | 539 | { |
4c2891ed | 540 | return (($type *)&pPerl->PL_$name); |
b207eff1 GS |
541 | } |
542 | ||
543 | ENDCODE | |
544 | ||
e3b8966e GS |
545 | print OUTFILE "#endif\n" unless ($separateObj == 0); |
546 | ||
b207eff1 GS |
547 | print HDRFILE <<ENDCODE; |
548 | ||
4c2891ed GS |
549 | #undef PL_$name |
550 | $type * _PL_$name (); | |
551 | #define PL_$name (*_PL_$name()) | |
b207eff1 GS |
552 | |
553 | ENDCODE | |
554 | ||
e3b8966e GS |
555 | } |
556 | ||
557 | foreach $key (keys %intrp) { | |
558 | DoVariable ($key, $intrp{$key}); | |
559 | } | |
560 | ||
561 | foreach $key (keys %thread) { | |
562 | DoVariable ($key, $thread{$key}); | |
563 | } | |
564 | ||
565 | foreach $key (keys %globvar) { | |
566 | DoVariable ($key, $globvar{$key}); | |
567 | } | |
568 | ||
569 | print OUTFILE <<EOCODE; | |
570 | ||
571 | ||
572 | extern "C" { | |
9e6b2b00 GS |
573 | |
574 | ||
575 | char ** _Perl_op_desc(void) | |
576 | { | |
577 | return pPerl->Perl_get_op_descs(); | |
578 | } | |
579 | ||
580 | char ** _Perl_op_name(void) | |
581 | { | |
582 | return pPerl->Perl_get_op_names(); | |
583 | } | |
584 | ||
585 | char * _Perl_no_modify(void) | |
586 | { | |
587 | return pPerl->Perl_get_no_modify(); | |
588 | } | |
589 | ||
590 | U32 * _Perl_opargs(void) | |
591 | { | |
592 | return pPerl->Perl_get_opargs(); | |
593 | } | |
594 | ||
b207eff1 | 595 | void xs_handler(CV* cv, CPerlObj* p) |
e3b8966e GS |
596 | { |
597 | void(*func)(CV*); | |
598 | SV* sv; | |
599 | MAGIC* m = pPerl->Perl_mg_find((SV*)cv, '~'); | |
600 | if(m != NULL) | |
601 | { | |
602 | sv = m->mg_obj; | |
603 | if(SvIOK(sv)) | |
604 | { | |
605 | func = (void(*)(CV*))SvIVX(sv); | |
606 | } | |
607 | else | |
608 | { | |
609 | func = (void(*)(CV*))pPerl->Perl_sv_2iv(sv); | |
610 | } | |
e3b8966e GS |
611 | func(cv); |
612 | } | |
613 | } | |
614 | ||
615 | CV* Perl_newXS(char* name, void (*subaddr)(CV* cv), char* filename) | |
616 | { | |
617 | CV* cv = pPerl->Perl_newXS(name, xs_handler, filename); | |
618 | pPerl->Perl_sv_magic((SV*)cv, pPerl->Perl_sv_2mortal(pPerl->Perl_newSViv((IV)subaddr)), '~', "CAPI", 4); | |
619 | return cv; | |
620 | } | |
621 | ||
b207eff1 GS |
622 | |
623 | void Perl_deb(const char pat, ...) | |
624 | { | |
625 | } | |
626 | ||
4c2891ed GS |
627 | #undef PL_piMem |
628 | #undef PL_piENV | |
629 | #undef PL_piStdIO | |
630 | #undef PL_piLIO | |
631 | #undef PL_piDir | |
632 | #undef PL_piSock | |
633 | #undef PL_piProc | |
e3b8966e GS |
634 | |
635 | int * _win32_errno(void) | |
636 | { | |
637 | return &pPerl->ErrorNo(); | |
638 | } | |
639 | ||
640 | FILE* _win32_stdin(void) | |
641 | { | |
4c2891ed | 642 | return (FILE*)pPerl->PL_piStdIO->Stdin(); |
e3b8966e GS |
643 | } |
644 | ||
645 | FILE* _win32_stdout(void) | |
646 | { | |
4c2891ed | 647 | return (FILE*)pPerl->PL_piStdIO->Stdout(); |
e3b8966e GS |
648 | } |
649 | ||
650 | FILE* _win32_stderr(void) | |
651 | { | |
4c2891ed | 652 | return (FILE*)pPerl->PL_piStdIO->Stderr(); |
e3b8966e GS |
653 | } |
654 | ||
655 | int _win32_ferror(FILE *fp) | |
656 | { | |
4c2891ed | 657 | return pPerl->PL_piStdIO->Error((PerlIO*)fp, ErrorNo()); |
e3b8966e GS |
658 | } |
659 | ||
660 | int _win32_feof(FILE *fp) | |
661 | { | |
4c2891ed | 662 | return pPerl->PL_piStdIO->Eof((PerlIO*)fp, ErrorNo()); |
e3b8966e GS |
663 | } |
664 | ||
665 | char* _win32_strerror(int e) | |
666 | { | |
667 | return strerror(e); | |
668 | } | |
669 | ||
670 | void _win32_perror(const char *str) | |
671 | { | |
672 | perror(str); | |
673 | } | |
674 | ||
675 | int _win32_vfprintf(FILE *pf, const char *format, va_list arg) | |
676 | { | |
4c2891ed | 677 | return pPerl->PL_piStdIO->Vprintf((PerlIO*)pf, ErrorNo(), format, arg); |
e3b8966e GS |
678 | } |
679 | ||
680 | int _win32_vprintf(const char *format, va_list arg) | |
681 | { | |
4c2891ed | 682 | return pPerl->PL_piStdIO->Vprintf(pPerl->PL_piStdIO->Stdout(), ErrorNo(), format, arg); |
e3b8966e GS |
683 | } |
684 | ||
685 | int _win32_fprintf(FILE *pf, const char *format, ...) | |
686 | { | |
687 | int ret; | |
688 | va_list args; | |
689 | va_start(args, format); | |
690 | ret = _win32_vfprintf(pf, format, args); | |
691 | va_end(args); | |
692 | return ret; | |
693 | } | |
694 | ||
695 | int _win32_printf(const char *format, ...) | |
696 | { | |
697 | int ret; | |
698 | va_list args; | |
699 | va_start(args, format); | |
700 | ret = _win32_vprintf(format, args); | |
701 | va_end(args); | |
702 | return ret; | |
703 | } | |
704 | ||
705 | size_t _win32_fread(void *buf, size_t size, size_t count, FILE *pf) | |
706 | { | |
4c2891ed | 707 | return pPerl->PL_piStdIO->Read((PerlIO*)pf, buf, (size*count), ErrorNo()); |
e3b8966e GS |
708 | } |
709 | ||
710 | size_t _win32_fwrite(const void *buf, size_t size, size_t count, FILE *pf) | |
711 | { | |
4c2891ed | 712 | return pPerl->PL_piStdIO->Write((PerlIO*)pf, buf, (size*count), ErrorNo()); |
e3b8966e GS |
713 | } |
714 | ||
715 | FILE* _win32_fopen(const char *path, const char *mode) | |
716 | { | |
4c2891ed | 717 | return (FILE*)pPerl->PL_piStdIO->Open(path, mode, ErrorNo()); |
e3b8966e GS |
718 | } |
719 | ||
720 | FILE* _win32_fdopen(int fh, const char *mode) | |
721 | { | |
4c2891ed | 722 | return (FILE*)pPerl->PL_piStdIO->Fdopen(fh, mode, ErrorNo()); |
e3b8966e GS |
723 | } |
724 | ||
725 | FILE* _win32_freopen(const char *path, const char *mode, FILE *pf) | |
726 | { | |
4c2891ed | 727 | return (FILE*)pPerl->PL_piStdIO->Reopen(path, mode, (PerlIO*)pf, ErrorNo()); |
e3b8966e GS |
728 | } |
729 | ||
730 | int _win32_fclose(FILE *pf) | |
731 | { | |
4c2891ed | 732 | return pPerl->PL_piStdIO->Close((PerlIO*)pf, ErrorNo()); |
e3b8966e GS |
733 | } |
734 | ||
735 | int _win32_fputs(const char *s,FILE *pf) | |
736 | { | |
4c2891ed | 737 | return pPerl->PL_piStdIO->Puts((PerlIO*)pf, s, ErrorNo()); |
e3b8966e GS |
738 | } |
739 | ||
740 | int _win32_fputc(int c,FILE *pf) | |
741 | { | |
4c2891ed | 742 | return pPerl->PL_piStdIO->Putc((PerlIO*)pf, c, ErrorNo()); |
e3b8966e GS |
743 | } |
744 | ||
745 | int _win32_ungetc(int c,FILE *pf) | |
746 | { | |
4c2891ed | 747 | return pPerl->PL_piStdIO->Ungetc((PerlIO*)pf, c, ErrorNo()); |
e3b8966e GS |
748 | } |
749 | ||
750 | int _win32_getc(FILE *pf) | |
751 | { | |
4c2891ed | 752 | return pPerl->PL_piStdIO->Getc((PerlIO*)pf, ErrorNo()); |
e3b8966e GS |
753 | } |
754 | ||
755 | int _win32_fileno(FILE *pf) | |
756 | { | |
4c2891ed | 757 | return pPerl->PL_piStdIO->Fileno((PerlIO*)pf, ErrorNo()); |
e3b8966e GS |
758 | } |
759 | ||
760 | void _win32_clearerr(FILE *pf) | |
761 | { | |
4c2891ed | 762 | pPerl->PL_piStdIO->Clearerr((PerlIO*)pf, ErrorNo()); |
e3b8966e GS |
763 | } |
764 | ||
765 | int _win32_fflush(FILE *pf) | |
766 | { | |
4c2891ed | 767 | return pPerl->PL_piStdIO->Flush((PerlIO*)pf, ErrorNo()); |
e3b8966e GS |
768 | } |
769 | ||
770 | long _win32_ftell(FILE *pf) | |
771 | { | |
4c2891ed | 772 | return pPerl->PL_piStdIO->Tell((PerlIO*)pf, ErrorNo()); |
e3b8966e GS |
773 | } |
774 | ||
775 | int _win32_fseek(FILE *pf,long offset,int origin) | |
776 | { | |
4c2891ed | 777 | return pPerl->PL_piStdIO->Seek((PerlIO*)pf, offset, origin, ErrorNo()); |
e3b8966e GS |
778 | } |
779 | ||
780 | int _win32_fgetpos(FILE *pf,fpos_t *p) | |
781 | { | |
4c2891ed | 782 | return pPerl->PL_piStdIO->Getpos((PerlIO*)pf, p, ErrorNo()); |
e3b8966e GS |
783 | } |
784 | ||
785 | int _win32_fsetpos(FILE *pf,const fpos_t *p) | |
786 | { | |
4c2891ed | 787 | return pPerl->PL_piStdIO->Setpos((PerlIO*)pf, p, ErrorNo()); |
e3b8966e GS |
788 | } |
789 | ||
790 | void _win32_rewind(FILE *pf) | |
791 | { | |
4c2891ed | 792 | pPerl->PL_piStdIO->Rewind((PerlIO*)pf, ErrorNo()); |
e3b8966e GS |
793 | } |
794 | ||
795 | FILE* _win32_tmpfile(void) | |
796 | { | |
4c2891ed | 797 | return (FILE*)pPerl->PL_piStdIO->Tmpfile(ErrorNo()); |
e3b8966e GS |
798 | } |
799 | ||
800 | void _win32_setbuf(FILE *pf, char *buf) | |
801 | { | |
4c2891ed | 802 | pPerl->PL_piStdIO->SetBuf((PerlIO*)pf, buf, ErrorNo()); |
e3b8966e GS |
803 | } |
804 | ||
805 | int _win32_setvbuf(FILE *pf, char *buf, int type, size_t size) | |
806 | { | |
4c2891ed | 807 | return pPerl->PL_piStdIO->SetVBuf((PerlIO*)pf, buf, type, size, ErrorNo()); |
e3b8966e GS |
808 | } |
809 | ||
9e6b2b00 GS |
810 | char* _win32_fgets(char *s, int n, FILE *pf) |
811 | { | |
4c2891ed | 812 | return pPerl->PL_piStdIO->Gets((PerlIO*)pf, s, n, ErrorNo()); |
9e6b2b00 GS |
813 | } |
814 | ||
815 | char* _win32_gets(char *s) | |
816 | { | |
4c2891ed | 817 | return _win32_fgets(s, 80, (FILE*)pPerl->PL_piStdIO->Stdin()); |
9e6b2b00 GS |
818 | } |
819 | ||
e3b8966e GS |
820 | int _win32_fgetc(FILE *pf) |
821 | { | |
4c2891ed | 822 | return pPerl->PL_piStdIO->Getc((PerlIO*)pf, ErrorNo()); |
e3b8966e GS |
823 | } |
824 | ||
825 | int _win32_putc(int c, FILE *pf) | |
826 | { | |
4c2891ed | 827 | return pPerl->PL_piStdIO->Putc((PerlIO*)pf, c, ErrorNo()); |
e3b8966e GS |
828 | } |
829 | ||
830 | int _win32_puts(const char *s) | |
831 | { | |
4c2891ed | 832 | return pPerl->PL_piStdIO->Puts(pPerl->PL_piStdIO->Stdout(), s, ErrorNo()); |
e3b8966e GS |
833 | } |
834 | ||
835 | int _win32_getchar(void) | |
836 | { | |
4c2891ed | 837 | return pPerl->PL_piStdIO->Getc(pPerl->PL_piStdIO->Stdin(), ErrorNo()); |
e3b8966e GS |
838 | } |
839 | ||
840 | int _win32_putchar(int c) | |
841 | { | |
4c2891ed | 842 | return pPerl->PL_piStdIO->Putc(pPerl->PL_piStdIO->Stdout(), c, ErrorNo()); |
e3b8966e GS |
843 | } |
844 | ||
845 | void* _win32_malloc(size_t size) | |
846 | { | |
4c2891ed | 847 | return pPerl->PL_piMem->Malloc(size); |
e3b8966e GS |
848 | } |
849 | ||
850 | void* _win32_calloc(size_t numitems, size_t size) | |
851 | { | |
4c2891ed | 852 | return pPerl->PL_piMem->Malloc(numitems*size); |
e3b8966e GS |
853 | } |
854 | ||
855 | void* _win32_realloc(void *block, size_t size) | |
856 | { | |
4c2891ed | 857 | return pPerl->PL_piMem->Realloc(block, size); |
e3b8966e GS |
858 | } |
859 | ||
860 | void _win32_free(void *block) | |
861 | { | |
4c2891ed | 862 | pPerl->PL_piMem->Free(block); |
e3b8966e GS |
863 | } |
864 | ||
865 | void _win32_abort(void) | |
866 | { | |
4c2891ed | 867 | pPerl->PL_piProc->Abort(); |
e3b8966e GS |
868 | } |
869 | ||
870 | int _win32_pipe(int *phandles, unsigned int psize, int textmode) | |
871 | { | |
4c2891ed | 872 | return pPerl->PL_piProc->Pipe(phandles); |
e3b8966e GS |
873 | } |
874 | ||
875 | FILE* _win32_popen(const char *command, const char *mode) | |
876 | { | |
4c2891ed | 877 | return (FILE*)pPerl->PL_piProc->Popen(command, mode); |
e3b8966e GS |
878 | } |
879 | ||
880 | int _win32_pclose(FILE *pf) | |
881 | { | |
4c2891ed | 882 | return pPerl->PL_piProc->Pclose((PerlIO*)pf); |
e3b8966e GS |
883 | } |
884 | ||
885 | unsigned _win32_sleep(unsigned int t) | |
886 | { | |
4c2891ed | 887 | return pPerl->PL_piProc->Sleep(t); |
e3b8966e GS |
888 | } |
889 | ||
890 | int _win32_spawnvp(int mode, const char *cmdname, const char *const *argv) | |
891 | { | |
4c2891ed | 892 | return pPerl->PL_piProc->Spawnvp(mode, cmdname, argv); |
e3b8966e GS |
893 | } |
894 | ||
895 | int _win32_mkdir(const char *dir, int mode) | |
896 | { | |
4c2891ed | 897 | return pPerl->PL_piDir->Makedir(dir, mode, ErrorNo()); |
e3b8966e GS |
898 | } |
899 | ||
900 | int _win32_rmdir(const char *dir) | |
901 | { | |
4c2891ed | 902 | return pPerl->PL_piDir->Rmdir(dir, ErrorNo()); |
e3b8966e GS |
903 | } |
904 | ||
905 | int _win32_chdir(const char *dir) | |
906 | { | |
4c2891ed | 907 | return pPerl->PL_piDir->Chdir(dir, ErrorNo()); |
e3b8966e GS |
908 | } |
909 | ||
910 | #undef stat | |
911 | int _win32_fstat(int fd,struct stat *sbufptr) | |
912 | { | |
4c2891ed | 913 | return pPerl->PL_piLIO->FileStat(fd, sbufptr, ErrorNo()); |
e3b8966e GS |
914 | } |
915 | ||
916 | int _win32_stat(const char *name,struct stat *sbufptr) | |
917 | { | |
4c2891ed | 918 | return pPerl->PL_piLIO->NameStat(name, sbufptr, ErrorNo()); |
e3b8966e GS |
919 | } |
920 | ||
8d9b2e3c | 921 | int _win32_rename(const char *oname, const char *newname) |
e24c7c18 | 922 | { |
4c2891ed | 923 | return pPerl->PL_piLIO->Rename(oname, newname, ErrorNo()); |
e24c7c18 GS |
924 | } |
925 | ||
e3b8966e GS |
926 | int _win32_setmode(int fd, int mode) |
927 | { | |
4c2891ed | 928 | return pPerl->PL_piLIO->Setmode(fd, mode, ErrorNo()); |
e3b8966e GS |
929 | } |
930 | ||
931 | long _win32_lseek(int fd, long offset, int origin) | |
932 | { | |
4c2891ed | 933 | return pPerl->PL_piLIO->Lseek(fd, offset, origin, ErrorNo()); |
e3b8966e GS |
934 | } |
935 | ||
936 | long _win32_tell(int fd) | |
937 | { | |
4c2891ed | 938 | return pPerl->PL_piStdIO->Tell((PerlIO*)fd, ErrorNo()); |
e3b8966e GS |
939 | } |
940 | ||
941 | int _win32_dup(int fd) | |
942 | { | |
4c2891ed | 943 | return pPerl->PL_piLIO->Dup(fd, ErrorNo()); |
e3b8966e GS |
944 | } |
945 | ||
946 | int _win32_dup2(int h1, int h2) | |
947 | { | |
4c2891ed | 948 | return pPerl->PL_piLIO->Dup2(h1, h2, ErrorNo()); |
e3b8966e GS |
949 | } |
950 | ||
951 | int _win32_open(const char *path, int oflag,...) | |
952 | { | |
4c2891ed | 953 | return pPerl->PL_piLIO->Open(path, oflag, ErrorNo()); |
e3b8966e GS |
954 | } |
955 | ||
956 | int _win32_close(int fd) | |
957 | { | |
4c2891ed | 958 | return pPerl->PL_piLIO->Close(fd, ErrorNo()); |
e3b8966e GS |
959 | } |
960 | ||
961 | int _win32_read(int fd, void *buf, unsigned int cnt) | |
962 | { | |
4c2891ed | 963 | return pPerl->PL_piLIO->Read(fd, buf, cnt, ErrorNo()); |
e3b8966e GS |
964 | } |
965 | ||
966 | int _win32_write(int fd, const void *buf, unsigned int cnt) | |
967 | { | |
4c2891ed | 968 | return pPerl->PL_piLIO->Write(fd, buf, cnt, ErrorNo()); |
e3b8966e GS |
969 | } |
970 | ||
971 | int _win32_times(struct tms *timebuf) | |
972 | { | |
4c2891ed | 973 | return pPerl->PL_piProc->Times(timebuf); |
e3b8966e GS |
974 | } |
975 | ||
976 | int _win32_ioctl(int i, unsigned int u, char *data) | |
977 | { | |
4c2891ed | 978 | return pPerl->PL_piLIO->IOCtl(i, u, data, ErrorNo()); |
e3b8966e GS |
979 | } |
980 | ||
981 | int _win32_utime(const char *f, struct utimbuf *t) | |
982 | { | |
4c2891ed | 983 | return pPerl->PL_piLIO->Utime((char*)f, t, ErrorNo()); |
e3b8966e GS |
984 | } |
985 | ||
986 | char* _win32_getenv(const char *name) | |
987 | { | |
4c2891ed | 988 | return pPerl->PL_piENV->Getenv(name, ErrorNo()); |
e3b8966e GS |
989 | } |
990 | ||
991 | int _win32_open_osfhandle(long handle, int flags) | |
992 | { | |
4c2891ed | 993 | return pPerl->PL_piStdIO->OpenOSfhandle(handle, flags); |
e3b8966e GS |
994 | } |
995 | ||
996 | long _win32_get_osfhandle(int fd) | |
997 | { | |
4c2891ed | 998 | return pPerl->PL_piStdIO->GetOSfhandle(fd); |
e3b8966e | 999 | } |
891fc7f2 GS |
1000 | |
1001 | u_long _win32_htonl (u_long hostlong) | |
1002 | { | |
4c2891ed | 1003 | return pPerl->PL_piSock->Htonl(hostlong); |
891fc7f2 GS |
1004 | } |
1005 | ||
1006 | u_short _win32_htons (u_short hostshort) | |
1007 | { | |
4c2891ed | 1008 | return pPerl->PL_piSock->Htons(hostshort); |
891fc7f2 GS |
1009 | } |
1010 | ||
1011 | u_long _win32_ntohl (u_long netlong) | |
1012 | { | |
4c2891ed | 1013 | return pPerl->PL_piSock->Ntohl(netlong); |
891fc7f2 GS |
1014 | } |
1015 | ||
1016 | u_short _win32_ntohs (u_short netshort) | |
1017 | { | |
4c2891ed | 1018 | return pPerl->PL_piSock->Ntohs(netshort); |
891fc7f2 GS |
1019 | } |
1020 | ||
1021 | unsigned long _win32_inet_addr (const char * cp) | |
1022 | { | |
4c2891ed | 1023 | return pPerl->PL_piSock->InetAddr(cp, ErrorNo()); |
891fc7f2 GS |
1024 | } |
1025 | ||
1026 | char * _win32_inet_ntoa (struct in_addr in) | |
1027 | { | |
4c2891ed | 1028 | return pPerl->PL_piSock->InetNtoa(in, ErrorNo()); |
891fc7f2 GS |
1029 | } |
1030 | ||
1031 | SOCKET _win32_socket (int af, int type, int protocol) | |
1032 | { | |
4c2891ed | 1033 | return pPerl->PL_piSock->Socket(af, type, protocol, ErrorNo()); |
891fc7f2 GS |
1034 | } |
1035 | ||
1036 | int _win32_bind (SOCKET s, const struct sockaddr *addr, int namelen) | |
1037 | { | |
4c2891ed | 1038 | return pPerl->PL_piSock->Bind(s, addr, namelen, ErrorNo()); |
891fc7f2 GS |
1039 | } |
1040 | ||
1041 | int _win32_listen (SOCKET s, int backlog) | |
1042 | { | |
4c2891ed | 1043 | return pPerl->PL_piSock->Listen(s, backlog, ErrorNo()); |
891fc7f2 GS |
1044 | } |
1045 | ||
1046 | SOCKET _win32_accept (SOCKET s, struct sockaddr *addr, int *addrlen) | |
1047 | { | |
4c2891ed | 1048 | return pPerl->PL_piSock->Accept(s, addr, addrlen, ErrorNo()); |
891fc7f2 GS |
1049 | } |
1050 | ||
1051 | int _win32_connect (SOCKET s, const struct sockaddr *name, int namelen) | |
1052 | { | |
4c2891ed | 1053 | return pPerl->PL_piSock->Connect(s, name, namelen, ErrorNo()); |
891fc7f2 GS |
1054 | } |
1055 | ||
1056 | int _win32_send (SOCKET s, const char * buf, int len, int flags) | |
1057 | { | |
4c2891ed | 1058 | return pPerl->PL_piSock->Send(s, buf, len, flags, ErrorNo()); |
891fc7f2 GS |
1059 | } |
1060 | ||
1061 | int _win32_sendto (SOCKET s, const char * buf, int len, int flags, | |
1062 | const struct sockaddr *to, int tolen) | |
1063 | { | |
4c2891ed | 1064 | return pPerl->PL_piSock->Sendto(s, buf, len, flags, to, tolen, ErrorNo()); |
891fc7f2 GS |
1065 | } |
1066 | ||
1067 | int _win32_recv (SOCKET s, char * buf, int len, int flags) | |
1068 | { | |
4c2891ed | 1069 | return pPerl->PL_piSock->Recv(s, buf, len, flags, ErrorNo()); |
891fc7f2 GS |
1070 | } |
1071 | ||
1072 | int _win32_recvfrom (SOCKET s, char * buf, int len, int flags, | |
1073 | struct sockaddr *from, int * fromlen) | |
1074 | { | |
4c2891ed | 1075 | return pPerl->PL_piSock->Recvfrom(s, buf, len, flags, from, fromlen, ErrorNo()); |
891fc7f2 GS |
1076 | } |
1077 | ||
1078 | int _win32_shutdown (SOCKET s, int how) | |
1079 | { | |
4c2891ed | 1080 | return pPerl->PL_piSock->Shutdown(s, how, ErrorNo()); |
891fc7f2 GS |
1081 | } |
1082 | ||
1083 | int _win32_closesocket (SOCKET s) | |
1084 | { | |
4c2891ed | 1085 | return pPerl->PL_piSock->Closesocket(s, ErrorNo()); |
891fc7f2 GS |
1086 | } |
1087 | ||
1088 | int _win32_ioctlsocket (SOCKET s, long cmd, u_long *argp) | |
1089 | { | |
4c2891ed | 1090 | return pPerl->PL_piSock->Ioctlsocket(s, cmd, argp, ErrorNo()); |
891fc7f2 GS |
1091 | } |
1092 | ||
1093 | int _win32_setsockopt (SOCKET s, int level, int optname, | |
1094 | const char * optval, int optlen) | |
1095 | { | |
4c2891ed | 1096 | return pPerl->PL_piSock->Setsockopt(s, level, optname, optval, optlen, ErrorNo()); |
891fc7f2 GS |
1097 | } |
1098 | ||
1099 | int _win32_getsockopt (SOCKET s, int level, int optname, char * optval, int *optlen) | |
1100 | { | |
4c2891ed | 1101 | return pPerl->PL_piSock->Getsockopt(s, level, optname, optval, optlen, ErrorNo()); |
891fc7f2 GS |
1102 | } |
1103 | ||
1104 | int _win32_getpeername (SOCKET s, struct sockaddr *name, int * namelen) | |
1105 | { | |
4c2891ed | 1106 | return pPerl->PL_piSock->Getpeername(s, name, namelen, ErrorNo()); |
891fc7f2 GS |
1107 | } |
1108 | ||
1109 | int _win32_getsockname (SOCKET s, struct sockaddr *name, int * namelen) | |
1110 | { | |
4c2891ed | 1111 | return pPerl->PL_piSock->Getsockname(s, name, namelen, ErrorNo()); |
891fc7f2 GS |
1112 | } |
1113 | ||
1114 | int _win32_gethostname (char * name, int namelen) | |
1115 | { | |
4c2891ed | 1116 | return pPerl->PL_piSock->Gethostname(name, namelen, ErrorNo()); |
891fc7f2 GS |
1117 | } |
1118 | ||
1119 | struct hostent * _win32_gethostbyname(const char * name) | |
1120 | { | |
4c2891ed | 1121 | return pPerl->PL_piSock->Gethostbyname(name, ErrorNo()); |
891fc7f2 GS |
1122 | } |
1123 | ||
1124 | struct hostent * _win32_gethostbyaddr(const char * addr, int len, int type) | |
1125 | { | |
4c2891ed | 1126 | return pPerl->PL_piSock->Gethostbyaddr(addr, len, type, ErrorNo()); |
891fc7f2 GS |
1127 | } |
1128 | ||
1129 | struct protoent * _win32_getprotobyname(const char * name) | |
1130 | { | |
4c2891ed | 1131 | return pPerl->PL_piSock->Getprotobyname(name, ErrorNo()); |
891fc7f2 GS |
1132 | } |
1133 | ||
1134 | struct protoent * _win32_getprotobynumber(int proto) | |
1135 | { | |
4c2891ed | 1136 | return pPerl->PL_piSock->Getprotobynumber(proto, ErrorNo()); |
891fc7f2 GS |
1137 | } |
1138 | ||
1139 | struct servent * _win32_getservbyname(const char * name, const char * proto) | |
1140 | { | |
4c2891ed | 1141 | return pPerl->PL_piSock->Getservbyname(name, proto, ErrorNo()); |
891fc7f2 GS |
1142 | } |
1143 | ||
1144 | struct servent * _win32_getservbyport(int port, const char * proto) | |
1145 | { | |
4c2891ed | 1146 | return pPerl->PL_piSock->Getservbyport(port, proto, ErrorNo()); |
891fc7f2 GS |
1147 | } |
1148 | ||
1149 | int _win32_select (int nfds, Perl_fd_set *rfds, Perl_fd_set *wfds, Perl_fd_set *xfds, | |
1150 | const struct timeval *timeout) | |
1151 | { | |
4c2891ed | 1152 | return pPerl->PL_piSock->Select(nfds, (char*)rfds, (char*)wfds, (char*)xfds, timeout, ErrorNo()); |
891fc7f2 GS |
1153 | } |
1154 | ||
1155 | void _win32_endnetent(void) | |
1156 | { | |
4c2891ed | 1157 | pPerl->PL_piSock->Endnetent(ErrorNo()); |
891fc7f2 GS |
1158 | } |
1159 | ||
1160 | void _win32_endhostent(void) | |
1161 | { | |
4c2891ed | 1162 | pPerl->PL_piSock->Endhostent(ErrorNo()); |
891fc7f2 GS |
1163 | } |
1164 | ||
1165 | void _win32_endprotoent(void) | |
1166 | { | |
4c2891ed | 1167 | pPerl->PL_piSock->Endprotoent(ErrorNo()); |
891fc7f2 GS |
1168 | } |
1169 | ||
1170 | void _win32_endservent(void) | |
1171 | { | |
4c2891ed | 1172 | pPerl->PL_piSock->Endservent(ErrorNo()); |
891fc7f2 GS |
1173 | } |
1174 | ||
1175 | struct netent * _win32_getnetent(void) | |
1176 | { | |
4c2891ed | 1177 | return pPerl->PL_piSock->Getnetent(ErrorNo()); |
891fc7f2 GS |
1178 | } |
1179 | ||
1180 | struct netent * _win32_getnetbyname(char *name) | |
1181 | { | |
4c2891ed | 1182 | return pPerl->PL_piSock->Getnetbyname(name, ErrorNo()); |
891fc7f2 GS |
1183 | } |
1184 | ||
1185 | struct netent * _win32_getnetbyaddr(long net, int type) | |
1186 | { | |
4c2891ed | 1187 | return pPerl->PL_piSock->Getnetbyaddr(net, type, ErrorNo()); |
891fc7f2 GS |
1188 | } |
1189 | ||
1190 | struct protoent *_win32_getprotoent(void) | |
1191 | { | |
4c2891ed | 1192 | return pPerl->PL_piSock->Getprotoent(ErrorNo()); |
891fc7f2 GS |
1193 | } |
1194 | ||
1195 | struct servent *_win32_getservent(void) | |
1196 | { | |
4c2891ed | 1197 | return pPerl->PL_piSock->Getservent(ErrorNo()); |
891fc7f2 GS |
1198 | } |
1199 | ||
1200 | void _win32_sethostent(int stayopen) | |
1201 | { | |
4c2891ed | 1202 | pPerl->PL_piSock->Sethostent(stayopen, ErrorNo()); |
891fc7f2 GS |
1203 | } |
1204 | ||
1205 | void _win32_setnetent(int stayopen) | |
1206 | { | |
4c2891ed | 1207 | pPerl->PL_piSock->Setnetent(stayopen, ErrorNo()); |
891fc7f2 GS |
1208 | } |
1209 | ||
1210 | void _win32_setprotoent(int stayopen) | |
1211 | { | |
4c2891ed | 1212 | pPerl->PL_piSock->Setprotoent(stayopen, ErrorNo()); |
891fc7f2 GS |
1213 | } |
1214 | ||
1215 | void _win32_setservent(int stayopen) | |
1216 | { | |
4c2891ed | 1217 | pPerl->PL_piSock->Setservent(stayopen, ErrorNo()); |
891fc7f2 | 1218 | } |
e3b8966e GS |
1219 | } /* extern "C" */ |
1220 | EOCODE | |
1221 | ||
1222 | ||
1223 | print HDRFILE <<EOCODE; | |
9e6b2b00 GS |
1224 | #undef Perl_op_desc |
1225 | char ** _Perl_op_desc (); | |
1226 | #define Perl_op_desc (_Perl_op_desc()) | |
1227 | ||
1228 | #undef Perl_op_name | |
1229 | char ** _Perl_op_name (); | |
1230 | #define Perl_op_name (_Perl_op_name()) | |
1231 | ||
1232 | #undef Perl_no_modify | |
58a50f62 | 1233 | char * _Perl_no_modify (); |
9e6b2b00 GS |
1234 | #define Perl_no_modify (_Perl_no_modify()) |
1235 | ||
1236 | #undef Perl_opargs | |
58a50f62 | 1237 | U32 * _Perl_opargs (); |
9e6b2b00 GS |
1238 | #define Perl_opargs (_Perl_opargs()) |
1239 | ||
1240 | ||
e3b8966e GS |
1241 | #undef win32_errno |
1242 | #undef win32_stdin | |
1243 | #undef win32_stdout | |
1244 | #undef win32_stderr | |
1245 | #undef win32_ferror | |
1246 | #undef win32_feof | |
1247 | #undef win32_fprintf | |
1248 | #undef win32_printf | |
1249 | #undef win32_vfprintf | |
1250 | #undef win32_vprintf | |
1251 | #undef win32_fread | |
1252 | #undef win32_fwrite | |
1253 | #undef win32_fopen | |
1254 | #undef win32_fdopen | |
1255 | #undef win32_freopen | |
1256 | #undef win32_fclose | |
1257 | #undef win32_fputs | |
1258 | #undef win32_fputc | |
1259 | #undef win32_ungetc | |
1260 | #undef win32_getc | |
1261 | #undef win32_fileno | |
1262 | #undef win32_clearerr | |
1263 | #undef win32_fflush | |
1264 | #undef win32_ftell | |
1265 | #undef win32_fseek | |
1266 | #undef win32_fgetpos | |
1267 | #undef win32_fsetpos | |
1268 | #undef win32_rewind | |
1269 | #undef win32_tmpfile | |
1270 | #undef win32_abort | |
1271 | #undef win32_fstat | |
1272 | #undef win32_stat | |
1273 | #undef win32_pipe | |
1274 | #undef win32_popen | |
1275 | #undef win32_pclose | |
e24c7c18 | 1276 | #undef win32_rename |
e3b8966e GS |
1277 | #undef win32_setmode |
1278 | #undef win32_lseek | |
1279 | #undef win32_tell | |
1280 | #undef win32_dup | |
1281 | #undef win32_dup2 | |
1282 | #undef win32_open | |
1283 | #undef win32_close | |
1284 | #undef win32_eof | |
1285 | #undef win32_read | |
1286 | #undef win32_write | |
1287 | #undef win32_mkdir | |
1288 | #undef win32_rmdir | |
1289 | #undef win32_chdir | |
1290 | #undef win32_setbuf | |
1291 | #undef win32_setvbuf | |
1292 | #undef win32_fgetc | |
9e6b2b00 GS |
1293 | #undef win32_fgets |
1294 | #undef win32_gets | |
e3b8966e GS |
1295 | #undef win32_putc |
1296 | #undef win32_puts | |
1297 | #undef win32_getchar | |
1298 | #undef win32_putchar | |
1299 | #undef win32_malloc | |
1300 | #undef win32_calloc | |
1301 | #undef win32_realloc | |
1302 | #undef win32_free | |
1303 | #undef win32_sleep | |
1304 | #undef win32_times | |
1305 | #undef win32_stat | |
1306 | #undef win32_ioctl | |
1307 | #undef win32_utime | |
1308 | #undef win32_getenv | |
1309 | ||
891fc7f2 GS |
1310 | #undef win32_htonl |
1311 | #undef win32_htons | |
1312 | #undef win32_ntohl | |
1313 | #undef win32_ntohs | |
1314 | #undef win32_inet_addr | |
1315 | #undef win32_inet_ntoa | |
1316 | ||
1317 | #undef win32_socket | |
1318 | #undef win32_bind | |
1319 | #undef win32_listen | |
1320 | #undef win32_accept | |
1321 | #undef win32_connect | |
1322 | #undef win32_send | |
1323 | #undef win32_sendto | |
1324 | #undef win32_recv | |
1325 | #undef win32_recvfrom | |
1326 | #undef win32_shutdown | |
1327 | #undef win32_closesocket | |
1328 | #undef win32_ioctlsocket | |
1329 | #undef win32_setsockopt | |
1330 | #undef win32_getsockopt | |
1331 | #undef win32_getpeername | |
1332 | #undef win32_getsockname | |
1333 | #undef win32_gethostname | |
1334 | #undef win32_gethostbyname | |
1335 | #undef win32_gethostbyaddr | |
1336 | #undef win32_getprotobyname | |
1337 | #undef win32_getprotobynumber | |
1338 | #undef win32_getservbyname | |
1339 | #undef win32_getservbyport | |
1340 | #undef win32_select | |
1341 | #undef win32_endhostent | |
1342 | #undef win32_endnetent | |
1343 | #undef win32_endprotoent | |
1344 | #undef win32_endservent | |
1345 | #undef win32_getnetent | |
1346 | #undef win32_getnetbyname | |
1347 | #undef win32_getnetbyaddr | |
1348 | #undef win32_getprotoent | |
1349 | #undef win32_getservent | |
1350 | #undef win32_sethostent | |
1351 | #undef win32_setnetent | |
1352 | #undef win32_setprotoent | |
1353 | #undef win32_setservent | |
1354 | ||
e3b8966e GS |
1355 | #define win32_errno _win32_errno |
1356 | #define win32_stdin _win32_stdin | |
1357 | #define win32_stdout _win32_stdout | |
1358 | #define win32_stderr _win32_stderr | |
1359 | #define win32_ferror _win32_ferror | |
1360 | #define win32_feof _win32_feof | |
1361 | #define win32_strerror _win32_strerror | |
1362 | #define win32_perror _win32_perror | |
1363 | #define win32_fprintf _win32_fprintf | |
1364 | #define win32_printf _win32_printf | |
1365 | #define win32_vfprintf _win32_vfprintf | |
1366 | #define win32_vprintf _win32_vprintf | |
1367 | #define win32_fread _win32_fread | |
1368 | #define win32_fwrite _win32_fwrite | |
1369 | #define win32_fopen _win32_fopen | |
1370 | #define win32_fdopen _win32_fdopen | |
1371 | #define win32_freopen _win32_freopen | |
1372 | #define win32_fclose _win32_fclose | |
1373 | #define win32_fputs _win32_fputs | |
1374 | #define win32_fputc _win32_fputc | |
1375 | #define win32_ungetc _win32_ungetc | |
1376 | #define win32_getc _win32_getc | |
1377 | #define win32_fileno _win32_fileno | |
1378 | #define win32_clearerr _win32_clearerr | |
1379 | #define win32_fflush _win32_fflush | |
1380 | #define win32_ftell _win32_ftell | |
1381 | #define win32_fseek _win32_fseek | |
1382 | #define win32_fgetpos _win32_fgetpos | |
1383 | #define win32_fsetpos _win32_fsetpos | |
1384 | #define win32_rewind _win32_rewind | |
1385 | #define win32_tmpfile _win32_tmpfile | |
1386 | #define win32_abort _win32_abort | |
1387 | #define win32_fstat _win32_fstat | |
1388 | #define win32_stat _win32_stat | |
1389 | #define win32_pipe _win32_pipe | |
1390 | #define win32_popen _win32_popen | |
1391 | #define win32_pclose _win32_pclose | |
e24c7c18 | 1392 | #define win32_rename _win32_rename |
e3b8966e GS |
1393 | #define win32_setmode _win32_setmode |
1394 | #define win32_lseek _win32_lseek | |
1395 | #define win32_tell _win32_tell | |
1396 | #define win32_dup _win32_dup | |
1397 | #define win32_dup2 _win32_dup2 | |
1398 | #define win32_open _win32_open | |
1399 | #define win32_close _win32_close | |
1400 | #define win32_eof _win32_eof | |
1401 | #define win32_read _win32_read | |
1402 | #define win32_write _win32_write | |
1403 | #define win32_mkdir _win32_mkdir | |
1404 | #define win32_rmdir _win32_rmdir | |
1405 | #define win32_chdir _win32_chdir | |
1406 | #define win32_setbuf _win32_setbuf | |
1407 | #define win32_setvbuf _win32_setvbuf | |
1408 | #define win32_fgetc _win32_fgetc | |
9e6b2b00 GS |
1409 | #define win32_fgets _win32_fgets |
1410 | #define win32_gets _win32_gets | |
e3b8966e GS |
1411 | #define win32_putc _win32_putc |
1412 | #define win32_puts _win32_puts | |
1413 | #define win32_getchar _win32_getchar | |
1414 | #define win32_putchar _win32_putchar | |
1415 | #define win32_malloc _win32_malloc | |
1416 | #define win32_calloc _win32_calloc | |
1417 | #define win32_realloc _win32_realloc | |
1418 | #define win32_free _win32_free | |
1419 | #define win32_sleep _win32_sleep | |
1420 | #define win32_spawnvp _win32_spawnvp | |
1421 | #define win32_times _win32_times | |
1422 | #define win32_stat _win32_stat | |
1423 | #define win32_ioctl _win32_ioctl | |
1424 | #define win32_utime _win32_utime | |
1425 | #define win32_getenv _win32_getenv | |
1426 | #define win32_open_osfhandle _win32_open_osfhandle | |
1427 | #define win32_get_osfhandle _win32_get_osfhandle | |
1428 | ||
891fc7f2 GS |
1429 | #define win32_htonl _win32_htonl |
1430 | #define win32_htons _win32_htons | |
1431 | #define win32_ntohl _win32_ntohl | |
1432 | #define win32_ntohs _win32_ntohs | |
1433 | #define win32_inet_addr _win32_inet_addr | |
1434 | #define win32_inet_ntoa _win32_inet_ntoa | |
1435 | ||
1436 | #define win32_socket _win32_socket | |
1437 | #define win32_bind _win32_bind | |
1438 | #define win32_listen _win32_listen | |
1439 | #define win32_accept _win32_accept | |
1440 | #define win32_connect _win32_connect | |
1441 | #define win32_send _win32_send | |
1442 | #define win32_sendto _win32_sendto | |
1443 | #define win32_recv _win32_recv | |
1444 | #define win32_recvfrom _win32_recvfrom | |
1445 | #define win32_shutdown _win32_shutdown | |
1446 | #define win32_closesocket _win32_closesocket | |
1447 | #define win32_ioctlsocket _win32_ioctlsocket | |
1448 | #define win32_setsockopt _win32_setsockopt | |
1449 | #define win32_getsockopt _win32_getsockopt | |
1450 | #define win32_getpeername _win32_getpeername | |
1451 | #define win32_getsockname _win32_getsockname | |
1452 | #define win32_gethostname _win32_gethostname | |
1453 | #define win32_gethostbyname _win32_gethostbyname | |
1454 | #define win32_gethostbyaddr _win32_gethostbyaddr | |
1455 | #define win32_getprotobyname _win32_getprotobyname | |
1456 | #define win32_getprotobynumber _win32_getprotobynumber | |
1457 | #define win32_getservbyname _win32_getservbyname | |
1458 | #define win32_getservbyport _win32_getservbyport | |
1459 | #define win32_select _win32_select | |
1460 | #define win32_endhostent _win32_endhostent | |
1461 | #define win32_endnetent _win32_endnetent | |
1462 | #define win32_endprotoent _win32_endprotoent | |
1463 | #define win32_endservent _win32_endservent | |
1464 | #define win32_getnetent _win32_getnetent | |
1465 | #define win32_getnetbyname _win32_getnetbyname | |
1466 | #define win32_getnetbyaddr _win32_getnetbyaddr | |
1467 | #define win32_getprotoent _win32_getprotoent | |
1468 | #define win32_getservent _win32_getservent | |
1469 | #define win32_sethostent _win32_sethostent | |
1470 | #define win32_setnetent _win32_setnetent | |
1471 | #define win32_setprotoent _win32_setprotoent | |
1472 | #define win32_setservent _win32_setservent | |
1473 | ||
e3b8966e GS |
1474 | int * _win32_errno(void); |
1475 | FILE* _win32_stdin(void); | |
1476 | FILE* _win32_stdout(void); | |
1477 | FILE* _win32_stderr(void); | |
1478 | int _win32_ferror(FILE *fp); | |
1479 | int _win32_feof(FILE *fp); | |
1480 | char* _win32_strerror(int e); | |
1481 | void _win32_perror(const char *str); | |
1482 | int _win32_fprintf(FILE *pf, const char *format, ...); | |
1483 | int _win32_printf(const char *format, ...); | |
1484 | int _win32_vfprintf(FILE *pf, const char *format, va_list arg); | |
1485 | int _win32_vprintf(const char *format, va_list arg); | |
1486 | size_t _win32_fread(void *buf, size_t size, size_t count, FILE *pf); | |
1487 | size_t _win32_fwrite(const void *buf, size_t size, size_t count, FILE *pf); | |
1488 | FILE* _win32_fopen(const char *path, const char *mode); | |
1489 | FILE* _win32_fdopen(int fh, const char *mode); | |
1490 | FILE* _win32_freopen(const char *path, const char *mode, FILE *pf); | |
1491 | int _win32_fclose(FILE *pf); | |
1492 | int _win32_fputs(const char *s,FILE *pf); | |
1493 | int _win32_fputc(int c,FILE *pf); | |
1494 | int _win32_ungetc(int c,FILE *pf); | |
1495 | int _win32_getc(FILE *pf); | |
1496 | int _win32_fileno(FILE *pf); | |
1497 | void _win32_clearerr(FILE *pf); | |
1498 | int _win32_fflush(FILE *pf); | |
1499 | long _win32_ftell(FILE *pf); | |
1500 | int _win32_fseek(FILE *pf,long offset,int origin); | |
1501 | int _win32_fgetpos(FILE *pf,fpos_t *p); | |
1502 | int _win32_fsetpos(FILE *pf,const fpos_t *p); | |
1503 | void _win32_rewind(FILE *pf); | |
1504 | FILE* _win32_tmpfile(void); | |
1505 | void _win32_abort(void); | |
1506 | int _win32_fstat(int fd,struct stat *sbufptr); | |
1507 | int _win32_stat(const char *name,struct stat *sbufptr); | |
1508 | int _win32_pipe( int *phandles, unsigned int psize, int textmode ); | |
1509 | FILE* _win32_popen( const char *command, const char *mode ); | |
1510 | int _win32_pclose( FILE *pf); | |
e24c7c18 | 1511 | int _win32_rename( const char *oldname, const char *newname); |
e3b8966e GS |
1512 | int _win32_setmode( int fd, int mode); |
1513 | long _win32_lseek( int fd, long offset, int origin); | |
1514 | long _win32_tell( int fd); | |
1515 | int _win32_dup( int fd); | |
1516 | int _win32_dup2(int h1, int h2); | |
1517 | int _win32_open(const char *path, int oflag,...); | |
1518 | int _win32_close(int fd); | |
1519 | int _win32_eof(int fd); | |
1520 | int _win32_read(int fd, void *buf, unsigned int cnt); | |
1521 | int _win32_write(int fd, const void *buf, unsigned int cnt); | |
1522 | int _win32_mkdir(const char *dir, int mode); | |
1523 | int _win32_rmdir(const char *dir); | |
1524 | int _win32_chdir(const char *dir); | |
1525 | void _win32_setbuf(FILE *pf, char *buf); | |
1526 | int _win32_setvbuf(FILE *pf, char *buf, int type, size_t size); | |
1527 | char* _win32_fgets(char *s, int n, FILE *pf); | |
1528 | char* _win32_gets(char *s); | |
1529 | int _win32_fgetc(FILE *pf); | |
1530 | int _win32_putc(int c, FILE *pf); | |
1531 | int _win32_puts(const char *s); | |
1532 | int _win32_getchar(void); | |
1533 | int _win32_putchar(int c); | |
1534 | void* _win32_malloc(size_t size); | |
1535 | void* _win32_calloc(size_t numitems, size_t size); | |
1536 | void* _win32_realloc(void *block, size_t size); | |
1537 | void _win32_free(void *block); | |
1538 | unsigned _win32_sleep(unsigned int); | |
1539 | int _win32_spawnvp(int mode, const char *cmdname, const char *const *argv); | |
1540 | int _win32_times(struct tms *timebuf); | |
1541 | int _win32_stat(const char *path, struct stat *buf); | |
1542 | int _win32_ioctl(int i, unsigned int u, char *data); | |
1543 | int _win32_utime(const char *f, struct utimbuf *t); | |
1544 | char* _win32_getenv(const char *name); | |
1545 | int _win32_open_osfhandle(long handle, int flags); | |
1546 | long _win32_get_osfhandle(int fd); | |
1547 | ||
891fc7f2 GS |
1548 | u_long _win32_htonl (u_long hostlong); |
1549 | u_short _win32_htons (u_short hostshort); | |
1550 | u_long _win32_ntohl (u_long netlong); | |
1551 | u_short _win32_ntohs (u_short netshort); | |
1552 | unsigned long _win32_inet_addr (const char * cp); | |
1553 | char * _win32_inet_ntoa (struct in_addr in); | |
1554 | ||
1555 | SOCKET _win32_socket (int af, int type, int protocol); | |
1556 | int _win32_bind (SOCKET s, const struct sockaddr *addr, int namelen); | |
1557 | int _win32_listen (SOCKET s, int backlog); | |
1558 | SOCKET _win32_accept (SOCKET s, struct sockaddr *addr, int *addrlen); | |
1559 | int _win32_connect (SOCKET s, const struct sockaddr *name, int namelen); | |
1560 | int _win32_send (SOCKET s, const char * buf, int len, int flags); | |
1561 | int _win32_sendto (SOCKET s, const char * buf, int len, int flags, | |
1562 | const struct sockaddr *to, int tolen); | |
1563 | int _win32_recv (SOCKET s, char * buf, int len, int flags); | |
1564 | int _win32_recvfrom (SOCKET s, char * buf, int len, int flags, | |
1565 | struct sockaddr *from, int * fromlen); | |
1566 | int _win32_shutdown (SOCKET s, int how); | |
1567 | int _win32_closesocket (SOCKET s); | |
1568 | int _win32_ioctlsocket (SOCKET s, long cmd, u_long *argp); | |
1569 | int _win32_setsockopt (SOCKET s, int level, int optname, | |
1570 | const char * optval, int optlen); | |
1571 | int _win32_getsockopt (SOCKET s, int level, int optname, char * optval, int *optlen); | |
1572 | int _win32_getpeername (SOCKET s, struct sockaddr *name, int * namelen); | |
1573 | int _win32_getsockname (SOCKET s, struct sockaddr *name, int * namelen); | |
1574 | int _win32_gethostname (char * name, int namelen); | |
1575 | struct hostent * _win32_gethostbyname(const char * name); | |
1576 | struct hostent * _win32_gethostbyaddr(const char * addr, int len, int type); | |
1577 | struct protoent * _win32_getprotobyname(const char * name); | |
1578 | struct protoent * _win32_getprotobynumber(int proto); | |
1579 | struct servent * _win32_getservbyname(const char * name, const char * proto); | |
1580 | struct servent * _win32_getservbyport(int port, const char * proto); | |
1581 | int _win32_select (int nfds, Perl_fd_set *rfds, Perl_fd_set *wfds, Perl_fd_set *xfds, | |
1582 | const struct timeval *timeout); | |
1583 | void _win32_endnetent(void); | |
1584 | void _win32_endhostent(void); | |
1585 | void _win32_endprotoent(void); | |
1586 | void _win32_endservent(void); | |
1587 | struct netent * _win32_getnetent(void); | |
1588 | struct netent * _win32_getnetbyname(char *name); | |
1589 | struct netent * _win32_getnetbyaddr(long net, int type); | |
1590 | struct protoent *_win32_getprotoent(void); | |
1591 | struct servent *_win32_getservent(void); | |
1592 | void _win32_sethostent(int stayopen); | |
1593 | void _win32_setnetent(int stayopen); | |
1594 | void _win32_setprotoent(int stayopen); | |
1595 | void _win32_setservent(int stayopen); | |
1596 | ||
e3b8966e GS |
1597 | #pragma warning(once : 4113) |
1598 | EOCODE | |
1599 | ||
1600 | ||
1601 | close HDRFILE; | |
1602 | close OUTFILE; |