package POSIX;
our $VERSION = "1.08";
use AutoLoader;
use XSLoader ();
# Grandfather old foo_h form to new :foo_h form
my $loaded;
sub import {
load_imports() unless $loaded++;
my $this = shift;
}
# declare usage to assist AutoLoad
sub usage;
my %NON_CONSTS = (map {($_,1)}
sub AUTOLOAD {
if ($AUTOLOAD =~ /::(_?[a-z])/) {
# require AutoLoader;
goto &AutoLoader::AUTOLOAD
}
local $! = 0;
$constname =~ s/.*:://;
if ($NON_CONSTS{$constname}) {
} else {
}
goto &$AUTOLOAD;
}
use AutoLoader 'AUTOLOAD';
package POSIX;
1;
sub usage {
my ($mess) = @_;
croak "Usage: POSIX::$mess";
}
sub redef {
my ($mess) = @_;
croak "Use method $mess instead";
}
sub unimpl {
my ($mess) = @_;
croak "Unimplemented: POSIX::$mess";
}
sub assert {
if (!$_[0]) {
croak "Assertion failed";
}
}
sub tolower {
lc($_[0]);
}
sub toupper {
uc($_[0]);
}
sub closedir {
CORE::closedir($_[0]);
}
sub opendir {
my $dirhandle;
? $dirhandle
: undef;
}
sub readdir {
CORE::readdir($_[0]);
}
sub rewinddir {
CORE::rewinddir($_[0]);
}
sub errno {
$! + 0;
}
sub creat {
}
sub fcntl {
}
sub getgrgid {
CORE::getgrgid($_[0]);
}
sub getgrnam {
CORE::getgrnam($_[0]);
}
sub atan2 {
}
sub cos {
CORE::cos($_[0]);
}
sub exp {
CORE::exp($_[0]);
}
sub fabs {
CORE::abs($_[0]);
}
sub log {
CORE::log($_[0]);
}
sub pow {
$_[0] ** $_[1];
}
sub sin {
CORE::sin($_[0]);
}
sub sqrt {
CORE::sqrt($_[0]);
}
sub getpwnam {
CORE::getpwnam($_[0]);
}
sub getpwuid {
CORE::getpwuid($_[0]);
}
sub longjmp {
unimpl "longjmp() is C-specific: use die instead";
}
sub setjmp {
unimpl "setjmp() is C-specific: use eval {} instead";
}
sub siglongjmp {
unimpl "siglongjmp() is C-specific: use die instead";
}
sub sigsetjmp {
unimpl "sigsetjmp() is C-specific: use eval {} instead";
}
sub kill {
}
sub raise {
}
sub offsetof {
unimpl "offsetof() is C-specific, stopped";
}
sub clearerr {
redef "IO::Handle::clearerr()";
}
sub fclose {
redef "IO::Handle::close()";
}
sub fdopen {
redef "IO::Handle::new_from_fd()";
}
sub feof {
redef "IO::Handle::eof()";
}
sub fgetc {
redef "IO::Handle::getc()";
}
sub fgets {
redef "IO::Handle::gets()";
}
sub fileno {
redef "IO::Handle::fileno()";
}
sub fopen {
redef "IO::File::open()";
}
sub fprintf {
unimpl "fprintf() is C-specific--use printf instead";
}
sub fputc {
unimpl "fputc() is C-specific--use print instead";
}
sub fputs {
unimpl "fputs() is C-specific--use print instead";
}
sub fread {
unimpl "fread() is C-specific--use read instead";
}
sub freopen {
unimpl "freopen() is C-specific--use open instead";
}
sub fscanf {
unimpl "fscanf() is C-specific--use <> and regular expressions instead";
}
sub fseek {
redef "IO::Seekable::seek()";
}
sub fsync {
redef "IO::Handle::sync()";
}
sub ferror {
redef "IO::Handle::error()";
}
sub fflush {
redef "IO::Handle::flush()";
}
sub fgetpos {
redef "IO::Seekable::getpos()";
}
sub fsetpos {
redef "IO::Seekable::setpos()";
}
sub ftell {
redef "IO::Seekable::tell()";
}
sub fwrite {
unimpl "fwrite() is C-specific--use print instead";
}
sub getc {
CORE::getc($_[0]);
}
sub getchar {
}
sub gets {
scalar <STDIN>;
}
sub perror {
print STDERR "@_: " if @_;
print STDERR $!,"\n";
}
sub printf {
}
sub putc {
unimpl "putc() is C-specific--use print instead";
}
sub putchar {
unimpl "putchar() is C-specific--use print instead";
}
sub puts {
unimpl "puts() is C-specific--use print instead";
}
sub remove {
CORE::unlink($_[0]);
}
sub rename {
}
sub rewind {
}
sub scanf {
unimpl "scanf() is C-specific--use <> and regular expressions instead";
}
sub sprintf {
CORE::sprintf(shift,@_);
}
sub sscanf {
unimpl "sscanf() is C-specific--use regular expressions instead";
}
sub tmpfile {
redef "IO::File::new_tmpfile()";
}
sub ungetc {
redef "IO::Handle::ungetc()";
}
sub vfprintf {
unimpl "vfprintf() is C-specific";
}
sub vprintf {
unimpl "vprintf() is C-specific";
}
sub vsprintf {
unimpl "vsprintf() is C-specific";
}
sub abs {
CORE::abs($_[0]);
}
sub atexit {
unimpl "atexit() is C-specific: use END {} instead";
}
sub atof {
unimpl "atof() is C-specific, stopped";
}
sub atoi {
unimpl "atoi() is C-specific, stopped";
}
sub atol {
unimpl "atol() is C-specific, stopped";
}
sub bsearch {
unimpl "bsearch() not supplied";
}
sub calloc {
unimpl "calloc() is C-specific, stopped";
}
sub div {
unimpl "div() is C-specific, use /, % and int instead";
}
sub exit {
CORE::exit($_[0]);
}
sub free {
unimpl "free() is C-specific, stopped";
}
sub getenv {
$ENV{$_[0]};
}
sub labs {
unimpl "labs() is C-specific, use abs instead";
}
sub ldiv {
unimpl "ldiv() is C-specific, use /, % and int instead";
}
sub malloc {
unimpl "malloc() is C-specific, stopped";
}
sub qsort {
unimpl "qsort() is C-specific, use sort instead";
}
sub rand {
unimpl "rand() is non-portable, use Perl's rand instead";
}
sub realloc {
unimpl "realloc() is C-specific, stopped";
}
sub srand {
unimpl "srand()";
}
sub system {
CORE::system($_[0]);
}
sub memchr {
unimpl "memchr() is C-specific, use index() instead";
}
sub memcmp {
unimpl "memcmp() is C-specific, use eq instead";
}
sub memcpy {
unimpl "memcpy() is C-specific, use = instead";
}
sub memmove {
unimpl "memmove() is C-specific, use = instead";
}
sub memset {
unimpl "memset() is C-specific, use x instead";
}
sub strcat {
unimpl "strcat() is C-specific, use .= instead";
}
sub strchr {
unimpl "strchr() is C-specific, use index() instead";
}
sub strcmp {
unimpl "strcmp() is C-specific, use eq instead";
}
sub strcpy {
unimpl "strcpy() is C-specific, use = instead";
}
sub strcspn {
unimpl "strcspn() is C-specific, use regular expressions instead";
}
sub strerror {
local $! = $_[0];
$! . "";
}
sub strlen {
unimpl "strlen() is C-specific, use length instead";
}
sub strncat {
unimpl "strncat() is C-specific, use .= instead";
}
sub strncmp {
unimpl "strncmp() is C-specific, use eq instead";
}
sub strncpy {
unimpl "strncpy() is C-specific, use = instead";
}
sub strpbrk {
unimpl "strpbrk() is C-specific, stopped";
}
sub strrchr {
unimpl "strrchr() is C-specific, use rindex() instead";
}
sub strspn {
unimpl "strspn() is C-specific, stopped";
}
sub strstr {
}
sub strtok {
unimpl "strtok() is C-specific, stopped";
}
sub chmod {
}
sub fstat {
local *TMP;
@l;
}
sub mkdir {
}
sub stat {
CORE::stat($_[0]);
}
sub umask {
CORE::umask($_[0]);
}
sub wait {
CORE::wait();
}
sub waitpid {
}
sub gmtime {
CORE::gmtime($_[0]);
}
sub localtime {
CORE::localtime($_[0]);
}
sub time {
CORE::time;
}
sub alarm {
CORE::alarm($_[0]);
}
sub chdir {
CORE::chdir($_[0]);
}
sub chown {
}
sub execl {
unimpl "execl() is C-specific, stopped";
}
sub execle {
unimpl "execle() is C-specific, stopped";
}
sub execlp {
unimpl "execlp() is C-specific, stopped";
}
sub execv {
unimpl "execv() is C-specific, stopped";
}
sub execve {
unimpl "execve() is C-specific, stopped";
}
sub execvp {
unimpl "execvp() is C-specific, stopped";
}
sub fork {
CORE::fork;
}
sub getegid {
$) + 0;
}
sub geteuid {
$> + 0;
}
sub getgid {
$( + 0;
}
sub getgroups {
my %seen;
grep(!$seen{$_}++, split(' ', $) ));
}
sub getlogin {
CORE::getlogin();
}
sub getpgrp {
CORE::getpgrp;
}
sub getpid {
$$;
}
sub getppid {
CORE::getppid;
}
sub getuid {
$<;
}
sub isatty {
-t $_[0];
}
sub link {
}
sub rmdir {
CORE::rmdir($_[0]);
}
sub setbuf {
redef "IO::Handle::setbuf()";
}
sub setvbuf {
redef "IO::Handle::setvbuf()";
}
sub sleep {
}
sub unlink {
CORE::unlink($_[0]);
}
sub utime {
}
sub load_imports {
%EXPORT_TAGS = (
dirent_h => [],
grp_h => [],
pwd_h => [],
stdarg_h => [],
sys_times_h => [],
sys_types_h => [],
sys_utsname_h => [qw(uname)],
utime_h => [],
);
# Exporter::export_tags();
for (values %EXPORT_TAGS) {
push @EXPORT, @$_;
}
@EXPORT_OK = qw(
abs
alarm
atan2
chdir
chmod
chown
close
closedir
cos
exit
exp
fcntl
fileno
fork
getc
getgrgid
getgrnam
getlogin
getpgrp
getppid
getpwnam
getpwuid
gmtime
kill
link
localtime
log
mkdir
open
opendir
pipe
printf
rand
read
readdir
rename
rewinddir
rmdir
sin
sleep
sprintf
sqrt
srand
stat
system
time
times
umask
unlink
utime
wait
waitpid
write
);
require Exporter;
}