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