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