]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/winapi.h
Remove new bnet_sig
[bacula/bacula] / bacula / src / lib / winapi.h
1 /*
2  * Windows APIs that are different for each system.
3  *   We use pointers to the entry points so that a
4  *   single binary will run on all Windows systems.
5  *
6  *     Kern Sibbald MMIII
7  */
8 /*
9    Copyright (C) 2000-2005 Kern Sibbald
10
11    This program is free software; you can redistribute it and/or
12    modify it under the terms of the GNU General Public License as
13    published by the Free Software Foundation; either version 2 of
14    the License, or (at your option) any later version.
15
16    This program is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19    General Public License for more details.
20
21    You should have received a copy of the GNU General Public
22    License along with this program; if not, write to the Free
23    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
24    MA 02111-1307, USA.
25
26  */
27
28 #ifndef __WINAPI_H
29 #define __WINAPI_H
30
31 #if defined(HAVE_WIN32)
32 /*
33  * Commented out native.h include statement, which is not distributed with the
34  * free version of VC++, and which is not used in bacula.
35  * 
36  * #if !defined(HAVE_MINGW) // native.h not present on mingw
37  * #include <native.h>
38  * #endif
39  */
40 #include <windef.h>
41 #endif
42
43 #if defined(HAVE_CYGWIN) || defined(HAVE_WIN32)
44
45 #ifndef POOLMEM
46 typedef char POOLMEM;
47 #endif
48
49 // unicode enabling of win 32 needs some defines and functions
50 #define MAX_PATH_UTF8    MAX_PATH*3
51
52 int wchar_2_UTF8(char *pszUTF, const WCHAR *pszUCS, int cchChar = MAX_PATH_UTF8);
53 int UTF8_2_wchar(POOLMEM **pszUCS, const char *pszUTF);
54
55
56 /* In ADVAPI32.DLL */
57
58 typedef BOOL (WINAPI * t_OpenProcessToken)(HANDLE, DWORD, PHANDLE);
59 typedef BOOL (WINAPI * t_AdjustTokenPrivileges)(HANDLE, BOOL,
60           PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD);
61 typedef BOOL (WINAPI * t_LookupPrivilegeValue)(LPCTSTR, LPCTSTR, PLUID);
62
63 extern t_OpenProcessToken      p_OpenProcessToken;
64 extern t_AdjustTokenPrivileges p_AdjustTokenPrivileges;
65 extern t_LookupPrivilegeValue  p_LookupPrivilegeValue;
66
67 /* In MSVCRT.DLL */
68 typedef int (__cdecl * t_wunlink) (const wchar_t *);
69 typedef int (__cdecl * t_wmkdir) (const wchar_t *);
70 typedef int (__cdecl * t_wopen)  (const wchar_t *, int, ...);
71
72 extern t_wunlink   p_wunlink;
73 extern t_wmkdir    p_wmkdir;
74 extern t_wopen     p_wopen;
75
76 /* In KERNEL32.DLL */
77 typedef BOOL (WINAPI * t_GetFileAttributesExA)(LPCSTR, GET_FILEEX_INFO_LEVELS,
78        LPVOID);
79 typedef BOOL (WINAPI * t_GetFileAttributesExW)(LPCWSTR, GET_FILEEX_INFO_LEVELS,
80        LPVOID);
81
82 typedef DWORD (WINAPI * t_GetFileAttributesA)(LPCSTR);
83 typedef DWORD (WINAPI * t_GetFileAttributesW)(LPCWSTR);
84 typedef BOOL (WINAPI * t_SetFileAttributesA)(LPCSTR, DWORD);
85 typedef BOOL (WINAPI * t_SetFileAttributesW)(LPCWSTR, DWORD);
86
87 typedef HANDLE (WINAPI * t_CreateFileA) (LPCSTR, DWORD ,DWORD, LPSECURITY_ATTRIBUTES,
88         DWORD , DWORD, HANDLE);
89 typedef HANDLE (WINAPI * t_CreateFileW) (LPCWSTR, DWORD ,DWORD, LPSECURITY_ATTRIBUTES,
90         DWORD , DWORD, HANDLE);
91
92 typedef BOOL (WINAPI * t_SetProcessShutdownParameters)(DWORD, DWORD);
93 typedef BOOL (WINAPI * t_BackupRead)(HANDLE,LPBYTE,DWORD,LPDWORD,BOOL,BOOL,LPVOID*);
94 typedef BOOL (WINAPI * t_BackupWrite)(HANDLE,LPBYTE,DWORD,LPDWORD,BOOL,BOOL,LPVOID*);
95
96 typedef int (WINAPI * t_WideCharToMultiByte) (UINT CodePage, DWORD , LPCWSTR, int,
97                                               LPSTR, int, LPCSTR, LPBOOL);
98
99 typedef int (WINAPI * t_MultiByteToWideChar) (UINT, DWORD, LPCSTR, int, LPWSTR, int);
100 typedef HANDLE (WINAPI * t_FindFirstFileA) (LPCSTR, LPWIN32_FIND_DATAA);
101 typedef HANDLE (WINAPI * t_FindFirstFileW) (LPCWSTR, LPWIN32_FIND_DATAW);
102
103 typedef BOOL (WINAPI * t_FindNextFileA) (HANDLE, LPWIN32_FIND_DATAA);
104 typedef BOOL (WINAPI * t_FindNextFileW) (HANDLE, LPWIN32_FIND_DATAW);
105
106 typedef BOOL (WINAPI * t_SetCurrentDirectoryA) (LPCSTR);
107 typedef BOOL (WINAPI * t_SetCurrentDirectoryW) (LPCWSTR);
108
109 typedef DWORD (WINAPI * t_GetCurrentDirectoryA) (DWORD, LPSTR);
110 typedef DWORD (WINAPI * t_GetCurrentDirectoryW) (DWORD, LPWSTR);
111
112 typedef BOOL (WINAPI * t_GetVolumePathNameW) (LPCWSTR, LPWSTR, DWORD);
113 typedef BOOL (WINAPI * t_GetVolumeNameForVolumeMountPointW) (LPCWSTR, LPWSTR, DWORD);
114   
115 extern t_GetFileAttributesA   p_GetFileAttributesA;
116 extern t_GetFileAttributesW   p_GetFileAttributesW;
117
118 extern t_GetFileAttributesExA   p_GetFileAttributesExA;
119 extern t_GetFileAttributesExW   p_GetFileAttributesExW;
120
121 extern t_SetFileAttributesA   p_SetFileAttributesA;
122 extern t_SetFileAttributesW   p_SetFileAttributesW;
123
124 extern t_CreateFileA   p_CreateFileA;
125 extern t_CreateFileW   p_CreateFileW;
126 extern t_SetProcessShutdownParameters p_SetProcessShutdownParameters;
127 extern t_BackupRead         p_BackupRead;
128 extern t_BackupWrite        p_BackupWrite;
129
130 extern t_WideCharToMultiByte p_WideCharToMultiByte;
131 extern t_MultiByteToWideChar p_MultiByteToWideChar;
132
133 extern t_FindFirstFileA p_FindFirstFileA;
134 extern t_FindFirstFileW p_FindFirstFileW;
135
136 extern t_FindNextFileA p_FindNextFileA;
137 extern t_FindNextFileW p_FindNextFileW;
138
139 extern t_SetCurrentDirectoryA p_SetCurrentDirectoryA;
140 extern t_SetCurrentDirectoryW p_SetCurrentDirectoryW;
141
142 extern t_GetCurrentDirectoryA p_GetCurrentDirectoryA;
143 extern t_GetCurrentDirectoryW p_GetCurrentDirectoryW;
144
145 extern t_GetVolumePathNameW p_GetVolumePathNameW;
146 extern t_GetVolumeNameForVolumeMountPointW p_GetVolumeNameForVolumeMountPointW;
147           
148 #ifdef WIN32_VSS
149 class  VSSClient;
150 extern VSSClient* g_pVSSClient;
151 #endif
152
153 void InitWinAPIWrapper();
154 #endif
155
156 #endif /* __WINAPI_H */