update Changes, patchlevel etc.
[p5sagit/p5-mst-13.2.git] / ext / POSIX / POSIX.pm
CommitLineData
a0d0e21e 1package POSIX;
2
e3d0cac0 3# use vars qw($VERSION @ISA %EXPORT_TAGS @EXPORT_OK $AUTOLOAD);
4(@ISA, %EXPORT_TAGS,@EXPORT_OK,$AUTOLOAD) = ();
73c78b0a 5
a0d0e21e 6use Carp;
3b35bae3 7use AutoLoader;
a0d0e21e 8require Config;
c07a80fd 9use Symbol;
10
11require Exporter;
12require DynaLoader;
fec02dd3 13@ISA = qw(Exporter DynaLoader);
a0d0e21e 14
e3d0cac0 15$VERSION = $VERSION = "1.03" ;
c07a80fd 16
748a9306 17%EXPORT_TAGS = (
a0d0e21e 18
748a9306 19 assert_h => [qw(assert NDEBUG)],
a0d0e21e 20
748a9306 21 ctype_h => [qw(isalnum isalpha iscntrl isdigit isgraph islower
22 isprint ispunct isspace isupper isxdigit tolower toupper)],
a0d0e21e 23
748a9306 24 dirent_h => [qw()],
25
774d564b 26 errno_h => [qw(E2BIG EACCES EADDRINUSE EADDRNOTAVAIL EAFNOSUPPORT
27 EAGAIN EALREADY EBADF EBUSY ECHILD ECONNABORTED
28 ECONNREFUSED ECONNRESET EDEADLK EDESTADDRREQ EDOM EDQUOT
29 EEXIST EFAULT EFBIG EHOSTDOWN EHOSTUNREACH EINPROGRESS
30 EINTR EINVAL EIO EISCONN EISDIR ELOOP EMFILE EMLINK
31 EMSGSIZE ENAMETOOLONG ENETDOWN ENETRESET ENETUNREACH
32 ENFILE ENOBUFS ENODEV ENOENT ENOEXEC ENOLCK ENOMEM
33 ENOPROTOOPT ENOSPC ENOSYS ENOTBLK ENOTCONN ENOTDIR
34 ENOTEMPTY ENOTSOCK ENOTTY ENXIO EOPNOTSUPP EPERM
35 EPFNOSUPPORT EPIPE EPROCLIM EPROTONOSUPPORT EPROTOTYPE
36 ERANGE EREMOTE ERESTART EROFS ESHUTDOWN ESOCKTNOSUPPORT
37 ESPIPE ESRCH ESTALE ETIMEDOUT ETOOMANYREFS ETXTBSY
38 EUSERS EWOULDBLOCK EXDEV errno)],
a0d0e21e 39
748a9306 40 fcntl_h => [qw(FD_CLOEXEC F_DUPFD F_GETFD F_GETFL F_GETLK F_RDLCK
a0d0e21e 41 F_SETFD F_SETFL F_SETLK F_SETLKW F_UNLCK F_WRLCK
42 O_ACCMODE O_APPEND O_CREAT O_EXCL O_NOCTTY O_NONBLOCK
43 O_RDONLY O_RDWR O_TRUNC O_WRONLY
44 creat
45 SEEK_CUR SEEK_END SEEK_SET
46 S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU
47 S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISGID S_ISREG S_ISUID
748a9306 48 S_IWGRP S_IWOTH S_IWUSR)],
a0d0e21e 49
748a9306 50 float_h => [qw(DBL_DIG DBL_EPSILON DBL_MANT_DIG
a0d0e21e 51 DBL_MAX DBL_MAX_10_EXP DBL_MAX_EXP
52 DBL_MIN DBL_MIN_10_EXP DBL_MIN_EXP
53 FLT_DIG FLT_EPSILON FLT_MANT_DIG
54 FLT_MAX FLT_MAX_10_EXP FLT_MAX_EXP
55 FLT_MIN FLT_MIN_10_EXP FLT_MIN_EXP
56 FLT_RADIX FLT_ROUNDS
57 LDBL_DIG LDBL_EPSILON LDBL_MANT_DIG
58 LDBL_MAX LDBL_MAX_10_EXP LDBL_MAX_EXP
748a9306 59 LDBL_MIN LDBL_MIN_10_EXP LDBL_MIN_EXP)],
a0d0e21e 60
748a9306 61 grp_h => [qw()],
a0d0e21e 62
748a9306 63 limits_h => [qw( ARG_MAX CHAR_BIT CHAR_MAX CHAR_MIN CHILD_MAX
a0d0e21e 64 INT_MAX INT_MIN LINK_MAX LONG_MAX LONG_MIN MAX_CANON
65 MAX_INPUT MB_LEN_MAX NAME_MAX NGROUPS_MAX OPEN_MAX
66 PATH_MAX PIPE_BUF SCHAR_MAX SCHAR_MIN SHRT_MAX SHRT_MIN
67 SSIZE_MAX STREAM_MAX TZNAME_MAX UCHAR_MAX UINT_MAX
68 ULONG_MAX USHRT_MAX _POSIX_ARG_MAX _POSIX_CHILD_MAX
69 _POSIX_LINK_MAX _POSIX_MAX_CANON _POSIX_MAX_INPUT
70 _POSIX_NAME_MAX _POSIX_NGROUPS_MAX _POSIX_OPEN_MAX
71 _POSIX_PATH_MAX _POSIX_PIPE_BUF _POSIX_SSIZE_MAX
4670cb3e 72 _POSIX_STREAM_MAX _POSIX_TZNAME_MAX)],
a0d0e21e 73
748a9306 74 locale_h => [qw(LC_ALL LC_COLLATE LC_CTYPE LC_MONETARY LC_NUMERIC
75 LC_TIME NULL localeconv setlocale)],
a0d0e21e 76
748a9306 77 math_h => [qw(HUGE_VAL acos asin atan ceil cosh fabs floor fmod
3b35bae3 78 frexp ldexp log10 modf pow sinh tan tanh)],
a0d0e21e 79
748a9306 80 pwd_h => [qw()],
a0d0e21e 81
748a9306 82 setjmp_h => [qw(longjmp setjmp siglongjmp sigsetjmp)],
a0d0e21e 83
774d564b 84 signal_h => [qw(SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK
85 SA_RESETHAND SA_RESTART SA_SIGINFO SIGABRT SIGALRM
86 SIGCHLD SIGCONT SIGFPE SIGHUP SIGILL SIGINT SIGKILL
87 SIGPIPE SIGQUIT SIGSEGV SIGSTOP SIGTERM SIGTSTP SIGTTIN
88 SIGTTOU SIGUSR1 SIGUSR2 SIG_BLOCK SIG_DFL SIG_ERR
89 SIG_IGN SIG_SETMASK SIG_UNBLOCK raise sigaction signal
90 sigpending sigprocmask sigsuspend)],
a0d0e21e 91
748a9306 92 stdarg_h => [qw()],
a0d0e21e 93
748a9306 94 stddef_h => [qw(NULL offsetof)],
a0d0e21e 95
748a9306 96 stdio_h => [qw(BUFSIZ EOF FILENAME_MAX L_ctermid L_cuserid
c07a80fd 97 L_tmpname NULL SEEK_CUR SEEK_END SEEK_SET
98 STREAM_MAX TMP_MAX stderr stdin stdout
a0d0e21e 99 clearerr fclose fdopen feof ferror fflush fgetc fgetpos
100 fgets fopen fprintf fputc fputs fread freopen
101 fscanf fseek fsetpos ftell fwrite getchar gets
102 perror putc putchar puts remove rewind
103 scanf setbuf setvbuf sscanf tmpfile tmpnam
748a9306 104 ungetc vfprintf vprintf vsprintf)],
a0d0e21e 105
748a9306 106 stdlib_h => [qw(EXIT_FAILURE EXIT_SUCCESS MB_CUR_MAX NULL RAND_MAX
a0d0e21e 107 abort atexit atof atoi atol bsearch calloc div
108 free getenv labs ldiv malloc mblen mbstowcs mbtowc
a89d8a78 109 qsort realloc strtod strtol strtoul wcstombs wctomb)],
a0d0e21e 110
748a9306 111 string_h => [qw(NULL memchr memcmp memcpy memmove memset strcat
a0d0e21e 112 strchr strcmp strcoll strcpy strcspn strerror strlen
113 strncat strncmp strncpy strpbrk strrchr strspn strstr
748a9306 114 strtok strxfrm)],
a0d0e21e 115
748a9306 116 sys_stat_h => [qw(S_IRGRP S_IROTH S_IRUSR S_IRWXG S_IRWXO S_IRWXU
a0d0e21e 117 S_ISBLK S_ISCHR S_ISDIR S_ISFIFO S_ISGID S_ISREG
118 S_ISUID S_IWGRP S_IWOTH S_IWUSR S_IXGRP S_IXOTH S_IXUSR
76b4e777 119 fstat mkfifo)],
a0d0e21e 120
748a9306 121 sys_times_h => [qw()],
a0d0e21e 122
748a9306 123 sys_types_h => [qw()],
a0d0e21e 124
748a9306 125 sys_utsname_h => [qw(uname)],
a0d0e21e 126
748a9306 127 sys_wait_h => [qw(WEXITSTATUS WIFEXITED WIFSIGNALED WIFSTOPPED
128 WNOHANG WSTOPSIG WTERMSIG WUNTRACED)],
a0d0e21e 129
748a9306 130 termios_h => [qw( B0 B110 B1200 B134 B150 B1800 B19200 B200 B2400
a0d0e21e 131 B300 B38400 B4800 B50 B600 B75 B9600 BRKINT CLOCAL
132 CREAD CS5 CS6 CS7 CS8 CSIZE CSTOPB ECHO ECHOE ECHOK
133 ECHONL HUPCL ICANON ICRNL IEXTEN IGNBRK IGNCR IGNPAR
134 INLCR INPCK ISIG ISTRIP IXOFF IXON NCCS NOFLSH OPOST
135 PARENB PARMRK PARODD TCIFLUSH TCIOFF TCIOFLUSH TCION
136 TCOFLUSH TCOOFF TCOON TCSADRAIN TCSAFLUSH TCSANOW
137 TOSTOP VEOF VEOL VERASE VINTR VKILL VMIN VQUIT VSTART
138 VSTOP VSUSP VTIME
139 cfgetispeed cfgetospeed cfsetispeed cfsetospeed tcdrain
748a9306 140 tcflow tcflush tcgetattr tcsendbreak tcsetattr )],
a0d0e21e 141
748a9306 142 time_h => [qw(CLK_TCK CLOCKS_PER_SEC NULL asctime clock ctime
143 difftime mktime strftime tzset tzname)],
a0d0e21e 144
748a9306 145 unistd_h => [qw(F_OK NULL R_OK SEEK_CUR SEEK_END SEEK_SET
a0d0e21e 146 STRERR_FILENO STDIN_FILENO STDOUT_FILENO W_OK X_OK
147 _PC_CHOWN_RESTRICTED _PC_LINK_MAX _PC_MAX_CANON
148 _PC_MAX_INPUT _PC_NAME_MAX _PC_NO_TRUNC _PC_PATH_MAX
149 _PC_PIPE_BUF _PC_VDISABLE _POSIX_CHOWN_RESTRICTED
150 _POSIX_JOB_CONTROL _POSIX_NO_TRUNC _POSIX_SAVED_IDS
151 _POSIX_VDISABLE _POSIX_VERSION _SC_ARG_MAX
152 _SC_CHILD_MAX _SC_CLK_TCK _SC_JOB_CONTROL
153 _SC_NGROUPS_MAX _SC_OPEN_MAX _SC_SAVED_IDS
154 _SC_STREAM_MAX _SC_TZNAME_MAX _SC_VERSION
155 _exit access ctermid cuserid
156 dup2 dup execl execle execlp execv execve execvp
157 fpathconf getcwd getegid geteuid getgid getgroups
158 getpid getuid isatty lseek pathconf pause setgid setpgid
748a9306 159 setsid setuid sysconf tcgetpgrp tcsetpgrp ttyname)],
a0d0e21e 160
748a9306 161 utime_h => [qw()],
a0d0e21e 162
748a9306 163);
a0d0e21e 164
e3d0cac0 165# Exporter::export_tags();
166for (values %EXPORT_TAGS) {
167 push @EXPORT, @$_;
168}
a0d0e21e 169
170@EXPORT_OK = qw(
171 closedir opendir readdir rewinddir
172 fcntl open
173 getgrgid getgrnam
3b35bae3 174 atan2 cos exp log sin sqrt
a0d0e21e 175 getpwnam getpwuid
176 kill
177 fileno getc printf rename sprintf
178 abs exit rand srand system
179 chmod mkdir stat umask
180 times
181 wait waitpid
182 gmtime localtime time
183 alarm chdir chown close fork getlogin getppid getpgrp link
184 pipe read rmdir sleep unlink write
185 utime
2676273e 186 nice
a0d0e21e 187);
188
748a9306 189# Grandfather old foo_h form to new :foo_h form
a0d0e21e 190sub import {
191 my $this = shift;
748a9306 192 my @list = map { m/^\w+_h$/ ? ":$_" : $_ } @_;
a0d0e21e 193 local $Exporter::ExportLevel = 1;
194 Exporter::import($this,@list);
195}
196
4633a7c4 197
73c78b0a 198bootstrap POSIX $VERSION;
4633a7c4 199
200my $EINVAL = constant("EINVAL", 0);
201my $EAGAIN = constant("EAGAIN", 0);
202
a0d0e21e 203sub AUTOLOAD {
204 if ($AUTOLOAD =~ /::(_?[a-z])/) {
205 $AutoLoader::AUTOLOAD = $AUTOLOAD;
206 goto &AutoLoader::AUTOLOAD
207 }
4633a7c4 208 local $! = 0;
209 my $constname = $AUTOLOAD;
a0d0e21e 210 $constname =~ s/.*:://;
3f73d1e9 211 my $val = constant($constname, @_ ? $_[0] : 0);
4633a7c4 212 if ($! == 0) {
213 *$AUTOLOAD = sub { $val };
214 }
215 elsif ($! == $EAGAIN) { # Not really a constant, so always call.
216 *$AUTOLOAD = sub { constant($constname, $_[0]) };
217 }
218 elsif ($! == $EINVAL) {
219 croak "$constname is not a valid POSIX macro";
a0d0e21e 220 }
4633a7c4 221 else {
222 croak "Your vendor has not defined POSIX macro $constname, used";
223 }
224
a0d0e21e 225 goto &$AUTOLOAD;
226}
227
a0d0e21e 228sub usage {
c07a80fd 229 my ($mess) = @_;
a0d0e21e 230 croak "Usage: POSIX::$mess";
231}
232
233sub redef {
c07a80fd 234 my ($mess) = @_;
a0d0e21e 235 croak "Use method $mess instead";
236}
237
238sub unimpl {
c07a80fd 239 my ($mess) = @_;
a0d0e21e 240 $mess =~ s/xxx//;
241 croak "Unimplemented: POSIX::$mess";
242}
243
a0d0e21e 244############################
245package POSIX::SigAction;
246
247sub new {
28757baa 248 bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0}, $_[0];
a0d0e21e 249}
250
251############################
a0d0e21e 252package POSIX; # return to package POSIX so AutoSplit is happy
2531;
254__END__
255
256sub assert {
257 usage "assert(expr)" if @_ != 1;
258 if (!$_[0]) {
259 croak "Assertion failed";
260 }
261}
262
263sub tolower {
264 usage "tolower(string)" if @_ != 1;
265 lc($_[0]);
266}
267
268sub toupper {
269 usage "toupper(string)" if @_ != 1;
270 uc($_[0]);
271}
272
273sub closedir {
274 usage "closedir(dirhandle)" if @_ != 1;
b56ec344 275 CORE::closedir($_[0]);
a0d0e21e 276}
277
278sub opendir {
279 usage "opendir(directory)" if @_ != 1;
c07a80fd 280 my $dirhandle = gensym;
b56ec344 281 CORE::opendir($dirhandle, $_[0])
a0d0e21e 282 ? $dirhandle
4633a7c4 283 : undef;
a0d0e21e 284}
285
286sub readdir {
287 usage "readdir(dirhandle)" if @_ != 1;
b56ec344 288 CORE::readdir($_[0]);
a0d0e21e 289}
290
291sub rewinddir {
292 usage "rewinddir(dirhandle)" if @_ != 1;
b56ec344 293 CORE::rewinddir($_[0]);
a0d0e21e 294}
295
296sub errno {
297 usage "errno()" if @_ != 0;
298 $! + 0;
299}
300
301sub creat {
302 usage "creat(filename, mode)" if @_ != 2;
94b6baf5 303 &open($_[0], &O_WRONLY | &O_CREAT | &O_TRUNC, $_[1]);
a0d0e21e 304}
305
306sub fcntl {
307 usage "fcntl(filehandle, cmd, arg)" if @_ != 3;
b56ec344 308 CORE::fcntl($_[0], $_[1], $_[2]);
a0d0e21e 309}
310
311sub getgrgid {
312 usage "getgrgid(gid)" if @_ != 1;
b56ec344 313 CORE::getgrgid($_[0]);
a0d0e21e 314}
315
316sub getgrnam {
317 usage "getgrnam(name)" if @_ != 1;
b56ec344 318 CORE::getgrnam($_[0]);
a0d0e21e 319}
320
321sub atan2 {
322 usage "atan2(x,y)" if @_ != 2;
b56ec344 323 CORE::atan2($_[0], $_[1]);
a0d0e21e 324}
325
326sub cos {
327 usage "cos(x)" if @_ != 1;
b56ec344 328 CORE::cos($_[0]);
a0d0e21e 329}
330
331sub exp {
332 usage "exp(x)" if @_ != 1;
b56ec344 333 CORE::exp($_[0]);
a0d0e21e 334}
335
336sub fabs {
337 usage "fabs(x)" if @_ != 1;
b56ec344 338 CORE::abs($_[0]);
a0d0e21e 339}
340
341sub log {
342 usage "log(x)" if @_ != 1;
b56ec344 343 CORE::log($_[0]);
a0d0e21e 344}
345
346sub pow {
347 usage "pow(x,exponent)" if @_ != 2;
348 $_[0] ** $_[1];
349}
350
351sub sin {
352 usage "sin(x)" if @_ != 1;
b56ec344 353 CORE::sin($_[0]);
a0d0e21e 354}
355
356sub sqrt {
357 usage "sqrt(x)" if @_ != 1;
b56ec344 358 CORE::sqrt($_[0]);
a0d0e21e 359}
360
a0d0e21e 361sub getpwnam {
362 usage "getpwnam(name)" if @_ != 1;
b56ec344 363 CORE::getpwnam($_[0]);
a0d0e21e 364}
365
366sub getpwuid {
367 usage "getpwuid(uid)" if @_ != 1;
b56ec344 368 CORE::getpwuid($_[0]);
a0d0e21e 369}
370
371sub longjmp {
372 unimpl "longjmp() is C-specific: use die instead";
373}
374
375sub setjmp {
376 unimpl "setjmp() is C-specific: use eval {} instead";
377}
378
379sub siglongjmp {
380 unimpl "siglongjmp() is C-specific: use die instead";
381}
382
383sub sigsetjmp {
384 unimpl "sigsetjmp() is C-specific: use eval {} instead";
385}
386
387sub kill {
388 usage "kill(pid, sig)" if @_ != 2;
b56ec344 389 CORE::kill $_[1], $_[0];
a0d0e21e 390}
391
392sub raise {
393 usage "raise(sig)" if @_ != 1;
b56ec344 394 CORE::kill $_[0], $$; # Is this good enough?
a0d0e21e 395}
396
397sub offsetof {
398 unimpl "offsetof() is C-specific, stopped";
399}
400
401sub clearerr {
28757baa 402 redef "IO::Handle::clearerr()";
a0d0e21e 403}
404
405sub fclose {
28757baa 406 redef "IO::Handle::close()";
a0d0e21e 407}
408
409sub fdopen {
28757baa 410 redef "IO::Handle::new_from_fd()";
a0d0e21e 411}
412
413sub feof {
28757baa 414 redef "IO::Handle::eof()";
a0d0e21e 415}
416
417sub fgetc {
28757baa 418 redef "IO::Handle::getc()";
a0d0e21e 419}
420
421sub fgets {
28757baa 422 redef "IO::Handle::gets()";
a0d0e21e 423}
424
425sub fileno {
28757baa 426 redef "IO::Handle::fileno()";
a0d0e21e 427}
428
429sub fopen {
28757baa 430 redef "IO::File::open()";
a0d0e21e 431}
432
433sub fprintf {
434 unimpl "fprintf() is C-specific--use printf instead";
435}
436
437sub fputc {
438 unimpl "fputc() is C-specific--use print instead";
439}
440
441sub fputs {
442 unimpl "fputs() is C-specific--use print instead";
443}
444
445sub fread {
446 unimpl "fread() is C-specific--use read instead";
447}
448
449sub freopen {
450 unimpl "freopen() is C-specific--use open instead";
451}
452
453sub fscanf {
454 unimpl "fscanf() is C-specific--use <> and regular expressions instead";
455}
456
457sub fseek {
28757baa 458 redef "IO::Seekable::seek()";
a0d0e21e 459}
460
461sub ferror {
28757baa 462 redef "IO::Handle::error()";
a0d0e21e 463}
464
465sub fflush {
28757baa 466 redef "IO::Handle::flush()";
a0d0e21e 467}
468
469sub fgetpos {
28757baa 470 redef "IO::Seekable::getpos()";
a0d0e21e 471}
472
473sub fsetpos {
28757baa 474 redef "IO::Seekable::setpos()";
a0d0e21e 475}
476
477sub ftell {
28757baa 478 redef "IO::Seekable::tell()";
a0d0e21e 479}
480
481sub fwrite {
482 unimpl "fwrite() is C-specific--use print instead";
483}
484
485sub getc {
486 usage "getc(handle)" if @_ != 1;
b56ec344 487 CORE::getc($_[0]);
a0d0e21e 488}
489
490sub getchar {
491 usage "getchar()" if @_ != 0;
b56ec344 492 CORE::getc(STDIN);
a0d0e21e 493}
494
495sub gets {
496 usage "gets()" if @_ != 0;
497 scalar <STDIN>;
498}
499
500sub perror {
501 print STDERR "@_: " if @_;
502 print STDERR $!,"\n";
503}
504
505sub printf {
506 usage "printf(pattern, args...)" if @_ < 1;
b56ec344 507 CORE::printf STDOUT @_;
a0d0e21e 508}
509
510sub putc {
511 unimpl "putc() is C-specific--use print instead";
512}
513
514sub putchar {
515 unimpl "putchar() is C-specific--use print instead";
516}
517
518sub puts {
519 unimpl "puts() is C-specific--use print instead";
520}
521
522sub remove {
523 usage "remove(filename)" if @_ != 1;
b56ec344 524 CORE::unlink($_[0]);
a0d0e21e 525}
526
527sub rename {
528 usage "rename(oldfilename, newfilename)" if @_ != 2;
b56ec344 529 CORE::rename($_[0], $_[1]);
a0d0e21e 530}
531
532sub rewind {
533 usage "rewind(filehandle)" if @_ != 1;
b56ec344 534 CORE::seek($_[0],0,0);
a0d0e21e 535}
536
537sub scanf {
538 unimpl "scanf() is C-specific--use <> and regular expressions instead";
539}
540
541sub sprintf {
542 usage "sprintf(pattern,args)" if @_ == 0;
b56ec344 543 CORE::sprintf(shift,@_);
a0d0e21e 544}
545
546sub sscanf {
547 unimpl "sscanf() is C-specific--use regular expressions instead";
548}
549
550sub tmpfile {
28757baa 551 redef "IO::File::new_tmpfile()";
a0d0e21e 552}
553
554sub ungetc {
28757baa 555 redef "IO::Handle::ungetc()";
a0d0e21e 556}
557
558sub vfprintf {
559 unimpl "vfprintf() is C-specific";
560}
561
562sub vprintf {
563 unimpl "vprintf() is C-specific";
564}
565
566sub vsprintf {
567 unimpl "vsprintf() is C-specific";
568}
569
570sub abs {
571 usage "abs(x)" if @_ != 1;
b56ec344 572 CORE::abs($_[0]);
a0d0e21e 573}
574
575sub atexit {
576 unimpl "atexit() is C-specific: use END {} instead";
577}
578
579sub atof {
580 unimpl "atof() is C-specific, stopped";
581}
582
583sub atoi {
584 unimpl "atoi() is C-specific, stopped";
585}
586
587sub atol {
588 unimpl "atol() is C-specific, stopped";
589}
590
591sub bsearch {
37120919 592 unimpl "bsearch() not supplied";
a0d0e21e 593}
594
595sub calloc {
596 unimpl "calloc() is C-specific, stopped";
597}
598
599sub div {
600 unimpl "div() is C-specific, stopped";
601}
602
603sub exit {
604 usage "exit(status)" if @_ != 1;
b56ec344 605 CORE::exit($_[0]);
a0d0e21e 606}
607
608sub free {
609 unimpl "free() is C-specific, stopped";
a0d0e21e 610}
611
612sub getenv {
613 usage "getenv(name)" if @_ != 1;
614 $ENV{$_[0]};
615}
616
617sub labs {
618 unimpl "labs() is C-specific, use abs instead";
619}
620
621sub ldiv {
622 unimpl "ldiv() is C-specific, use / and int instead";
623}
624
625sub malloc {
626 unimpl "malloc() is C-specific, stopped";
627}
628
629sub qsort {
630 unimpl "qsort() is C-specific, use sort instead";
631}
632
633sub rand {
634 unimpl "rand() is non-portable, use Perl's rand instead";
635}
636
637sub realloc {
638 unimpl "realloc() is C-specific, stopped";
639}
640
641sub srand {
642 unimpl "srand()";
643}
644
a0d0e21e 645sub system {
646 usage "system(command)" if @_ != 1;
b56ec344 647 CORE::system($_[0]);
a0d0e21e 648}
649
650sub memchr {
651 unimpl "memchr() is C-specific, use index() instead";
652}
653
654sub memcmp {
655 unimpl "memcmp() is C-specific, use eq instead";
656}
657
658sub memcpy {
659 unimpl "memcpy() is C-specific, use = instead";
37120919 660}
a0d0e21e 661
662sub memmove {
663 unimpl "memmove() is C-specific, use = instead";
664}
665
666sub memset {
667 unimpl "memset() is C-specific, use x instead";
668}
669
670sub strcat {
671 unimpl "strcat() is C-specific, use .= instead";
672}
673
674sub strchr {
675 unimpl "strchr() is C-specific, use index() instead";
676}
677
678sub strcmp {
679 unimpl "strcmp() is C-specific, use eq instead";
680}
681
682sub strcpy {
683 unimpl "strcpy() is C-specific, use = instead";
684}
685
686sub strcspn {
687 unimpl "strcspn() is C-specific, use regular expressions instead";
688}
689
690sub strerror {
691 usage "strerror(errno)" if @_ != 1;
692 local $! = $_[0];
693 $! . "";
694}
695
696sub strlen {
697 unimpl "strlen() is C-specific, use length instead";
698}
699
700sub strncat {
701 unimpl "strncat() is C-specific, use .= instead";
702}
703
704sub strncmp {
705 unimpl "strncmp() is C-specific, use eq instead";
706}
707
708sub strncpy {
709 unimpl "strncpy() is C-specific, use = instead";
710}
711
712sub strpbrk {
713 unimpl "strpbrk() is C-specific, stopped";
714}
715
716sub strrchr {
717 unimpl "strrchr() is C-specific, use rindex() instead";
718}
719
720sub strspn {
721 unimpl "strspn() is C-specific, stopped";
722}
723
724sub strstr {
725 usage "strstr(big, little)" if @_ != 2;
b56ec344 726 CORE::index($_[0], $_[1]);
a0d0e21e 727}
728
729sub strtok {
730 unimpl "strtok() is C-specific, stopped";
731}
732
733sub chmod {
3b35bae3 734 usage "chmod(mode, filename)" if @_ != 2;
b56ec344 735 CORE::chmod($_[0], $_[1]);
a0d0e21e 736}
737
738sub fstat {
739 usage "fstat(fd)" if @_ != 1;
c07a80fd 740 local *TMP;
a0d0e21e 741 open(TMP, "<&$_[0]"); # Gross.
b56ec344 742 my @l = CORE::stat(TMP);
a0d0e21e 743 close(TMP);
744 @l;
745}
746
747sub mkdir {
748 usage "mkdir(directoryname, mode)" if @_ != 2;
b56ec344 749 CORE::mkdir($_[0], $_[1]);
a0d0e21e 750}
751
752sub stat {
753 usage "stat(filename)" if @_ != 1;
b56ec344 754 CORE::stat($_[0]);
a0d0e21e 755}
756
757sub umask {
758 usage "umask(mask)" if @_ != 1;
b56ec344 759 CORE::umask($_[0]);
a0d0e21e 760}
761
a0d0e21e 762sub wait {
cb1a09d0 763 usage "wait()" if @_ != 0;
b56ec344 764 CORE::wait();
a0d0e21e 765}
766
767sub waitpid {
cb1a09d0 768 usage "waitpid(pid, options)" if @_ != 2;
b56ec344 769 CORE::waitpid($_[0], $_[1]);
a0d0e21e 770}
771
772sub gmtime {
773 usage "gmtime(time)" if @_ != 1;
b56ec344 774 CORE::gmtime($_[0]);
a0d0e21e 775}
776
777sub localtime {
778 usage "localtime(time)" if @_ != 1;
b56ec344 779 CORE::localtime($_[0]);
a0d0e21e 780}
781
782sub time {
37120919 783 usage "time()" if @_ != 0;
b56ec344 784 CORE::time;
a0d0e21e 785}
786
787sub alarm {
788 usage "alarm(seconds)" if @_ != 1;
b56ec344 789 CORE::alarm($_[0]);
a0d0e21e 790}
791
792sub chdir {
793 usage "chdir(directory)" if @_ != 1;
b56ec344 794 CORE::chdir($_[0]);
a0d0e21e 795}
796
797sub chown {
798 usage "chown(filename, uid, gid)" if @_ != 3;
b56ec344 799 CORE::chown($_[0], $_[1], $_[2]);
a0d0e21e 800}
801
802sub execl {
803 unimpl "execl() is C-specific, stopped";
a0d0e21e 804}
805
806sub execle {
807 unimpl "execle() is C-specific, stopped";
a0d0e21e 808}
809
810sub execlp {
811 unimpl "execlp() is C-specific, stopped";
a0d0e21e 812}
813
814sub execv {
815 unimpl "execv() is C-specific, stopped";
a0d0e21e 816}
817
818sub execve {
819 unimpl "execve() is C-specific, stopped";
a0d0e21e 820}
821
822sub execvp {
823 unimpl "execvp() is C-specific, stopped";
a0d0e21e 824}
825
826sub fork {
827 usage "fork()" if @_ != 0;
b56ec344 828 CORE::fork;
a0d0e21e 829}
830
831sub getcwd
832{
833 usage "getcwd()" if @_ != 0;
6dead956 834 if ($^O eq 'MSWin32') {
835 # this perhaps applies to everyone else also?
836 require Cwd;
837 $cwd = &Cwd::cwd;
838 }
839 else {
840 chop($cwd = `pwd`);
841 }
a0d0e21e 842 $cwd;
843}
844
845sub getegid {
846 usage "getegid()" if @_ != 0;
847 $) + 0;
848}
849
850sub geteuid {
851 usage "geteuid()" if @_ != 0;
852 $> + 0;
853}
854
855sub getgid {
856 usage "getgid()" if @_ != 0;
857 $( + 0;
858}
859
860sub getgroups {
861 usage "getgroups()" if @_ != 0;
c07a80fd 862 my %seen;
a0d0e21e 863 grep(!$seen{$_}++, split(' ', $) ));
864}
865
866sub getlogin {
867 usage "getlogin()" if @_ != 0;
b56ec344 868 CORE::getlogin();
a0d0e21e 869}
870
871sub getpgrp {
872 usage "getpgrp()" if @_ != 0;
5507c093 873 CORE::getpgrp;
a0d0e21e 874}
875
876sub getpid {
877 usage "getpid()" if @_ != 0;
878 $$;
879}
880
881sub getppid {
882 usage "getppid()" if @_ != 0;
b56ec344 883 CORE::getppid;
a0d0e21e 884}
885
886sub getuid {
887 usage "getuid()" if @_ != 0;
888 $<;
889}
890
891sub isatty {
892 usage "isatty(filehandle)" if @_ != 1;
893 -t $_[0];
894}
895
896sub link {
897 usage "link(oldfilename, newfilename)" if @_ != 2;
b56ec344 898 CORE::link($_[0], $_[1]);
a0d0e21e 899}
900
901sub rmdir {
902 usage "rmdir(directoryname)" if @_ != 1;
b56ec344 903 CORE::rmdir($_[0]);
a0d0e21e 904}
905
a41ecaa8 906sub setbuf {
907 redef "IO::Handle::setbuf()";
908}
909
a0d0e21e 910sub setgid {
911 usage "setgid(gid)" if @_ != 1;
912 $( = $_[0];
913}
914
915sub setuid {
916 usage "setuid(uid)" if @_ != 1;
917 $< = $_[0];
918}
919
a41ecaa8 920sub setvbuf {
921 redef "IO::Handle::setvbuf()";
922}
923
a0d0e21e 924sub sleep {
925 usage "sleep(seconds)" if @_ != 1;
b56ec344 926 CORE::sleep($_[0]);
a0d0e21e 927}
928
929sub unlink {
930 usage "unlink(filename)" if @_ != 1;
b56ec344 931 CORE::unlink($_[0]);
a0d0e21e 932}
933
934sub utime {
935 usage "utime(filename, atime, mtime)" if @_ != 3;
b56ec344 936 CORE::utime($_[1], $_[2], $_[0]);
a0d0e21e 937}
938