2 Bacula® - The Network Backup Solution
4 Copyright (C) 2004-2011 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
40 #if !defined(__COMPAT_H_)
43 #define _STAT_H /* don't pull in MinGW stat.h */
47 #define _STAT_DEFINED 1 /* don't pull in MinGW struct stat from wchar.h */
50 #if defined(_MSC_VER) && (_MSC_VER >= 1400) // VC8+
51 #pragma warning(disable : 4996) // Either disable all deprecation warnings,
52 // #define _CRT_SECURE_NO_DEPRECATE // Or just turn off warnings about the newly deprecated CRT functions.
53 #elif !defined(HAVE_MINGW) && !defined(HAVE_WXCONSOLE)
61 #define _declspec __declspec
63 /* Missing in 64 bit mingw */
64 typedef struct _REPARSE_DATA_BUFFER {
66 WORD ReparseDataLength;
70 WORD SubstituteNameOffset;
71 WORD SubstituteNameLength;
75 } SymbolicLinkReparseBuffer;
77 WORD SubstituteNameOffset;
78 WORD SubstituteNameLength;
82 } MountPointReparseBuffer;
85 } GenericReparseBuffer;
87 } REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
94 # define GWL_USERDATA GWLP_USERDATA
98 #define INT64 long long int
101 typedef UINT64 u_int64_t;
102 typedef UINT64 uint64_t;
103 typedef INT64 int64_t;
104 typedef UINT32 uint32_t;
105 typedef INT64 intmax_t;
106 typedef unsigned char uint8_t;
107 typedef unsigned short uint16_t;
108 typedef signed short int16_t;
109 typedef signed char int8_t;
110 typedef int __daddr_t;
112 #if !defined(HAVE_MINGW)
113 typedef long int32_t;
114 typedef float float32_t;
115 typedef double float64_t;
118 #if !defined(_MSC_VER) || (_MSC_VER < 1400) // VC8+
119 #ifndef _TIME_T_DEFINED
120 #define _TIME_T_DEFINED
125 #if __STDC__ && !defined(HAVE_MINGW)
126 typedef _dev_t dev_t;
127 #if !defined(HAVE_WXCONSOLE)
128 typedef __int64 ino_t;
132 typedef UINT32 u_int32_t;
133 typedef unsigned char u_int8_t;
134 typedef unsigned short u_int16_t;
136 #if !defined(HAVE_MINGW)
142 typedef UINT32 key_t;
144 #if defined(HAVE_MINGW)
146 typedef UINT32 uid_t;
147 typedef UINT32 gid_t;
150 typedef UINT32 uid_t;
151 typedef UINT32 gid_t;
152 typedef UINT32 mode_t;
153 typedef INT32 ssize_t;
154 typedef UINT32 size_t;
155 #define HAVE_SSIZE_T 1
157 #endif /* HAVE_MINGW */
168 #if !defined(__cplusplus)
177 #ifndef _TIMEZONE_DEFINED /* also in sys/time.h */
178 #define _TIMEZONE_DEFINED
184 int strcasecmp(const char*, const char *);
185 int gettimeofday(struct timeval *, struct timezone *);
187 #if !defined(EETXTBUSY)
191 #if !defined(ETIMEDOUT)
195 #if !defined(ENOMEDIUM)
196 #define ENOMEDIUM 123
199 #if !defined(ENODATA)
221 #define S_IFMT 0170000 /* file type mask */
223 #define S_IFDIR 0040000 /* directory */
224 #define S_IFCHR 0020000 /* character special */
225 #define S_IFBLK 0060000 /* block special */
226 #define S_IFIFO 0010000 /* pipe */
228 #define S_IFREG 0100000 /* regular */
229 #define S_IREAD 0000400 /* read permission, owner */
230 #define S_IWRITE 0000200 /* write permission, owner */
231 #define S_IEXEC 0000100 /* execute/search permission, owner */
233 #define S_IRUSR S_IREAD
234 #define S_IWUSR S_IWRITE
235 #define S_IXUSR S_IEXEC
236 #define S_ISREG(x) (((x) & S_IFMT) == S_IFREG)
237 #define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR)
239 #define S_ISBLK(x) (((x) & S_IFMT) == S_IFBLK)
240 #define S_ISFIFO(x) 0
242 #define S_IRGRP 000040
243 #define S_IWGRP 000020
244 #define S_IXGRP 000010
246 #define S_IROTH 00004
247 #define S_IWOTH 00002
248 #define S_IXOTH 00001
250 #define S_IRWXO 000007
251 #define S_IRWXG 000070
252 #define S_ISUID 004000
253 #define S_ISGID 002000
254 #define S_ISVTX 001000
255 #define S_ISSOCK(x) 0
259 #define O_RDONLY _O_RDONLY
260 #define O_WRONLY _O_WRONLY
261 #define O_RDWR _O_RDWR
262 #define O_CREAT _O_CREAT
263 #define O_TRUNC _O_TRUNC
265 #define isascii __isascii
266 #define toascii __toascii
267 #define iscsymf __iscsymf
268 #define iscsym __iscsym
271 typedef BOOL (*t_pVSSPathConvert)(const char *szFilePath, char *szShadowPath, int nBuflen);
272 typedef BOOL (*t_pVSSPathConvertW)(const wchar_t *szFilePath, wchar_t *szShadowPath, int nBuflen);
274 void SetVSSPathConvert(t_pVSSPathConvert pPathConvert, t_pVSSPathConvertW pPathConvertW);
276 int lchown(const char *, uid_t uid, gid_t gid);
277 int chown(const char *, uid_t uid, gid_t gid);
278 #if !defined(HAVE_MINGW)
279 int chmod(const char *, mode_t mode);
281 #define O_NONBLOCK 04000
285 int win32_tape_open(const char *file, int flags, ...);
286 int win32_tape_ioctl(int fd, unsigned long int request, ...);
287 int win32_tape_close(int fd);
288 ssize_t win32_tape_read(int fd, void *buffer, size_t count);
289 ssize_t win32_tape_write(int fd, const void *buffer, size_t count);
291 ssize_t win32_read(int fd, void *buffer, size_t count);
292 ssize_t win32_write(int fd, const void *buffer, size_t count);
293 int win32_ioctl(int fd, unsigned long int req, ...);
299 int fcntl(int fd, int cmd, long arg);
300 int fstat(intptr_t fd, struct stat *sb);
302 int inet_aton(const char *cp, struct in_addr *inp);
303 int kill(int pid, int signo);
306 int waitpid(int, int *, int);
308 #if !defined(HAVE_MINGW)
309 #define strncasecmp strnicmp
310 //int strncasecmp(const char*, const char *, int);
311 int utime(const char *filename, struct utimbuf *buf);
312 #define vsnprintf _vsnprintf
313 #define snprintf _snprintf
318 #define WIFEXITED(x) 0
319 #define WEXITSTATUS(x) x
320 #define WIFSIGNALED(x) 0
321 #define WTERMSIG(x) x
325 #define HAVE_OLD_SOCKOPT
328 int readdir(unsigned int fd, struct dirent *dirp, unsigned int count);
329 int nanosleep(const struct timespec*, struct timespec *);
330 long int random(void);
331 void srandom(unsigned int seed);
332 int lstat(const char *, struct stat *);
333 int stat(const char *file, struct stat *sb);
334 long pathconf(const char *, int);
335 int readlink(const char *, char *, int);
336 #define _PC_PATH_MAX 1
337 #define _PC_NAME_MAX 2
341 DIR *opendir(const char *name);
342 int closedir(DIR *dir);
352 struct passwd *getpwuid(uid_t);
353 struct group *getgrgid(uid_t);
357 void (*sa_handler)(int);
359 #define sigfillset(x)
360 #define sigaction(a, b, c)
362 #define mkdir(p, m) win32_mkdir(p)
363 #define unlink win32_unlink
364 #define chdir win32_chdir
365 #define chmod win32_chmod
366 extern "C" void syslog(int type, const char *fmt, ...);
367 #if !defined(LOG_DAEMON)
371 #if !defined(HAVE_MINGW)
374 int stat(const char *, struct stat *);
375 #if defined(__cplusplus)
376 #define access _access
377 extern "C" _CRTIMP int __cdecl _access(const char *, int);
378 int execvp(const char *, char *[]);
379 extern "C" void * __cdecl _alloca(size_t);
383 #define getpid _getpid
386 #define gethostid() 0
390 #define getcwd win32_getcwd
391 #define chdir win32_chdir
392 #define chmod win32_chmod
393 #define fputs win32_fputs
394 char *win32_getcwd(char *buf, int maxlen);
395 int win32_chdir(const char *buf);
396 int win32_mkdir(const char *buf);
397 int win32_fputs(const char *string, FILE *stream);
398 int win32_unlink(const char *filename);
399 int win32_chmod(const char *, mode_t);
402 char* win32_cgets (char* buffer, int len);
405 void Win32ConvCleanupCache();
407 #if defined(HAVE_MINGW)
409 void openlog(const char *ident, int option, int facility);
412 /* Don't let OS go to sleep (usually a Laptop) while we are backing up */
413 void prevent_os_suspensions();
414 void allow_os_suspensions();
416 typedef DWORD EXECUTION_STATE;
417 #ifndef ES_CONTINUOUS
418 #define ES_CONTINUOUS 0x80000000
420 #ifndef ES_SYSTEM_REQUIRED
421 #define ES_SYSTEM_REQUIRED 0x00000001
423 #ifndef ES_DISPLAY_REQUIRED
424 #define ES_DISPLAY_REQUIRED 0x00000002
426 #ifndef ES_USER_PRESENT
427 # define ES_USER_PRESENT 0x00000004
430 WINBASEAPI EXECUTION_STATE WINAPI SetThreadExecutionState(EXECUTION_STATE esFlags);
433 extern void LogErrorMsg(const char *message);
435 #if !defined(INVALID_FILE_ATTRIBUTES)
436 #define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
439 #if defined(_MSC_VER)
440 inline unsigned long ffs(unsigned long word)
444 if (_BitScanForward(&index, word) != 0)
451 #define ffs __builtin_ffs
455 int win32_ftruncate(int fd, int64_t length);
458 #define ftruncate win32_ftruncate
460 #endif /* __COMPAT_H_ */