]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/winapi.c
Strip pathname portion off all message routines that print filename:line.
[bacula/bacula] / bacula / src / lib / winapi.c
index 976a33a24c2d7bffce1329ab8f89930155313348..58a20fd715891fb254510b92160a9e4b0176fc05 100644 (file)
@@ -6,31 +6,32 @@
  *     Kern Sibbald MMIII
  */
 /*
-   Copyright (C) 2000-2005 Kern Sibbald
+   Copyright (C) 2003-2006 Kern Sibbald
 
    This program is free software; you can redistribute it and/or
-   modify it under the terms of the GNU General Public License as
-   published by the Free Software Foundation; either version 2 of
-   the License, or (at your option) any later version.
+   modify it under the terms of the GNU General Public License
+   version 2 as amended with additional clauses defined in the
+   file LICENSE in the main source directory.
 
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-   General Public License for more details.
-
-   You should have received a copy of the GNU General Public
-   License along with this program; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
-   MA 02111-1307, USA.
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
+   the file LICENSE for additional details.
 
  */
 
+#ifdef __APCUPSD__
+#include "apc.h"
+#else
 #include "bacula.h"
+#endif
 
 #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
 
 #include "winapi.h"
 
+int win32_client = 1;
+
 #ifdef WIN32_VSS
 #include "vss.h"   
 #endif
 DWORD  g_platform_id = VER_PLATFORM_WIN32_WINDOWS;
 #ifdef WIN32_VSS
 /* preset VSSClient to NULL */
-VSSClientg_pVSSClient = NULL;
+VSSClient *g_pVSSClient = NULL;
 #endif
 
 
 /* API Pointers */
 
-t_OpenProcessToken     p_OpenProcessToken = NULL;
+t_OpenProcessToken      p_OpenProcessToken = NULL;
 t_AdjustTokenPrivileges p_AdjustTokenPrivileges = NULL;
-t_LookupPrivilegeValue p_LookupPrivilegeValue = NULL;
+t_LookupPrivilegeValue  p_LookupPrivilegeValue = NULL;
 
 t_SetProcessShutdownParameters p_SetProcessShutdownParameters = NULL;
 
-t_CreateFileA  p_CreateFileA = NULL;
-t_CreateFileW  p_CreateFileW = NULL;
+t_CreateFileA   p_CreateFileA = NULL;
+t_CreateFileW   p_CreateFileW = NULL;
+t_CreateDirectoryA   p_CreateDirectoryA;
+t_CreateDirectoryW   p_CreateDirectoryW;
 
 t_wunlink p_wunlink = NULL;
 t_wmkdir p_wmkdir = NULL;
 t_wopen p_wopen = NULL;
 
-t_GetFileAttributesA   p_GetFileAttributesA = NULL;
-t_GetFileAttributesW   p_GetFileAttributesW = NULL;
+t_GetFileAttributesA    p_GetFileAttributesA = NULL;
+t_GetFileAttributesW    p_GetFileAttributesW = NULL;
 
-t_GetFileAttributesExA p_GetFileAttributesExA = NULL;
-t_GetFileAttributesExW p_GetFileAttributesExW = NULL;
+t_GetFileAttributesExA  p_GetFileAttributesExA = NULL;
+t_GetFileAttributesExW  p_GetFileAttributesExW = NULL;
 
-t_SetFileAttributesA   p_SetFileAttributesA = NULL;
-t_SetFileAttributesW   p_SetFileAttributesW = NULL;
-t_BackupRead           p_BackupRead = NULL;
-t_BackupWrite          p_BackupWrite = NULL;
+t_SetFileAttributesA    p_SetFileAttributesA = NULL;
+t_SetFileAttributesW    p_SetFileAttributesW = NULL;
+t_BackupRead            p_BackupRead = NULL;
+t_BackupWrite           p_BackupWrite = NULL;
 t_WideCharToMultiByte p_WideCharToMultiByte = NULL;
 t_MultiByteToWideChar p_MultiByteToWideChar = NULL;
 
