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