comparison src/sysfile.h @ 412:697ef44129c6 r21-2-14

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