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