Use inline functions instead of macros to avoid problems in C++.
[wine.git] / include / msvcrt / sys / stat.h
blob9603b54411a0760b36b29247d329f8310abba76a
1 /*
2 * _stat() definitions
4 * Derived from the mingw header written by Colin Peters.
5 * Modified for Wine use by Jon Griffiths and Francois Gouget.
6 * This file is in the public domain.
7 */
8 #ifndef __WINE_SYS_STAT_H
9 #define __WINE_SYS_STAT_H
10 #define __WINE_USE_MSVCRT
12 #include "sys/types.h"
14 #ifndef MSVCRT
15 # ifdef USE_MSVCRT_PREFIX
16 # define MSVCRT(x) MSVCRT_##x
17 # else
18 # define MSVCRT(x) x
19 # endif
20 #endif
22 #ifndef MSVCRT_WCHAR_T_DEFINED
23 #define MSVCRT_WCHAR_T_DEFINED
24 #ifndef __cplusplus
25 typedef unsigned short MSVCRT(wchar_t);
26 #endif
27 #endif
29 #ifndef _MSC_VER
30 # ifndef __int64
31 # define __int64 long long
32 # endif
33 #endif
35 #ifndef MSVCRT_DEV_T_DEFINED
36 typedef unsigned int _dev_t;
37 #define MSVCRT_DEV_T_DEFINED
38 #endif
40 #ifndef MSVCRT_INO_T_DEFINED
41 typedef unsigned short _ino_t;
42 #define MSVCRT_INO_T_DEFINED
43 #endif
45 #ifndef MSVCRT_TIME_T_DEFINED
46 typedef long MSVCRT(time_t);
47 #define MSVCRT_TIME_T_DEFINED
48 #endif
50 #ifndef MSVCRT_OFF_T_DEFINED
51 typedef int MSVCRT(_off_t);
52 #define MSVCRT_OFF_T_DEFINED
53 #endif
55 #define _S_IEXEC 0x0040
56 #define _S_IWRITE 0x0080
57 #define _S_IREAD 0x0100
58 #define _S_IFIFO 0x1000
59 #define _S_IFCHR 0x2000
60 #define _S_IFDIR 0x4000
61 #define _S_IFREG 0x8000
62 #define _S_IFMT 0xF000
64 /* for FreeBSD */
65 #undef st_atime
66 #undef st_ctime
67 #undef st_mtime
69 #ifndef MSVCRT_STAT_DEFINED
70 #define MSVCRT_STAT_DEFINED
72 struct _stat {
73 _dev_t st_dev;
74 _ino_t st_ino;
75 unsigned short st_mode;
76 short st_nlink;
77 short st_uid;
78 short st_gid;
79 _dev_t st_rdev;
80 MSVCRT(_off_t) st_size;
81 MSVCRT(time_t) st_atime;
82 MSVCRT(time_t) st_mtime;
83 MSVCRT(time_t) st_ctime;
86 struct _stati64 {
87 _dev_t st_dev;
88 _ino_t st_ino;
89 unsigned short st_mode;
90 short st_nlink;
91 short st_uid;
92 short st_gid;
93 _dev_t st_rdev;
94 __int64 st_size;
95 MSVCRT(time_t) st_atime;
96 MSVCRT(time_t) st_mtime;
97 MSVCRT(time_t) st_ctime;
99 #endif /* MSVCRT_STAT_DEFINED */
101 #ifdef __cplusplus
102 extern "C" {
103 #endif
105 int MSVCRT(_fstat)(int,struct _stat*);
106 int MSVCRT(_stat)(const char*,struct _stat*);
107 int _fstati64(int,struct _stati64*);
108 int _stati64(const char*,struct _stati64*);
109 int _umask(int);
111 #ifndef MSVCRT_WSTAT_DEFINED
112 #define MSVCRT_WSTAT_DEFINED
113 int _wstat(const MSVCRT(wchar_t)*,struct _stat*);
114 int _wstati64(const MSVCRT(wchar_t)*,struct _stati64*);
115 #endif /* MSVCRT_WSTAT_DEFINED */
117 #ifdef __cplusplus
119 #endif
122 #ifndef USE_MSVCRT_PREFIX
123 #define S_IFMT _S_IFMT
124 #define S_IFDIR _S_IFDIR
125 #define S_IFCHR _S_IFCHR
126 #define S_IFREG _S_IFREG
127 #define S_IREAD _S_IREAD
128 #define S_IWRITE _S_IWRITE
129 #define S_IEXEC _S_IEXEC
131 static inline int fstat(int fd, struct _stat* ptr) { return _fstat(fd, ptr); }
132 static inline int stat(const char* path, struct _stat* ptr) { return _stat(path, ptr); }
133 #ifndef MSVCRT_UMASK_DEFINED
134 static inline int umask(int fd) { return _umask(fd); }
135 #define MSVCRT_UMASK_DEFINED
136 #endif
137 #endif /* USE_MSVCRT_PREFIX */
139 #endif /* __WINE_SYS_STAT_H */