source: trunk/essentials/dev-lang/perl/ext/POSIX/POSIX.pm@ 3400

Last change on this file since 3400 was 3181, checked in by bird, 19 years ago

perl 5.8.8

File size: 18.5 KB
Line 
1package POSIX;
2
3our(@ISA, %EXPORT_TAGS, @EXPORT_OK, $AUTOLOAD) = ();
4
5our $VERSION = "1.09";
6
7use AutoLoader;
8
9use XSLoader ();
10
11# Grandfather old foo_h form to new :foo_h form
12my $loaded;
13
14sub import {
15 load_imports() unless $loaded++;
16 my $this = shift;
17 my @list = map { m/^\w+_h$/ ? ":$_" : $_ } @_;
18 local $Exporter::ExportLevel = 1;
19 Exporter::import($this,@list);
20}
21
22sub croak { require Carp; goto &Carp::croak }
23# declare usage to assist AutoLoad
24sub usage;
25
26XSLoader::load 'POSIX', $VERSION;
27
28my %NON_CONSTS = (map {($_,1)}
29 qw(S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISREG WEXITSTATUS
30 WIFEXITED WIFSIGNALED WIFSTOPPED WSTOPSIG WTERMSIG));
31
32sub AUTOLOAD {
33 if ($AUTOLOAD =~ /::(_?[a-z])/) {
34 # require AutoLoader;
35 $AutoLoader::AUTOLOAD = $AUTOLOAD;
36 goto &AutoLoader::AUTOLOAD
37 }
38 local $! = 0;
39 my $constname = $AUTOLOAD;
40 $constname =~ s/.*:://;
41 if ($NON_CONSTS{$constname}) {
42 my ($val, $error) = &int_macro_int($constname, $_[0]);
43 croak $error if $error;
44 *$AUTOLOAD = sub { &int_macro_int($constname, $_[0]) };
45 } else {
46 my ($error, $val) = constant($constname);
47 croak $error if $error;
48 *$AUTOLOAD = sub { $val };
49 }
50
51 goto &$AUTOLOAD;
52}
53
54package POSIX::SigAction;
55
56use AutoLoader 'AUTOLOAD';
57sub new { bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0, SAFE => 0}, $_[0] }
58
59package POSIX;
60
611;
62__END__
63
64sub usage {
65 my ($mess) = @_;
66 croak "Usage: POSIX::$mess";
67}
68
69sub redef {
70 my ($mess) = @_;
71 croak "Use method $mess instead";
72}
73
74sub unimpl {
75 my ($mess) = @_;