]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/win32/filed/plugins/exch_api.h
Restore win32 dir from Branch-5.2 and update it
[bacula/bacula] / bacula / src / win32 / filed / plugins / exch_api.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2018 Kern Sibbald
5
6    The original author of Bacula is Kern Sibbald, with contributions
7    from many others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    This notice must be preserved when any source code is
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19 /* 
20  *  Written by James Harper, July 2010
21  */
22
23 extern "C" {
24
25 #define BACKUP_NODE_TYPE_MACHINE                0x001
26 #define BACKUP_NODE_TYPE_ANNOTATION             0x010
27 #define BACKUP_NODE_TYPE_DISPLAY                0x100
28
29 #define ESE_BACKUP_INSTANCE_END_ERROR   0x0
30 #define ESE_BACKUP_INSTANCE_END_SUCCESS 0x1
31
32 #define BACKUP_TYPE_FULL                        0x1
33 #define BACKUP_TYPE_LOGS_ONLY                   0x2
34 #define BACKUP_TYPE_FULL_WITH_ALL_LOGS          0x3
35
36 #define RESTORE_CLOSE_ABORT                     0x1
37 #define RESTORE_CLOSE_NORMAL                    0x0
38
39 #define ESE_RESTORE_COMPLETE_NOWAIT             0x00010000
40 #define ESE_RESTORE_COMPLETE_ATTACH_DBS         0x00000001
41 #define ESE_RESTORE_KEEP_LOG_FILES              0x00020000
42
43 //#include <windef.h>
44
45 struct ESE_ICON_DESCRIPTION {
46    uint32_t ulSize;
47    char *pvData;
48 };
49
50 struct BACKUP_NODE_TREE {
51    WCHAR *wszName;
52    uint32_t fFlags;
53    ESE_ICON_DESCRIPTION iconDescription;
54    struct BACKUP_NODE_TREE *pNextNode;
55    struct BACKUP_NODE_TREE *pChildNode;
56 };
57
58 struct DATABASE_BACKUP_INFO {
59    WCHAR *wszDatabaseDisplayName;
60    uint32_t cwDatabaseStreams;
61    WCHAR *wszDatabaseStreams;
62    GUID rguidDatabase;
63    uint32_t *rgIconIndexDatabase;
64    uint32_t fDatabaseFlags;
65 };
66
67 struct INSTANCE_BACKUP_INFO {
68    uint64_t hInstanceId;
69    //RPC_STRING wszInstanceName;
70    WCHAR *wszInstanceName;
71    uint32_t ulIconIndexInstance;
72    uint32_t cDatabase;
73    DATABASE_BACKUP_INFO *rgDatabase;
74    uint32_t cIconDescription;
75    ESE_ICON_DESCRIPTION *rgIconDescription;
76 };
77
78 enum RECOVER_STATUS {
79    recoverInvalid          = 0,
80    recoverNotStarted       = 1,
81    recoverStarted          = 2,
82    recoverEnded            = 3,
83    recoverStatusMax
84 };
85
86 struct RESTORE_ENVIRONMENT      {
87    WCHAR *                 m_wszRestoreLogPath;
88    WCHAR *                 m_wszSrcInstanceName;
89    uint32_t                m_cDatabases;
90    WCHAR                   **m_wszDatabaseDisplayName;
91    GUID *                  m_rguidDatabase;
92    WCHAR *                 m_wszRestoreInstanceSystemPath;
93    WCHAR *                 m_wszRestoreInstanceLogPath;
94    WCHAR *                 m_wszTargetInstanceName;
95    WCHAR **                m_wszDatabaseStreamsS;
96    WCHAR **                m_wszDatabaseStreamsD;
97    uint32_t                m_ulGenLow;
98    uint32_t                m_ulGenHigh;
99    WCHAR *                 m_wszLogBaseName;
100    time_t                  m_timeLastRestore;
101    RECOVER_STATUS  m_statusLastRecover;
102    HRESULT                 m_hrLastRecover;
103    time_t                  m_timeLastRecover;
104    WCHAR *                 m_wszAnnotation;
105 };
106
107 typedef HANDLE HCCX;
108
109 typedef HRESULT (WINAPI *HrESEBackupRestoreGetNodes_t)
110 (
111    WCHAR* wszComputerName,
112    BACKUP_NODE_TREE* pBackupNodeTree
113 );
114
115 typedef HRESULT (WINAPI *HrESEBackupPrepare_t)
116 (
117    WCHAR* wszBackupServer,
118    WCHAR* wszBackupAnnotation,
119    uint32_t *pcInstanceInfo,
120    INSTANCE_BACKUP_INFO **paInstanceInfo,
121    HCCX *phccxBackupContext
122 );
123
124 typedef HRESULT (WINAPI *HrESEBackupEnd_t)
125 (
126    HCCX hccsBackupContext
127 );
128
129 typedef HRESULT (WINAPI *HrESEBackupSetup_t)
130 (
131    HCCX hccsBackupContext,
132    uint64_t hInstanceID,
133    uint32_t btBackupType
134 );
135
136 typedef HRESULT (WINAPI *HrESEBackupGetLogAndPatchFiles_t)
137 (
138    HCCX hccsBackupContext,
139    WCHAR** pwszFiles
140 );
141
142 typedef HRESULT (WINAPI *HrESEBackupInstanceEnd_t)
143 (
144    HCCX hccsBackupContext,
145    uint32_t fFlags
146 );
147
148 typedef HRESULT (WINAPI *HrESEBackupOpenFile_t)
149 (
150    HCCX hccsBackupContext,
151    WCHAR* wszFileName,
152    uint32_t cbReadHintSize,
153    uint32_t cSections,
154    void** rghFile,
155    uint64_t* rgliSectionSize
156 );
157
158 typedef HRESULT (WINAPI *HrESEBackupReadFile_t)
159 (
160    HCCX hccsBackupContext,
161    void* hFile,
162    void* pvBuffer,
163    uint32_t cbBuffer,
164    uint32_t* pcbRead
165 );
166
167 typedef HRESULT (WINAPI *HrESEBackupCloseFile_t)
168 (
169    HCCX hccsBackupContext,
170    void* hFile
171 );
172
173 typedef HRESULT (WINAPI *HrESEBackupTruncateLogs_t)
174 (
175    HCCX hccsBackupContext
176 );
177
178 typedef HRESULT (WINAPI *HrESERestoreOpen_t)
179 (
180    WCHAR* wszBackupServer,
181    WCHAR* wszBackupAnnotation,
182    WCHAR* wszSrcInstanceName,
183    WCHAR* wszRestoreLogPath,
184    HCCX* phccxRestoreContext
185 );
186
187 typedef HRESULT (WINAPI *HrESERestoreReopen_t)
188 (
189    WCHAR* wszBackupServer,
190    WCHAR* wszBackupAnnotation,
191    WCHAR* wszRestoreLogPath,
192    HCCX* phccxRestoreContext
193 );
194
195 typedef HRESULT (WINAPI *HrESERestoreClose_t)
196 (
197    HCCX phccxRestoreContext,
198    uint32_t fRestoreAbort
199 );
200
201 typedef HRESULT (WINAPI *HrESERestoreComplete_t)
202 (
203    HCCX phccxRestoreContext,
204    WCHAR* wszCheckpointFilePath,
205    WCHAR* wszLogFilePath,
206    WCHAR* wszTargetInstanceName,
207    uint32_t fFlags
208 );
209
210 typedef HRESULT (WINAPI *HrESERestoreSaveEnvironment_t)
211 (
212    HCCX phccxRestoreContext
213 );
214
215 typedef HRESULT (WINAPI *HrESERestoreGetEnvironment_t)
216 (
217    HCCX phccxRestoreContext,
218    RESTORE_ENVIRONMENT **ppRestoreEnvironment
219 );
220
221 typedef HRESULT (WINAPI *HrESERestoreAddDatabase_t)
222 (
223    HCCX phccxRestoreContext,
224    WCHAR* wszDatabaseDisplayName,
225    GUID guidDatabase,
226    WCHAR* wszDatabaseStreamsS,
227    WCHAR** wszDatabaseStreamsD
228 );
229
230 typedef HRESULT (WINAPI *HrESERestoreOpenFile_t)
231 (
232    HCCX phccxRestoreContext,
233    WCHAR* wszFileName,
234    uint32_t cSections,
235    void* rghFile
236 );
237
238 bRC
239 loadExchangeApi();
240
241 const char *
242 ESEErrorMessage(HRESULT result);
243
244 #define hrLogfileHasBadSignature    (HRESULT)0xC8000262L
245 #define hrLogfileNotContiguous      (HRESULT)0xC8000263L
246 #define hrCBDatabaseInUse           (HRESULT)0xC7FE1F41L
247 #define hrRestoreAtFileLevel        (HRESULT)0xC7FF0FA5L
248 #define hrMissingFullBackup         (HRESULT)0xC8000230L
249 #define hrBackupInProgress          (HRESULT)0xC80001F9L
250 #define hrCBDatabaseNotFound        (HRESULT)0xC7FE1F42L
251 #define hrErrorFromESECall          (HRESULT)0xC7FF1004L
252
253 extern HrESEBackupRestoreGetNodes_t HrESEBackupRestoreGetNodes;
254 extern HrESEBackupPrepare_t HrESEBackupPrepare;
255 extern HrESEBackupGetLogAndPatchFiles_t HrESEBackupGetLogAndPatchFiles;
256 extern HrESEBackupTruncateLogs_t HrESEBackupTruncateLogs;
257 extern HrESEBackupEnd_t HrESEBackupEnd;
258 extern HrESEBackupSetup_t HrESEBackupSetup;
259 extern HrESEBackupInstanceEnd_t HrESEBackupInstanceEnd;
260 extern HrESEBackupOpenFile_t HrESEBackupOpenFile;
261 extern HrESEBackupReadFile_t HrESEBackupReadFile;
262 extern HrESEBackupCloseFile_t HrESEBackupCloseFile;
263
264 extern HrESERestoreOpen_t HrESERestoreOpen;
265 extern HrESERestoreReopen_t HrESERestoreReopen;
266 extern HrESERestoreComplete_t HrESERestoreComplete;
267 extern HrESERestoreClose_t HrESERestoreClose;
268 extern HrESERestoreGetEnvironment_t HrESERestoreGetEnvironment;
269 extern HrESERestoreSaveEnvironment_t HrESERestoreSaveEnvironment;
270 extern HrESERestoreAddDatabase_t HrESERestoreAddDatabase;
271 extern HrESERestoreOpenFile_t HrESERestoreOpenFile;
272
273 #if !defined(MINGW64)  && (_WIN32_WINNT < 0x0500)
274 typedef enum _COMPUTER_NAME_FORMAT {
275    ComputerNameNetBIOS,
276    ComputerNameDnsHostname,
277    ComputerNameDnsDomain,
278    ComputerNameDnsFullyQualified,
279    ComputerNamePhysicalNetBIOS,
280    ComputerNamePhysicalDnsHostname,
281    ComputerNamePhysicalDnsDomain,
282    ComputerNamePhysicalDnsFullyQualified,
283    ComputerNameMax
284 } COMPUTER_NAME_FORMAT;
285
286 BOOL WINAPI GetComputerNameExW(
287    COMPUTER_NAME_FORMAT NameType,
288    LPWSTR lpBuffer,
289    LPDWORD lpnSize
290 );
291 #endif
292
293 }