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