home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / gccdist / gcc / include / stat.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-29  |  2.7 KB  |  98 lines

  1. /*
  2.  *    VAX-11 "C" runtime compatible stat definition
  3.  */
  4.  
  5. #ifndef    _STAT_
  6. #define    _STAT_
  7.  
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11.  
  12. /*
  13.  *    Because of alignment differences between VAX-11 "C" and GNU "C"
  14.  *    we can't normally access any field AFTER st_gid.  To fix this
  15.  *    the macro stat_alignment_fix(statp) makes fields AFTER st_gid
  16.  *    work right.  stat_alignment_fix2(statp) allows st_fab_mrs to be
  17.  *    accessed.
  18.  *
  19.  *    VMS/GCC defines the CPP variable "PCC_ALIGNMENT" if UNIX PCC
  20.  *    style alignment is in effect.  Otherwise, VAX-11 "C" style
  21.  *    alignment is in effect.
  22.  */
  23. #ifdef    PCC_ALIGNMENT
  24. #define    stat_alignment_fix(statp) \
  25.     ((struct stat *)((char *)statp - sizeof(short)))
  26.  
  27. #define    stat_alignment_fix1(statp) \
  28.     ((struct stat *)((char *)statp - sizeof(short) - sizeof(char)))
  29. #endif    PCC_ALIGNMENT
  30.  
  31. /*
  32.  *    If <sys/types> has not been included we need to define the following:
  33.  */
  34. #ifndef    _TYPES_
  35. typedef unsigned off_t;
  36. typedef unsigned short ino_t;
  37. typedef char *dev_t;
  38. #endif    _TYPES_
  39.  
  40. struct  stat
  41. {
  42.         dev_t   st_dev;
  43.         ino_t   st_ino[3];
  44.         unsigned short st_mode;
  45.         int    st_nlink;
  46.         unsigned st_uid;
  47.         unsigned short st_gid;    /* <---- The big screw...  VAX-11 "C" doesn't
  48.                     do alignment so everything following
  49.                     this is wrong! */
  50.         dev_t    st_rdev;
  51.         off_t   st_size;
  52.         unsigned st_atime;
  53.         unsigned st_mtime;
  54.         unsigned st_ctime;
  55.     char    st_fab_rfm;
  56.     char    st_fab_rat;
  57.     char    st_fab_fsz;    /* <---- Another screw */
  58.     unsigned st_fab_mrs;
  59. };
  60.  
  61. #define S_IFMT   0170000         /* type of file */
  62. #define          S_IFDIR 0040000 /* directory */
  63. #define          S_IFCHR 0020000 /* character special */
  64. #define          S_IFBLK 0060000 /* block special */
  65. #define          S_IFREG 0100000 /* regular */
  66. #define          S_IFMPC 0030000 /* multiplexed char special */
  67. #define          S_IFMPB 0070000 /* multiplexed block special */
  68. #define S_ISUID  0004000         /* set user id on execution */
  69. #define S_ISGID  0002000         /* set group id on execution */
  70. #define S_ISVTX  0001000         /* save swapped text even after use */
  71. #define S_IREAD  0000400         /* read permission, owner */
  72. #define S_IWRITE 0000200         /* write permission, owner */
  73. #define S_IEXEC  0000100         /* execute/search permission, owner */
  74.  
  75. #ifndef S_ISDIR
  76. #define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
  77. #endif
  78. #ifndef S_ISBLK
  79. #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
  80. #endif
  81. #ifndef S_ISCHR
  82. #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
  83. #endif
  84. #ifndef S_ISFIFO
  85. #define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFFIFO)
  86. #endif
  87. #ifndef S_ISREG
  88. #define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
  89. #endif
  90.  
  91. int fstat(int, struct stat *);
  92. #ifdef __cplusplus
  93. }
  94. #endif
  95.  
  96.  
  97. #endif    _STAT_
  98.