Commit | Line | Data |
---|---|---|
c5be433b | 1 | #define PERL_NO_GET_CONTEXT |
a0d0e21e LW |
2 | #include "EXTERN.h" |
3 | #include "perl.h" | |
4 | #include "XSUB.h" | |
5 | ||
75ced34b | 6 | #ifdef VMS |
7 | # include <file.h> | |
8 | #else | |
cd661bb6 NIS |
9 | #if defined(__GNUC__) && defined(__cplusplus) && defined(WIN32) |
10 | #define _NO_OLDNAMES | |
11 | #endif | |
75ced34b | 12 | # include <fcntl.h> |
cd661bb6 NIS |
13 | #if defined(__GNUC__) && defined(__cplusplus) && defined(WIN32) |
14 | #undef _NO_OLDNAMES | |
15 | #endif | |
75ced34b | 16 | #endif |
a0d0e21e | 17 | |
ac88732c JH |
18 | #ifdef I_UNISTD |
19 | #include <unistd.h> | |
20 | #endif | |
21 | ||
8e07c86e AD |
22 | /* This comment is a kludge to get metaconfig to see the symbols |
23 | VAL_O_NONBLOCK | |
24 | VAL_EAGAIN | |
25 | RD_NODATA | |
26 | EOF_NONBLOCK | |
27 | and include the appropriate metaconfig unit | |
28 | so that Configure will test how to turn on non-blocking I/O | |
29 | for a file descriptor. See config.h for how to use these | |
30 | in your extension. | |
31 | ||
32 | While I'm at it, I'll have metaconfig look for HAS_POLL too. | |
33 | --AD October 16, 1995 | |
34 | */ | |
35 | ||
a0d0e21e | 36 | static int |
f0f333f4 | 37 | not_here(char *s) |
a0d0e21e LW |
38 | { |
39 | croak("%s not implemented on this architecture", s); | |
40 | return -1; | |
41 | } | |
42 | ||
7ea3cd40 NIS |
43 | static IV |
44 | constant(char *name) | |
a0d0e21e LW |
45 | { |
46 | errno = 0; | |
7ea3cd40 | 47 | switch (*(name++)) { |
ca6e1c26 | 48 | case '_': |
7ea3cd40 | 49 | if (strEQ(name, "S_IFMT")) /* Yes, on name _S_IFMT return S_IFMT. */ |
ca6e1c26 JH |
50 | #ifdef S_IFMT |
51 | return S_IFMT; | |
52 | #else | |
53 | goto not_there; | |
54 | #endif | |
55 | break; | |
a0d0e21e | 56 | case 'F': |
7ea3cd40 NIS |
57 | if (*name == '_') { |
58 | name++; | |
59 | if (strEQ(name, "ALLOCSP")) | |
ac88732c JH |
60 | #ifdef F_ALLOCSP |
61 | return F_ALLOCSP; | |
62 | #else | |
63 | goto not_there; | |
64 | #endif | |
7ea3cd40 | 65 | if (strEQ(name, "ALLOCSP64")) |
ac88732c JH |
66 | #ifdef F_ALLOCSP64 |
67 | return F_ALLOCSP64; | |
68 | #else | |
69 | goto not_there; | |
70 | #endif | |
7ea3cd40 | 71 | if (strEQ(name, "COMPAT")) |
ac88732c JH |
72 | #ifdef F_COMPAT |
73 | return F_COMPAT; | |
74 | #else | |
75 | goto not_there; | |
76 | #endif | |
7ea3cd40 | 77 | if (strEQ(name, "DUP2FD")) |
ac88732c JH |
78 | #ifdef F_DUP2FD |
79 | return F_DUP2FD; | |
80 | #else | |
81 | goto not_there; | |
82 | #endif | |
7ea3cd40 | 83 | if (strEQ(name, "DUPFD")) |
a0d0e21e LW |
84 | #ifdef F_DUPFD |
85 | return F_DUPFD; | |
86 | #else | |
87 | goto not_there; | |
88 | #endif | |
7ea3cd40 | 89 | if (strEQ(name, "EXLCK")) |
0fd60c2a JH |
90 | #ifdef F_EXLCK |
91 | return F_EXLCK; | |
92 | #else | |
93 | goto not_there; | |
94 | #endif | |
7ea3cd40 | 95 | if (strEQ(name, "FREESP")) |
ac88732c JH |
96 | #ifdef F_FREESP |
97 | return F_FREESP; | |
98 | #else | |
99 | goto not_there; | |
100 | #endif | |
7ea3cd40 | 101 | if (strEQ(name, "FREESP64")) |
ac88732c JH |
102 | #ifdef F_FREESP64 |
103 | return F_FREESP64; | |
104 | #else | |
105 | goto not_there; | |
106 | #endif | |
7ea3cd40 | 107 | if (strEQ(name, "FSYNC")) |
ac88732c JH |
108 | #ifdef F_FSYNC |
109 | return F_FSYNC; | |
110 | #else | |
111 | goto not_there; | |
112 | #endif | |
7ea3cd40 | 113 | if (strEQ(name, "FSYNC64")) |
ac88732c JH |
114 | #ifdef F_FSYNC64 |
115 | return F_FSYNC64; | |
116 | #else | |
117 | goto not_there; | |
118 | #endif | |
7ea3cd40 | 119 | if (strEQ(name, "GETFD")) |
a0d0e21e LW |
120 | #ifdef F_GETFD |
121 | return F_GETFD; | |
122 | #else | |
123 | goto not_there; | |
124 | #endif | |
7ea3cd40 | 125 | if (strEQ(name, "GETFL")) |
0fd60c2a JH |
126 | #ifdef F_GETFL |
127 | return F_GETFL; | |
128 | #else | |
129 | goto not_there; | |
130 | #endif | |
7ea3cd40 | 131 | if (strEQ(name, "GETLK")) |
a0d0e21e LW |
132 | #ifdef F_GETLK |
133 | return F_GETLK; | |
134 | #else | |
135 | goto not_there; | |
136 | #endif | |
7ea3cd40 | 137 | if (strEQ(name, "GETLK64")) |
5ff3f7a4 GS |
138 | #ifdef F_GETLK64 |
139 | return F_GETLK64; | |
140 | #else | |
141 | goto not_there; | |
142 | #endif | |
7ea3cd40 | 143 | if (strEQ(name, "GETOWN")) |
5f832ef3 JH |
144 | #ifdef F_GETOWN |
145 | return F_GETOWN; | |
146 | #else | |
147 | goto not_there; | |
148 | #endif | |
7ea3cd40 | 149 | if (strEQ(name, "NODNY")) |
ac88732c JH |
150 | #ifdef F_NODNY |
151 | return F_NODNY; | |
152 | #else | |
153 | goto not_there; | |
154 | #endif | |
7ea3cd40 | 155 | if (strEQ(name, "POSIX")) |
0fd60c2a JH |
156 | #ifdef F_POSIX |
157 | return F_POSIX; | |
a0d0e21e LW |
158 | #else |
159 | goto not_there; | |
160 | #endif | |
7ea3cd40 | 161 | if (strEQ(name, "RDACC")) |
ac88732c JH |
162 | #ifdef F_RDACC |
163 | return F_RDACC; | |
164 | #else | |
165 | goto not_there; | |
166 | #endif | |
7ea3cd40 | 167 | if (strEQ(name, "RDDNY")) |
ac88732c JH |
168 | #ifdef F_RDDNY |
169 | return F_RDDNY; | |
170 | #else | |
171 | goto not_there; | |
172 | #endif | |
7ea3cd40 | 173 | if (strEQ(name, "RDLCK")) |
0fd60c2a JH |
174 | #ifdef F_RDLCK |
175 | return F_RDLCK; | |
a0d0e21e LW |
176 | #else |
177 | goto not_there; | |
178 | #endif | |
7ea3cd40 | 179 | if (strEQ(name, "RWACC")) |
ac88732c JH |
180 | #ifdef F_RWACC |
181 | return F_RWACC; | |
182 | #else | |
183 | goto not_there; | |
184 | #endif | |
7ea3cd40 | 185 | if (strEQ(name, "RWDNY")) |
ac88732c JH |
186 | #ifdef F_RWDNY |
187 | return F_RWDNY; | |
188 | #else | |
189 | goto not_there; | |
190 | #endif | |
7ea3cd40 | 191 | if (strEQ(name, "SETFD")) |
0fd60c2a JH |
192 | #ifdef F_SETFD |
193 | return F_SETFD; | |
3e3baf6d TB |
194 | #else |
195 | goto not_there; | |
196 | #endif | |
7ea3cd40 | 197 | if (strEQ(name, "SETFL")) |
232e078e AD |
198 | #ifdef F_SETFL |
199 | return F_SETFL; | |
a0d0e21e LW |
200 | #else |
201 | goto not_there; | |
202 | #endif | |
7ea3cd40 | 203 | if (strEQ(name, "SETLK")) |
d9fde92e GS |
204 | #ifdef F_SETLK |
205 | return F_SETLK; | |
206 | #else | |
207 | goto not_there; | |
208 | #endif | |
7ea3cd40 | 209 | if (strEQ(name, "SETLK64")) |
5ff3f7a4 GS |
210 | #ifdef F_SETLK64 |
211 | return F_SETLK64; | |
a0d0e21e LW |
212 | #else |
213 | goto not_there; | |
214 | #endif | |
7ea3cd40 | 215 | if (strEQ(name, "SETLKW")) |
a0d0e21e LW |
216 | #ifdef F_SETLKW |
217 | return F_SETLKW; | |
218 | #else | |
219 | goto not_there; | |
220 | #endif | |
7ea3cd40 | 221 | if (strEQ(name, "SETLKW64")) |
5ff3f7a4 GS |
222 | #ifdef F_SETLKW64 |
223 | return F_SETLKW64; | |
224 | #else | |
225 | goto not_there; | |
226 | #endif | |
7ea3cd40 | 227 | if (strEQ(name, "SETOWN")) |
5f832ef3 JH |
228 | #ifdef F_SETOWN |
229 | return F_SETOWN; | |
230 | #else | |
231 | goto not_there; | |
232 | #endif | |
7ea3cd40 | 233 | if (strEQ(name, "SHARE")) |
ac88732c JH |
234 | #ifdef F_SHARE |
235 | return F_SHARE; | |
236 | #else | |
237 | goto not_there; | |
238 | #endif | |
7ea3cd40 | 239 | if (strEQ(name, "SHLCK")) |
0fd60c2a JH |
240 | #ifdef F_SHLCK |
241 | return F_SHLCK; | |
a0d0e21e LW |
242 | #else |
243 | goto not_there; | |
244 | #endif | |
7ea3cd40 | 245 | if (strEQ(name, "UNLCK")) |
a0d0e21e LW |
246 | #ifdef F_UNLCK |
247 | return F_UNLCK; | |
248 | #else | |
249 | goto not_there; | |
250 | #endif | |
7ea3cd40 | 251 | if (strEQ(name, "UNSHARE")) |
ac88732c JH |
252 | #ifdef F_UNSHARE |
253 | return F_UNSHARE; | |
254 | #else | |
255 | goto not_there; | |
256 | #endif | |
7ea3cd40 | 257 | if (strEQ(name, "WRACC")) |
ac88732c JH |
258 | #ifdef F_WRACC |
259 | return F_WRACC; | |
260 | #else | |
261 | goto not_there; | |
262 | #endif | |
7ea3cd40 | 263 | if (strEQ(name, "WRDNY")) |
ac88732c JH |
264 | #ifdef F_WRDNY |
265 | return F_WRDNY; | |
266 | #else | |
267 | goto not_there; | |
268 | #endif | |
7ea3cd40 | 269 | if (strEQ(name, "WRLCK")) |
a0d0e21e LW |
270 | #ifdef F_WRLCK |
271 | return F_WRLCK; | |
272 | #else | |
273 | goto not_there; | |
274 | #endif | |
275 | errno = EINVAL; | |
276 | return 0; | |
3e3baf6d | 277 | } |
7ea3cd40 | 278 | if (strEQ(name, "APPEND")) |
3e3baf6d TB |
279 | #ifdef FAPPEND |
280 | return FAPPEND; | |
281 | #else | |
282 | goto not_there; | |
283 | #endif | |
7ea3cd40 | 284 | if (strEQ(name, "ASYNC")) |
3e3baf6d TB |
285 | #ifdef FASYNC |
286 | return FASYNC; | |
287 | #else | |
288 | goto not_there; | |
289 | #endif | |
7ea3cd40 | 290 | if (strEQ(name, "CREAT")) |
3e3baf6d TB |
291 | #ifdef FCREAT |
292 | return FCREAT; | |
293 | #else | |
294 | goto not_there; | |
295 | #endif | |
7ea3cd40 | 296 | if (strEQ(name, "D_CLOEXEC")) |
a0d0e21e LW |
297 | #ifdef FD_CLOEXEC |
298 | return FD_CLOEXEC; | |
299 | #else | |
300 | goto not_there; | |
301 | #endif | |
7ea3cd40 | 302 | if (strEQ(name, "DEFER")) |
0fd60c2a JH |
303 | #ifdef FDEFER |
304 | return FDEFER; | |
305 | #else | |
306 | goto not_there; | |
307 | #endif | |
7ea3cd40 | 308 | if (strEQ(name, "DSYNC")) |
ac88732c JH |
309 | #ifdef FDSYNC |
310 | return FDSYNC; | |
311 | #else | |
312 | goto not_there; | |
313 | #endif | |
7ea3cd40 | 314 | if (strEQ(name, "EXCL")) |
3e3baf6d TB |
315 | #ifdef FEXCL |
316 | return FEXCL; | |
317 | #else | |
318 | goto not_there; | |
319 | #endif | |
7ea3cd40 | 320 | if (strEQ(name, "LARGEFILE")) |
ac88732c JH |
321 | #ifdef FLARGEFILE |
322 | return FLARGEFILE; | |
323 | #else | |
324 | goto not_there; | |
325 | #endif | |
7ea3cd40 | 326 | if (strEQ(name, "NDELAY")) |
3e3baf6d TB |
327 | #ifdef FNDELAY |
328 | return FNDELAY; | |
329 | #else | |
330 | goto not_there; | |
331 | #endif | |
7ea3cd40 | 332 | if (strEQ(name, "NONBLOCK")) |
3e3baf6d TB |
333 | #ifdef FNONBLOCK |
334 | return FNONBLOCK; | |
335 | #else | |
336 | goto not_there; | |
337 | #endif | |
7ea3cd40 | 338 | if (strEQ(name, "RSYNC")) |
ac88732c JH |
339 | #ifdef FRSYNC |
340 | return FRSYNC; | |
341 | #else | |
342 | goto not_there; | |
343 | #endif | |
7ea3cd40 | 344 | if (strEQ(name, "SYNC")) |
3e3baf6d TB |
345 | #ifdef FSYNC |
346 | return FSYNC; | |
347 | #else | |
348 | goto not_there; | |
349 | #endif | |
7ea3cd40 | 350 | if (strEQ(name, "TRUNC")) |
3e3baf6d TB |
351 | #ifdef FTRUNC |
352 | return FTRUNC; | |
353 | #else | |
354 | goto not_there; | |
355 | #endif | |
a0d0e21e | 356 | break; |
7e1af8bc | 357 | case 'L': |
7ea3cd40 | 358 | if (strnEQ(name, "OCK_", 4)) { |
7e1af8bc | 359 | /* We support flock() on systems which don't have it, so |
360 | always supply the constants. */ | |
7ea3cd40 NIS |
361 | name += 4; |
362 | if (strEQ(name, "SH")) | |
7e1af8bc | 363 | #ifdef LOCK_SH |
364 | return LOCK_SH; | |
365 | #else | |
366 | return 1; | |
367 | #endif | |
7ea3cd40 | 368 | if (strEQ(name, "EX")) |
7e1af8bc | 369 | #ifdef LOCK_EX |
370 | return LOCK_EX; | |
371 | #else | |
372 | return 2; | |
373 | #endif | |
7ea3cd40 | 374 | if (strEQ(name, "NB")) |
7e1af8bc | 375 | #ifdef LOCK_NB |
376 | return LOCK_NB; | |
377 | #else | |
378 | return 4; | |
379 | #endif | |
7ea3cd40 | 380 | if (strEQ(name, "UN")) |
7e1af8bc | 381 | #ifdef LOCK_UN |
382 | return LOCK_UN; | |
383 | #else | |
384 | return 8; | |
385 | #endif | |
386 | } else | |
387 | goto not_there; | |
388 | break; | |
a0d0e21e | 389 | case 'O': |
7ea3cd40 NIS |
390 | if (name[0] == '_') { |
391 | name++; | |
392 | if (strEQ(name, "ACCMODE")) | |
0fd60c2a JH |
393 | #ifdef O_ACCMODE |
394 | return O_ACCMODE; | |
395 | #else | |
396 | goto not_there; | |
397 | #endif | |
7ea3cd40 | 398 | if (strEQ(name, "APPEND")) |
0fd60c2a JH |
399 | #ifdef O_APPEND |
400 | return O_APPEND; | |
401 | #else | |
402 | goto not_there; | |
403 | #endif | |
7ea3cd40 | 404 | if (strEQ(name, "ASYNC")) |
0fd60c2a JH |
405 | #ifdef O_ASYNC |
406 | return O_ASYNC; | |
407 | #else | |
408 | goto not_there; | |
409 | #endif | |
7ea3cd40 | 410 | if (strEQ(name, "BINARY")) |
0fd60c2a JH |
411 | #ifdef O_BINARY |
412 | return O_BINARY; | |
413 | #else | |
414 | goto not_there; | |
415 | #endif | |
7ea3cd40 | 416 | if (strEQ(name, "CREAT")) |
a0d0e21e LW |
417 | #ifdef O_CREAT |
418 | return O_CREAT; | |
419 | #else | |
420 | goto not_there; | |
421 | #endif | |
7ea3cd40 | 422 | if (strEQ(name, "DEFER")) |
0fd60c2a JH |
423 | #ifdef O_DEFER |
424 | return O_DEFER; | |
425 | #else | |
426 | goto not_there; | |
427 | #endif | |
7ea3cd40 | 428 | if (strEQ(name, "DIRECT")) |
ca6e1c26 JH |
429 | #ifdef O_DIRECT |
430 | return O_DIRECT; | |
431 | #else | |
432 | goto not_there; | |
433 | #endif | |
7ea3cd40 | 434 | if (strEQ(name, "DIRECTORY")) |
ca6e1c26 JH |
435 | #ifdef O_DIRECTORY |
436 | return O_DIRECTORY; | |
437 | #else | |
438 | goto not_there; | |
439 | #endif | |
7ea3cd40 | 440 | if (strEQ(name, "DSYNC")) |
0fd60c2a JH |
441 | #ifdef O_DSYNC |
442 | return O_DSYNC; | |
443 | #else | |
444 | goto not_there; | |
445 | #endif | |
7ea3cd40 | 446 | if (strEQ(name, "EXCL")) |
a0d0e21e LW |
447 | #ifdef O_EXCL |
448 | return O_EXCL; | |
449 | #else | |
450 | goto not_there; | |
451 | #endif | |
7ea3cd40 | 452 | if (strEQ(name, "EXLOCK")) |
0fd60c2a JH |
453 | #ifdef O_EXLOCK |
454 | return O_EXLOCK; | |
a0d0e21e LW |
455 | #else |
456 | goto not_there; | |
457 | #endif | |
7ea3cd40 | 458 | if (strEQ(name, "LARGEFILE")) |
5ff3f7a4 GS |
459 | #ifdef O_LARGEFILE |
460 | return O_LARGEFILE; | |
461 | #else | |
462 | goto not_there; | |
463 | #endif | |
7ea3cd40 | 464 | if (strEQ(name, "NDELAY")) |
0fd60c2a JH |
465 | #ifdef O_NDELAY |
466 | return O_NDELAY; | |
a0d0e21e LW |
467 | #else |
468 | goto not_there; | |
469 | #endif | |
7ea3cd40 | 470 | if (strEQ(name, "NOCTTY")) |
0fd60c2a JH |
471 | #ifdef O_NOCTTY |
472 | return O_NOCTTY; | |
a0d0e21e LW |
473 | #else |
474 | goto not_there; | |
475 | #endif | |
7ea3cd40 | 476 | if (strEQ(name, "NOFOLLOW")) |
ca6e1c26 JH |
477 | #ifdef O_NOFOLLOW |
478 | return O_NOFOLLOW; | |
479 | #else | |
480 | goto not_there; | |
481 | #endif | |
7ea3cd40 | 482 | if (strEQ(name, "NOINHERIT")) |
8c99d73e GS |
483 | #ifdef O_NOINHERIT |
484 | return O_NOINHERIT; | |
485 | #else | |
486 | goto not_there; | |
487 | #endif | |
7ea3cd40 | 488 | if (strEQ(name, "NONBLOCK")) |
a0d0e21e LW |
489 | #ifdef O_NONBLOCK |
490 | return O_NONBLOCK; | |
491 | #else | |
492 | goto not_there; | |
493 | #endif | |
7ea3cd40 | 494 | if (strEQ(name, "RANDOM")) |
8c99d73e GS |
495 | #ifdef O_RANDOM |
496 | return O_RANDOM; | |
497 | #else | |
498 | goto not_there; | |
499 | #endif | |
7ea3cd40 | 500 | if (strEQ(name, "RAW")) |
8c99d73e GS |
501 | #ifdef O_RAW |
502 | return O_RAW; | |
503 | #else | |
504 | goto not_there; | |
505 | #endif | |
7ea3cd40 | 506 | if (strEQ(name, "RDONLY")) |
a0d0e21e LW |
507 | #ifdef O_RDONLY |
508 | return O_RDONLY; | |
509 | #else | |
510 | goto not_there; | |
511 | #endif | |
7ea3cd40 | 512 | if (strEQ(name, "RDWR")) |
a0d0e21e LW |
513 | #ifdef O_RDWR |
514 | return O_RDWR; | |
515 | #else | |
516 | goto not_there; | |
517 | #endif | |
7ea3cd40 | 518 | if (strEQ(name, "RSYNC")) |
0fd60c2a JH |
519 | #ifdef O_RSYNC |
520 | return O_RSYNC; | |
705af498 JH |
521 | #else |
522 | goto not_there; | |
523 | #endif | |
7ea3cd40 | 524 | if (strEQ(name, "SEQUENTIAL")) |
8c99d73e GS |
525 | #ifdef O_SEQUENTIAL |
526 | return O_SEQUENTIAL; | |
527 | #else | |
528 | goto not_there; | |
529 | #endif | |
7ea3cd40 | 530 | if (strEQ(name, "SHLOCK")) |
705af498 JH |
531 | #ifdef O_SHLOCK |
532 | return O_SHLOCK; | |
533 | #else | |
534 | goto not_there; | |
535 | #endif | |
7ea3cd40 | 536 | if (strEQ(name, "SYNC")) |
0fd60c2a JH |
537 | #ifdef O_SYNC |
538 | return O_SYNC; | |
705af498 JH |
539 | #else |
540 | goto not_there; | |
541 | #endif | |
7ea3cd40 | 542 | if (strEQ(name, "TEMPORARY")) |
ca6e1c26 JH |
543 | #ifdef O_TEMPORARY |
544 | return O_TEMPORARY; | |
545 | #else | |
546 | goto not_there; | |
547 | #endif | |
7ea3cd40 | 548 | if (strEQ(name, "TEXT")) |
0fd60c2a JH |
549 | #ifdef O_TEXT |
550 | return O_TEXT; | |
705af498 JH |
551 | #else |
552 | goto not_there; | |
553 | #endif | |
7ea3cd40 | 554 | if (strEQ(name, "TRUNC")) |
0fd60c2a JH |
555 | #ifdef O_TRUNC |
556 | return O_TRUNC; | |
705af498 JH |
557 | #else |
558 | goto not_there; | |
559 | #endif | |
7ea3cd40 | 560 | if (strEQ(name, "WRONLY")) |
0fd60c2a JH |
561 | #ifdef O_WRONLY |
562 | return O_WRONLY; | |
705af498 JH |
563 | #else |
564 | goto not_there; | |
565 | #endif | |
7ea3cd40 | 566 | if (strEQ(name, "ALIAS")) |
cd39f2b6 JH |
567 | #ifdef O_ALIAS |
568 | return O_ALIAS; | |
569 | #else | |
570 | goto not_there; | |
571 | #endif | |
7ea3cd40 | 572 | if (strEQ(name, "RSRC")) |
cd39f2b6 JH |
573 | #ifdef O_RSRC |
574 | return O_RSRC; | |
575 | #else | |
576 | goto not_there; | |
577 | #endif | |
a0d0e21e LW |
578 | } else |
579 | goto not_there; | |
580 | break; | |
ac88732c | 581 | case 'S': |
7ea3cd40 | 582 | switch (*(name++)) { |
ca6e1c26 | 583 | case '_': |
7ea3cd40 | 584 | if (strEQ(name, "ISUID")) |
ca6e1c26 JH |
585 | #ifdef S_ISUID |
586 | return S_ISUID; | |
587 | #else | |
588 | goto not_there; | |
589 | #endif | |
7ea3cd40 | 590 | if (strEQ(name, "ISGID")) |
ca6e1c26 JH |
591 | #ifdef S_ISGID |
592 | return S_ISGID; | |
593 | #else | |
594 | goto not_there; | |
595 | #endif | |
7ea3cd40 | 596 | if (strEQ(name, "ISVTX")) |
ca6e1c26 JH |
597 | #ifdef S_ISVTX |
598 | return S_ISVTX; | |
599 | #else | |
600 | goto not_there; | |
601 | #endif | |
7ea3cd40 | 602 | if (strEQ(name, "ISTXT")) |
ca6e1c26 JH |
603 | #ifdef S_ISTXT |
604 | return S_ISTXT; | |
605 | #else | |
606 | goto not_there; | |
607 | #endif | |
7ea3cd40 | 608 | if (strEQ(name, "IFREG")) |
ca6e1c26 JH |
609 | #ifdef S_IFREG |
610 | return S_IFREG; | |
611 | #else | |
612 | goto not_there; | |
613 | #endif | |
7ea3cd40 | 614 | if (strEQ(name, "IFDIR")) |
ca6e1c26 JH |
615 | #ifdef S_IFDIR |
616 | return S_IFDIR; | |
617 | #else | |
618 | goto not_there; | |
619 | #endif | |
7ea3cd40 | 620 | if (strEQ(name, "IFLNK")) |
ca6e1c26 JH |
621 | #ifdef S_IFLNK |
622 | return S_IFLNK; | |
623 | #else | |
624 | goto not_there; | |
625 | #endif | |
7ea3cd40 | 626 | if (strEQ(name, "IFSOCK")) |
ca6e1c26 JH |
627 | #ifdef S_IFSOCK |
628 | return S_IFSOCK; | |
629 | #else | |
630 | goto not_there; | |
631 | #endif | |
7ea3cd40 | 632 | if (strEQ(name, "IFBLK")) |
ca6e1c26 JH |
633 | #ifdef S_IFBLK |
634 | return S_IFBLK; | |
635 | #else | |
636 | goto not_there; | |
637 | #endif | |
7ea3cd40 | 638 | if (strEQ(name, "IFCHR")) |
ca6e1c26 JH |
639 | #ifdef S_IFCHR |
640 | return S_IFCHR; | |
641 | #else | |
642 | goto not_there; | |
643 | #endif | |
7ea3cd40 | 644 | if (strEQ(name, "IFIFO")) |
ca6e1c26 JH |
645 | #ifdef S_IFIFO |
646 | return S_IFIFO; | |
647 | #else | |
648 | goto not_there; | |
649 | #endif | |
7ea3cd40 | 650 | if (strEQ(name, "IFWHT")) |
ca6e1c26 JH |
651 | #ifdef S_IFWHT |
652 | return S_IFWHT; | |
653 | #else | |
654 | goto not_there; | |
655 | #endif | |
7ea3cd40 | 656 | if (strEQ(name, "ENFMT")) |
ca6e1c26 JH |
657 | #ifdef S_ENFMT |
658 | return S_ENFMT; | |
659 | #else | |
660 | goto not_there; | |
661 | #endif | |
7ea3cd40 | 662 | if (strEQ(name, "IRUSR")) |
ca6e1c26 JH |
663 | #ifdef S_IRUSR |
664 | return S_IRUSR; | |
665 | #else | |
666 | goto not_there; | |
667 | #endif | |
7ea3cd40 | 668 | if (strEQ(name, "IWUSR")) |
ca6e1c26 JH |
669 | #ifdef S_IWUSR |
670 | return S_IWUSR; | |
671 | #else | |
672 | goto not_there; | |
673 | #endif | |
7ea3cd40 | 674 | if (strEQ(name, "IXUSR")) |
ca6e1c26 JH |
675 | #ifdef S_IXUSR |
676 | return S_IXUSR; | |
677 | #else | |
678 | goto not_there; | |
679 | #endif | |
7ea3cd40 | 680 | if (strEQ(name, "IRWXU")) |
ca6e1c26 JH |
681 | #ifdef S_IRWXU |
682 | return S_IRWXU; | |
683 | #else | |
684 | goto not_there; | |
685 | #endif | |
7ea3cd40 | 686 | if (strEQ(name, "IRGRP")) |
ca6e1c26 JH |
687 | #ifdef S_IRGRP |
688 | return S_IRGRP; | |
689 | #else | |
690 | goto not_there; | |
691 | #endif | |
7ea3cd40 | 692 | if (strEQ(name, "IWGRP")) |
ca6e1c26 JH |
693 | #ifdef S_IWGRP |
694 | return S_IWGRP; | |
695 | #else | |
696 | goto not_there; | |
697 | #endif | |
7ea3cd40 | 698 | if (strEQ(name, "IXGRP")) |
ca6e1c26 JH |
699 | #ifdef S_IXGRP |
700 | return S_IXGRP; | |
701 | #else | |
702 | goto not_there; | |
703 | #endif | |
7ea3cd40 | 704 | if (strEQ(name, "IRWXG")) |
ca6e1c26 JH |
705 | #ifdef S_IRWXG |
706 | return S_IRWXG; | |
707 | #else | |
708 | goto not_there; | |
709 | #endif | |
7ea3cd40 | 710 | if (strEQ(name, "IROTH")) |
ca6e1c26 JH |
711 | #ifdef S_IROTH |
712 | return S_IROTH; | |
713 | #else | |
714 | goto not_there; | |
715 | #endif | |
7ea3cd40 | 716 | if (strEQ(name, "IWOTH")) |
ca6e1c26 JH |
717 | #ifdef S_IWOTH |
718 | return S_IWOTH; | |
719 | #else | |
720 | goto not_there; | |
721 | #endif | |
7ea3cd40 | 722 | if (strEQ(name, "IXOTH")) |
ca6e1c26 JH |
723 | #ifdef S_IXOTH |
724 | return S_IXOTH; | |
725 | #else | |
726 | goto not_there; | |
727 | #endif | |
7ea3cd40 | 728 | if (strEQ(name, "IRWXO")) |
ca6e1c26 JH |
729 | #ifdef S_IRWXO |
730 | return S_IRWXO; | |
731 | #else | |
732 | goto not_there; | |
733 | #endif | |
7ea3cd40 | 734 | if (strEQ(name, "IREAD")) |
ca6e1c26 JH |
735 | #ifdef S_IREAD |
736 | return S_IREAD; | |
737 | #else | |
738 | goto not_there; | |
739 | #endif | |
7ea3cd40 | 740 | if (strEQ(name, "IWRITE")) |
ca6e1c26 JH |
741 | #ifdef S_IWRITE |
742 | return S_IWRITE; | |
743 | #else | |
744 | goto not_there; | |
745 | #endif | |
7ea3cd40 | 746 | if (strEQ(name, "IEXEC")) |
ca6e1c26 JH |
747 | #ifdef S_IEXEC |
748 | return S_IEXEC; | |
749 | #else | |
750 | goto not_there; | |
751 | #endif | |
752 | break; | |
753 | case 'E': | |
7ea3cd40 | 754 | if (strEQ(name, "EK_CUR")) |
ac88732c | 755 | #ifdef SEEK_CUR |
ca6e1c26 | 756 | return SEEK_CUR; |
ac88732c | 757 | #else |
ca6e1c26 | 758 | return 1; |
ac88732c | 759 | #endif |
7ea3cd40 | 760 | if (strEQ(name, "EK_END")) |
ac88732c | 761 | #ifdef SEEK_END |
ca6e1c26 | 762 | return SEEK_END; |
ac88732c | 763 | #else |
ca6e1c26 | 764 | return 2; |
ac88732c | 765 | #endif |
7ea3cd40 | 766 | if (strEQ(name, "EK_SET")) |
ac88732c | 767 | #ifdef SEEK_SET |
ca6e1c26 | 768 | return SEEK_SET; |
ac88732c | 769 | #else |
ca6e1c26 | 770 | return 0; |
ac88732c | 771 | #endif |
ca6e1c26 JH |
772 | break; |
773 | } | |
a0d0e21e LW |
774 | } |
775 | errno = EINVAL; | |
776 | return 0; | |
777 | ||
778 | not_there: | |
779 | errno = ENOENT; | |
780 | return 0; | |
781 | } | |
782 | ||
783 | ||
784 | MODULE = Fcntl PACKAGE = Fcntl | |
785 | ||
7ea3cd40 NIS |
786 | IV |
787 | constant(name) | |
a0d0e21e | 788 | char * name |
a0d0e21e | 789 |