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