2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2010-2011 Bacula Systems(R) SA
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 modify it under the terms of
9 version three of the GNU Affero General Public License as published by the Free
10 Software Foundation, which is listed in the file LICENSE.
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
17 You should have received a copy of the GNU Affero General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 Bacula(R) is a registered trademark of Kern Sibbald.
23 Bacula Systems(R) is a trademark of Bacula Systems SA.
24 Bacula Enterprise(TM) is a trademark of Bacula Systems SA.
26 The licensor of Bacula Enterprise(TM) is Bacula Systems(R) SA,
27 Rue Galilee 5, 1400 Yverdon-les-Bains, Switzerland.
30 /* You can include this file to your plugin to have
31 * access to some common tools and utilities provided by Bacula
37 #define JT_BACKUP 'B' /* Backup Job */
38 #define JT_RESTORE 'R' /* Restore Job */
40 #define L_FULL 'F' /* Full backup */
41 #define L_INCREMENTAL 'I' /* since last backup */
42 #define L_DIFFERENTIAL 'D' /* since last full backup */
45 # if defined(BUILDING_DLL)
46 # define DLL_IMP_EXP __declspec(dllexport)
47 # elif defined(USING_DLL)
48 # define DLL_IMP_EXP __declspec(dllimport)
54 DLL_IMP_EXP void *sm_malloc(const char *fname, int lineno, unsigned int nbytes);
55 DLL_IMP_EXP void sm_free(const char *file, int line, void *fp);
56 DLL_IMP_EXP void *reallymalloc(const char *fname, int lineno, unsigned int nbytes);
57 DLL_IMP_EXP void reallyfree(const char *file, int line, void *fp);
60 # define bmalloc(s) sm_malloc(__FILE__, __LINE__, (s))
61 # define bfree(o) sm_free(__FILE__, __LINE__, (o))
64 #define SM_CHECK sm_check(__FILE__, __LINE__, false)
71 #define malloc(s) sm_malloc(__FILE__, __LINE__, (s))
72 #define free(o) sm_free(__FILE__, __LINE__, (o))
74 inline void *operator new(size_t size, char const * file, int line)
76 void *pnew = sm_malloc(file,line, size);
77 memset((char *)pnew, 0, size);
81 inline void *operator new[](size_t size, char const * file, int line)
83 void *pnew = sm_malloc(file, line, size);
84 memset((char *)pnew, 0, size);
88 inline void *operator new(size_t size)
90 void *pnew = sm_malloc(__FILE__, __LINE__, size);
91 memset((char *)pnew, 0, size);
95 inline void *operator new[](size_t size)
97 void *pnew = sm_malloc(__FILE__, __LINE__, size);
98 memset((char *)pnew, 0, size);
102 #define new new(__FILE__, __LINE__)
104 inline void operator delete(void *buf)
106 sm_free( __FILE__, __LINE__, buf);
109 inline void operator delete[] (void *buf)
111 sm_free(__FILE__, __LINE__, buf);
114 #define Dmsg(context, level, ...) bfuncs->DebugMessage(context, __FILE__, __LINE__, level, __VA_ARGS__ )
115 #define Jmsg(context, type, ...) bfuncs->JobMessage(context, __FILE__, __LINE__, type, 0, __VA_ARGS__ )
119 /* Keep drive letters for windows vss snapshot */
120 static void add_drive(char *drives, int *nCount, char *fname) {
121 if (strlen(fname) >= 2 && B_ISALPHA(fname[0]) && fname[1] == ':') {
122 /* always add in uppercase */
123 char ch = toupper(fname[0]);
124 /* if not found in string, add drive letter */
125 if (!strchr(drives,ch)) {
126 drives[*nCount] = ch;
127 drives[*nCount+1] = 0;
133 /* Copy our drive list to Bacula core list */
134 static void copy_drives(char *drives, char *dest) {
135 int last = strlen(dest); /* dest is 27 bytes long */
136 for (char *p = drives; *p && last < 26; p++) {
137 if (!strchr(dest, *p)) {