5 #ifdef I_DIRENT /* XXX maybe better to just rely on perl.h? */
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
34 #if defined(I_TERMIOS)
43 #include <sys/times.h>
44 #include <sys/types.h>
46 #include <sys/utsname.h>
56 typedef long SysRetLong;
57 typedef sigset_t* POSIX__SigSet;
58 typedef HV* POSIX__SigAction;
60 typedef struct termios* POSIX__Termios;
61 #else /* Define termios types to int, and call not_here for the functions.*/
62 #define POSIX__Termios int
66 #define cfgetispeed(x) not_here("cfgetispeed")
67 #define cfgetospeed(x) not_here("cfgetospeed")
68 #define tcdrain(x) not_here("tcdrain")
69 #define tcflush(x,y) not_here("tcflush")
70 #define tcsendbreak(x,y) not_here("tcsendbreak")
71 #define cfsetispeed(x,y) not_here("cfsetispeed")
72 #define cfsetospeed(x,y) not_here("cfsetospeed")
73 #define ctermid(x) (char *) not_here("ctermid")
74 #define tcflow(x,y) not_here("tcflow")
75 #define tcgetattr(x,y) not_here("tcgetattr")
76 #define tcsetattr(x,y,z) not_here("tcsetattr")
79 /* Possibly needed prototypes */
80 char *cuserid _((char *));
83 #define cuserid(a) (char *) not_here("cuserid")
87 #define difftime(a,b) not_here("difftime")
91 #define fpathconf(f,n) (SysRetLong) not_here("fpathconf")
94 #define mktime(a) not_here("mktime")
97 #define nice(a) not_here("nice")
100 #define pathconf(f,n) (SysRetLong) not_here("pathconf")
103 #define sysconf(n) (SysRetLong) not_here("sysconf")
106 #define readlink(a,b,c) not_here("readlink")
109 #define setpgid(a,b) not_here("setpgid")
112 #define setsid() not_here("setsid")
115 #define strcoll(s1,s2) not_here("strcoll")
118 #define strxfrm(s1,s2,n) not_here("strxfrm")
120 #ifndef HAS_TCGETPGRP
121 #define tcgetpgrp(a) not_here("tcgetpgrp")
123 #ifndef HAS_TCSETPGRP
124 #define tcsetpgrp(a,b) not_here("tcsetpgrp")
127 #define times(a) not_here("times")
130 #define uname(a) not_here("uname")
133 #define waitpid(a,b,c) not_here("waitpid")
137 #define fgetpos(a,b) not_here("fgetpos")
140 #define fsetpos(a,b) not_here("fsetpos")
145 #define mblen(a,b) not_here("mblen")
149 #define mbstowcs(s, pwcs, n) not_here("mbstowcs")
152 #define mbtowc(pwc, s, n) not_here("mbtowc")
155 #define wcstombs(s, pwcs, n) not_here("wcstombs")
158 #define wctomb(s, wchar) not_here("wcstombs")
160 #if !defined(HAS_MBLEN) && !defined(HAS_MBSTOWCS) && !defined(HAS_MBTOWC) && !defined(HAS_WCSTOMBS) && !defined(HAS_WCTOMB)
161 /* If we don't have these functions, then we wouldn't have gotten a typedef
162 for wchar_t, the wide character type. Defining wchar_t allows the
163 functions referencing it to compile. Its actual type is then meaningless,
164 since without the above functions, all sections using it end up calling
165 not_here() and croak. --Kaveh Ghazi (ghazi@noc.rutgers.edu) 9/18/94. */
171 #ifndef HAS_LOCALECONV
172 #define localeconv() not_here("localeconv")
176 extern char *tzname[];
178 char *tzname[] = { "" , "" };
181 /* XXX struct tm on some systems (SunOS4/BSD) contains extra (non POSIX)
182 * fields for which we don't have Configure support yet:
183 * char *tm_zone; -- abbreviation of timezone name
184 * long tm_gmtoff; -- offset from GMT in seconds
185 * To workaround core dumps from the uninitialised tm_zone we get the
186 * system to give us a reasonable struct to copy. This fix means that
187 * strftime uses the tm_zone and tm_gmtoff values returned by
188 * localtime(time()). That should give the desired result most of the
189 * time. But probably not always!
191 * This is a temporary workaround to be removed once Configure
192 * support is added and NETaa14816 is considered in full.
193 * It does not address tzname aspects of NETaa14816.
195 #ifdef STRUCT_TM_HASZONE
197 init_tm(ptm) /* see mktime, strftime and asctime */
202 Copy(localtime(&now), ptm, 1, struct tm);
206 # define init_tm(ptm)
210 #ifndef HAS_LONG_DOUBLE /* XXX What to do about long doubles? */
226 croak("POSIX::%s not implemented on this architecture", s);
238 if (strEQ(name, "ARG_MAX"))
246 if (strEQ(name, "BUFSIZ"))
252 if (strEQ(name, "BRKINT"))
258 if (strEQ(name, "B9600"))
264 if (strEQ(name, "B19200"))
270 if (strEQ(name, "B38400"))
276 if (strEQ(name, "B0"))
282 if (strEQ(name, "B110"))
288 if (strEQ(name, "B1200"))
294 if (strEQ(name, "B134"))
300 if (strEQ(name, "B150"))
306 if (strEQ(name, "B1800"))
312 if (strEQ(name, "B200"))
318 if (strEQ(name, "B2400"))
324 if (strEQ(name, "B300"))
330 if (strEQ(name, "B4800"))
336 if (strEQ(name, "B50"))
342 if (strEQ(name, "B600"))
348 if (strEQ(name, "B75"))
356 if (strEQ(name, "CHAR_BIT"))
362 if (strEQ(name, "CHAR_MAX"))
368 if (strEQ(name, "CHAR_MIN"))
374 if (strEQ(name, "CHILD_MAX"))
380 if (strEQ(name, "CLK_TCK"))
386 if (strEQ(name, "CLOCAL"))
392 if (strEQ(name, "CLOCKS_PER_SEC"))
393 #ifdef CLOCKS_PER_SEC
394 return CLOCKS_PER_SEC;
398 if (strEQ(name, "CREAD"))
404 if (strEQ(name, "CS5"))
410 if (strEQ(name, "CS6"))
416 if (strEQ(name, "CS7"))
422 if (strEQ(name, "CS8"))
428 if (strEQ(name, "CSIZE"))
434 if (strEQ(name, "CSTOPB"))
442 if (strEQ(name, "DBL_MAX"))
448 if (strEQ(name, "DBL_MIN"))
454 if (strEQ(name, "DBL_DIG"))
460 if (strEQ(name, "DBL_EPSILON"))
466 if (strEQ(name, "DBL_MANT_DIG"))
472 if (strEQ(name, "DBL_MAX_10_EXP"))
473 #ifdef DBL_MAX_10_EXP
474 return DBL_MAX_10_EXP;
478 if (strEQ(name, "DBL_MAX_EXP"))
484 if (strEQ(name, "DBL_MIN_10_EXP"))
485 #ifdef DBL_MIN_10_EXP
486 return DBL_MIN_10_EXP;
490 if (strEQ(name, "DBL_MIN_EXP"))
500 if (strEQ(name, "EACCES"))
506 if (strEQ(name, "EAGAIN"))
514 if (strEQ(name, "EBADF"))
520 if (strEQ(name, "EBUSY"))
528 if (strEQ(name, "ECHILD"))
534 if (strEQ(name, "ECHO"))
540 if (strEQ(name, "ECHOE"))
546 if (strEQ(name, "ECHOK"))
552 if (strEQ(name, "ECHONL"))
560 if (strEQ(name, "EDEADLK"))
566 if (strEQ(name, "EDOM"))
574 if (strEQ(name, "EEXIST"))
582 if (strEQ(name, "EFAULT"))
588 if (strEQ(name, "EFBIG"))
596 if (strEQ(name, "EINTR"))
602 if (strEQ(name, "EINVAL"))
608 if (strEQ(name, "EIO"))
614 if (strEQ(name, "EISDIR"))
622 if (strEQ(name, "EMFILE"))
628 if (strEQ(name, "EMLINK"))
636 if (strEQ(name, "ENOMEM"))
642 if (strEQ(name, "ENOSPC"))
648 if (strEQ(name, "ENOEXEC"))
654 if (strEQ(name, "ENOTTY"))
660 if (strEQ(name, "ENOTDIR"))
666 if (strEQ(name, "ENOTEMPTY"))
672 if (strEQ(name, "ENFILE"))
678 if (strEQ(name, "ENODEV"))
684 if (strEQ(name, "ENOENT"))
690 if (strEQ(name, "ENOLCK"))
696 if (strEQ(name, "ENOSYS"))
702 if (strEQ(name, "ENXIO"))
708 if (strEQ(name, "ENAMETOOLONG"))
716 if (strEQ(name, "EOF"))
724 if (strEQ(name, "EPERM"))
730 if (strEQ(name, "EPIPE"))
738 if (strEQ(name, "ERANGE"))
744 if (strEQ(name, "EROFS"))
752 if (strEQ(name, "ESPIPE"))
758 if (strEQ(name, "ESRCH"))
766 if (strEQ(name, "EXIT_FAILURE"))
772 if (strEQ(name, "EXIT_SUCCESS"))
778 if (strEQ(name, "EXDEV"))
786 if (strEQ(name, "E2BIG"))
794 if (strnEQ(name, "FLT_", 4)) {
795 if (strEQ(name, "FLT_MAX"))
801 if (strEQ(name, "FLT_MIN"))
807 if (strEQ(name, "FLT_ROUNDS"))
813 if (strEQ(name, "FLT_DIG"))
819 if (strEQ(name, "FLT_EPSILON"))
825 if (strEQ(name, "FLT_MANT_DIG"))
831 if (strEQ(name, "FLT_MAX_10_EXP"))
832 #ifdef FLT_MAX_10_EXP
833 return FLT_MAX_10_EXP;
837 if (strEQ(name, "FLT_MAX_EXP"))
843 if (strEQ(name, "FLT_MIN_10_EXP"))
844 #ifdef FLT_MIN_10_EXP
845 return FLT_MIN_10_EXP;
849 if (strEQ(name, "FLT_MIN_EXP"))
855 if (strEQ(name, "FLT_RADIX"))
863 if (strnEQ(name, "F_", 2)) {
864 if (strEQ(name, "F_DUPFD"))
870 if (strEQ(name, "F_GETFD"))
876 if (strEQ(name, "F_GETFL"))
882 if (strEQ(name, "F_GETLK"))
888 if (strEQ(name, "F_OK"))
894 if (strEQ(name, "F_RDLCK"))
900 if (strEQ(name, "F_SETFD"))
906 if (strEQ(name, "F_SETFL"))
912 if (strEQ(name, "F_SETLK"))
918 if (strEQ(name, "F_SETLKW"))
924 if (strEQ(name, "F_UNLCK"))
930 if (strEQ(name, "F_WRLCK"))
938 if (strEQ(name, "FD_CLOEXEC"))
944 if (strEQ(name, "FILENAME_MAX"))
952 if (strEQ(name, "HUGE_VAL"))
958 if (strEQ(name, "HUPCL"))
966 if (strEQ(name, "INT_MAX"))
972 if (strEQ(name, "INT_MIN"))
978 if (strEQ(name, "ICANON"))
984 if (strEQ(name, "ICRNL"))
990 if (strEQ(name, "IEXTEN"))
996 if (strEQ(name, "IGNBRK"))
1002 if (strEQ(name, "IGNCR"))
1008 if (strEQ(name, "IGNPAR"))
1014 if (strEQ(name, "INLCR"))
1020 if (strEQ(name, "INPCK"))
1026 if (strEQ(name, "ISIG"))
1032 if (strEQ(name, "ISTRIP"))
1038 if (strEQ(name, "IXOFF"))
1044 if (strEQ(name, "IXON"))
1052 if (strnEQ(name, "LC_", 3)) {
1053 if (strEQ(name, "LC_ALL"))
1059 if (strEQ(name, "LC_COLLATE"))
1065 if (strEQ(name, "LC_CTYPE"))
1071 if (strEQ(name, "LC_MONETARY"))
1077 if (strEQ(name, "LC_NUMERIC"))
1083 if (strEQ(name, "LC_TIME"))
1091 if (strnEQ(name, "LDBL_", 5)) {
1092 if (strEQ(name, "LDBL_MAX"))
1098 if (strEQ(name, "LDBL_MIN"))
1104 if (strEQ(name, "LDBL_DIG"))
1110 if (strEQ(name, "LDBL_EPSILON"))
1112 return LDBL_EPSILON;
1116 if (strEQ(name, "LDBL_MANT_DIG"))
1117 #ifdef LDBL_MANT_DIG
1118 return LDBL_MANT_DIG;
1122 if (strEQ(name, "LDBL_MAX_10_EXP"))
1123 #ifdef LDBL_MAX_10_EXP
1124 return LDBL_MAX_10_EXP;
1128 if (strEQ(name, "LDBL_MAX_EXP"))
1130 return LDBL_MAX_EXP;
1134 if (strEQ(name, "LDBL_MIN_10_EXP"))
1135 #ifdef LDBL_MIN_10_EXP
1136 return LDBL_MIN_10_EXP;
1140 if (strEQ(name, "LDBL_MIN_EXP"))
1142 return LDBL_MIN_EXP;
1148 if (strnEQ(name, "L_", 2)) {
1149 if (strEQ(name, "L_ctermid"))
1155 if (strEQ(name, "L_cuserid"))
1161 if (strEQ(name, "L_tmpname"))
1169 if (strEQ(name, "LONG_MAX"))
1175 if (strEQ(name, "LONG_MIN"))
1181 if (strEQ(name, "LINK_MAX"))
1189 if (strEQ(name, "MAX_CANON"))
1195 if (strEQ(name, "MAX_INPUT"))
1201 if (strEQ(name, "MB_CUR_MAX"))
1207 if (strEQ(name, "MB_LEN_MAX"))
1215 if (strEQ(name, "NULL")) return 0;
1216 if (strEQ(name, "NAME_MAX"))
1222 if (strEQ(name, "NCCS"))
1228 if (strEQ(name, "NGROUPS_MAX"))
1234 if (strEQ(name, "NOFLSH"))
1242 if (strnEQ(name, "O_", 2)) {
1243 if (strEQ(name, "O_APPEND"))
1249 if (strEQ(name, "O_CREAT"))
1255 if (strEQ(name, "O_TRUNC"))
1261 if (strEQ(name, "O_RDONLY"))
1267 if (strEQ(name, "O_RDWR"))
1273 if (strEQ(name, "O_WRONLY"))
1279 if (strEQ(name, "O_EXCL"))
1285 if (strEQ(name, "O_NOCTTY"))
1291 if (strEQ(name, "O_NONBLOCK"))
1297 if (strEQ(name, "O_ACCMODE"))
1305 if (strEQ(name, "OPEN_MAX"))
1311 if (strEQ(name, "OPOST"))
1319 if (strEQ(name, "PATH_MAX"))
1325 if (strEQ(name, "PARENB"))
1331 if (strEQ(name, "PARMRK"))
1337 if (strEQ(name, "PARODD"))
1343 if (strEQ(name, "PIPE_BUF"))
1351 if (strEQ(name, "RAND_MAX"))
1357 if (strEQ(name, "R_OK"))
1365 if (strnEQ(name, "SIG", 3)) {
1366 if (name[3] == '_') {
1367 if (strEQ(name, "SIG_BLOCK"))
1374 if (strEQ(name, "SIG_DFL")) return (int)SIG_DFL;
1377 if (strEQ(name, "SIG_ERR")) return (int)SIG_ERR;
1380 if (strEQ(name, "SIG_IGN")) return (int)SIG_IGN;
1382 if (strEQ(name, "SIG_SETMASK"))
1388 if (strEQ(name, "SIG_UNBLOCK"))
1396 if (strEQ(name, "SIGABRT"))
1402 if (strEQ(name, "SIGALRM"))
1408 if (strEQ(name, "SIGCHLD"))
1414 if (strEQ(name, "SIGCONT"))
1420 if (strEQ(name, "SIGFPE"))
1426 if (strEQ(name, "SIGHUP"))
1432 if (strEQ(name, "SIGILL"))
1438 if (strEQ(name, "SIGINT"))
1444 if (strEQ(name, "SIGKILL"))
1450 if (strEQ(name, "SIGPIPE"))
1456 if (strEQ(name, "SIGQUIT"))
1462 if (strEQ(name, "SIGSEGV"))
1468 if (strEQ(name, "SIGSTOP"))
1474 if (strEQ(name, "SIGTERM"))
1480 if (strEQ(name, "SIGTSTP"))
1486 if (strEQ(name, "SIGTTIN"))
1492 if (strEQ(name, "SIGTTOU"))
1498 if (strEQ(name, "SIGUSR1"))
1504 if (strEQ(name, "SIGUSR2"))
1512 if (name[1] == '_') {
1513 if (strEQ(name, "S_ISGID"))
1519 if (strEQ(name, "S_ISUID"))
1525 if (strEQ(name, "S_IRGRP"))
1531 if (strEQ(name, "S_IROTH"))
1537 if (strEQ(name, "S_IRUSR"))
1543 if (strEQ(name, "S_IRWXG"))
1549 if (strEQ(name, "S_IRWXO"))
1555 if (strEQ(name, "S_IRWXU"))
1561 if (strEQ(name, "S_IWGRP"))
1567 if (strEQ(name, "S_IWOTH"))
1573 if (strEQ(name, "S_IWUSR"))
1579 if (strEQ(name, "S_IXGRP"))
1585 if (strEQ(name, "S_IXOTH"))
1591 if (strEQ(name, "S_IXUSR"))
1597 errno = EAGAIN; /* the following aren't constants */
1599 if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg);
1602 if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg);
1605 if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg);
1608 if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg);
1611 if (strEQ(name, "S_ISREG")) return S_ISREG(arg);
1615 if (strEQ(name, "SEEK_CUR"))
1621 if (strEQ(name, "SEEK_END"))
1627 if (strEQ(name, "SEEK_SET"))
1633 if (strEQ(name, "STREAM_MAX"))
1639 if (strEQ(name, "SHRT_MAX"))
1645 if (strEQ(name, "SHRT_MIN"))
1651 if (strEQ(name, "SA_NOCLDSTOP"))
1653 return SA_NOCLDSTOP;
1657 if (strEQ(name, "SCHAR_MAX"))
1663 if (strEQ(name, "SCHAR_MIN"))
1669 if (strEQ(name, "SSIZE_MAX"))
1675 if (strEQ(name, "STDIN_FILENO"))
1677 return STDIN_FILENO;
1681 if (strEQ(name, "STDOUT_FILENO"))
1682 #ifdef STDOUT_FILENO
1683 return STDOUT_FILENO;
1687 if (strEQ(name, "STRERR_FILENO"))
1688 #ifdef STRERR_FILENO
1689 return STRERR_FILENO;
1695 if (strEQ(name, "TCIFLUSH"))
1701 if (strEQ(name, "TCIOFF"))
1707 if (strEQ(name, "TCIOFLUSH"))
1713 if (strEQ(name, "TCION"))
1719 if (strEQ(name, "TCOFLUSH"))
1725 if (strEQ(name, "TCOOFF"))
1731 if (strEQ(name, "TCOON"))
1737 if (strEQ(name, "TCSADRAIN"))
1743 if (strEQ(name, "TCSAFLUSH"))
1749 if (strEQ(name, "TCSANOW"))
1755 if (strEQ(name, "TMP_MAX"))
1761 if (strEQ(name, "TOSTOP"))
1767 if (strEQ(name, "TZNAME_MAX"))
1775 if (strEQ(name, "UCHAR_MAX"))
1781 if (strEQ(name, "UINT_MAX"))
1787 if (strEQ(name, "ULONG_MAX"))
1793 if (strEQ(name, "USHRT_MAX"))
1801 if (strEQ(name, "VEOF"))
1807 if (strEQ(name, "VEOL"))
1813 if (strEQ(name, "VERASE"))
1819 if (strEQ(name, "VINTR"))
1825 if (strEQ(name, "VKILL"))
1831 if (strEQ(name, "VMIN"))
1837 if (strEQ(name, "VQUIT"))
1843 if (strEQ(name, "VSTART"))
1849 if (strEQ(name, "VSTOP"))
1855 if (strEQ(name, "VSUSP"))
1861 if (strEQ(name, "VTIME"))
1869 if (strEQ(name, "W_OK"))
1875 if (strEQ(name, "WNOHANG"))
1881 if (strEQ(name, "WUNTRACED"))
1887 errno = EAGAIN; /* the following aren't constants */
1889 if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg);
1892 if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg);
1895 if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg);
1898 if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg);
1901 if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg);
1904 if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg);
1908 if (strEQ(name, "X_OK"))
1916 if (strnEQ(name, "_PC_", 4)) {
1917 if (strEQ(name, "_PC_CHOWN_RESTRICTED"))
1918 #ifdef _PC_CHOWN_RESTRICTED
1919 return _PC_CHOWN_RESTRICTED;
1923 if (strEQ(name, "_PC_LINK_MAX"))
1925 return _PC_LINK_MAX;
1929 if (strEQ(name, "_PC_MAX_CANON"))
1930 #ifdef _PC_MAX_CANON
1931 return _PC_MAX_CANON;
1935 if (strEQ(name, "_PC_MAX_INPUT"))
1936 #ifdef _PC_MAX_INPUT
1937 return _PC_MAX_INPUT;
1941 if (strEQ(name, "_PC_NAME_MAX"))
1943 return _PC_NAME_MAX;
1947 if (strEQ(name, "_PC_NO_TRUNC"))
1949 return _PC_NO_TRUNC;
1953 if (strEQ(name, "_PC_PATH_MAX"))
1955 return _PC_PATH_MAX;
1959 if (strEQ(name, "_PC_PIPE_BUF"))
1961 return _PC_PIPE_BUF;
1965 if (strEQ(name, "_PC_VDISABLE"))
1967 return _PC_VDISABLE;
1973 if (strnEQ(name, "_POSIX_", 7)) {
1974 if (strEQ(name, "_POSIX_ARG_MAX"))
1975 #ifdef _POSIX_ARG_MAX
1976 return _POSIX_ARG_MAX;
1980 if (strEQ(name, "_POSIX_CHILD_MAX"))
1981 #ifdef _POSIX_CHILD_MAX
1982 return _POSIX_CHILD_MAX;
1986 if (strEQ(name, "_POSIX_CHOWN_RESTRICTED"))
1987 #ifdef _POSIX_CHOWN_RESTRICTED
1988 return _POSIX_CHOWN_RESTRICTED;
1992 if (strEQ(name, "_POSIX_JOB_CONTROL"))
1993 #ifdef _POSIX_JOB_CONTROL
1994 return _POSIX_JOB_CONTROL;
1998 if (strEQ(name, "_POSIX_LINK_MAX"))
1999 #ifdef _POSIX_LINK_MAX
2000 return _POSIX_LINK_MAX;
2004 if (strEQ(name, "_POSIX_MAX_CANON"))
2005 #ifdef _POSIX_MAX_CANON
2006 return _POSIX_MAX_CANON;
2010 if (strEQ(name, "_POSIX_MAX_INPUT"))
2011 #ifdef _POSIX_MAX_INPUT
2012 return _POSIX_MAX_INPUT;
2016 if (strEQ(name, "_POSIX_NAME_MAX"))
2017 #ifdef _POSIX_NAME_MAX
2018 return _POSIX_NAME_MAX;
2022 if (strEQ(name, "_POSIX_NGROUPS_MAX"))
2023 #ifdef _POSIX_NGROUPS_MAX
2024 return _POSIX_NGROUPS_MAX;
2028 if (strEQ(name, "_POSIX_NO_TRUNC"))
2029 #ifdef _POSIX_NO_TRUNC
2030 return _POSIX_NO_TRUNC;
2034 if (strEQ(name, "_POSIX_OPEN_MAX"))
2035 #ifdef _POSIX_OPEN_MAX
2036 return _POSIX_OPEN_MAX;
2040 if (strEQ(name, "_POSIX_PATH_MAX"))
2041 #ifdef _POSIX_PATH_MAX
2042 return _POSIX_PATH_MAX;
2046 if (strEQ(name, "_POSIX_PIPE_BUF"))
2047 #ifdef _POSIX_PIPE_BUF
2048 return _POSIX_PIPE_BUF;
2052 if (strEQ(name, "_POSIX_SAVED_IDS"))
2053 #ifdef _POSIX_SAVED_IDS
2054 return _POSIX_SAVED_IDS;
2058 if (strEQ(name, "_POSIX_SSIZE_MAX"))
2059 #ifdef _POSIX_SSIZE_MAX
2060 return _POSIX_SSIZE_MAX;
2064 if (strEQ(name, "_POSIX_STREAM_MAX"))
2065 #ifdef _POSIX_STREAM_MAX
2066 return _POSIX_STREAM_MAX;
2070 if (strEQ(name, "_POSIX_TZNAME_MAX"))
2071 #ifdef _POSIX_TZNAME_MAX
2072 return _POSIX_TZNAME_MAX;
2076 if (strEQ(name, "_POSIX_VDISABLE"))
2077 #ifdef _POSIX_VDISABLE
2078 return _POSIX_VDISABLE;
2082 if (strEQ(name, "_POSIX_VERSION"))
2083 #ifdef _POSIX_VERSION
2084 return _POSIX_VERSION;
2090 if (strnEQ(name, "_SC_", 4)) {
2091 if (strEQ(name, "_SC_ARG_MAX"))
2097 if (strEQ(name, "_SC_CHILD_MAX"))
2098 #ifdef _SC_CHILD_MAX
2099 return _SC_CHILD_MAX;
2103 if (strEQ(name, "_SC_CLK_TCK"))
2109 if (strEQ(name, "_SC_JOB_CONTROL"))
2110 #ifdef _SC_JOB_CONTROL
2111 return _SC_JOB_CONTROL;
2115 if (strEQ(name, "_SC_NGROUPS_MAX"))
2116 #ifdef _SC_NGROUPS_MAX
2117 return _SC_NGROUPS_MAX;
2121 if (strEQ(name, "_SC_OPEN_MAX"))
2123 return _SC_OPEN_MAX;
2127 if (strEQ(name, "_SC_SAVED_IDS"))
2128 #ifdef _SC_SAVED_IDS
2129 return _SC_SAVED_IDS;
2133 if (strEQ(name, "_SC_STREAM_MAX"))
2134 #ifdef _SC_STREAM_MAX
2135 return _SC_STREAM_MAX;
2139 if (strEQ(name, "_SC_TZNAME_MAX"))
2140 #ifdef _SC_TZNAME_MAX
2141 return _SC_TZNAME_MAX;
2145 if (strEQ(name, "_SC_VERSION"))
2162 MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig
2165 new(packname = "POSIX::SigSet", ...)
2170 RETVAL = (sigset_t*)safemalloc(sizeof(sigset_t));
2171 sigemptyset(RETVAL);
2172 for (i = 1; i < items; i++)
2173 sigaddset(RETVAL, SvIV(ST(i)));
2180 POSIX::SigSet sigset
2182 safefree((char *)sigset);
2185 sigaddset(sigset, sig)
2186 POSIX::SigSet sigset
2190 sigdelset(sigset, sig)
2191 POSIX::SigSet sigset
2196 POSIX::SigSet sigset
2200 POSIX::SigSet sigset
2203 sigismember(sigset, sig)
2204 POSIX::SigSet sigset
2208 MODULE = Termios PACKAGE = POSIX::Termios PREFIX = cf
2211 new(packname = "POSIX::Termios", ...)
2216 RETVAL = (struct termios*)safemalloc(sizeof(struct termios));
2218 not_here("termios");
2225 DESTROY(termios_ref)
2226 POSIX::Termios termios_ref
2229 safefree((char *)termios_ref);
2231 not_here("termios");
2235 getattr(termios_ref, fd = 0)
2236 POSIX::Termios termios_ref
2239 RETVAL = tcgetattr(fd, termios_ref);
2244 setattr(termios_ref, fd = 0, optional_actions = 0)
2245 POSIX::Termios termios_ref
2247 int optional_actions
2249 RETVAL = tcsetattr(fd, optional_actions, termios_ref);
2254 cfgetispeed(termios_ref)
2255 POSIX::Termios termios_ref
2258 cfgetospeed(termios_ref)
2259 POSIX::Termios termios_ref
2262 getiflag(termios_ref)
2263 POSIX::Termios termios_ref
2265 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2266 RETVAL = termios_ref->c_iflag;
2268 not_here("getiflag");
2274 getoflag(termios_ref)
2275 POSIX::Termios termios_ref
2277 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2278 RETVAL = termios_ref->c_oflag;
2280 not_here("getoflag");
2286 getcflag(termios_ref)
2287 POSIX::Termios termios_ref
2289 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2290 RETVAL = termios_ref->c_cflag;
2292 not_here("getcflag");
2298 getlflag(termios_ref)
2299 POSIX::Termios termios_ref
2301 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2302 RETVAL = termios_ref->c_lflag;
2304 not_here("getlflag");
2310 getcc(termios_ref, ccix)
2311 POSIX::Termios termios_ref
2314 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2316 croak("Bad getcc subscript");
2317 RETVAL = termios_ref->c_cc[ccix];
2325 cfsetispeed(termios_ref, speed)
2326 POSIX::Termios termios_ref
2330 cfsetospeed(termios_ref, speed)
2331 POSIX::Termios termios_ref
2335 setiflag(termios_ref, iflag)
2336 POSIX::Termios termios_ref
2339 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2340 termios_ref->c_iflag = iflag;
2342 not_here("setiflag");
2346 setoflag(termios_ref, oflag)
2347 POSIX::Termios termios_ref
2350 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2351 termios_ref->c_oflag = oflag;
2353 not_here("setoflag");
2357 setcflag(termios_ref, cflag)
2358 POSIX::Termios termios_ref
2361 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2362 termios_ref->c_cflag = cflag;
2364 not_here("setcflag");
2368 setlflag(termios_ref, lflag)
2369 POSIX::Termios termios_ref
2372 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2373 termios_ref->c_lflag = lflag;
2375 not_here("setlflag");
2379 setcc(termios_ref, ccix, cc)
2380 POSIX::Termios termios_ref
2384 #ifdef I_TERMIOS /* References a termios structure member so ifdef it out. */
2386 croak("Bad setcc subscript");
2387 termios_ref->c_cc[ccix] = cc;
2393 MODULE = POSIX PACKAGE = POSIX
2406 for (s = charstring; *s && RETVAL; s++)
2418 for (s = charstring; *s && RETVAL; s++)
2430 for (s = charstring; *s && RETVAL; s++)
2442 for (s = charstring; *s && RETVAL; s++)
2454 for (s = charstring; *s && RETVAL; s++)
2466 for (s = charstring; *s && RETVAL; s++)
2478 for (s = charstring; *s && RETVAL; s++)
2490 for (s = charstring; *s && RETVAL; s++)
2502 for (s = charstring; *s && RETVAL; s++)
2514 for (s = charstring; *s && RETVAL; s++)
2521 isxdigit(charstring)
2526 for (s = charstring; *s && RETVAL; s++)
2533 open(filename, flags = O_RDONLY, mode = 0666)
2538 if (flags & (O_APPEND|O_CREAT|O_TRUNC|O_RDWR|O_WRONLY|O_EXCL))
2539 TAINT_PROPER("open");
2540 RETVAL = open(filename, flags, mode);
2548 #ifdef HAS_LOCALECONV
2549 struct lconv *lcbuf;
2551 if (lcbuf = localeconv()) {
2553 if (lcbuf->decimal_point && *lcbuf->decimal_point)
2554 hv_store(RETVAL, "decimal_point", 13,
2555 newSVpv(lcbuf->decimal_point, 0), 0);
2556 if (lcbuf->thousands_sep && *lcbuf->thousands_sep)
2557 hv_store(RETVAL, "thousands_sep", 13,
2558 newSVpv(lcbuf->thousands_sep, 0), 0);
2559 if (lcbuf->grouping && *lcbuf->grouping)
2560 hv_store(RETVAL, "grouping", 8,
2561 newSVpv(lcbuf->grouping, 0), 0);
2562 if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol)
2563 hv_store(RETVAL, "int_curr_symbol", 15,
2564 newSVpv(lcbuf->int_curr_symbol, 0), 0);
2565 if (lcbuf->currency_symbol && *lcbuf->currency_symbol)
2566 hv_store(RETVAL, "currency_symbol", 15,
2567 newSVpv(lcbuf->currency_symbol, 0), 0);
2568 if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point)
2569 hv_store(RETVAL, "mon_decimal_point", 17,
2570 newSVpv(lcbuf->mon_decimal_point, 0), 0);
2571 if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep)
2572 hv_store(RETVAL, "mon_thousands_sep", 17,
2573 newSVpv(lcbuf->mon_thousands_sep, 0), 0);
2574 if (lcbuf->mon_grouping && *lcbuf->mon_grouping)
2575 hv_store(RETVAL, "mon_grouping", 12,
2576 newSVpv(lcbuf->mon_grouping, 0), 0);
2577 if (lcbuf->positive_sign && *lcbuf->positive_sign)
2578 hv_store(RETVAL, "positive_sign", 13,
2579 newSVpv(lcbuf->positive_sign, 0), 0);
2580 if (lcbuf->negative_sign && *lcbuf->negative_sign)
2581 hv_store(RETVAL, "negative_sign", 13,
2582 newSVpv(lcbuf->negative_sign, 0), 0);
2584 if (lcbuf->int_frac_digits != CHAR_MAX)
2585 hv_store(RETVAL, "int_frac_digits", 15,
2586 newSViv(lcbuf->int_frac_digits), 0);
2587 if (lcbuf->frac_digits != CHAR_MAX)
2588 hv_store(RETVAL, "frac_digits", 11,
2589 newSViv(lcbuf->frac_digits), 0);
2590 if (lcbuf->p_cs_precedes != CHAR_MAX)
2591 hv_store(RETVAL, "p_cs_precedes", 13,
2592 newSViv(lcbuf->p_cs_precedes), 0);
2593 if (lcbuf->p_sep_by_space != CHAR_MAX)
2594 hv_store(RETVAL, "p_sep_by_space", 14,
2595 newSViv(lcbuf->p_sep_by_space), 0);
2596 if (lcbuf->n_cs_precedes != CHAR_MAX)
2597 hv_store(RETVAL, "n_cs_precedes", 13,
2598 newSViv(lcbuf->n_cs_precedes), 0);
2599 if (lcbuf->n_sep_by_space != CHAR_MAX)
2600 hv_store(RETVAL, "n_sep_by_space", 14,
2601 newSViv(lcbuf->n_sep_by_space), 0);
2602 if (lcbuf->p_sign_posn != CHAR_MAX)
2603 hv_store(RETVAL, "p_sign_posn", 11,
2604 newSViv(lcbuf->p_sign_posn), 0);
2605 if (lcbuf->n_sign_posn != CHAR_MAX)
2606 hv_store(RETVAL, "n_sign_posn", 11,
2607 newSViv(lcbuf->n_sign_posn), 0);
2610 localeconv(); /* A stub to call not_here(). */
2616 setlocale(category, locale)
2654 /* (We already know stack is long enough.) */
2655 PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar))));
2656 PUSHs(sv_2mortal(newSViv(expvar)));
2672 /* (We already know stack is long enough.) */
2673 PUSHs(sv_2mortal(newSVnv(modf(x,&intvar))));
2674 PUSHs(sv_2mortal(newSVnv(intvar)));
2689 sigaction(sig, action, oldaction = 0)
2691 POSIX::SigAction action
2692 POSIX::SigAction oldaction
2695 # This code is really grody because we're trying to make the signal
2696 # interface look beautiful, which is hard.
2699 gv_fetchpv("SIG", TRUE, SVt_PVHV);
2702 struct sigaction act;
2703 struct sigaction oact;
2704 POSIX__SigSet sigset;
2706 SV** sigsvp = hv_fetch(GvHVn(siggv),
2708 strlen(sig_name[sig]),
2711 /* Remember old handler name if desired. */
2713 char *hand = SvPVx(*sigsvp, na);
2714 svp = hv_fetch(oldaction, "HANDLER", 7, TRUE);
2715 sv_setpv(*svp, *hand ? hand : "DEFAULT");
2719 /* Vector new handler through %SIG. (We always use sighandler
2720 for the C signal handler, which reads %SIG to dispatch.) */
2721 svp = hv_fetch(action, "HANDLER", 7, FALSE);
2723 croak("Can't supply an action without a HANDLER");
2724 sv_setpv(*sigsvp, SvPV(*svp, na));
2725 mg_set(*sigsvp); /* handles DEFAULT and IGNORE */
2726 act.sa_handler = sighandler;
2728 /* Set up any desired mask. */
2729 svp = hv_fetch(action, "MASK", 4, FALSE);
2730 if (svp && sv_isa(*svp, "POSIX::SigSet")) {
2732 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
2733 sigset = (sigset_t*) tmp;
2734 act.sa_mask = *sigset;
2737 sigemptyset(& act.sa_mask);
2739 /* Set up any desired flags. */
2740 svp = hv_fetch(action, "FLAGS", 5, FALSE);
2741 act.sa_flags = svp ? SvIV(*svp) : 0;
2744 /* Now work around sigaction oddities */
2745 if (action && oldaction)
2746 RETVAL = sigaction(sig, & act, & oact);
2748 RETVAL = sigaction(sig, & act, (struct sigaction*)0);
2750 RETVAL = sigaction(sig, (struct sigaction*)0, & oact);
2755 /* Get back the mask. */
2756 svp = hv_fetch(oldaction, "MASK", 4, TRUE);
2757 if (sv_isa(*svp, "POSIX::SigSet")) {
2759 tmp = (unsigned long)SvNV((SV*)SvRV(*svp));
2760 sigset = (sigset_t*) tmp;
2763 sigset = (sigset_t*)safemalloc(sizeof(sigset_t));
2764 sv_setptrobj(*svp, sigset, "POSIX::SigSet");
2766 *sigset = oact.sa_mask;
2768 /* Get back the flags. */
2769 svp = hv_fetch(oldaction, "FLAGS", 5, TRUE);
2770 sv_setiv(*svp, oact.sa_flags);
2778 POSIX::SigSet sigset
2781 sigprocmask(how, sigset, oldsigset = 0)
2783 POSIX::SigSet sigset
2784 POSIX::SigSet oldsigset
2787 sigsuspend(signal_mask)
2788 POSIX::SigSet signal_mask
2808 lseek(fd, offset, whence)
2821 if (pipe(fds) != -1) {
2823 PUSHs(sv_2mortal(newSViv(fds[0])));
2824 PUSHs(sv_2mortal(newSViv(fds[1])));
2828 read(fd, buffer, nbytes)
2830 SV *sv_buffer = SvROK(ST(1)) ? SvRV(ST(1)) : ST(1);
2834 char * buffer = sv_grow( sv_buffer, nbytes+1 );
2837 SvCUR(sv_buffer) = RETVAL;
2838 SvPOK_only(sv_buffer);
2839 *SvEND(sv_buffer) = '\0';
2841 sv_magic(sv_buffer, 0, 't', 0, 0);
2857 tcsetpgrp(fd, pgrp_id)
2866 if (uname(&buf) >= 0) {
2868 PUSHs(sv_2mortal(newSVpv(buf.sysname, 0)));
2869 PUSHs(sv_2mortal(newSVpv(buf.nodename, 0)));
2870 PUSHs(sv_2mortal(newSVpv(buf.release, 0)));
2871 PUSHs(sv_2mortal(newSVpv(buf.version, 0)));
2872 PUSHs(sv_2mortal(newSVpv(buf.machine, 0)));
2875 uname((char *) 0); /* A stub to call not_here(). */
2879 write(fd, buffer, nbytes)
2897 mbstowcs(s, pwcs, n)
2909 wcstombs(s, pwcs, n)
2931 char *p = SvPV(src,srclen);
2933 ST(0) = sv_2mortal(NEWSV(800,srclen));
2934 dstlen = strxfrm(SvPVX(ST(0)), p, (size_t)srclen);
2935 if (dstlen > srclen) {
2937 SvGROW(ST(0), dstlen);
2938 strxfrm(SvPVX(ST(0)), p, (size_t)dstlen);
2941 SvCUR(ST(0)) = dstlen;
2946 mkfifo(filename, mode)
2950 TAINT_PROPER("mkfifo");
2951 RETVAL = mkfifo(filename, mode);
2967 tcflush(fd, queue_selector)
2972 tcsendbreak(fd, duration)
2977 asctime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
2990 init_tm(&mytm); /* XXX workaround - see init_tm() above */
2993 mytm.tm_hour = hour;
2994 mytm.tm_mday = mday;
2996 mytm.tm_year = year;
2997 mytm.tm_wday = wday;
2998 mytm.tm_yday = yday;
2999 mytm.tm_isdst = isdst;
3000 RETVAL = asctime(&mytm);
3017 realtime = times( &tms );
3019 PUSHs( sv_2mortal( newSVnv( realtime ) ) );
3020 PUSHs( sv_2mortal( newSVnv( tms.tms_utime ) ) );
3021 PUSHs( sv_2mortal( newSVnv( tms.tms_stime ) ) );
3022 PUSHs( sv_2mortal( newSVnv( tms.tms_cutime ) ) );
3023 PUSHs( sv_2mortal( newSVnv( tms.tms_cstime ) ) );
3026 difftime(time1, time2)
3031 mktime(sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3044 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3047 mytm.tm_hour = hour;
3048 mytm.tm_mday = mday;
3050 mytm.tm_year = year;
3051 mytm.tm_wday = wday;
3052 mytm.tm_yday = yday;
3053 mytm.tm_isdst = isdst;
3054 RETVAL = mktime(&mytm);
3060 strftime(fmt, sec, min, hour, mday, mon, year, wday = 0, yday = 0, isdst = 0)
3076 init_tm(&mytm); /* XXX workaround - see init_tm() above */
3079 mytm.tm_hour = hour;
3080 mytm.tm_mday = mday;
3082 mytm.tm_year = year;
3083 mytm.tm_wday = wday;
3084 mytm.tm_yday = yday;
3085 mytm.tm_isdst = isdst;
3086 len = strftime(tmpbuf, sizeof tmpbuf, fmt, &mytm);
3087 ST(0) = sv_2mortal(newSVpv(tmpbuf, len));
3097 PUSHs(sv_2mortal(newSVpv(tzname[0],strlen(tzname[0]))));
3098 PUSHs(sv_2mortal(newSVpv(tzname[1],strlen(tzname[1]))));
3101 access(filename, mode)
3119 pathconf(filename, name)