More HP-UX/IA64 work
[p5sagit/p5-mst-13.2.git] / reentr.pl
CommitLineData
10bc17b6 1#!/usr/bin/perl -w
2
3#
4# Generate the reentr.c and reentr.h,
5# and optionally also the relevant metaconfig units (-U option).
6#
7
8use strict;
9use Getopt::Std;
10my %opts;
11getopts('U', \%opts);
12
13my %map = (
14 V => "void",
15 A => "char*", # as an input argument
16 B => "char*", # as an output argument
17 C => "const char*", # as a read-only input argument
18 I => "int",
19 L => "long",
20 W => "size_t",
21 H => "FILE**",
22 E => "int*",
23 );
24
25# (See the definitions after __DATA__.)
26# In func|inc|type|... a "S" means "type*", and a "R" means "type**".
27# (The "types" are often structs, such as "struct passwd".)
28#
29# After the prototypes one can have |X=...|Y=... to define more types.
30# A commonly used extra type is to define D to be equal to "type_data",
31# for example "struct_hostent_data to" go with "struct hostent".
32#
33# Example #1: I_XSBWR means int func_r(X, type, char*, size_t, type**)
34# Example #2: S_SBIE means type func_r(type, char*, int, int*)
35# Example #3: S_CBI means type func_r(const char*, char*, int)
36
37
38die "reentr.h: $!" unless open(H, ">reentr.h");
39select H;
40print <<EOF;
41/*
42 * reentr.h
43 *
44 * Copyright (c) 1997-2002, Larry Wall
45 *
46 * You may distribute under the terms of either the GNU General Public
47 * License or the Artistic License, as specified in the README file.
48 *
49 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
50 * This file is built by reentrl.pl from data in reentr.pl.
51 */
52
53#ifndef REENTR_H
54#define REENTR_H
55
56#ifdef USE_REENTRANT_API
57
58/* Deprecations: some platforms have the said reentrant interfaces
59 * but they are declared obsolete and are not to be used. Often this
60 * means that the platform has threadsafed the interfaces (hopefully).
61 * All this is OS version dependent, so we are of course fooling ourselves.
62 * If you know of more deprecations on some platforms, please add your own. */
63
64#ifdef __hpux
65# undef HAS_CRYPT_R
66# undef HAS_DRAND48_R
efa45b01 67# undef HAS_ENDGRENT_R
68# undef HAS_ENDPWENT_R
10bc17b6 69# undef HAS_GETGRENT_R
70# undef HAS_GETPWENT_R
71# undef HAS_SETLOCALE_R
72# undef HAS_SRAND48_R
73# undef HAS_STRERROR_R
74# define NETDB_R_OBSOLETE
75#endif
76
77#if defined(__osf__) && defined(__alpha) /* Tru64 aka Digital UNIX */
78# undef HAS_CRYPT_R
79# undef HAS_STRERROR_R
80# define NETDB_R_OBSOLETE
81#endif
82
83#ifdef NETDB_R_OBSOLETE
84# undef HAS_ENDHOSTENT_R
85# undef HAS_ENDNETENT_R
86# undef HAS_ENDPROTOENT_R
87# undef HAS_ENDSERVENT_R
88# undef HAS_GETHOSTBYADDR_R
89# undef HAS_GETHOSTBYNAME_R
90# undef HAS_GETHOSTENT_R
91# undef HAS_GETNETBYADDR_R
92# undef HAS_GETNETBYNAME_R
93# undef HAS_GETNETENT_R
94# undef HAS_GETPROTOBYNAME_R
95# undef HAS_GETPROTOBYNUMBER_R
96# undef HAS_GETPROTOENT_R
97# undef HAS_GETSERVBYNAME_R
98# undef HAS_GETSERVBYPORT_R
99# undef HAS_GETSERVENT_R
100# undef HAS_SETHOSTENT_R
101# undef HAS_SETNETENT_R
102# undef HAS_SETPROTOENT_R
103# undef HAS_SETSERVENT_R
104#endif
105
106#ifdef I_PWD
107# include <pwd.h>
108#endif
109#ifdef I_GRP
110# include <grp.h>
111#endif
112#ifdef I_NETDB
113# include <netdb.h>
114#endif
115#ifdef I_STDLIB
116# include <stdlib.h> /* drand48_data */
117#endif
118#ifdef I_CRYPT
119# ifdef I_CRYPT
120# include <crypt.h>
121# endif
122#endif
123#ifdef HAS_GETSPNAM_R
124# ifdef I_SHADOW
125# include <shadow.h>
126# endif
127#endif
128
129EOF
130
131my %seenh;
132my %seena;
133my @seenf;
134my %seenp;
135my %seent;
136my %seens;
137my %seend;
138my %seenu;
139
140while (<DATA>) {
141 next if /^\s+$/;
142 chomp;
143 my ($f, $h, $t, @p) = split(/\s*\|\s*/, $_, -1);
144 my $u;
145 ($f, $u) = split(' ', $f);
146 $seenu{$f} = defined $u ? length $u : 0;
147 my $F = uc $f;
148 push @seenf, $f;
149 my %m = %map;
150 if ($t) {
151 $m{S} = "$t*";
152 $m{R} = "$t**";
153 }
154 if (@p) {
155 while ($p[-1] =~ /=/) {
156 my ($k, $v) = ($p[-1] =~ /^([A-Za-z])\s*=\s*(.*)/);
157 $m{$k} = $v;
158 pop @p;
159 }
160 }
161 if ($opts{U} && open(U, ">d_${f}_r.U")) {
162 select U;
163 }
164 my $prereqh = $h eq 'stdio' ? '' : "i_$h"; # There's no i_stdio.
165 print <<EOF if $opts{U};
166?RCS: \$Id: d_${f}_r.U,v $
167?RCS:
168?RCS: Copyright (c) 2002 Jarkko Hietaniemi
169?RCS:
170?RCS: You may distribute under the terms of either the GNU General Public
171?RCS: License or the Artistic License, as specified in the README file.
172?RCS:
173?RCS: Generated by the reentr.pl from the Perl 5.8 distribution.
174?RCS:
c18e646a 175?MAKE:d_${f}_r ${f}_r_proto: Inlibc Protochk Hasproto i_systypes $prereqh usethreads
10bc17b6 176?MAKE: -pick add \$@ %<
177?S:d_${f}_r:
178?S: This variable conditionally defines the HAS_${F}_R symbol,
179?S: which indicates to the C program that the ${f}_r()
180?S: routine is available.
181?S:.
182?S:${f}_r_proto:
183?S: This variable encodes the prototype of ${f}_r.
184?S:.
185?C:HAS_${F}_R:
186?C: This symbol, if defined, indicates that the ${f}_r routine
187?C: is available to ${f} re-entrantly.
188?C:.
189?C:${F}_R_PROTO:
190?C: This symbol encodes the prototype of ${f}_r.
191?C:.
192?H:#\$d_${f}_r HAS_${F}_R /**/
193?H:#define ${F}_R_PROTO \$${f}_r_proto /**/
194?H:.
a48ec845 195?T:try hdrs d_${f}_r_proto
10bc17b6 196?LINT:set d_${f}_r
197?LINT:set ${f}_r_proto
198: see if ${f}_r exists
199set ${f}_r d_${f}_r
200eval \$inlibc
201case "\$d_${f}_r" in
202"\$define")
203 hdrs="\$i_systypes sys/types.h define stdio.h \$i_${h} $h.h"
90e831dc 204 case "$h" in
205 time)
206 hdrs="\$hdrs \$i_systime sys/time.h"
207 ;;
208 esac
c18e646a 209 case "\$d_${f}_r_proto:\$usethreads" in
210 ":define") d_${f}_r_proto=define
a48ec845 211 set d_${f}_r_proto ${f}_r \$hdrs
212 eval \$hasproto ;;
213 *) ;;
214 esac
215 case "\$d_${f}_r_proto" in
216 define)
10bc17b6 217EOF
218 for my $p (@p) {
219 my ($r, $a) = ($p =~ /^(.)_(.+)/);
220 my $v = join(", ", map { $m{$_} } split '', $a);
221 if ($opts{U}) {
222 print <<EOF ;
223 case "\$${f}_r_proto" in
224 ''|0) try='$m{$r} ${f}_r($v);'
225 ./protochk "extern \$try" \$hdrs && ${f}_r_proto=$p ;;
226 esac
227EOF
228 }
229 $seenh{$f}->{$p}++;
230 push @{$seena{$f}}, $p;
231 $seenp{$p}++;
232 $seent{$f} = $t;
233 $seens{$f} = $m{S};
234 $seend{$f} = $m{D};
235 }
236 if ($opts{U}) {
237 print <<EOF;
238 case "\$${f}_r_proto" in
90e831dc 239 ''|0) d_${f}_r=undef
10bc17b6 240 ${f}_r_proto=0
a48ec845 241 echo "Disabling ${f}_r, cannot determine prototype." >&4 ;;
10bc17b6 242 * ) case "\$${f}_r_proto" in
243 REENTRANT_PROTO*) ;;
244 *) ${f}_r_proto="REENTRANT_PROTO_\$${f}_r_proto" ;;
245 esac
246 echo "Prototype: \$try" ;;
247 esac
248 ;;
c18e646a 249 *) case "\$usethreads" in
250 define) echo "${f}_r has no prototype, not using it." >&4 ;;
251 esac
90e831dc 252 d_${f}_r=undef
253 ${f}_r_proto=0
c18e646a 254 ;;
a48ec845 255 esac
256 ;;
10bc17b6 257*) ${f}_r_proto=0
258 ;;
259esac
260
261EOF
262 close(U);
263 }
264}
265
266close DATA;
267
268select H;
269
270{
271 my $i = 1;
272 for my $p (sort keys %seenp) {
273 print "#define REENTRANT_PROTO_${p} ${i}\n";
274 $i++;
275 }
276}
277
278sub ifprotomatch {
279 my $F = shift;
280 join " || ", map { "${F}_R_PROTO == REENTRANT_PROTO_$_" } @_;
281}
282
283my @struct;
284my @size;
285my @init;
286my @free;
287my @wrap;
288my @define;
289
290sub pushssif {
291 push @struct, @_;
292 push @size, @_;
293 push @init, @_;
294 push @free, @_;
295}
296
297sub pushinitfree {
298 my $f = shift;
299 push @init, <<EOF;
300 New(31338, PL_reentrant_buffer->_${f}_buffer, PL_reentrant_buffer->_${f}_size, char);
301EOF
302 push @free, <<EOF;
303 Safefree(PL_reentrant_buffer->_${f}_buffer);
304EOF
305}
306
307sub define {
308 my ($n, $p, @F) = @_;
309 my @H;
310 my $H = uc $F[0];
311 push @define, <<EOF;
312/* The @F using \L$n? */
313
314EOF
315 for my $f (@F) {
316 my $F = uc $f;
317 my $h = "${F}_R_HAS_$n";
318 push @H, $h;
319 my @h = grep { /$p/ } @{$seena{$f}};
320 if (@h) {
09310450 321 push @define, "#if defined(HAS_${F}_R) && (" . join(" || ", map { "${F}_R_PROTO == REENTRANT_PROTO_$_" } @h) . ")\n";
10bc17b6 322
323 push @define, <<EOF;
324# define $h
325#else
326# undef $h
327#endif
328EOF
329 }
330 }
331 push @define, <<EOF;
332
333/* Any of the @F using \L$n? */
334
335EOF
336 push @define, "#if (" . join(" || ", map { "defined($_)" } @H) . ")\n";
337 push @define, <<EOF;
338# define USE_${H}_$n
339#else
340# undef USE_${H}_$n
341#endif
342
343EOF
344}
345
edd309b7 346define('BUFFER', 'B',
347 qw(getgrent getgrgid getgrnam));
348
10bc17b6 349define('PTR', 'R',
350 qw(getgrent getgrgid getgrnam));
351define('PTR', 'R',
352 qw(getpwent getpwnam getpwuid));
353define('PTR', 'R',
354 qw(getspent getspnam));
355
356define('FPTR', 'H',
357 qw(getgrent getgrgid getgrnam));
358define('FPTR', 'H',
359 qw(getpwent getpwnam getpwuid));
360
edd309b7 361define('BUFFER', 'B',
362 qw(getpwent getpwgid getpwnam));
363
10bc17b6 364define('PTR', 'R',
365 qw(gethostent gethostbyaddr gethostbyname));
366define('PTR', 'R',
367 qw(getnetent getnetbyaddr getnetbyname));
368define('PTR', 'R',
369 qw(getprotoent getprotobyname getprotobynumber));
370define('PTR', 'R',
371 qw(getservent getservbyname getservbyport));
372
edd309b7 373define('BUFFER', 'B',
374 qw(gethostent gethostbyaddr gethostbyname));
375define('BUFFER', 'B',
376 qw(getnetent getnetbyaddr getnetbyname));
377define('BUFFER', 'B',
378 qw(getprotoent getprotobyname getprotobynumber));
379define('BUFFER', 'B',
380 qw(getservent getservbyname getservbyport));
381
10bc17b6 382define('ERRNO', 'E',
383 qw(gethostent gethostbyaddr gethostbyname));
384define('ERRNO', 'E',
385 qw(getnetent getnetbyaddr getnetbyname));
386
387for my $f (@seenf) {
388 my $F = uc $f;
389 my $ifdef = "#ifdef HAS_${F}_R\n";
390 my $endif = "#endif /* HAS_${F}_R */\n";
391 if (exists $seena{$f}) {
392 my @p = @{$seena{$f}};
393 if ($f =~ /^(asctime|ctime|getlogin|setlocale|strerror|ttyname)$/) {
394 pushssif $ifdef;
395 push @struct, <<EOF;
396 char* _${f}_buffer;
397 size_t _${f}_size;
398EOF
399 push @size, <<EOF;
400 PL_reentrant_buffer->_${f}_size = 256; /* Make something up. */
401EOF
402 pushinitfree $f;
403 pushssif $endif;
404 }
b430fd04 405 elsif ($f =~ /^(crypt)$/) {
10bc17b6 406 pushssif $ifdef;
407 push @struct, <<EOF;
b430fd04 408#if CRYPT_R_PROTO == REENTRANT_PROTO_B_CCD
409 $seend{$f} _${f}_data;
410#else
10bc17b6 411 $seent{$f} _${f}_struct;
b430fd04 412#endif
10bc17b6 413EOF
b430fd04 414 push @init, <<EOF;
10bc17b6 415#ifdef __GLIBC__
416 PL_reentrant_buffer->_${f}_struct.initialized = 0;
417#endif
418EOF
b430fd04 419 pushssif $endif;
420 }
421 elsif ($f =~ /^(drand48|gmtime|localtime|random)$/) {
422 pushssif $ifdef;
423 push @struct, <<EOF;
424 $seent{$f} _${f}_struct;
425EOF
10bc17b6 426 if ($1 eq 'drand48') {
427 push @struct, <<EOF;
428 double _${f}_double;
429EOF
430 }
431 pushssif $endif;
432 }
433 elsif ($f =~ /^(getgrnam|getpwnam|getspnam)$/) {
434 pushssif $ifdef;
435 my $g = $f;
436 $g =~ s/nam/ent/g;
437 my $G = uc $g;
438 push @struct, <<EOF;
439 $seent{$f} _${g}_struct;
440 char* _${g}_buffer;
441 size_t _${g}_size;
442EOF
443 push @struct, <<EOF;
444# ifdef USE_${G}_PTR
445 $seent{$f}* _${g}_ptr;
446# endif
447EOF
448 if ($g eq 'getspent') {
449 push @size, <<EOF;
450 PL_reentrant_buffer->_${g}_size = 1024;
451EOF
452 } else {
453 push @struct, <<EOF;
454# ifdef USE_${G}_FPTR
455 FILE* _${g}_fptr;
456# endif
457EOF
458 push @init, <<EOF;
459# ifdef USE_${G}_FPTR
460 PL_reentrant_buffer->_${g}_fptr = NULL;
461# endif
462EOF
463 my $sc = $g eq 'getgrent' ?
464 '_SC_GETGR_R_SIZE_MAX' : '_SC_GETPW_R_SIZE_MAX';
465 push @size, <<EOF;
466# if defined(HAS_SYSCONF) && defined($sc) && !defined(__GLIBC__)
467 PL_reentrant_buffer->_${g}_size = sysconf($sc);
468# else
469# if defined(__osf__) && defined(__alpha) && defined(SIABUFSIZ)
470 PL_reentrant_buffer->_${g}_size = SIABUFSIZ;
471# else
472# ifdef __sgi
473 PL_reentrant_buffer->_${g}_size = BUFSIZ;
474# else
edd309b7 475 PL_reentrant_buffer->_${g}_size = 256;
10bc17b6 476# endif
477# endif
478# endif
479EOF
480 }
481 pushinitfree $g;
482 pushssif $endif;
483 }
484 elsif ($f =~ /^(gethostbyname|getnetbyname|getservbyname|getprotobyname)$/) {
485 pushssif $ifdef;
486 my $g = $f;
487 $g =~ s/byname/ent/;
488 my $G = uc $g;
489 my $D = ifprotomatch($F, grep {/D/} @p);
490 my $d = $seend{$f};
491 push @struct, <<EOF;
492 $seent{$f} _${g}_struct;
493# if $D
494 $d _${g}_data;
495# else
496 char* _${g}_buffer;
497 size_t _${g}_size;
498# endif
499# ifdef USE_${G}_PTR
500 $seent{$f}* _${g}_ptr;
501# endif
502EOF
503 push @struct, <<EOF;
504# ifdef USE_${G}_ERRNO
505 int _${g}_errno;
506# endif
507EOF
508 push @size, <<EOF;
509#if !($D)
510 PL_reentrant_buffer->_${g}_size = 2048; /* Any better ideas? */
511#endif
512EOF
513 push @init, <<EOF;
514#if !($D)
515 New(31338, PL_reentrant_buffer->_${g}_buffer, PL_reentrant_buffer->_${g}_size, char);
516#endif
517EOF
518 push @free, <<EOF;
519#if !($D)
520 Safefree(PL_reentrant_buffer->_${g}_buffer);
521#endif
522EOF
523 pushssif $endif;
524 }
525 elsif ($f =~ /^(readdir|readdir64)$/) {
526 pushssif $ifdef;
527 my $R = ifprotomatch($F, grep {/R/} @p);
528 push @struct, <<EOF;
529 $seent{$f}* _${f}_struct;
530 size_t _${f}_size;
531# if $R
532 $seent{$f}* _${f}_ptr;
533# endif
534EOF
535 push @size, <<EOF;
536 /* This is the size Solaris recommends.
537 * (though we go static, should use pathconf() instead) */
538 PL_reentrant_buffer->_${f}_size = sizeof($seent{$f}) + MAXPATHLEN + 1;
539EOF
540 push @init, <<EOF;
541 PL_reentrant_buffer->_${f}_struct = ($seent{$f}*)safemalloc(PL_reentrant_buffer->_${f}_size);
542EOF
543 push @free, <<EOF;
544 Safefree(PL_reentrant_buffer->_${f}_struct);
545EOF
546 pushssif $endif;
547 }
548
549 push @wrap, $ifdef;
550
551# Doesn't implement the buffer growth loop for glibc gethostby*().
552 push @wrap, <<EOF;
553# undef $f
554EOF
555 my @v = 'a'..'z';
556 my $v = join(", ", @v[0..$seenu{$f}-1]);
557 for my $p (@p) {
558 my ($r, $a) = split '_', $p;
559 my $test = $r eq 'I' ? ' == 0' : '';
560 my $true = 1;
10bc17b6 561 my $g = $f;
562 if ($g =~ /^(?:get|set|end)(pw|gr|host|net|proto|serv|sp)/) {
563 $g = "get$1ent";
564 } elsif ($g eq 'srand48') {
565 $g = "drand48";
566 }
567 my $b = $a;
568 my $w = '';
569 substr($b, 0, $seenu{$f}) = '';
570 if ($b =~ /R/) {
571 $true = "PL_reentrant_buffer->_${g}_ptr";
572 } elsif ($b =~ /T/ && $f eq 'drand48') {
573 $true = "PL_reentrant_buffer->_${g}_double";
574 } elsif ($b =~ /S/) {
575 if ($f =~ /^readdir/) {
576 $true = "PL_reentrant_buffer->_${g}_struct";
577 } else {
578 $true = "&PL_reentrant_buffer->_${g}_struct";
579 }
580 } elsif ($b =~ /B/) {
581 $true = "PL_reentrant_buffer->_${g}_buffer";
582 }
583 if (length $b) {
584 $w = join ", ",
585 map {
586 $_ eq 'R' ?
587 "&PL_reentrant_buffer->_${g}_ptr" :
588 $_ eq 'E' ?
589 "&PL_reentrant_buffer->_${g}_errno" :
590 $_ eq 'B' ?
591 "PL_reentrant_buffer->_${g}_buffer" :
592 $_ =~ /^[WI]$/ ?
593 "PL_reentrant_buffer->_${g}_size" :
594 $_ eq 'H' ?
595 "&PL_reentrant_buffer->_${g}_fptr" :
596 $_ eq 'D' ?
597 "&PL_reentrant_buffer->_${g}_data" :
598 $_ eq 'S' ?
599 ($f =~ /^readdir/ ?
600 "PL_reentrant_buffer->_${g}_struct" :
601 "&PL_reentrant_buffer->_${g}_struct" ) :
602 $_ eq 'T' && $f eq 'drand48' ?
603 "&PL_reentrant_buffer->_${g}_double" :
604 $_
605 } split '', $b;
606 $w = ", $w" if length $v;
607 }
608 my $call = "${f}_r($v$w)";
609 $call = "((errno = $call))" if $r eq 'I';
610 push @wrap, <<EOF;
611# if !defined($f) && ${F}_R_PROTO == REENTRANT_PROTO_$p
612EOF
613 if ($r eq 'V' || $r eq 'B') {
614 push @wrap, <<EOF;
615# define $f($v) $call
616EOF
617 } else {
edd309b7 618 if ($f =~ /^get/) {
619 my $rv = $v ? ", $v" : "";
620 push @wrap, <<EOF;
621# define $f($v) ($call$test ? $true : (errno == ERANGE ? Perl_reentrant_retry("$f"$rv) : 0))
10bc17b6 622EOF
edd309b7 623 } else {
624 push @wrap, <<EOF;
625# define $f($v) ($call$test ? $true : 0)
626EOF
627 }
10bc17b6 628 }
629 push @wrap, <<EOF;
630# endif
631EOF
632 }
633
634 push @wrap, $endif, "\n";
635 }
636}
637
638local $" = '';
639
640print <<EOF;
641
642/* Defines for indicating which special features are supported. */
643
644@define
645typedef struct {
646@struct
647} REENTR;
648
649/* The wrappers. */
650
651@wrap
652#endif /* USE_REENTRANT_API */
653
654#endif
655
656EOF
657
658close(H);
659
660die "reentr.c: $!" unless open(C, ">reentr.c");
661select C;
662print <<EOF;
663/*
664 * reentr.c
665 *
666 * Copyright (c) 1997-2002, Larry Wall
667 *
668 * You may distribute under the terms of either the GNU General Public
669 * License or the Artistic License, as specified in the README file.
670 *
671 * !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
672 * This file is built by reentrl.pl from data in reentr.pl.
673 *
674 * "Saruman," I said, standing away from him, "only one hand at a time can
675 * wield the One, and you know that well, so do not trouble to say we!"
676 *
677 */
678
679#include "EXTERN.h"
680#define PERL_IN_REENTR_C
681#include "perl.h"
682#include "reentr.h"
683
684void
685Perl_reentrant_size(pTHX) {
686#ifdef USE_REENTRANT_API
687@size
688#endif /* USE_REENTRANT_API */
689}
690
691void
692Perl_reentrant_init(pTHX) {
693#ifdef USE_REENTRANT_API
694 New(31337, PL_reentrant_buffer, 1, REENTR);
695 Perl_reentrant_size(aTHX);
696@init
697#endif /* USE_REENTRANT_API */
698}
699
700void
701Perl_reentrant_free(pTHX) {
702#ifdef USE_REENTRANT_API
703@free
704 Safefree(PL_reentrant_buffer);
705#endif /* USE_REENTRANT_API */
706}
707
edd309b7 708void*
709Perl_reentrant_retry(const char *f, ...)
710{
711 dTHX;
712 void *retptr = NULL;
713#ifdef USE_REENTRANT_API
714 void *p0, *p1;
715 size_t asize;
716 int anint;
717 va_list ap;
718
719 va_start(ap, f);
720
721#define REENTRANTHALFMAXSIZE 32768 /* The maximum may end up twice this. */
722
723 switch (PL_op->op_type) {
724#ifdef USE_GETHOSTENT_BUFFER
725 case OP_GHBYADDR:
726 case OP_GHBYNAME:
727 case OP_GHOSTENT:
728 {
729 if (PL_reentrant_buffer->_gethostent_size <= REENTRANTHALFMAXSIZE) {
730 PL_reentrant_buffer->_gethostent_size *= 2;
731 Renew(PL_reentrant_buffer->_gethostent_buffer,
732 PL_reentrant_buffer->_gethostent_size, char);
733 switch (PL_op->op_type) {
734 case OP_GHBYADDR:
735 p0 = va_arg(ap, void *);
736 asize = va_arg(ap, size_t);
737 anint = va_arg(ap, int);
738 retptr = gethostbyaddr(p0, asize, anint); break;
739 case OP_GHBYNAME:
740 p0 = va_arg(ap, void *);
741 retptr = gethostbyname(p0); break;
742 case OP_GHOSTENT:
743 retptr = gethostent(); break;
744 default:
745 break;
746 }
747 }
748 }
749 break;
750#endif
751#ifdef USE_GETGRENT_BUFFER
752 case OP_GGRNAM:
753 case OP_GGRGID:
754 case OP_GGRENT:
755 {
756 if (PL_reentrant_buffer->_getgrent_size <= REENTRANTHALFMAXSIZE) {
757 Gid_t gid;
758 PL_reentrant_buffer->_getgrent_size *= 2;
759 Renew(PL_reentrant_buffer->_getgrent_buffer,
760 PL_reentrant_buffer->_getgrent_size, char);
761 switch (PL_op->op_type) {
762 case OP_GGRNAM:
763 p0 = va_arg(ap, void *);
764 retptr = getgrnam(p0); break;
765 case OP_GGRGID:
766 gid = va_arg(ap, Gid_t);
767 retptr = getgrgid(gid); break;
768 case OP_GGRENT:
769 retptr = getgrent(); break;
770 default:
771 break;
772 }
773 }
774 }
775 break;
776#endif
777#ifdef USE_GETNETENT_BUFFER
778 case OP_GNBYADDR:
779 case OP_GNBYNAME:
780 case OP_GNETENT:
781 {
782 if (PL_reentrant_buffer->_getnetent_size <= REENTRANTHALFMAXSIZE) {
783 Netdb_net_t net;
784 PL_reentrant_buffer->_getnetent_size *= 2;
785 Renew(PL_reentrant_buffer->_getnetent_buffer,
786 PL_reentrant_buffer->_getnetent_size, char);
787 switch (PL_op->op_type) {
788 case OP_GNBYADDR:
789 net = va_arg(ap, Netdb_net_t);
790 anint = va_arg(ap, int);
791 retptr = getnetbyaddr(net, anint); break;
792 case OP_GNBYNAME:
793 p0 = va_arg(ap, void *);
794 retptr = getnetbyname(p0); break;
795 case OP_GNETENT:
796 retptr = getnetent(); break;
797 default:
798 break;
799 }
800 }
801 }
802 break;
803#endif
804#ifdef USE_GETPWENT_BUFFER
805 case OP_GPWNAM:
806 case OP_GPWUID:
807 case OP_GPWENT:
808 {
809 if (PL_reentrant_buffer->_getpwent_size <= REENTRANTHALFMAXSIZE) {
810 Uid_t uid;
811 PL_reentrant_buffer->_getpwent_size *= 2;
812 Renew(PL_reentrant_buffer->_getpwent_buffer,
813 PL_reentrant_buffer->_getpwent_size, char);
814 switch (PL_op->op_type) {
815 case OP_GPWNAM:
816 p0 = va_arg(ap, void *);
817 retptr = getpwnam(p0); break;
818 case OP_GPWUID:
819 uid = va_arg(ap, Uid_t);
820 retptr = getpwuid(uid); break;
821 case OP_GPWENT:
822 retptr = getpwent(); break;
823 default:
824 break;
825 }
826 }
827 }
828 break;
829#endif
830#ifdef USE_GETPROTOENT_BUFFER
831 case OP_GPBYNAME:
832 case OP_GPBYNUMBER:
833 case OP_GPROTOENT:
834 {
835 if (PL_reentrant_buffer->_getprotoent_size <= REENTRANTHALFMAXSIZE) {
836 PL_reentrant_buffer->_getprotoent_size *= 2;
837 Renew(PL_reentrant_buffer->_getprotoent_buffer,
838 PL_reentrant_buffer->_getprotoent_size, char);
839 switch (PL_op->op_type) {
840 case OP_GPBYNAME:
841 p0 = va_arg(ap, void *);
842 retptr = getprotobyname(p0); break;
843 case OP_GPBYNUMBER:
844 anint = va_arg(ap, int);
845 retptr = getprotobynumber(anint); break;
846 case OP_GPROTOENT:
847 retptr = getprotoent(); break;
848 default:
849 break;
850 }
851 }
852 }
853 break;
854#endif
855#ifdef USE_GETSERVENT_BUFFER
856 case OP_GSBYNAME:
857 case OP_GSBYPORT:
858 case OP_GSERVENT:
859 {
860 if (PL_reentrant_buffer->_getservent_size <= REENTRANTHALFMAXSIZE) {
861 PL_reentrant_buffer->_getservent_size *= 2;
862 Renew(PL_reentrant_buffer->_getservent_buffer,
863 PL_reentrant_buffer->_getservent_size, char);
864 switch (PL_op->op_type) {
865 case OP_GSBYNAME:
866 p0 = va_arg(ap, void *);
867 p1 = va_arg(ap, void *);
868 retptr = getservbyname(p0, p1); break;
869 case OP_GSBYPORT:
870 anint = va_arg(ap, int);
871 p0 = va_arg(ap, void *);
872 retptr = getservbyport(anint, p0); break;
873 case OP_GSERVENT:
874 retptr = getservent(); break;
875 default:
876 break;
877 }
878 }
879 }
880 break;
881#endif
882 default:
883 /* Not known how to retry, so just fail. */
884 break;
885 }
886
887 va_end(ap);
888#endif
889 return retptr;
890}
891
10bc17b6 892EOF
893
894__DATA__
895asctime S |time |const struct tm|B_SB|B_SBI|I_SB|I_SBI
b430fd04 896crypt CC |crypt |struct crypt_data|B_CCS|B_CCD|D=CRYPTD*
10bc17b6 897ctermid B |stdio | |B_B
898ctime S |time |const time_t |B_SB|B_SBI|I_SB|I_SBI
899drand48 |stdlib |struct drand48_data |I_ST|T=double*
900endgrent |grp | |I_H|V_H
901endhostent |netdb |struct hostent_data |I_S|V_S
902endnetent |netdb |struct netent_data |I_S|V_S
903endprotoent |netdb |struct protoent_data |I_S|V_S
904endpwent |pwd | |I_H|V_H
905endservent |netdb |struct servent_data |I_S|V_S
906getgrent |grp |struct group |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
907getgrgid T |grp |struct group |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=gid_t
908getgrnam C |grp |struct group |I_CSBWR|I_CSBIR|S_CBI|I_CSBI|S_CSBI
909gethostbyaddr CWI |netdb |struct hostent |I_CWISBWRE|S_CWISBWIE|S_CWISBIE|S_TWISBIE|S_CIISBIE|S_CSBIE|S_TSBIE|I_CWISD|I_CIISD|I_CII|D=struct hostent_data*|T=const void*
910gethostbyname C |netdb |struct hostent |I_CSBWRE|S_CSBIE|I_CSD|D=struct hostent_data*
911gethostent |netdb |struct hostent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct hostent_data*
912getlogin |unistd | |I_BW|I_BI|B_BW|B_BI
913getnetbyaddr LI |netdb |struct netent |I_UISBWRE|I_LISBI|S_TISBI|S_LISBI|I_TISD|I_LISD|I_IISD|D=struct netent_data*|T=in_addr_t|U=unsigned long
914getnetbyname C |netdb |struct netent |I_CSBWRE|I_CSBI|S_CSBI|I_CSD|D=struct netent_data*
915getnetent |netdb |struct netent |I_SBWRE|I_SBIE|S_SBIE|S_SBI|I_SBI|I_SD|D=struct netent_data*
916getprotobyname C|netdb |struct protoent|I_CSBWR|S_CSBI|I_CSD|D=struct protoent_data*
917getprotobynumber I |netdb |struct protoent|I_ISBWR|S_ISBI|I_ISD|D=struct protoent_data*
918getprotoent |netdb |struct protoent|I_SBWR|I_SBI|S_SBI|I_SD|D=struct protoent_data*
919getpwent |pwd |struct passwd |I_SBWR|I_SBIR|S_SBW|S_SBI|I_SBI|I_SBIH
920getpwnam C |pwd |struct passwd |I_CSBWR|I_CSBIR|S_CSBI|I_CSBI
921getpwuid T |pwd |struct passwd |I_TSBWR|I_TSBIR|I_TSBI|S_TSBI|T=uid_t
922getservbyname CC|netdb |struct servent |I_CCSBWR|S_CCSBI|I_CCSD|D=struct servent_data*
923getservbyport IC|netdb |struct servent |I_ICSBWR|S_ICSBI|I_ICSD|D=struct servent_data*
924getservent |netdb |struct servent |I_SBWR|I_SBI|S_SBI|I_SD|D=struct servent_data*
925getspnam C |shadow |struct spwd |I_CSBWR|S_CSBI
926gmtime T |time |struct tm |S_TS|I_TS|T=const time_t*
927localtime T |time |struct tm |S_TS|I_TS|T=const time_t*
928random |stdlib |struct random_data|I_TS|T=int*
929readdir T |dirent |struct dirent |I_TSR|I_TS|T=DIR*
930readdir64 T |dirent |struct dirent64|I_TSR|I_TS|T=DIR*
931setgrent |grp | |I_H|V_H
932sethostent I |netdb | |I_ID|V_ID|D=struct hostent_data*
933setlocale IC |locale | |I_ICBI
934setnetent I |netdb | |I_ID|V_ID|D=struct netent_data*
935setprotoent I |netdb | |I_ID|V_ID|D=struct protoent_data*
936setpwent |pwd | |I_H|V_H
937setservent I |netdb | |I_ID|V_ID|D=struct servent_data*
938srand48 L |stdlib |struct drand48_data |I_LS
939srandom T |stdlib |struct random_data|I_TS|T=unsigned int
940strerror I |string | |I_IBW|I_IBI|B_IBW
941tmpnam B |stdio | |B_B
942ttyname I |unistd | |I_IBW|I_IBI|B_IBI