Commit | Line | Data |
a0d0e21e |
1 | package POSIX; |
2 | |
17f410f9 |
3 | our(@ISA, %EXPORT_TAGS, @EXPORT_OK, $AUTOLOAD) = (); |
73c78b0a |
4 | |
3b35bae3 |
5 | use AutoLoader; |
c07a80fd |
6 | |
9426adcd |
7 | use XSLoader (); |
a0d0e21e |
8 | |
d4742b2c |
9 | our $VERSION = "1.05" ; |
c07a80fd |
10 | |
748a9306 |
11 | # Grandfather old foo_h form to new :foo_h form |
66fbe9e2 |
12 | my $loaded; |
13 | |
a0d0e21e |
14 | sub import { |
66fbe9e2 |
15 | load_imports() unless $loaded++; |
a0d0e21e |
16 | my $this = shift; |
748a9306 |
17 | my @list = map { m/^\w+_h$/ ? ":$_" : $_ } @_; |
a0d0e21e |
18 | local $Exporter::ExportLevel = 1; |
19 | Exporter::import($this,@list); |
20 | } |
21 | |
66fbe9e2 |
22 | sub croak { require Carp; goto &Carp::croak } |
4633a7c4 |
23 | |
9426adcd |
24 | XSLoader::load 'POSIX', $VERSION; |
4633a7c4 |
25 | |
a290f238 |
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)); |
4633a7c4 |
29 | |
a0d0e21e |
30 | sub AUTOLOAD { |
31 | if ($AUTOLOAD =~ /::(_?[a-z])/) { |
66fbe9e2 |
32 | # require AutoLoader; |
a0d0e21e |
33 | $AutoLoader::AUTOLOAD = $AUTOLOAD; |
34 | goto &AutoLoader::AUTOLOAD |
35 | } |
4633a7c4 |
36 | local $! = 0; |
37 | my $constname = $AUTOLOAD; |
a0d0e21e |
38 | $constname =~ s/.*:://; |
a290f238 |
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; |
4633a7c4 |
46 | *$AUTOLOAD = sub { $val }; |
47 | } |
4633a7c4 |
48 | |
a0d0e21e |
49 | goto &$AUTOLOAD; |
50 | } |
51 | |
d4742b2c |
52 | sub POSIX::SigAction::new { |
53 | bless {HANDLER => $_[1], MASK => $_[2], FLAGS => $_[3] || 0}, $_[0]; |
54 | } |
55 | |
56 | 1; |
57 | __END__ |
58 | |
a0d0e21e |
59 | sub usage { |
c07a80fd |
60 | my ($mess) = @_; |
a0d0e21e |
61 | croak "Usage: POSIX::$mess"; |
62 | } |
63 | |
64 | sub redef { |
c07a80fd |
65 | my ($mess) = @_; |
a0d0e21e |
66 | croak "Use method $mess instead"; |
67 | } |
68 | |
69 | sub unimpl { |
c07a80fd |
70 | my ($mess) = @_; |
a0d0e21e |
71 | $mess =~ s/xxx//; |
72 | croak "Unimplemented: POSIX::$mess"; |
73 | } |
74 | |
a0d0e21e |
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; |
b56ec344 |
94 | CORE::closedir($_[0]); |
a0d0e21e |
95 | } |
96 | |
97 | sub opendir { |
98 | usage "opendir(directory)" if @_ != 1; |
66fbe9e2 |
99 | my $dirhandle; |
b56ec344 |
100 | CORE::opendir($dirhandle, $_[0]) |
a0d0e21e |
101 | ? $dirhandle |
4633a7c4 |
102 | : undef; |
a0d0e21e |
103 | } |
104 | |
105 | sub readdir { |
106 | usage "readdir(dirhandle)" if @_ != 1; |
b56ec344 |
107 | CORE::readdir($_[0]); |
a0d0e21e |
108 | } |
109 | |
110 | sub rewinddir { |
111 | usage "rewinddir(dirhandle)" if @_ != 1; |
b56ec344 |
112 | CORE::rewinddir($_[0]); |
a0d0e21e |
113 | } |
114 | |
115 | sub errno { |
116 | usage "errno()" if @_ != 0; |
117 | $! + 0; |
118 | } |
119 | |
120 | sub creat { |
121 | usage "creat(filename, mode)" if @_ != 2; |
94b6baf5 |
122 | &open($_[0], &O_WRONLY | &O_CREAT | &O_TRUNC, $_[1]); |
a0d0e21e |
123 | } |
124 | |
125 | sub fcntl { |
126 | usage "fcntl(filehandle, cmd, arg)" if @_ != 3; |
b56ec344 |
127 | CORE::fcntl($_[0], $_[1], $_[2]); |
a0d0e21e |
128 | } |
129 | |
130 | sub getgrgid { |
131 | usage "getgrgid(gid)" if @_ != 1; |
b56ec344 |
132 | CORE::getgrgid($_[0]); |
a0d0e21e |
133 | } |
134 | |
135 | sub getgrnam { |
136 | usage "getgrnam(name)" if @_ != 1; |
b56ec344 |
137 | CORE::getgrnam($_[0]); |
a0d0e21e |
138 | } |
139 | |
140 | sub atan2 { |
141 | usage "atan2(x,y)" if @_ != 2; |
b56ec344 |
142 | CORE::atan2($_[0], $_[1]); |
a0d0e21e |
143 | } |
144 | |
145 | sub cos { |
146 | usage "cos(x)" if @_ != 1; |
b56ec344 |
147 | CORE::cos($_[0]); |
a0d0e21e |
148 | } |
149 | |
150 | sub exp { |
151 | usage "exp(x)" if @_ != 1; |
b56ec344 |
152 | CORE::exp($_[0]); |
a0d0e21e |
153 | } |
154 | |
155 | sub fabs { |
156 | usage "fabs(x)" if @_ != 1; |
b56ec344 |
157 | CORE::abs($_[0]); |
a0d0e21e |
158 | } |
159 | |
160 | sub log { |
161 | usage "log(x)" if @_ != 1; |
b56ec344 |
162 | CORE::log($_[0]); |
a0d0e21e |
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; |
b56ec344 |
172 | CORE::sin($_[0]); |
a0d0e21e |
173 | } |
174 | |
175 | sub sqrt { |
176 | usage "sqrt(x)" if @_ != 1; |
b56ec344 |
177 | CORE::sqrt($_[0]); |
a0d0e21e |
178 | } |
179 | |
a0d0e21e |
180 | sub getpwnam { |
181 | usage "getpwnam(name)" if @_ != 1; |
b56ec344 |
182 | CORE::getpwnam($_[0]); |
a0d0e21e |
183 | } |
184 | |
185 | sub getpwuid { |
186 | usage "getpwuid(uid)" if @_ != 1; |
b56ec344 |
187 | CORE::getpwuid($_[0]); |
a0d0e21e |
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; |
b56ec344 |
208 | CORE::kill $_[1], $_[0]; |
a0d0e21e |
209 | } |
210 | |
211 | sub raise { |
212 | usage "raise(sig)" if @_ != 1; |
b56ec344 |
213 | CORE::kill $_[0], $$; # Is this good enough? |
a0d0e21e |
214 | } |
215 | |
216 | sub offsetof { |
217 | unimpl "offsetof() is C-specific, stopped"; |
218 | } |
219 | |
220 | sub clearerr { |
28757baa |
221 | redef "IO::Handle::clearerr()"; |
a0d0e21e |
222 | } |
223 | |
224 | sub fclose { |
28757baa |
225 | redef "IO::Handle::close()"; |
a0d0e21e |
226 | } |
227 | |
228 | sub fdopen { |
28757baa |
229 | redef "IO::Handle::new_from_fd()"; |
a0d0e21e |
230 | } |
231 | |
232 | sub feof { |
28757baa |
233 | redef "IO::Handle::eof()"; |
a0d0e21e |
234 | } |
235 | |
236 | sub fgetc { |
28757baa |
237 | redef "IO::Handle::getc()"; |
a0d0e21e |
238 | } |
239 | |
240 | sub fgets { |
28757baa |
241 | redef "IO::Handle::gets()"; |
a0d0e21e |
242 | } |
243 | |
244 | sub fileno { |
28757baa |
245 | redef "IO::Handle::fileno()"; |
a0d0e21e |
246 | } |
247 | |
248 | sub fopen { |
28757baa |
249 | redef "IO::File::open()"; |
a0d0e21e |
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 { |
28757baa |
277 | redef "IO::Seekable::seek()"; |
a0d0e21e |
278 | } |
279 | |
280 | sub ferror { |
28757baa |
281 | redef "IO::Handle::error()"; |
a0d0e21e |
282 | } |
283 | |
284 | sub fflush { |
28757baa |
285 | redef "IO::Handle::flush()"; |
a0d0e21e |
286 | } |
287 | |
288 | sub fgetpos { |
28757baa |
289 | redef "IO::Seekable::getpos()"; |
a0d0e21e |
290 | } |
291 | |
292 | sub fsetpos { |
28757baa |
293 | redef "IO::Seekable::setpos()"; |
a0d0e21e |
294 | } |
295 | |
296 | sub ftell { |
28757baa |
297 | redef "IO::Seekable::tell()"; |
a0d0e21e |
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; |
b56ec344 |
306 | CORE::getc($_[0]); |
a0d0e21e |
307 | } |
308 | |
309 | sub getchar { |
310 | usage "getchar()" if @_ != 0; |
b56ec344 |
311 | CORE::getc(STDIN); |
a0d0e21e |
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; |
b56ec344 |
326 | CORE::printf STDOUT @_; |
a0d0e21e |
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; |
b56ec344 |
343 | CORE::unlink($_[0]); |
a0d0e21e |
344 | } |
345 | |
346 | sub rename { |
347 | usage "rename(oldfilename, newfilename)" if @_ != 2; |
b56ec344 |
348 | CORE::rename($_[0], $_[1]); |
a0d0e21e |
349 | } |
350 | |
351 | sub rewind { |
352 | usage "rewind(filehandle)" if @_ != 1; |
b56ec344 |
353 | CORE::seek($_[0],0,0); |
a0d0e21e |
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; |
b56ec344 |
362 | CORE::sprintf(shift,@_); |
a0d0e21e |
363 | } |
364 | |
365 | sub sscanf { |
366 | unimpl "sscanf() is C-specific--use regular expressions instead"; |
367 | } |
368 | |
369 | sub tmpfile { |
28757baa |
370 | redef "IO::File::new_tmpfile()"; |
a0d0e21e |
371 | } |
372 | |
373 | sub ungetc { |
28757baa |
374 | redef "IO::Handle::ungetc()"; |
a0d0e21e |
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; |
b56ec344 |
391 | CORE::abs($_[0]); |
a0d0e21e |
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 { |
37120919 |
411 | unimpl "bsearch() not supplied"; |
a0d0e21e |
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; |
b56ec344 |
424 | CORE::exit($_[0]); |
a0d0e21e |
425 | } |
426 | |
427 | sub free { |
428 | unimpl "free() is C-specific, stopped"; |
a0d0e21e |
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 | |
a0d0e21e |
464 | sub system { |
465 | usage "system(command)" if @_ != 1; |
b56ec344 |
466 | CORE::system($_[0]); |
a0d0e21e |
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"; |
37120919 |
479 | } |
a0d0e21e |
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; |
b56ec344 |
545 | CORE::index($_[0], $_[1]); |
a0d0e21e |
546 | } |
547 | |
548 | sub strtok { |
549 | unimpl "strtok() is C-specific, stopped"; |
550 | } |
551 | |
552 | sub chmod { |
3b35bae3 |
553 | usage "chmod(mode, filename)" if @_ != 2; |
b56ec344 |
554 | CORE::chmod($_[0], $_[1]); |
a0d0e21e |
555 | } |
556 | |
557 | sub fstat { |
558 | usage "fstat(fd)" if @_ != 1; |
c07a80fd |
559 | local *TMP; |
29778b0a |
560 | CORE::open(TMP, "<&$_[0]"); # Gross. |
b56ec344 |
561 | my @l = CORE::stat(TMP); |
29778b0a |
562 | CORE::close(TMP); |
a0d0e21e |
563 | @l; |
564 | } |
565 | |
566 | sub mkdir { |
567 | usage "mkdir(directoryname, mode)" if @_ != 2; |
b56ec344 |
568 | CORE::mkdir($_[0], $_[1]); |
a0d0e21e |
569 | } |
570 | |
571 | sub stat { |
572 | usage "stat(filename)" if @_ != 1; |
b56ec344 |
573 | CORE::stat($_[0]); |
a0d0e21e |
574 | } |
575 | |
576 | sub umask { |
577 | usage "umask(mask)" if @_ != 1; |
b56ec344 |
578 | CORE::umask($_[0]); |
a0d0e21e |
579 | } |
580 | |
a0d0e21e |
581 | sub wait { |
cb1a09d0 |
582 | usage "wait()" if @_ != 0; |
b56ec344 |
583 | CORE::wait(); |
a0d0e21e |
584 | } |
585 | |
586 | sub waitpid { |
cb1a09d0 |
587 | usage "waitpid(pid, options)" if @_ != 2; |
b56ec344 |
588 | CORE::waitpid($_[0], $_[1]); |
a0d0e21e |
589 | } |
590 | |
591 | sub gmtime { |
592 | usage "gmtime(time)" if @_ != 1; |
b56ec344 |
593 | CORE::gmtime($_[0]); |
a0d0e21e |
594 | } |
595 | |
596 | sub localtime { |
597 | usage "localtime(time)" if @_ != 1; |
b56ec344 |
598 | CORE::localtime($_[0]); |
a0d0e21e |
599 | } |
600 | |
601 | sub time { |
37120919 |
602 | usage "time()" if @_ != 0; |
b56ec344 |
603 | CORE::time; |
a0d0e21e |
604 | } |
605 | |
606 | sub alarm { |
607 | usage "alarm(seconds)" if @_ != 1; |
b56ec344 |
608 | CORE::alarm($_[0]); |
a0d0e21e |
609 | } |
610 | |
611 | sub chdir { |
612 | usage "chdir(directory)" if @_ != 1; |
b56ec344 |
613 | CORE::chdir($_[0]); |
a0d0e21e |
614 | } |
615 | |
616 | sub chown { |
617 | usage "chown(filename, uid, gid)" if @_ != 3; |
b56ec344 |
618 | CORE::chown($_[0], $_[1], $_[2]); |
a0d0e21e |
619 | } |
620 | |
621 | sub execl { |
622 | unimpl "execl() is C-specific, stopped"; |
a0d0e21e |
623 | } |
624 | |
625 | sub execle { |
626 | unimpl "execle() is C-specific, stopped"; |
a0d0e21e |
627 | } |
628 | |
629 | sub execlp { |
630 | unimpl "execlp() is C-specific, stopped"; |
a0d0e21e |
631 | } |
632 | |
633 | sub execv { |
634 | unimpl "execv() is C-specific, stopped"; |
a0d0e21e |
635 | } |
636 | |
637 | sub execve { |
638 | unimpl "execve() is C-specific, stopped"; |
a0d0e21e |
639 | } |
640 | |
641 | sub execvp { |
642 | unimpl "execvp() is C-specific, stopped"; |
a0d0e21e |
643 | } |
644 | |
645 | sub fork { |
646 | usage "fork()" if @_ != 0; |
b56ec344 |
647 | CORE::fork; |
a0d0e21e |
648 | } |
649 | |
a0d0e21e |
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; |
c07a80fd |
667 | my %seen; |
a0d0e21e |
668 | grep(!$seen{$_}++, split(' ', $) )); |
669 | } |
670 | |
671 | sub getlogin { |
672 | usage "getlogin()" if @_ != 0; |
b56ec344 |
673 | CORE::getlogin(); |
a0d0e21e |
674 | } |
675 | |
676 | sub getpgrp { |
677 | usage "getpgrp()" if @_ != 0; |
5507c093 |
678 | CORE::getpgrp; |
a0d0e21e |
679 | } |
680 | |
681 | sub getpid { |
682 | usage "getpid()" if @_ != 0; |
683 | $$; |
684 | } |
685 | |
686 | sub getppid { |
687 | usage "getppid()" if @_ != 0; |
b56ec344 |
688 | CORE::getppid; |
a0d0e21e |
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; |
b56ec344 |
703 | CORE::link($_[0], $_[1]); |
a0d0e21e |
704 | } |
705 | |
706 | sub rmdir { |
707 | usage "rmdir(directoryname)" if @_ != 1; |
b56ec344 |
708 | CORE::rmdir($_[0]); |
a0d0e21e |
709 | } |
710 | |
a41ecaa8 |
711 | sub setbuf { |
712 | redef "IO::Handle::setbuf()"; |
713 | } |
714 | |
a41ecaa8 |
715 | sub setvbuf { |
716 | redef "IO::Handle::setvbuf()"; |
717 | } |
718 | |
a0d0e21e |
719 | sub sleep { |
720 | usage "sleep(seconds)" if @_ != 1; |
b56ec344 |
721 | CORE::sleep($_[0]); |
a0d0e21e |
722 | } |
723 | |
724 | sub unlink { |
725 | usage "unlink(filename)" if @_ != 1; |
b56ec344 |
726 | CORE::unlink($_[0]); |
a0d0e21e |
727 | } |
728 | |
729 | sub utime { |
730 | usage "utime(filename, atime, mtime)" if @_ != 3; |
b56ec344 |
731 | CORE::utime($_[1], $_[2], $_[0]); |
a0d0e21e |
732 | } |
733 | |
66fbe9e2 |
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 | |
d4742b2c |
742 | dirent_h => [], |
66fbe9e2 |
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 | |
d4742b2c |
779 | grp_h => [], |
66fbe9e2 |
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 | |
83f427f7 |
792 | locale_h => [qw(LC_ALL LC_COLLATE LC_CTYPE LC_MESSAGES |
793 | LC_MONETARY LC_NUMERIC LC_TIME NULL |
794 | localeconv setlocale)], |
66fbe9e2 |
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 | |
d4742b2c |
799 | pwd_h => [], |
66fbe9e2 |
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 | |
d4742b2c |
811 | stdarg_h => [], |
66fbe9e2 |
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 | |
d4742b2c |
840 | sys_times_h => [], |
66fbe9e2 |
841 | |
d4742b2c |
842 | sys_types_h => [], |
66fbe9e2 |
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 |
b250498f |
865 | STDERR_FILENO STDIN_FILENO STDOUT_FILENO W_OK X_OK |
66fbe9e2 |
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 | |
d4742b2c |
880 | utime_h => [], |
66fbe9e2 |
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 | } |