2 Bacula® - The Network Backup Solution
4 Copyright (C) 2004-2009 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version three of the GNU Affero General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU Affero General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of Kern Sibbald.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
31 // Copyright transferred from Raider Solutions, Inc to
32 // Kern Sibbald and John Walker by express permission.
35 * Author : Christopher S. Hull
36 * Created On : Fri Jan 30 13:00:51 2004
37 * Last Modified By: Thorsten Engel
38 * Last Modified On: Fri Apr 22 19:30:00 2004
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)
62 #define _declspec __declspec
66 # define GWL_USERDATA GWLP_USERDATA
70 #define INT64 long long int
73 typedef UINT64 u_int64_t;
74 typedef UINT64 uint64_t;
75 typedef INT64 int64_t;
76 typedef UINT32 uint32_t;
77 typedef INT64 intmax_t;
78 typedef unsigned char uint8_t;
79 typedef unsigned short uint16_t;
80 typedef signed short int16_t;
81 typedef signed char int8_t;
82 typedef int __daddr_t;
84 #if !defined(HAVE_MINGW)
86 typedef float float32_t;
87 typedef double float64_t;
90 #if !defined(_MSC_VER) || (_MSC_VER < 1400) // VC8+
91 #ifndef _TIME_T_DEFINED
92 #define _TIME_T_DEFINED
97 #if __STDC__ && !defined(HAVE_MINGW)
99 #if !defined(HAVE_WXCONSOLE)
100 typedef __int64 ino_t;
104 typedef UINT32 u_int32_t;
105 typedef unsigned char u_int8_t;
106 typedef unsigned short u_int16_t;
108 #if !defined(HAVE_MINGW)
114 typedef UINT32 key_t;
116 #if defined(HAVE_MINGW)
118 typedef UINT32 uid_t;
119 typedef UINT32 gid_t;
122 typedef UINT32 uid_t;
123 typedef UINT32 gid_t;
124 typedef UINT32 mode_t;
125 typedef INT32 ssize_t;
126 typedef UINT32 size_t;
127 #define HAVE_SSIZE_T 1
129 #endif /* HAVE_MINGW */
140 #if !defined(__cplusplus)
149 #ifndef _TIMEZONE_DEFINED /* also in sys/time.h */
150 #define _TIMEZONE_DEFINED
156 int strcasecmp(const char*, const char *);
157 int gettimeofday(struct timeval *, struct timezone *);
159 #if !defined(EETXTBUSY)
163 #if !defined(ETIMEDOUT)
167 #if !defined(ENOMEDIUM)
168 #define ENOMEDIUM 123
171 #if !defined(ENODATA)
193 #define S_IFMT 0170000 /* file type mask */
195 #define S_IFDIR 0040000 /* directory */
196 #define S_IFCHR 0020000 /* character special */
197 #define S_IFBLK 0060000 /* block special */
198 #define S_IFIFO 0010000 /* pipe */
200 #define S_IFREG 0100000 /* regular */
201 #define S_IREAD 0000400 /* read permission, owner */
202 #define S_IWRITE 0000200 /* write permission, owner */
203 #define S_IEXEC 0000100 /* execute/search permission, owner */
205 #define S_IRUSR S_IREAD
206 #define S_IWUSR S_IWRITE
207 #define S_IXUSR S_IEXEC
208 #define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
209 #define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
211 #define S_ISBLK(x) (((x) & S_IFMT) == S_IFBLK)
212 #define S_ISFIFO(x) 0
214 #define S_IRGRP 000040
215 #define S_IWGRP 000020
216 #define S_IXGRP 000010
218 #define S_IROTH 00004
219 #define S_IWOTH 00002
220 #define S_IXOTH 00001
222 #define S_IRWXO 000007
223 #define S_IRWXG 000070
224 #define S_ISUID 004000
225 #define S_ISGID 002000
226 #define S_ISVTX 001000
227 #define S_ISSOCK(x) 0
231 #define O_RDONLY _O_RDONLY
232 #define O_WRONLY _O_WRONLY
233 #define O_RDWR _O_RDWR
234 #define O_CREAT _O_CREAT
235 #define O_TRUNC _O_TRUNC
237 #define isascii __isascii
238 #define toascii __toascii
239 #define iscsymf __iscsymf
240 #define iscsym __iscsym
243 typedef BOOL (*t_pVSSPathConvert)(const char *szFilePath, char *szShadowPath, int nBuflen);
244 typedef BOOL (*t_pVSSPathConvertW)(const wchar_t *szFilePath, wchar_t *szShadowPath, int nBuflen);
246 void SetVSSPathConvert(t_pVSSPathConvert pPathConvert, t_pVSSPathConvertW pPathConvertW);
248 int lchown(const char *, uid_t uid, gid_t gid);
249 int chown(const char *, uid_t uid, gid_t gid);
250 #if !defined(HAVE_MINGW)
251 int chmod(const char *, mode_t mode);
253 #define O_NONBLOCK 04000
257 int win32_tape_open(const char *file, int flags, ...);
258 int win32_tape_ioctl(int fd, unsigned long int request, ...);
259 int win32_tape_close(int fd);
260 ssize_t win32_tape_read(int fd, void *buffer, size_t count);
261 ssize_t win32_tape_write(int fd, const void *buffer, size_t count);
263 ssize_t win32_read(int fd, void *buffer, size_t count);
264 ssize_t win32_write(int fd, const void *buffer, size_t count);
265 int win32_ioctl(int fd, unsigned long int req, ...);
271 int fcntl(int fd, int cmd, long arg);
272 int fstat(intptr_t fd, struct stat *sb);
274 int inet_aton(const char *cp, struct in_addr *inp);
275 int kill(int pid, int signo);
278 int waitpid(int, int *, int);
280 #if !defined(HAVE_MINGW)
281 #define strncasecmp strnicmp
282 //int strncasecmp(const char*, const char *, int);
283 int utime(const char *filename, struct utimbuf *buf);
284 #define vsnprintf _vsnprintf
285 #define snprintf _snprintf
290 #define WIFEXITED(x) 0
291 #define WEXITSTATUS(x) x
292 #define WIFSIGNALED(x) 0
293 #define WTERMSIG(x) x
297 #define HAVE_OLD_SOCKOPT
300 int readdir(unsigned int fd, struct dirent *dirp, unsigned int count);
301 int nanosleep(const struct timespec*, struct timespec *);
302 long int random(void);
303 void srandom(unsigned int seed);
304 int lstat(const char *, struct stat *);
305 int stat(const char *file, struct stat *sb);
306 long pathconf(const char *, int);
307 int readlink(const char *, char *, int);
308 #define _PC_PATH_MAX 1
309 #define _PC_NAME_MAX 2
313 DIR *opendir(const char *name);
314 int closedir(DIR *dir);
324 struct passwd *getpwuid(uid_t);
325 struct group *getgrgid(uid_t);
329 void (*sa_handler)(int);
331 #define sigfillset(x)
332 #define sigaction(a, b, c)
334 #define mkdir(p, m) win32_mkdir(p)
335 #define unlink win32_unlink
336 #define chdir win32_chdir
337 #define chmod win32_chmod
338 extern "C" void syslog(int type, const char *fmt, ...);
339 #if !defined(LOG_DAEMON)
343 #if !defined(HAVE_MINGW)
346 int stat(const char *, struct stat *);
347 #if defined(__cplusplus)
348 #define access _access
349 extern "C" _CRTIMP int __cdecl _access(const char *, int);
350 int execvp(const char *, char *[]);
351 extern "C" void * __cdecl _alloca(size_t);
355 #define getpid _getpid
358 #define gethostid() 0
362 #define getcwd win32_getcwd
363 #define chdir win32_chdir
364 #define chmod win32_chmod
365 #define fputs win32_fputs
366 char *win32_getcwd(char *buf, int maxlen);
367 int win32_chdir(const char *buf);
368 int win32_mkdir(const char *buf);
369 int win32_fputs(const char *string, FILE *stream);
370 int win32_unlink(const char *filename);
371 int win32_chmod(const char *, mode_t);
374 char* win32_cgets (char* buffer, int len);
377 void Win32ConvCleanupCache();
379 #if defined(HAVE_MINGW)
381 void openlog(const char *ident, int option, int facility);
384 void LogErrorMsg(const char *message);
386 /* Don't let OS go to sleep (usually a Laptop) while we are backing up */
387 void prevent_os_suspensions();
388 void allow_os_suspensions();
390 typedef DWORD EXECUTION_STATE;
391 #define ES_CONTINUOUS 0x80000000
392 #define ES_SYSTEM_REQUIRED 0x00000001
393 #define ES_DISPLAY_REQUIRED 0x00000002
394 #ifndef ES_USER_PRESENT
395 # define ES_USER_PRESENT 0x00000004
398 WINBASEAPI EXECUTION_STATE WINAPI SetThreadExecutionState(EXECUTION_STATE esFlags);
401 #if !defined(INVALID_FILE_ATTRIBUTES)
402 #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
405 #if defined(_MSC_VER)
406 inline unsigned long ffs(unsigned long word)
410 if (_BitScanForward(&index, word) != 0)
417 #define ffs __builtin_ffs
421 int win32_ftruncate(int fd, int64_t length);
424 #define ftruncate win32_ftruncate
426 #endif /* __COMPAT_H_ */