Mercurial > hg > xemacs-beta
comparison src/sysfile.h @ 442:abe6d1db359e r21-2-36
Import from CVS: tag r21-2-36
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:35:02 +0200 |
parents | 8de8e3f6228a |
children | 3078fd1074e8 |
comparison
equal
deleted
inserted
replaced
441:72a7cfa4a488 | 442:abe6d1db359e |
---|---|
23 #ifndef INCLUDED_sysfile_h_ | 23 #ifndef INCLUDED_sysfile_h_ |
24 #define INCLUDED_sysfile_h_ | 24 #define INCLUDED_sysfile_h_ |
25 | 25 |
26 #include <errno.h> | 26 #include <errno.h> |
27 | 27 |
28 #ifndef WINDOWSNT | 28 #ifndef WIN32_NATIVE |
29 #include <sys/errno.h> /* <errno.h> does not always imply this */ | 29 #include <sys/errno.h> /* <errno.h> does not always imply this */ |
30 #endif | 30 #endif |
31 | 31 |
32 #ifdef HAVE_UNISTD_H | 32 #ifdef HAVE_UNISTD_H |
33 #include <unistd.h> | 33 #include <unistd.h> |
41 /* Load sys/types.h if not already loaded. | 41 /* Load sys/types.h if not already loaded. |
42 In some systems loading it twice is suicidal. */ | 42 In some systems loading it twice is suicidal. */ |
43 #ifndef makedev | 43 #ifndef makedev |
44 #include <sys/types.h> /* some typedefs are used in sys/file.h */ | 44 #include <sys/types.h> /* some typedefs are used in sys/file.h */ |
45 #endif | 45 #endif |
46 | |
47 #ifndef WIN32_NATIVE | |
46 #include <sys/file.h> | 48 #include <sys/file.h> |
49 #endif | |
50 | |
47 #include <sys/stat.h> | 51 #include <sys/stat.h> |
52 | |
53 #ifndef WIN32_NATIVE | |
54 /* Some configuration files' definitions for the LOAD_AVE_CVT macro | |
55 (like sparc.h's) use macros like FSCALE, defined here. */ | |
48 #include <sys/param.h> | 56 #include <sys/param.h> |
49 | 57 #endif |
50 #if defined (NeXT) || defined(__CYGWIN32__) | 58 |
59 #if defined (NeXT) || defined(CYGWIN) | |
51 /* what is needed from here? Do others need it too? | 60 /* what is needed from here? Do others need it too? |
52 O_BINARY is in here under cygwin. */ | 61 O_BINARY is in here under cygwin. */ |
53 # include <sys/fcntl.h> | 62 # include <sys/fcntl.h> |
54 #endif /* NeXT */ | 63 #endif /* NeXT */ |
55 | 64 |
56 #ifdef WINDOWSNT | 65 #ifdef WIN32_NATIVE |
57 #include <io.h> | 66 #include <io.h> |
58 #include <direct.h> | 67 #include <direct.h> |
59 #endif | 68 #endif |
60 | 69 |
61 #ifndef STDERR_FILENO | 70 #ifndef STDERR_FILENO |
92 #define OPEN_TEXT (0) | 101 #define OPEN_TEXT (0) |
93 #endif | 102 #endif |
94 #endif | 103 #endif |
95 | 104 |
96 #ifndef CREAT_MODE | 105 #ifndef CREAT_MODE |
97 #ifdef WINDOWSNT | 106 #ifdef WIN32_NATIVE |
98 #define CREAT_MODE (S_IREAD | S_IWRITE) | 107 #define CREAT_MODE (S_IREAD | S_IWRITE) |
99 #else | 108 #else |
100 #define CREAT_MODE (0666) | 109 #define CREAT_MODE (0666) |
101 #endif | 110 #endif |
102 #endif | 111 #endif |
112 #ifndef READ_BINARY | 121 #ifndef READ_BINARY |
113 #ifdef O_BINARY | 122 #ifdef O_BINARY |
114 #define READ_BINARY "rb" | 123 #define READ_BINARY "rb" |
115 #else | 124 #else |
116 #define READ_BINARY "r" | 125 #define READ_BINARY "r" |
126 #endif | |
127 #endif | |
128 | |
129 #ifndef READ_PLUS_TEXT | |
130 #ifdef O_TEXT | |
131 #define READ_PLUS_TEXT "r+t" | |
132 #else | |
133 #define READ_PLUS_TEXT "r+" | |
134 #endif | |
135 #endif | |
136 | |
137 #ifndef READ_PLUS_BINARY | |
138 #ifdef O_BINARY | |
139 #define READ_PLUS_BINARY "r+b" | |
140 #else | |
141 #define READ_PLUS_BINARY "r+" | |
142 #endif | |
143 #endif | |
144 | |
145 #ifndef WRITE_TEXT | |
146 #ifdef O_TEXT | |
147 #define WRITE_TEXT "wt" | |
148 #else | |
149 #define WRITE_TEXT "w" | |
117 #endif | 150 #endif |
118 #endif | 151 #endif |
119 | 152 |
120 #ifndef WRITE_BINARY | 153 #ifndef WRITE_BINARY |
121 #ifdef O_BINARY | 154 #ifdef O_BINARY |
204 #endif | 237 #endif |
205 #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */ | 238 #if !defined(S_ISNWK) && defined(S_IFNWK) /* HP/UX */ |
206 #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) | 239 #define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK) |
207 #endif | 240 #endif |
208 | 241 |
242 /* Client .c files should simply use `PATH_MAX'. */ | |
243 #ifndef PATH_MAX | |
244 # if defined (_POSIX_PATH_MAX) | |
245 # define PATH_MAX _POSIX_PATH_MAX | |
246 # elif defined (MAXPATHLEN) | |
247 # define PATH_MAX MAXPATHLEN | |
248 # else | |
249 # define PATH_MAX 1024 | |
250 # endif | |
251 #endif | |
252 | |
253 /* MAXPATHLEN is deprecated, but, as of this writing, still used. */ | |
209 #ifndef MAXPATHLEN | 254 #ifndef MAXPATHLEN |
210 /* in 4.1, param.h fails to define this. */ | 255 # define MAXPATHLEN 1024 |
211 #define MAXPATHLEN 1024 | 256 #endif |
212 #endif /* not MAXPATHLEN */ | 257 |
213 | 258 /* The following definitions are needed under Windows, at least */ |
214 #ifndef X_OK | 259 #ifndef X_OK |
215 # define X_OK 01 | 260 # define X_OK 1 |
261 #endif | |
262 | |
263 #ifndef R_OK | |
264 # define R_OK 4 | |
265 #endif | |
266 | |
267 #ifndef W_OK | |
268 # define W_OK 2 | |
269 #endif | |
270 | |
271 #ifndef F_OK | |
272 # define F_OK 0 | |
216 #endif | 273 #endif |
217 | 274 |
218 #ifndef FD_CLOEXEC | 275 #ifndef FD_CLOEXEC |
219 # define FD_CLOEXEC 1 | 276 # define FD_CLOEXEC 1 |
220 #endif | 277 #endif |
252 #if !defined (ENCAPSULATE_READ) && defined (DONT_ENCAPSULATE) | 309 #if !defined (ENCAPSULATE_READ) && defined (DONT_ENCAPSULATE) |
253 # define sys_read read | 310 # define sys_read read |
254 #endif | 311 #endif |
255 | 312 |
256 #ifdef ENCAPSULATE_WRITE | 313 #ifdef ENCAPSULATE_WRITE |
257 ssize_t sys_write (int, CONST void *, size_t); | 314 ssize_t sys_write (int, const void *, size_t); |
258 #endif | 315 #endif |
259 #if defined (ENCAPSULATE_WRITE) && !defined (DONT_ENCAPSULATE) | 316 #if defined (ENCAPSULATE_WRITE) && !defined (DONT_ENCAPSULATE) |
260 # undef write | 317 # undef write |
261 # define write sys_write | 318 # define write sys_write |
262 #endif | 319 #endif |
263 #if !defined (ENCAPSULATE_WRITE) && defined (DONT_ENCAPSULATE) | 320 #if !defined (ENCAPSULATE_WRITE) && defined (DONT_ENCAPSULATE) |
264 # define sys_write write | 321 # define sys_write write |
265 #endif | 322 #endif |
266 | 323 |
267 #ifdef ENCAPSULATE_OPEN | 324 #ifdef ENCAPSULATE_OPEN |
268 int sys_open (CONST char *, int, ...); | 325 int sys_open (const char *, int, ...); |
269 #endif | 326 #endif |
270 #if defined (ENCAPSULATE_OPEN) && !defined (DONT_ENCAPSULATE) | 327 #if defined (ENCAPSULATE_OPEN) && !defined (DONT_ENCAPSULATE) |
271 # undef open | 328 # undef open |
272 # define open sys_open | 329 # define open sys_open |
273 #endif | 330 #endif |
298 #if !defined (ENCAPSULATE_FREAD) && defined (DONT_ENCAPSULATE) | 355 #if !defined (ENCAPSULATE_FREAD) && defined (DONT_ENCAPSULATE) |
299 # define sys_fread fread | 356 # define sys_fread fread |
300 #endif | 357 #endif |
301 | 358 |
302 #ifdef ENCAPSULATE_FWRITE | 359 #ifdef ENCAPSULATE_FWRITE |
303 size_t sys_fwrite (CONST void *, size_t, size_t, FILE *); | 360 size_t sys_fwrite (const void *, size_t, size_t, FILE *); |
304 #endif | 361 #endif |
305 #if defined (ENCAPSULATE_FWRITE) && !defined (DONT_ENCAPSULATE) | 362 #if defined (ENCAPSULATE_FWRITE) && !defined (DONT_ENCAPSULATE) |
306 # undef fwrite | 363 # undef fwrite |
307 # define fwrite sys_fwrite | 364 # define fwrite sys_fwrite |
308 #endif | 365 #endif |
309 #if !defined (ENCAPSULATE_FWRITE) && defined (DONT_ENCAPSULATE) | 366 #if !defined (ENCAPSULATE_FWRITE) && defined (DONT_ENCAPSULATE) |
310 # define sys_fwrite fwrite | 367 # define sys_fwrite fwrite |
311 #endif | 368 #endif |
312 | 369 |
313 #ifdef ENCAPSULATE_FOPEN | 370 #ifdef ENCAPSULATE_FOPEN |
314 FILE *sys_fopen (CONST char *, CONST char *); | 371 FILE *sys_fopen (const char *, const char *); |
315 #endif | 372 #endif |
316 #if defined (ENCAPSULATE_FOPEN) && !defined (DONT_ENCAPSULATE) | 373 #if defined (ENCAPSULATE_FOPEN) && !defined (DONT_ENCAPSULATE) |
317 # undef fopen | 374 # undef fopen |
318 # define fopen sys_fopen | 375 # define fopen sys_fopen |
319 #endif | 376 #endif |
334 | 391 |
335 | 392 |
336 /* encapsulations: file-information calls */ | 393 /* encapsulations: file-information calls */ |
337 | 394 |
338 #ifdef ENCAPSULATE_ACCESS | 395 #ifdef ENCAPSULATE_ACCESS |
339 int sys_access (CONST char *path, int mode); | 396 int sys_access (const char *path, int mode); |
340 #endif | 397 #endif |
341 #if defined (ENCAPSULATE_ACCESS) && !defined (DONT_ENCAPSULATE) | 398 #if defined (ENCAPSULATE_ACCESS) && !defined (DONT_ENCAPSULATE) |
342 # undef access | 399 # undef access |
343 # define access sys_access | 400 # define access sys_access |
344 #endif | 401 #endif |
345 #if !defined (ENCAPSULATE_ACCESS) && defined (DONT_ENCAPSULATE) | 402 #if !defined (ENCAPSULATE_ACCESS) && defined (DONT_ENCAPSULATE) |
346 # define sys_access access | 403 # define sys_access access |
347 #endif | 404 #endif |
348 | 405 |
349 #ifdef ENCAPSULATE_EACCESS | 406 #ifdef ENCAPSULATE_EACCESS |
350 int sys_eaccess (CONST char *path, int mode); | 407 int sys_eaccess (const char *path, int mode); |
351 #endif | 408 #endif |
352 #if defined (ENCAPSULATE_EACCESS) && !defined (DONT_ENCAPSULATE) | 409 #if defined (ENCAPSULATE_EACCESS) && !defined (DONT_ENCAPSULATE) |
353 # undef eaccess | 410 # undef eaccess |
354 # define eaccess sys_eaccess | 411 # define eaccess sys_eaccess |
355 #endif | 412 #endif |
356 #if !defined (ENCAPSULATE_EACCESS) && defined (DONT_ENCAPSULATE) | 413 #if !defined (ENCAPSULATE_EACCESS) && defined (DONT_ENCAPSULATE) |
357 # define sys_eaccess eaccess | 414 # define sys_eaccess eaccess |
358 #endif | 415 #endif |
359 | 416 |
360 #ifdef ENCAPSULATE_LSTAT | 417 #ifdef ENCAPSULATE_LSTAT |
361 int sys_lstat (CONST char *path, struct stat *buf); | 418 int sys_lstat (const char *path, struct stat *buf); |
362 #endif | 419 #endif |
363 #if defined (ENCAPSULATE_LSTAT) && !defined (DONT_ENCAPSULATE) | 420 #if defined (ENCAPSULATE_LSTAT) && !defined (DONT_ENCAPSULATE) |
364 # undef lstat | 421 # undef lstat |
365 # define lstat sys_lstat | 422 # define lstat sys_lstat |
366 #endif | 423 #endif |
367 #if !defined (ENCAPSULATE_LSTAT) && defined (DONT_ENCAPSULATE) | 424 #if !defined (ENCAPSULATE_LSTAT) && defined (DONT_ENCAPSULATE) |
368 # define sys_lstat lstat | 425 # define sys_lstat lstat |
369 #endif | 426 #endif |
370 | 427 |
371 #ifdef ENCAPSULATE_READLINK | 428 #ifdef ENCAPSULATE_READLINK |
372 int sys_readlink (CONST char *path, char *buf, size_t bufsiz); | 429 int sys_readlink (const char *path, char *buf, size_t bufsiz); |
373 #endif | 430 #endif |
374 #if defined (ENCAPSULATE_READLINK) && !defined (DONT_ENCAPSULATE) | 431 #if defined (ENCAPSULATE_READLINK) && !defined (DONT_ENCAPSULATE) |
375 # undef readlink | 432 # undef readlink |
376 # define readlink sys_readlink | 433 # define readlink sys_readlink |
377 #endif | 434 #endif |
382 #ifdef ENCAPSULATE_FSTAT | 439 #ifdef ENCAPSULATE_FSTAT |
383 int sys_fstat (int fd, struct stat *buf); | 440 int sys_fstat (int fd, struct stat *buf); |
384 #endif | 441 #endif |
385 #if defined (ENCAPSULATE_FSTAT) && !defined (DONT_ENCAPSULATE) | 442 #if defined (ENCAPSULATE_FSTAT) && !defined (DONT_ENCAPSULATE) |
386 # undef fstat | 443 # undef fstat |
387 /* Need to use arguments to avoid messing with struct stat */ | 444 # define fstat sys_fstat |
388 # define fstat(fd, buf) sys_fstat (fd, buf) | |
389 #endif | 445 #endif |
390 #if !defined (ENCAPSULATE_FSTAT) && defined (DONT_ENCAPSULATE) | 446 #if !defined (ENCAPSULATE_FSTAT) && defined (DONT_ENCAPSULATE) |
391 # define sys_fstat fstat | 447 # define sys_fstat fstat |
392 #endif | 448 #endif |
393 | 449 |
394 #ifdef ENCAPSULATE_STAT | 450 int xemacs_stat (const char *path, struct stat *buf); |
395 int sys_stat (CONST char *path, struct stat *buf); | |
396 #endif | |
397 #if defined (ENCAPSULATE_STAT) && !defined (DONT_ENCAPSULATE) | |
398 # undef stat | |
399 /* Need to use arguments to avoid messing with struct stat */ | |
400 # define stat(path, buf) sys_stat (path, buf) | |
401 #endif | |
402 #if !defined (ENCAPSULATE_STAT) && defined (DONT_ENCAPSULATE) | |
403 # define sys_stat stat | |
404 #endif | |
405 | 451 |
406 /* encapsulations: file-manipulation calls */ | 452 /* encapsulations: file-manipulation calls */ |
407 | 453 |
408 #ifdef ENCAPSULATE_CHMOD | 454 #ifdef ENCAPSULATE_CHMOD |
409 int sys_chmod (CONST char *path, mode_t mode); | 455 int sys_chmod (const char *path, mode_t mode); |
410 #endif | 456 #endif |
411 #if defined (ENCAPSULATE_CHMOD) && !defined (DONT_ENCAPSULATE) | 457 #if defined (ENCAPSULATE_CHMOD) && !defined (DONT_ENCAPSULATE) |
412 # undef chmod | 458 # undef chmod |
413 # define chmod sys_chmod | 459 # define chmod sys_chmod |
414 #endif | 460 #endif |
415 #if !defined (ENCAPSULATE_CHMOD) && defined (DONT_ENCAPSULATE) | 461 #if !defined (ENCAPSULATE_CHMOD) && defined (DONT_ENCAPSULATE) |
416 # define sys_chmod chmod | 462 # define sys_chmod chmod |
417 #endif | 463 #endif |
418 | 464 |
419 #ifdef ENCAPSULATE_CREAT | 465 #ifdef ENCAPSULATE_CREAT |
420 int sys_creat (CONST char *path, mode_t mode); | 466 int sys_creat (const char *path, mode_t mode); |
421 #endif | 467 #endif |
422 #if defined (ENCAPSULATE_CREAT) && !defined (DONT_ENCAPSULATE) | 468 #if defined (ENCAPSULATE_CREAT) && !defined (DONT_ENCAPSULATE) |
423 # undef creat | 469 # undef creat |
424 # define creat sys_creat | 470 # define creat sys_creat |
425 #endif | 471 #endif |
426 #if !defined (ENCAPSULATE_CREAT) && defined (DONT_ENCAPSULATE) | 472 #if !defined (ENCAPSULATE_CREAT) && defined (DONT_ENCAPSULATE) |
427 # define sys_creat creat | 473 # define sys_creat creat |
428 #endif | 474 #endif |
429 | 475 |
430 #ifdef ENCAPSULATE_LINK | 476 #ifdef ENCAPSULATE_LINK |
431 int sys_link (CONST char *existing, CONST char *new); | 477 int sys_link (const char *existing, const char *new); |
432 #endif | 478 #endif |
433 #if defined (ENCAPSULATE_LINK) && !defined (DONT_ENCAPSULATE) | 479 #if defined (ENCAPSULATE_LINK) && !defined (DONT_ENCAPSULATE) |
434 # undef link | 480 # undef link |
435 # define link sys_link | 481 # define link sys_link |
436 #endif | 482 #endif |
437 #if !defined (ENCAPSULATE_LINK) && defined (DONT_ENCAPSULATE) | 483 #if !defined (ENCAPSULATE_LINK) && defined (DONT_ENCAPSULATE) |
438 # define sys_link link | 484 # define sys_link link |
439 #endif | 485 #endif |
440 | 486 |
441 #ifdef ENCAPSULATE_RENAME | 487 #ifdef ENCAPSULATE_RENAME |
442 int sys_rename (CONST char *old, CONST char *new); | 488 int sys_rename (const char *old, const char *new); |
443 #endif | 489 #endif |
444 #if defined (ENCAPSULATE_RENAME) && !defined (DONT_ENCAPSULATE) | 490 #if defined (ENCAPSULATE_RENAME) && !defined (DONT_ENCAPSULATE) |
445 # undef rename | 491 # undef rename |
446 # define rename sys_rename | 492 # define rename sys_rename |
447 #endif | 493 #endif |
448 #if !defined (ENCAPSULATE_RENAME) && defined (DONT_ENCAPSULATE) | 494 #if !defined (ENCAPSULATE_RENAME) && defined (DONT_ENCAPSULATE) |
449 # define sys_rename rename | 495 # define sys_rename rename |
450 #endif | 496 #endif |
451 | 497 |
452 #ifdef ENCAPSULATE_SYMLINK | 498 #ifdef ENCAPSULATE_SYMLINK |
453 int sys_symlink (CONST char *name1, CONST char *name2); | 499 int sys_symlink (const char *name1, const char *name2); |
454 #endif | 500 #endif |
455 #if defined (ENCAPSULATE_SYMLINK) && !defined (DONT_ENCAPSULATE) | 501 #if defined (ENCAPSULATE_SYMLINK) && !defined (DONT_ENCAPSULATE) |
456 # undef symlink | 502 # undef symlink |
457 # define symlink sys_symlink | 503 # define symlink sys_symlink |
458 #endif | 504 #endif |
459 #if !defined (ENCAPSULATE_SYMLINK) && defined (DONT_ENCAPSULATE) | 505 #if !defined (ENCAPSULATE_SYMLINK) && defined (DONT_ENCAPSULATE) |
460 # define sys_symlink symlink | 506 # define sys_symlink symlink |
461 #endif | 507 #endif |
462 | 508 |
463 #ifdef ENCAPSULATE_UNLINK | 509 #ifdef ENCAPSULATE_UNLINK |
464 int sys_unlink (CONST char *path); | 510 int sys_unlink (const char *path); |
465 #endif | 511 #endif |
466 #if defined (ENCAPSULATE_UNLINK) && !defined (DONT_ENCAPSULATE) | 512 #if defined (ENCAPSULATE_UNLINK) && !defined (DONT_ENCAPSULATE) |
467 # undef unlink | 513 # undef unlink |
468 # define unlink sys_unlink | 514 # define unlink sys_unlink |
469 #endif | 515 #endif |
470 #if !defined (ENCAPSULATE_UNLINK) && defined (DONT_ENCAPSULATE) | 516 #if !defined (ENCAPSULATE_UNLINK) && defined (DONT_ENCAPSULATE) |
471 # define sys_unlink unlink | 517 # define sys_unlink unlink |
472 #endif | 518 #endif |
473 | 519 |
474 #ifdef ENCAPSULATE_EXECVP | 520 #ifdef ENCAPSULATE_EXECVP |
475 int sys_execvp (CONST char *, char * CONST *); | 521 int sys_execvp (const char *, char * const *); |
476 #endif | 522 #endif |
477 #if defined (ENCAPSULATE_EXECVP) && !defined (DONT_ENCAPSULATE) | 523 #if defined (ENCAPSULATE_EXECVP) && !defined (DONT_ENCAPSULATE) |
478 # undef execvp | 524 # undef execvp |
479 # define execvp sys_execvp | 525 # define execvp sys_execvp |
480 #endif | 526 #endif |