home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / gnu / mntinc16 / fcntl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-07-29  |  2.3 KB  |  98 lines

  1. /*
  2.  *    FCNTL.H
  3.  */
  4.  
  5. #ifndef    _FCNTL_H
  6. #define    _FCNTL_H
  7.  
  8. #define    O_RDONLY    0x00        /* read only */
  9. #define    O_WRONLY    0x01        /* write only */
  10. #define    O_RDWR        0x02        /* read/write */
  11. #define O_ACCMODE    0x03        /* used to mask off file access mode */
  12.  
  13. /* file sharing modes (not POSIX) */
  14. #define O_COMPAT    0x00        /* old TOS compatibility mode */
  15. #define O_DENYRW    0x10        /* deny both reads and writes */
  16. #define O_DENYW        0x20
  17. #define O_DENYR        0x30
  18. #define O_DENYNONE    0x40        /* don't deny anything */
  19. #define O_SHMODE    0x70        /* mask for file sharing mode */
  20.  
  21. #define    O_NDELAY    0x100        /* Non-blocking I/O */
  22. #define O_SYNC        0x00        /* sync after writes (not implemented) */
  23.  
  24. /* the following flags are not passed to the OS */
  25. #define    O_CREAT        0x200        /* create new file if needed */
  26. #define    O_TRUNC        0x400        /* make file 0 length */
  27. #define    O_EXCL        0x800        /* error if file exists */
  28. #define    O_APPEND    0x1000        /* position at EOF */
  29.  
  30. /*
  31.  * defines for the access() function
  32.  */
  33. #define    F_OK            0
  34. #define    X_OK            1
  35. #define    W_OK            2
  36. #define    R_OK            4
  37.  
  38. /*
  39.  * defines for fcntl()
  40.  */
  41. #define    F_DUPFD        0    /* Duplicate fildes */
  42. #define    F_GETFD        1    /* Get fildes flags */
  43. #define    F_SETFD        2    /* Set fildes flags */
  44. #define    F_GETFL        3    /* Get file flags */
  45. #define    F_SETFL        4    /* Set file flags */
  46. #define F_GETLK        5    /* Get file lock */
  47. #define F_SETLK        6    /* Set file lock */
  48.  
  49. struct flock {
  50.     short l_type;
  51. #define F_RDLCK        O_RDONLY
  52. #define F_WRLCK        O_WRONLY
  53. #define F_UNLCK        3
  54.     short l_whence;
  55.     long l_start;
  56.     long l_len;
  57.     short l_pid;
  58. };
  59.  
  60. #ifndef _COMPILER_H
  61. #include <compiler.h>
  62. #endif
  63.  
  64. __EXTERN int    fcntl __PROTO((int, int, void *));
  65. /* maybe more later */
  66.  
  67. /*
  68.  * stuff for speeding up isatty(), and other library internal defines
  69.  */
  70.  
  71. #define __NHANDLES 40
  72. #ifdef __MSHORT__
  73. #define __SMALLEST_VALID_HANDLE (-3)
  74. #else
  75. #define __SMALLEST_VALID_HANDLE (0)
  76. #endif
  77.  
  78. #define __OPEN_INDEX(fd) ((short)(fd) + 3)
  79.  
  80. struct __open_file {
  81.     short    status;        /* whether or not it's a tty */
  82.     short    flags;        /* if a tty, its flags */
  83. };
  84.  
  85. extern struct __open_file __open_stat[__NHANDLES];
  86.  
  87. #define FH_UNKNOWN    0
  88. #define FH_ISATTY    1
  89. #define FH_ISAFILE    2
  90.  
  91. #ifndef _COMPILER_H
  92. #include <compiler.h>
  93. #endif
  94.  
  95. __EXTERN int fcntl __PROTO((int f, int cmd, void *arg));
  96.  
  97. #endif /* _FCNTL_H */
  98.