4 // Copyright transferred from Raider Solutions, Inc to
5 // Kern Sibbald and John Walker by express permission.
8 * Author : Christopher S. Hull
9 * Created On : Fri Jan 30 13:00:51 2004
10 * Last Modified By: Thorsten Engel
11 * Last Modified On: Fri Apr 22 19:30:00 2004
16 Bacula® - The Network Backup Solution
18 Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
20 The main author of Bacula is Kern Sibbald, with contributions from
21 many others, a complete list can be found in the file AUTHORS.
22 This program is Free Software; you can redistribute it and/or
23 modify it under the terms of version two of the GNU General Public
24 License as published by the Free Software Foundation plus additions
25 that are listed in the file LICENSE.
27 This program is distributed in the hope that it will be useful, but
28 WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 General Public License for more details.
32 You should have received a copy of the GNU General Public License
33 along with this program; if not, write to the Free Software
34 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
37 Bacula® is a registered trademark of John Walker.
38 The licensor of Bacula is the Free Software Foundation Europe
39 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
40 Switzerland, email:ftf@fsfeurope.org.
44 #if !defined(__COMPAT_H_)
47 #define _STAT_H /* don't pull in MinGW stat.h */
48 #define _STAT_DEFINED /* don't pull in MinGW stat.h */
51 #if defined(_MSC_VER) && (_MSC_VER >= 1400) // VC8+
52 #pragma warning(disable : 4996) // Either disable all deprecation warnings,
53 // #define _CRT_SECURE_NO_DEPRECATE // Or just turn off warnings about the newly deprecated CRT functions.
54 #elif !defined(HAVE_MINGW) && !defined(HAVE_WXCONSOLE)
60 typedef UINT64 u_int64_t;
61 typedef UINT64 uint64_t;
62 typedef INT64 int64_t;
63 typedef UINT32 uint32_t;
64 typedef INT64 intmax_t;
65 typedef unsigned char uint8_t;
66 typedef unsigned short uint16_t;
67 typedef signed short int16_t;
68 typedef signed char int8_t;
69 typedef int __daddr_t;
70 #if !defined(HAVE_MINGW)
72 typedef float float32_t;
73 typedef double float64_t;
76 #if !defined(_MSC_VER) || (_MSC_VER < 1400) // VC8+
80 #if __STDC__ && !defined(HAVE_MINGW)
82 #if !defined(HAVE_WXCONSOLE)
83 typedef __int64 ino_t;
87 typedef UINT32 u_int32_t;
88 typedef unsigned char u_int8_t;
89 typedef unsigned short u_int16_t;
91 #if !defined(HAVE_MINGW)
99 #if defined(HAVE_MINGW)
101 typedef UINT32 uid_t;
102 typedef UINT32 gid_t;
105 typedef UINT32 uid_t;
106 typedef UINT32 gid_t;
107 typedef UINT32 mode_t;
108 typedef INT32 ssize_t;
109 #define HAVE_SSIZE_T 1
111 #endif /* HAVE_MINGW */
122 #if !defined(__cplusplus)
135 int strcasecmp(const char*, const char *);
136 int gettimeofday(struct timeval *, struct timezone *);
138 #if !defined(EETXTBUSY)
142 #if !defined(ETIMEDOUT)
146 #if !defined(ENOMEDIUM)
147 #define ENOMEDIUM 123
150 #if !defined(ENODATA)
172 #define S_IFMT 0170000 /* file type mask */
174 #define S_IFDIR 0040000 /* directory */
175 #define S_IFCHR 0020000 /* character special */
176 #define S_IFBLK 0060000 /* block special */
177 #define S_IFIFO 0010000 /* pipe */
179 #define S_IFREG 0100000 /* regular */
180 #define S_IREAD 0000400 /* read permission, owner */
181 #define S_IWRITE 0000200 /* write permission, owner */
182 #define S_IEXEC 0000100 /* execute/search permission, owner */
184 #define S_IRUSR S_IREAD
185 #define S_IWUSR S_IWRITE
186 #define S_IXUSR S_IEXEC
187 #define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
188 #define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
190 #define S_ISBLK(x) (((x) & S_IFMT) == S_IFBLK)
191 #define S_ISFIFO(x) 0
193 #define S_IRGRP 000040
194 #define S_IWGRP 000020
195 #define S_IXGRP 000010
197 #define S_IROTH 00004
198 #define S_IWOTH 00002
199 #define S_IXOTH 00001
201 #define S_IRWXO 000007
202 #define S_IRWXG 000070
203 #define S_ISUID 004000
204 #define S_ISGID 002000
205 #define S_ISVTX 001000
206 #define S_ISSOCK(x) 0
210 #define O_RDONLY _O_RDONLY
211 #define O_WRONLY _O_WRONLY
212 #define O_RDWR _O_RDWR
213 #define O_CREAT _O_CREAT
214 #define O_TRUNC _O_TRUNC
216 #define isascii __isascii
217 #define toascii __toascii
218 #define iscsymf __iscsymf
219 #define iscsym __iscsym
222 typedef BOOL (*t_pVSSPathConvert)(const char *szFilePath, char *szShadowPath, int nBuflen);
223 typedef BOOL (*t_pVSSPathConvertW)(const wchar_t *szFilePath, wchar_t *szShadowPath, int nBuflen);
225 void SetVSSPathConvert(t_pVSSPathConvert pPathConvert, t_pVSSPathConvertW pPathConvertW);
227 int lchown(const char *, uid_t uid, gid_t gid);
228 int chown(const char *, uid_t uid, gid_t gid);
229 #if !defined(HAVE_MINGW)
230 int chmod(const char *, mode_t mode);
232 #define O_NONBLOCK 04000
236 int tape_open(const char *file, int flags, int mode = 0);
237 int tape_read(int fd, void *buffer, unsigned int count);
238 int tape_write(int fd, const void *buffer, unsigned int count);
239 int tape_ioctl(int fd, unsigned long int request, ...);
240 int tape_close(int fd);
244 int fcntl(int fd, int cmd, long arg);
245 int fstat(int fd, struct stat *sb);
247 int inet_aton(const char *cp, struct in_addr *inp);
248 int kill(int pid, int signo);
251 int waitpid(int, int *, int);
253 #if !defined(HAVE_MINGW)
254 #define strncasecmp strnicmp
255 //int strncasecmp(const char*, const char *, int);
256 int utime(const char *filename, struct utimbuf *buf);
257 #define vsnprintf _vsnprintf
258 #define snprintf _snprintf
263 #define WIFEXITED(x) 0
264 #define WEXITSTATUS(x) x
265 #define WIFSIGNALED(x) 0
266 #define WTERMSIG(x) x
270 #define HAVE_OLD_SOCKOPT
273 int readdir(unsigned int fd, struct dirent *dirp, unsigned int count);
274 int nanosleep(const struct timespec*, struct timespec *);
275 long int random(void);
276 void srandom(unsigned int seed);
277 int lstat(const char *, struct stat *);
278 int stat(const char *file, struct stat *sb);
279 long pathconf(const char *, int);
280 int readlink(const char *, char *, int);
281 #define _PC_PATH_MAX 1
282 #define _PC_NAME_MAX 2
286 DIR *opendir(const char *name);
287 int closedir(DIR *dir);
297 struct passwd *getpwuid(uid_t);
298 struct group *getgrgid(uid_t);
302 void (*sa_handler)(int);
304 #define sigfillset(x)
305 #define sigaction(a, b, c)
307 #define mkdir(p, m) win32_mkdir(p)
308 #define unlink win32_unlink
309 #define chdir win32_chdir
310 extern "C" void syslog(int type, const char *fmt, ...);
311 #if !defined(LOG_DAEMON)
315 #if !defined(HAVE_MINGW)
318 int stat(const char *, struct stat *);
319 #if defined(__cplusplus)
320 #define access _access
321 extern "C" _CRTIMP int __cdecl _access(const char *, int);
322 int execvp(const char *, char *[]);
323 extern "C" void * __cdecl _alloca(size_t);
327 #define getpid _getpid
330 #define gethostid() 0
334 #define getcwd win32_getcwd
335 #define chdir win32_chdir
336 #define fputs win32_fputs
337 char *win32_getcwd(char *buf, int maxlen);
338 int win32_chdir(const char *buf);
339 int win32_mkdir(const char *buf);
340 int win32_fputs(const char *string, FILE *stream);
341 int win32_unlink(const char *filename);
343 char* win32_cgets (char* buffer, int len);
346 void Win32ConvCleanupCache();
348 #if defined(HAVE_MINGW)
350 void openlog(const char *ident, int option, int facility);
353 #if !defined(INVALID_FILE_ATTRIBUTES)
354 #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
357 #if defined(_MSC_VER)
358 inline unsigned long ffs(unsigned long word)
362 if (_BitScanForward(&index, word) != 0)
368 #define ftruncate _chsize_s
370 #define ffs __builtin_ffs
373 #endif /* __COMPAT_H_ */