3 Bacula® - The Network Backup Solution
5 Copyright (C) 2010-2014 Free Software Foundation Europe e.V.
7 The main author of Bacula is Kern Sibbald, with contributions from many
8 others, a complete list can be found in the file AUTHORS.
10 You may use this file and others of this release according to the
11 license defined in the LICENSE file, which includes the Affero General
12 Public License, v3.0 ("AGPLv3") and some additional permissions and
13 terms pursuant to its AGPLv3 Section 7.
15 Bacula® is a registered trademark of Kern Sibbald.
19 /* You can include this file to your plugin to have
20 * access to some common tools and utilities provided by Bacula
26 #define JT_BACKUP 'B' /* Backup Job */
27 #define JT_RESTORE 'R' /* Restore Job */
29 #define L_FULL 'F' /* Full backup */
30 #define L_INCREMENTAL 'I' /* since last backup */
31 #define L_DIFFERENTIAL 'D' /* since last full backup */
34 # if defined(BUILDING_DLL)
35 # define DLL_IMP_EXP __declspec(dllexport)
36 # elif defined(USING_DLL)
37 # define DLL_IMP_EXP __declspec(dllimport)
43 DLL_IMP_EXP void *sm_malloc(const char *fname, int lineno, unsigned int nbytes);
44 DLL_IMP_EXP void sm_free(const char *file, int line, void *fp);
45 DLL_IMP_EXP void *reallymalloc(const char *fname, int lineno, unsigned int nbytes);
46 DLL_IMP_EXP void reallyfree(const char *file, int line, void *fp);
49 # define bmalloc(s) sm_malloc(__FILE__, __LINE__, (s))
50 # define bfree(o) sm_free(__FILE__, __LINE__, (o))
53 #define SM_CHECK sm_check(__FILE__, __LINE__, false)
60 #define malloc(s) sm_malloc(__FILE__, __LINE__, (s))
61 #define free(o) sm_free(__FILE__, __LINE__, (o))
63 inline void *operator new(size_t size, char const * file, int line)
65 void *pnew = sm_malloc(file,line, size);
66 memset((char *)pnew, 0, size);
70 inline void *operator new[](size_t size, char const * file, int line)
72 void *pnew = sm_malloc(file, line, size);
73 memset((char *)pnew, 0, size);
77 inline void *operator new(size_t size)
79 void *pnew = sm_malloc(__FILE__, __LINE__, size);
80 memset((char *)pnew, 0, size);
84 inline void *operator new[](size_t size)
86 void *pnew = sm_malloc(__FILE__, __LINE__, size);
87 memset((char *)pnew, 0, size);
91 #define new new(__FILE__, __LINE__)
93 inline void operator delete(void *buf)
95 sm_free( __FILE__, __LINE__, buf);
98 inline void operator delete[] (void *buf)
100 sm_free(__FILE__, __LINE__, buf);
103 #define Dmsg(context, level, ...) bfuncs->DebugMessage(context, __FILE__, __LINE__, level, __VA_ARGS__ )
104 #define Jmsg(context, type, ...) bfuncs->JobMessage(context, __FILE__, __LINE__, type, 0, __VA_ARGS__ )
108 /* Keep drive letters for windows vss snapshot */
109 static void add_drive(char *drives, int *nCount, char *fname) {
110 if (strlen(fname) >= 2 && B_ISALPHA(fname[0]) && fname[1] == ':') {
111 /* always add in uppercase */
112 char ch = toupper(fname[0]);
113 /* if not found in string, add drive letter */
114 if (!strchr(drives,ch)) {
115 drives[*nCount] = ch;
116 drives[*nCount+1] = 0;
122 /* Copy our drive list to Bacula core list */
123 static void copy_drives(char *drives, char *dest) {
124 int last = strlen(dest); /* dest is 27 bytes long */
125 for (char *p = drives; *p && last < 26; p++) {
126 if (!strchr(dest, *p)) {