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