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