This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
perl 5.000
[perl5.git] / ext / POSIX / POSIX.xs
CommitLineData
463ee0b2
LW
1#include "EXTERN.h"
2#include "perl.h"
3#include "XSUB.h"
2304df62 4#include <ctype.h>
a0d0e21e 5#ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
2304df62 6#include <dirent.h>
a0d0e21e 7#endif
2304df62
AD
8#include <errno.h>
9#include <fcntl.h>
10#ifdef I_FLOAT
11#include <float.h>
12#endif
13#include <grp.h>
a0d0e21e 14#ifdef I_LIMITS
2304df62 15#include <limits.h>
a0d0e21e 16#endif
2304df62
AD
17#include <locale.h>
18#include <math.h>
85e6fe83 19#ifdef I_PWD
2304df62 20#include <pwd.h>
85e6fe83 21#endif
2304df62
AD
22#include <setjmp.h>
23#include <signal.h>
24#ifdef I_STDARG
25#include <stdarg.h>
26#endif
27#ifdef I_STDDEF
28#include <stddef.h>
29#endif
a0d0e21e
LW
30/* XXX This comment is just to make I_TERMIO and I_SGTTY visible to
31 metaconfig for future extension writers. We don't use them in POSIX.
32 (This is really sneaky :-) --AD
33*/
34#if defined(I_TERMIOS)
35#include <termios.h>
36#endif
2304df62 37#include <stdio.h>
a0d0e21e 38#ifdef I_STDLIB
2304df62 39#include <stdlib.h>
a0d0e21e 40#endif
2304df62
AD
41#include <string.h>
42#include <sys/stat.h>
43#include <sys/times.h>
44#include <sys/types.h>
a0d0e21e 45#ifdef HAS_UNAME
8990e307 46#include <sys/utsname.h>
2304df62 47#endif
a0d0e21e 48#include <sys/wait.h>
2304df62
AD
49#include <time.h>
50#include <unistd.h>
a0d0e21e 51#ifdef I_UTIME
2304df62 52#include <utime.h>
a0d0e21e 53#endif
2304df62 54
a0d0e21e
LW
55typedef FILE * InputStream;
56typedef FILE * OutputStream;
2304df62 57typedef int SysRet;
a0d0e21e 58typedef long SysRetLong;
2304df62
AD
59typedef sigset_t* POSIX__SigSet;
60typedef HV* POSIX__SigAction;
a0d0e21e
LW
61#ifdef I_TERMIOS
62typedef struct termios* POSIX__Termios;
63#else /* Define termios types to int, and call not_here for the functions.*/
64#define POSIX__Termios int
65#define speed_t int
66#define tcflag_t int
67#define cc_t int
68#define cfgetispeed(x) not_here("cfgetispeed")
69#define cfgetospeed(x) not_here("cfgetospeed")
70#define tcdrain(x) not_here("tcdrain")
71#define tcflush(x,y) not_here("tcflush")
72#define tcsendbreak(x,y) not_here("tcsendbreak")
73#define cfsetispeed(x,y) not_here("cfsetispeed")
74#define cfsetospeed(x,y) not_here("cfsetospeed")
75#define ctermid(x) (char *) not_here("ctermid")
76#define tcflow(x,y) not_here("tcflow")
77#define tcgetattr(x,y) not_here("tcgetattr")
78#define tcsetattr(x,y,z) not_here("tcsetattr")
79#endif
80
81/* Possibly needed prototypes */
82char *cuserid _((char *));
83
84#ifndef HAS_CUSERID
85#define cuserid(a) (char *) not_here("cuserid")
86#endif
87#ifndef HAS_DIFFTIME
88#ifndef difftime
89#define difftime(a,b) not_here("difftime")
90#endif
91#endif
92#ifndef HAS_FPATHCONF
93#define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
94#endif
95#ifndef HAS_MKTIME
96#define mktime(a) not_here("mktime")
8990e307
LW
97#endif
98#ifndef HAS_NICE
99#define nice(a) not_here("nice")
100#endif
a0d0e21e
LW
101#ifndef HAS_PATHCONF
102#define pathconf(f,n) (SysRetLong) not_here("pathconf")
103#endif
104#ifndef HAS_SYSCONF
105#define sysconf(n) (SysRetLong) not_here("sysconf")
106#endif
8990e307
LW
107#ifndef HAS_READLINK
108#define readlink(a,b,c) not_here("readlink")
109#endif
110#ifndef HAS_SETPGID
111#define setpgid(a,b) not_here("setpgid")
112#endif
8990e307
LW
113#ifndef HAS_SETSID
114#define setsid() not_here("setsid")
115#endif
a0d0e21e
LW
116#ifndef HAS_STRCOLL
117#define strcoll(s1,s2) not_here("strcoll")
118#endif
119#ifndef HAS_STRXFRM
120#define strxfrm(s1,s2,n) not_here("strxfrm")
8990e307
LW
121#endif
122#ifndef HAS_TCGETPGRP
123#define tcgetpgrp(a) not_here("tcgetpgrp")
124#endif
125#ifndef HAS_TCSETPGRP
126#define tcsetpgrp(a,b) not_here("tcsetpgrp")
127#endif
128#ifndef HAS_TIMES
129#define times(a) not_here("times")
130#endif
131#ifndef HAS_UNAME
132#define uname(a) not_here("uname")
133#endif
134#ifndef HAS_WAITPID
135#define waitpid(a,b,c) not_here("waitpid")
136#endif
137
a0d0e21e
LW
138#ifndef HAS_FGETPOS
139#define fgetpos(a,b) not_here("fgetpos")
140#endif
141#ifndef HAS_FSETPOS
142#define fsetpos(a,b) not_here("fsetpos")
143#endif
144
145#ifndef HAS_MBLEN
146#ifndef mblen
147#define mblen(a,b) not_here("mblen")
148#endif
149#endif
150#ifndef HAS_MBSTOWCS
151#define mbstowcs(s, pwcs, n) not_here("mbstowcs")
152#endif
153#ifndef HAS_MBTOWC
154#define mbtowc(pwc, s, n) not_here("mbtowc")
155#endif
156#ifndef HAS_WCSTOMBS
157#define wcstombs(s, pwcs, n) not_here("wcstombs")
158#endif
159#ifndef HAS_WCTOMB
160#define wctomb(s, wchar) not_here("wcstombs")
161#endif
162#if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
163/* If we don't have these functions, then we wouldn't have gotten a typedef
164 for wchar_t, the wide character type. Defining wchar_t allows the
165 functions referencing it to compile. Its actual type is then meaningless,
166 since without the above functions, all sections using it end up calling
167 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
168#ifndef wchar_t
169#define wchar_t char
170#endif
171#endif
172
173#ifndef HAS_LOCALECONV
174#define localeconv() not_here("localeconv")
175#endif
176
177#ifdef HAS_TZNAME
178extern char *tzname[];
179#else
180char *tzname[] = { "" , "" };
181#endif
182
183#ifndef HAS_LONG_DOUBLE /* XXX What to do about long doubles? */
184#ifdef LDBL_MAX
185#undef LDBL_MAX
186#endif
187#ifdef LDBL_MIN
188#undef LDBL_MIN
189#endif
190#ifdef LDBL_EPSILON
191#undef LDBL_EPSILON
192#endif
193#endif
194
8990e307
LW
195static int
196not_here(s)
197char *s;
198{
199 croak("POSIX::%s not implemented on this architecture", s);
200 return -1;
201}
463ee0b2 202
a0d0e21e
LW
203static double
204constant(name, arg)
2304df62
AD
205char *name;
206int arg;
207{
208 errno = 0;
209 switch (*name) {
210 case 'A':
211 if (strEQ(name, "ARG_MAX"))
212#ifdef ARG_MAX
213 return ARG_MAX;
214#else
215 goto not_there;
216#endif
217 break;
218 case 'B':
219 if (strEQ(name, "BUFSIZ"))
220#ifdef BUFSIZ
221 return BUFSIZ;
222#else
223 goto not_there;
224#endif
225 if (strEQ(name, "BRKINT"))
226#ifdef BRKINT
227 return BRKINT;
228#else
229 goto not_there;
230#endif
231 if (strEQ(name, "B9600"))
232#ifdef B9600
233 return B9600;
234#else
235 goto not_there;
236#endif
237 if (strEQ(name, "B19200"))
238#ifdef B19200
239 return B19200;
240#else
241 goto not_there;
242#endif
243 if (strEQ(name, "B38400"))
244#ifdef B38400
245 return B38400;
246#else
247 goto not_there;
248#endif
249 if (strEQ(name, "B0"))
250#ifdef B0
251 return B0;
252#else
253 goto not_there;
254#endif
255 if (strEQ(name, "B110"))
256#ifdef B110
257 return B110;
258#else
259 goto not_there;
260#endif
261 if (strEQ(name, "B1200"))
262#ifdef B1200
263 return B1200;
264#else
265 goto not_there;
266#endif
267 if (strEQ(name, "B134"))
268#ifdef B134
269 return B134;
270#else
271 goto not_there;
272#endif
273 if (strEQ(name, "B150"))
274#ifdef B150
275 return B150;
276#else
277 goto not_there;
278#endif
279 if (strEQ(name, "B1800"))
280#ifdef B1800
281 return B1800;
282#else
283 goto not_there;
284#endif
285 if (strEQ(name, "B200"))
286#ifdef B200
287 return B200;
288#else
289 goto not_there;
290#endif
291 if (strEQ(name, "B2400"))
292#ifdef B2400
293 return B2400;
294#else
295 goto not_there;
296#endif
297 if (strEQ(name, "B300"))
298#ifdef B300
299 return B300;
300#else
301 goto not_there;
302#endif
303 if (strEQ(name, "B4800"))
304#ifdef B4800
305 return B4800;
306#else
307 goto not_there;
308#endif
309 if (strEQ(name, "B50"))
310#ifdef B50
311 return B50;
312#else
313 goto not_there;
314#endif
315 if (strEQ(name, "B600"))
316#ifdef B600
317 return B600;
318#else
319 goto not_there;
320#endif
321 if (strEQ(name, "B75"))
322#ifdef B75
323 return B75;
324#else
325 goto not_there;
326#endif
327 break;
328 case 'C':
329 if (strEQ(name, "CHAR_BIT"))
330#ifdef CHAR_BIT
331 return CHAR_BIT;
332#else
333 goto not_there;
334#endif
335 if (strEQ(name, "CHAR_MAX"))
336#ifdef CHAR_MAX
337 return CHAR_MAX;
338#else
339 goto not_there;
340#endif
341 if (strEQ(name, "CHAR_MIN"))
342#ifdef CHAR_MIN
343 return CHAR_MIN;
344#else
345 goto not_there;
346#endif
347 if (strEQ(name, "CHILD_MAX"))
348#ifdef CHILD_MAX
349 return CHILD_MAX;
350#else
351 goto not_there;
352#endif
353 if (strEQ(name, "CLK_TCK"))
354#ifdef CLK_TCK
355 return CLK_TCK;
356#else
357 goto not_there;
358#endif
359 if (strEQ(name, "CLOCAL"))
360#ifdef CLOCAL
361 return CLOCAL;
362#else
363 goto not_there;
364#endif
365 if (strEQ(name, "CLOCKS_PER_SEC"))
366#ifdef CLOCKS_PER_SEC
367 return CLOCKS_PER_SEC;
368#else
369 goto not_there;
370#endif
371 if (strEQ(name, "CREAD"))
372#ifdef CREAD
373 return CREAD;
374#else
375 goto not_there;
376#endif
377 if (strEQ(name, "CS5"))
378#ifdef CS5
379 return CS5;
380#else
381 goto not_there;
382#endif
383 if (strEQ(name, "CS6"))
384#ifdef CS6
385 return CS6;
386#else
387 goto not_there;
388#endif
389 if (strEQ(name, "CS7"))
390#ifdef CS7
391 return CS7;
392#else
393 goto not_there;
394#endif
395 if (strEQ(name, "CS8"))
396#ifdef CS8
397 return CS8;
398#else
399 goto not_there;
400#endif
401 if (strEQ(name, "CSIZE"))
402#ifdef CSIZE
403 return CSIZE;
404#else
405 goto not_there;
406#endif
407 if (strEQ(name, "CSTOPB"))
408#ifdef CSTOPB
409 return CSTOPB;
410#else
411 goto not_there;
412#endif
413 break;
414 case 'D':
415 if (strEQ(name, "DBL_MAX"))
416#ifdef DBL_MAX
417 return DBL_MAX;
418#else
419 goto not_there;
420#endif
421 if (strEQ(name, "DBL_MIN"))
422#ifdef DBL_MIN
423 return DBL_MIN;
424#else
425 goto not_there;
426#endif
427 if (strEQ(name, "DBL_DIG"))
428#ifdef DBL_DIG
429 return DBL_DIG;
430#else
431 goto not_there;
432#endif
433 if (strEQ(name, "DBL_EPSILON"))
434#ifdef DBL_EPSILON
435 return DBL_EPSILON;
436#else
437 goto not_there;
438#endif
439 if (strEQ(name, "DBL_MANT_DIG"))
440#ifdef DBL_MANT_DIG
441 return DBL_MANT_DIG;
442#else
443 goto not_there;
444#endif
445 if (strEQ(name, "DBL_MAX_10_EXP"))
446#ifdef DBL_MAX_10_EXP
447 return DBL_MAX_10_EXP;
448#else
449 goto not_there;
450#endif
451 if (strEQ(name, "DBL_MAX_EXP"))
452#ifdef DBL_MAX_EXP
453 return DBL_MAX_EXP;
454#else
455 goto not_there;
456#endif
457 if (strEQ(name, "DBL_MIN_10_EXP"))
458#ifdef DBL_MIN_10_EXP
459 return DBL_MIN_10_EXP;
460#else
461 goto not_there;
462#endif
463 if (strEQ(name, "DBL_MIN_EXP"))
464#ifdef DBL_MIN_EXP
465 return DBL_MIN_EXP;
466#else
467 goto not_there;
468#endif
469 break;
470 case 'E':
471 switch (name[1]) {
472 case 'A':
473 if (strEQ(name, "EACCES"))
474#ifdef EACCES
475 return EACCES;
476#else
477 goto not_there;
478#endif
479 if (strEQ(name, "EAGAIN"))
480#ifdef EAGAIN
481 return EAGAIN;
482#else
483 goto not_there;
484#endif
485 break;
486 case 'B':
487 if (strEQ(name, "EBADF"))
488#ifdef EBADF
489 return EBADF;
490#else
491 goto not_there;
492#endif
493 if (strEQ(name, "EBUSY"))
494#ifdef EBUSY
495 return EBUSY;
496#else
497 goto not_there;
498#endif
499 break;
500 case 'C':
501 if (strEQ(name, "ECHILD"))
502#ifdef ECHILD
503 return ECHILD;
504#else
505 goto not_there;
506#endif
507 if (strEQ(name, "ECHO"))
508#ifdef ECHO
509 return ECHO;
510#else
511 goto not_there;
512#endif
513 if (strEQ(name, "ECHOE"))
514#ifdef ECHOE
515 return ECHOE;
516#else
517 goto not_there;
518#endif
519 if (strEQ(name, "ECHOK"))
520#ifdef ECHOK
521 return ECHOK;
522#else
523 goto not_there;
524#endif
525 if (strEQ(name, "ECHONL"))
526#ifdef ECHONL
527 return ECHONL;
528#else
529 goto not_there;
530#endif
531 break;
532 case 'D':
533 if (strEQ(name, "EDEADLK"))
534#ifdef EDEADLK
535 return EDEADLK;
536#else
537 goto not_there;
538#endif
539 if (strEQ(name, "EDOM"))
540#ifdef EDOM
541 return EDOM;
542#else
543 goto not_there;
544#endif
545 break;
546 case 'E':
547 if (strEQ(name, "EEXIST"))
548#ifdef EEXIST
549 return EEXIST;
550#else
551 goto not_there;
552#endif
553 break;
554 case 'F':
555 if (strEQ(name, "EFAULT"))
556#ifdef EFAULT
557 return EFAULT;
558#else
559 goto not_there;
560#endif
561 if (strEQ(name, "EFBIG"))
562#ifdef EFBIG
563 return EFBIG;
564#else
565 goto not_there;
566#endif
567 break;
568 case 'I':
569 if (strEQ(name, "EINTR"))
570#ifdef EINTR
571 return EINTR;
572#else
573 goto not_there;
574#endif
575 if (strEQ(name, "EINVAL"))
576#ifdef EINVAL
577 return EINVAL;
578#else
579 goto not_there;
580#endif
581 if (strEQ(name, "EIO"))
582#ifdef EIO
583 return EIO;
584#else
585 goto not_there;
586#endif
587 if (strEQ(name, "EISDIR"))
588#ifdef EISDIR
589 return EISDIR;
590#else
591 goto not_there;
592#endif
593 break;
594 case 'M':
595 if (strEQ(name, "EMFILE"))
596#ifdef EMFILE
597 return EMFILE;
598#else
599 goto not_there;
600#endif
601 if (strEQ(name, "EMLINK"))
602#ifdef EMLINK
603 return EMLINK;
604#else
605 goto not_there;
606#endif
607 break;
608 case 'N':
609 if (strEQ(name, "ENOMEM"))
610#ifdef ENOMEM
611 return ENOMEM;
612#else
613 goto not_there;
614#endif
615 if (strEQ(name, "ENOSPC"))
616#ifdef ENOSPC
617 return ENOSPC;
618#else
619 goto not_there;
620#endif
621 if (strEQ(name, "ENOEXEC"))
622#ifdef ENOEXEC
623 return ENOEXEC;
624#else
625 goto not_there;
626#endif
627 if (strEQ(name, "ENOTTY"))
628#ifdef ENOTTY
629 return ENOTTY;
630#else
631 goto not_there;
632#endif
633 if (strEQ(name, "ENOTDIR"))
634#ifdef ENOTDIR
635 return ENOTDIR;
636#else
637 goto not_there;
638#endif
639 if (strEQ(name, "ENOTEMPTY"))
640#ifdef ENOTEMPTY
641 return ENOTEMPTY;
642#else
643 goto not_there;
644#endif
645 if (strEQ(name, "ENFILE"))
646#ifdef ENFILE
647 return ENFILE;
648#else
649 goto not_there;
650#endif
651 if (strEQ(name, "ENODEV"))
652#ifdef ENODEV
653 return ENODEV;
654#else
655 goto not_there;
656#endif
657 if (strEQ(name, "ENOENT"))
658#ifdef ENOENT
659 return ENOENT;
660#else
661 goto not_there;
662#endif
663 if (strEQ(name, "ENOLCK"))
664#ifdef ENOLCK
665 return ENOLCK;
666#else
667 goto not_there;
668#endif
669 if (strEQ(name, "ENOSYS"))
670#ifdef ENOSYS
671 return ENOSYS;
672#else
673 goto not_there;
674#endif
675 if (strEQ(name, "ENXIO"))
676#ifdef ENXIO
677 return ENXIO;
678#else
679 goto not_there;
680#endif
681 if (strEQ(name, "ENAMETOOLONG"))
682#ifdef ENAMETOOLONG
683 return ENAMETOOLONG;
684#else
685 goto not_there;
686#endif
687 break;
688 case 'O':
689 if (strEQ(name, "EOF"))
690#ifdef EOF
691 return EOF;
692#else
693 goto not_there;
694#endif
695 break;
696 case 'P':
697 if (strEQ(name, "EPERM"))
698#ifdef EPERM
699 return EPERM;
700#else
701 goto not_there;
702#endif
703 if (strEQ(name, "EPIPE"))
704#ifdef EPIPE
705 return EPIPE;
706#else
707 goto not_there;
708#endif
709 break;
710 case 'R':
711 if (strEQ(name, "ERANGE"))
712#ifdef ERANGE
713 return ERANGE;
714#else
715 goto not_there;
716#endif
717 if (strEQ(name, "EROFS"))
718#ifdef EROFS
719 return EROFS;
720#else
721 goto not_there;
722#endif
723 break;
724 case 'S':
725 if (strEQ(name, "ESPIPE"))
726#ifdef ESPIPE
727 return ESPIPE;
728#else
729 goto not_there;
730#endif
731 if (strEQ(name, "ESRCH"))
732#ifdef ESRCH
733 return ESRCH;
734#else
735 goto not_there;
736#endif
737 break;
738 case 'X':
739 if (strEQ(name, "EXIT_FAILURE"))
740#ifdef EXIT_FAILURE
741 return EXIT_FAILURE;
742#else
743 return 1;
744#endif
745 if (strEQ(name, "EXIT_SUCCESS"))
746#ifdef EXIT_SUCCESS
747 return EXIT_SUCCESS;
748#else
749 return 0;
750#endif
751 if (strEQ(name, "EXDEV"))
752#ifdef EXDEV
753 return EXDEV;
754#else
755 goto not_there;
756#endif
757 break;
758 }
759 if (strEQ(name, "E2BIG"))
760#ifdef E2BIG
761 return E2BIG;
762#else
763 goto not_there;
764#endif
765 break;
766 case 'F':
767 if (strnEQ(name, "FLT_", 4)) {
768 if (strEQ(name, "FLT_MAX"))
769#ifdef FLT_MAX
770 return FLT_MAX;
771#else
772 goto not_there;
773#endif
774 if (strEQ(name, "FLT_MIN"))
775#ifdef FLT_MIN
776 return FLT_MIN;
777#else
778 goto not_there;
779#endif
780 if (strEQ(name, "FLT_ROUNDS"))
781#ifdef FLT_ROUNDS
782 return FLT_ROUNDS;
783#else
784 goto not_there;
785#endif
786 if (strEQ(name, "FLT_DIG"))
787#ifdef FLT_DIG
788 return FLT_DIG;
789#else
790 goto not_there;
791#endif
792 if (strEQ(name, "FLT_EPSILON"))
793#ifdef FLT_EPSILON
794 return FLT_EPSILON;
795#else
796 goto not_there;
797#endif
798 if (strEQ(name, "FLT_MANT_DIG"))
799#ifdef FLT_MANT_DIG
800 return FLT_MANT_DIG;
801#else
802 goto not_there;
803#endif
804 if (strEQ(name, "FLT_MAX_10_EXP"))
805#ifdef FLT_MAX_10_EXP
806 return FLT_MAX_10_EXP;
807#else
808 goto not_there;
809#endif
810 if (strEQ(name, "FLT_MAX_EXP"))
811#ifdef FLT_MAX_EXP
812 return FLT_MAX_EXP;
813#else
814 goto not_there;
815#endif
816 if (strEQ(name, "FLT_MIN_10_EXP"))
817#ifdef FLT_MIN_10_EXP
818 return FLT_MIN_10_EXP;
819#else
820 goto not_there;
821#endif
822 if (strEQ(name, "FLT_MIN_EXP"))
823#ifdef FLT_MIN_EXP
824 return FLT_MIN_EXP;
825#else
826 goto not_there;
827#endif
828 if (strEQ(name, "FLT_RADIX"))
829#ifdef FLT_RADIX
830 return FLT_RADIX;
831#else
832 goto not_there;
833#endif
834 break;
835 }
836 if (strnEQ(name, "F_", 2)) {
837 if (strEQ(name, "F_DUPFD"))
838#ifdef F_DUPFD
839 return F_DUPFD;
840#else
841 goto not_there;
842#endif
843 if (strEQ(name, "F_GETFD"))
844#ifdef F_GETFD
845 return F_GETFD;
846#else
847 goto not_there;
848#endif
849 if (strEQ(name, "F_GETFL"))
850#ifdef F_GETFL
851 return F_GETFL;
852#else
853 goto not_there;
854#endif
855 if (strEQ(name, "F_GETLK"))
856#ifdef F_GETLK
857 return F_GETLK;
858#else
859 goto not_there;
860#endif
861 if (strEQ(name, "F_OK"))
862#ifdef F_OK
863 return F_OK;
864#else
865 goto not_there;
866#endif
867 if (strEQ(name, "F_RDLCK"))
868#ifdef F_RDLCK
869 return F_RDLCK;
870#else
871 goto not_there;
872#endif
873 if (strEQ(name, "F_SETFD"))
874#ifdef F_SETFD
875 return F_SETFD;
876#else
877 goto not_there;
878#endif
879 if (strEQ(name, "F_SETFL"))
880#ifdef F_SETFL
881 return F_SETFL;
882#else
883 goto not_there;
884#endif
885 if (strEQ(name, "F_SETLK"))
886#ifdef F_SETLK
887 return F_SETLK;
888#else
889 goto not_there;
890#endif
891 if (strEQ(name, "F_SETLKW"))
892#ifdef F_SETLKW
893 return F_SETLKW;
894#else
895 goto not_there;
896#endif
897 if (strEQ(name, "F_UNLCK"))
898#ifdef F_UNLCK
899 return F_UNLCK;
900#else
901 goto not_there;
902#endif
903 if (strEQ(name, "F_WRLCK"))
904#ifdef F_WRLCK
905 return F_WRLCK;
906#else
907 goto not_there;
908#endif
909 break;
910 }
911 if (strEQ(name, "FD_CLOEXEC")) return FD_CLOEXEC;
912 if (strEQ(name, "FILENAME_MAX"))
913#ifdef FILENAME_MAX
914 return FILENAME_MAX;
915#else
916 goto not_there;
917#endif
918 break;
919 case 'H':
920 if (strEQ(name, "HUGE_VAL"))
921#ifdef HUGE_VAL
922 return HUGE_VAL;
923#else
924 goto not_there;
925#endif
926 if (strEQ(name, "HUPCL"))
927#ifdef HUPCL
928 return HUPCL;
929#else
930 goto not_there;
931#endif
932 break;
933 case 'I':
934 if (strEQ(name, "INT_MAX"))
935#ifdef INT_MAX
936 return INT_MAX;
937#else
938 goto not_there;
939#endif
940 if (strEQ(name, "INT_MIN"))
941#ifdef INT_MIN
942 return INT_MIN;
943#else
944 goto not_there;
945#endif
946 if (strEQ(name, "ICANON"))
947#ifdef ICANON
948 return ICANON;
949#else
950 goto not_there;
951#endif
952 if (strEQ(name, "ICRNL"))
953#ifdef ICRNL
954 return ICRNL;
955#else
956 goto not_there;
957#endif
958 if (strEQ(name, "IEXTEN"))
959#ifdef IEXTEN
960 return IEXTEN;
961#else
962 goto not_there;
963#endif
964 if (strEQ(name, "IGNBRK"))
965#ifdef IGNBRK
966 return IGNBRK;
967#else
968 goto not_there;
969#endif
970 if (strEQ(name, "IGNCR"))
971#ifdef IGNCR
972 return IGNCR;
973#else
974 goto not_there;
975#endif
976 if (strEQ(name, "IGNPAR"))
977#ifdef IGNPAR
978 return IGNPAR;
979#else
980 goto not_there;
981#endif
982 if (strEQ(name, "INLCR"))
983#ifdef INLCR
984 return INLCR;
985#else
986 goto not_there;
987#endif
988 if (strEQ(name, "INPCK"))
989#ifdef INPCK
990 return INPCK;
991#else
992 goto not_there;
993#endif
994 if (strEQ(name, "ISIG"))
995#ifdef ISIG
996 return ISIG;
997#else
998 goto not_there;
999#endif
1000 if (strEQ(name, "ISTRIP"))
1001#ifdef ISTRIP
1002 return ISTRIP;
1003#else
1004 goto not_there;
1005#endif
1006 if (strEQ(name, "IXOFF"))
1007#ifdef IXOFF
1008 return IXOFF;
1009#else
1010 goto not_there;
1011#endif
1012 if (strEQ(name, "IXON"))
1013#ifdef IXON
1014 return IXON;
1015#else
1016 goto not_there;
1017#endif
1018 break;
1019 case 'L':
1020 if (strnEQ(name, "LC_", 3)) {
1021 if (strEQ(name, "LC_ALL"))
1022#ifdef LC_ALL
1023 return LC_ALL;
1024#else
1025 goto not_there;
1026#endif
1027 if (strEQ(name, "LC_COLLATE"))
1028#ifdef LC_COLLATE
1029 return LC_COLLATE;
1030#else
1031 goto not_there;
1032#endif
1033 if (strEQ(name, "LC_CTYPE"))
1034#ifdef LC_CTYPE
1035 return LC_CTYPE;
1036#else
1037 goto not_there;
1038#endif
1039 if (strEQ(name, "LC_MONETARY"))
1040#ifdef LC_MONETARY
1041 return LC_MONETARY;
1042#else
1043 goto not_there;
1044#endif
1045 if (strEQ(name, "LC_NUMERIC"))
1046#ifdef LC_NUMERIC
1047 return LC_NUMERIC;
1048#else
1049 goto not_there;
1050#endif
1051 if (strEQ(name, "LC_TIME"))
1052#ifdef LC_TIME
1053 return LC_TIME;
1054#else
1055 goto not_there;
1056#endif
1057 break;
1058 }
1059 if (strnEQ(name, "LDBL_", 5)) {
1060 if (strEQ(name, "LDBL_MAX"))
1061#ifdef LDBL_MAX
1062 return LDBL_MAX;
1063#else
1064 goto not_there;
1065#endif
1066 if (strEQ(name, "LDBL_MIN"))
1067#ifdef LDBL_MIN
1068 return LDBL_MIN;
1069#else
1070 goto not_there;
1071#endif
1072 if (strEQ(name, "LDBL_DIG"))
1073#ifdef LDBL_DIG
1074 return LDBL_DIG;
1075#else
1076 goto not_there;
1077#endif
1078 if (strEQ(name, "LDBL_EPSILON"))
1079#ifdef LDBL_EPSILON
1080 return LDBL_EPSILON;
1081#else
1082 goto not_there;
1083#endif
1084 if (strEQ(name, "LDBL_MANT_DIG"))
1085#ifdef LDBL_MANT_DIG
1086 return LDBL_MANT_DIG;
1087#else
1088 goto not_there;
1089#endif
1090 if (strEQ(name, "LDBL_MAX_10_EXP"))
1091#ifdef LDBL_MAX_10_EXP
1092 return LDBL_MAX_10_EXP;
1093#else
1094 goto not_there;
1095#endif
1096 if (strEQ(name, "LDBL_MAX_EXP"))
1097#ifdef LDBL_MAX_EXP
1098 return LDBL_MAX_EXP;
1099#else
1100 goto not_there;
1101#endif
1102 if (strEQ(name, "LDBL_MIN_10_EXP"))
1103#ifdef LDBL_MIN_10_EXP
1104 return LDBL_MIN_10_EXP;
1105#else
1106 goto not_there;
1107#endif
1108 if (strEQ(name, "LDBL_MIN_EXP"))
1109#ifdef LDBL_MIN_EXP
1110 return LDBL_MIN_EXP;
1111#else
1112 goto not_there;
1113#endif
1114 break;
1115 }
1116 if (strnEQ(name, "L_", 2)) {
1117 if (strEQ(name, "L_ctermid"))
1118#ifdef L_ctermid
1119 return L_ctermid;
1120#else
1121 goto not_there;
1122#endif
1123 if (strEQ(name, "L_cuserid"))
1124#ifdef L_cuserid
1125 return L_cuserid;
1126#else
1127 goto not_there;
1128#endif
1129 if (strEQ(name, "L_tmpname"))
1130#ifdef L_tmpname
1131 return L_tmpname;
1132#else
1133 goto not_there;
1134#endif
1135 break;
1136 }
1137 if (strEQ(name, "LONG_MAX"))
1138#ifdef LONG_MAX
1139 return LONG_MAX;
1140#else
1141 goto not_there;
1142#endif
1143 if (strEQ(name, "LONG_MIN"))
1144#ifdef LONG_MIN
1145 return LONG_MIN;
1146#else
1147 goto not_there;
1148#endif
1149 if (strEQ(name, "LINK_MAX"))
1150#ifdef LINK_MAX
1151 return LINK_MAX;
1152#else
1153 goto not_there;
1154#endif
1155 break;
1156 case 'M':
1157 if (strEQ(name, "MAX_CANON"))
1158#ifdef MAX_CANON
1159 return MAX_CANON;
1160#else
1161 goto not_there;
1162#endif
1163 if (strEQ(name, "MAX_INPUT"))
1164#ifdef MAX_INPUT
1165 return MAX_INPUT;
1166#else
1167 goto not_there;
1168#endif
1169 if (strEQ(name, "MB_CUR_MAX"))
1170#ifdef MB_CUR_MAX
1171 return MB_CUR_MAX;
1172#else
1173 goto not_there;
1174#endif
1175 if (strEQ(name, "MB_LEN_MAX"))
1176#ifdef MB_LEN_MAX
1177 return MB_LEN_MAX;
1178#else
1179 goto not_there;
1180#endif
1181 break;
1182 case 'N':
a0d0e21e 1183 if (strEQ(name, "NULL")) return 0;
2304df62
AD
1184 if (strEQ(name, "NAME_MAX"))
1185#ifdef NAME_MAX
1186 return NAME_MAX;
1187#else
1188 goto not_there;
1189#endif
1190 if (strEQ(name, "NCCS"))
1191#ifdef NCCS
1192 return NCCS;
1193#else
1194 goto not_there;
1195#endif
1196 if (strEQ(name, "NGROUPS_MAX"))
1197#ifdef NGROUPS_MAX
1198 return NGROUPS_MAX;
1199#else
1200 goto not_there;
1201#endif
1202 if (strEQ(name, "NOFLSH"))
1203#ifdef NOFLSH
1204 return NOFLSH;
1205#else
1206 goto not_there;
1207#endif
1208 break;
1209 case 'O':
1210 if (strnEQ(name, "O_", 2)) {
1211 if (strEQ(name, "O_APPEND"))
1212#ifdef O_APPEND
1213 return O_APPEND;
1214#else
1215 goto not_there;
1216#endif
1217 if (strEQ(name, "O_CREAT"))
1218#ifdef O_CREAT
1219 return O_CREAT;
1220#else
1221 goto not_there;
1222#endif
1223 if (strEQ(name, "O_TRUNC"))
1224#ifdef O_TRUNC
1225 return O_TRUNC;
1226#else
1227 goto not_there;
1228#endif
1229 if (strEQ(name, "O_RDONLY"))
1230#ifdef O_RDONLY
1231 return O_RDONLY;
1232#else
1233 goto not_there;
1234#endif
1235 if (strEQ(name, "O_RDWR"))
1236#ifdef O_RDWR
1237 return O_RDWR;
1238#else
1239 goto not_there;
1240#endif
1241 if (strEQ(name, "O_WRONLY"))
1242#ifdef O_WRONLY
1243 return O_WRONLY;
1244#else
1245 goto not_there;
1246#endif
1247 if (strEQ(name, "O_EXCL"))
1248#ifdef O_EXCL
1249 return O_EXCL;
1250#else
1251 goto not_there;
1252#endif
1253 if (strEQ(name, "O_NOCTTY"))
1254#ifdef O_NOCTTY
1255 return O_NOCTTY;
1256#else
1257 goto not_there;
1258#endif
1259 if (strEQ(name, "O_NONBLOCK"))
1260#ifdef O_NONBLOCK
1261 return O_NONBLOCK;
1262#else
1263 goto not_there;
1264#endif
1265 if (strEQ(name, "O_ACCMODE"))
1266#ifdef O_ACCMODE
1267 return O_ACCMODE;
1268#else
1269 goto not_there;
1270#endif
1271 break;
1272 }
1273 if (strEQ(name, "OPEN_MAX"))
1274#ifdef OPEN_MAX
1275 return OPEN_MAX;
1276#else
1277 goto not_there;
1278#endif
1279 if (strEQ(name, "OPOST"))
1280#ifdef OPOST
1281 return OPOST;
1282#else
1283 goto not_there;
1284#endif
1285 break;
1286 case 'P':
1287 if (strEQ(name, "PATH_MAX"))
1288#ifdef PATH_MAX
1289 return PATH_MAX;
1290#else
1291 goto not_there;
1292#endif
1293 if (strEQ(name, "PARENB"))
1294#ifdef PARENB
1295 return PARENB;
1296#else
1297 goto not_there;
1298#endif
1299 if (strEQ(name, "PARMRK"))
1300#ifdef PARMRK
1301 return PARMRK;
1302#else
1303 goto not_there;
1304#endif
1305 if (strEQ(name, "PARODD"))
1306#ifdef PARODD
1307 return PARODD;
1308#else
1309 goto not_there;
1310#endif
1311 if (strEQ(name, "PIPE_BUF"))
1312#ifdef PIPE_BUF
1313 return PIPE_BUF;
1314#else
1315 goto not_there;
1316#endif
1317 break;
1318 case 'R':
1319 if (strEQ(name, "RAND_MAX"))
1320#ifdef RAND_MAX
1321 return RAND_MAX;
1322#else
1323 goto not_there;
1324#endif
1325 if (strEQ(name, "R_OK"))
1326#ifdef R_OK
1327 return R_OK;
1328#else
1329 goto not_there;
1330#endif
1331 break;
1332 case 'S':
1333 if (strnEQ(name, "SIG", 3)) {
1334 if (name[3] == '_') {
1335 if (strEQ(name, "SIG_BLOCK"))
1336#ifdef SIG_BLOCK
1337 return SIG_BLOCK;
1338#else
1339 goto not_there;
1340#endif
1341#ifdef SIG_DFL
1342 if (strEQ(name, "SIG_DFL")) return (int)SIG_DFL;
1343#endif
1344#ifdef SIG_ERR
1345 if (strEQ(name, "SIG_ERR")) return (int)SIG_ERR;
1346#endif
1347#ifdef SIG_IGN
1348 if (strEQ(name, "SIG_IGN")) return (int)SIG_IGN;
1349#endif
1350 if (strEQ(name, "SIG_SETMASK"))
1351#ifdef SIG_SETMASK
1352 return SIG_SETMASK;
1353#else
1354 goto not_there;
1355#endif
1356 if (strEQ(name, "SIG_UNBLOCK"))
1357#ifdef SIG_UNBLOCK
1358 return SIG_UNBLOCK;
1359#else
1360 goto not_there;
1361#endif
1362 break;
1363 }
1364 if (strEQ(name, "SIGABRT"))
1365#ifdef SIGABRT
1366 return SIGABRT;
1367#else
1368 goto not_there;
1369#endif
1370 if (strEQ(name, "SIGALRM"))
1371#ifdef SIGALRM
1372 return SIGALRM;
1373#else
1374 goto not_there;
1375#endif
1376 if (strEQ(name, "SIGCHLD"))
1377#ifdef SIGCHLD
1378 return SIGCHLD;
1379#else
1380 goto not_there;
1381#endif
1382 if (strEQ(name, "SIGCONT"))
1383#ifdef SIGCONT
1384 return SIGCONT;
1385#else
1386 goto not_there;
1387#endif
1388 if (strEQ(name, "SIGFPE"))
1389#ifdef SIGFPE
1390 return SIGFPE;
1391#else
1392 goto not_there;
1393#endif
1394 if (strEQ(name, "SIGHUP"))
1395#ifdef SIGHUP
1396 return SIGHUP;
1397#else
1398 goto not_there;
1399#endif
1400 if (strEQ(name, "SIGILL"))
1401#ifdef SIGILL
1402 return SIGILL;
1403#else
1404 goto not_there;
1405#endif
1406 if (strEQ(name, "SIGINT"))
1407#ifdef SIGINT
1408 return SIGINT;
1409#else
1410 goto not_there;
1411#endif
1412 if (strEQ(name, "SIGKILL"))
1413#ifdef SIGKILL
1414 return SIGKILL;
1415#else
1416 goto not_there;
1417#endif
1418 if (strEQ(name, "SIGPIPE"))
1419#ifdef SIGPIPE
1420 return SIGPIPE;
1421#else
1422 goto not_there;
1423#endif
1424 if (strEQ(name, "SIGQUIT"))
1425#ifdef SIGQUIT
1426 return SIGQUIT;
1427#else
1428 goto not_there;
1429#endif
1430 if (strEQ(name, "SIGSEGV"))
1431#ifdef SIGSEGV
1432 return SIGSEGV;
1433#else
1434 goto not_there;
1435#endif
1436 if (strEQ(name, "SIGSTOP"))
1437#ifdef SIGSTOP
1438 return SIGSTOP;
1439#else
1440 goto not_there;
1441#endif
1442 if (strEQ(name, "SIGTERM"))
1443#ifdef SIGTERM
1444 return SIGTERM;
1445#else
1446 goto not_there;
1447#endif
1448 if (strEQ(name, "SIGTSTP"))
1449#ifdef SIGTSTP
1450 return SIGTSTP;
1451#else
1452 goto not_there;
1453#endif
1454 if (strEQ(name, "SIGTTIN"))
1455#ifdef SIGTTIN
1456 return SIGTTIN;
1457#else
1458 goto not_there;
1459#endif
1460 if (strEQ(name, "SIGTTOU"))
1461#ifdef SIGTTOU
1462 return SIGTTOU;
1463#else
1464 goto not_there;
1465#endif
1466 if (strEQ(name, "SIGUSR1"))
1467#ifdef SIGUSR1
1468 return SIGUSR1;
1469#else
1470 goto not_there;
1471#endif
1472 if (strEQ(name, "SIGUSR2"))
1473#ifdef SIGUSR2
1474 return SIGUSR2;
1475#else
1476 goto not_there;
1477#endif
1478 break;
1479 }
1480 if (name[1] == '_') {
1481#ifdef S_ISBLK
1482 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1483#endif
1484#ifdef S_ISCHR
1485 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1486#endif
1487#ifdef S_ISDIR
1488 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1489#endif
1490#ifdef S_ISFIFO
1491 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1492#endif
1493#ifdef S_ISREG
1494 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1495#endif
1496 if (strEQ(name, "S_ISGID"))
1497#ifdef S_ISGID
1498 return S_ISGID;
1499#else
1500 goto not_there;
1501#endif
1502 if (strEQ(name, "S_ISUID"))
1503#ifdef S_ISUID
1504 return S_ISUID;
1505#else
1506 goto not_there;
1507#endif
1508 if (strEQ(name, "S_IRGRP"))
1509#ifdef S_IRGRP
1510 return S_IRGRP;
1511#else
1512 goto not_there;
1513#endif
1514 if (strEQ(name, "S_IROTH"))
1515#ifdef S_IROTH
1516 return S_IROTH;
1517#else
1518 goto not_there;
1519#endif
1520 if (strEQ(name, "S_IRUSR"))
1521#ifdef S_IRUSR
1522 return S_IRUSR;
1523#else
1524 goto not_there;
1525#endif
1526 if (strEQ(name, "S_IRWXG"))
1527#ifdef S_IRWXG
1528 return S_IRWXG;
1529#else
1530 goto not_there;
1531#endif
1532 if (strEQ(name, "S_IRWXO"))
1533#ifdef S_IRWXO
1534 return S_IRWXO;
1535#else
1536 goto not_there;
1537#endif
1538 if (strEQ(name, "S_IRWXU"))
1539#ifdef S_IRWXU
1540 return S_IRWXU;
1541#else
1542 goto not_there;
1543#endif
1544 if (strEQ(name, "S_IWGRP"))
1545#ifdef S_IWGRP
1546 return S_IWGRP;
1547#else
1548 goto not_there;
1549#endif
1550 if (strEQ(name, "S_IWOTH"))
1551#ifdef S_IWOTH
1552 return S_IWOTH;
1553#else
1554 goto not_there;
1555#endif
1556 if (strEQ(name, "S_IWUSR"))
1557#ifdef S_IWUSR
1558 return S_IWUSR;
1559#else
1560 goto not_there;
1561#endif
1562 if (strEQ(name, "S_IXGRP"))
1563#ifdef S_IXGRP
1564 return S_IXGRP;
1565#else
1566 goto not_there;
1567#endif
1568 if (strEQ(name, "S_IXOTH"))
1569#ifdef S_IXOTH
1570 return S_IXOTH;
1571#else
1572 goto not_there;
1573#endif
1574 if (strEQ(name, "S_IXUSR"))
1575#ifdef S_IXUSR
1576 return S_IXUSR;
1577#else
1578 goto not_there;
1579#endif
1580 break;
1581 }
1582 if (strEQ(name, "SEEK_CUR"))
1583#ifdef SEEK_CUR
1584 return SEEK_CUR;
1585#else
1586 goto not_there;
1587#endif
1588 if (strEQ(name, "SEEK_END"))
1589#ifdef SEEK_END
1590 return SEEK_END;
1591#else
1592 goto not_there;
1593#endif
1594 if (strEQ(name, "SEEK_SET"))
1595#ifdef SEEK_SET
1596 return SEEK_SET;
1597#else
1598 goto not_there;
1599#endif
1600 if (strEQ(name, "STREAM_MAX"))
1601#ifdef STREAM_MAX
1602 return STREAM_MAX;
1603#else
1604 goto not_there;
1605#endif
1606 if (strEQ(name, "SHRT_MAX"))
1607#ifdef SHRT_MAX
1608 return SHRT_MAX;
1609#else
1610 goto not_there;
1611#endif
1612 if (strEQ(name, "SHRT_MIN"))
1613#ifdef SHRT_MIN
1614 return SHRT_MIN;
1615#else
1616 goto not_there;
1617#endif
1618 if (strEQ(name, "SA_NOCLDSTOP"))
1619#ifdef SA_NOCLDSTOP
1620 return SA_NOCLDSTOP;
1621#else
1622 goto not_there;
1623#endif
1624 if (strEQ(name, "SCHAR_MAX"))
1625#ifdef SCHAR_MAX
1626 return SCHAR_MAX;
1627#else
1628 goto not_there;
1629#endif
1630 if (strEQ(name, "SCHAR_MIN"))
1631#ifdef SCHAR_MIN
1632 return SCHAR_MIN;
1633#else
1634 goto not_there;
1635#endif
1636 if (strEQ(name, "SSIZE_MAX"))
1637#ifdef SSIZE_MAX
1638 return SSIZE_MAX;
1639#else
1640 goto not_there;
1641#endif
1642 if (strEQ(name, "STDIN_FILENO"))
1643#ifdef STDIN_FILENO
1644 return STDIN_FILENO;
1645#else
1646 goto not_there;
1647#endif
1648 if (strEQ(name, "STDOUT_FILENO"))
1649#ifdef STDOUT_FILENO
1650 return STDOUT_FILENO;
1651#else
1652 goto not_there;
1653#endif
1654 if (strEQ(name, "STRERR_FILENO"))
1655#ifdef STRERR_FILENO
1656 return STRERR_FILENO;
1657#else
1658 goto not_there;
1659#endif
1660 break;
1661 case 'T':
1662 if (strEQ(name, "TCIFLUSH"))
1663#ifdef TCIFLUSH
1664 return TCIFLUSH;
1665#else
1666 goto not_there;
1667#endif
1668 if (strEQ(name, "TCIOFF"))
1669#ifdef TCIOFF
1670 return TCIOFF;
1671#else
1672 goto not_there;
1673#endif
1674 if (strEQ(name, "TCIOFLUSH"))
1675#ifdef TCIOFLUSH
1676 return TCIOFLUSH;
1677#else
1678 goto not_there;
1679#endif
1680 if (strEQ(name, "TCION"))
1681#ifdef TCION
1682 return TCION;
1683#else
1684 goto not_there;
1685#endif
1686 if (strEQ(name, "TCOFLUSH"))
1687#ifdef TCOFLUSH
1688 return TCOFLUSH;
1689#else
1690 goto not_there;
1691#endif
1692 if (strEQ(name, "TCOOFF"))
1693#ifdef TCOOFF
1694 return TCOOFF;
1695#else
1696 goto not_there;
1697#endif
1698 if (strEQ(name, "TCOON"))
1699#ifdef TCOON
1700 return TCOON;
1701#else
1702 goto not_there;
1703#endif
1704 if (strEQ(name, "TCSADRAIN"))
1705#ifdef TCSADRAIN
1706 return TCSADRAIN;
1707#else
1708 goto not_there;
1709#endif
1710 if (strEQ(name, "TCSAFLUSH"))
1711#ifdef TCSAFLUSH
1712 return TCSAFLUSH;
1713#else
1714 goto not_there;
1715#endif
1716 if (strEQ(name, "TCSANOW"))
1717#ifdef TCSANOW
1718 return TCSANOW;
1719#else
1720 goto not_there;
1721#endif
1722 if (strEQ(name, "TMP_MAX"))
1723#ifdef TMP_MAX
1724 return TMP_MAX;
1725#else
1726 goto not_there;
1727#endif
1728 if (strEQ(name, "TOSTOP"))
1729#ifdef TOSTOP
1730 return TOSTOP;
1731#else
1732 goto not_there;
1733#endif
1734 if (strEQ(name, "TZNAME_MAX"))
1735#ifdef TZNAME_MAX
1736 return TZNAME_MAX;
1737#else
1738 goto not_there;
1739#endif
1740 break;
1741 case 'U':
1742 if (strEQ(name, "UCHAR_MAX"))
1743#ifdef UCHAR_MAX
1744 return UCHAR_MAX;
1745#else
1746 goto not_there;
1747#endif
1748 if (strEQ(name, "UINT_MAX"))
1749#ifdef UINT_MAX
1750 return UINT_MAX;
1751#else
1752 goto not_there;
1753#endif
1754 if (strEQ(name, "ULONG_MAX"))
1755#ifdef ULONG_MAX
1756 return ULONG_MAX;
1757#else
1758 goto not_there;
1759#endif
1760 if (strEQ(name, "USHRT_MAX"))
1761#ifdef USHRT_MAX
1762 return USHRT_MAX;
1763#else
1764 goto not_there;
1765#endif
1766 break;
1767 case 'V':
1768 if (strEQ(name, "VEOF"))
1769#ifdef VEOF
1770 return VEOF;
1771#else
1772 goto not_there;
1773#endif
1774 if (strEQ(name, "VEOL"))
1775#ifdef VEOL
1776 return VEOL;
1777#else
1778 goto not_there;
1779#endif
1780 if (strEQ(name, "VERASE"))
1781#ifdef VERASE
1782 return VERASE;
1783#else
1784 goto not_there;
1785#endif
1786 if (strEQ(name, "VINTR"))
1787#ifdef VINTR
1788 return VINTR;
1789#else
1790 goto not_there;
1791#endif
1792 if (strEQ(name, "VKILL"))
1793#ifdef VKILL
1794 return VKILL;
1795#else
1796 goto not_there;
1797#endif
1798 if (strEQ(name, "VMIN"))
1799#ifdef VMIN
1800 return VMIN;
1801#else
1802 goto not_there;
1803#endif
1804 if (strEQ(name, "VQUIT"))
1805#ifdef VQUIT
1806 return VQUIT;
1807#else
1808 goto not_there;
1809#endif
1810 if (strEQ(name, "VSTART"))
1811#ifdef VSTART
1812 return VSTART;
1813#else
1814 goto not_there;
1815#endif
1816 if (strEQ(name, "VSTOP"))
1817#ifdef VSTOP
1818 return VSTOP;
1819#else
1820 goto not_there;
1821#endif
1822 if (strEQ(name, "VSUSP"))
1823#ifdef VSUSP
1824 return VSUSP;
1825#else
1826 goto not_there;
1827#endif
1828 if (strEQ(name, "VTIME"))
1829#ifdef VTIME
1830 return VTIME;
1831#else
1832 goto not_there;
1833#endif
1834 break;
1835 case 'W':
1836 if (strEQ(name, "W_OK"))
1837#ifdef W_OK
1838 return W_OK;
1839#else
1840 goto not_there;
1841#endif
1842#ifdef WEXITSTATUS
1843 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
1844#endif
1845#ifdef WIFEXITED
1846 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
1847#endif
1848#ifdef WIFSIGNALED
1849 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
1850#endif
1851#ifdef WIFSTOPPED
1852 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
1853#endif
1854 if (strEQ(name, "WNOHANG"))
1855#ifdef WNOHANG
1856 return WNOHANG;
1857#else
1858 goto not_there;
1859#endif
1860#ifdef WSTOPSIG
1861 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
1862#endif
1863#ifdef WTERMSIG
1864 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
1865#endif
1866 if (strEQ(name, "WUNTRACED"))
1867#ifdef WUNTRACED
1868 return WUNTRACED;
1869#else
1870 goto not_there;
1871#endif
1872 break;
1873 case 'X':
1874 if (strEQ(name, "X_OK"))
1875#ifdef X_OK
1876 return X_OK;
1877#else
1878 goto not_there;
1879#endif
1880 break;
1881 case '_':
1882 if (strnEQ(name, "_PC_", 4)) {
1883 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
1884#ifdef _PC_CHOWN_RESTRICTED
1885 return _PC_CHOWN_RESTRICTED;
1886#else
1887 goto not_there;
1888#endif
1889 if (strEQ(name, "_PC_LINK_MAX"))
1890#ifdef _PC_LINK_MAX
1891 return _PC_LINK_MAX;
1892#else
1893 goto not_there;
1894#endif
1895 if (strEQ(name, "_PC_MAX_CANON"))
1896#ifdef _PC_MAX_CANON
1897 return _PC_MAX_CANON;
1898#else
1899 goto not_there;
1900#endif
1901 if (strEQ(name, "_PC_MAX_INPUT"))
1902#ifdef _PC_MAX_INPUT
1903 return _PC_MAX_INPUT;
1904#else
1905 goto not_there;
1906#endif
1907 if (strEQ(name, "_PC_NAME_MAX"))
1908#ifdef _PC_NAME_MAX
1909 return _PC_NAME_MAX;
1910#else
1911 goto not_there;
1912#endif
1913 if (strEQ(name, "_PC_NO_TRUNC"))
1914#ifdef _PC_NO_TRUNC
1915 return _PC_NO_TRUNC;
1916#else
1917 goto not_there;
1918#endif
1919 if (strEQ(name, "_PC_PATH_MAX"))
1920#ifdef _PC_PATH_MAX
1921 return _PC_PATH_MAX;
1922#else
1923 goto not_there;
1924#endif
1925 if (strEQ(name, "_PC_PIPE_BUF"))
1926#ifdef _PC_PIPE_BUF
1927 return _PC_PIPE_BUF;
1928#else
1929 goto not_there;
1930#endif
1931 if (strEQ(name, "_PC_VDISABLE"))
1932#ifdef _PC_VDISABLE
1933 return _PC_VDISABLE;
1934#else
1935 goto not_there;
1936#endif
1937 break;
1938 }
1939 if (strnEQ(name, "_POSIX_", 7)) {
1940 if (strEQ(name, "_POSIX_ARG_MAX"))
1941#ifdef _POSIX_ARG_MAX
1942 return _POSIX_ARG_MAX;
1943#else
1944 return 0;
1945#endif
1946 if (strEQ(name, "_POSIX_CHILD_MAX"))
1947#ifdef _POSIX_CHILD_MAX
1948 return _POSIX_CHILD_MAX;
1949#else
1950 return 0;
1951#endif
1952 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
1953#ifdef _POSIX_CHOWN_RESTRICTED
1954 return _POSIX_CHOWN_RESTRICTED;
1955#else
1956 return 0;
1957#endif
1958 if (strEQ(name, "_POSIX_JOB_CONTROL"))
1959#ifdef _POSIX_JOB_CONTROL
1960 return _POSIX_JOB_CONTROL;
1961#else
1962 return 0;
1963#endif
1964 if (strEQ(name, "_POSIX_LINK_MAX"))
1965#ifdef _POSIX_LINK_MAX
1966 return _POSIX_LINK_MAX;
1967#else
1968 return 0;
1969#endif
1970 if (strEQ(name, "_POSIX_MAX_CANON"))
1971#ifdef _POSIX_MAX_CANON
1972 return _POSIX_MAX_CANON;
1973#else
1974 return 0;
1975#endif
1976 if (strEQ(name, "_POSIX_MAX_INPUT"))
1977#ifdef _POSIX_MAX_INPUT
1978 return _POSIX_MAX_INPUT;
1979#else
1980 return 0;
1981#endif
1982 if (strEQ(name, "_POSIX_NAME_MAX"))
1983#ifdef _POSIX_NAME_MAX
1984 return _POSIX_NAME_MAX;
1985#else
1986 return 0;
1987#endif
1988 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
1989#ifdef _POSIX_NGROUPS_MAX
1990 return _POSIX_NGROUPS_MAX;
1991#else
1992 return 0;
1993#endif
1994 if (strEQ(name, "_POSIX_NO_TRUNC"))
1995#ifdef _POSIX_NO_TRUNC
1996 return _POSIX_NO_TRUNC;
1997#else
1998 return 0;
1999#endif
2000 if (strEQ(name, "_POSIX_OPEN_MAX"))
2001#ifdef _POSIX_OPEN_MAX
2002 return _POSIX_OPEN_MAX;
2003#else
2004 return 0;
2005#endif
2006 if (strEQ(name, "_POSIX_PATH_MAX"))
2007#ifdef _POSIX_PATH_MAX
2008 return _POSIX_PATH_MAX;
2009#else
2010 return 0;
2011#endif
2012 if (strEQ(name, "_POSIX_PIPE_BUF"))
2013#ifdef _POSIX_PIPE_BUF
2014 return _POSIX_PIPE_BUF;
2015#else
2016 return 0;
2017#endif
2018 if (strEQ(name, "_POSIX_SAVED_IDS"))
2019#ifdef _POSIX_SAVED_IDS
2020 return _POSIX_SAVED_IDS;
2021#else
2022 return 0;
2023#endif
2024 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2025#ifdef _POSIX_SSIZE_MAX
2026 return _POSIX_SSIZE_MAX;
2027#else
2028 return 0;
2029#endif
2030 if (strEQ(name, "_POSIX_STREAM_MAX"))
2031#ifdef _POSIX_STREAM_MAX
2032 return _POSIX_STREAM_MAX;
2033#else
2034 return 0;
2035#endif
2036 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2037#ifdef _POSIX_TZNAME_MAX
2038 return _POSIX_TZNAME_MAX;
2039#else
2040 return 0;
2041#endif
2042 if (strEQ(name, "_POSIX_VDISABLE"))
2043#ifdef _POSIX_VDISABLE
2044 return _POSIX_VDISABLE;
2045#else
2046 return 0;
2047#endif
2048 if (strEQ(name, "_POSIX_VERSION"))
2049#ifdef _POSIX_VERSION
2050 return _POSIX_VERSION;
2051#else
2052 return 0;
2053#endif
2054 break;
2055 }
2056 if (strnEQ(name, "_SC_", 4)) {
2057 if (strEQ(name, "_SC_ARG_MAX"))
2058#ifdef _SC_ARG_MAX
2059 return _SC_ARG_MAX;
2060#else
2061 goto not_there;
2062#endif
2063 if (strEQ(name, "_SC_CHILD_MAX"))
2064#ifdef _SC_CHILD_MAX
2065 return _SC_CHILD_MAX;
2066#else
2067 goto not_there;
2068#endif
2069 if (strEQ(name, "_SC_CLK_TCK"))
2070#ifdef _SC_CLK_TCK
2071 return _SC_CLK_TCK;
2072#else
2073 goto not_there;
2074#endif
2075 if (strEQ(name, "_SC_JOB_CONTROL"))
2076#ifdef _SC_JOB_CONTROL
2077 return _SC_JOB_CONTROL;
2078#else
2079 goto not_there;
2080#endif
2081 if (strEQ(name, "_SC_NGROUPS_MAX"))
2082#ifdef _SC_NGROUPS_MAX
2083 return _SC_NGROUPS_MAX;
2084#else
2085 goto not_there;
2086#endif
2087 if (strEQ(name, "_SC_OPEN_MAX"))
2088#ifdef _SC_OPEN_MAX
2089 return _SC_OPEN_MAX;
2090#else
2091 goto not_there;
2092#endif
2093 if (strEQ(name, "_SC_SAVED_IDS"))
2094#ifdef _SC_SAVED_IDS
2095 return _SC_SAVED_IDS;
2096#else
2097 goto not_there;
2098#endif
2099 if (strEQ(name, "_SC_STREAM_MAX"))
2100#ifdef _SC_STREAM_MAX
2101 return _SC_STREAM_MAX;
2102#else
2103 goto not_there;
2104#endif
2105 if (strEQ(name, "_SC_TZNAME_MAX"))
2106#ifdef _SC_TZNAME_MAX
2107 return _SC_TZNAME_MAX;
2108#else
2109 goto not_there;
2110#endif
2111 if (strEQ(name, "_SC_VERSION"))
2112#ifdef _SC_VERSION
2113 return _SC_VERSION;
2114#else
2115 goto not_there;
2116#endif
2117 break;
2118 }
2119 if (strEQ(name, "_IOFBF"))
2120#ifdef _IOFBF
2121 return _IOFBF;
2122#else
2123 goto not_there;
2124#endif
2125 if (strEQ(name, "_IOLBF"))
2126#ifdef _IOLBF
2127 return _IOLBF;
2128#else
2129 goto not_there;
2130#endif
2131 if (strEQ(name, "_IONBF"))
2132#ifdef _IONBF
2133 return _IONBF;
2134#else
2135 goto not_there;
2136#endif
2137 break;
2138 }
2139 errno = EINVAL;
2140 return 0;
2141
2142not_there:
2143 errno = ENOENT;
2144 return 0;
2145}
2146
2147MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2148
2149POSIX::SigSet
2150new(packname = "POSIX::SigSet", ...)
2151 char * packname
2152 CODE:
2153 {
2154 int i;
2155 RETVAL = (sigset_t*)safemalloc(sizeof(sigset_t));
2156 sigemptyset(RETVAL);
a0d0e21e 2157 for (i = 1; i < items; i++)
2304df62
AD
2158 sigaddset(RETVAL, SvIV(ST(i)));
2159 }
2160 OUTPUT:
2161 RETVAL
463ee0b2 2162
8990e307 2163void
2304df62
AD
2164DESTROY(sigset)
2165 POSIX::SigSet sigset
2166 CODE:
a0d0e21e 2167 safefree((char *)sigset);
2304df62
AD
2168
2169SysRet
2170sigaddset(sigset, sig)
2171 POSIX::SigSet sigset
2172 int sig
2173
2174SysRet
2175sigdelset(sigset, sig)
2176 POSIX::SigSet sigset
2177 int sig
2178
2179SysRet
2180sigemptyset(sigset)
2181 POSIX::SigSet sigset
2182
2183SysRet
2184sigfillset(sigset)
2185 POSIX::SigSet sigset
2186
2187int
2188sigismember(sigset, sig)
2189 POSIX::SigSet sigset
2190 int sig
2191
2192
a0d0e21e
LW
2193MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2194
2195POSIX::Termios
2196new(packname = "POSIX::Termios", ...)
2197 char * packname
2198 CODE:
2199 {
2200#ifdef I_TERMIOS
2201 RETVAL = (struct termios*)safemalloc(sizeof(struct termios));
2202#else
2203 not_here("termios");
2204#endif
2205 }
2206 OUTPUT:
2207 RETVAL
2208
2209void
2210DESTROY(termios_ref)
2211 POSIX::Termios termios_ref
2212 CODE:
2213#ifdef I_TERMIOS
2214 safefree((char *)termios_ref);
2215#else
2216 not_here("termios");
2217#endif
2218
2219SysRet
2220getattr(termios_ref, fd = 0)
2221 POSIX::Termios termios_ref
2222 int fd
2223 CODE:
2224 RETVAL = tcgetattr(fd, termios_ref);
2225 OUTPUT:
2226 RETVAL
2227
2228SysRet
2229setattr(termios_ref, fd = 0, optional_actions = 0)
2230 POSIX::Termios termios_ref
2231 int fd
2232 int optional_actions
2233 CODE:
2234 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2235 OUTPUT:
2236 RETVAL
2237
2238speed_t
2239cfgetispeed(termios_ref)
2240 POSIX::Termios termios_ref
2241
2242speed_t
2243cfgetospeed(termios_ref)
2244 POSIX::Termios termios_ref
2245
2246tcflag_t
2247getiflag(termios_ref)
2248 POSIX::Termios termios_ref
2249 CODE:
2250#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2251 RETVAL = termios_ref->c_iflag;
2252#else
2253 not_here("getiflag");
2254#endif
2255 OUTPUT:
2256 RETVAL
2257
2258tcflag_t
2259getoflag(termios_ref)
2260 POSIX::Termios termios_ref
2261 CODE:
2262#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2263 RETVAL = termios_ref->c_oflag;
2264#else
2265 not_here("getoflag");
2266#endif
2267 OUTPUT:
2268 RETVAL
2269
2270tcflag_t
2271getcflag(termios_ref)
2272 POSIX::Termios termios_ref
2273 CODE:
2274#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2275 RETVAL = termios_ref->c_cflag;
2276#else
2277 not_here("getcflag");
2278#endif
2279 OUTPUT:
2280 RETVAL
2281
2282tcflag_t
2283getlflag(termios_ref)
2284 POSIX::Termios termios_ref
2285 CODE:
2286#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2287 RETVAL = termios_ref->c_lflag;
2288#else
2289 not_here("getlflag");
2290#endif
2291 OUTPUT:
2292 RETVAL
2293
2294cc_t
2295getcc(termios_ref, ccix)
2296 POSIX::Termios termios_ref
2297 int ccix
2298 CODE:
2299#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2300 if (ccix >= NCCS)
2301 croak("Bad getcc subscript");
2302 RETVAL = termios_ref->c_cc[ccix];
2303#else
2304 not_here("getcc");
2305#endif
2306 OUTPUT:
2307 RETVAL
2308
2309SysRet
2310cfsetispeed(termios_ref, speed)
2311 POSIX::Termios termios_ref
2312 speed_t speed
2313
2314SysRet
2315cfsetospeed(termios_ref, speed)
2316 POSIX::Termios termios_ref
2317 speed_t speed
2318
2319void
2320setiflag(termios_ref, iflag)
2321 POSIX::Termios termios_ref
2322 tcflag_t iflag
2323 CODE:
2324#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2325 termios_ref->c_iflag = iflag;
2326#else
2327 not_here("setiflag");
2328#endif
2329
2330void
2331setoflag(termios_ref, oflag)
2332 POSIX::Termios termios_ref
2333 tcflag_t oflag
2334 CODE:
2335#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2336 termios_ref->c_oflag = oflag;
2337#else
2338 not_here("setoflag");
2339#endif
2340
2341void
2342setcflag(termios_ref, cflag)
2343 POSIX::Termios termios_ref
2344 tcflag_t cflag
2345 CODE:
2346#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2347 termios_ref->c_cflag = cflag;
2348#else
2349 not_here("setcflag");
2350#endif
2351
2352void
2353setlflag(termios_ref, lflag)
2354 POSIX::Termios termios_ref
2355 tcflag_t lflag
2356 CODE:
2357#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2358 termios_ref->c_lflag = lflag;
2359#else
2360 not_here("setlflag");
2361#endif
2362
2363void
2364setcc(termios_ref, ccix, cc)
2365 POSIX::Termios termios_ref
2366 int ccix
2367 cc_t cc
2368 CODE:
2369#ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2370 if (ccix >= NCCS)
2371 croak("Bad setcc subscript");
2372 termios_ref->c_cc[ccix] = cc;
2373#else
2374 not_here("setcc");
2375#endif
2376
2377
2378
2379MODULE = FileHandle PACKAGE = FileHandle PREFIX = f
2380
2381SV *
2382fgetpos(handle)
2383 InputStream handle
2384 CODE:
2385 {
2386 Fpos_t pos;
2387 fgetpos(handle, &pos);
2388 ST(0) = sv_2mortal(newSVpv((char*)&pos, sizeof(Fpos_t)));
2389 }
2390
2391SysRet
2392fsetpos(handle, pos)
2393 InputStream handle
2394 SV * pos
2395 CODE:
2396 RETVAL = fsetpos(handle, (Fpos_t*)SvPVX(pos));
2397 OUTPUT:
2398 RETVAL
2399
2400int
2401ungetc(handle, c)
2402 InputStream handle
2403 int c
2404 CODE:
2405 RETVAL = ungetc(c, handle);
2406 OUTPUT:
2407 RETVAL
2408
2409OutputStream
2410new_tmpfile()
2411 CODE:
2412 RETVAL = tmpfile();
2413 OUTPUT:
2414 RETVAL
2304df62
AD
2415
2416int
a0d0e21e
LW
2417ferror(handle)
2418 InputStream handle
2419
2420SysRet
2421fflush(handle)
2422 OutputStream handle
2423
2424void
2425setbuf(handle, buf)
2426 OutputStream handle
2427 char * buf = SvPOK(ST(1)) ? sv_grow(ST(1), BUFSIZ) : 0;
2428
2429SysRet
2430setvbuf(handle, buf, type, size)
2431 OutputStream handle
2432 char * buf = SvPOK(ST(1)) ? sv_grow(ST(1), SvIV(ST(3))) : 0;
2433 int type
2434 int size
2435
2436MODULE = POSIX PACKAGE = POSIX
2437
2438double
2304df62
AD
2439constant(name,arg)
2440 char * name
2441 int arg
2442
2443int
2444isalnum(charstring)
2445 char * charstring
2446 CODE:
2447 char *s;
2448 RETVAL = 1;
85e6fe83 2449 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2450 if (!isalnum(*s))
2451 RETVAL = 0;
2452 OUTPUT:
2453 RETVAL
2454
2455int
2456isalpha(charstring)
2457 char * charstring
2458 CODE:
2459 char *s;
2460 RETVAL = 1;
85e6fe83 2461 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2462 if (!isalpha(*s))
2463 RETVAL = 0;
2464 OUTPUT:
2465 RETVAL
2466
2467int
2468iscntrl(charstring)
2469 char * charstring
2470 CODE:
2471 char *s;
2472 RETVAL = 1;
85e6fe83 2473 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2474 if (!iscntrl(*s))
2475 RETVAL = 0;
2476 OUTPUT:
2477 RETVAL
2478
2479int
2480isdigit(charstring)
2481 char * charstring
2482 CODE:
2483 char *s;
2484 RETVAL = 1;
85e6fe83 2485 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2486 if (!isdigit(*s))
2487 RETVAL = 0;
2488 OUTPUT:
2489 RETVAL
2490
2491int
2492isgraph(charstring)
2493 char * charstring
2494 CODE:
2495 char *s;
2496 RETVAL = 1;
85e6fe83 2497 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2498 if (!isgraph(*s))
2499 RETVAL = 0;
2500 OUTPUT:
2501 RETVAL
2502
2503int
2504islower(charstring)
2505 char * charstring
2506 CODE:
2507 char *s;
2508 RETVAL = 1;
85e6fe83 2509 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2510 if (!islower(*s))
2511 RETVAL = 0;
2512 OUTPUT:
2513 RETVAL
2514
2515int
2516isprint(charstring)
2517 char * charstring
2518 CODE:
2519 char *s;
2520 RETVAL = 1;
85e6fe83 2521 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2522 if (!isprint(*s))
2523 RETVAL = 0;
2524 OUTPUT:
2525 RETVAL
2526
2527int
2528ispunct(charstring)
2529 char * charstring
2530 CODE:
2531 char *s;
2532 RETVAL = 1;
85e6fe83 2533 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2534 if (!ispunct(*s))
2535 RETVAL = 0;
2536 OUTPUT:
2537 RETVAL
2538
2539int
2540isspace(charstring)
2541 char * charstring
2542 CODE:
2543 char *s;
2544 RETVAL = 1;
85e6fe83 2545 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2546 if (!isspace(*s))
2547 RETVAL = 0;
2548 OUTPUT:
2549 RETVAL
8990e307
LW
2550
2551int
2304df62
AD
2552isupper(charstring)
2553 char * charstring
2554 CODE:
2555 char *s;
2556 RETVAL = 1;
85e6fe83 2557 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2558 if (!isupper(*s))
2559 RETVAL = 0;
2560 OUTPUT:
2561 RETVAL
8990e307
LW
2562
2563int
2304df62
AD
2564isxdigit(charstring)
2565 char * charstring
2566 CODE:
2567 char *s;
2568 RETVAL = 1;
85e6fe83 2569 for (s = charstring; *s && RETVAL; s++)
2304df62
AD
2570 if (!isxdigit(*s))
2571 RETVAL = 0;
2572 OUTPUT:
2573 RETVAL
2574
2575SysRet
2576open(filename, flags = O_RDONLY, mode = 0666)
2577 char * filename
2578 int flags
a0d0e21e 2579 Mode_t mode
2304df62
AD
2580
2581HV *
2582localeconv()
2583 CODE:
a0d0e21e 2584#ifdef HAS_LOCALECONV
2304df62
AD
2585 struct lconv *lcbuf;
2586 RETVAL = newHV();
2587 if (lcbuf = localeconv()) {
2588 /* the strings */
2589 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2590 hv_store(RETVAL, "decimal_point", 13,
2591 newSVpv(lcbuf->decimal_point, 0), 0);
2592 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2593 hv_store(RETVAL, "thousands_sep", 13,
2594 newSVpv(lcbuf->thousands_sep, 0), 0);
2595 if (lcbuf->grouping && *lcbuf->grouping)
2596 hv_store(RETVAL, "grouping", 8,
2597 newSVpv(lcbuf->grouping, 0), 0);
2598 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2599 hv_store(RETVAL, "int_curr_symbol", 15,
2600 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2601 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2602 hv_store(RETVAL, "currency_symbol", 15,
2603 newSVpv(lcbuf->currency_symbol, 0), 0);
2604 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2605 hv_store(RETVAL, "mon_decimal_point", 17,
2606 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2607 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2608 hv_store(RETVAL, "mon_thousands_sep", 17,
2609 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2610 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2611 hv_store(RETVAL, "mon_grouping", 12,
2612 newSVpv(lcbuf->mon_grouping, 0), 0);
2613 if (lcbuf->positive_sign && *lcbuf->positive_sign)
2614 hv_store(RETVAL, "positive_sign", 13,
2615 newSVpv(lcbuf->positive_sign, 0), 0);
2616 if (lcbuf->negative_sign && *lcbuf->negative_sign)
2617 hv_store(RETVAL, "negative_sign", 13,
2618 newSVpv(lcbuf->negative_sign, 0), 0);
2619 /* the integers */
2620 if (lcbuf->int_frac_digits != CHAR_MAX)
2621 hv_store(RETVAL, "int_frac_digits", 15,
2622 newSViv(lcbuf->int_frac_digits), 0);
2623 if (lcbuf->frac_digits != CHAR_MAX)
2624 hv_store(RETVAL, "frac_digits", 11,
2625 newSViv(lcbuf->frac_digits), 0);
2626 if (lcbuf->p_cs_precedes != CHAR_MAX)
2627 hv_store(RETVAL, "p_cs_precedes", 13,
2628 newSViv(lcbuf->p_cs_precedes), 0);
2629 if (lcbuf->p_sep_by_space != CHAR_MAX)
2630 hv_store(RETVAL, "p_sep_by_space", 14,
2631 newSViv(lcbuf->p_sep_by_space), 0);
2632 if (lcbuf->n_cs_precedes != CHAR_MAX)
2633 hv_store(RETVAL, "n_cs_precedes", 13,
2634 newSViv(lcbuf->n_cs_precedes), 0);
2635 if (lcbuf->n_sep_by_space != CHAR_MAX)
2636 hv_store(RETVAL, "n_sep_by_space", 14,
2637 newSViv(lcbuf->n_sep_by_space), 0);
2638 if (lcbuf->p_sign_posn != CHAR_MAX)
2639 hv_store(RETVAL, "p_sign_posn", 11,
2640 newSViv(lcbuf->p_sign_posn), 0);
2641 if (lcbuf->n_sign_posn != CHAR_MAX)
2642 hv_store(RETVAL, "n_sign_posn", 11,
2643 newSViv(lcbuf->n_sign_posn), 0);
2644 }
a0d0e21e
LW
2645#else
2646 localeconv(); /* A stub to call not_here(). */
2647#endif
2304df62
AD
2648 OUTPUT:
2649 RETVAL
2650
2651char *
2652setlocale(category, locale)
2653 int category
2654 char * locale
2655
2656double
2657acos(x)
2658 double x
2659
2660double
2661asin(x)
2662 double x
2663
2664double
2665atan(x)
2666 double x
2667
2668double
2669ceil(x)
2670 double x
2671
2672double
2673cosh(x)
2674 double x
2675
2676double
2677floor(x)
2678 double x
2679
2680double
2681fmod(x,y)
2682 double x
2683 double y
2684
2685void
2686frexp(x)
2687 double x
2688 PPCODE:
2689 int expvar;
2304df62
AD
2690 /* (We already know stack is long enough.) */
2691 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
2692 PUSHs(sv_2mortal(newSViv(expvar)));
2693
2694double
2695ldexp(x,exp)
2696 double x
2697 int exp
2698
2699double
2700log10(x)
2701 double x
2702
2703void
2704modf(x)
2705 double x
2706 PPCODE:
2707 double intvar;
2304df62
AD
2708 /* (We already know stack is long enough.) */
2709 PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
2710 PUSHs(sv_2mortal(newSVnv(intvar)));
2711
2712double
2713sinh(x)
2714 double x
2715
2716double
2717tanh(x)
2718 double x
2719
2720SysRet
2721sigaction(sig, action, oldaction = 0)
2722 int sig
2723 POSIX::SigAction action
2724 POSIX::SigAction oldaction
2725 CODE:
2726
2727# This code is really grody because we're trying to make the signal
2728# interface look beautiful, which is hard.
2729
2730 if (!siggv)
85e6fe83 2731 gv_fetchpv("SIG", TRUE, SVt_PVHV);
2304df62
AD
2732
2733 {
2734 struct sigaction act;
2735 struct sigaction oact;
2736 POSIX__SigSet sigset;
2737 SV** svp;
2738 SV** sigsvp = hv_fetch(GvHVn(siggv),
2739 sig_name[sig],
2740 strlen(sig_name[sig]),
2741 TRUE);
2742
2743 /* Remember old handler name if desired. */
2744 if (oldaction) {
2745 char *hand = SvPVx(*sigsvp, na);
2746 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
2747 sv_setpv(*svp, *hand ? hand : "DEFAULT");
2748 }
2749
2750 if (action) {
2751 /* Vector new handler through %SIG. (We always use sighandler
2752 for the C signal handler, which reads %SIG to dispatch.) */
2753 svp = hv_fetch(action, "HANDLER", 7, FALSE);
2754 if (!svp)
2755 croak("Can't supply an action without a HANDLER");
2756 sv_setpv(*sigsvp, SvPV(*svp, na));
2757 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
2758 act.sa_handler = sighandler;
2759
2760 /* Set up any desired mask. */
2761 svp = hv_fetch(action, "MASK", 4, FALSE);
2762 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
a0d0e21e
LW
2763 unsigned long tmp;
2764 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
2765 sigset = (sigset_t*) tmp;
2304df62
AD
2766 act.sa_mask = *sigset;
2767 }
2768 else
85e6fe83 2769 sigemptyset(& act.sa_mask);
2304df62
AD
2770
2771 /* Set up any desired flags. */
2772 svp = hv_fetch(action, "FLAGS", 5, FALSE);
2773 act.sa_flags = svp ? SvIV(*svp) : 0;
2774 }
2775
2776 /* Now work around sigaction oddities */
2777 if (action && oldaction)
85e6fe83 2778 RETVAL = sigaction(sig, & act, & oact);
2304df62 2779 else if (action)
85e6fe83 2780 RETVAL = sigaction(sig, & act, (struct sigaction*)0);
2304df62 2781 else if (oldaction)
85e6fe83 2782 RETVAL = sigaction(sig, (struct sigaction*)0, & oact);
a0d0e21e
LW
2783 else
2784 RETVAL = -1;
2304df62
AD
2785
2786 if (oldaction) {
2787 /* Get back the mask. */
2788 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
a0d0e21e
LW
2789 if (sv_isa(*svp, "POSIX::SigSet")) {
2790 unsigned long tmp;
2791 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
2792 sigset = (sigset_t*) tmp;
2793 }
2304df62
AD
2794 else {
2795 sigset = (sigset_t*)safemalloc(sizeof(sigset_t));
2796 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
2797 }
2798 *sigset = oact.sa_mask;
2799
2800 /* Get back the flags. */
2801 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
2802 sv_setiv(*svp, oact.sa_flags);
2803 }
2804 }
2805 OUTPUT:
2806 RETVAL
2807
2808SysRet
2809sigpending(sigset)
2810 POSIX::SigSet sigset
2811
2812SysRet
2813sigprocmask(how, sigset, oldsigset = 0)
2814 int how
2815 POSIX::SigSet sigset
2816 POSIX::SigSet oldsigset
2817
2818SysRet
2819sigsuspend(signal_mask)
2820 POSIX::SigSet signal_mask
2821
2304df62
AD
2822void
2823_exit(status)
2824 int status
8990e307 2825
85e6fe83 2826SysRet
8990e307
LW
2827close(fd)
2828 int fd
2829
85e6fe83 2830SysRet
8990e307
LW
2831dup(fd)
2832 int fd
2833
85e6fe83 2834SysRet
8990e307
LW
2835dup2(fd1, fd2)
2836 int fd1
2837 int fd2
2838
85e6fe83 2839SysRet
a0d0e21e 2840lseek(fd, offset, whence)
85e6fe83
LW
2841 int fd
2842 Off_t offset
2843 int whence
8990e307 2844
85e6fe83 2845SysRet
8990e307
LW
2846nice(incr)
2847 int incr
2848
2849int
8990e307 2850pipe()
85e6fe83
LW
2851 PPCODE:
2852 int fds[2];
85e6fe83
LW
2853 if (pipe(fds) != -1) {
2854 EXTEND(sp,2);
2855 PUSHs(sv_2mortal(newSViv(fds[0])));
2856 PUSHs(sv_2mortal(newSViv(fds[1])));
2857 }
8990e307 2858
85e6fe83 2859SysRet
a0d0e21e
LW
2860read(fd, buffer, nbytes)
2861 int fd
2862 char * buffer = sv_grow(ST(1),SvIV(ST(2))+1);
2863 size_t nbytes
2864 CLEANUP:
2865 if (RETVAL >= 0) {
2866 SvCUR(ST(1)) = RETVAL;
2867 SvPOK_only(ST(1));
2868 *SvEND(ST(1)) = '\0';
2869 if (tainting)
2870 sv_magic(ST(1), 0, 't', 0, 0);
2871 }
8990e307 2872
85e6fe83
LW
2873SysRet
2874setgid(gid)
2875 Gid_t gid
8990e307 2876
85e6fe83 2877SysRet
8990e307
LW
2878setpgid(pid, pgid)
2879 pid_t pid
2880 pid_t pgid
2881
8990e307
LW
2882pid_t
2883setsid()
2884
85e6fe83
LW
2885SysRet
2886setuid(uid)
2887 Uid_t uid
8990e307
LW
2888
2889pid_t
2890tcgetpgrp(fd)
2891 int fd
2892
85e6fe83 2893SysRet
8990e307
LW
2894tcsetpgrp(fd, pgrp_id)
2895 int fd
2896 pid_t pgrp_id
2897
2898int
8990e307 2899uname()
2304df62 2900 PPCODE:
a0d0e21e 2901#ifdef HAS_UNAME
85e6fe83 2902 struct utsname buf;
85e6fe83 2903 if (uname(&buf) >= 0) {
8990e307 2904 EXTEND(sp, 5);
85e6fe83
LW
2905 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
2906 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
2907 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
2908 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
2909 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
8990e307 2910 }
a0d0e21e
LW
2911#else
2912 uname((char *) 0); /* A stub to call not_here(). */
2913#endif
8990e307 2914
85e6fe83 2915SysRet
a0d0e21e
LW
2916write(fd, buffer, nbytes)
2917 int fd
2918 char * buffer
2919 size_t nbytes
2920
2921char *
2922tmpnam(s = 0)
2923 char * s = 0;
2924
2925void
2926abort()
2927
2928int
2929mblen(s, n)
2930 char * s
2931 size_t n
2932
2933size_t
2934mbstowcs(s, pwcs, n)
2935 wchar_t * s
2936 char * pwcs
2937 size_t n
2938
2939int
2940mbtowc(pwc, s, n)
2941 wchar_t * pwc
2942 char * s
2943 size_t n
2944
2945int
2946wcstombs(s, pwcs, n)
2947 char * s
2948 wchar_t * pwcs
2949 size_t n
2950
2951int
2952wctomb(s, wchar)
2953 char * s
2954 wchar_t wchar
2955
2956int
2957strcoll(s1, s2)
2958 char * s1
2959 char * s2
2960
2961SV *
2962strxfrm(src)
2963 SV * src
85e6fe83 2964 CODE:
a0d0e21e
LW
2965 {
2966 STRLEN srclen;
2967 STRLEN dstlen;
2968 char *p = SvPV(src,srclen);
2969 srclen++;
2970 ST(0) = sv_2mortal(newSV(srclen));
2971 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
2972 if (dstlen > srclen) {
2973 dstlen++;
2974 SvGROW(ST(0), dstlen);
2975 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
2976 dstlen--;
2977 }
2978 SvCUR(ST(0)) = dstlen;
2979 SvPOK_only(ST(0));
2980 }
2981
2982SysRet
2983mkfifo(filename, mode)
2984 char * filename
2985 Mode_t mode
2986
2987SysRet
2988tcdrain(fd)
2989 int fd
2990
2991
2992SysRet
2993tcflow(fd, action)
2994 int fd
2995 int action
2996
2997
2998SysRet
2999tcflush(fd, queue_selector)
3000 int fd
3001 int queue_selector
3002
3003SysRet
3004tcsendbreak(fd, duration)
3005 int fd
3006 int duration
3007
3008char *
3009asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3010 int sec
3011 int min
3012 int hour
3013 int mday
3014 int mon
3015 int year
3016 int wday
3017 int yday
3018 int isdst
3019 CODE:
3020 {
3021 struct tm mytm;
3022 mytm.tm_sec = sec;
3023 mytm.tm_min = min;
3024 mytm.tm_hour = hour;
3025 mytm.tm_mday = mday;
3026 mytm.tm_mon = mon;
3027 mytm.tm_year = year;
3028 mytm.tm_wday = wday;
3029 mytm.tm_yday = yday;
3030 mytm.tm_isdst = isdst;
3031 RETVAL = asctime(&mytm);
3032 }
3033 OUTPUT:
3034 RETVAL
3035
3036long
3037clock()
3038
3039char *
3040ctime(time)
3041 Time_t * time
8990e307 3042
a0d0e21e
LW
3043double
3044difftime(time1, time2)
3045 Time_t time1
3046 Time_t time2
3047
3048SysRetLong
3049mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3050 int sec
3051 int min
3052 int hour
3053 int mday
3054 int mon
3055 int year
3056 int wday
3057 int yday
3058 int isdst
3059 CODE:
3060 {
3061 struct tm mytm;
3062 mytm.tm_sec = sec;
3063 mytm.tm_min = min;
3064 mytm.tm_hour = hour;
3065 mytm.tm_mday = mday;
3066 mytm.tm_mon = mon;
3067 mytm.tm_year = year;
3068 mytm.tm_wday = wday;
3069 mytm.tm_yday = yday;
3070 mytm.tm_isdst = isdst;
3071 RETVAL = mktime(&mytm);
3072 }
85e6fe83
LW
3073 OUTPUT:
3074 RETVAL
a0d0e21e
LW
3075
3076char *
3077strftime(fmt, sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3078 char * fmt
3079 int sec
3080 int min
3081 int hour
3082 int mday
3083 int mon
3084 int year
3085 int wday
3086 int yday
3087 int isdst
3088 CODE:
3089 {
3090 char tmpbuf[128];
3091 struct tm mytm;
3092 int len;
3093 mytm.tm_sec = sec;
3094 mytm.tm_min = min;
3095 mytm.tm_hour = hour;
3096 mytm.tm_mday = mday;
3097 mytm.tm_mon = mon;
3098 mytm.tm_year = year;
3099 mytm.tm_wday = wday;
3100 mytm.tm_yday = yday;
3101 mytm.tm_isdst = isdst;
3102 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3103 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3104 }
3105
3106void
3107tzset()
3108
3109void
3110tzname()
3111 PPCODE:
3112 EXTEND(sp,2);
3113 PUSHs(sv_2mortal(newSVpv(tzname[0],strlen(tzname[0]))));
3114 PUSHs(sv_2mortal(newSVpv(tzname[1],strlen(tzname[1]))));
3115
3116SysRet
3117access(filename, mode)
3118 char * filename
3119 Mode_t mode
3120
3121char *
3122ctermid(s = 0)
3123 char * s = 0;
3124
3125char *
3126cuserid(s = 0)
3127 char * s = 0;
3128
3129SysRetLong
3130fpathconf(fd, name)
3131 int fd
3132 int name
3133
3134SysRetLong
3135pathconf(filename, name)
3136 char * filename
3137 int name
3138
3139SysRet
3140pause()
3141
3142SysRetLong
3143sysconf(name)
3144 int name
3145
3146char *
3147ttyname(fd)
3148 int fd