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