Commit | Line | Data |
---|---|---|
463ee0b2 LW |
1 | #include "EXTERN.h" |
2 | #include "perl.h" | |
3 | #include "XSUB.h" | |
2304df62 AD |
4 | |
5 | #include <ctype.h> | |
6 | #include <dirent.h> | |
7 | #include <errno.h> | |
8 | #include <fcntl.h> | |
9 | #ifdef I_FLOAT | |
10 | #include <float.h> | |
11 | #endif | |
12 | #include <grp.h> | |
13 | #include <limits.h> | |
14 | #include <locale.h> | |
15 | #include <math.h> | |
85e6fe83 | 16 | #ifdef I_PWD |
2304df62 | 17 | #include <pwd.h> |
85e6fe83 | 18 | #endif |
2304df62 AD |
19 | #include <setjmp.h> |
20 | #include <signal.h> | |
21 | #ifdef I_STDARG | |
22 | #include <stdarg.h> | |
23 | #endif | |
24 | #ifdef I_STDDEF | |
25 | #include <stddef.h> | |
26 | #endif | |
27 | #include <stdio.h> | |
28 | #include <stdlib.h> | |
29 | #include <string.h> | |
30 | #include <sys/stat.h> | |
31 | #include <sys/times.h> | |
32 | #include <sys/types.h> | |
8990e307 | 33 | #include <sys/utsname.h> |
2304df62 | 34 | #include <sys/wait.h> |
85e6fe83 | 35 | #if defined(I_TERMIOS) && !defined(CR3) |
2304df62 AD |
36 | #include <termios.h> |
37 | #endif | |
38 | #include <time.h> | |
39 | #include <unistd.h> | |
40 | #include <utime.h> | |
41 | ||
42 | typedef int SysRet; | |
43 | typedef sigset_t* POSIX__SigSet; | |
44 | typedef HV* POSIX__SigAction; | |
8990e307 LW |
45 | |
46 | #define HAS_UNAME | |
47 | ||
48 | #ifndef HAS_GETPGRP | |
85e6fe83 | 49 | #define getpgrp() not_here("getpgrp") |
8990e307 LW |
50 | #endif |
51 | #ifndef HAS_NICE | |
52 | #define nice(a) not_here("nice") | |
53 | #endif | |
54 | #ifndef HAS_READLINK | |
55 | #define readlink(a,b,c) not_here("readlink") | |
56 | #endif | |
57 | #ifndef HAS_SETPGID | |
58 | #define setpgid(a,b) not_here("setpgid") | |
59 | #endif | |
8990e307 LW |
60 | #ifndef HAS_SETSID |
61 | #define setsid() not_here("setsid") | |
62 | #endif | |
63 | #ifndef HAS_SYMLINK | |
64 | #define symlink(a,b) not_here("symlink") | |
65 | #endif | |
66 | #ifndef HAS_TCGETPGRP | |
67 | #define tcgetpgrp(a) not_here("tcgetpgrp") | |
68 | #endif | |
69 | #ifndef HAS_TCSETPGRP | |
70 | #define tcsetpgrp(a,b) not_here("tcsetpgrp") | |
71 | #endif | |
72 | #ifndef HAS_TIMES | |
73 | #define times(a) not_here("times") | |
74 | #endif | |
75 | #ifndef HAS_UNAME | |
76 | #define uname(a) not_here("uname") | |
77 | #endif | |
78 | #ifndef HAS_WAITPID | |
79 | #define waitpid(a,b,c) not_here("waitpid") | |
80 | #endif | |
81 | ||
82 | static int | |
83 | not_here(s) | |
84 | char *s; | |
85 | { | |
86 | croak("POSIX::%s not implemented on this architecture", s); | |
87 | return -1; | |
88 | } | |
463ee0b2 | 89 | |
2304df62 AD |
90 | int constant(name, arg) |
91 | char *name; | |
92 | int arg; | |
93 | { | |
94 | errno = 0; | |
95 | switch (*name) { | |
96 | case 'A': | |
97 | if (strEQ(name, "ARG_MAX")) | |
98 | #ifdef ARG_MAX | |
99 | return ARG_MAX; | |
100 | #else | |
101 | goto not_there; | |
102 | #endif | |
103 | break; | |
104 | case 'B': | |
105 | if (strEQ(name, "BUFSIZ")) | |
106 | #ifdef BUFSIZ | |
107 | return BUFSIZ; | |
108 | #else | |
109 | goto not_there; | |
110 | #endif | |
111 | if (strEQ(name, "BRKINT")) | |
112 | #ifdef BRKINT | |
113 | return BRKINT; | |
114 | #else | |
115 | goto not_there; | |
116 | #endif | |
117 | if (strEQ(name, "B9600")) | |
118 | #ifdef B9600 | |
119 | return B9600; | |
120 | #else | |
121 | goto not_there; | |
122 | #endif | |
123 | if (strEQ(name, "B19200")) | |
124 | #ifdef B19200 | |
125 | return B19200; | |
126 | #else | |
127 | goto not_there; | |
128 | #endif | |
129 | if (strEQ(name, "B38400")) | |
130 | #ifdef B38400 | |
131 | return B38400; | |
132 | #else | |
133 | goto not_there; | |
134 | #endif | |
135 | if (strEQ(name, "B0")) | |
136 | #ifdef B0 | |
137 | return B0; | |
138 | #else | |
139 | goto not_there; | |
140 | #endif | |
141 | if (strEQ(name, "B110")) | |
142 | #ifdef B110 | |
143 | return B110; | |
144 | #else | |
145 | goto not_there; | |
146 | #endif | |
147 | if (strEQ(name, "B1200")) | |
148 | #ifdef B1200 | |
149 | return B1200; | |
150 | #else | |
151 | goto not_there; | |
152 | #endif | |
153 | if (strEQ(name, "B134")) | |
154 | #ifdef B134 | |
155 | return B134; | |
156 | #else | |
157 | goto not_there; | |
158 | #endif | |
159 | if (strEQ(name, "B150")) | |
160 | #ifdef B150 | |
161 | return B150; | |
162 | #else | |
163 | goto not_there; | |
164 | #endif | |
165 | if (strEQ(name, "B1800")) | |
166 | #ifdef B1800 | |
167 | return B1800; | |
168 | #else | |
169 | goto not_there; | |
170 | #endif | |
171 | if (strEQ(name, "B200")) | |
172 | #ifdef B200 | |
173 | return B200; | |
174 | #else | |
175 | goto not_there; | |
176 | #endif | |
177 | if (strEQ(name, "B2400")) | |
178 | #ifdef B2400 | |
179 | return B2400; | |
180 | #else | |
181 | goto not_there; | |
182 | #endif | |
183 | if (strEQ(name, "B300")) | |
184 | #ifdef B300 | |
185 | return B300; | |
186 | #else | |
187 | goto not_there; | |
188 | #endif | |
189 | if (strEQ(name, "B4800")) | |
190 | #ifdef B4800 | |
191 | return B4800; | |
192 | #else | |
193 | goto not_there; | |
194 | #endif | |
195 | if (strEQ(name, "B50")) | |
196 | #ifdef B50 | |
197 | return B50; | |
198 | #else | |
199 | goto not_there; | |
200 | #endif | |
201 | if (strEQ(name, "B600")) | |
202 | #ifdef B600 | |
203 | return B600; | |
204 | #else | |
205 | goto not_there; | |
206 | #endif | |
207 | if (strEQ(name, "B75")) | |
208 | #ifdef B75 | |
209 | return B75; | |
210 | #else | |
211 | goto not_there; | |
212 | #endif | |
213 | break; | |
214 | case 'C': | |
215 | if (strEQ(name, "CHAR_BIT")) | |
216 | #ifdef CHAR_BIT | |
217 | return CHAR_BIT; | |
218 | #else | |
219 | goto not_there; | |
220 | #endif | |
221 | if (strEQ(name, "CHAR_MAX")) | |
222 | #ifdef CHAR_MAX | |
223 | return CHAR_MAX; | |
224 | #else | |
225 | goto not_there; | |
226 | #endif | |
227 | if (strEQ(name, "CHAR_MIN")) | |
228 | #ifdef CHAR_MIN | |
229 | return CHAR_MIN; | |
230 | #else | |
231 | goto not_there; | |
232 | #endif | |
233 | if (strEQ(name, "CHILD_MAX")) | |
234 | #ifdef CHILD_MAX | |
235 | return CHILD_MAX; | |
236 | #else | |
237 | goto not_there; | |
238 | #endif | |
239 | if (strEQ(name, "CLK_TCK")) | |
240 | #ifdef CLK_TCK | |
241 | return CLK_TCK; | |
242 | #else | |
243 | goto not_there; | |
244 | #endif | |
245 | if (strEQ(name, "CLOCAL")) | |
246 | #ifdef CLOCAL | |
247 | return CLOCAL; | |
248 | #else | |
249 | goto not_there; | |
250 | #endif | |
251 | if (strEQ(name, "CLOCKS_PER_SEC")) | |
252 | #ifdef CLOCKS_PER_SEC | |
253 | return CLOCKS_PER_SEC; | |
254 | #else | |
255 | goto not_there; | |
256 | #endif | |
257 | if (strEQ(name, "CREAD")) | |
258 | #ifdef CREAD | |
259 | return CREAD; | |
260 | #else | |
261 | goto not_there; | |
262 | #endif | |
263 | if (strEQ(name, "CS5")) | |
264 | #ifdef CS5 | |
265 | return CS5; | |
266 | #else | |
267 | goto not_there; | |
268 | #endif | |
269 | if (strEQ(name, "CS6")) | |
270 | #ifdef CS6 | |
271 | return CS6; | |
272 | #else | |
273 | goto not_there; | |
274 | #endif | |
275 | if (strEQ(name, "CS7")) | |
276 | #ifdef CS7 | |
277 | return CS7; | |
278 | #else | |
279 | goto not_there; | |
280 | #endif | |
281 | if (strEQ(name, "CS8")) | |
282 | #ifdef CS8 | |
283 | return CS8; | |
284 | #else | |
285 | goto not_there; | |
286 | #endif | |
287 | if (strEQ(name, "CSIZE")) | |
288 | #ifdef CSIZE | |
289 | return CSIZE; | |
290 | #else | |
291 | goto not_there; | |
292 | #endif | |
293 | if (strEQ(name, "CSTOPB")) | |
294 | #ifdef CSTOPB | |
295 | return CSTOPB; | |
296 | #else | |
297 | goto not_there; | |
298 | #endif | |
299 | break; | |
300 | case 'D': | |
301 | if (strEQ(name, "DBL_MAX")) | |
302 | #ifdef DBL_MAX | |
303 | return DBL_MAX; | |
304 | #else | |
305 | goto not_there; | |
306 | #endif | |
307 | if (strEQ(name, "DBL_MIN")) | |
308 | #ifdef DBL_MIN | |
309 | return DBL_MIN; | |
310 | #else | |
311 | goto not_there; | |
312 | #endif | |
313 | if (strEQ(name, "DBL_DIG")) | |
314 | #ifdef DBL_DIG | |
315 | return DBL_DIG; | |
316 | #else | |
317 | goto not_there; | |
318 | #endif | |
319 | if (strEQ(name, "DBL_EPSILON")) | |
320 | #ifdef DBL_EPSILON | |
321 | return DBL_EPSILON; | |
322 | #else | |
323 | goto not_there; | |
324 | #endif | |
325 | if (strEQ(name, "DBL_MANT_DIG")) | |
326 | #ifdef DBL_MANT_DIG | |
327 | return DBL_MANT_DIG; | |
328 | #else | |
329 | goto not_there; | |
330 | #endif | |
331 | if (strEQ(name, "DBL_MAX_10_EXP")) | |
332 | #ifdef DBL_MAX_10_EXP | |
333 | return DBL_MAX_10_EXP; | |
334 | #else | |
335 | goto not_there; | |
336 | #endif | |
337 | if (strEQ(name, "DBL_MAX_EXP")) | |
338 | #ifdef DBL_MAX_EXP | |
339 | return DBL_MAX_EXP; | |
340 | #else | |
341 | goto not_there; | |
342 | #endif | |
343 | if (strEQ(name, "DBL_MIN_10_EXP")) | |
344 | #ifdef DBL_MIN_10_EXP | |
345 | return DBL_MIN_10_EXP; | |
346 | #else | |
347 | goto not_there; | |
348 | #endif | |
349 | if (strEQ(name, "DBL_MIN_EXP")) | |
350 | #ifdef DBL_MIN_EXP | |
351 | return DBL_MIN_EXP; | |
352 | #else | |
353 | goto not_there; | |
354 | #endif | |
355 | break; | |
356 | case 'E': | |
357 | switch (name[1]) { | |
358 | case 'A': | |
359 | if (strEQ(name, "EACCES")) | |
360 | #ifdef EACCES | |
361 | return EACCES; | |
362 | #else | |
363 | goto not_there; | |
364 | #endif | |
365 | if (strEQ(name, "EAGAIN")) | |
366 | #ifdef EAGAIN | |
367 | return EAGAIN; | |
368 | #else | |
369 | goto not_there; | |
370 | #endif | |
371 | break; | |
372 | case 'B': | |
373 | if (strEQ(name, "EBADF")) | |
374 | #ifdef EBADF | |
375 | return EBADF; | |
376 | #else | |
377 | goto not_there; | |
378 | #endif | |
379 | if (strEQ(name, "EBUSY")) | |
380 | #ifdef EBUSY | |
381 | return EBUSY; | |
382 | #else | |
383 | goto not_there; | |
384 | #endif | |
385 | break; | |
386 | case 'C': | |
387 | if (strEQ(name, "ECHILD")) | |
388 | #ifdef ECHILD | |
389 | return ECHILD; | |
390 | #else | |
391 | goto not_there; | |
392 | #endif | |
393 | if (strEQ(name, "ECHO")) | |
394 | #ifdef ECHO | |
395 | return ECHO; | |
396 | #else | |
397 | goto not_there; | |
398 | #endif | |
399 | if (strEQ(name, "ECHOE")) | |
400 | #ifdef ECHOE | |
401 | return ECHOE; | |
402 | #else | |
403 | goto not_there; | |
404 | #endif | |
405 | if (strEQ(name, "ECHOK")) | |
406 | #ifdef ECHOK | |
407 | return ECHOK; | |
408 | #else | |
409 | goto not_there; | |
410 | #endif | |
411 | if (strEQ(name, "ECHONL")) | |
412 | #ifdef ECHONL | |
413 | return ECHONL; | |
414 | #else | |
415 | goto not_there; | |
416 | #endif | |
417 | break; | |
418 | case 'D': | |
419 | if (strEQ(name, "EDEADLK")) | |
420 | #ifdef EDEADLK | |
421 | return EDEADLK; | |
422 | #else | |
423 | goto not_there; | |
424 | #endif | |
425 | if (strEQ(name, "EDOM")) | |
426 | #ifdef EDOM | |
427 | return EDOM; | |
428 | #else | |
429 | goto not_there; | |
430 | #endif | |
431 | break; | |
432 | case 'E': | |
433 | if (strEQ(name, "EEXIST")) | |
434 | #ifdef EEXIST | |
435 | return EEXIST; | |
436 | #else | |
437 | goto not_there; | |
438 | #endif | |
439 | break; | |
440 | case 'F': | |
441 | if (strEQ(name, "EFAULT")) | |
442 | #ifdef EFAULT | |
443 | return EFAULT; | |
444 | #else | |
445 | goto not_there; | |
446 | #endif | |
447 | if (strEQ(name, "EFBIG")) | |
448 | #ifdef EFBIG | |
449 | return EFBIG; | |
450 | #else | |
451 | goto not_there; | |
452 | #endif | |
453 | break; | |
454 | case 'I': | |
455 | if (strEQ(name, "EINTR")) | |
456 | #ifdef EINTR | |
457 | return EINTR; | |
458 | #else | |
459 | goto not_there; | |
460 | #endif | |
461 | if (strEQ(name, "EINVAL")) | |
462 | #ifdef EINVAL | |
463 | return EINVAL; | |
464 | #else | |
465 | goto not_there; | |
466 | #endif | |
467 | if (strEQ(name, "EIO")) | |
468 | #ifdef EIO | |
469 | return EIO; | |
470 | #else | |
471 | goto not_there; | |
472 | #endif | |
473 | if (strEQ(name, "EISDIR")) | |
474 | #ifdef EISDIR | |
475 | return EISDIR; | |
476 | #else | |
477 | goto not_there; | |
478 | #endif | |
479 | break; | |
480 | case 'M': | |
481 | if (strEQ(name, "EMFILE")) | |
482 | #ifdef EMFILE | |
483 | return EMFILE; | |
484 | #else | |
485 | goto not_there; | |
486 | #endif | |
487 | if (strEQ(name, "EMLINK")) | |
488 | #ifdef EMLINK | |
489 | return EMLINK; | |
490 | #else | |
491 | goto not_there; | |
492 | #endif | |
493 | break; | |
494 | case 'N': | |
495 | if (strEQ(name, "ENOMEM")) | |
496 | #ifdef ENOMEM | |
497 | return ENOMEM; | |
498 | #else | |
499 | goto not_there; | |
500 | #endif | |
501 | if (strEQ(name, "ENOSPC")) | |
502 | #ifdef ENOSPC | |
503 | return ENOSPC; | |
504 | #else | |
505 | goto not_there; | |
506 | #endif | |
507 | if (strEQ(name, "ENOEXEC")) | |
508 | #ifdef ENOEXEC | |
509 | return ENOEXEC; | |
510 | #else | |
511 | goto not_there; | |
512 | #endif | |
513 | if (strEQ(name, "ENOTTY")) | |
514 | #ifdef ENOTTY | |
515 | return ENOTTY; | |
516 | #else | |
517 | goto not_there; | |
518 | #endif | |
519 | if (strEQ(name, "ENOTDIR")) | |
520 | #ifdef ENOTDIR | |
521 | return ENOTDIR; | |
522 | #else | |
523 | goto not_there; | |
524 | #endif | |
525 | if (strEQ(name, "ENOTEMPTY")) | |
526 | #ifdef ENOTEMPTY | |
527 | return ENOTEMPTY; | |
528 | #else | |
529 | goto not_there; | |
530 | #endif | |
531 | if (strEQ(name, "ENFILE")) | |
532 | #ifdef ENFILE | |
533 | return ENFILE; | |
534 | #else | |
535 | goto not_there; | |
536 | #endif | |
537 | if (strEQ(name, "ENODEV")) | |
538 | #ifdef ENODEV | |
539 | return ENODEV; | |
540 | #else | |
541 | goto not_there; | |
542 | #endif | |
543 | if (strEQ(name, "ENOENT")) | |
544 | #ifdef ENOENT | |
545 | return ENOENT; | |
546 | #else | |
547 | goto not_there; | |
548 | #endif | |
549 | if (strEQ(name, "ENOLCK")) | |
550 | #ifdef ENOLCK | |
551 | return ENOLCK; | |
552 | #else | |
553 | goto not_there; | |
554 | #endif | |
555 | if (strEQ(name, "ENOSYS")) | |
556 | #ifdef ENOSYS | |
557 | return ENOSYS; | |
558 | #else | |
559 | goto not_there; | |
560 | #endif | |
561 | if (strEQ(name, "ENXIO")) | |
562 | #ifdef ENXIO | |
563 | return ENXIO; | |
564 | #else | |
565 | goto not_there; | |
566 | #endif | |
567 | if (strEQ(name, "ENAMETOOLONG")) | |
568 | #ifdef ENAMETOOLONG | |
569 | return ENAMETOOLONG; | |
570 | #else | |
571 | goto not_there; | |
572 | #endif | |
573 | break; | |
574 | case 'O': | |
575 | if (strEQ(name, "EOF")) | |
576 | #ifdef EOF | |
577 | return EOF; | |
578 | #else | |
579 | goto not_there; | |
580 | #endif | |
581 | break; | |
582 | case 'P': | |
583 | if (strEQ(name, "EPERM")) | |
584 | #ifdef EPERM | |
585 | return EPERM; | |
586 | #else | |
587 | goto not_there; | |
588 | #endif | |
589 | if (strEQ(name, "EPIPE")) | |
590 | #ifdef EPIPE | |
591 | return EPIPE; | |
592 | #else | |
593 | goto not_there; | |
594 | #endif | |
595 | break; | |
596 | case 'R': | |
597 | if (strEQ(name, "ERANGE")) | |
598 | #ifdef ERANGE | |
599 | return ERANGE; | |
600 | #else | |
601 | goto not_there; | |
602 | #endif | |
603 | if (strEQ(name, "EROFS")) | |
604 | #ifdef EROFS | |
605 | return EROFS; | |
606 | #else | |
607 | goto not_there; | |
608 | #endif | |
609 | break; | |
610 | case 'S': | |
611 | if (strEQ(name, "ESPIPE")) | |
612 | #ifdef ESPIPE | |
613 | return ESPIPE; | |
614 | #else | |
615 | goto not_there; | |
616 | #endif | |
617 | if (strEQ(name, "ESRCH")) | |
618 | #ifdef ESRCH | |
619 | return ESRCH; | |
620 | #else | |
621 | goto not_there; | |
622 | #endif | |
623 | break; | |
624 | case 'X': | |
625 | if (strEQ(name, "EXIT_FAILURE")) | |
626 | #ifdef EXIT_FAILURE | |
627 | return EXIT_FAILURE; | |
628 | #else | |
629 | return 1; | |
630 | #endif | |
631 | if (strEQ(name, "EXIT_SUCCESS")) | |
632 | #ifdef EXIT_SUCCESS | |
633 | return EXIT_SUCCESS; | |
634 | #else | |
635 | return 0; | |
636 | #endif | |
637 | if (strEQ(name, "EXDEV")) | |
638 | #ifdef EXDEV | |
639 | return EXDEV; | |
640 | #else | |
641 | goto not_there; | |
642 | #endif | |
643 | break; | |
644 | } | |
645 | if (strEQ(name, "E2BIG")) | |
646 | #ifdef E2BIG | |
647 | return E2BIG; | |
648 | #else | |
649 | goto not_there; | |
650 | #endif | |
651 | break; | |
652 | case 'F': | |
653 | if (strnEQ(name, "FLT_", 4)) { | |
654 | if (strEQ(name, "FLT_MAX")) | |
655 | #ifdef FLT_MAX | |
656 | return FLT_MAX; | |
657 | #else | |
658 | goto not_there; | |
659 | #endif | |
660 | if (strEQ(name, "FLT_MIN")) | |
661 | #ifdef FLT_MIN | |
662 | return FLT_MIN; | |
663 | #else | |
664 | goto not_there; | |
665 | #endif | |
666 | if (strEQ(name, "FLT_ROUNDS")) | |
667 | #ifdef FLT_ROUNDS | |
668 | return FLT_ROUNDS; | |
669 | #else | |
670 | goto not_there; | |
671 | #endif | |
672 | if (strEQ(name, "FLT_DIG")) | |
673 | #ifdef FLT_DIG | |
674 | return FLT_DIG; | |
675 | #else | |
676 | goto not_there; | |
677 | #endif | |
678 | if (strEQ(name, "FLT_EPSILON")) | |
679 | #ifdef FLT_EPSILON | |
680 | return FLT_EPSILON; | |
681 | #else | |
682 | goto not_there; | |
683 | #endif | |
684 | if (strEQ(name, "FLT_MANT_DIG")) | |
685 | #ifdef FLT_MANT_DIG | |
686 | return FLT_MANT_DIG; | |
687 | #else | |
688 | goto not_there; | |
689 | #endif | |
690 | if (strEQ(name, "FLT_MAX_10_EXP")) | |
691 | #ifdef FLT_MAX_10_EXP | |
692 | return FLT_MAX_10_EXP; | |
693 | #else | |
694 | goto not_there; | |
695 | #endif | |
696 | if (strEQ(name, "FLT_MAX_EXP")) | |
697 | #ifdef FLT_MAX_EXP | |
698 | return FLT_MAX_EXP; | |
699 | #else | |
700 | goto not_there; | |
701 | #endif | |
702 | if (strEQ(name, "FLT_MIN_10_EXP")) | |
703 | #ifdef FLT_MIN_10_EXP | |
704 | return FLT_MIN_10_EXP; | |
705 | #else | |
706 | goto not_there; | |
707 | #endif | |
708 | if (strEQ(name, "FLT_MIN_EXP")) | |
709 | #ifdef FLT_MIN_EXP | |
710 | return FLT_MIN_EXP; | |
711 | #else | |
712 | goto not_there; | |
713 | #endif | |
714 | if (strEQ(name, "FLT_RADIX")) | |
715 | #ifdef FLT_RADIX | |
716 | return FLT_RADIX; | |
717 | #else | |
718 | goto not_there; | |
719 | #endif | |
720 | break; | |
721 | } | |
722 | if (strnEQ(name, "F_", 2)) { | |
723 | if (strEQ(name, "F_DUPFD")) | |
724 | #ifdef F_DUPFD | |
725 | return F_DUPFD; | |
726 | #else | |
727 | goto not_there; | |
728 | #endif | |
729 | if (strEQ(name, "F_GETFD")) | |
730 | #ifdef F_GETFD | |
731 | return F_GETFD; | |
732 | #else | |
733 | goto not_there; | |
734 | #endif | |
735 | if (strEQ(name, "F_GETFL")) | |
736 | #ifdef F_GETFL | |
737 | return F_GETFL; | |
738 | #else | |
739 | goto not_there; | |
740 | #endif | |
741 | if (strEQ(name, "F_GETLK")) | |
742 | #ifdef F_GETLK | |
743 | return F_GETLK; | |
744 | #else | |
745 | goto not_there; | |
746 | #endif | |
747 | if (strEQ(name, "F_OK")) | |
748 | #ifdef F_OK | |
749 | return F_OK; | |
750 | #else | |
751 | goto not_there; | |
752 | #endif | |
753 | if (strEQ(name, "F_RDLCK")) | |
754 | #ifdef F_RDLCK | |
755 | return F_RDLCK; | |
756 | #else | |
757 | goto not_there; | |
758 | #endif | |
759 | if (strEQ(name, "F_SETFD")) | |
760 | #ifdef F_SETFD | |
761 | return F_SETFD; | |
762 | #else | |
763 | goto not_there; | |
764 | #endif | |
765 | if (strEQ(name, "F_SETFL")) | |
766 | #ifdef F_SETFL | |
767 | return F_SETFL; | |
768 | #else | |
769 | goto not_there; | |
770 | #endif | |
771 | if (strEQ(name, "F_SETLK")) | |
772 | #ifdef F_SETLK | |
773 | return F_SETLK; | |
774 | #else | |
775 | goto not_there; | |
776 | #endif | |
777 | if (strEQ(name, "F_SETLKW")) | |
778 | #ifdef F_SETLKW | |
779 | return F_SETLKW; | |
780 | #else | |
781 | goto not_there; | |
782 | #endif | |
783 | if (strEQ(name, "F_UNLCK")) | |
784 | #ifdef F_UNLCK | |
785 | return F_UNLCK; | |
786 | #else | |
787 | goto not_there; | |
788 | #endif | |
789 | if (strEQ(name, "F_WRLCK")) | |
790 | #ifdef F_WRLCK | |
791 | return F_WRLCK; | |
792 | #else | |
793 | goto not_there; | |
794 | #endif | |
795 | break; | |
796 | } | |
797 | if (strEQ(name, "FD_CLOEXEC")) return FD_CLOEXEC; | |
798 | if (strEQ(name, "FILENAME_MAX")) | |
799 | #ifdef FILENAME_MAX | |
800 | return FILENAME_MAX; | |
801 | #else | |
802 | goto not_there; | |
803 | #endif | |
804 | break; | |
805 | case 'H': | |
806 | if (strEQ(name, "HUGE_VAL")) | |
807 | #ifdef HUGE_VAL | |
808 | return HUGE_VAL; | |
809 | #else | |
810 | goto not_there; | |
811 | #endif | |
812 | if (strEQ(name, "HUPCL")) | |
813 | #ifdef HUPCL | |
814 | return HUPCL; | |
815 | #else | |
816 | goto not_there; | |
817 | #endif | |
818 | break; | |
819 | case 'I': | |
820 | if (strEQ(name, "INT_MAX")) | |
821 | #ifdef INT_MAX | |
822 | return INT_MAX; | |
823 | #else | |
824 | goto not_there; | |
825 | #endif | |
826 | if (strEQ(name, "INT_MIN")) | |
827 | #ifdef INT_MIN | |
828 | return INT_MIN; | |
829 | #else | |
830 | goto not_there; | |
831 | #endif | |
832 | if (strEQ(name, "ICANON")) | |
833 | #ifdef ICANON | |
834 | return ICANON; | |
835 | #else | |
836 | goto not_there; | |
837 | #endif | |
838 | if (strEQ(name, "ICRNL")) | |
839 | #ifdef ICRNL | |
840 | return ICRNL; | |
841 | #else | |
842 | goto not_there; | |
843 | #endif | |
844 | if (strEQ(name, "IEXTEN")) | |
845 | #ifdef IEXTEN | |
846 | return IEXTEN; | |
847 | #else | |
848 | goto not_there; | |
849 | #endif | |
850 | if (strEQ(name, "IGNBRK")) | |
851 | #ifdef IGNBRK | |
852 | return IGNBRK; | |
853 | #else | |
854 | goto not_there; | |
855 | #endif | |
856 | if (strEQ(name, "IGNCR")) | |
857 | #ifdef IGNCR | |
858 | return IGNCR; | |
859 | #else | |
860 | goto not_there; | |
861 | #endif | |
862 | if (strEQ(name, "IGNPAR")) | |
863 | #ifdef IGNPAR | |
864 | return IGNPAR; | |
865 | #else | |
866 | goto not_there; | |
867 | #endif | |
868 | if (strEQ(name, "INLCR")) | |
869 | #ifdef INLCR | |
870 | return INLCR; | |
871 | #else | |
872 | goto not_there; | |
873 | #endif | |
874 | if (strEQ(name, "INPCK")) | |
875 | #ifdef INPCK | |
876 | return INPCK; | |
877 | #else | |
878 | goto not_there; | |
879 | #endif | |
880 | if (strEQ(name, "ISIG")) | |
881 | #ifdef ISIG | |
882 | return ISIG; | |
883 | #else | |
884 | goto not_there; | |
885 | #endif | |
886 | if (strEQ(name, "ISTRIP")) | |
887 | #ifdef ISTRIP | |
888 | return ISTRIP; | |
889 | #else | |
890 | goto not_there; | |
891 | #endif | |
892 | if (strEQ(name, "IXOFF")) | |
893 | #ifdef IXOFF | |
894 | return IXOFF; | |
895 | #else | |
896 | goto not_there; | |
897 | #endif | |
898 | if (strEQ(name, "IXON")) | |
899 | #ifdef IXON | |
900 | return IXON; | |
901 | #else | |
902 | goto not_there; | |
903 | #endif | |
904 | break; | |
905 | case 'L': | |
906 | if (strnEQ(name, "LC_", 3)) { | |
907 | if (strEQ(name, "LC_ALL")) | |
908 | #ifdef LC_ALL | |
909 | return LC_ALL; | |
910 | #else | |
911 | goto not_there; | |
912 | #endif | |
913 | if (strEQ(name, "LC_COLLATE")) | |
914 | #ifdef LC_COLLATE | |
915 | return LC_COLLATE; | |
916 | #else | |
917 | goto not_there; | |
918 | #endif | |
919 | if (strEQ(name, "LC_CTYPE")) | |
920 | #ifdef LC_CTYPE | |
921 | return LC_CTYPE; | |
922 | #else | |
923 | goto not_there; | |
924 | #endif | |
925 | if (strEQ(name, "LC_MONETARY")) | |
926 | #ifdef LC_MONETARY | |
927 | return LC_MONETARY; | |
928 | #else | |
929 | goto not_there; | |
930 | #endif | |
931 | if (strEQ(name, "LC_NUMERIC")) | |
932 | #ifdef LC_NUMERIC | |
933 | return LC_NUMERIC; | |
934 | #else | |
935 | goto not_there; | |
936 | #endif | |
937 | if (strEQ(name, "LC_TIME")) | |
938 | #ifdef LC_TIME | |
939 | return LC_TIME; | |
940 | #else | |
941 | goto not_there; | |
942 | #endif | |
943 | break; | |
944 | } | |
945 | if (strnEQ(name, "LDBL_", 5)) { | |
946 | if (strEQ(name, "LDBL_MAX")) | |
947 | #ifdef LDBL_MAX | |
948 | return LDBL_MAX; | |
949 | #else | |
950 | goto not_there; | |
951 | #endif | |
952 | if (strEQ(name, "LDBL_MIN")) | |
953 | #ifdef LDBL_MIN | |
954 | return LDBL_MIN; | |
955 | #else | |
956 | goto not_there; | |
957 | #endif | |
958 | if (strEQ(name, "LDBL_DIG")) | |
959 | #ifdef LDBL_DIG | |
960 | return LDBL_DIG; | |
961 | #else | |
962 | goto not_there; | |
963 | #endif | |
964 | if (strEQ(name, "LDBL_EPSILON")) | |
965 | #ifdef LDBL_EPSILON | |
966 | return LDBL_EPSILON; | |
967 | #else | |
968 | goto not_there; | |
969 | #endif | |
970 | if (strEQ(name, "LDBL_MANT_DIG")) | |
971 | #ifdef LDBL_MANT_DIG | |
972 | return LDBL_MANT_DIG; | |
973 | #else | |
974 | goto not_there; | |
975 | #endif | |
976 | if (strEQ(name, "LDBL_MAX_10_EXP")) | |
977 | #ifdef LDBL_MAX_10_EXP | |
978 | return LDBL_MAX_10_EXP; | |
979 | #else | |
980 | goto not_there; | |
981 | #endif | |
982 | if (strEQ(name, "LDBL_MAX_EXP")) | |
983 | #ifdef LDBL_MAX_EXP | |
984 | return LDBL_MAX_EXP; | |
985 | #else | |
986 | goto not_there; | |
987 | #endif | |
988 | if (strEQ(name, "LDBL_MIN_10_EXP")) | |
989 | #ifdef LDBL_MIN_10_EXP | |
990 | return LDBL_MIN_10_EXP; | |
991 | #else | |
992 | goto not_there; | |
993 | #endif | |
994 | if (strEQ(name, "LDBL_MIN_EXP")) | |
995 | #ifdef LDBL_MIN_EXP | |
996 | return LDBL_MIN_EXP; | |
997 | #else | |
998 | goto not_there; | |
999 | #endif | |
1000 | break; | |
1001 | } | |
1002 | if (strnEQ(name, "L_", 2)) { | |
1003 | if (strEQ(name, "L_ctermid")) | |
1004 | #ifdef L_ctermid | |
1005 | return L_ctermid; | |
1006 | #else | |
1007 | goto not_there; | |
1008 | #endif | |
1009 | if (strEQ(name, "L_cuserid")) | |
1010 | #ifdef L_cuserid | |
1011 | return L_cuserid; | |
1012 | #else | |
1013 | goto not_there; | |
1014 | #endif | |
1015 | if (strEQ(name, "L_tmpname")) | |
1016 | #ifdef L_tmpname | |
1017 | return L_tmpname; | |
1018 | #else | |
1019 | goto not_there; | |
1020 | #endif | |
1021 | break; | |
1022 | } | |
1023 | if (strEQ(name, "LONG_MAX")) | |
1024 | #ifdef LONG_MAX | |
1025 | return LONG_MAX; | |
1026 | #else | |
1027 | goto not_there; | |
1028 | #endif | |
1029 | if (strEQ(name, "LONG_MIN")) | |
1030 | #ifdef LONG_MIN | |
1031 | return LONG_MIN; | |
1032 | #else | |
1033 | goto not_there; | |
1034 | #endif | |
1035 | if (strEQ(name, "LINK_MAX")) | |
1036 | #ifdef LINK_MAX | |
1037 | return LINK_MAX; | |
1038 | #else | |
1039 | goto not_there; | |
1040 | #endif | |
1041 | break; | |
1042 | case 'M': | |
1043 | if (strEQ(name, "MAX_CANON")) | |
1044 | #ifdef MAX_CANON | |
1045 | return MAX_CANON; | |
1046 | #else | |
1047 | goto not_there; | |
1048 | #endif | |
1049 | if (strEQ(name, "MAX_INPUT")) | |
1050 | #ifdef MAX_INPUT | |
1051 | return MAX_INPUT; | |
1052 | #else | |
1053 | goto not_there; | |
1054 | #endif | |
1055 | if (strEQ(name, "MB_CUR_MAX")) | |
1056 | #ifdef MB_CUR_MAX | |
1057 | return MB_CUR_MAX; | |
1058 | #else | |
1059 | goto not_there; | |
1060 | #endif | |
1061 | if (strEQ(name, "MB_LEN_MAX")) | |
1062 | #ifdef MB_LEN_MAX | |
1063 | return MB_LEN_MAX; | |
1064 | #else | |
1065 | goto not_there; | |
1066 | #endif | |
1067 | break; | |
1068 | case 'N': | |
1069 | if (strEQ(name, "NULL")) return NULL; | |
1070 | if (strEQ(name, "NAME_MAX")) | |
1071 | #ifdef NAME_MAX | |
1072 | return NAME_MAX; | |
1073 | #else | |
1074 | goto not_there; | |
1075 | #endif | |
1076 | if (strEQ(name, "NCCS")) | |
1077 | #ifdef NCCS | |
1078 | return NCCS; | |
1079 | #else | |
1080 | goto not_there; | |
1081 | #endif | |
1082 | if (strEQ(name, "NGROUPS_MAX")) | |
1083 | #ifdef NGROUPS_MAX | |
1084 | return NGROUPS_MAX; | |
1085 | #else | |
1086 | goto not_there; | |
1087 | #endif | |
1088 | if (strEQ(name, "NOFLSH")) | |
1089 | #ifdef NOFLSH | |
1090 | return NOFLSH; | |
1091 | #else | |
1092 | goto not_there; | |
1093 | #endif | |
1094 | break; | |
1095 | case 'O': | |
1096 | if (strnEQ(name, "O_", 2)) { | |
1097 | if (strEQ(name, "O_APPEND")) | |
1098 | #ifdef O_APPEND | |
1099 | return O_APPEND; | |
1100 | #else | |
1101 | goto not_there; | |
1102 | #endif | |
1103 | if (strEQ(name, "O_CREAT")) | |
1104 | #ifdef O_CREAT | |
1105 | return O_CREAT; | |
1106 | #else | |
1107 | goto not_there; | |
1108 | #endif | |
1109 | if (strEQ(name, "O_TRUNC")) | |
1110 | #ifdef O_TRUNC | |
1111 | return O_TRUNC; | |
1112 | #else | |
1113 | goto not_there; | |
1114 | #endif | |
1115 | if (strEQ(name, "O_RDONLY")) | |
1116 | #ifdef O_RDONLY | |
1117 | return O_RDONLY; | |
1118 | #else | |
1119 | goto not_there; | |
1120 | #endif | |
1121 | if (strEQ(name, "O_RDWR")) | |
1122 | #ifdef O_RDWR | |
1123 | return O_RDWR; | |
1124 | #else | |
1125 | goto not_there; | |
1126 | #endif | |
1127 | if (strEQ(name, "O_WRONLY")) | |
1128 | #ifdef O_WRONLY | |
1129 | return O_WRONLY; | |
1130 | #else | |
1131 | goto not_there; | |
1132 | #endif | |
1133 | if (strEQ(name, "O_EXCL")) | |
1134 | #ifdef O_EXCL | |
1135 | return O_EXCL; | |
1136 | #else | |
1137 | goto not_there; | |
1138 | #endif | |
1139 | if (strEQ(name, "O_NOCTTY")) | |
1140 | #ifdef O_NOCTTY | |
1141 | return O_NOCTTY; | |
1142 | #else | |
1143 | goto not_there; | |
1144 | #endif | |
1145 | if (strEQ(name, "O_NONBLOCK")) | |
1146 | #ifdef O_NONBLOCK | |
1147 | return O_NONBLOCK; | |
1148 | #else | |
1149 | goto not_there; | |
1150 | #endif | |
1151 | if (strEQ(name, "O_ACCMODE")) | |
1152 | #ifdef O_ACCMODE | |
1153 | return O_ACCMODE; | |
1154 | #else | |
1155 | goto not_there; | |
1156 | #endif | |
1157 | break; | |
1158 | } | |
1159 | if (strEQ(name, "OPEN_MAX")) | |
1160 | #ifdef OPEN_MAX | |
1161 | return OPEN_MAX; | |
1162 | #else | |
1163 | goto not_there; | |
1164 | #endif | |
1165 | if (strEQ(name, "OPOST")) | |
1166 | #ifdef OPOST | |
1167 | return OPOST; | |
1168 | #else | |
1169 | goto not_there; | |
1170 | #endif | |
1171 | break; | |
1172 | case 'P': | |
1173 | if (strEQ(name, "PATH_MAX")) | |
1174 | #ifdef PATH_MAX | |
1175 | return PATH_MAX; | |
1176 | #else | |
1177 | goto not_there; | |
1178 | #endif | |
1179 | if (strEQ(name, "PARENB")) | |
1180 | #ifdef PARENB | |
1181 | return PARENB; | |
1182 | #else | |
1183 | goto not_there; | |
1184 | #endif | |
1185 | if (strEQ(name, "PARMRK")) | |
1186 | #ifdef PARMRK | |
1187 | return PARMRK; | |
1188 | #else | |
1189 | goto not_there; | |
1190 | #endif | |
1191 | if (strEQ(name, "PARODD")) | |
1192 | #ifdef PARODD | |
1193 | return PARODD; | |
1194 | #else | |
1195 | goto not_there; | |
1196 | #endif | |
1197 | if (strEQ(name, "PIPE_BUF")) | |
1198 | #ifdef PIPE_BUF | |
1199 | return PIPE_BUF; | |
1200 | #else | |
1201 | goto not_there; | |
1202 | #endif | |
1203 | break; | |
1204 | case 'R': | |
1205 | if (strEQ(name, "RAND_MAX")) | |
1206 | #ifdef RAND_MAX | |
1207 | return RAND_MAX; | |
1208 | #else | |
1209 | goto not_there; | |
1210 | #endif | |
1211 | if (strEQ(name, "R_OK")) | |
1212 | #ifdef R_OK | |
1213 | return R_OK; | |
1214 | #else | |
1215 | goto not_there; | |
1216 | #endif | |
1217 | break; | |
1218 | case 'S': | |
1219 | if (strnEQ(name, "SIG", 3)) { | |
1220 | if (name[3] == '_') { | |
1221 | if (strEQ(name, "SIG_BLOCK")) | |
1222 | #ifdef SIG_BLOCK | |
1223 | return SIG_BLOCK; | |
1224 | #else | |
1225 | goto not_there; | |
1226 | #endif | |
1227 | #ifdef SIG_DFL | |
1228 | if (strEQ(name, "SIG_DFL")) return (int)SIG_DFL; | |
1229 | #endif | |
1230 | #ifdef SIG_ERR | |
1231 | if (strEQ(name, "SIG_ERR")) return (int)SIG_ERR; | |
1232 | #endif | |
1233 | #ifdef SIG_IGN | |
1234 | if (strEQ(name, "SIG_IGN")) return (int)SIG_IGN; | |
1235 | #endif | |
1236 | if (strEQ(name, "SIG_SETMASK")) | |
1237 | #ifdef SIG_SETMASK | |
1238 | return SIG_SETMASK; | |
1239 | #else | |
1240 | goto not_there; | |
1241 | #endif | |
1242 | if (strEQ(name, "SIG_UNBLOCK")) | |
1243 | #ifdef SIG_UNBLOCK | |
1244 | return SIG_UNBLOCK; | |
1245 | #else | |
1246 | goto not_there; | |
1247 | #endif | |
1248 | break; | |
1249 | } | |
1250 | if (strEQ(name, "SIGABRT")) | |
1251 | #ifdef SIGABRT | |
1252 | return SIGABRT; | |
1253 | #else | |
1254 | goto not_there; | |
1255 | #endif | |
1256 | if (strEQ(name, "SIGALRM")) | |
1257 | #ifdef SIGALRM | |
1258 | return SIGALRM; | |
1259 | #else | |
1260 | goto not_there; | |
1261 | #endif | |
1262 | if (strEQ(name, "SIGCHLD")) | |
1263 | #ifdef SIGCHLD | |
1264 | return SIGCHLD; | |
1265 | #else | |
1266 | goto not_there; | |
1267 | #endif | |
1268 | if (strEQ(name, "SIGCONT")) | |
1269 | #ifdef SIGCONT | |
1270 | return SIGCONT; | |
1271 | #else | |
1272 | goto not_there; | |
1273 | #endif | |
1274 | if (strEQ(name, "SIGFPE")) | |
1275 | #ifdef SIGFPE | |
1276 | return SIGFPE; | |
1277 | #else | |
1278 | goto not_there; | |
1279 | #endif | |
1280 | if (strEQ(name, "SIGHUP")) | |
1281 | #ifdef SIGHUP | |
1282 | return SIGHUP; | |
1283 | #else | |
1284 | goto not_there; | |
1285 | #endif | |
1286 | if (strEQ(name, "SIGILL")) | |
1287 | #ifdef SIGILL | |
1288 | return SIGILL; | |
1289 | #else | |
1290 | goto not_there; | |
1291 | #endif | |
1292 | if (strEQ(name, "SIGINT")) | |
1293 | #ifdef SIGINT | |
1294 | return SIGINT; | |
1295 | #else | |
1296 | goto not_there; | |
1297 | #endif | |
1298 | if (strEQ(name, "SIGKILL")) | |
1299 | #ifdef SIGKILL | |
1300 | return SIGKILL; | |
1301 | #else | |
1302 | goto not_there; | |
1303 | #endif | |
1304 | if (strEQ(name, "SIGPIPE")) | |
1305 | #ifdef SIGPIPE | |
1306 | return SIGPIPE; | |
1307 | #else | |
1308 | goto not_there; | |
1309 | #endif | |
1310 | if (strEQ(name, "SIGQUIT")) | |
1311 | #ifdef SIGQUIT | |
1312 | return SIGQUIT; | |
1313 | #else | |
1314 | goto not_there; | |
1315 | #endif | |
1316 | if (strEQ(name, "SIGSEGV")) | |
1317 | #ifdef SIGSEGV | |
1318 | return SIGSEGV; | |
1319 | #else | |
1320 | goto not_there; | |
1321 | #endif | |
1322 | if (strEQ(name, "SIGSTOP")) | |
1323 | #ifdef SIGSTOP | |
1324 | return SIGSTOP; | |
1325 | #else | |
1326 | goto not_there; | |
1327 | #endif | |
1328 | if (strEQ(name, "SIGTERM")) | |
1329 | #ifdef SIGTERM | |
1330 | return SIGTERM; | |
1331 | #else | |
1332 | goto not_there; | |
1333 | #endif | |
1334 | if (strEQ(name, "SIGTSTP")) | |
1335 | #ifdef SIGTSTP | |
1336 | return SIGTSTP; | |
1337 | #else | |
1338 | goto not_there; | |
1339 | #endif | |
1340 | if (strEQ(name, "SIGTTIN")) | |
1341 | #ifdef SIGTTIN | |
1342 | return SIGTTIN; | |
1343 | #else | |
1344 | goto not_there; | |
1345 | #endif | |
1346 | if (strEQ(name, "SIGTTOU")) | |
1347 | #ifdef SIGTTOU | |
1348 | return SIGTTOU; | |
1349 | #else | |
1350 | goto not_there; | |
1351 | #endif | |
1352 | if (strEQ(name, "SIGUSR1")) | |
1353 | #ifdef SIGUSR1 | |
1354 | return SIGUSR1; | |
1355 | #else | |
1356 | goto not_there; | |
1357 | #endif | |
1358 | if (strEQ(name, "SIGUSR2")) | |
1359 | #ifdef SIGUSR2 | |
1360 | return SIGUSR2; | |
1361 | #else | |
1362 | goto not_there; | |
1363 | #endif | |
1364 | break; | |
1365 | } | |
1366 | if (name[1] == '_') { | |
1367 | #ifdef S_ISBLK | |
1368 | if (strEQ(name, "S_ISBLK")) return S_ISBLK(arg); | |
1369 | #endif | |
1370 | #ifdef S_ISCHR | |
1371 | if (strEQ(name, "S_ISCHR")) return S_ISCHR(arg); | |
1372 | #endif | |
1373 | #ifdef S_ISDIR | |
1374 | if (strEQ(name, "S_ISDIR")) return S_ISDIR(arg); | |
1375 | #endif | |
1376 | #ifdef S_ISFIFO | |
1377 | if (strEQ(name, "S_ISFIFO")) return S_ISFIFO(arg); | |
1378 | #endif | |
1379 | #ifdef S_ISREG | |
1380 | if (strEQ(name, "S_ISREG")) return S_ISREG(arg); | |
1381 | #endif | |
1382 | if (strEQ(name, "S_ISGID")) | |
1383 | #ifdef S_ISGID | |
1384 | return S_ISGID; | |
1385 | #else | |
1386 | goto not_there; | |
1387 | #endif | |
1388 | if (strEQ(name, "S_ISUID")) | |
1389 | #ifdef S_ISUID | |
1390 | return S_ISUID; | |
1391 | #else | |
1392 | goto not_there; | |
1393 | #endif | |
1394 | if (strEQ(name, "S_IRGRP")) | |
1395 | #ifdef S_IRGRP | |
1396 | return S_IRGRP; | |
1397 | #else | |
1398 | goto not_there; | |
1399 | #endif | |
1400 | if (strEQ(name, "S_IROTH")) | |
1401 | #ifdef S_IROTH | |
1402 | return S_IROTH; | |
1403 | #else | |
1404 | goto not_there; | |
1405 | #endif | |
1406 | if (strEQ(name, "S_IRUSR")) | |
1407 | #ifdef S_IRUSR | |
1408 | return S_IRUSR; | |
1409 | #else | |
1410 | goto not_there; | |
1411 | #endif | |
1412 | if (strEQ(name, "S_IRWXG")) | |
1413 | #ifdef S_IRWXG | |
1414 | return S_IRWXG; | |
1415 | #else | |
1416 | goto not_there; | |
1417 | #endif | |
1418 | if (strEQ(name, "S_IRWXO")) | |
1419 | #ifdef S_IRWXO | |
1420 | return S_IRWXO; | |
1421 | #else | |
1422 | goto not_there; | |
1423 | #endif | |
1424 | if (strEQ(name, "S_IRWXU")) | |
1425 | #ifdef S_IRWXU | |
1426 | return S_IRWXU; | |
1427 | #else | |
1428 | goto not_there; | |
1429 | #endif | |
1430 | if (strEQ(name, "S_IWGRP")) | |
1431 | #ifdef S_IWGRP | |
1432 | return S_IWGRP; | |
1433 | #else | |
1434 | goto not_there; | |
1435 | #endif | |
1436 | if (strEQ(name, "S_IWOTH")) | |
1437 | #ifdef S_IWOTH | |
1438 | return S_IWOTH; | |
1439 | #else | |
1440 | goto not_there; | |
1441 | #endif | |
1442 | if (strEQ(name, "S_IWUSR")) | |
1443 | #ifdef S_IWUSR | |
1444 | return S_IWUSR; | |
1445 | #else | |
1446 | goto not_there; | |
1447 | #endif | |
1448 | if (strEQ(name, "S_IXGRP")) | |
1449 | #ifdef S_IXGRP | |
1450 | return S_IXGRP; | |
1451 | #else | |
1452 | goto not_there; | |
1453 | #endif | |
1454 | if (strEQ(name, "S_IXOTH")) | |
1455 | #ifdef S_IXOTH | |
1456 | return S_IXOTH; | |
1457 | #else | |
1458 | goto not_there; | |
1459 | #endif | |
1460 | if (strEQ(name, "S_IXUSR")) | |
1461 | #ifdef S_IXUSR | |
1462 | return S_IXUSR; | |
1463 | #else | |
1464 | goto not_there; | |
1465 | #endif | |
1466 | break; | |
1467 | } | |
1468 | if (strEQ(name, "SEEK_CUR")) | |
1469 | #ifdef SEEK_CUR | |
1470 | return SEEK_CUR; | |
1471 | #else | |
1472 | goto not_there; | |
1473 | #endif | |
1474 | if (strEQ(name, "SEEK_END")) | |
1475 | #ifdef SEEK_END | |
1476 | return SEEK_END; | |
1477 | #else | |
1478 | goto not_there; | |
1479 | #endif | |
1480 | if (strEQ(name, "SEEK_SET")) | |
1481 | #ifdef SEEK_SET | |
1482 | return SEEK_SET; | |
1483 | #else | |
1484 | goto not_there; | |
1485 | #endif | |
1486 | if (strEQ(name, "STREAM_MAX")) | |
1487 | #ifdef STREAM_MAX | |
1488 | return STREAM_MAX; | |
1489 | #else | |
1490 | goto not_there; | |
1491 | #endif | |
1492 | if (strEQ(name, "SHRT_MAX")) | |
1493 | #ifdef SHRT_MAX | |
1494 | return SHRT_MAX; | |
1495 | #else | |
1496 | goto not_there; | |
1497 | #endif | |
1498 | if (strEQ(name, "SHRT_MIN")) | |
1499 | #ifdef SHRT_MIN | |
1500 | return SHRT_MIN; | |
1501 | #else | |
1502 | goto not_there; | |
1503 | #endif | |
1504 | if (strEQ(name, "SA_NOCLDSTOP")) | |
1505 | #ifdef SA_NOCLDSTOP | |
1506 | return SA_NOCLDSTOP; | |
1507 | #else | |
1508 | goto not_there; | |
1509 | #endif | |
1510 | if (strEQ(name, "SCHAR_MAX")) | |
1511 | #ifdef SCHAR_MAX | |
1512 | return SCHAR_MAX; | |
1513 | #else | |
1514 | goto not_there; | |
1515 | #endif | |
1516 | if (strEQ(name, "SCHAR_MIN")) | |
1517 | #ifdef SCHAR_MIN | |
1518 | return SCHAR_MIN; | |
1519 | #else | |
1520 | goto not_there; | |
1521 | #endif | |
1522 | if (strEQ(name, "SSIZE_MAX")) | |
1523 | #ifdef SSIZE_MAX | |
1524 | return SSIZE_MAX; | |
1525 | #else | |
1526 | goto not_there; | |
1527 | #endif | |
1528 | if (strEQ(name, "STDIN_FILENO")) | |
1529 | #ifdef STDIN_FILENO | |
1530 | return STDIN_FILENO; | |
1531 | #else | |
1532 | goto not_there; | |
1533 | #endif | |
1534 | if (strEQ(name, "STDOUT_FILENO")) | |
1535 | #ifdef STDOUT_FILENO | |
1536 | return STDOUT_FILENO; | |
1537 | #else | |
1538 | goto not_there; | |
1539 | #endif | |
1540 | if (strEQ(name, "STRERR_FILENO")) | |
1541 | #ifdef STRERR_FILENO | |
1542 | return STRERR_FILENO; | |
1543 | #else | |
1544 | goto not_there; | |
1545 | #endif | |
1546 | break; | |
1547 | case 'T': | |
1548 | if (strEQ(name, "TCIFLUSH")) | |
1549 | #ifdef TCIFLUSH | |
1550 | return TCIFLUSH; | |
1551 | #else | |
1552 | goto not_there; | |
1553 | #endif | |
1554 | if (strEQ(name, "TCIOFF")) | |
1555 | #ifdef TCIOFF | |
1556 | return TCIOFF; | |
1557 | #else | |
1558 | goto not_there; | |
1559 | #endif | |
1560 | if (strEQ(name, "TCIOFLUSH")) | |
1561 | #ifdef TCIOFLUSH | |
1562 | return TCIOFLUSH; | |
1563 | #else | |
1564 | goto not_there; | |
1565 | #endif | |
1566 | if (strEQ(name, "TCION")) | |
1567 | #ifdef TCION | |
1568 | return TCION; | |
1569 | #else | |
1570 | goto not_there; | |
1571 | #endif | |
1572 | if (strEQ(name, "TCOFLUSH")) | |
1573 | #ifdef TCOFLUSH | |
1574 | return TCOFLUSH; | |
1575 | #else | |
1576 | goto not_there; | |
1577 | #endif | |
1578 | if (strEQ(name, "TCOOFF")) | |
1579 | #ifdef TCOOFF | |
1580 | return TCOOFF; | |
1581 | #else | |
1582 | goto not_there; | |
1583 | #endif | |
1584 | if (strEQ(name, "TCOON")) | |
1585 | #ifdef TCOON | |
1586 | return TCOON; | |
1587 | #else | |
1588 | goto not_there; | |
1589 | #endif | |
1590 | if (strEQ(name, "TCSADRAIN")) | |
1591 | #ifdef TCSADRAIN | |
1592 | return TCSADRAIN; | |
1593 | #else | |
1594 | goto not_there; | |
1595 | #endif | |
1596 | if (strEQ(name, "TCSAFLUSH")) | |
1597 | #ifdef TCSAFLUSH | |
1598 | return TCSAFLUSH; | |
1599 | #else | |
1600 | goto not_there; | |
1601 | #endif | |
1602 | if (strEQ(name, "TCSANOW")) | |
1603 | #ifdef TCSANOW | |
1604 | return TCSANOW; | |
1605 | #else | |
1606 | goto not_there; | |
1607 | #endif | |
1608 | if (strEQ(name, "TMP_MAX")) | |
1609 | #ifdef TMP_MAX | |
1610 | return TMP_MAX; | |
1611 | #else | |
1612 | goto not_there; | |
1613 | #endif | |
1614 | if (strEQ(name, "TOSTOP")) | |
1615 | #ifdef TOSTOP | |
1616 | return TOSTOP; | |
1617 | #else | |
1618 | goto not_there; | |
1619 | #endif | |
1620 | if (strEQ(name, "TZNAME_MAX")) | |
1621 | #ifdef TZNAME_MAX | |
1622 | return TZNAME_MAX; | |
1623 | #else | |
1624 | goto not_there; | |
1625 | #endif | |
1626 | break; | |
1627 | case 'U': | |
1628 | if (strEQ(name, "UCHAR_MAX")) | |
1629 | #ifdef UCHAR_MAX | |
1630 | return UCHAR_MAX; | |
1631 | #else | |
1632 | goto not_there; | |
1633 | #endif | |
1634 | if (strEQ(name, "UINT_MAX")) | |
1635 | #ifdef UINT_MAX | |
1636 | return UINT_MAX; | |
1637 | #else | |
1638 | goto not_there; | |
1639 | #endif | |
1640 | if (strEQ(name, "ULONG_MAX")) | |
1641 | #ifdef ULONG_MAX | |
1642 | return ULONG_MAX; | |
1643 | #else | |
1644 | goto not_there; | |
1645 | #endif | |
1646 | if (strEQ(name, "USHRT_MAX")) | |
1647 | #ifdef USHRT_MAX | |
1648 | return USHRT_MAX; | |
1649 | #else | |
1650 | goto not_there; | |
1651 | #endif | |
1652 | break; | |
1653 | case 'V': | |
1654 | if (strEQ(name, "VEOF")) | |
1655 | #ifdef VEOF | |
1656 | return VEOF; | |
1657 | #else | |
1658 | goto not_there; | |
1659 | #endif | |
1660 | if (strEQ(name, "VEOL")) | |
1661 | #ifdef VEOL | |
1662 | return VEOL; | |
1663 | #else | |
1664 | goto not_there; | |
1665 | #endif | |
1666 | if (strEQ(name, "VERASE")) | |
1667 | #ifdef VERASE | |
1668 | return VERASE; | |
1669 | #else | |
1670 | goto not_there; | |
1671 | #endif | |
1672 | if (strEQ(name, "VINTR")) | |
1673 | #ifdef VINTR | |
1674 | return VINTR; | |
1675 | #else | |
1676 | goto not_there; | |
1677 | #endif | |
1678 | if (strEQ(name, "VKILL")) | |
1679 | #ifdef VKILL | |
1680 | return VKILL; | |
1681 | #else | |
1682 | goto not_there; | |
1683 | #endif | |
1684 | if (strEQ(name, "VMIN")) | |
1685 | #ifdef VMIN | |
1686 | return VMIN; | |
1687 | #else | |
1688 | goto not_there; | |
1689 | #endif | |
1690 | if (strEQ(name, "VQUIT")) | |
1691 | #ifdef VQUIT | |
1692 | return VQUIT; | |
1693 | #else | |
1694 | goto not_there; | |
1695 | #endif | |
1696 | if (strEQ(name, "VSTART")) | |
1697 | #ifdef VSTART | |
1698 | return VSTART; | |
1699 | #else | |
1700 | goto not_there; | |
1701 | #endif | |
1702 | if (strEQ(name, "VSTOP")) | |
1703 | #ifdef VSTOP | |
1704 | return VSTOP; | |
1705 | #else | |
1706 | goto not_there; | |
1707 | #endif | |
1708 | if (strEQ(name, "VSUSP")) | |
1709 | #ifdef VSUSP | |
1710 | return VSUSP; | |
1711 | #else | |
1712 | goto not_there; | |
1713 | #endif | |
1714 | if (strEQ(name, "VTIME")) | |
1715 | #ifdef VTIME | |
1716 | return VTIME; | |
1717 | #else | |
1718 | goto not_there; | |
1719 | #endif | |
1720 | break; | |
1721 | case 'W': | |
1722 | if (strEQ(name, "W_OK")) | |
1723 | #ifdef W_OK | |
1724 | return W_OK; | |
1725 | #else | |
1726 | goto not_there; | |
1727 | #endif | |
1728 | #ifdef WEXITSTATUS | |
1729 | if (strEQ(name, "WEXITSTATUS")) return WEXITSTATUS(arg); | |
1730 | #endif | |
1731 | #ifdef WIFEXITED | |
1732 | if (strEQ(name, "WIFEXITED")) return WIFEXITED(arg); | |
1733 | #endif | |
1734 | #ifdef WIFSIGNALED | |
1735 | if (strEQ(name, "WIFSIGNALED")) return WIFSIGNALED(arg); | |
1736 | #endif | |
1737 | #ifdef WIFSTOPPED | |
1738 | if (strEQ(name, "WIFSTOPPED")) return WIFSTOPPED(arg); | |
1739 | #endif | |
1740 | if (strEQ(name, "WNOHANG")) | |
1741 | #ifdef WNOHANG | |
1742 | return WNOHANG; | |
1743 | #else | |
1744 | goto not_there; | |
1745 | #endif | |
1746 | #ifdef WSTOPSIG | |
1747 | if (strEQ(name, "WSTOPSIG")) return WSTOPSIG(arg); | |
1748 | #endif | |
1749 | #ifdef WTERMSIG | |
1750 | if (strEQ(name, "WTERMSIG")) return WTERMSIG(arg); | |
1751 | #endif | |
1752 | if (strEQ(name, "WUNTRACED")) | |
1753 | #ifdef WUNTRACED | |
1754 | return WUNTRACED; | |
1755 | #else | |
1756 | goto not_there; | |
1757 | #endif | |
1758 | break; | |
1759 | case 'X': | |
1760 | if (strEQ(name, "X_OK")) | |
1761 | #ifdef X_OK | |
1762 | return X_OK; | |
1763 | #else | |
1764 | goto not_there; | |
1765 | #endif | |
1766 | break; | |
1767 | case '_': | |
1768 | if (strnEQ(name, "_PC_", 4)) { | |
1769 | if (strEQ(name, "_PC_CHOWN_RESTRICTED")) | |
1770 | #ifdef _PC_CHOWN_RESTRICTED | |
1771 | return _PC_CHOWN_RESTRICTED; | |
1772 | #else | |
1773 | goto not_there; | |
1774 | #endif | |
1775 | if (strEQ(name, "_PC_LINK_MAX")) | |
1776 | #ifdef _PC_LINK_MAX | |
1777 | return _PC_LINK_MAX; | |
1778 | #else | |
1779 | goto not_there; | |
1780 | #endif | |
1781 | if (strEQ(name, "_PC_MAX_CANON")) | |
1782 | #ifdef _PC_MAX_CANON | |
1783 | return _PC_MAX_CANON; | |
1784 | #else | |
1785 | goto not_there; | |
1786 | #endif | |
1787 | if (strEQ(name, "_PC_MAX_INPUT")) | |
1788 | #ifdef _PC_MAX_INPUT | |
1789 | return _PC_MAX_INPUT; | |
1790 | #else | |
1791 | goto not_there; | |
1792 | #endif | |
1793 | if (strEQ(name, "_PC_NAME_MAX")) | |
1794 | #ifdef _PC_NAME_MAX | |
1795 | return _PC_NAME_MAX; | |
1796 | #else | |
1797 | goto not_there; | |
1798 | #endif | |
1799 | if (strEQ(name, "_PC_NO_TRUNC")) | |
1800 | #ifdef _PC_NO_TRUNC | |
1801 | return _PC_NO_TRUNC; | |
1802 | #else | |
1803 | goto not_there; | |
1804 | #endif | |
1805 | if (strEQ(name, "_PC_PATH_MAX")) | |
1806 | #ifdef _PC_PATH_MAX | |
1807 | return _PC_PATH_MAX; | |
1808 | #else | |
1809 | goto not_there; | |
1810 | #endif | |
1811 | if (strEQ(name, "_PC_PIPE_BUF")) | |
1812 | #ifdef _PC_PIPE_BUF | |
1813 | return _PC_PIPE_BUF; | |
1814 | #else | |
1815 | goto not_there; | |
1816 | #endif | |
1817 | if (strEQ(name, "_PC_VDISABLE")) | |
1818 | #ifdef _PC_VDISABLE | |
1819 | return _PC_VDISABLE; | |
1820 | #else | |
1821 | goto not_there; | |
1822 | #endif | |
1823 | break; | |
1824 | } | |
1825 | if (strnEQ(name, "_POSIX_", 7)) { | |
1826 | if (strEQ(name, "_POSIX_ARG_MAX")) | |
1827 | #ifdef _POSIX_ARG_MAX | |
1828 | return _POSIX_ARG_MAX; | |
1829 | #else | |
1830 | return 0; | |
1831 | #endif | |
1832 | if (strEQ(name, "_POSIX_CHILD_MAX")) | |
1833 | #ifdef _POSIX_CHILD_MAX | |
1834 | return _POSIX_CHILD_MAX; | |
1835 | #else | |
1836 | return 0; | |
1837 | #endif | |
1838 | if (strEQ(name, "_POSIX_CHOWN_RESTRICTED")) | |
1839 | #ifdef _POSIX_CHOWN_RESTRICTED | |
1840 | return _POSIX_CHOWN_RESTRICTED; | |
1841 | #else | |
1842 | return 0; | |
1843 | #endif | |
1844 | if (strEQ(name, "_POSIX_JOB_CONTROL")) | |
1845 | #ifdef _POSIX_JOB_CONTROL | |
1846 | return _POSIX_JOB_CONTROL; | |
1847 | #else | |
1848 | return 0; | |
1849 | #endif | |
1850 | if (strEQ(name, "_POSIX_LINK_MAX")) | |
1851 | #ifdef _POSIX_LINK_MAX | |
1852 | return _POSIX_LINK_MAX; | |
1853 | #else | |
1854 | return 0; | |
1855 | #endif | |
1856 | if (strEQ(name, "_POSIX_MAX_CANON")) | |
1857 | #ifdef _POSIX_MAX_CANON | |
1858 | return _POSIX_MAX_CANON; | |
1859 | #else | |
1860 | return 0; | |
1861 | #endif | |
1862 | if (strEQ(name, "_POSIX_MAX_INPUT")) | |
1863 | #ifdef _POSIX_MAX_INPUT | |
1864 | return _POSIX_MAX_INPUT; | |
1865 | #else | |
1866 | return 0; | |
1867 | #endif | |
1868 | if (strEQ(name, "_POSIX_NAME_MAX")) | |
1869 | #ifdef _POSIX_NAME_MAX | |
1870 | return _POSIX_NAME_MAX; | |
1871 | #else | |
1872 | return 0; | |
1873 | #endif | |
1874 | if (strEQ(name, "_POSIX_NGROUPS_MAX")) | |
1875 | #ifdef _POSIX_NGROUPS_MAX | |
1876 | return _POSIX_NGROUPS_MAX; | |
1877 | #else | |
1878 | return 0; | |
1879 | #endif | |
1880 | if (strEQ(name, "_POSIX_NO_TRUNC")) | |
1881 | #ifdef _POSIX_NO_TRUNC | |
1882 | return _POSIX_NO_TRUNC; | |
1883 | #else | |
1884 | return 0; | |
1885 | #endif | |
1886 | if (strEQ(name, "_POSIX_OPEN_MAX")) | |
1887 | #ifdef _POSIX_OPEN_MAX | |
1888 | return _POSIX_OPEN_MAX; | |
1889 | #else | |
1890 | return 0; | |
1891 | #endif | |
1892 | if (strEQ(name, "_POSIX_PATH_MAX")) | |
1893 | #ifdef _POSIX_PATH_MAX | |
1894 | return _POSIX_PATH_MAX; | |
1895 | #else | |
1896 | return 0; | |
1897 | #endif | |
1898 | if (strEQ(name, "_POSIX_PIPE_BUF")) | |
1899 | #ifdef _POSIX_PIPE_BUF | |
1900 | return _POSIX_PIPE_BUF; | |
1901 | #else | |
1902 | return 0; | |
1903 | #endif | |
1904 | if (strEQ(name, "_POSIX_SAVED_IDS")) | |
1905 | #ifdef _POSIX_SAVED_IDS | |
1906 | return _POSIX_SAVED_IDS; | |
1907 | #else | |
1908 | return 0; | |
1909 | #endif | |
1910 | if (strEQ(name, "_POSIX_SSIZE_MAX")) | |
1911 | #ifdef _POSIX_SSIZE_MAX | |
1912 | return _POSIX_SSIZE_MAX; | |
1913 | #else | |
1914 | return 0; | |
1915 | #endif | |
1916 | if (strEQ(name, "_POSIX_STREAM_MAX")) | |
1917 | #ifdef _POSIX_STREAM_MAX | |
1918 | return _POSIX_STREAM_MAX; | |
1919 | #else | |
1920 | return 0; | |
1921 | #endif | |
1922 | if (strEQ(name, "_POSIX_TZNAME_MAX")) | |
1923 | #ifdef _POSIX_TZNAME_MAX | |
1924 | return _POSIX_TZNAME_MAX; | |
1925 | #else | |
1926 | return 0; | |
1927 | #endif | |
1928 | if (strEQ(name, "_POSIX_VDISABLE")) | |
1929 | #ifdef _POSIX_VDISABLE | |
1930 | return _POSIX_VDISABLE; | |
1931 | #else | |
1932 | return 0; | |
1933 | #endif | |
1934 | if (strEQ(name, "_POSIX_VERSION")) | |
1935 | #ifdef _POSIX_VERSION | |
1936 | return _POSIX_VERSION; | |
1937 | #else | |
1938 | return 0; | |
1939 | #endif | |
1940 | break; | |
1941 | } | |
1942 | if (strnEQ(name, "_SC_", 4)) { | |
1943 | if (strEQ(name, "_SC_ARG_MAX")) | |
1944 | #ifdef _SC_ARG_MAX | |
1945 | return _SC_ARG_MAX; | |
1946 | #else | |
1947 | goto not_there; | |
1948 | #endif | |
1949 | if (strEQ(name, "_SC_CHILD_MAX")) | |
1950 | #ifdef _SC_CHILD_MAX | |
1951 | return _SC_CHILD_MAX; | |
1952 | #else | |
1953 | goto not_there; | |
1954 | #endif | |
1955 | if (strEQ(name, "_SC_CLK_TCK")) | |
1956 | #ifdef _SC_CLK_TCK | |
1957 | return _SC_CLK_TCK; | |
1958 | #else | |
1959 | goto not_there; | |
1960 | #endif | |
1961 | if (strEQ(name, "_SC_JOB_CONTROL")) | |
1962 | #ifdef _SC_JOB_CONTROL | |
1963 | return _SC_JOB_CONTROL; | |
1964 | #else | |
1965 | goto not_there; | |
1966 | #endif | |
1967 | if (strEQ(name, "_SC_NGROUPS_MAX")) | |
1968 | #ifdef _SC_NGROUPS_MAX | |
1969 | return _SC_NGROUPS_MAX; | |
1970 | #else | |
1971 | goto not_there; | |
1972 | #endif | |
1973 | if (strEQ(name, "_SC_OPEN_MAX")) | |
1974 | #ifdef _SC_OPEN_MAX | |
1975 | return _SC_OPEN_MAX; | |
1976 | #else | |
1977 | goto not_there; | |
1978 | #endif | |
1979 | if (strEQ(name, "_SC_SAVED_IDS")) | |
1980 | #ifdef _SC_SAVED_IDS | |
1981 | return _SC_SAVED_IDS; | |
1982 | #else | |
1983 | goto not_there; | |
1984 | #endif | |
1985 | if (strEQ(name, "_SC_STREAM_MAX")) | |
1986 | #ifdef _SC_STREAM_MAX | |
1987 | return _SC_STREAM_MAX; | |
1988 | #else | |
1989 | goto not_there; | |
1990 | #endif | |
1991 | if (strEQ(name, "_SC_TZNAME_MAX")) | |
1992 | #ifdef _SC_TZNAME_MAX | |
1993 | return _SC_TZNAME_MAX; | |
1994 | #else | |
1995 | goto not_there; | |
1996 | #endif | |
1997 | if (strEQ(name, "_SC_VERSION")) | |
1998 | #ifdef _SC_VERSION | |
1999 | return _SC_VERSION; | |
2000 | #else | |
2001 | goto not_there; | |
2002 | #endif | |
2003 | break; | |
2004 | } | |
2005 | if (strEQ(name, "_IOFBF")) | |
2006 | #ifdef _IOFBF | |
2007 | return _IOFBF; | |
2008 | #else | |
2009 | goto not_there; | |
2010 | #endif | |
2011 | if (strEQ(name, "_IOLBF")) | |
2012 | #ifdef _IOLBF | |
2013 | return _IOLBF; | |
2014 | #else | |
2015 | goto not_there; | |
2016 | #endif | |
2017 | if (strEQ(name, "_IONBF")) | |
2018 | #ifdef _IONBF | |
2019 | return _IONBF; | |
2020 | #else | |
2021 | goto not_there; | |
2022 | #endif | |
2023 | break; | |
2024 | } | |
2025 | errno = EINVAL; | |
2026 | return 0; | |
2027 | ||
2028 | not_there: | |
2029 | errno = ENOENT; | |
2030 | return 0; | |
2031 | } | |
2032 | ||
2033 | MODULE = SigSet PACKAGE = POSIX::SigSet PREFIX = sig | |
2034 | ||
2035 | POSIX::SigSet | |
2036 | new(packname = "POSIX::SigSet", ...) | |
2037 | char * packname | |
2038 | CODE: | |
2039 | { | |
2040 | int i; | |
2041 | RETVAL = (sigset_t*)safemalloc(sizeof(sigset_t)); | |
2042 | sigemptyset(RETVAL); | |
2043 | for (i = 2; i <= items; i++) | |
2044 | sigaddset(RETVAL, SvIV(ST(i))); | |
2045 | } | |
2046 | OUTPUT: | |
2047 | RETVAL | |
463ee0b2 | 2048 | |
8990e307 | 2049 | void |
2304df62 AD |
2050 | DESTROY(sigset) |
2051 | POSIX::SigSet sigset | |
2052 | CODE: | |
2053 | safefree(sigset); | |
2054 | ||
2055 | SysRet | |
2056 | sigaddset(sigset, sig) | |
2057 | POSIX::SigSet sigset | |
2058 | int sig | |
2059 | ||
2060 | SysRet | |
2061 | sigdelset(sigset, sig) | |
2062 | POSIX::SigSet sigset | |
2063 | int sig | |
2064 | ||
2065 | SysRet | |
2066 | sigemptyset(sigset) | |
2067 | POSIX::SigSet sigset | |
2068 | ||
2069 | SysRet | |
2070 | sigfillset(sigset) | |
2071 | POSIX::SigSet sigset | |
2072 | ||
2073 | int | |
2074 | sigismember(sigset, sig) | |
2075 | POSIX::SigSet sigset | |
2076 | int sig | |
2077 | ||
2078 | ||
2079 | MODULE = POSIX PACKAGE = POSIX | |
2080 | ||
2081 | int | |
2082 | constant(name,arg) | |
2083 | char * name | |
2084 | int arg | |
2085 | ||
2086 | int | |
2087 | isalnum(charstring) | |
2088 | char * charstring | |
2089 | CODE: | |
2090 | char *s; | |
2091 | RETVAL = 1; | |
85e6fe83 | 2092 | for (s = charstring; *s && RETVAL; s++) |
2304df62 AD |
2093 | if (!isalnum(*s)) |
2094 | RETVAL = 0; | |
2095 | OUTPUT: | |
2096 | RETVAL | |
2097 | ||
2098 | int | |
2099 | isalpha(charstring) | |
2100 | char * charstring | |
2101 | CODE: | |
2102 | char *s; | |
2103 | RETVAL = 1; | |
85e6fe83 | 2104 | for (s = charstring; *s && RETVAL; s++) |
2304df62 AD |
2105 | if (!isalpha(*s)) |
2106 | RETVAL = 0; | |
2107 | OUTPUT: | |
2108 | RETVAL | |
2109 | ||
2110 | int | |
2111 | iscntrl(charstring) | |
2112 | char * charstring | |
2113 | CODE: | |
2114 | char *s; | |
2115 | RETVAL = 1; | |
85e6fe83 | 2116 | for (s = charstring; *s && RETVAL; s++) |
2304df62 AD |
2117 | if (!iscntrl(*s)) |
2118 | RETVAL = 0; | |
2119 | OUTPUT: | |
2120 | RETVAL | |
2121 | ||
2122 | int | |
2123 | isdigit(charstring) | |
2124 | char * charstring | |
2125 | CODE: | |
2126 | char *s; | |
2127 | RETVAL = 1; | |
85e6fe83 | 2128 | for (s = charstring; *s && RETVAL; s++) |
2304df62 AD |
2129 | if (!isdigit(*s)) |
2130 | RETVAL = 0; | |
2131 | OUTPUT: | |
2132 | RETVAL | |
2133 | ||
2134 | int | |
2135 | isgraph(charstring) | |
2136 | char * charstring | |
2137 | CODE: | |
2138 | char *s; | |
2139 | RETVAL = 1; | |
85e6fe83 | 2140 | for (s = charstring; *s && RETVAL; s++) |
2304df62 AD |
2141 | if (!isgraph(*s)) |
2142 | RETVAL = 0; | |
2143 | OUTPUT: | |
2144 | RETVAL | |
2145 | ||
2146 | int | |
2147 | islower(charstring) | |
2148 | char * charstring | |
2149 | CODE: | |
2150 | char *s; | |
2151 | RETVAL = 1; | |
85e6fe83 | 2152 | for (s = charstring; *s && RETVAL; s++) |
2304df62 AD |
2153 | if (!islower(*s)) |
2154 | RETVAL = 0; | |
2155 | OUTPUT: | |
2156 | RETVAL | |
2157 | ||
2158 | int | |
2159 | isprint(charstring) | |
2160 | char * charstring | |
2161 | CODE: | |
2162 | char *s; | |
2163 | RETVAL = 1; | |
85e6fe83 | 2164 | for (s = charstring; *s && RETVAL; s++) |
2304df62 AD |
2165 | if (!isprint(*s)) |
2166 | RETVAL = 0; | |
2167 | OUTPUT: | |
2168 | RETVAL | |
2169 | ||
2170 | int | |
2171 | ispunct(charstring) | |
2172 | char * charstring | |
2173 | CODE: | |
2174 | char *s; | |
2175 | RETVAL = 1; | |
85e6fe83 | 2176 | for (s = charstring; *s && RETVAL; s++) |
2304df62 AD |
2177 | if (!ispunct(*s)) |
2178 | RETVAL = 0; | |
2179 | OUTPUT: | |
2180 | RETVAL | |
2181 | ||
2182 | int | |
2183 | isspace(charstring) | |
2184 | char * charstring | |
2185 | CODE: | |
2186 | char *s; | |
2187 | RETVAL = 1; | |
85e6fe83 | 2188 | for (s = charstring; *s && RETVAL; s++) |
2304df62 AD |
2189 | if (!isspace(*s)) |
2190 | RETVAL = 0; | |
2191 | OUTPUT: | |
2192 | RETVAL | |
8990e307 LW |
2193 | |
2194 | int | |
2304df62 AD |
2195 | isupper(charstring) |
2196 | char * charstring | |
2197 | CODE: | |
2198 | char *s; | |
2199 | RETVAL = 1; | |
85e6fe83 | 2200 | for (s = charstring; *s && RETVAL; s++) |
2304df62 AD |
2201 | if (!isupper(*s)) |
2202 | RETVAL = 0; | |
2203 | OUTPUT: | |
2204 | RETVAL | |
8990e307 LW |
2205 | |
2206 | int | |
2304df62 AD |
2207 | isxdigit(charstring) |
2208 | char * charstring | |
2209 | CODE: | |
2210 | char *s; | |
2211 | RETVAL = 1; | |
85e6fe83 | 2212 | for (s = charstring; *s && RETVAL; s++) |
2304df62 AD |
2213 | if (!isxdigit(*s)) |
2214 | RETVAL = 0; | |
2215 | OUTPUT: | |
2216 | RETVAL | |
2217 | ||
2218 | SysRet | |
2219 | open(filename, flags = O_RDONLY, mode = 0666) | |
2220 | char * filename | |
2221 | int flags | |
2222 | int mode | |
2223 | ||
2224 | HV * | |
2225 | localeconv() | |
2226 | CODE: | |
2227 | struct lconv *lcbuf; | |
2228 | RETVAL = newHV(); | |
2229 | if (lcbuf = localeconv()) { | |
2230 | /* the strings */ | |
2231 | if (lcbuf->decimal_point && *lcbuf->decimal_point) | |
2232 | hv_store(RETVAL, "decimal_point", 13, | |
2233 | newSVpv(lcbuf->decimal_point, 0), 0); | |
2234 | if (lcbuf->thousands_sep && *lcbuf->thousands_sep) | |
2235 | hv_store(RETVAL, "thousands_sep", 13, | |
2236 | newSVpv(lcbuf->thousands_sep, 0), 0); | |
2237 | if (lcbuf->grouping && *lcbuf->grouping) | |
2238 | hv_store(RETVAL, "grouping", 8, | |
2239 | newSVpv(lcbuf->grouping, 0), 0); | |
2240 | if (lcbuf->int_curr_symbol && *lcbuf->int_curr_symbol) | |
2241 | hv_store(RETVAL, "int_curr_symbol", 15, | |
2242 | newSVpv(lcbuf->int_curr_symbol, 0), 0); | |
2243 | if (lcbuf->currency_symbol && *lcbuf->currency_symbol) | |
2244 | hv_store(RETVAL, "currency_symbol", 15, | |
2245 | newSVpv(lcbuf->currency_symbol, 0), 0); | |
2246 | if (lcbuf->mon_decimal_point && *lcbuf->mon_decimal_point) | |
2247 | hv_store(RETVAL, "mon_decimal_point", 17, | |
2248 | newSVpv(lcbuf->mon_decimal_point, 0), 0); | |
2249 | if (lcbuf->mon_thousands_sep && *lcbuf->mon_thousands_sep) | |
2250 | hv_store(RETVAL, "mon_thousands_sep", 17, | |
2251 | newSVpv(lcbuf->mon_thousands_sep, 0), 0); | |
2252 | if (lcbuf->mon_grouping && *lcbuf->mon_grouping) | |
2253 | hv_store(RETVAL, "mon_grouping", 12, | |
2254 | newSVpv(lcbuf->mon_grouping, 0), 0); | |
2255 | if (lcbuf->positive_sign && *lcbuf->positive_sign) | |
2256 | hv_store(RETVAL, "positive_sign", 13, | |
2257 | newSVpv(lcbuf->positive_sign, 0), 0); | |
2258 | if (lcbuf->negative_sign && *lcbuf->negative_sign) | |
2259 | hv_store(RETVAL, "negative_sign", 13, | |
2260 | newSVpv(lcbuf->negative_sign, 0), 0); | |
2261 | /* the integers */ | |
2262 | if (lcbuf->int_frac_digits != CHAR_MAX) | |
2263 | hv_store(RETVAL, "int_frac_digits", 15, | |
2264 | newSViv(lcbuf->int_frac_digits), 0); | |
2265 | if (lcbuf->frac_digits != CHAR_MAX) | |
2266 | hv_store(RETVAL, "frac_digits", 11, | |
2267 | newSViv(lcbuf->frac_digits), 0); | |
2268 | if (lcbuf->p_cs_precedes != CHAR_MAX) | |
2269 | hv_store(RETVAL, "p_cs_precedes", 13, | |
2270 | newSViv(lcbuf->p_cs_precedes), 0); | |
2271 | if (lcbuf->p_sep_by_space != CHAR_MAX) | |
2272 | hv_store(RETVAL, "p_sep_by_space", 14, | |
2273 | newSViv(lcbuf->p_sep_by_space), 0); | |
2274 | if (lcbuf->n_cs_precedes != CHAR_MAX) | |
2275 | hv_store(RETVAL, "n_cs_precedes", 13, | |
2276 | newSViv(lcbuf->n_cs_precedes), 0); | |
2277 | if (lcbuf->n_sep_by_space != CHAR_MAX) | |
2278 | hv_store(RETVAL, "n_sep_by_space", 14, | |
2279 | newSViv(lcbuf->n_sep_by_space), 0); | |
2280 | if (lcbuf->p_sign_posn != CHAR_MAX) | |
2281 | hv_store(RETVAL, "p_sign_posn", 11, | |
2282 | newSViv(lcbuf->p_sign_posn), 0); | |
2283 | if (lcbuf->n_sign_posn != CHAR_MAX) | |
2284 | hv_store(RETVAL, "n_sign_posn", 11, | |
2285 | newSViv(lcbuf->n_sign_posn), 0); | |
2286 | } | |
2287 | OUTPUT: | |
2288 | RETVAL | |
2289 | ||
2290 | char * | |
2291 | setlocale(category, locale) | |
2292 | int category | |
2293 | char * locale | |
2294 | ||
2295 | double | |
2296 | acos(x) | |
2297 | double x | |
2298 | ||
2299 | double | |
2300 | asin(x) | |
2301 | double x | |
2302 | ||
2303 | double | |
2304 | atan(x) | |
2305 | double x | |
2306 | ||
2307 | double | |
2308 | ceil(x) | |
2309 | double x | |
2310 | ||
2311 | double | |
2312 | cosh(x) | |
2313 | double x | |
2314 | ||
2315 | double | |
2316 | floor(x) | |
2317 | double x | |
2318 | ||
2319 | double | |
2320 | fmod(x,y) | |
2321 | double x | |
2322 | double y | |
2323 | ||
2324 | void | |
2325 | frexp(x) | |
2326 | double x | |
2327 | PPCODE: | |
2328 | int expvar; | |
2329 | sp--; | |
2330 | /* (We already know stack is long enough.) */ | |
2331 | PUSHs(sv_2mortal(newSVnv(frexp(x,&expvar)))); | |
2332 | PUSHs(sv_2mortal(newSViv(expvar))); | |
2333 | ||
2334 | double | |
2335 | ldexp(x,exp) | |
2336 | double x | |
2337 | int exp | |
2338 | ||
2339 | double | |
2340 | log10(x) | |
2341 | double x | |
2342 | ||
2343 | void | |
2344 | modf(x) | |
2345 | double x | |
2346 | PPCODE: | |
2347 | double intvar; | |
2348 | sp--; | |
2349 | /* (We already know stack is long enough.) */ | |
2350 | PUSHs(sv_2mortal(newSVnv(modf(x,&intvar)))); | |
2351 | PUSHs(sv_2mortal(newSVnv(intvar))); | |
2352 | ||
2353 | double | |
2354 | sinh(x) | |
2355 | double x | |
2356 | ||
2357 | double | |
2358 | tanh(x) | |
2359 | double x | |
2360 | ||
2361 | SysRet | |
2362 | sigaction(sig, action, oldaction = 0) | |
2363 | int sig | |
2364 | POSIX::SigAction action | |
2365 | POSIX::SigAction oldaction | |
2366 | CODE: | |
2367 | ||
2368 | # This code is really grody because we're trying to make the signal | |
2369 | # interface look beautiful, which is hard. | |
2370 | ||
2371 | if (!siggv) | |
85e6fe83 | 2372 | gv_fetchpv("SIG", TRUE, SVt_PVHV); |
2304df62 AD |
2373 | |
2374 | { | |
2375 | struct sigaction act; | |
2376 | struct sigaction oact; | |
2377 | POSIX__SigSet sigset; | |
2378 | SV** svp; | |
2379 | SV** sigsvp = hv_fetch(GvHVn(siggv), | |
2380 | sig_name[sig], | |
2381 | strlen(sig_name[sig]), | |
2382 | TRUE); | |
2383 | ||
2384 | /* Remember old handler name if desired. */ | |
2385 | if (oldaction) { | |
2386 | char *hand = SvPVx(*sigsvp, na); | |
2387 | svp = hv_fetch(oldaction, "HANDLER", 7, TRUE); | |
2388 | sv_setpv(*svp, *hand ? hand : "DEFAULT"); | |
2389 | } | |
2390 | ||
2391 | if (action) { | |
2392 | /* Vector new handler through %SIG. (We always use sighandler | |
2393 | for the C signal handler, which reads %SIG to dispatch.) */ | |
2394 | svp = hv_fetch(action, "HANDLER", 7, FALSE); | |
2395 | if (!svp) | |
2396 | croak("Can't supply an action without a HANDLER"); | |
2397 | sv_setpv(*sigsvp, SvPV(*svp, na)); | |
2398 | mg_set(*sigsvp); /* handles DEFAULT and IGNORE */ | |
2399 | act.sa_handler = sighandler; | |
2400 | ||
2401 | /* Set up any desired mask. */ | |
2402 | svp = hv_fetch(action, "MASK", 4, FALSE); | |
2403 | if (svp && sv_isa(*svp, "POSIX::SigSet")) { | |
2404 | sigset = (sigset_t*)(unsigned long)SvNV((SV*)SvRV(*svp)); | |
2405 | act.sa_mask = *sigset; | |
2406 | } | |
2407 | else | |
85e6fe83 | 2408 | sigemptyset(& act.sa_mask); |
2304df62 AD |
2409 | |
2410 | /* Set up any desired flags. */ | |
2411 | svp = hv_fetch(action, "FLAGS", 5, FALSE); | |
2412 | act.sa_flags = svp ? SvIV(*svp) : 0; | |
2413 | } | |
2414 | ||
2415 | /* Now work around sigaction oddities */ | |
2416 | if (action && oldaction) | |
85e6fe83 | 2417 | RETVAL = sigaction(sig, & act, & oact); |
2304df62 | 2418 | else if (action) |
85e6fe83 | 2419 | RETVAL = sigaction(sig, & act, (struct sigaction*)0); |
2304df62 | 2420 | else if (oldaction) |
85e6fe83 | 2421 | RETVAL = sigaction(sig, (struct sigaction*)0, & oact); |
2304df62 AD |
2422 | |
2423 | if (oldaction) { | |
2424 | /* Get back the mask. */ | |
2425 | svp = hv_fetch(oldaction, "MASK", 4, TRUE); | |
2426 | if (sv_isa(*svp, "POSIX::SigSet")) | |
2427 | sigset = (sigset_t*)(unsigned long)SvNV((SV*)SvRV(*svp)); | |
2428 | else { | |
2429 | sigset = (sigset_t*)safemalloc(sizeof(sigset_t)); | |
2430 | sv_setptrobj(*svp, sigset, "POSIX::SigSet"); | |
2431 | } | |
2432 | *sigset = oact.sa_mask; | |
2433 | ||
2434 | /* Get back the flags. */ | |
2435 | svp = hv_fetch(oldaction, "FLAGS", 5, TRUE); | |
2436 | sv_setiv(*svp, oact.sa_flags); | |
2437 | } | |
2438 | } | |
2439 | OUTPUT: | |
2440 | RETVAL | |
2441 | ||
2442 | SysRet | |
2443 | sigpending(sigset) | |
2444 | POSIX::SigSet sigset | |
2445 | ||
2446 | SysRet | |
2447 | sigprocmask(how, sigset, oldsigset = 0) | |
2448 | int how | |
2449 | POSIX::SigSet sigset | |
2450 | POSIX::SigSet oldsigset | |
2451 | ||
2452 | SysRet | |
2453 | sigsuspend(signal_mask) | |
2454 | POSIX::SigSet signal_mask | |
2455 | ||
2456 | ############ Work in progress | |
2457 | ||
2458 | #FileHandle | |
2459 | #fdopen(fd, type) | |
2460 | # int fd | |
2461 | # char * type | |
2462 | ||
2463 | #int | |
2464 | #ferror(handle) | |
2465 | # FileHandle handle | |
2466 | ||
2467 | #SysRet | |
2468 | #fflush(handle) | |
2469 | # OutputHandle handle | |
2470 | ||
2471 | void | |
2472 | _exit(status) | |
2473 | int status | |
8990e307 | 2474 | |
85e6fe83 | 2475 | SysRet |
8990e307 LW |
2476 | close(fd) |
2477 | int fd | |
2478 | ||
85e6fe83 | 2479 | SysRet |
8990e307 LW |
2480 | dup(fd) |
2481 | int fd | |
2482 | ||
85e6fe83 | 2483 | SysRet |
8990e307 LW |
2484 | dup2(fd1, fd2) |
2485 | int fd1 | |
2486 | int fd2 | |
2487 | ||
85e6fe83 | 2488 | SysRet |
8990e307 | 2489 | lseek() |
85e6fe83 LW |
2490 | int fd |
2491 | Off_t offset | |
2492 | int whence | |
8990e307 | 2493 | |
85e6fe83 | 2494 | SysRet |
8990e307 LW |
2495 | nice(incr) |
2496 | int incr | |
2497 | ||
2498 | int | |
8990e307 | 2499 | pipe() |
85e6fe83 LW |
2500 | PPCODE: |
2501 | int fds[2]; | |
2502 | sp--; | |
2503 | if (pipe(fds) != -1) { | |
2504 | EXTEND(sp,2); | |
2505 | PUSHs(sv_2mortal(newSViv(fds[0]))); | |
2506 | PUSHs(sv_2mortal(newSViv(fds[1]))); | |
2507 | } | |
8990e307 | 2508 | |
85e6fe83 | 2509 | SysRet |
8990e307 | 2510 | read() |
85e6fe83 LW |
2511 | CODE: |
2512 | int fd; | |
2513 | char * buffer; | |
2514 | size_t nbytes; | |
8990e307 | 2515 | |
85e6fe83 LW |
2516 | RETVAL = read(fd, buffer, nbytes); |
2517 | croak("POSIX::read() not implemented yet\n"); | |
2518 | OUTPUT: | |
2519 | RETVAL | |
8990e307 | 2520 | |
85e6fe83 LW |
2521 | SysRet |
2522 | setgid(gid) | |
2523 | Gid_t gid | |
8990e307 | 2524 | |
85e6fe83 | 2525 | SysRet |
8990e307 LW |
2526 | setpgid(pid, pgid) |
2527 | pid_t pid | |
2528 | pid_t pgid | |
2529 | ||
8990e307 LW |
2530 | pid_t |
2531 | setsid() | |
2532 | ||
85e6fe83 LW |
2533 | SysRet |
2534 | setuid(uid) | |
2535 | Uid_t uid | |
8990e307 LW |
2536 | |
2537 | pid_t | |
2538 | tcgetpgrp(fd) | |
2539 | int fd | |
2540 | ||
85e6fe83 | 2541 | SysRet |
8990e307 LW |
2542 | tcsetpgrp(fd, pgrp_id) |
2543 | int fd | |
2544 | pid_t pgrp_id | |
2545 | ||
2546 | int | |
8990e307 | 2547 | uname() |
2304df62 | 2548 | PPCODE: |
85e6fe83 | 2549 | struct utsname buf; |
8990e307 | 2550 | sp--; |
85e6fe83 | 2551 | if (uname(&buf) >= 0) { |
8990e307 | 2552 | EXTEND(sp, 5); |
85e6fe83 LW |
2553 | PUSHs(sv_2mortal(newSVpv(buf.sysname, 0))); |
2554 | PUSHs(sv_2mortal(newSVpv(buf.nodename, 0))); | |
2555 | PUSHs(sv_2mortal(newSVpv(buf.release, 0))); | |
2556 | PUSHs(sv_2mortal(newSVpv(buf.version, 0))); | |
2557 | PUSHs(sv_2mortal(newSVpv(buf.machine, 0))); | |
8990e307 | 2558 | } |
8990e307 | 2559 | |
85e6fe83 | 2560 | SysRet |
8990e307 | 2561 | write() |
85e6fe83 LW |
2562 | CODE: |
2563 | int fd; | |
2564 | char * buffer; | |
2565 | size_t nbytes; | |
8990e307 | 2566 | |
85e6fe83 LW |
2567 | RETVAL = write(fd, buffer, nbytes); |
2568 | croak("POSIX::write() not implemented yet\n"); | |
2569 | OUTPUT: | |
2570 | RETVAL |