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