1 /***
2 *sys/stat.h - defines structure used by stat() and fstat()
3 *
4 *           Copyright (c) Microsoft Corporation. All rights reserved.
5 *
6 *Purpose:
7 *           This file defines the structure used by the _stat() and _fstat()
8 *           routines.
9 *           [System V]
10 *
11 *           [Public]
12 *
13 ****/
14
15 #if        _MSC_VER > 1000
16 #pragma once
17 #endif
18
19 #ifndef _INC_STAT
20 #define _INC_STAT
21
22 #if        !defined(_WIN32)
23 #error ERROR: Only Win32 target supported!
24 #endif
25
26 #include <crtdefs.h>
27
28
29 #ifdef  _MSC_VER
30 #pragma pack(push,_CRT_PACKING)
31 #endif  /* _MSC_VER */
32
33 #ifdef  __cplusplus
34 extern "C" {
35 #endif
36
37
38
39 /* Define _CRTIMP */
40
41 #ifndef _CRTIMP
42 #ifdef  _DLL
43 #define _CRTIMP __declspec(dllimport)
44 #else     /* ndef _DLL */
45 #define _CRTIMP
46 #endif  /* _DLL */
47 #endif  /* _CRTIMP */
48
49
50 /* Define __cdecl for non-Microsoft compilers */
51
52 #if        ( !defined(_MSC_VER) && !defined(__cdecl) )
53 #define __cdecl
54 #endif
55
56
57 #include <sys/types.h>
58
59 #if !defined(_W64)
60 #if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300
61 #define _W64 __w64
62 #else
63 #define _W64
64 #endif
65 #endif
66
67 #ifdef  _USE_32BIT_TIME_T
68 #ifdef  _WIN64
69 #include <crtwrn.h>
70 #pragma _CRT_WARNING( _NO_32BIT_TIME_T )
71 #undef  _USE_32BIT_TIME_T
72 #endif
73 #endif
74
75 #ifndef _TIME32_T_DEFINED
76 typedef _W64 long __time32_t;     /* 32-bit time value */
77 #define _TIME32_T_DEFINED
78 #endif
79
80 #ifndef _TIME64_T_DEFINED
81 typedef __int64 __time64_t;        /* 64-bit time value */
82 #define _TIME64_T_DEFINED
83 #endif
84
85 #ifndef _TIME_T_DEFINED
86 #ifdef _USE_32BIT_TIME_T
87 typedef __time32_t time_t;          /* time value */
88 #else
89 typedef __time64_t time_t;          /* time value */
90 #endif
91 #define _TIME_T_DEFINED               /* avoid multiple def's of time_t */
92 #endif
93
94 #ifndef _WCHAR_T_DEFINED
95 typedef unsigned short wchar_t;
96 #define _WCHAR_T_DEFINED
97 #endif
98
99
100 /* define structure for returning status information */
101
102 #ifndef _STAT_DEFINED
103
104 struct _stat32 {
105              _dev_t        st_dev;
106              _ino_t        st_ino;
107              unsigned short st_mode;
108              short          st_nlink;
109              short          st_uid;
110              short          st_gid;
111              _dev_t        st_rdev;
112              _off_t        st_size;
113              __time32_t st_atime;
114              __time32_t st_mtime;
115              __time32_t st_ctime;
116              };
117
118 #if        !__STDC__
119 /* Non-ANSI names for compatibility */
120 struct stat {
121              _dev_t        st_dev;
122              _ino_t        st_ino;
123              unsigned short st_mode;
124              short          st_nlink;
125              short          st_uid;
126              short          st_gid;
127              _dev_t        st_rdev;
128              _off_t        st_size;
129              time_t st_atime;
130              time_t st_mtime;
131              time_t st_ctime;
132              };
133
134 #endif  /* __STDC__ */
135
136 struct _stat32i64 {
137              _dev_t        st_dev;
138              _ino_t        st_ino;
139              unsigned short st_mode;
140              short          st_nlink;
141              short          st_uid;
142              short          st_gid;
143              _dev_t        st_rdev;
144              __int64      st_size;
145              __time32_t st_atime;
146              __time32_t st_mtime;
147              __time32_t st_ctime;
148              };
149
150 struct _stat64i32 {
151              _dev_t        st_dev;
152              _ino_t        st_ino;
153              unsigned short st_mode;
154              short          st_nlink;
155              short          st_uid;
156              short          st_gid;
157              _dev_t        st_rdev;
158              _off_t        st_size;
159              __time64_t st_atime;
160              __time64_t st_mtime;
161              __time64_t st_ctime;
162              };
163
164 struct _stat64 {
165              _dev_t        st_dev;
166              _ino_t        st_ino;
167              unsigned short st_mode;
168              short          st_nlink;
169              short          st_uid;
170              short          st_gid;
171              _dev_t        st_rdev;
172              __int64      st_size;
173              __time64_t st_atime;
174              __time64_t st_mtime;
175              __time64_t st_ctime;
176              };
177
178 /*
Lines 179 ... 188 are skipped.
189 #define _wstat          _wstat32
190 #define _wstati64     _wstat32i64
191
192 #else
193 #define _fstat          _fstat64i32
194 #define _fstati64     _fstat64
195 #define _stat           _stat64i32
196 #define _stati64      _stat64
197 #define _wstat          _wstat64i32
198 #define _wstati64     _wstat64
199
200 #endif
201
202 #define _STAT_DEFINED
203 #endif
204
205
206 #define _S_IFMT               0xF000                /* file type mask */
207 #define _S_IFDIR             0x4000                /* directory */
208 #define _S_IFCHR             0x2000                /* character special */
209 #define _S_IFIFO             0x1000                /* pipe */
210 #define _S_IFREG             0x8000                /* regular */
211 #define _S_IREAD             0x0100                /* read permission, owner */
212 #define _S_IWRITE           0x0080                /* write permission, owner */
213 #define _S_IEXEC             0x0040                /* execute/search permission, owner */
214
215
216 /* Function prototypes */
217
218 _CRTIMP int __cdecl _fstat32(_In_ int _FileDes, _Out_ struct _stat32 * _Stat);
219 _CRTIMP int __cdecl _stat32(_In_z_ const char * _Name, _Out_ struct _stat32 * _Stat);
220
221 _CRTIMP int __cdecl _fstat32i64(_In_ int _FileDes, _Out_ struct _stat32i64 * _Stat);
222 _CRTIMP int __cdecl _fstat64i32(_In_ int _FileDes, _Out_ struct _stat64i32 * _Stat);
223 _CRTIMP int __cdecl _fstat64(_In_ int _FileDes, _Out_ struct _stat64 * _Stat);
224 _CRTIMP int __cdecl _stat32i64(_In_z_ const char * _Name, _Out_ struct _stat32i64 * _Stat);
225 _CRTIMP int __cdecl _stat64i32(_In_z_ const char * _Name, _Out_ struct _stat64i32 * _Stat);
226 _CRTIMP int __cdecl _stat64(_In_z_ const char * _Name, _Out_ struct _stat64 * _Stat);
227
228 #ifndef _WSTAT_DEFINED
229
230 /* also declared in wchar.h */
231
232 _CRTIMP int __cdecl _wstat32(_In_z_ const wchar_t * _Name, _Out_ struct _stat32 * _Stat);
233
234 _CRTIMP int __cdecl _wstat32i64(_In_z_ const wchar_t * _Name, _Out_ struct _stat32i64 * _Stat);
235 _CRTIMP int __cdecl _wstat64i32(_In_z_ const wchar_t * _Name, _Out_ struct _stat64i32 * _Stat);
236 _CRTIMP int __cdecl _wstat64(_In_z_ const wchar_t * _Name, _Out_ struct _stat64 * _Stat);
237
238 #define _WSTAT_DEFINED
239 #endif
240
241 #if        !__STDC__
242
243 /* Non-ANSI names for compatibility */
244
245 #define S_IFMT     _S_IFMT
246 #define S_IFDIR  _S_IFDIR
247 #define S_IFCHR  _S_IFCHR
248 #define S_IFREG  _S_IFREG
249 #define S_IREAD  _S_IREAD
250 #define S_IWRITE _S_IWRITE
251 #define S_IEXEC  _S_IEXEC
252
253 #endif  /* __STDC__ */
254
255 /*
256  * This file is included for __inlined non stdc functions. i.e. stat and fstat
257  */
258 #if !defined(RC_INVOKED) && !defined(__midl)
259 #include <sys/stat.inl>
260 #endif
261
262 #ifdef  __cplusplus
263 }
264 #endif
265
266 #ifdef  _MSC_VER
267 #pragma pack(pop)
268 #endif  /* _MSC_VER */
269
270 #endif  /* _INC_STAT */
271