home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hsys.z / stat.h < prev    next >
C/C++ Source or Header  |  1996-07-24  |  8KB  |  216 lines

  1. /*
  2.  *  sys/stat.h    Equates and prototype for fstat, stat functions
  3.  *
  4.  *  Copyright by WATCOM International Corp. 1988-1996.  All rights reserved.
  5.  */
  6. #ifndef _STAT_H_INCLUDED
  7. #define _STAT_H_INCLUDED
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11.  
  12. #ifndef _COMDEF_H_INCLUDED
  13.  #include <_comdef.h>
  14. #endif
  15.  
  16. #ifndef _MAX_NAME
  17. #define _MAX_NAME 13    /* maximum length of file name (with extension) */
  18. #endif
  19.  
  20. #ifndef _WCHAR_T_DEFINED
  21. #define _WCHAR_T_DEFINED
  22. #define _WCHAR_T_DEFINED_
  23. #ifdef __cplusplus
  24. typedef long char wchar_t;
  25. #else
  26. typedef unsigned short wchar_t;
  27. #endif
  28. #endif
  29.  
  30. #ifndef __TYPES_H_INCLUDED
  31.  #include <sys/types.h>
  32. #endif
  33.  
  34. #if defined(_M_IX86)
  35.   #pragma pack(__push,1);
  36. #else
  37.   #pragma pack(__push,8);
  38. #endif
  39.  
  40. struct _stat {
  41.     dev_t    st_dev;     /* disk drive file resides on */
  42.     ino_t    st_ino;     /* this inode's #, not used for DOS */
  43.     unsigned short st_mode; /* file mode */
  44.     short    st_nlink;    /* # of hard links */
  45.     unsigned long  st_uid;    /* user-id, always 'root' */
  46.     short    st_gid;     /* group-id, always 'root' */
  47.     dev_t    st_rdev;    /* should be device type */
  48.                 /* but same as st_dev for the time being */
  49.     off_t    st_size;    /* total file size */
  50.     time_t    st_atime;    /* should be file last access time */
  51.     time_t    st_mtime;    /* file last modify time */
  52.     time_t    st_ctime;    /* should be file last status change time */
  53.     time_t            st_btime; /* last archived date and time */
  54.     unsigned long        st_attr;  /* file attributes */
  55.                            /* next 4 fields Netware only */
  56.     unsigned long        st_archivedID; /* user/object ID that last archived file*/
  57.     unsigned long        st_updatedID;  /* user/object ID that last updated file*/
  58.     unsigned short        st_inheritedRightsMask;
  59.     unsigned char        st_originatingNameSpace;
  60.     unsigned char        st_name[_MAX_NAME]; /* ASCIIZ filename */
  61. };
  62.  
  63. struct stat {
  64.     dev_t    st_dev;     /* disk drive file resides on */
  65.     ino_t    st_ino;     /* this inode's #, not used for DOS */
  66.     unsigned short st_mode; /* file mode */
  67.     short    st_nlink;    /* # of hard links */
  68.     unsigned long  st_uid;    /* user-id, always 'root' */
  69.     short    st_gid;     /* group-id, always 'root' */
  70.     dev_t    st_rdev;    /* should be device type */
  71.                 /* but same as st_dev for the time being */
  72.     off_t    st_size;    /* total file size */
  73.     time_t    st_atime;    /* should be file last access time */
  74.     time_t    st_mtime;    /* file last modify time */
  75.     time_t    st_ctime;    /* should be file last status change time */
  76.     time_t            st_btime; /* last archived date and time */
  77.     unsigned long        st_attr;  /* file attributes */
  78.                            /* next 4 fields Netware only */
  79.     unsigned long        st_archivedID; /* user/object ID that last archived file*/
  80.     unsigned long        st_updatedID;  /* user/object ID that last updated file*/
  81.     unsigned short        st_inheritedRightsMask;
  82.     unsigned char        st_originatingNameSpace;
  83.     unsigned char        st_name[_MAX_NAME]; /* ASCIIZ filename */
  84. };
  85.  
  86. struct _wstat {
  87.     dev_t    st_dev;     /* disk drive file resides on */
  88.     ino_t    st_ino;     /* this inode's #, not used for DOS */
  89.     unsigned short st_mode; /* file mode */
  90.     short    st_nlink;    /* # of hard links */
  91.     unsigned long  st_uid;    /* user-id, always 'root' */
  92.     short    st_gid;     /* group-id, always 'root' */
  93.     dev_t    st_rdev;    /* should be device type */
  94.                 /* but same as st_dev for the time being */
  95.     off_t    st_size;    /* total file size */
  96.     time_t    st_atime;    /* should be file last access time */
  97.     time_t    st_mtime;    /* file last modify time */
  98.     time_t    st_ctime;    /* should be file last status change time */
  99.     time_t            st_btime; /* last archived date and time */
  100.     unsigned long        st_attr;  /* file attributes */
  101.                            /* next 4 fields Netware only */
  102.     unsigned long        st_archivedID; /* user/object ID that last archived file*/
  103.     unsigned long        st_updatedID;  /* user/object ID that last updated file*/
  104.     unsigned short        st_inheritedRightsMask;
  105.     unsigned char        st_originatingNameSpace;
  106.     wchar_t            st_name[_MAX_NAME]; /* wide char filename */
  107. };
  108.  
  109. #ifdef __WATCOM_INT64__
  110. struct _stati64 {
  111.     dev_t    st_dev;     /* disk drive file resides on */
  112.     ino_t    st_ino;     /* this inode's #, not used for DOS */
  113.     unsigned short st_mode; /* file mode */
  114.     short    st_nlink;    /* # of hard links */
  115.     unsigned long  st_uid;    /* user-id, always 'root' */
  116.     short    st_gid;     /* group-id, always 'root' */
  117.     dev_t    st_rdev;    /* should be device type */
  118.                 /* but same as st_dev for the time being */
  119.     __int64    st_size;    /* total file size */
  120.     time_t    st_atime;    /* should be file last access time */
  121.     time_t    st_mtime;    /* file last modify time */
  122.     time_t    st_ctime;    /* should be file last status change time */
  123.     time_t            st_btime; /* last archived date and time */
  124.     unsigned long        st_attr;  /* file attributes */
  125.                            /* next 4 fields Netware only */
  126.     unsigned long        st_archivedID; /* user/object ID that last archived file*/
  127.     unsigned long        st_updatedID;  /* user/object ID that last updated file*/
  128.     unsigned short        st_inheritedRightsMask;
  129.     unsigned char        st_originatingNameSpace;
  130.     unsigned char        st_name[_MAX_NAME]; /* ASCIIZ filename */
  131. };
  132.  
  133. struct _wstati64 {
  134.     dev_t    st_dev;     /* disk drive file resides on */
  135.     ino_t    st_ino;     /* this inode's #, not used for DOS */
  136.     unsigned short st_mode; /* file mode */
  137.     short    st_nlink;    /* # of hard links */
  138.     unsigned long  st_uid;    /* user-id, always 'root' */
  139.     short    st_gid;     /* group-id, always 'root' */
  140.     dev_t    st_rdev;    /* should be device type */
  141.                 /* but same as st_dev for the time being */
  142.     __int64    st_size;    /* total file size */
  143.     time_t    st_atime;    /* should be file last access time */
  144.     time_t    st_mtime;    /* file last modify time */
  145.     time_t    st_ctime;    /* should be file last status change time */
  146.     time_t            st_btime; /* last archived date and time */
  147.     unsigned long        st_attr;  /* file attributes */
  148.                            /* next 4 fields Netware only */
  149.     unsigned long        st_archivedID; /* user/object ID that last archived file*/
  150.     unsigned long        st_updatedID;  /* user/object ID that last updated file*/
  151.     unsigned short        st_inheritedRightsMask;
  152.     unsigned char        st_originatingNameSpace;
  153.     wchar_t            st_name[_MAX_NAME]; /* wide char filename */
  154. };
  155. #endif
  156.  
  157. /* File attribute constants for st_mode field */
  158. #define S_IFMT        0170000 /* type of file */
  159. #define S_IFDIR     0040000 /* directory */
  160. #define S_IFCHR     0020000 /* character special file */
  161. #define S_IFFIFO    0010000 /* FIFO */
  162. #define S_IFREG     0100000 /* regular */
  163. /* the following is not possible on PC */
  164. #define S_ISBLK( m )    0
  165. #define S_ISFIFO( m )    (((m) & S_IFMT) == S_IFFIFO)
  166. #define S_ISCHR( m )    (((m) & S_IFMT) == S_IFCHR)
  167. #define S_ISDIR( m )    (((m) & S_IFMT) == S_IFDIR)
  168. #define S_ISREG( m )    (((m) & S_IFMT) == S_IFREG)
  169.  
  170. /* owner permission */
  171. #define S_IRWXU     0000700
  172. #define S_IRUSR     0000400
  173. #define S_IWUSR     0000200
  174. #define S_IXUSR     0000100
  175. #define S_IREAD     0000400
  176. #define S_IWRITE    0000200
  177. #define S_IEXEC     0000100
  178.  
  179. /* group permission.  same as owner's on PC and PenPoint*/
  180. #define S_IRWXG     0000070
  181. #define S_IRGRP     0000040
  182. #define S_IWGRP     0000020
  183. #define S_IXGRP     0000010
  184.  
  185. /* other permission.  same as owner's on PC and PenPoint*/
  186. #define S_IRWXO     0000007
  187. #define S_IROTH     0000004
  188. #define S_IWOTH     0000002
  189. #define S_IXOTH     0000001
  190.  
  191. /* setuid, setgid, and sticky.    always false on PC */
  192. #define S_ISUID     0004000
  193. #define S_ISGID     0002000
  194. #define S_ISVTX     0001000
  195.  
  196. _WCRTLINK extern int fstat( int, struct stat * );
  197. _WCRTLINK extern int _fstat( int, struct _stat * );
  198. _WCRTLINK extern int stat( const char *, struct stat * );
  199. _WCRTLINK extern int _stat( const char *, struct _stat * );
  200.  
  201. _WCRTLINK extern int _wstat( const wchar_t *, struct _wstat * );
  202. _WCRTLINK extern int _wfstat( int, struct _wstat * );
  203.  
  204. #ifdef __WATCOM_INT64__
  205. _WCRTLINK extern int _fstati64( int, struct _stati64 * );
  206. _WCRTLINK extern int _wfstati64( int, struct _wstati64 * );
  207. _WCRTLINK extern int _stati64( const char *, struct _stati64 * );
  208. _WCRTLINK extern int _wstati64( const wchar_t *, struct _wstati64 * );
  209. #endif
  210.  
  211. #pragma pack(__pop);
  212. #ifdef __cplusplus
  213. };
  214. #endif
  215. #endif
  216.