home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / Compilers / digital marsC compier / dm / include / sys / Stat.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-03-16  |  5.5 KB  |  262 lines

  1. /* Copyright (C) 1986-1994 by Digital Mars. $Revision: 1.1.1.1 $ */
  2. #if __SC__ || __RCC__
  3. #pragma once
  4. #endif
  5.  
  6. #ifndef __SYS_STAT_H
  7. #define __SYS_STAT_H 1
  8.  
  9. #if __cplusplus
  10. extern "C" {
  11. #endif
  12.  
  13. /* Define _CRTAPI1 (for compatibility with the NT SDK) */
  14. #ifndef _CRTAPI1
  15. #define _CRTAPI1 __cdecl
  16. #endif
  17.  
  18.  
  19. /* Define _CRTAPI2 (for compatibility with the NT SDK) */
  20. #ifndef _CRTAPI2
  21. #define _CRTAPI2 __cdecl
  22. #endif
  23.  
  24. /* Define CRTIMP */
  25. #ifndef _CRTIMP
  26. #if defined(_WIN32) && defined(_DLL)
  27. #define _CRTIMP  __declspec(dllimport)
  28. #else
  29. #define _CRTIMP
  30. #endif
  31. #endif
  32.  
  33. #ifndef __STDC__
  34. #if !defined(_WCHAR_T_DEFINED)
  35. typedef unsigned short wchar_t;
  36. #define _WCHAR_T_DEFINED 1
  37. #endif
  38. #endif
  39.  
  40. #define _S_IFMT      0xF000
  41. #define _S_IFDIR  0x4000
  42. #define _S_IFCHR  0x2000
  43. #define _S_IFIFO  0x1000
  44. #define _S_IFREG  0x8000
  45. #define _S_IREAD  0x0100
  46. #define _S_IWRITE 0x0080
  47. #define _S_IEXEC  0x0040
  48.  
  49. #ifndef __STDC__
  50. #define S_IFMT     _S_IFMT
  51. #define S_IFDIR  _S_IFDIR
  52. #define S_IFCHR  _S_IFCHR
  53. #define S_IFREG  _S_IFREG
  54. #define S_IREAD  _S_IREAD
  55. #define S_IWRITE _S_IWRITE
  56. #define S_IEXEC  _S_IEXEC
  57. #define S_IFBLK  0x6000
  58. #define S_IFNAM  0x5000
  59. #endif
  60.  
  61. #define S_ISREG(m)  (((m)&(S_IFMT))==S_IFREG)
  62. #define S_ISBLK(m)  (((m)&(S_IFMT))==S_IFBLK)
  63. #define S_ISNAM(m)  (((m)&(S_IFMT))==S_IFNAM)
  64. #define S_ISDIR(m)  (((m)&(S_IFMT))==S_IFDIR)
  65. #define S_ISCHR(m)  (((m)&(S_IFMT))==S_IFCHR)
  66.  
  67. #if M_UNIX || M_XENIX
  68. #define S_IFIFO 0x1000
  69. #define S_ISFIFO(m) (((m)&(S_IFMT))==S_IFIFO)
  70.  
  71. #define S_IXOTH 0x0001
  72. #define S_IWOTH 0x0002
  73. #define S_IROTH 0x0004
  74. #define S_IRWXO 0x0007
  75. #define S_INSEM 0x0001
  76. #define S_INSHD 0x0002
  77. #define S_ISUID 0x0800
  78. #define S_ISGID 0x0400
  79. #define S_ISVTX 0x0200
  80. #define S_ENFMT 0x0400
  81. #define S_IRWXU 0x01C0
  82. #define S_IRUSR 0x0100
  83. #define S_IWUSR 0x0080
  84. #define S_IXUSR 0x0040
  85. #define S_IRWXG 0x0038
  86. #define S_IRGRP 0x0020
  87. #define S_IWGRP 0x0010
  88. #define S_IXGRP 0x0008
  89.  
  90. #if !defined(_POSIX_SOURCE)
  91. #define S_IFLNK  0xA000
  92. #define S_IFSOCK 0xC000
  93. #endif
  94.  
  95. #include <sys/types.h>
  96. #include <time.h>
  97.  
  98. #ifndef _STYPES
  99. #if !defined(M_ELF)
  100. #define _STYPES 1
  101. #endif
  102. #endif
  103.  
  104. #if !defined(_STYPES)
  105.  
  106. #define _ST_FSTYPSZ     16
  107.  
  108. /* SVR4 stat */
  109.  
  110. struct  stat {
  111.     dev_t    st_dev;
  112.     long    st_pad1[3];
  113.     ino_t    st_ino;
  114.     mode_t     st_mode;
  115.     nlink_t    st_nlink;
  116.     uid_t     st_uid;
  117.     gid_t     st_gid;
  118.     dev_t    st_rdev;
  119.     long    st_pad2[2];
  120.     off_t    st_size;
  121.     long    st_pad3;
  122.         union
  123.               {
  124.                 time_t          st__sec;
  125.                 timestruc_t     st__tim;
  126.               } st_atim,
  127.                 st_mtim,
  128.                 st_ctim;
  129.     long    st_blksize;
  130.     long    st_blocks;
  131.     char    st_fstype[_ST_FSTYPSZ];
  132.     int    st_aclcnt;
  133.     level_t    st_level;
  134.     ulong_t    st_flags;
  135.     lid_t    st_cmwlevel;
  136.     long    st_pad4[4];
  137. };
  138.  
  139. #define st_atime st_atim.st__sec
  140. #define st_mtime st_mtim.st__sec
  141. #define st_ctime st_ctim.st__sec
  142.  
  143. #else   /* !defined(_STYPES) */
  144.  
  145. /* SVID 2 stat */
  146.  
  147. struct  stat {
  148.         o_dev_t st_dev;
  149.         o_ino_t st_ino;
  150.         o_mode_t st_mode;
  151.         o_nlink_t st_nlink;
  152.         o_uid_t st_uid;
  153.         o_gid_t st_gid;
  154.         o_dev_t st_rdev;
  155.  
  156.         off_t   st_size;
  157.         time_t  st_atime;
  158.         time_t  st_mtime;
  159.         time_t  st_ctime;
  160. };
  161.  
  162. int __cdecl stat(const char *,struct stat *);
  163. int __cdecl fstat(int,struct stat *);
  164.  
  165. #if !defined(_POSIX_SOURCE)
  166. int __cdecl lstat(const char *, struct stat *);
  167. int __cdecl mknod(const char *, mode_t, dev_t);
  168. #endif
  169.  
  170. #endif /* !defined(_STYPES) */
  171.  
  172. #if defined(M_ELF)
  173.  
  174. int __cdecl _fxstat(const int, int, struct stat *);
  175. int __cdecl _xstat(const int, const char *, struct stat *);
  176.  
  177. #if !defined(_POSIX_SOURCE) 
  178. int __cdecl _lxstat(const int, const char *, struct stat *);
  179. int __cdecl _xmknod(const int, const char *, mode_t, dev_t);
  180. #endif
  181.  
  182. #if !defined(_STYPES)
  183. #define _MKNOD_VER      2
  184. #define _STAT_VER       2
  185. /* Map to SVR4 functions */
  186. #define fstat(fd,buf) _fxstat(_STAT_VER, fd, buf)
  187.  
  188. #if !defined(_POSIX_SOURCE) 
  189. #define lstat(path,buf) _lxstat(_STAT_VER, path, buf)
  190. #define mknod(path, mode, dev) _xmknod(_MKNOD_VER, path, mode, dev)
  191. #endif
  192.  
  193. static int __cdecl stat( const char *path, struct stat *buf)
  194. {
  195.     return _xstat(_STAT_VER, path, buf);
  196. }
  197.  
  198.  
  199. #endif /* !defined(_STYPES) */
  200.  
  201. #endif /* M_ELF */
  202.  
  203. int __cdecl chmod(const char *, mode_t);
  204. int __cdecl mkdir(const char *, mode_t);
  205. int __cdecl mkfifo(const char *, mode_t);
  206. /* mode_t __cdecl umask(mode_t); defined in io.h */ 
  207. int __cdecl fchmod(int, mode_t);
  208.  
  209. #else /* M_UNIX || M_XENIX */
  210.  
  211. #pragma pack (2)
  212. struct stat
  213. {    short    st_dev;
  214.     unsigned short    st_ino;
  215.     unsigned short st_mode;
  216.     short    st_nlink;
  217.     unsigned short    st_uid;
  218.     unsigned short    st_gid;
  219.     short    st_rdev;
  220. #if __INTSIZE == 4
  221.     short    dummy;                  /* for alignment                */
  222. #endif
  223.     long    st_size;
  224.     long    st_atime;
  225.     long    st_mtime;
  226.     long    st_ctime;
  227. };
  228. #pragma pack ()
  229.  
  230. #define _stat stat
  231.  
  232. int __cdecl stat(const char *,struct stat *);
  233. int __cdecl fstat(int,struct stat *);
  234. #define _fstat fstat
  235. int __cdecl _stat(const char *,struct stat *);
  236.  
  237. #endif /* M_UNIX || M_XENIX */
  238.  
  239. /* For MicroSoft and Borland compatibility */
  240. #define _S_IFMT    0xF000
  241. #define _S_IFREG 0x8000
  242. #define _S_IFBLK 0x6000
  243. #define _S_IFNAM 0x5000
  244. #define _S_IFDIR 0x4000
  245. #define _S_IFCHR 0x2000
  246. #define _S_IREAD 0x0100
  247. #define _S_IWRITE 0x0080
  248. #define _S_IEXEC 0x0040
  249.  
  250. #ifdef __NT__
  251. #ifndef __STDC__
  252. int __cdecl _wstat(const wchar_t *, struct stat *);
  253. #endif
  254. #endif
  255.  
  256. #if __cplusplus
  257. }
  258. #endif
  259.  
  260. #endif
  261.  
  262.