From 9d3de1c91cf738ca4281082e66cb9a0792e2172c Mon Sep 17 00:00:00 2001 From: James Harper Date: Sun, 29 Mar 2009 10:34:11 +0000 Subject: [PATCH] whitespace cleanup git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8639 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/src/win32/filed/plugins/api.c | 161 ++-- bacula/src/win32/filed/plugins/api.h | 210 ++--- bacula/src/win32/filed/plugins/dbi_node.c | 402 ++++---- bacula/src/win32/filed/plugins/exchange-fd.c | 566 ++++++------ bacula/src/win32/filed/plugins/exchange-fd.h | 34 +- bacula/src/win32/filed/plugins/file_node.c | 306 +++---- bacula/src/win32/filed/plugins/node.c | 114 +-- bacula/src/win32/filed/plugins/node.h | 250 ++--- bacula/src/win32/filed/plugins/root_node.c | 190 ++-- bacula/src/win32/filed/plugins/service_node.c | 332 +++---- .../win32/filed/plugins/storage_group_node.c | 862 +++++++++--------- bacula/src/win32/filed/plugins/store_node.c | 376 ++++---- 12 files changed, 1902 insertions(+), 1901 deletions(-) diff --git a/bacula/src/win32/filed/plugins/api.c b/bacula/src/win32/filed/plugins/api.c index 7601afaa7e..2f01d84441 100644 --- a/bacula/src/win32/filed/plugins/api.c +++ b/bacula/src/win32/filed/plugins/api.c @@ -54,91 +54,92 @@ HrESERestoreOpenFile_t HrESERestoreOpenFile; bRC loadExchangeApi() { - HMODULE h; - LONG status; - HKEY key_handle; - WCHAR *buf; - DWORD buf_len; - DWORD type; - - status = RegOpenKeyW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\BackupRestore\\DLLPaths", &key_handle); - if (status != ERROR_SUCCESS) - { - _JobMessageNull(M_ERROR, "Cannot get key for Exchange DLL path, result = %08x\n", status); - return bRC_Error; - } - - type = REG_EXPAND_SZ; - status = RegQueryValueExW(key_handle, L"esebcli2", NULL, &type, NULL, &buf_len); - if (status != ERROR_SUCCESS) - { - _JobMessageNull(M_ERROR, "Cannot get key for Exchange DLL path, result = %08x\n", status); - return bRC_Error; - } - buf_len += 2; - buf = new WCHAR[buf_len]; - - type = REG_EXPAND_SZ; - status = RegQueryValueExW(key_handle, L"esebcli2", NULL, &type, (LPBYTE)buf, &buf_len); - if (status != ERROR_SUCCESS) - { - _JobMessageNull(M_ERROR, "Cannot get key for Exchange DLL path, result = %08x\n", status); - delete buf; - return bRC_Error; - } + HMODULE h; + LONG status; + HKEY key_handle; + WCHAR *buf; + DWORD buf_len; + DWORD type; + + status = RegOpenKeyW(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\BackupRestore\\DLLPaths", &key_handle); + if (status != ERROR_SUCCESS) + { + _JobMessageNull(M_ERROR, "Cannot get key for Exchange DLL path, result = %08x\n", status); + return bRC_Error; + } + + type = REG_EXPAND_SZ; + status = RegQueryValueExW(key_handle, L"esebcli2", NULL, &type, NULL, &buf_len); + if (status != ERROR_SUCCESS) + { + _JobMessageNull(M_ERROR, "Cannot get key for Exchange DLL path, result = %08x\n", status); + return bRC_Error; + } + buf_len += 2; + buf = new WCHAR[buf_len]; + + type = REG_EXPAND_SZ; + status = RegQueryValueExW(key_handle, L"esebcli2", NULL, &type, (LPBYTE)buf, &buf_len); + if (status != ERROR_SUCCESS) + { + _JobMessageNull(M_ERROR, "Cannot get key for Exchange DLL path, result = %08x\n", status); + delete buf; + return bRC_Error; + } printf("Got value %S\n", buf); - // strictly speaking, a REG_EXPAND_SZ should be run through ExpandEnvironmentStrings - - h = LoadLibraryW(buf); - delete buf; - if (!h) { - return bRC_Error; - } - HrESEBackupRestoreGetNodes = (HrESEBackupRestoreGetNodes_t)GetProcAddress(h, "HrESEBackupRestoreGetNodes"); - HrESEBackupPrepare = (HrESEBackupPrepare_t)GetProcAddress(h, "HrESEBackupPrepare"); - HrESEBackupEnd = (HrESEBackupEnd_t)GetProcAddress(h, "HrESEBackupEnd"); - HrESEBackupSetup = (HrESEBackupSetup_t)GetProcAddress(h, "HrESEBackupSetup"); - HrESEBackupGetLogAndPatchFiles = (HrESEBackupGetLogAndPatchFiles_t)GetProcAddress(h, "HrESEBackupGetLogAndPatchFiles"); - HrESEBackupTruncateLogs = (HrESEBackupTruncateLogs_t)GetProcAddress(h, "HrESEBackupTruncateLogs"); - HrESEBackupInstanceEnd = (HrESEBackupInstanceEnd_t)GetProcAddress(h, "HrESEBackupInstanceEnd"); - HrESEBackupOpenFile = (HrESEBackupOpenFile_t)GetProcAddress(h, "HrESEBackupOpenFile"); - HrESEBackupReadFile = (HrESEBackupReadFile_t)GetProcAddress(h, "HrESEBackupReadFile"); - HrESEBackupCloseFile = (HrESEBackupCloseFile_t)GetProcAddress(h, "HrESEBackupCloseFile"); - HrESERestoreOpen = (HrESERestoreOpen_t)GetProcAddress(h, "HrESERestoreOpen"); - HrESERestoreReopen = (HrESERestoreReopen_t)GetProcAddress(h, "HrESERestoreReopen"); - HrESERestoreComplete = (HrESERestoreComplete_t)GetProcAddress(h, "HrESERestoreComplete"); - HrESERestoreClose = (HrESERestoreClose_t)GetProcAddress(h, "HrESERestoreClose"); - HrESERestoreSaveEnvironment = (HrESERestoreSaveEnvironment_t)GetProcAddress(h, "HrESERestoreSaveEnvironment"); - HrESERestoreGetEnvironment = (HrESERestoreGetEnvironment_t)GetProcAddress(h, "HrESERestoreGetEnvironment"); - HrESERestoreAddDatabase = (HrESERestoreAddDatabase_t)GetProcAddress(h, "HrESERestoreAddDatabase"); - HrESERestoreOpenFile = (HrESERestoreOpenFile_t)GetProcAddress(h, "HrESERestoreOpenFile"); - return bRC_OK; + // strictly speaking, a REG_EXPAND_SZ should be run through ExpandEnvironmentStrings + + h = LoadLibraryW(buf); + delete buf; + if (!h) { + return bRC_Error; + } + HrESEBackupRestoreGetNodes = (HrESEBackupRestoreGetNodes_t)GetProcAddress(h, "HrESEBackupRestoreGetNodes"); + HrESEBackupPrepare = (HrESEBackupPrepare_t)GetProcAddress(h, "HrESEBackupPrepare"); + HrESEBackupEnd = (HrESEBackupEnd_t)GetProcAddress(h, "HrESEBackupEnd"); + HrESEBackupSetup = (HrESEBackupSetup_t)GetProcAddress(h, "HrESEBackupSetup"); + HrESEBackupGetLogAndPatchFiles = (HrESEBackupGetLogAndPatchFiles_t)GetProcAddress(h, "HrESEBackupGetLogAndPatchFiles"); + HrESEBackupTruncateLogs = (HrESEBackupTruncateLogs_t)GetProcAddress(h, "HrESEBackupTruncateLogs"); + HrESEBackupInstanceEnd = (HrESEBackupInstanceEnd_t)GetProcAddress(h, "HrESEBackupInstanceEnd"); + HrESEBackupOpenFile = (HrESEBackupOpenFile_t)GetProcAddress(h, "HrESEBackupOpenFile"); + HrESEBackupReadFile = (HrESEBackupReadFile_t)GetProcAddress(h, "HrESEBackupReadFile"); + HrESEBackupCloseFile = (HrESEBackupCloseFile_t)GetProcAddress(h, "HrESEBackupCloseFile"); + HrESERestoreOpen = (HrESERestoreOpen_t)GetProcAddress(h, "HrESERestoreOpen"); + HrESERestoreReopen = (HrESERestoreReopen_t)GetProcAddress(h, "HrESERestoreReopen"); + HrESERestoreComplete = (HrESERestoreComplete_t)GetProcAddress(h, "HrESERestoreComplete"); + HrESERestoreClose = (HrESERestoreClose_t)GetProcAddress(h, "HrESERestoreClose"); + HrESERestoreSaveEnvironment = (HrESERestoreSaveEnvironment_t)GetProcAddress(h, "HrESERestoreSaveEnvironment"); + HrESERestoreGetEnvironment = (HrESERestoreGetEnvironment_t)GetProcAddress(h, "HrESERestoreGetEnvironment"); + HrESERestoreAddDatabase = (HrESERestoreAddDatabase_t)GetProcAddress(h, "HrESERestoreAddDatabase"); + HrESERestoreOpenFile = (HrESERestoreOpenFile_t)GetProcAddress(h, "HrESERestoreOpenFile"); + return bRC_OK; } char * ESEErrorMessage(HRESULT result) { - switch (result) - { - case 0: - return "No error."; - case hrLogfileHasBadSignature: - return "Log file has bad signature. Check that no stale files are left in the Exchange data/log directories."; - case hrCBDatabaseInUse: - return "Database in use. Make sure database is dismounted."; - case hrRestoreAtFileLevel: - return "File must be restored using Windows file I/O calls."; - case hrMissingFullBackup: - return "Exchange reports that no previous full backup has been done."; - case hrBackupInProgress: - return "Exchange backup already in progress."; - case hrLogfileNotContiguous: - return "Existing log file is not contiguous. Check that no stale files are left in the Exchange data/log directories."; - case hrCBDatabaseNotFound: - return "Database not found. Check that the Database you are trying to restore actually exists in the Storage Group you are restoring to."; - default: - return "Unknown error."; - } -} + switch (result) + { + case 0: + return "No error."; + case hrLogfileHasBadSignature: + return "Log file has bad signature. Check that no stale files are left in the Exchange data/log directories."; + case hrCBDatabaseInUse: + return "Database in use. Make sure database is dismounted."; + case hrRestoreAtFileLevel: + return "File must be restored using Windows file I/O calls."; + case hrMissingFullBackup: + return "Exchange reports that no previous full backup has been done."; + case hrBackupInProgress: + return "Exchange backup already in progress."; + case hrLogfileNotContiguous: + return "Existing log file is not contiguous. Check that no stale files are left in the Exchange data/log directories."; + case hrCBDatabaseNotFound: + return "Database not found. Check that the Database you are trying to restore actually exists in the Storage Group you are restoring to."; + default: + return "Unknown error."; + } +} + diff --git a/bacula/src/win32/filed/plugins/api.h b/bacula/src/win32/filed/plugins/api.h index 7e41991245..105e9640fc 100644 --- a/bacula/src/win32/filed/plugins/api.h +++ b/bacula/src/win32/filed/plugins/api.h @@ -40,210 +40,210 @@ extern "C" { #define ESE_BACKUP_INSTANCE_END_ERROR 0x0 #define ESE_BACKUP_INSTANCE_END_SUCCESS 0x1 -#define BACKUP_TYPE_FULL 0x1 +#define BACKUP_TYPE_FULL 0x1 #define BACKUP_TYPE_LOGS_ONLY 0x2 -#define BACKUP_TYPE_FULL_WITH_ALL_LOGS 0x3 +#define BACKUP_TYPE_FULL_WITH_ALL_LOGS 0x3 -#define RESTORE_CLOSE_ABORT 0x1 +#define RESTORE_CLOSE_ABORT 0x1 #define RESTORE_CLOSE_NORMAL 0x0 #define ESE_RESTORE_COMPLETE_NOWAIT 0x00010000 -#define ESE_RESTORE_COMPLETE_ATTACH_DBS 0x00000001 +#define ESE_RESTORE_COMPLETE_ATTACH_DBS 0x00000001 #define ESE_RESTORE_KEEP_LOG_FILES 0x00020000 //#include struct ESE_ICON_DESCRIPTION { - uint32_t ulSize; - char *pvData; + uint32_t ulSize; + char *pvData; }; struct BACKUP_NODE_TREE { - WCHAR *wszName; - uint32_t fFlags; - ESE_ICON_DESCRIPTION iconDescription; - struct BACKUP_NODE_TREE *pNextNode; - struct BACKUP_NODE_TREE *pChildNode; + WCHAR *wszName; + uint32_t fFlags; + ESE_ICON_DESCRIPTION iconDescription; + struct BACKUP_NODE_TREE *pNextNode; + struct BACKUP_NODE_TREE *pChildNode; }; struct DATABASE_BACKUP_INFO { - WCHAR *wszDatabaseDisplayName; - uint32_t cwDatabaseStreams; - WCHAR *wszDatabaseStreams; - GUID rguidDatabase; - uint32_t *rgIconIndexDatabase; - uint32_t fDatabaseFlags; + WCHAR *wszDatabaseDisplayName; + uint32_t cwDatabaseStreams; + WCHAR *wszDatabaseStreams; + GUID rguidDatabase; + uint32_t *rgIconIndexDatabase; + uint32_t fDatabaseFlags; }; struct INSTANCE_BACKUP_INFO { - uint64_t hInstanceId; - //RPC_STRING wszInstanceName; - WCHAR *wszInstanceName; - uint32_t ulIconIndexInstance; - uint32_t cDatabase; - DATABASE_BACKUP_INFO *rgDatabase; - uint32_t cIconDescription; - ESE_ICON_DESCRIPTION *rgIconDescription; + uint64_t hInstanceId; + //RPC_STRING wszInstanceName; + WCHAR *wszInstanceName; + uint32_t ulIconIndexInstance; + uint32_t cDatabase; + DATABASE_BACKUP_INFO *rgDatabase; + uint32_t cIconDescription; + ESE_ICON_DESCRIPTION *rgIconDescription; }; enum RECOVER_STATUS { - recoverInvalid = 0, - recoverNotStarted = 1, - recoverStarted = 2, - recoverEnded = 3, - recoverStatusMax + recoverInvalid = 0, + recoverNotStarted = 1, + recoverStarted = 2, + recoverEnded = 3, + recoverStatusMax }; struct RESTORE_ENVIRONMENT { - WCHAR * m_wszRestoreLogPath; - WCHAR * m_wszSrcInstanceName; - uint32_t m_cDatabases; - WCHAR **m_wszDatabaseDisplayName; - GUID * m_rguidDatabase; - WCHAR * m_wszRestoreInstanceSystemPath; - WCHAR * m_wszRestoreInstanceLogPath; - WCHAR * m_wszTargetInstanceName; - WCHAR ** m_wszDatabaseStreamsS; - WCHAR ** m_wszDatabaseStreamsD; - uint32_t m_ulGenLow; - uint32_t m_ulGenHigh; - WCHAR * m_wszLogBaseName; - time_t m_timeLastRestore; - RECOVER_STATUS m_statusLastRecover; - HRESULT m_hrLastRecover; - time_t m_timeLastRecover; - WCHAR * m_wszAnnotation; + WCHAR * m_wszRestoreLogPath; + WCHAR * m_wszSrcInstanceName; + uint32_t m_cDatabases; + WCHAR **m_wszDatabaseDisplayName; + GUID * m_rguidDatabase; + WCHAR * m_wszRestoreInstanceSystemPath; + WCHAR * m_wszRestoreInstanceLogPath; + WCHAR * m_wszTargetInstanceName; + WCHAR ** m_wszDatabaseStreamsS; + WCHAR ** m_wszDatabaseStreamsD; + uint32_t m_ulGenLow; + uint32_t m_ulGenHigh; + WCHAR * m_wszLogBaseName; + time_t m_timeLastRestore; + RECOVER_STATUS m_statusLastRecover; + HRESULT m_hrLastRecover; + time_t m_timeLastRecover; + WCHAR * m_wszAnnotation; }; typedef HANDLE HCCX; typedef HRESULT (WINAPI *HrESEBackupRestoreGetNodes_t) ( - WCHAR* wszComputerName, - BACKUP_NODE_TREE* pBackupNodeTree + WCHAR* wszComputerName, + BACKUP_NODE_TREE* pBackupNodeTree ); typedef HRESULT (WINAPI *HrESEBackupPrepare_t) ( - WCHAR* wszBackupServer, - WCHAR* wszBackupAnnotation, - uint32_t *pcInstanceInfo, - INSTANCE_BACKUP_INFO **paInstanceInfo, - HCCX *phccxBackupContext + WCHAR* wszBackupServer, + WCHAR* wszBackupAnnotation, + uint32_t *pcInstanceInfo, + INSTANCE_BACKUP_INFO **paInstanceInfo, + HCCX *phccxBackupContext ); typedef HRESULT (WINAPI *HrESEBackupEnd_t) ( - HCCX hccsBackupContext + HCCX hccsBackupContext ); typedef HRESULT (WINAPI *HrESEBackupSetup_t) ( - HCCX hccsBackupContext, - uint64_t hInstanceID, - uint32_t btBackupType + HCCX hccsBackupContext, + uint64_t hInstanceID, + uint32_t btBackupType ); typedef HRESULT (WINAPI *HrESEBackupGetLogAndPatchFiles_t) ( - HCCX hccsBackupContext, - WCHAR** pwszFiles + HCCX hccsBackupContext, + WCHAR** pwszFiles ); typedef HRESULT (WINAPI *HrESEBackupInstanceEnd_t) ( - HCCX hccsBackupContext, - uint32_t fFlags + HCCX hccsBackupContext, + uint32_t fFlags ); typedef HRESULT (WINAPI *HrESEBackupOpenFile_t) ( - HCCX hccsBackupContext, - WCHAR* wszFileName, - uint32_t cbReadHintSize, - uint32_t cSections, - void** rghFile, - uint64_t* rgliSectionSize + HCCX hccsBackupContext, + WCHAR* wszFileName, + uint32_t cbReadHintSize, + uint32_t cSections, + void** rghFile, + uint64_t* rgliSectionSize ); typedef HRESULT (WINAPI *HrESEBackupReadFile_t) ( - HCCX hccsBackupContext, - void* hFile, - void* pvBuffer, - uint32_t cbBuffer, - uint32_t* pcbRead + HCCX hccsBackupContext, + void* hFile, + void* pvBuffer, + uint32_t cbBuffer, + uint32_t* pcbRead ); typedef HRESULT (WINAPI *HrESEBackupCloseFile_t) ( - HCCX hccsBackupContext, - void* hFile + HCCX hccsBackupContext, + void* hFile ); typedef HRESULT (WINAPI *HrESEBackupTruncateLogs_t) ( - HCCX hccsBackupContext + HCCX hccsBackupContext ); typedef HRESULT (WINAPI *HrESERestoreOpen_t) ( - WCHAR* wszBackupServer, - WCHAR* wszBackupAnnotation, - WCHAR* wszSrcInstanceName, - WCHAR* wszRestoreLogPath, - HCCX* phccxRestoreContext + WCHAR* wszBackupServer, + WCHAR* wszBackupAnnotation, + WCHAR* wszSrcInstanceName, + WCHAR* wszRestoreLogPath, + HCCX* phccxRestoreContext ); typedef HRESULT (WINAPI *HrESERestoreReopen_t) ( - WCHAR* wszBackupServer, - WCHAR* wszBackupAnnotation, - WCHAR* wszRestoreLogPath, - HCCX* phccxRestoreContext + WCHAR* wszBackupServer, + WCHAR* wszBackupAnnotation, + WCHAR* wszRestoreLogPath, + HCCX* phccxRestoreContext ); typedef HRESULT (WINAPI *HrESERestoreClose_t) ( - HCCX phccxRestoreContext, - uint32_t fRestoreAbort + HCCX phccxRestoreContext, + uint32_t fRestoreAbort ); typedef HRESULT (WINAPI *HrESERestoreComplete_t) ( - HCCX phccxRestoreContext, - WCHAR* wszCheckpointFilePath, - WCHAR* wszLogFilePath, - WCHAR* wszTargetInstanceName, - uint32_t fFlags + HCCX phccxRestoreContext, + WCHAR* wszCheckpointFilePath, + WCHAR* wszLogFilePath, + WCHAR* wszTargetInstanceName, + uint32_t fFlags ); typedef HRESULT (WINAPI *HrESERestoreSaveEnvironment_t) ( - HCCX phccxRestoreContext + HCCX phccxRestoreContext ); typedef HRESULT (WINAPI *HrESERestoreGetEnvironment_t) ( - HCCX phccxRestoreContext, - RESTORE_ENVIRONMENT **ppRestoreEnvironment + HCCX phccxRestoreContext, + RESTORE_ENVIRONMENT **ppRestoreEnvironment ); typedef HRESULT (WINAPI *HrESERestoreAddDatabase_t) ( - HCCX phccxRestoreContext, - WCHAR* wszDatabaseDisplayName, - GUID guidDatabase, - WCHAR* wszDatabaseStreamsS, - WCHAR** wszDatabaseStreamsD + HCCX phccxRestoreContext, + WCHAR* wszDatabaseDisplayName, + GUID guidDatabase, + WCHAR* wszDatabaseStreamsS, + WCHAR** wszDatabaseStreamsD ); typedef HRESULT (WINAPI *HrESERestoreOpenFile_t) ( - HCCX phccxRestoreContext, - WCHAR* wszFileName, - uint32_t cSections, - void* rghFile + HCCX phccxRestoreContext, + WCHAR* wszFileName, + uint32_t cSections, + void* rghFile ); bRC diff --git a/bacula/src/win32/filed/plugins/dbi_node.c b/bacula/src/win32/filed/plugins/dbi_node.c index 91ba09aa03..05f3efcdaf 100644 --- a/bacula/src/win32/filed/plugins/dbi_node.c +++ b/bacula/src/win32/filed/plugins/dbi_node.c @@ -33,260 +33,260 @@ dbi_node_t::dbi_node_t(char *name, node_t *parent_node) : node_t(name, NODE_TYPE_DATABASE_INFO, parent_node) { - restore_display_name = NULL; - restore_input_streams = NULL; - buffer = NULL; + restore_display_name = NULL; + restore_input_streams = NULL; + buffer = NULL; } dbi_node_t::~dbi_node_t() { - if (buffer != NULL) - delete buffer; - if (restore_input_streams != NULL) - delete restore_input_streams; - if (restore_display_name != NULL) - delete restore_display_name; + if (buffer != NULL) + delete buffer; + if (restore_input_streams != NULL) + delete restore_input_streams; + if (restore_display_name != NULL) + delete restore_display_name; } bRC dbi_node_t::startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp) { - time_t now = time(NULL); - - _DebugMessage(100, "startBackupNode_DBI state = %d\n", state); - - if (context->job_level == 'F') { - sp->fname = full_path; - sp->link = full_path; - sp->statp.st_mode = 0700 | S_IFREG; - sp->statp.st_ctime = now; - sp->statp.st_mtime = now; - sp->statp.st_atime = now; - sp->statp.st_size = (uint64_t)-1; - sp->type = FT_REG; - return bRC_OK; - } - else - { - bfuncs->setBaculaValue(context->bpContext, bVarFileSeen, (void *)full_path); - return bRC_Seen; - } + time_t now = time(NULL); + + _DebugMessage(100, "startBackupNode_DBI state = %d\n", state); + + if (context->job_level == 'F') { + sp->fname = full_path; + sp->link = full_path; + sp->statp.st_mode = 0700 | S_IFREG; + sp->statp.st_ctime = now; + sp->statp.st_mtime = now; + sp->statp.st_atime = now; + sp->statp.st_size = (uint64_t)-1; + sp->type = FT_REG; + return bRC_OK; + } + else + { + bfuncs->setBaculaValue(context->bpContext, bVarFileSeen, (void *)full_path); + return bRC_Seen; + } } bRC dbi_node_t::endBackupFile(exchange_fd_context_t *context) { - _DebugMessage(100, "endBackupNode_DBI state = %d\n", state); + _DebugMessage(100, "endBackupNode_DBI state = %d\n", state); - context->current_node = parent; + context->current_node = parent; - return bRC_OK; + return bRC_OK; } bRC dbi_node_t::createFile(exchange_fd_context_t *context, struct restore_pkt *rp) { - _DebugMessage(0, "createFile_DBI state = %d\n", state); + _DebugMessage(0, "createFile_DBI state = %d\n", state); - rp->create_status = CF_EXTRACT; + rp->create_status = CF_EXTRACT; - return bRC_OK; + return bRC_OK; } bRC dbi_node_t::endRestoreFile(exchange_fd_context_t *context) { - _DebugMessage(0, "endRestoreFile_DBI state = %d\n", state); + _DebugMessage(0, "endRestoreFile_DBI state = %d\n", state); - context->current_node = parent; + context->current_node = parent; - return bRC_OK; + return bRC_OK; } bRC dbi_node_t::pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io) { - uint32_t len; - WCHAR *ptr; - WCHAR *stream; - //char tmp[512]; - - buffer_pos = 0; - buffer_size = 65536; - buffer = new char[buffer_size]; - - if (context->job_type == JOB_TYPE_BACKUP) - { - ptr = (WCHAR *)buffer; - len = snwprintf(ptr, (buffer_size - buffer_pos) / 2, L"DatabaseBackupInfo\n"); - if (len < 0) - goto fail; - buffer_pos += len * 2; - ptr += len; - - len = snwprintf(ptr, (buffer_size - buffer_pos) / 2, L"%d\n", EXCHANGE_PLUGIN_VERSION); - if (len < 0) - goto fail; - buffer_pos += len * 2; - ptr += len; - - len = snwprintf(ptr, (buffer_size - buffer_pos) / 2, L"%s\n", dbi->wszDatabaseDisplayName); - if (len < 0) - goto fail; - buffer_pos += len * 2; - ptr += len; - - len = snwprintf(ptr, (buffer_size - buffer_pos) / 2, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", - dbi->rguidDatabase.Data1, dbi->rguidDatabase.Data2, dbi->rguidDatabase.Data3, - dbi->rguidDatabase.Data4[0], dbi->rguidDatabase.Data4[1], - dbi->rguidDatabase.Data4[2], dbi->rguidDatabase.Data4[3], - dbi->rguidDatabase.Data4[4], dbi->rguidDatabase.Data4[5], - dbi->rguidDatabase.Data4[6], dbi->rguidDatabase.Data4[7]); - if (len < 0) - goto fail; - buffer_pos += len * 2; - ptr += len; - - stream = dbi->wszDatabaseStreams; - while (*stream) - { - len = snwprintf(ptr, (buffer_size - buffer_pos) / 2, L"%s\n", stream); - if (len < 0) - goto fail; - buffer_pos += len * 2; - ptr += len; - stream += wcslen(stream) + 1; - } - - buffer_size = buffer_pos; - buffer_pos = 0; - } - - io->status = 0; - io->io_errno = 0; - return bRC_OK; + uint32_t len; + WCHAR *ptr; + WCHAR *stream; + //char tmp[512]; + + buffer_pos = 0; + buffer_size = 65536; + buffer = new char[buffer_size]; + + if (context->job_type == JOB_TYPE_BACKUP) + { + ptr = (WCHAR *)buffer; + len = snwprintf(ptr, (buffer_size - buffer_pos) / 2, L"DatabaseBackupInfo\n"); + if (len < 0) + goto fail; + buffer_pos += len * 2; + ptr += len; + + len = snwprintf(ptr, (buffer_size - buffer_pos) / 2, L"%d\n", EXCHANGE_PLUGIN_VERSION); + if (len < 0) + goto fail; + buffer_pos += len * 2; + ptr += len; + + len = snwprintf(ptr, (buffer_size - buffer_pos) / 2, L"%s\n", dbi->wszDatabaseDisplayName); + if (len < 0) + goto fail; + buffer_pos += len * 2; + ptr += len; + + len = snwprintf(ptr, (buffer_size - buffer_pos) / 2, L"%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", + dbi->rguidDatabase.Data1, dbi->rguidDatabase.Data2, dbi->rguidDatabase.Data3, + dbi->rguidDatabase.Data4[0], dbi->rguidDatabase.Data4[1], + dbi->rguidDatabase.Data4[2], dbi->rguidDatabase.Data4[3], + dbi->rguidDatabase.Data4[4], dbi->rguidDatabase.Data4[5], + dbi->rguidDatabase.Data4[6], dbi->rguidDatabase.Data4[7]); + if (len < 0) + goto fail; + buffer_pos += len * 2; + ptr += len; + + stream = dbi->wszDatabaseStreams; + while (*stream) + { + len = snwprintf(ptr, (buffer_size - buffer_pos) / 2, L"%s\n", stream); + if (len < 0) + goto fail; + buffer_pos += len * 2; + ptr += len; + stream += wcslen(stream) + 1; + } + + buffer_size = buffer_pos; + buffer_pos = 0; + } + + io->status = 0; + io->io_errno = 0; + return bRC_OK; fail: - io->status = 0; - io->io_errno = 1; - return bRC_Error; + io->status = 0; + io->io_errno = 1; + return bRC_Error; } bRC dbi_node_t::pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io) { - io->status = 0; - io->io_errno = 0; + io->status = 0; + io->io_errno = 0; - io->status = MIN(io->count, (int)(buffer_size - buffer_pos)); - if (io->status == 0) - return bRC_OK; - memcpy(io->buf, buffer + buffer_pos, io->status); - buffer_pos += io->status; + io->status = MIN(io->count, (int)(buffer_size - buffer_pos)); + if (io->status == 0) + return bRC_OK; + memcpy(io->buf, buffer + buffer_pos, io->status); + buffer_pos += io->status; - return bRC_OK; + return bRC_OK; } bRC dbi_node_t::pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io) { - memcpy(&buffer[buffer_pos], io->buf, io->count); - buffer_pos += io->count; - io->status = io->count; - io->io_errno = 0; - return bRC_OK; + memcpy(&buffer[buffer_pos], io->buf, io->count); + buffer_pos += io->count; + io->status = io->count; + io->io_errno = 0; + return bRC_OK; } bRC dbi_node_t::pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io) { - WCHAR tmp[128]; - WCHAR *ptr; - WCHAR eol; - int wchars_read; - int version; - int stream_buf_count; - WCHAR *streams_start; - - if (context->job_type == JOB_TYPE_RESTORE) - { - // need to think about making this buffer overflow proof... - _DebugMessage(100, "analyzing DatabaseBackupInfo\n"); - ptr = (WCHAR *)buffer; - - if (swscanf(ptr, L"%127[^\n]%c%n", tmp, &eol, &wchars_read) != 2) - goto restore_fail; - ptr += wchars_read; - _DebugMessage(150, "Header = %S\n", tmp); - // verify that header == "DatabaseBackupInfo" - - if (swscanf(ptr, L"%127[^\n]%c%n", tmp, &eol, &wchars_read) != 2) - goto restore_fail; - if (swscanf(tmp, L"%d%c", &version, &eol) != 1) - { - version = 0; - _DebugMessage(150, "Version = 0 (inferred)\n"); - } - else - { - ptr += wchars_read; - _DebugMessage(150, "Version = %d\n", version); - if (swscanf(ptr, L"%127[^\n]%c%n", tmp, &eol, &wchars_read) != 2) - goto restore_fail; - } - restore_display_name = new WCHAR[wchars_read]; - swscanf(ptr, L"%127[^\n]", restore_display_name); - _DebugMessage(150, "Database Display Name = %S\n", restore_display_name); - ptr += wchars_read; - - if (swscanf(ptr, L"%127[^\n]%c%n", tmp, &eol, &wchars_read) != 2) - goto restore_fail; - - if (swscanf(ptr, L"%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x", - &restore_guid.Data1, &restore_guid.Data2, &restore_guid.Data3, - &restore_guid.Data4[0], &restore_guid.Data4[1], - &restore_guid.Data4[2], &restore_guid.Data4[3], - &restore_guid.Data4[4], &restore_guid.Data4[5], - &restore_guid.Data4[6], &restore_guid.Data4[7]) != 11) - { - goto restore_fail; - } - _DebugMessage(150, "GUID = %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", - restore_guid.Data1, restore_guid.Data2, restore_guid.Data3, - restore_guid.Data4[0], restore_guid.Data4[1], - restore_guid.Data4[2], restore_guid.Data4[3], - restore_guid.Data4[4], restore_guid.Data4[5], - restore_guid.Data4[6], restore_guid.Data4[7]); - - ptr += wchars_read; - - stream_buf_count = 1; - streams_start = ptr; - while (ptr < (WCHAR *)(buffer + buffer_pos) && swscanf(ptr, L"%127[^\n]%c%n", tmp, &eol, &wchars_read) == 2) - { - _DebugMessage(150, "File = %S\n", tmp); - ptr += wchars_read; - stream_buf_count += wchars_read; - } - restore_input_streams = new WCHAR[stream_buf_count]; - ptr = streams_start; - stream_buf_count = 0; - while (ptr < (WCHAR *)(buffer + buffer_pos) && swscanf(ptr, L"%127[^\n]%c%n", tmp, &eol, &wchars_read) == 2) - { - snwprintf(&restore_input_streams[stream_buf_count], 65535, L"%s", tmp); - ptr += wchars_read; - stream_buf_count += wchars_read; - } - restore_input_streams[stream_buf_count] = 0; - - _DebugMessage(100, "done analyzing DatabasePluginInfo\n"); - } - delete buffer; - buffer = NULL; - return bRC_OK; + WCHAR tmp[128]; + WCHAR *ptr; + WCHAR eol; + int wchars_read; + int version; + int stream_buf_count; + WCHAR *streams_start; + + if (context->job_type == JOB_TYPE_RESTORE) + { + // need to think about making this buffer overflow proof... + _DebugMessage(100, "analyzing DatabaseBackupInfo\n"); + ptr = (WCHAR *)buffer; + + if (swscanf(ptr, L"%127[^\n]%c%n", tmp, &eol, &wchars_read) != 2) + goto restore_fail; + ptr += wchars_read; + _DebugMessage(150, "Header = %S\n", tmp); + // verify that header == "DatabaseBackupInfo" + + if (swscanf(ptr, L"%127[^\n]%c%n", tmp, &eol, &wchars_read) != 2) + goto restore_fail; + if (swscanf(tmp, L"%d%c", &version, &eol) != 1) + { + version = 0; + _DebugMessage(150, "Version = 0 (inferred)\n"); + } + else + { + ptr += wchars_read; + _DebugMessage(150, "Version = %d\n", version); + if (swscanf(ptr, L"%127[^\n]%c%n", tmp, &eol, &wchars_read) != 2) + goto restore_fail; + } + restore_display_name = new WCHAR[wchars_read]; + swscanf(ptr, L"%127[^\n]", restore_display_name); + _DebugMessage(150, "Database Display Name = %S\n", restore_display_name); + ptr += wchars_read; + + if (swscanf(ptr, L"%127[^\n]%c%n", tmp, &eol, &wchars_read) != 2) + goto restore_fail; + + if (swscanf(ptr, L"%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x", + &restore_guid.Data1, &restore_guid.Data2, &restore_guid.Data3, + &restore_guid.Data4[0], &restore_guid.Data4[1], + &restore_guid.Data4[2], &restore_guid.Data4[3], + &restore_guid.Data4[4], &restore_guid.Data4[5], + &restore_guid.Data4[6], &restore_guid.Data4[7]) != 11) + { + goto restore_fail; + } + _DebugMessage(150, "GUID = %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n", + restore_guid.Data1, restore_guid.Data2, restore_guid.Data3, + restore_guid.Data4[0], restore_guid.Data4[1], + restore_guid.Data4[2], restore_guid.Data4[3], + restore_guid.Data4[4], restore_guid.Data4[5], + restore_guid.Data4[6], restore_guid.Data4[7]); + + ptr += wchars_read; + + stream_buf_count = 1; + streams_start = ptr; + while (ptr < (WCHAR *)(buffer + buffer_pos) && swscanf(ptr, L"%127[^\n]%c%n", tmp, &eol, &wchars_read) == 2) + { + _DebugMessage(150, "File = %S\n", tmp); + ptr += wchars_read; + stream_buf_count += wchars_read; + } + restore_input_streams = new WCHAR[stream_buf_count]; + ptr = streams_start; + stream_buf_count = 0; + while (ptr < (WCHAR *)(buffer + buffer_pos) && swscanf(ptr, L"%127[^\n]%c%n", tmp, &eol, &wchars_read) == 2) + { + snwprintf(&restore_input_streams[stream_buf_count], 65535, L"%s", tmp); + ptr += wchars_read; + stream_buf_count += wchars_read; + } + restore_input_streams[stream_buf_count] = 0; + + _DebugMessage(100, "done analyzing DatabasePluginInfo\n"); + } + delete buffer; + buffer = NULL; + return bRC_OK; restore_fail: - _JobMessage(M_ERROR, "Format of %s is incorrect", full_path); - delete buffer; - buffer = NULL; - return bRC_Error; + _JobMessage(M_ERROR, "Format of %s is incorrect", full_path); + delete buffer; + buffer = NULL; + return bRC_Error; } diff --git a/bacula/src/win32/filed/plugins/exchange-fd.c b/bacula/src/win32/filed/plugins/exchange-fd.c index 897c759423..3d45903b0e 100644 --- a/bacula/src/win32/filed/plugins/exchange-fd.c +++ b/bacula/src/win32/filed/plugins/exchange-fd.c @@ -37,7 +37,7 @@ bInfo *binfo = NULL; #define PLUGIN_LICENSE "Bacula GPLv2" #define PLUGIN_AUTHOR "James Harper" -#define PLUGIN_DATE "September 2008" +#define PLUGIN_DATE "September 2008" #define PLUGIN_VERSION "1" #define PLUGIN_DESCRIPTION "Exchange Plugin" @@ -71,8 +71,8 @@ static pFuncs pluginFuncs = { FD_PLUGIN_INTERFACE_VERSION, /* Entry points into plugin */ - newPlugin, /* new plugin instance */ - freePlugin, /* free plugin instance */ + newPlugin, /* new plugin instance */ + freePlugin, /* free plugin instance */ getPluginValue, setPluginValue, handlePluginEvent, @@ -120,24 +120,24 @@ splitString(char *string, char split, int maxParts, int *count) bRC DLL_IMP_EXP loadPlugin(bInfo *lbinfo, bFuncs *lbfuncs, pInfo **pinfo, pFuncs **pfuncs) { - bRC retval; - bfuncs = lbfuncs; /* set Bacula funct pointers */ - binfo = lbinfo; - *pinfo = &pluginInfo; - *pfuncs = &pluginFuncs; - retval = loadExchangeApi(); - if (retval != bRC_OK) - { - printf("Cannot load Exchange DLL\n"); - return retval; - } - return retval; + bRC retval; + bfuncs = lbfuncs; /* set Bacula funct pointers */ + binfo = lbinfo; + *pinfo = &pluginInfo; + *pfuncs = &pluginFuncs; + retval = loadExchangeApi(); + if (retval != bRC_OK) + { + printf("Cannot load Exchange DLL\n"); + return retval; + } + return retval; } bRC DLL_IMP_EXP unloadPlugin() { - return bRC_OK; + return bRC_OK; } } @@ -145,182 +145,182 @@ unloadPlugin() void * b_malloc(const char *file, int lone, size_t size) { - return NULL; + return NULL; } void * sm_malloc(const char *file, int lone, size_t size) { - return NULL; + return NULL; } */ static bRC newPlugin(bpContext *ctx) { - exchange_fd_context_t *context; - bRC retval = bRC_OK; - DWORD size; - - int JobId = 0; - ctx->pContext = new exchange_fd_context_t; - context = (exchange_fd_context_t *)ctx->pContext; - context->bpContext = ctx; - context->job_since = 0; - context->notrunconfull_option = false; - bfuncs->getBaculaValue(ctx, bVarJobId, (void *)&JobId); - _DebugMessage(0, "newPlugin JobId=%d\n", JobId); - bfuncs->registerBaculaEvents(ctx, 1, 2, 0); - size = MAX_COMPUTERNAME_LENGTH + 1; - context->computer_name = new WCHAR[size]; - GetComputerNameW(context->computer_name, &size); - context->current_node = NULL; - context->root_node = NULL; - return retval; + exchange_fd_context_t *context; + bRC retval = bRC_OK; + DWORD size; + + int JobId = 0; + ctx->pContext = new exchange_fd_context_t; + context = (exchange_fd_context_t *)ctx->pContext; + context->bpContext = ctx; + context->job_since = 0; + context->notrunconfull_option = false; + bfuncs->getBaculaValue(ctx, bVarJobId, (void *)&JobId); + _DebugMessage(0, "newPlugin JobId=%d\n", JobId); + bfuncs->registerBaculaEvents(ctx, 1, 2, 0); + size = MAX_COMPUTERNAME_LENGTH + 1; + context->computer_name = new WCHAR[size]; + GetComputerNameW(context->computer_name, &size); + context->current_node = NULL; + context->root_node = NULL; + return retval; } static bRC freePlugin(bpContext *ctx) { - exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; - int JobId = 0; - bfuncs->getBaculaValue(ctx, bVarJobId, (void *)&JobId); - _DebugMessage(100, "freePlugin JobId=%d\n", JobId); - delete context; - return bRC_OK; + exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; + int JobId = 0; + bfuncs->getBaculaValue(ctx, bVarJobId, (void *)&JobId); + _DebugMessage(100, "freePlugin JobId=%d\n", JobId); + delete context; + return bRC_OK; } static bRC getPluginValue(bpContext *ctx, pVariable var, void *value) { - exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; - _DebugMessage(100, "getPluginValue var=%d\n", var); - return bRC_OK; + exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; + _DebugMessage(100, "getPluginValue var=%d\n", var); + return bRC_OK; } static bRC setPluginValue(bpContext *ctx, pVariable var, void *value) { - exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; - _DebugMessage(100, "setPluginValue var=%d\n", var); - return bRC_OK; + exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; + _DebugMessage(100, "setPluginValue var=%d\n", var); + return bRC_OK; } static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) { - exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; - char *name; - int i, intval; - int accurate; - - switch (event->eventType) { - case bEventJobStart: - _DebugMessage(0, "JobStart=%s\n", (char *)value); - break; - case bEventJobEnd: - _DebugMessage(0, "JobEnd\n"); - break; - case bEventStartBackupJob: - _DebugMessage(0, "BackupStart\n"); - bfuncs->getBaculaValue(ctx, bVarAccurate, (void *)&accurate); - context->accurate = accurate; - context->job_type = JOB_TYPE_BACKUP; - // level should have been specified by now - check it - // if level is D or I, since should have been specified too - switch (context->job_level) - { - case 'F': - if (context->notrunconfull_option) { - context->truncate_logs = false; - } else { - context->truncate_logs = true; - } - break; - case 'D': - context->truncate_logs = false; - break; - case 'I': - context->truncate_logs = false; - break; - default: - _DebugMessage(0, "Invalid job level %c\n", context->job_level); - return bRC_Error; - } - break; - case bEventEndBackupJob: - _DebugMessage(0, "BackupEnd\n"); - break; - case bEventLevel: - intval = (intptr_t)value; - _DebugMessage(0, "JobLevel=%c %d\n", intval, intval); - context->job_level = intval; - break; - case bEventSince: - intval = (intptr_t)value; - _DebugMessage(0, "since=%d\n", intval); - context->job_since = (time_t)value; - break; - case bEventStartRestoreJob: - _DebugMessage(0, "StartRestoreJob\n"); - context->job_type = JOB_TYPE_RESTORE; - break; - case bEventEndRestoreJob: - _DebugMessage(0, "EndRestoreJob\n"); - break; - - /* Plugin command e.g. plugin = ::command */ - case bEventRestoreCommand: - _DebugMessage(0, "restore\n"); // command=%s\n", (char *)value); - break; - - case bEventBackupCommand: - { - _DebugMessage(0, "backup command=%s\n", (char *)value); - char *command = new char[strlen((char *)value)]; - strcpy(command, (char *)value); - char *plugin_name = strtok((char *)command, ":"); - char *path = strtok(NULL, ":"); - char *option; - while ((option = strtok(NULL, ":")) != NULL) - { - _DebugMessage(100, "option %s\n", option); - if (stricmp(option, "notrunconfull") == 0) - { - context->notrunconfull_option = true; - } - else - { - _JobMessage(M_WARNING, "Unknown plugin option '%s'\n", option); - } - } - _DebugMessage(0, "name = %s\n", plugin_name); - _DebugMessage(0, "path = %s\n", path); - if (*path != '/') - { - _JobMessage(M_ERROR, "Path does not begin with a '/'\n"); - return bRC_Error; - } - - for (i = 0; i < 6; i++) - context->path_bits[i] = NULL; - - char *path_bit = strtok(path, "/"); - for (i = 0; path_bit != NULL && i < 6; i++) - { - context->path_bits[i] = new char[strlen(path_bit) + 1]; - strcpy(context->path_bits[i], path_bit); - path_bit = strtok(NULL, "/"); - } - - if (i < 2 || i > 4) - { - _JobMessage(M_ERROR, "Invalid plugin backup path\n"); - return bRC_Error; - } - context->root_node = new root_node_t(context->path_bits[0]); - context->current_node = context->root_node; - - } - break; + exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; + char *name; + int i, intval; + int accurate; + + switch (event->eventType) { + case bEventJobStart: + _DebugMessage(0, "JobStart=%s\n", (char *)value); + break; + case bEventJobEnd: + _DebugMessage(0, "JobEnd\n"); + break; + case bEventStartBackupJob: + _DebugMessage(0, "BackupStart\n"); + bfuncs->getBaculaValue(ctx, bVarAccurate, (void *)&accurate); + context->accurate = accurate; + context->job_type = JOB_TYPE_BACKUP; + // level should have been specified by now - check it + // if level is D or I, since should have been specified too + switch (context->job_level) + { + case 'F': + if (context->notrunconfull_option) { + context->truncate_logs = false; + } else { + context->truncate_logs = true; + } + break; + case 'D': + context->truncate_logs = false; + break; + case 'I': + context->truncate_logs = false; + break; + default: + _DebugMessage(0, "Invalid job level %c\n", context->job_level); + return bRC_Error; + } + break; + case bEventEndBackupJob: + _DebugMessage(0, "BackupEnd\n"); + break; + case bEventLevel: + intval = (intptr_t)value; + _DebugMessage(0, "JobLevel=%c %d\n", intval, intval); + context->job_level = intval; + break; + case bEventSince: + intval = (intptr_t)value; + _DebugMessage(0, "since=%d\n", intval); + context->job_since = (time_t)value; + break; + case bEventStartRestoreJob: + _DebugMessage(0, "StartRestoreJob\n"); + context->job_type = JOB_TYPE_RESTORE; + break; + case bEventEndRestoreJob: + _DebugMessage(0, "EndRestoreJob\n"); + break; + + /* Plugin command e.g. plugin = ::command */ + case bEventRestoreCommand: + _DebugMessage(0, "restore\n"); // command=%s\n", (char *)value); + break; + + case bEventBackupCommand: + { + _DebugMessage(0, "backup command=%s\n", (char *)value); + char *command = new char[strlen((char *)value)]; + strcpy(command, (char *)value); + char *plugin_name = strtok((char *)command, ":"); + char *path = strtok(NULL, ":"); + char *option; + while ((option = strtok(NULL, ":")) != NULL) + { + _DebugMessage(100, "option %s\n", option); + if (stricmp(option, "notrunconfull") == 0) + { + context->notrunconfull_option = true; + } + else + { + _JobMessage(M_WARNING, "Unknown plugin option '%s'\n", option); + } + } + _DebugMessage(0, "name = %s\n", plugin_name); + _DebugMessage(0, "path = %s\n", path); + if (*path != '/') + { + _JobMessage(M_ERROR, "Path does not begin with a '/'\n"); + return bRC_Error; + } + + for (i = 0; i < 6; i++) + context->path_bits[i] = NULL; + + char *path_bit = strtok(path, "/"); + for (i = 0; path_bit != NULL && i < 6; i++) + { + context->path_bits[i] = new char[strlen(path_bit) + 1]; + strcpy(context->path_bits[i], path_bit); + path_bit = strtok(NULL, "/"); + } + + if (i < 2 || i > 4) + { + _JobMessage(M_ERROR, "Invalid plugin backup path\n"); + return bRC_Error; + } + context->root_node = new root_node_t(context->path_bits[0]); + context->current_node = context->root_node; + + } + break; default: - _JobMessage(M_ERROR, "unknown event=%d\n", event->eventType); + _JobMessage(M_ERROR, "unknown event=%d\n", event->eventType); } bfuncs->getBaculaValue(ctx, bVarFDName, (void *)&name); return bRC_OK; @@ -329,43 +329,43 @@ static bRC handlePluginEvent(bpContext *ctx, bEvent *event, void *value) static bRC startBackupFile(bpContext *ctx, struct save_pkt *sp) { - bRC retval; - exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; - node_t *current_node; - - _DebugMessage(100, "startBackupFile, cmd = %s\n", sp->cmd); - if (sp->pkt_size != sizeof(struct save_pkt) || sp->pkt_end != sizeof(struct save_pkt)) - { - _JobMessage(M_FATAL, "save_pkt size mismatch - sizeof(struct save_pkt) = %d, pkt_size = %d, pkt_end = %d\n", sizeof(struct save_pkt), sp->pkt_size, sp->pkt_end); - return bRC_Error; - } - - //context->root_node = new root_node_t(PLUGIN_PATH_PREFIX_BASE); - //context->current_node = context->root_node; - do { - current_node = context->current_node; - retval = current_node->startBackupFile(context, sp); - if (retval == bRC_Seen) - endBackupFile(ctx); - } while (current_node != context->current_node); - _DebugMessage(100, "startBackupFile done - type = %d, fname = %s, retval = %d\n", sp->type, sp->fname, retval); - return retval; + bRC retval; + exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; + node_t *current_node; + + _DebugMessage(100, "startBackupFile, cmd = %s\n", sp->cmd); + if (sp->pkt_size != sizeof(struct save_pkt) || sp->pkt_end != sizeof(struct save_pkt)) + { + _JobMessage(M_FATAL, "save_pkt size mismatch - sizeof(struct save_pkt) = %d, pkt_size = %d, pkt_end = %d\n", sizeof(struct save_pkt), sp->pkt_size, sp->pkt_end); + return bRC_Error; + } + + //context->root_node = new root_node_t(PLUGIN_PATH_PREFIX_BASE); + //context->current_node = context->root_node; + do { + current_node = context->current_node; + retval = current_node->startBackupFile(context, sp); + if (retval == bRC_Seen) + endBackupFile(ctx); + } while (current_node != context->current_node); + _DebugMessage(100, "startBackupFile done - type = %d, fname = %s, retval = %d\n", sp->type, sp->fname, retval); + return retval; } static bRC endBackupFile(bpContext *ctx) { - bRC retval; - exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; - node_t *current_node; - - _DebugMessage(100, "endBackupFile\n"); - - do { - current_node = context->current_node; - retval = current_node->endBackupFile(context); - } while (current_node != context->current_node); - _DebugMessage(100, "endBackupFile done - retval = %d\n", retval); - return retval; + bRC retval; + exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; + node_t *current_node; + + _DebugMessage(100, "endBackupFile\n"); + + do { + current_node = context->current_node; + retval = current_node->endBackupFile(context); + } while (current_node != context->current_node); + _DebugMessage(100, "endBackupFile done - retval = %d\n", retval); + return retval; } /* @@ -373,107 +373,107 @@ static bRC endBackupFile(bpContext *ctx) */ static bRC pluginIO(bpContext *ctx, struct io_pkt *io) { - bRC retval = bRC_OK; - exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; - - if (io->pkt_size != sizeof(struct io_pkt) || io->pkt_end != sizeof(struct io_pkt)) - { - _JobMessage(M_ERROR, "io_pkt size mismatch - sizeof(struct io_pkt) = %d, pkt_size = %d, pkt_end = %d\n", sizeof(struct io_pkt), io->pkt_size, io->pkt_end); - } - - switch(io->func) { - case IO_OPEN: - _DebugMessage(100, "IO_OPEN\n"); - retval = context->current_node->pluginIoOpen(context, io); - break; - case IO_READ: - //_DebugMessage(100, "IO_READ buf=%p len=%d\n", io->buf, io->count); - retval = context->current_node->pluginIoRead(context, io); - break; - case IO_WRITE: - //_DebugMessage(100, "IO_WRITE buf=%p len=%d\n", io->buf, io->count); - retval = context->current_node->pluginIoWrite(context, io); - break; - case IO_CLOSE: - _DebugMessage(100, "IO_CLOSE\n"); - retval = context->current_node->pluginIoClose(context, io); - break; - } - return retval; + bRC retval = bRC_OK; + exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; + + if (io->pkt_size != sizeof(struct io_pkt) || io->pkt_end != sizeof(struct io_pkt)) + { + _JobMessage(M_ERROR, "io_pkt size mismatch - sizeof(struct io_pkt) = %d, pkt_size = %d, pkt_end = %d\n", sizeof(struct io_pkt), io->pkt_size, io->pkt_end); + } + + switch(io->func) { + case IO_OPEN: + _DebugMessage(100, "IO_OPEN\n"); + retval = context->current_node->pluginIoOpen(context, io); + break; + case IO_READ: + //_DebugMessage(100, "IO_READ buf=%p len=%d\n", io->buf, io->count); + retval = context->current_node->pluginIoRead(context, io); + break; + case IO_WRITE: + //_DebugMessage(100, "IO_WRITE buf=%p len=%d\n", io->buf, io->count); + retval = context->current_node->pluginIoWrite(context, io); + break; + case IO_CLOSE: + _DebugMessage(100, "IO_CLOSE\n"); + retval = context->current_node->pluginIoClose(context, io); + break; + } + return retval; } static bRC startRestoreFile(bpContext *ctx, const char *cmd) { - exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; - _DebugMessage(100, "startRestoreFile\n"); + exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; + _DebugMessage(100, "startRestoreFile\n"); - return bRC_OK; + return bRC_OK; } static bRC endRestoreFile(bpContext *ctx) { - bRC retval; - exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; - node_t *current_node; - - _DebugMessage(100, "endRestoreFile\n"); - - do { - current_node = context->current_node; - retval = current_node->endRestoreFile(context); - } while (current_node != context->current_node); - _DebugMessage(100, "endRestoreFile done - retval = %d\n", retval); - return retval; + bRC retval; + exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; + node_t *current_node; + + _DebugMessage(100, "endRestoreFile\n"); + + do { + current_node = context->current_node; + retval = current_node->endRestoreFile(context); + } while (current_node != context->current_node); + _DebugMessage(100, "endRestoreFile done - retval = %d\n", retval); + return retval; } static bRC createFile(bpContext *ctx, struct restore_pkt *rp) { - bRC retval; - exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; - node_t *current_node; - char **path_bits; - int count; - int i; - - - _DebugMessage(100, "createFile - type = %d, ofname = %s\n", rp->type, rp->ofname); - if (rp->pkt_size != sizeof(struct restore_pkt) || rp->pkt_end != sizeof(struct restore_pkt)) - { - _JobMessage(M_ERROR, "restore_pkt size mismatch - sizeof(struct restore_pkt) = %d, pkt_size = %d, pkt_end = %d\n", sizeof(struct restore_pkt), rp->pkt_size, rp->pkt_end); - } - - for (i = 0; i < 6; i++) - { - context->path_bits[i] = NULL; - } - - path_bits = splitString((char *)rp->ofname, '/', 7, &count); - - _DebugMessage(100, "count = %d\n", count); - - for (i = 1; i < count; i++) - { - _DebugMessage(150, "%d = '%s'\n", i, path_bits[i]); - context->path_bits[i - 1] = path_bits[i]; - } - - if (context->current_node == NULL) - { - context->root_node = new root_node_t(context->path_bits[0]); - context->current_node = context->root_node; - } - - do { - current_node = context->current_node; - retval = current_node->createFile(context, rp); - } while (current_node != context->current_node); - _DebugMessage(100, "createFile done - retval = %d\n", retval); - return retval; + bRC retval; + exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; + node_t *current_node; + char **path_bits; + int count; + int i; + + + _DebugMessage(100, "createFile - type = %d, ofname = %s\n", rp->type, rp->ofname); + if (rp->pkt_size != sizeof(struct restore_pkt) || rp->pkt_end != sizeof(struct restore_pkt)) + { + _JobMessage(M_ERROR, "restore_pkt size mismatch - sizeof(struct restore_pkt) = %d, pkt_size = %d, pkt_end = %d\n", sizeof(struct restore_pkt), rp->pkt_size, rp->pkt_end); + } + + for (i = 0; i < 6; i++) + { + context->path_bits[i] = NULL; + } + + path_bits = splitString((char *)rp->ofname, '/', 7, &count); + + _DebugMessage(100, "count = %d\n", count); + + for (i = 1; i < count; i++) + { + _DebugMessage(150, "%d = '%s'\n", i, path_bits[i]); + context->path_bits[i - 1] = path_bits[i]; + } + + if (context->current_node == NULL) + { + context->root_node = new root_node_t(context->path_bits[0]); + context->current_node = context->root_node; + } + + do { + current_node = context->current_node; + retval = current_node->createFile(context, rp); + } while (current_node != context->current_node); + _DebugMessage(100, "createFile done - retval = %d\n", retval); + return retval; } static bRC setFileAttributes(bpContext *ctx, struct restore_pkt *rp) { - exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; - _DebugMessage(100, "setFileAttributes\n"); - return bRC_OK; + exchange_fd_context_t *context = (exchange_fd_context_t *)ctx->pContext; + _DebugMessage(100, "setFileAttributes\n"); + return bRC_OK; } diff --git a/bacula/src/win32/filed/plugins/exchange-fd.h b/bacula/src/win32/filed/plugins/exchange-fd.h index e1125b2355..d1b4be8dce 100644 --- a/bacula/src/win32/filed/plugins/exchange-fd.h +++ b/bacula/src/win32/filed/plugins/exchange-fd.h @@ -123,31 +123,31 @@ struct exchange_fd_context_t; #include "node.h" struct exchange_fd_context_t { - struct bpContext *bpContext; - WCHAR *computer_name; - char *path_bits[6]; - root_node_t *root_node; - node_t *current_node; - int job_type; - int job_level; - time_t job_since; - bool notrunconfull_option; - bool truncate_logs; - bool accurate; + struct bpContext *bpContext; + WCHAR *computer_name; + char *path_bits[6]; + root_node_t *root_node; + node_t *current_node; + int job_type; + int job_level; + time_t job_since; + bool notrunconfull_option; + bool truncate_logs; + bool accurate; }; static inline char *tocharstring(WCHAR *src) { - char *tmp = new char[wcslen(src) + 1]; - wcstombs(tmp, src, wcslen(src) + 1); - return tmp; + char *tmp = new char[wcslen(src) + 1]; + wcstombs(tmp, src, wcslen(src) + 1); + return tmp; } static inline WCHAR *towcharstring(char *src) { - WCHAR *tmp = new WCHAR[strlen(src) + 1]; - mbstowcs(tmp, src, strlen(src) + 1); - return tmp; + WCHAR *tmp = new WCHAR[strlen(src) + 1]; + mbstowcs(tmp, src, strlen(src) + 1); + return tmp; } diff --git a/bacula/src/win32/filed/plugins/file_node.c b/bacula/src/win32/filed/plugins/file_node.c index bd40036290..e382d8b12d 100644 --- a/bacula/src/win32/filed/plugins/file_node.c +++ b/bacula/src/win32/filed/plugins/file_node.c @@ -33,204 +33,204 @@ file_node_t::file_node_t(char *name, node_t *parent_node) : node_t(name, NODE_TYPE_FILE, parent_node) { - backup_file_handle = INVALID_HANDLE_VALUE; - restore_file_handle = INVALID_HANDLE_VALUE; - restore_at_file_level = FALSE; + backup_file_handle = INVALID_HANDLE_VALUE; + restore_file_handle = INVALID_HANDLE_VALUE; + restore_at_file_level = FALSE; } file_node_t::~file_node_t() { - if (backup_file_handle != INVALID_HANDLE_VALUE) - { - //_DebugMessage(100, "closing file handle in destructor\n"); - CloseHandle(backup_file_handle); - } - if (restore_file_handle != INVALID_HANDLE_VALUE) - { - //_DebugMessage(100, "closing file handle in destructor\n"); - if (restore_at_file_level) - { - CloseHandle(restore_file_handle); - } - else - { - // maybe one day - } - } + if (backup_file_handle != INVALID_HANDLE_VALUE) + { + //_DebugMessage(100, "closing file handle in destructor\n"); + CloseHandle(backup_file_handle); + } + if (restore_file_handle != INVALID_HANDLE_VALUE) + { + //_DebugMessage(100, "closing file handle in destructor\n"); + if (restore_at_file_level) + { + CloseHandle(restore_file_handle); + } + else + { + // maybe one day + } + } } bRC file_node_t::startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp) { - time_t now = time(NULL); - _DebugMessage(100, "startBackupNode_FILE state = %d\n", state); - - if (context->job_level == 'F' || parent->type == NODE_TYPE_STORAGE_GROUP) { - sp->fname = full_path; - sp->link = full_path; - _DebugMessage(100, "fname = %s\n", sp->fname); - sp->statp.st_mode = 0700 | S_IFREG; - sp->statp.st_ctime = now; - sp->statp.st_mtime = now; - sp->statp.st_atime = now; - sp->statp.st_size = (uint64_t)-1; - sp->type = FT_REG; - return bRC_OK; - } else { - bfuncs->setBaculaValue(context->bpContext, bVarFileSeen, (void *)full_path); - return bRC_Seen; - } + time_t now = time(NULL); + _DebugMessage(100, "startBackupNode_FILE state = %d\n", state); + + if (context->job_level == 'F' || parent->type == NODE_TYPE_STORAGE_GROUP) { + sp->fname = full_path; + sp->link = full_path; + _DebugMessage(100, "fname = %s\n", sp->fname); + sp->statp.st_mode = 0700 | S_IFREG; + sp->statp.st_ctime = now; + sp->statp.st_mtime = now; + sp->statp.st_atime = now; + sp->statp.st_size = (uint64_t)-1; + sp->type = FT_REG; + return bRC_OK; + } else { + bfuncs->setBaculaValue(context->bpContext, bVarFileSeen, (void *)full_path); + return bRC_Seen; + } } bRC file_node_t::endBackupFile(exchange_fd_context_t *context) { - _DebugMessage(100, "endBackupNode_FILE state = %d\n", state); + _DebugMessage(100, "endBackupNode_FILE state = %d\n", state); - context->current_node = parent; + context->current_node = parent; - return bRC_OK; + return bRC_OK; } bRC file_node_t::createFile(exchange_fd_context_t *context, struct restore_pkt *rp) { - //HrESERestoreOpenFile with name of log file + //HrESERestoreOpenFile with name of log file - _DebugMessage(0, "createFile_FILE state = %d\n", state); - rp->create_status = CF_EXTRACT; - return bRC_OK; + _DebugMessage(0, "createFile_FILE state = %d\n", state); + rp->create_status = CF_EXTRACT; + return bRC_OK; } bRC file_node_t::endRestoreFile(exchange_fd_context_t *context) { - _DebugMessage(0, "endRestoreFile_FILE state = %d\n", state); - context->current_node = parent; - return bRC_OK; + _DebugMessage(0, "endRestoreFile_FILE state = %d\n", state); + context->current_node = parent; + return bRC_OK; } bRC file_node_t::pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io) { - HRESULT result; - HANDLE handle; - char *tmp = new char[wcslen(filename) + 1]; - wcstombs(tmp, filename, wcslen(filename) + 1); - - _DebugMessage(0, "pluginIoOpen_FILE - filename = %s\n", tmp); - io->status = 0; - io->io_errno = 0; - if (context->job_type == JOB_TYPE_BACKUP) - { - _DebugMessage(10, "Calling HrESEBackupOpenFile\n"); - result = HrESEBackupOpenFile(hccx, filename, 65535, 1, &backup_file_handle, §ion_size); - if (result) - { - _JobMessage(M_ERROR, "HrESEBackupOpenFile failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - backup_file_handle = INVALID_HANDLE_VALUE; - io->io_errno = 1; - return bRC_Error; - } - } - else - { - _DebugMessage(10, "Calling HrESERestoreOpenFile for '%s'\n", tmp); - result = HrESERestoreOpenFile(hccx, filename, 1, &restore_file_handle); - if (result == hrRestoreAtFileLevel) - { - restore_at_file_level = true; - _DebugMessage(100, "Calling CreateFileW for '%s'\n", tmp); - handle = CreateFileW(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); - if (handle == INVALID_HANDLE_VALUE) - { - _JobMessage(M_ERROR, "CreateFile failed"); - return bRC_Error; - } - restore_file_handle = (void *)handle; - return bRC_OK; - } - else if (result == 0) - { - _JobMessage(M_ERROR, "Exchange File IO API not yet supported for restore\n"); - restore_at_file_level = false; - return bRC_Error; - } - else - { - _JobMessage(M_ERROR, "HrESERestoreOpenFile failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - return bRC_Error; - } - } - return bRC_OK; + HRESULT result; + HANDLE handle; + char *tmp = new char[wcslen(filename) + 1]; + wcstombs(tmp, filename, wcslen(filename) + 1); + + _DebugMessage(0, "pluginIoOpen_FILE - filename = %s\n", tmp); + io->status = 0; + io->io_errno = 0; + if (context->job_type == JOB_TYPE_BACKUP) + { + _DebugMessage(10, "Calling HrESEBackupOpenFile\n"); + result = HrESEBackupOpenFile(hccx, filename, 65535, 1, &backup_file_handle, §ion_size); + if (result) + { + _JobMessage(M_ERROR, "HrESEBackupOpenFile failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + backup_file_handle = INVALID_HANDLE_VALUE; + io->io_errno = 1; + return bRC_Error; + } + } + else + { + _DebugMessage(10, "Calling HrESERestoreOpenFile for '%s'\n", tmp); + result = HrESERestoreOpenFile(hccx, filename, 1, &restore_file_handle); + if (result == hrRestoreAtFileLevel) + { + restore_at_file_level = true; + _DebugMessage(100, "Calling CreateFileW for '%s'\n", tmp); + handle = CreateFileW(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (handle == INVALID_HANDLE_VALUE) + { + _JobMessage(M_ERROR, "CreateFile failed"); + return bRC_Error; + } + restore_file_handle = (void *)handle; + return bRC_OK; + } + else if (result == 0) + { + _JobMessage(M_ERROR, "Exchange File IO API not yet supported for restore\n"); + restore_at_file_level = false; + return bRC_Error; + } + else + { + _JobMessage(M_ERROR, "HrESERestoreOpenFile failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + return bRC_Error; + } + } + return bRC_OK; } bRC file_node_t::pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io) { - HRESULT result; - uint32_t readLength; - - io->status = 0; - io->io_errno = 0; - _DebugMessage(200, "Calling HrESEBackupReadFile\n"); - result = HrESEBackupReadFile(hccx, backup_file_handle, io->buf, io->count, &readLength); - if (result) - { - io->io_errno = 1; - return bRC_Error; - } - io->status = readLength; - size += readLength; - return bRC_OK; + HRESULT result; + uint32_t readLength; + + io->status = 0; + io->io_errno = 0; + _DebugMessage(200, "Calling HrESEBackupReadFile\n"); + result = HrESEBackupReadFile(hccx, backup_file_handle, io->buf, io->count, &readLength); + if (result) + { + io->io_errno = 1; + return bRC_Error; + } + io->status = readLength; + size += readLength; + return bRC_OK; } bRC file_node_t::pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io) { - DWORD bytes_written; - - io->io_errno = 0; - if (!restore_at_file_level) - return bRC_Error; - - if (!WriteFile(restore_file_handle, io->buf, io->count, &bytes_written, NULL)) - { - _JobMessage(M_ERROR, "Write Error"); - return bRC_Error; - } - - if (bytes_written != (DWORD)io->count) - { - _JobMessage(M_ERROR, "Short write"); - return bRC_Error; - } - io->status = bytes_written; - - return bRC_OK; + DWORD bytes_written; + + io->io_errno = 0; + if (!restore_at_file_level) + return bRC_Error; + + if (!WriteFile(restore_file_handle, io->buf, io->count, &bytes_written, NULL)) + { + _JobMessage(M_ERROR, "Write Error"); + return bRC_Error; + } + + if (bytes_written != (DWORD)io->count) + { + _JobMessage(M_ERROR, "Short write"); + return bRC_Error; + } + io->status = bytes_written; + + return bRC_OK; } bRC file_node_t::pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io) { - if (context->job_type == JOB_TYPE_BACKUP) - { - _DebugMessage(100, "Calling HrESEBackupCloseFile\n"); - HrESEBackupCloseFile(hccx, backup_file_handle); - backup_file_handle = INVALID_HANDLE_VALUE; - return bRC_OK; - } - else - { - if (restore_at_file_level) - { - CloseHandle(restore_file_handle); - restore_file_handle = INVALID_HANDLE_VALUE; - return bRC_OK; - } - else - { - return bRC_OK; - } - } + if (context->job_type == JOB_TYPE_BACKUP) + { + _DebugMessage(100, "Calling HrESEBackupCloseFile\n"); + HrESEBackupCloseFile(hccx, backup_file_handle); + backup_file_handle = INVALID_HANDLE_VALUE; + return bRC_OK; + } + else + { + if (restore_at_file_level) + { + CloseHandle(restore_file_handle); + restore_file_handle = INVALID_HANDLE_VALUE; + return bRC_OK; + } + else + { + return bRC_OK; + } + } } diff --git a/bacula/src/win32/filed/plugins/node.c b/bacula/src/win32/filed/plugins/node.c index eb52e01552..b9433f4986 100644 --- a/bacula/src/win32/filed/plugins/node.c +++ b/bacula/src/win32/filed/plugins/node.c @@ -33,95 +33,95 @@ node_t::node_t(char *name, int type) { - this->type = type; - state = 0; - parent = NULL; - this->name = bstrdup(name); - full_path = make_full_path(); - size = 0; - level = 0; + this->type = type; + state = 0; + parent = NULL; + this->name = bstrdup(name); + full_path = make_full_path(); + size = 0; + level = 0; } node_t::node_t(char *name, int type, node_t *parent_node) { - this->type = type; - state = 0; - parent = parent_node; - this->name = bstrdup(name); - full_path = make_full_path(); - size = 0; - level = parent->level + 1; + this->type = type; + state = 0; + parent = parent_node; + this->name = bstrdup(name); + full_path = make_full_path(); + size = 0; + level = parent->level + 1; } node_t::~node_t() { - delete name; - delete full_path; + delete name; + delete full_path; } char * node_t::make_full_path() { - node_t *curr_node; - int len; - char *retval; + node_t *curr_node; + int len; + char *retval; - for (len = 0, curr_node = this; curr_node != NULL; curr_node = curr_node->parent) - { - len += strlen(curr_node->name) + 1; - } - if (type == NODE_TYPE_FILE || type == NODE_TYPE_DATABASE_INFO) - { - retval = new char[len + 1]; - retval[len] = 0; - } - else - { - retval = new char[len + 2]; - retval[len] = '/'; - retval[len + 1] = 0; - } - for (curr_node = this; curr_node != NULL; curr_node = curr_node->parent) - { - len -= strlen(curr_node->name); - memcpy(retval + len, curr_node->name, strlen(curr_node->name)); - retval[--len] = '/'; - } - return retval; + for (len = 0, curr_node = this; curr_node != NULL; curr_node = curr_node->parent) + { + len += strlen(curr_node->name) + 1; + } + if (type == NODE_TYPE_FILE || type == NODE_TYPE_DATABASE_INFO) + { + retval = new char[len + 1]; + retval[len] = 0; + } + else + { + retval = new char[len + 2]; + retval[len] = '/'; + retval[len + 1] = 0; + } + for (curr_node = this; curr_node != NULL; curr_node = curr_node->parent) + { + len -= strlen(curr_node->name); + memcpy(retval + len, curr_node->name, strlen(curr_node->name)); + retval[--len] = '/'; + } + return retval; } bRC node_t::pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io) { - _DebugMessage(100, "pluginIoOpen_Node\n"); - io->status = 0; - io->io_errno = 0; - return bRC_OK; + _DebugMessage(100, "pluginIoOpen_Node\n"); + io->status = 0; + io->io_errno = 0; + return bRC_OK; } bRC node_t::pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io) { - _DebugMessage(100, "pluginIoRead_Node\n"); - io->status = 0; - io->io_errno = 0; - return bRC_OK; + _DebugMessage(100, "pluginIoRead_Node\n"); + io->status = 0; + io->io_errno = 0; + return bRC_OK; } bRC node_t::pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io) { - _DebugMessage(100, "pluginIoWrite_Node\n"); - io->status = 0; - io->io_errno = 1; - return bRC_Error; + _DebugMessage(100, "pluginIoWrite_Node\n"); + io->status = 0; + io->io_errno = 1; + return bRC_Error; } bRC node_t::pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io) { - _DebugMessage(100, "pluginIoClose_Node\n"); - io->status = 0; - io->io_errno = 0; - return bRC_OK; + _DebugMessage(100, "pluginIoClose_Node\n"); + io->status = 0; + io->io_errno = 0; + return bRC_OK; } diff --git a/bacula/src/win32/filed/plugins/node.h b/bacula/src/win32/filed/plugins/node.h index f17e2d1b7d..eb151b84ac 100644 --- a/bacula/src/win32/filed/plugins/node.h +++ b/bacula/src/win32/filed/plugins/node.h @@ -29,158 +29,158 @@ * Written by James Harper, October 2008 */ -#define NODE_TYPE_UNKNOWN 0 -#define NODE_TYPE_ROOT 1 -#define NODE_TYPE_SERVICE 2 -#define NODE_TYPE_STORAGE_GROUP 3 -#define NODE_TYPE_STORE 4 -#define NODE_TYPE_DATABASE_INFO 5 -#define NODE_TYPE_FILE 6 +#define NODE_TYPE_UNKNOWN 0 +#define NODE_TYPE_ROOT 1 +#define NODE_TYPE_SERVICE 2 +#define NODE_TYPE_STORAGE_GROUP 3 +#define NODE_TYPE_STORE 4 +#define NODE_TYPE_DATABASE_INFO 5 +#define NODE_TYPE_FILE 6 class node_t { public: - int type; - int state; - node_t *parent; - char *name; - char *full_path; - size_t size; - int level; - - node_t(char *name, int type); - node_t(char *name, int type, node_t *parent_node); - virtual ~node_t(); - - char *make_full_path(); - - virtual bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp) = 0; - virtual bRC endBackupFile(exchange_fd_context_t *context) = 0; - - virtual bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp) = 0; - virtual bRC endRestoreFile(exchange_fd_context_t *context) = 0; - - virtual bRC pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io); - virtual bRC pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io); - virtual bRC pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io); - virtual bRC pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io); + int type; + int state; + node_t *parent; + char *name; + char *full_path; + size_t size; + int level; + + node_t(char *name, int type); + node_t(char *name, int type, node_t *parent_node); + virtual ~node_t(); + + char *make_full_path(); + + virtual bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp) = 0; + virtual bRC endBackupFile(exchange_fd_context_t *context) = 0; + + virtual bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp) = 0; + virtual bRC endRestoreFile(exchange_fd_context_t *context) = 0; + + virtual bRC pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io); + virtual bRC pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io); + virtual bRC pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io); + virtual bRC pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io); }; class file_node_t : public node_t { public: - WCHAR *filename; - HCCX hccx; - VOID *backup_file_handle; - VOID *restore_file_handle; - uint64_t section_size; - bool restore_at_file_level; - - file_node_t(char *name, node_t *parent_node); - virtual ~file_node_t(); - bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp); - bRC endBackupFile(exchange_fd_context_t *context); - - bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp); - bRC endRestoreFile(exchange_fd_context_t *context); - - bRC pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io); - bRC pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io); - bRC pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io); - bRC pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io); + WCHAR *filename; + HCCX hccx; + VOID *backup_file_handle; + VOID *restore_file_handle; + uint64_t section_size; + bool restore_at_file_level; + + file_node_t(char *name, node_t *parent_node); + virtual ~file_node_t(); + bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp); + bRC endBackupFile(exchange_fd_context_t *context); + + bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp); + bRC endRestoreFile(exchange_fd_context_t *context); + + bRC pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io); + bRC pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io); + bRC pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io); + bRC pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io); }; class dbi_node_t : public node_t { public: - DATABASE_BACKUP_INFO *dbi; - char *buffer; - uint32_t buffer_size; - uint32_t buffer_pos; - WCHAR *restore_display_name; - GUID restore_guid; - WCHAR *restore_input_streams; - WCHAR *restore_output_streams; - - dbi_node_t(char *name, node_t *parent_node); - virtual ~dbi_node_t(); - bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp); - bRC endBackupFile(exchange_fd_context_t *context); - - bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp); - bRC endRestoreFile(exchange_fd_context_t *context); - - bRC pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io); - bRC pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io); - bRC pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io); - bRC pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io); + DATABASE_BACKUP_INFO *dbi; + char *buffer; + uint32_t buffer_size; + uint32_t buffer_pos; + WCHAR *restore_display_name; + GUID restore_guid; + WCHAR *restore_input_streams; + WCHAR *restore_output_streams; + + dbi_node_t(char *name, node_t *parent_node); + virtual ~dbi_node_t(); + bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp); + bRC endBackupFile(exchange_fd_context_t *context); + + bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp); + bRC endRestoreFile(exchange_fd_context_t *context); + + bRC pluginIoOpen(exchange_fd_context_t *context, struct io_pkt *io); + bRC pluginIoRead(exchange_fd_context_t *context, struct io_pkt *io); + bRC pluginIoWrite(exchange_fd_context_t *context, struct io_pkt *io); + bRC pluginIoClose(exchange_fd_context_t *context, struct io_pkt *io); }; class store_node_t : public node_t { public: - HCCX hccx; - DATABASE_BACKUP_INFO *dbi; - WCHAR *stream_ptr; - file_node_t *file_node; - dbi_node_t *dbi_node; - WCHAR *out_stream_ptr; - - store_node_t(char *name, node_t *parent_node); - virtual ~store_node_t(); - bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp); - bRC endBackupFile(exchange_fd_context_t *context); - - bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp); - bRC endRestoreFile(exchange_fd_context_t *context); + HCCX hccx; + DATABASE_BACKUP_INFO *dbi; + WCHAR *stream_ptr; + file_node_t *file_node; + dbi_node_t *dbi_node; + WCHAR *out_stream_ptr; + + store_node_t(char *name, node_t *parent_node); + virtual ~store_node_t(); + bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp); + bRC endBackupFile(exchange_fd_context_t *context); + + bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp); + bRC endRestoreFile(exchange_fd_context_t *context); }; class storage_group_node_t : public node_t { public: - HCCX hccx; - INSTANCE_BACKUP_INFO *ibi; - store_node_t *store_node; - file_node_t *file_node; - uint32_t current_dbi; - WCHAR *logfiles; - WCHAR *logfile_ptr; - RESTORE_ENVIRONMENT *restore_environment; - WCHAR *service_name; - WCHAR *storage_group_name; - WCHAR *saved_log_path; - storage_group_node_t *next; - - storage_group_node_t(char *name, node_t *parent_node); - virtual ~storage_group_node_t(); - bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp); - bRC endBackupFile(exchange_fd_context_t *context); - - bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp); - bRC endRestoreFile(exchange_fd_context_t *context); + HCCX hccx; + INSTANCE_BACKUP_INFO *ibi; + store_node_t *store_node; + file_node_t *file_node; + uint32_t current_dbi; + WCHAR *logfiles; + WCHAR *logfile_ptr; + RESTORE_ENVIRONMENT *restore_environment; + WCHAR *service_name; + WCHAR *storage_group_name; + WCHAR *saved_log_path; + storage_group_node_t *next; + + storage_group_node_t(char *name, node_t *parent_node); + virtual ~storage_group_node_t(); + bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp); + bRC endBackupFile(exchange_fd_context_t *context); + + bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp); + bRC endRestoreFile(exchange_fd_context_t *context); }; class service_node_t : public node_t { public: - uint32_t ibi_count; - INSTANCE_BACKUP_INFO *ibi; - HCCX hccx; - uint32_t current_ibi; - storage_group_node_t *first_storage_group_node; - - service_node_t(char *name, node_t *parent_node); - virtual ~service_node_t(); - bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp); - bRC endBackupFile(exchange_fd_context_t *context); - - bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp); - bRC endRestoreFile(exchange_fd_context_t *context); + uint32_t ibi_count; + INSTANCE_BACKUP_INFO *ibi; + HCCX hccx; + uint32_t current_ibi; + storage_group_node_t *first_storage_group_node; + + service_node_t(char *name, node_t *parent_node); + virtual ~service_node_t(); + bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp); + bRC endBackupFile(exchange_fd_context_t *context); + + bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp); + bRC endRestoreFile(exchange_fd_context_t *context); }; class root_node_t : public node_t { public: - service_node_t *service_node; + service_node_t *service_node; - root_node_t(char *name); - virtual ~root_node_t(); - bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp); - bRC endBackupFile(exchange_fd_context_t *context); + root_node_t(char *name); + virtual ~root_node_t(); + bRC startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp); + bRC endBackupFile(exchange_fd_context_t *context); - bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp); - bRC endRestoreFile(exchange_fd_context_t *context); + bRC createFile(exchange_fd_context_t *context, struct restore_pkt *rp); + bRC endRestoreFile(exchange_fd_context_t *context); }; diff --git a/bacula/src/win32/filed/plugins/root_node.c b/bacula/src/win32/filed/plugins/root_node.c index 26619fb212..60457f227a 100644 --- a/bacula/src/win32/filed/plugins/root_node.c +++ b/bacula/src/win32/filed/plugins/root_node.c @@ -33,7 +33,7 @@ root_node_t::root_node_t(char *name) : node_t(name, NODE_TYPE_ROOT) { - service_node = NULL; + service_node = NULL; } root_node_t::~root_node_t() @@ -43,115 +43,115 @@ root_node_t::~root_node_t() bRC root_node_t::startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp) { - bRC retval = bRC_OK; - time_t now; + bRC retval = bRC_OK; + time_t now; - _DebugMessage(100, "startBackupNode_ROOT state = %d\n", state); - switch(state) - { - case 0: - if (strcmp(PLUGIN_PATH_PREFIX_BASE, name) != 0) - { - _JobMessage(M_ERROR, "Invalid backup path specified, must start with '/" PLUGIN_PATH_PREFIX_BASE "/'\n"); - state = 999; - return bRC_Error; - } - // check that service_node == NULL - service_node = new service_node_t(bstrdup(context->path_bits[level + 1]), this); - state = 1; - // fall through - case 1: - context->current_node = service_node; - break; - case 2: - now = time(NULL); - sp->fname = full_path; - sp->link = full_path; - sp->statp.st_mode = 0700 | S_IFDIR; - sp->statp.st_ctime = now; - sp->statp.st_mtime = now; - sp->statp.st_atime = now; - sp->statp.st_size = 0; - sp->type = FT_DIREND; - break; - case 999: - return bRC_Error; - default: - _JobMessage(M_ERROR, "Invalid state %d", state); - state = 999; - } - return retval; + _DebugMessage(100, "startBackupNode_ROOT state = %d\n", state); + switch(state) + { + case 0: + if (strcmp(PLUGIN_PATH_PREFIX_BASE, name) != 0) + { + _JobMessage(M_ERROR, "Invalid backup path specified, must start with '/" PLUGIN_PATH_PREFIX_BASE "/'\n"); + state = 999; + return bRC_Error; + } + // check that service_node == NULL + service_node = new service_node_t(bstrdup(context->path_bits[level + 1]), this); + state = 1; + // fall through + case 1: + context->current_node = service_node; + break; + case 2: + now = time(NULL); + sp->fname = full_path; + sp->link = full_path; + sp->statp.st_mode = 0700 | S_IFDIR; + sp->statp.st_ctime = now; + sp->statp.st_mtime = now; + sp->statp.st_atime = now; + sp->statp.st_size = 0; + sp->type = FT_DIREND; + break; + case 999: + return bRC_Error; + default: + _JobMessage(M_ERROR, "Invalid state %d", state); + state = 999; + } + return retval; } bRC root_node_t::endBackupFile(exchange_fd_context_t *context) { - bRC retval = bRC_OK; + bRC retval = bRC_OK; - _DebugMessage(100, "endBackupNode_ROOT state = %d\n", state); - switch(state) - { - case 1: - state = 2; - retval = bRC_More; - // free service_node here? - break; - case 2: - retval = bRC_OK; - break; - case 999: - retval = bRC_Error; - default: - _JobMessage(M_ERROR, "Invalid state %d", state); - state = 999; - return bRC_Error; - } - return retval; + _DebugMessage(100, "endBackupNode_ROOT state = %d\n", state); + switch(state) + { + case 1: + state = 2; + retval = bRC_More; + // free service_node here? + break; + case 2: + retval = bRC_OK; + break; + case 999: + retval = bRC_Error; + default: + _JobMessage(M_ERROR, "Invalid state %d", state); + state = 999; + return bRC_Error; + } + return retval; } bRC root_node_t::createFile(exchange_fd_context_t *context, struct restore_pkt *rp) { - _DebugMessage(0, "createFile_ROOT state = %d\n", state); - switch (state) - { - case 0: - if (strcmp(name, PLUGIN_PATH_PREFIX_BASE) != 0) - { - _JobMessage(M_ERROR, "Invalid restore path specified, must start with '/" PLUGIN_PATH_PREFIX_BASE "/'\n"); - state = 999; - return bRC_Error; - } - service_node = new service_node_t(bstrdup(context->path_bits[level + 1]), this); - context->current_node = service_node; - return bRC_OK; - case 1: - rp->create_status = CF_CREATED; - return bRC_OK; - case 999: - return bRC_Error; - default: - _JobMessage(M_ERROR, "Invalid state %d", state); - state = 999; - } - return bRC_Error; + _DebugMessage(0, "createFile_ROOT state = %d\n", state); + switch (state) + { + case 0: + if (strcmp(name, PLUGIN_PATH_PREFIX_BASE) != 0) + { + _JobMessage(M_ERROR, "Invalid restore path specified, must start with '/" PLUGIN_PATH_PREFIX_BASE "/'\n"); + state = 999; + return bRC_Error; + } + service_node = new service_node_t(bstrdup(context->path_bits[level + 1]), this); + context->current_node = service_node; + return bRC_OK; + case 1: + rp->create_status = CF_CREATED; + return bRC_OK; + case 999: + return bRC_Error; + default: + _JobMessage(M_ERROR, "Invalid state %d", state); + state = 999; + } + return bRC_Error; } bRC root_node_t::endRestoreFile(exchange_fd_context_t *context) { - _DebugMessage(0, "endRestoreFile_ROOT state = %d\n", state); - switch (state) - { - case 0: - delete service_node; - state = 1; - return bRC_OK; - case 1: - return bRC_OK; - default: - _JobMessage(M_ERROR, "Invalid state %d", state); - state = 999; - } - return bRC_Error; + _DebugMessage(0, "endRestoreFile_ROOT state = %d\n", state); + switch (state) + { + case 0: + delete service_node; + state = 1; + return bRC_OK; + case 1: + return bRC_OK; + default: + _JobMessage(M_ERROR, "Invalid state %d", state); + state = 999; + } + return bRC_Error; } diff --git a/bacula/src/win32/filed/plugins/service_node.c b/bacula/src/win32/filed/plugins/service_node.c index 9d3a267d97..4309bc5a5e 100644 --- a/bacula/src/win32/filed/plugins/service_node.c +++ b/bacula/src/win32/filed/plugins/service_node.c @@ -33,11 +33,11 @@ service_node_t::service_node_t(char *name, node_t *parent_node) : node_t(name, NODE_TYPE_SERVICE, parent_node) { - current_ibi = 0; - hccx = NULL; - ibi = NULL; - ibi_count = 0; - first_storage_group_node = NULL; + current_ibi = 0; + hccx = NULL; + ibi = NULL; + ibi_count = 0; + first_storage_group_node = NULL; } service_node_t::~service_node_t() @@ -47,180 +47,180 @@ service_node_t::~service_node_t() bRC service_node_t::startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp) { - HRESULT result; - - _DebugMessage(100, "startBackupNode_SERVICE state = %d\n", state); - switch(state) - { - case 0: - if (strcmp(PLUGIN_PATH_PREFIX_SERVICE, name) != 0) - { - _JobMessage(M_ERROR, "Invalid restore path specified, must start with /" PLUGIN_PATH_PREFIX_BASE "/" PLUGIN_PATH_PREFIX_SERVICE "/\n"); - return bRC_Error; - } - // convert name to a wide string - - _DebugMessage(100, "Calling HrESEBackupPrepare\n"); - result = HrESEBackupPrepare(context->computer_name, PLUGIN_PATH_PREFIX_SERVICE_W, &ibi_count, &ibi, &hccx); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESEBackupPrepare failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - return bRC_Error; - } - state = 1; - // fall through - case 1: - if (context->path_bits[level + 1] == NULL) - { - _DebugMessage(100, "No specific storage group specified - backing them all up\n"); - char *tmp = new char[wcslen(ibi[current_ibi].wszInstanceName) + 1]; - wcstombs(tmp, ibi[current_ibi].wszInstanceName, wcslen(ibi[current_ibi].wszInstanceName) + 1); - first_storage_group_node = new storage_group_node_t(tmp, this); - delete tmp; - _DebugMessage(100, "storage group name = %s\n", first_storage_group_node->name); - first_storage_group_node->ibi = &ibi[current_ibi]; - first_storage_group_node->hccx = hccx; - context->current_node = first_storage_group_node; - } - else - { - char *tmp = NULL; - for (current_ibi = 0; current_ibi < ibi_count; current_ibi++) - { - tmp = new char[wcslen(ibi[current_ibi].wszInstanceName) + 1]; - wcstombs(tmp, ibi[current_ibi].wszInstanceName, wcslen(ibi[current_ibi].wszInstanceName) + 1); - if (stricmp(tmp, context->path_bits[level + 1]) == 0) - break; - } - first_storage_group_node = new storage_group_node_t(tmp, this); - delete tmp; - if (current_ibi == ibi_count) - { - _JobMessage(M_ERROR, "Invalid Storage Group '%s'\n", context->path_bits[level + 1]); - return bRC_Error; - } - _DebugMessage(100, "storage group name = %s\n", first_storage_group_node->name); - first_storage_group_node->ibi = &ibi[current_ibi]; - first_storage_group_node->hccx = hccx; - context->current_node = first_storage_group_node; - } - break; - case 2: - time_t now = time(NULL); - sp->fname = full_path; - sp->link = full_path; - sp->statp.st_mode = 0700 | S_IFDIR; - sp->statp.st_ctime = now; - sp->statp.st_mtime = now; - sp->statp.st_atime = now; - sp->statp.st_size = 0; - sp->statp.st_nlink = 1; - //sp->statp.st_blocks = 0; - sp->type = FT_DIREND; - break; - } - _DebugMessage(100, "ending startBackupNode_SERVICE state = %d\n", state); - return bRC_OK; + HRESULT result; + + _DebugMessage(100, "startBackupNode_SERVICE state = %d\n", state); + switch(state) + { + case 0: + if (strcmp(PLUGIN_PATH_PREFIX_SERVICE, name) != 0) + { + _JobMessage(M_ERROR, "Invalid restore path specified, must start with /" PLUGIN_PATH_PREFIX_BASE "/" PLUGIN_PATH_PREFIX_SERVICE "/\n"); + return bRC_Error; + } + // convert name to a wide string + + _DebugMessage(100, "Calling HrESEBackupPrepare\n"); + result = HrESEBackupPrepare(context->computer_name, PLUGIN_PATH_PREFIX_SERVICE_W, &ibi_count, &ibi, &hccx); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESEBackupPrepare failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + return bRC_Error; + } + state = 1; + // fall through + case 1: + if (context->path_bits[level + 1] == NULL) + { + _DebugMessage(100, "No specific storage group specified - backing them all up\n"); + char *tmp = new char[wcslen(ibi[current_ibi].wszInstanceName) + 1]; + wcstombs(tmp, ibi[current_ibi].wszInstanceName, wcslen(ibi[current_ibi].wszInstanceName) + 1); + first_storage_group_node = new storage_group_node_t(tmp, this); + delete tmp; + _DebugMessage(100, "storage group name = %s\n", first_storage_group_node->name); + first_storage_group_node->ibi = &ibi[current_ibi]; + first_storage_group_node->hccx = hccx; + context->current_node = first_storage_group_node; + } + else + { + char *tmp = NULL; + for (current_ibi = 0; current_ibi < ibi_count; current_ibi++) + { + tmp = new char[wcslen(ibi[current_ibi].wszInstanceName) + 1]; + wcstombs(tmp, ibi[current_ibi].wszInstanceName, wcslen(ibi[current_ibi].wszInstanceName) + 1); + if (stricmp(tmp, context->path_bits[level + 1]) == 0) + break; + } + first_storage_group_node = new storage_group_node_t(tmp, this); + delete tmp; + if (current_ibi == ibi_count) + { + _JobMessage(M_ERROR, "Invalid Storage Group '%s'\n", context->path_bits[level + 1]); + return bRC_Error; + } + _DebugMessage(100, "storage group name = %s\n", first_storage_group_node->name); + first_storage_group_node->ibi = &ibi[current_ibi]; + first_storage_group_node->hccx = hccx; + context->current_node = first_storage_group_node; + } + break; + case 2: + time_t now = time(NULL); + sp->fname = full_path; + sp->link = full_path; + sp->statp.st_mode = 0700 | S_IFDIR; + sp->statp.st_ctime = now; + sp->statp.st_mtime = now; + sp->statp.st_atime = now; + sp->statp.st_size = 0; + sp->statp.st_nlink = 1; + //sp->statp.st_blocks = 0; + sp->type = FT_DIREND; + break; + } + _DebugMessage(100, "ending startBackupNode_SERVICE state = %d\n", state); + return bRC_OK; } bRC service_node_t::endBackupFile(exchange_fd_context_t *context) { - HRESULT result; - bRC retval = bRC_OK; - - _DebugMessage(100, "endBackupNode_SERVICE state = %d\n", state); - switch(state) - { - case 0: - // should never happen - break; - case 1: - // free node->storage_group_node - if (context->path_bits[level + 1] == NULL) - { - current_ibi++; - if (current_ibi == ibi_count) - state = 2; - } - else - state = 2; - retval = bRC_More; - break; - case 2: - _DebugMessage(100, "calling HrESEBackupEnd\n"); - result = HrESEBackupEnd(hccx); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESEBackupEnd failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - return bRC_Error; - } - - context->current_node = parent; - retval = bRC_OK; - break; - } - return retval; + HRESULT result; + bRC retval = bRC_OK; + + _DebugMessage(100, "endBackupNode_SERVICE state = %d\n", state); + switch(state) + { + case 0: + // should never happen + break; + case 1: + // free node->storage_group_node + if (context->path_bits[level + 1] == NULL) + { + current_ibi++; + if (current_ibi == ibi_count) + state = 2; + } + else + state = 2; + retval = bRC_More; + break; + case 2: + _DebugMessage(100, "calling HrESEBackupEnd\n"); + result = HrESEBackupEnd(hccx); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESEBackupEnd failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + return bRC_Error; + } + + context->current_node = parent; + retval = bRC_OK; + break; + } + return retval; } bRC service_node_t::createFile(exchange_fd_context_t *context, struct restore_pkt *rp) { - storage_group_node_t *curr_sg, *prev_sg; - - _DebugMessage(0, "createFile_SERVICE state = %d\n", state); - if (strcmp(name, "Microsoft Information Store") != 0) - { - _JobMessage(M_ERROR, "Invalid restore path specified, must start with '/" PLUGIN_PATH_PREFIX_BASE "/" PLUGIN_PATH_PREFIX_SERVICE "/'\n", state); - return bRC_Error; - } - for(;;) - { - switch (state) - { - case 0: - if (context->path_bits[level + 1] == NULL) - { - state = 1; - break; - } - for (prev_sg = NULL, curr_sg = first_storage_group_node; curr_sg != NULL; prev_sg = curr_sg, curr_sg = curr_sg->next) - { - if (strcmp(curr_sg->name, context->path_bits[level + 1]) == 0) - { - break; - } - } - if (curr_sg == NULL) - { - curr_sg = new storage_group_node_t(bstrdup(context->path_bits[level + 1]), this); - if (prev_sg == NULL) - first_storage_group_node = curr_sg; - else - prev_sg->next = curr_sg; - } - context->current_node = curr_sg; - return bRC_OK; - case 1: - rp->create_status = CF_CREATED; - return bRC_OK; - } - } - return bRC_Error; + storage_group_node_t *curr_sg, *prev_sg; + + _DebugMessage(0, "createFile_SERVICE state = %d\n", state); + if (strcmp(name, "Microsoft Information Store") != 0) + { + _JobMessage(M_ERROR, "Invalid restore path specified, must start with '/" PLUGIN_PATH_PREFIX_BASE "/" PLUGIN_PATH_PREFIX_SERVICE "/'\n", state); + return bRC_Error; + } + for(;;) + { + switch (state) + { + case 0: + if (context->path_bits[level + 1] == NULL) + { + state = 1; + break; + } + for (prev_sg = NULL, curr_sg = first_storage_group_node; curr_sg != NULL; prev_sg = curr_sg, curr_sg = curr_sg->next) + { + if (strcmp(curr_sg->name, context->path_bits[level + 1]) == 0) + { + break; + } + } + if (curr_sg == NULL) + { + curr_sg = new storage_group_node_t(bstrdup(context->path_bits[level + 1]), this); + if (prev_sg == NULL) + first_storage_group_node = curr_sg; + else + prev_sg->next = curr_sg; + } + context->current_node = curr_sg; + return bRC_OK; + case 1: + rp->create_status = CF_CREATED; + return bRC_OK; + } + } + return bRC_Error; } bRC service_node_t::endRestoreFile(exchange_fd_context_t *context) { - _DebugMessage(0, "endRestoreFile_SERVICE state = %d\n", state); - switch(state) - { - case 0: - return bRC_Error; - case 1: - context->current_node = parent; - return bRC_OK; - } - - return bRC_Error; + _DebugMessage(0, "endRestoreFile_SERVICE state = %d\n", state); + switch(state) + { + case 0: + return bRC_Error; + case 1: + context->current_node = parent; + return bRC_OK; + } + + return bRC_Error; } diff --git a/bacula/src/win32/filed/plugins/storage_group_node.c b/bacula/src/win32/filed/plugins/storage_group_node.c index 21badc0ff4..2ec7e8e8b3 100644 --- a/bacula/src/win32/filed/plugins/storage_group_node.c +++ b/bacula/src/win32/filed/plugins/storage_group_node.c @@ -33,474 +33,474 @@ storage_group_node_t::storage_group_node_t(char *name, node_t *parent_node) : node_t(name, NODE_TYPE_STORAGE_GROUP, parent_node) { - ibi = NULL; - store_node = NULL; - current_dbi = 0; - restore_environment = NULL; - saved_log_path = NULL; - next = NULL; + ibi = NULL; + store_node = NULL; + current_dbi = 0; + restore_environment = NULL; + saved_log_path = NULL; + next = NULL; } storage_group_node_t::~storage_group_node_t() { /* - if (dbi_node != NULL) - delete dbi_node; + if (dbi_node != NULL) + delete dbi_node; - if (file_node != NULL) - delete file_node; + if (file_node != NULL) + delete file_node; */ } bRC storage_group_node_t::startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp) { - HRESULT result; - int len; - WCHAR *tmp_logfiles, *tmp_logfile_ptr; - char *tmp; + HRESULT result; + int len; + WCHAR *tmp_logfiles, *tmp_logfile_ptr; + char *tmp; - for(;;) - { - _DebugMessage(100, "startBackupNode_STORAGE_GROUP state = %d, name = %s\n", state, name); - switch(state) - { - case 0: - current_dbi = 0; - store_node = NULL; - logfile_ptr = NULL; - if (context->job_level == 'F') - { - _DebugMessage(100, "Calling HrESEBackupSetup (BACKUP_TYPE_FULL)\n"); - result = HrESEBackupSetup(hccx, ibi->hInstanceId, BACKUP_TYPE_FULL); - state = 1; - } - else - { - _DebugMessage(100, "Calling HrESEBackupSetup (BACKUP_TYPE_LOGS_ONLY)\n"); - result = HrESEBackupSetup(hccx, ibi->hInstanceId, BACKUP_TYPE_LOGS_ONLY); - if (context->accurate) - state = 1; - else - state = 2; - } - if (result != 0) - { - _JobMessage(M_ERROR, "HrESEBackupSetup failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - state = 999; - return bRC_Error; - } - break; - case 1: - if (context->path_bits[level + 1] == NULL) - { - _DebugMessage(100, "No specific database specified - backing them all up\n"); - DATABASE_BACKUP_INFO *dbi = &ibi->rgDatabase[current_dbi]; - char *tmp = new char[wcslen(dbi->wszDatabaseDisplayName) + 1]; - wcstombs(tmp, dbi->wszDatabaseDisplayName, wcslen(dbi->wszDatabaseDisplayName) + 1); - store_node = new store_node_t(tmp, this); - store_node->dbi = dbi; - store_node->hccx = hccx; - context->current_node = store_node; - } - else - { - DATABASE_BACKUP_INFO *dbi = NULL; - char *tmp = NULL; - for (current_dbi = 0; current_dbi < ibi->cDatabase; current_dbi++) - { - dbi = &ibi->rgDatabase[current_dbi]; - char *tmp = new char[wcslen(dbi->wszDatabaseDisplayName) + 1]; - wcstombs(tmp, dbi->wszDatabaseDisplayName, wcslen(dbi->wszDatabaseDisplayName) + 1); - if (stricmp(tmp, context->path_bits[level + 1]) == 0) - break; - delete tmp; - } - if (current_dbi == ibi->cDatabase) - { - _JobMessage(M_ERROR, "Invalid Database '%s'\n", context->path_bits[level + 1]); - return bRC_Error; - } - store_node = new store_node_t(tmp, this); - _DebugMessage(100, "Database name = %s\n", store_node->name); - delete tmp; - store_node->hccx = hccx; - store_node->dbi = dbi; - context->current_node = store_node; - } - return bRC_OK; - case 2: - _DebugMessage(100, "Calling HrESEBackupGetLogAndPatchFiles\n"); - result = HrESEBackupGetLogAndPatchFiles(hccx, &tmp_logfiles); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESEBackupGetLogAndPatchFiles failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - return bRC_Error; - } - for (len = 0, tmp_logfile_ptr = tmp_logfiles; *tmp_logfile_ptr != 0; tmp_logfile_ptr += wcslen(tmp_logfile_ptr) + 1) - { - len += wcslen(tmp_logfile_ptr) + 1; - } - logfiles = new WCHAR[len + 1]; - logfile_ptr = logfiles; - for (tmp_logfile_ptr = tmp_logfiles; *tmp_logfile_ptr != 0; tmp_logfile_ptr += wcslen(tmp_logfile_ptr) + 1) - { - // check file modification date - HANDLE handle; - FILETIME modified_time; - //int64_t tmp_time; - __int64 tmp_time; - bool include_file; - include_file = false; - handle = INVALID_HANDLE_VALUE; - if (context->job_since == 0) - include_file = true; - if (!include_file) - { - handle = CreateFileW(tmp_logfile_ptr, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - if (handle == INVALID_HANDLE_VALUE) - { - //_JobMessage(M_WARNING, "Could not open '%S' to check last modified date (0x%08x), including anyway\n", tmp_logfile_ptr, GetLastError()); - include_file = true; - } - } - if (!include_file) - { - if (GetFileTime(handle, NULL, NULL, &modified_time) == 0) - { - //_JobMessage(M_WARNING, "Could check last modified date for '%S' (0x%08x), including anyway\n", tmp_logfile_ptr, GetLastError()); - include_file = true; - } - } - if (!include_file) - { - tmp_time = (((int64_t)modified_time.dwHighDateTime) << 32) | modified_time.dwLowDateTime; - tmp_time -= 116444736000000000LL; - tmp_time /= 10000000; - if (tmp_time > context->job_since) - { - include_file = true; - } - } - if (include_file) - { - memcpy(logfile_ptr, tmp_logfile_ptr, (wcslen(tmp_logfile_ptr) + 1) * 2); - logfile_ptr += wcslen(logfile_ptr) + 1; - //_DebugMessage(100, "Including file %S\n", logfile_ptr); - } - else - { - if (context->accurate) { - tmp = new char[strlen(full_path) + wcslen(tmp_logfile_ptr) + 1]; - strcpy(tmp, full_path); - wcstombs(tmp + strlen(full_path), tmp_logfile_ptr, wcslen(tmp_logfile_ptr) + 1); - _JobMessage(M_WARNING, "Marking '%s' as seen\n", tmp); - bfuncs->setBaculaValue(context->bpContext, bVarFileSeen, (void *)tmp); - delete tmp; - } - } + for(;;) + { + _DebugMessage(100, "startBackupNode_STORAGE_GROUP state = %d, name = %s\n", state, name); + switch(state) + { + case 0: + current_dbi = 0; + store_node = NULL; + logfile_ptr = NULL; + if (context->job_level == 'F') + { + _DebugMessage(100, "Calling HrESEBackupSetup (BACKUP_TYPE_FULL)\n"); + result = HrESEBackupSetup(hccx, ibi->hInstanceId, BACKUP_TYPE_FULL); + state = 1; + } + else + { + _DebugMessage(100, "Calling HrESEBackupSetup (BACKUP_TYPE_LOGS_ONLY)\n"); + result = HrESEBackupSetup(hccx, ibi->hInstanceId, BACKUP_TYPE_LOGS_ONLY); + if (context->accurate) + state = 1; + else + state = 2; + } + if (result != 0) + { + _JobMessage(M_ERROR, "HrESEBackupSetup failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + state = 999; + return bRC_Error; + } + break; + case 1: + if (context->path_bits[level + 1] == NULL) + { + _DebugMessage(100, "No specific database specified - backing them all up\n"); + DATABASE_BACKUP_INFO *dbi = &ibi->rgDatabase[current_dbi]; + char *tmp = new char[wcslen(dbi->wszDatabaseDisplayName) + 1]; + wcstombs(tmp, dbi->wszDatabaseDisplayName, wcslen(dbi->wszDatabaseDisplayName) + 1); + store_node = new store_node_t(tmp, this); + store_node->dbi = dbi; + store_node->hccx = hccx; + context->current_node = store_node; + } + else + { + DATABASE_BACKUP_INFO *dbi = NULL; + char *tmp = NULL; + for (current_dbi = 0; current_dbi < ibi->cDatabase; current_dbi++) + { + dbi = &ibi->rgDatabase[current_dbi]; + char *tmp = new char[wcslen(dbi->wszDatabaseDisplayName) + 1]; + wcstombs(tmp, dbi->wszDatabaseDisplayName, wcslen(dbi->wszDatabaseDisplayName) + 1); + if (stricmp(tmp, context->path_bits[level + 1]) == 0) + break; + delete tmp; + } + if (current_dbi == ibi->cDatabase) + { + _JobMessage(M_ERROR, "Invalid Database '%s'\n", context->path_bits[level + 1]); + return bRC_Error; + } + store_node = new store_node_t(tmp, this); + _DebugMessage(100, "Database name = %s\n", store_node->name); + delete tmp; + store_node->hccx = hccx; + store_node->dbi = dbi; + context->current_node = store_node; + } + return bRC_OK; + case 2: + _DebugMessage(100, "Calling HrESEBackupGetLogAndPatchFiles\n"); + result = HrESEBackupGetLogAndPatchFiles(hccx, &tmp_logfiles); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESEBackupGetLogAndPatchFiles failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + return bRC_Error; + } + for (len = 0, tmp_logfile_ptr = tmp_logfiles; *tmp_logfile_ptr != 0; tmp_logfile_ptr += wcslen(tmp_logfile_ptr) + 1) + { + len += wcslen(tmp_logfile_ptr) + 1; + } + logfiles = new WCHAR[len + 1]; + logfile_ptr = logfiles; + for (tmp_logfile_ptr = tmp_logfiles; *tmp_logfile_ptr != 0; tmp_logfile_ptr += wcslen(tmp_logfile_ptr) + 1) + { + // check file modification date + HANDLE handle; + FILETIME modified_time; + //int64_t tmp_time; + __int64 tmp_time; + bool include_file; + include_file = false; + handle = INVALID_HANDLE_VALUE; + if (context->job_since == 0) + include_file = true; + if (!include_file) + { + handle = CreateFileW(tmp_logfile_ptr, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + if (handle == INVALID_HANDLE_VALUE) + { + //_JobMessage(M_WARNING, "Could not open '%S' to check last modified date (0x%08x), including anyway\n", tmp_logfile_ptr, GetLastError()); + include_file = true; + } + } + if (!include_file) + { + if (GetFileTime(handle, NULL, NULL, &modified_time) == 0) + { + //_JobMessage(M_WARNING, "Could check last modified date for '%S' (0x%08x), including anyway\n", tmp_logfile_ptr, GetLastError()); + include_file = true; + } + } + if (!include_file) + { + tmp_time = (((int64_t)modified_time.dwHighDateTime) << 32) | modified_time.dwLowDateTime; + tmp_time -= 116444736000000000LL; + tmp_time /= 10000000; + if (tmp_time > context->job_since) + { + include_file = true; + } + } + if (include_file) + { + memcpy(logfile_ptr, tmp_logfile_ptr, (wcslen(tmp_logfile_ptr) + 1) * 2); + logfile_ptr += wcslen(logfile_ptr) + 1; + //_DebugMessage(100, "Including file %S\n", logfile_ptr); + } + else + { + if (context->accurate) { + tmp = new char[strlen(full_path) + wcslen(tmp_logfile_ptr) + 1]; + strcpy(tmp, full_path); + wcstombs(tmp + strlen(full_path), tmp_logfile_ptr, wcslen(tmp_logfile_ptr) + 1); + _JobMessage(M_WARNING, "Marking '%s' as seen\n", tmp); + bfuncs->setBaculaValue(context->bpContext, bVarFileSeen, (void *)tmp); + delete tmp; + } + } - if (handle != INVALID_HANDLE_VALUE) - CloseHandle(handle); + if (handle != INVALID_HANDLE_VALUE) + CloseHandle(handle); - } - *logfile_ptr = 0; - logfile_ptr = logfiles; - state = 3; - break; - case 3: - tmp = new char[wcslen(logfile_ptr) + 1]; - wcstombs(tmp, logfile_ptr, wcslen(logfile_ptr) + 1); - file_node = new file_node_t(tmp, this); - delete tmp; - file_node->hccx = hccx; - file_node->filename = logfile_ptr; - context->current_node = file_node; - return bRC_OK; - case 4: - time_t now = time(NULL); - sp->fname = full_path; - sp->link = full_path; - _DebugMessage(100, "fname = %s\n", sp->fname); - sp->statp.st_mode = 0700 | S_IFDIR; - sp->statp.st_ctime = now; - sp->statp.st_mtime = now; - sp->statp.st_atime = now; - sp->statp.st_size = 0; - //sp->statp.st_blocks = 0; - sp->type = FT_DIREND; - return bRC_OK; - } - } + } + *logfile_ptr = 0; + logfile_ptr = logfiles; + state = 3; + break; + case 3: + tmp = new char[wcslen(logfile_ptr) + 1]; + wcstombs(tmp, logfile_ptr, wcslen(logfile_ptr) + 1); + file_node = new file_node_t(tmp, this); + delete tmp; + file_node->hccx = hccx; + file_node->filename = logfile_ptr; + context->current_node = file_node; + return bRC_OK; + case 4: + time_t now = time(NULL); + sp->fname = full_path; + sp->link = full_path; + _DebugMessage(100, "fname = %s\n", sp->fname); + sp->statp.st_mode = 0700 | S_IFDIR; + sp->statp.st_ctime = now; + sp->statp.st_mtime = now; + sp->statp.st_atime = now; + sp->statp.st_size = 0; + //sp->statp.st_blocks = 0; + sp->type = FT_DIREND; + return bRC_OK; + } + } } bRC storage_group_node_t::endBackupFile(exchange_fd_context_t *context) { - HRESULT result; - bRC retval = bRC_Error; + HRESULT result; + bRC retval = bRC_Error; - _DebugMessage(100, "endBackupNode_STORAGE_GROUP state = %d\n", state); + _DebugMessage(100, "endBackupNode_STORAGE_GROUP state = %d\n", state); - switch(state) - { - case 0: - // should never happen - break; - case 1: - // free node->storage_group_node - if (context->path_bits[level + 1] == NULL) - { - current_dbi++; - if (current_dbi == ibi->cDatabase) - state = 2; - } - else - state = 2; - retval = bRC_More; - break; - case 2: - // should never happen - break; - case 3: - delete file_node; - logfile_ptr += wcslen(logfile_ptr) + 1; - if (*logfile_ptr == 0) - state = 4; - retval = bRC_More; - break; - case 4: - if (context->truncate_logs) - { - _DebugMessage(100, "Calling HrESEBackupTruncateLogs\n"); - result = HrESEBackupTruncateLogs(hccx); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESEBackupTruncateLogs failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - } - else - { - _JobMessage(M_INFO, "Truncated database logs for Storage Group %s\n", name); - } - } - else - { - _JobMessage(M_INFO, "Did NOT truncate database logs for Storage Group %s\n", name); - } - _DebugMessage(100, "Calling HrESEBackupInstanceEnd\n"); - result = HrESEBackupInstanceEnd(hccx, ESE_BACKUP_INSTANCE_END_SUCCESS); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESEBackupInstanceEnd failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - return bRC_Error; - } - retval = bRC_OK; - context->current_node = parent; - break; - } - return retval; + switch(state) + { + case 0: + // should never happen + break; + case 1: + // free node->storage_group_node + if (context->path_bits[level + 1] == NULL) + { + current_dbi++; + if (current_dbi == ibi->cDatabase) + state = 2; + } + else + state = 2; + retval = bRC_More; + break; + case 2: + // should never happen + break; + case 3: + delete file_node; + logfile_ptr += wcslen(logfile_ptr) + 1; + if (*logfile_ptr == 0) + state = 4; + retval = bRC_More; + break; + case 4: + if (context->truncate_logs) + { + _DebugMessage(100, "Calling HrESEBackupTruncateLogs\n"); + result = HrESEBackupTruncateLogs(hccx); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESEBackupTruncateLogs failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + } + else + { + _JobMessage(M_INFO, "Truncated database logs for Storage Group %s\n", name); + } + } + else + { + _JobMessage(M_INFO, "Did NOT truncate database logs for Storage Group %s\n", name); + } + _DebugMessage(100, "Calling HrESEBackupInstanceEnd\n"); + result = HrESEBackupInstanceEnd(hccx, ESE_BACKUP_INSTANCE_END_SUCCESS); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESEBackupInstanceEnd failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + return bRC_Error; + } + retval = bRC_OK; + context->current_node = parent; + break; + } + return retval; } bRC storage_group_node_t::createFile(exchange_fd_context_t *context, struct restore_pkt *rp) { - HRESULT result; - int len; + HRESULT result; + int len; - _DebugMessage(0, "createFile_STORAGE_GROUP state = %d\n", state); + _DebugMessage(0, "createFile_STORAGE_GROUP state = %d\n", state); - if (strcmp(context->path_bits[level], name) != 0) - { - _DebugMessage(0, "Different storage group - switching back to parent\n", state); - saved_log_path = new WCHAR[wcslen(restore_environment->m_wszRestoreLogPath) + 1]; - wcscpy(saved_log_path, restore_environment->m_wszRestoreLogPath); - _DebugMessage(100, "Calling HrESERestoreSaveEnvironment\n"); - result = HrESERestoreSaveEnvironment(hccx); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESERestoreSaveEnvironment failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - state = 999; - rp->create_status = CF_CREATED; - return bRC_OK; - } - _DebugMessage(100, "Calling HrESERestoreClose\n"); - result = HrESERestoreClose(hccx, RESTORE_CLOSE_NORMAL); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESERestoreClose failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - state = 999; - rp->create_status = CF_CREATED; - return bRC_OK; - } - context->current_node = parent; - return bRC_OK; - } - if (saved_log_path != NULL) - { - _DebugMessage(0, "Calling HrESERestoreReopen\n"); - result = HrESERestoreReopen(context->computer_name, service_name, saved_log_path, &hccx); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESERestoreReopen failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - state = 999; - saved_log_path = NULL; - rp->create_status = CF_CREATED; - return bRC_OK; - } - _DebugMessage(0, "Calling HrESERestoreGetEnvironment\n"); - result = HrESERestoreGetEnvironment(hccx, &restore_environment); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESERestoreGetEnvironment failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - state = 999; - saved_log_path = NULL; - rp->create_status = CF_CREATED; - return bRC_OK; - } - saved_log_path = NULL; - } + if (strcmp(context->path_bits[level], name) != 0) + { + _DebugMessage(0, "Different storage group - switching back to parent\n", state); + saved_log_path = new WCHAR[wcslen(restore_environment->m_wszRestoreLogPath) + 1]; + wcscpy(saved_log_path, restore_environment->m_wszRestoreLogPath); + _DebugMessage(100, "Calling HrESERestoreSaveEnvironment\n"); + result = HrESERestoreSaveEnvironment(hccx); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESERestoreSaveEnvironment failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + state = 999; + rp->create_status = CF_CREATED; + return bRC_OK; + } + _DebugMessage(100, "Calling HrESERestoreClose\n"); + result = HrESERestoreClose(hccx, RESTORE_CLOSE_NORMAL); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESERestoreClose failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + state = 999; + rp->create_status = CF_CREATED; + return bRC_OK; + } + context->current_node = parent; + return bRC_OK; + } + if (saved_log_path != NULL) + { + _DebugMessage(0, "Calling HrESERestoreReopen\n"); + result = HrESERestoreReopen(context->computer_name, service_name, saved_log_path, &hccx); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESERestoreReopen failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + state = 999; + saved_log_path = NULL; + rp->create_status = CF_CREATED; + return bRC_OK; + } + _DebugMessage(0, "Calling HrESERestoreGetEnvironment\n"); + result = HrESERestoreGetEnvironment(hccx, &restore_environment); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESERestoreGetEnvironment failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + state = 999; + saved_log_path = NULL; + rp->create_status = CF_CREATED; + return bRC_OK; + } + saved_log_path = NULL; + } - for (;;) - { - switch (state) - { - case 0: - if (context->path_bits[level + 2] == NULL) - { - _JobMessage(M_ERROR, "Unexpected log file '%s%s' - expecting database\n", full_path, context->path_bits[level + 1]); - state = 999; - break; - } - service_name = new WCHAR[strlen(parent->name) + 1]; - storage_group_name = new WCHAR[strlen(name) + 1]; - mbstowcs(service_name, parent->name, strlen(parent->name) + 1); - mbstowcs(storage_group_name, name, strlen(name) + 1); - _DebugMessage(0, "Calling HrESERestoreOpen\n"); - result = HrESERestoreOpen(context->computer_name, service_name, storage_group_name, NULL, &hccx); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESERestoreOpen failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - state = 999; - break; - } - _DebugMessage(0, "Calling HrESERestoreGetEnvironment\n"); - result = HrESERestoreGetEnvironment(hccx, &restore_environment); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESERestoreGetEnvironment failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - state = 999; - break; - } - state = 1; - break; - case 1: - if (context->path_bits[level + 2] == NULL) - { - state = 2; - break; - } - store_node = new store_node_t(bstrdup(context->path_bits[level + 1]), this); - store_node->hccx = hccx; - context->current_node = store_node; - return bRC_OK; - case 2: - if (context->path_bits[level + 2] != NULL) - { - _JobMessage(M_ERROR, "Unexpected file '%s'\n", full_path); - state = 999; - break; - } - if (context->path_bits[level + 1] == NULL) - { - state = 3; - break; - } - state = 2; - file_node = new file_node_t(bstrdup(context->path_bits[level + 1]), this); - file_node->hccx = hccx; - int i; - for (i = strlen(file_node->name) - 1; i >= 0; i--) - { - if (file_node->name[i] == '\\') - { - i++; - break; - } - } - len = wcslen(restore_environment->m_wszRestoreLogPath) + strlen(file_node->name + i) + 1 + 1; - file_node->filename = new WCHAR[len]; - wcscpy(file_node->filename, restore_environment->m_wszRestoreLogPath); - wcscat(file_node->filename, L"\\"); - mbstowcs(&file_node->filename[wcslen(file_node->filename)], file_node->name + i, strlen(file_node->name + i) + 1); - context->current_node = file_node; - return bRC_OK; - case 3: - if (rp->type != FT_DIREND) - { - _JobMessage(M_ERROR, "Unexpected file '%s'\n", full_path); - state = 999; - break; - } - // must be the storage group node - _DebugMessage(100, "Calling HrESERestoreSaveEnvironment\n"); - result = HrESERestoreSaveEnvironment(hccx); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESERestoreSaveEnvironment failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - state = 999; - break; - } + for (;;) + { + switch (state) + { + case 0: + if (context->path_bits[level + 2] == NULL) + { + _JobMessage(M_ERROR, "Unexpected log file '%s%s' - expecting database\n", full_path, context->path_bits[level + 1]); + state = 999; + break; + } + service_name = new WCHAR[strlen(parent->name) + 1]; + storage_group_name = new WCHAR[strlen(name) + 1]; + mbstowcs(service_name, parent->name, strlen(parent->name) + 1); + mbstowcs(storage_group_name, name, strlen(name) + 1); + _DebugMessage(0, "Calling HrESERestoreOpen\n"); + result = HrESERestoreOpen(context->computer_name, service_name, storage_group_name, NULL, &hccx); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESERestoreOpen failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + state = 999; + break; + } + _DebugMessage(0, "Calling HrESERestoreGetEnvironment\n"); + result = HrESERestoreGetEnvironment(hccx, &restore_environment); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESERestoreGetEnvironment failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + state = 999; + break; + } + state = 1; + break; + case 1: + if (context->path_bits[level + 2] == NULL) + { + state = 2; + break; + } + store_node = new store_node_t(bstrdup(context->path_bits[level + 1]), this); + store_node->hccx = hccx; + context->current_node = store_node; + return bRC_OK; + case 2: + if (context->path_bits[level + 2] != NULL) + { + _JobMessage(M_ERROR, "Unexpected file '%s'\n", full_path); + state = 999; + break; + } + if (context->path_bits[level + 1] == NULL) + { + state = 3; + break; + } + state = 2; + file_node = new file_node_t(bstrdup(context->path_bits[level + 1]), this); + file_node->hccx = hccx; + int i; + for (i = strlen(file_node->name) - 1; i >= 0; i--) + { + if (file_node->name[i] == '\\') + { + i++; + break; + } + } + len = wcslen(restore_environment->m_wszRestoreLogPath) + strlen(file_node->name + i) + 1 + 1; + file_node->filename = new WCHAR[len]; + wcscpy(file_node->filename, restore_environment->m_wszRestoreLogPath); + wcscat(file_node->filename, L"\\"); + mbstowcs(&file_node->filename[wcslen(file_node->filename)], file_node->name + i, strlen(file_node->name + i) + 1); + context->current_node = file_node; + return bRC_OK; + case 3: + if (rp->type != FT_DIREND) + { + _JobMessage(M_ERROR, "Unexpected file '%s'\n", full_path); + state = 999; + break; + } + // must be the storage group node + _DebugMessage(100, "Calling HrESERestoreSaveEnvironment\n"); + result = HrESERestoreSaveEnvironment(hccx); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESERestoreSaveEnvironment failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + state = 999; + break; + } - _DebugMessage(100, "Calling HrESERestoreComplete\n"); - result = HrESERestoreComplete(hccx, restore_environment->m_wszRestoreLogPath, - restore_environment->m_wszRestoreLogPath, storage_group_name, ESE_RESTORE_COMPLETE_ATTACH_DBS); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESERestoreComplete failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - state = 999; - break; - } - else - { - _JobMessage(M_INFO, "Storage Group '%s' restored successfully\n", name); - } + _DebugMessage(100, "Calling HrESERestoreComplete\n"); + result = HrESERestoreComplete(hccx, restore_environment->m_wszRestoreLogPath, + restore_environment->m_wszRestoreLogPath, storage_group_name, ESE_RESTORE_COMPLETE_ATTACH_DBS); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESERestoreComplete failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + state = 999; + break; + } + else + { + _JobMessage(M_INFO, "Storage Group '%s' restored successfully\n", name); + } - _DebugMessage(100, "Calling HrESERestoreClose\n"); - result = HrESERestoreClose(hccx, RESTORE_CLOSE_NORMAL); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESERestoreClose failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - state = 999; - break; - } + _DebugMessage(100, "Calling HrESERestoreClose\n"); + result = HrESERestoreClose(hccx, RESTORE_CLOSE_NORMAL); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESERestoreClose failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + state = 999; + break; + } - rp->create_status = CF_CREATED; - return bRC_OK; - case 999: - rp->create_status = CF_CREATED; - return bRC_OK; - } - } + rp->create_status = CF_CREATED; + return bRC_OK; + case 999: + rp->create_status = CF_CREATED; + return bRC_OK; + } + } } bRC storage_group_node_t::endRestoreFile(exchange_fd_context_t *context) { - _DebugMessage(0, "endRestoreFile_STORAGE_GROUP state = %d\n", state); - switch (state) - { - case 0: - return bRC_Error; - case 1: - return bRC_OK; - case 2: - return bRC_OK; - case 3: - context->current_node = parent; - return bRC_OK; - case 999: - return bRC_OK; - } + _DebugMessage(0, "endRestoreFile_STORAGE_GROUP state = %d\n", state); + switch (state) + { + case 0: + return bRC_Error; + case 1: + return bRC_OK; + case 2: + return bRC_OK; + case 3: + context->current_node = parent; + return bRC_OK; + case 999: + return bRC_OK; + } - return bRC_Error; + return bRC_Error; } diff --git a/bacula/src/win32/filed/plugins/store_node.c b/bacula/src/win32/filed/plugins/store_node.c index ae44939d57..8470b1c202 100644 --- a/bacula/src/win32/filed/plugins/store_node.c +++ b/bacula/src/win32/filed/plugins/store_node.c @@ -33,217 +33,217 @@ store_node_t::store_node_t(char *name, node_t *parent_node) : node_t(name, NODE_TYPE_STORE, parent_node) { - dbi = NULL; - hccx = NULL; - dbi_node = NULL; - file_node = NULL; + dbi = NULL; + hccx = NULL; + dbi_node = NULL; + file_node = NULL; } store_node_t::~store_node_t() { - if (dbi_node != NULL) - delete dbi_node; + if (dbi_node != NULL) + delete dbi_node; - if (file_node != NULL) - delete file_node; + if (file_node != NULL) + delete file_node; } bRC store_node_t::startBackupFile(exchange_fd_context_t *context, struct save_pkt *sp) { - char *tmp; - - _DebugMessage(100, "startBackupNode_STORE state = %d\n", state); - - switch(state) - { - case 0: - stream_ptr = dbi->wszDatabaseStreams; - state = 1; - // fall through - case 1: - dbi_node = new dbi_node_t("DatabaseBackupInfo", this); - dbi_node->dbi = dbi; - context->current_node = dbi_node; - break; - case 2: - tmp = new char[wcslen(stream_ptr) + 1]; - wcstombs(tmp, stream_ptr, wcslen(stream_ptr) + 1); - file_node = new file_node_t(tmp, this); - file_node->hccx = hccx; - file_node->filename = stream_ptr; - context->current_node = file_node; - break; - case 3: - if (context->job_level == 'F') - { - time_t now = time(NULL); - sp->fname = full_path; - sp->link = full_path; - sp->statp.st_mode = 0700 | S_IFDIR; - sp->statp.st_ctime = now; - sp->statp.st_mtime = now; - sp->statp.st_atime = now; - sp->statp.st_size = 0; - sp->type = FT_DIREND; - } - else - { - bfuncs->setBaculaValue(context->bpContext, bVarFileSeen, (void *)full_path); - return bRC_Seen; - } - break; - } - - return bRC_OK; + char *tmp; + + _DebugMessage(100, "startBackupNode_STORE state = %d\n", state); + + switch(state) + { + case 0: + stream_ptr = dbi->wszDatabaseStreams; + state = 1; + // fall through + case 1: + dbi_node = new dbi_node_t("DatabaseBackupInfo", this); + dbi_node->dbi = dbi; + context->current_node = dbi_node; + break; + case 2: + tmp = new char[wcslen(stream_ptr) + 1]; + wcstombs(tmp, stream_ptr, wcslen(stream_ptr) + 1); + file_node = new file_node_t(tmp, this); + file_node->hccx = hccx; + file_node->filename = stream_ptr; + context->current_node = file_node; + break; + case 3: + if (context->job_level == 'F') + { + time_t now = time(NULL); + sp->fname = full_path; + sp->link = full_path; + sp->statp.st_mode = 0700 | S_IFDIR; + sp->statp.st_ctime = now; + sp->statp.st_mtime = now; + sp->statp.st_atime = now; + sp->statp.st_size = 0; + sp->type = FT_DIREND; + } + else + { + bfuncs->setBaculaValue(context->bpContext, bVarFileSeen, (void *)full_path); + return bRC_Seen; + } + break; + } + + return bRC_OK; } bRC store_node_t::endBackupFile(exchange_fd_context_t *context) { - _DebugMessage(100, "endBackupNode_STORE state = %d\n", state); - bRC retval = bRC_OK; - - switch(state) - { - case 0: - // should never happen - break; - case 1: - state = 2; - retval = bRC_More; - break; - case 2: - delete file_node; - stream_ptr += wcslen(stream_ptr) + 1; - if (*stream_ptr == 0) - state = 3; - retval = bRC_More; - break; - case 3: - //delete dbi_node; - context->current_node = parent; - break; - } - return retval; + _DebugMessage(100, "endBackupNode_STORE state = %d\n", state); + bRC retval = bRC_OK; + + switch(state) + { + case 0: + // should never happen + break; + case 1: + state = 2; + retval = bRC_More; + break; + case 2: + delete file_node; + stream_ptr += wcslen(stream_ptr) + 1; + if (*stream_ptr == 0) + state = 3; + retval = bRC_More; + break; + case 3: + //delete dbi_node; + context->current_node = parent; + break; + } + return retval; } bRC store_node_t::createFile(exchange_fd_context_t *context, struct restore_pkt *rp) { - _DebugMessage(0, "createFile_STORE state = %d\n", state); - - if (strcmp(context->path_bits[level - 1], parent->name) != 0) - { - _DebugMessage(0, "Different storage group - switching back to parent\n", state); - context->current_node = parent; - return bRC_OK; - } - for (;;) - { - switch (state) - { - case 0: - if (strcmp("DatabaseBackupInfo", context->path_bits[level + 1]) != 0) - { - _JobMessage(M_ERROR, "DatabaseBackupInfo file must exist and must be first in directory\n"); - state = 999; - break; - } - dbi_node = new dbi_node_t(bstrdup(context->path_bits[level + 1]), this); - context->current_node = dbi_node; - return bRC_OK; - case 1: - if (strcmp(context->path_bits[level - 1], parent->name) != 0) - { - _JobMessage(M_ERROR, "Unexpected Storage Group Change\n"); - state = 999; - break; - } - - if (*stream_ptr != 0) - { - // verify that stream_ptr == context->path_bits[level + 1]; - _DebugMessage(150, "stream_ptr = %S\n", stream_ptr); - _DebugMessage(150, "out_stream_ptr = %S\n", out_stream_ptr); - file_node = new file_node_t(bstrdup(context->path_bits[level + 1]), this); - file_node->hccx = hccx; - file_node->filename = out_stream_ptr; - context->current_node = file_node; - return bRC_OK; - } - else - { - _JobMessage(M_ERROR, "Extra file found '%s'\n", full_path); - state = 999; - break; - } - case 2: - if (rp->type != FT_DIREND) - { - _JobMessage(M_ERROR, "Unexpected file '%s'\n", full_path); - state = 999; - break; - } - rp->create_status = CF_CREATED; - return bRC_OK; - case 999: - if (strcmp(context->path_bits[level], name) != 0) - { - _DebugMessage(0, "End of Store when in error state - switching back to parent\n", state); - context->current_node = parent; - return bRC_OK; - } - rp->create_status = CF_CREATED; - return bRC_OK; - } - } + _DebugMessage(0, "createFile_STORE state = %d\n", state); + + if (strcmp(context->path_bits[level - 1], parent->name) != 0) + { + _DebugMessage(0, "Different storage group - switching back to parent\n", state); + context->current_node = parent; + return bRC_OK; + } + for (;;) + { + switch (state) + { + case 0: + if (strcmp("DatabaseBackupInfo", context->path_bits[level + 1]) != 0) + { + _JobMessage(M_ERROR, "DatabaseBackupInfo file must exist and must be first in directory\n"); + state = 999; + break; + } + dbi_node = new dbi_node_t(bstrdup(context->path_bits[level + 1]), this); + context->current_node = dbi_node; + return bRC_OK; + case 1: + if (strcmp(context->path_bits[level - 1], parent->name) != 0) + { + _JobMessage(M_ERROR, "Unexpected Storage Group Change\n"); + state = 999; + break; + } + + if (*stream_ptr != 0) + { + // verify that stream_ptr == context->path_bits[level + 1]; + _DebugMessage(150, "stream_ptr = %S\n", stream_ptr); + _DebugMessage(150, "out_stream_ptr = %S\n", out_stream_ptr); + file_node = new file_node_t(bstrdup(context->path_bits[level + 1]), this); + file_node->hccx = hccx; + file_node->filename = out_stream_ptr; + context->current_node = file_node; + return bRC_OK; + } + else + { + _JobMessage(M_ERROR, "Extra file found '%s'\n", full_path); + state = 999; + break; + } + case 2: + if (rp->type != FT_DIREND) + { + _JobMessage(M_ERROR, "Unexpected file '%s'\n", full_path); + state = 999; + break; + } + rp->create_status = CF_CREATED; + return bRC_OK; + case 999: + if (strcmp(context->path_bits[level], name) != 0) + { + _DebugMessage(0, "End of Store when in error state - switching back to parent\n", state); + context->current_node = parent; + return bRC_OK; + } + rp->create_status = CF_CREATED; + return bRC_OK; + } + } } bRC store_node_t::endRestoreFile(exchange_fd_context_t *context) { - HRESULT result; - - _DebugMessage(0, "endRestoreFile_STORE state = %d\n", state); - for (;;) - { - switch (state) - { - case 0: - state = 1; - _DebugMessage(0, "Calling HrESERestoreAddDatabase\n"); - result = HrESERestoreAddDatabase(hccx, dbi_node->restore_display_name, dbi_node->restore_guid, dbi_node->restore_input_streams, &dbi_node->restore_output_streams); - if (result != 0) - { - _JobMessage(M_ERROR, "HrESERestoreAddDatabase failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); - state = 999; - break; - } - stream_ptr = dbi_node->restore_input_streams; - out_stream_ptr = dbi_node->restore_output_streams; - return bRC_OK; - case 1: - if (*stream_ptr != 0) - { - delete file_node; - file_node = NULL; - stream_ptr += wcslen(stream_ptr) + 1; - out_stream_ptr += wcslen(out_stream_ptr) + 1; - if (*stream_ptr == 0) - state = 2; - return bRC_OK; - } - else - { - state = 999; - break; - } - case 2: - context->current_node = parent; - return bRC_OK; - case 999: - return bRC_OK; - } - } + HRESULT result; + + _DebugMessage(0, "endRestoreFile_STORE state = %d\n", state); + for (;;) + { + switch (state) + { + case 0: + state = 1; + _DebugMessage(0, "Calling HrESERestoreAddDatabase\n"); + result = HrESERestoreAddDatabase(hccx, dbi_node->restore_display_name, dbi_node->restore_guid, dbi_node->restore_input_streams, &dbi_node->restore_output_streams); + if (result != 0) + { + _JobMessage(M_ERROR, "HrESERestoreAddDatabase failed with error 0x%08x - %s\n", result, ESEErrorMessage(result)); + state = 999; + break; + } + stream_ptr = dbi_node->restore_input_streams; + out_stream_ptr = dbi_node->restore_output_streams; + return bRC_OK; + case 1: + if (*stream_ptr != 0) + { + delete file_node; + file_node = NULL; + stream_ptr += wcslen(stream_ptr) + 1; + out_stream_ptr += wcslen(out_stream_ptr) + 1; + if (*stream_ptr == 0) + state = 2; + return bRC_OK; + } + else + { + state = 999; + break; + } + case 2: + context->current_node = parent; + return bRC_OK; + case 999: + return bRC_OK; + } + } } -- 2.39.5