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