@@ -83,6 +86,9 @@ t_SetCurrentDirectoryW p_SetCurrentDirectoryW = NULL;
 t_GetCurrentDirectoryA p_GetCurrentDirectoryA = NULL;
 t_GetCurrentDirectoryW p_GetCurrentDirectoryW = NULL;
 
+t_GetVolumePathNameW p_GetVolumePathNameW = NULL;
+t_GetVolumeNameForVolumeMountPointW p_GetVolumeNameForVolumeMountPointW = NULL;
+
 #ifdef WIN32_VSS
 void 
 VSSCleanup()
@@ -103,6 +109,11 @@ InitWinAPIWrapper()
       p_CreateFileW = (t_CreateFileW)
           GetProcAddress(hLib, "CreateFileW");      
 
+      p_CreateDirectoryA = (t_CreateDirectoryA)
+          GetProcAddress(hLib, "CreateDirectoryA");
+      p_CreateDirectoryW = (t_CreateDirectoryW)
+          GetProcAddress(hLib, "CreateDirectoryW");      
+
       /* attribute calls */
       p_GetFileAttributesA = (t_GetFileAttributesA)
           GetProcAddress(hLib, "GetFileAttributesA");
@@ -148,6 +159,14 @@ InitWinAPIWrapper()
           GetProcAddress(hLib, "GetCurrentDirectoryA");
       p_GetCurrentDirectoryW = (t_GetCurrentDirectoryW)
           GetProcAddress(hLib, "GetCurrentDirectoryW");      
+
+      /* some special stuff we need for VSS
+         but statically linkage doesn't work on Win 9x */
+      p_GetVolumePathNameW = (t_GetVolumePathNameW)
+          GetProcAddress(hLib, "GetVolumePathNameW");
+      p_GetVolumeNameForVolumeMountPointW = (t_GetVolumeNameForVolumeMountPointW)
+          GetProcAddress(hLib, "GetVolumeNameForVolumeMountPointW");
+    
       FreeLibrary(hLib);
    }
    
@@ -162,7 +181,7 @@ InitWinAPIWrapper()
       /* wopen */
       p_wopen = (t_wopen)
       GetProcAddress(hLib, "_wopen");
-       
+        
       FreeLibrary(hLib);
    }
    
@@ -197,12 +216,12 @@ InitWinAPIWrapper()
       p_BackupRead = NULL;
       p_BackupWrite = NULL;
 
-      p_CreateFileW = NULL;         
-      p_GetFileAttributesW = NULL;         
+      p_CreateFileW = NULL;          
+      p_GetFileAttributesW = NULL;          
       p_GetFileAttributesExW = NULL;
-         
+          
       p_SetFileAttributesW = NULL;
-               
+                
       p_FindFirstFileW = NULL;
       p_FindNextFileW = NULL;
       p_SetCurrentDirectoryW = NULL;
@@ -211,21 +230,30 @@ InitWinAPIWrapper()
       p_wunlink = NULL;
       p_wmkdir = NULL;
       p_wopen = NULL;
+
+      p_GetVolumePathNameW = NULL;
+      p_GetVolumeNameForVolumeMountPointW = NULL;
    }   
 
    /* decide which vss class to initialize */
 #ifdef WIN32_VSS
    switch (dwMinorVersion) {
       case 1: 
-        g_pVSSClient = new VSSClientXP();
-        atexit(VSSCleanup);
-        break;
+         g_pVSSClient = new VSSClientXP();
+         atexit(VSSCleanup);
+         break;
       case 2: 
-        g_pVSSClient = new VSSClient2003();
-        atexit(VSSCleanup);
-        break;
+         g_pVSSClient = new VSSClient2003();
+         atexit(VSSCleanup);
+         break;
    }
-#endif
+#endif /* WIN32_VSS */
+   atexit(Win32ConvCleanupCache);
 }
 
+#else
+
+/* Not Windows */
+int win32_client = 0;
+
 #endif