]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/lib/winapi.h
Move winapi.h/c from findlib to lib for inclusion in multiple places
[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 // unicode enabling of win 32 needs some defines and functions
46 #define MAX_PATH_UNICODE 32767
47 #define MAX_PATH_UTF8    MAX_PATH*3
48
49 int wchar_2_UTF8(char *pszUTF, const WCHAR *pszUCS, int cchChar = MAX_PATH_UTF8);
50 int UTF8_2_wchar(WCHAR *pszUCS, const char *pszUTF, int cchWideChar = MAX_PATH);
51
52
53 /* In ADVAPI32.DLL */
54
55 typedef BOOL (WINAPI * t_OpenProcessToken)(HANDLE, DWORD, PHANDLE);
56 typedef BOOL (WINAPI * t_AdjustTokenPrivileges)(HANDLE, BOOL,
57           PTOKEN_PRIVILEGES, DWORD, PTOKEN_PRIVILEGES, PDWORD);
58 typedef BOOL (WINAPI * t_LookupPrivilegeValue)(LPCTSTR, LPCTSTR, PLUID);
59
60 extern t_OpenProcessToken      p_OpenProcessToken;
61 extern t_AdjustTokenPrivileges p_AdjustTokenPrivileges;
62 extern t_LookupPrivilegeValue  p_LookupPrivilegeValue;
63
64 /* In MSVCRT.DLL */
65 typedef int (__cdecl * t_wunlink) (const wchar_t *);
66 typedef int (__cdecl * t_wmkdir) (const wchar_t *);
67 typedef int (__cdecl * t_wopen)  (const wchar_t *, int, ...);
68
69 extern t_wunlink   p_wunlink;
70 extern t_wmkdir    p_wmkdir;
71 extern t_wopen     p_wopen;
72 /* In KERNEL32.DLL */
73 typedef BOOL (WINAPI * t_GetFileAttributesExA)(LPCSTR, GET_FILEEX_INFO_LEVELS,
74        LPVOID);
75 typedef BOOL (WINAPI * t_GetFileAttributesExW)(LPCWSTR, GET_FILEEX_INFO_LEVELS,
76        LPVOID);
77
78 typedef DWORD (WINAPI * t_GetFileAttributesA)(LPCSTR);
79 typedef DWORD (WINAPI * t_GetFileAttributesW)(LPCWSTR);
80 typedef BOOL (WINAPI * t_SetFileAttributesA)(LPCSTR, DWORD);
81 typedef BOOL (WINAPI * t_SetFileAttributesW)(LPCWSTR, DWORD);
82
83 typedef HANDLE (WINAPI * t_CreateFileA) (LPCSTR, DWORD ,DWORD, LPSECURITY_ATTRIBUTES,
84         DWORD , DWORD, HANDLE);
85 typedef HANDLE (WINAPI * t_CreateFileW) (LPCWSTR, DWORD ,DWORD, LPSECURITY_ATTRIBUTES,
86         DWORD , DWORD, HANDLE);
87
88 typedef BOOL (WINAPI * t_SetProcessShutdownParameters)(DWORD, DWORD);
89 typedef BOOL (WINAPI * t_BackupRead)(HANDLE,LPBYTE,DWORD,LPDWORD,BOOL,BOOL,LPVOID*);
90 typedef BOOL (WINAPI * t_BackupWrite)(HANDLE,LPBYTE,DWORD,LPDWORD,BOOL,BOOL,LPVOID*);
91
92 typedef int (WINAPI * t_WideCharToMultiByte) (UINT CodePage, DWORD , LPCWSTR, int,
93                                               LPSTR, int, LPCSTR, LPBOOL);
94
95 typedef int (WINAPI * t_MultiByteToWideChar) (UINT, DWORD, LPCSTR, int, LPWSTR, int);
96 typedef HANDLE (WINAPI * t_FindFirstFileA) (LPCSTR, LPWIN32_FIND_DATAA);
97 typedef HANDLE (WINAPI * t_FindFirstFileW) (LPCWSTR, LPWIN32_FIND_DATAW);
98
99 typedef BOOL (WINAPI * t_FindNextFileA) (HANDLE, LPWIN32_FIND_DATAA);
100 typedef BOOL (WINAPI * t_FindNextFileW) (HANDLE, LPWIN32_FIND_DATAW);
101
102 typedef BOOL (WINAPI * t_SetCurrentDirectoryA) (LPCSTR);
103 typedef BOOL (WINAPI * t_SetCurrentDirectoryW) (LPCWSTR);
104
105 typedef DWORD (WINAPI * t_GetCurrentDirectoryA) (DWORD, LPSTR);
106 typedef DWORD (WINAPI * t_GetCurrentDirectoryW) (DWORD, LPWSTR);
107
108 extern t_GetFileAttributesA   p_GetFileAttributesA;
109 extern t_GetFileAttributesW   p_GetFileAttributesW;
110
111 extern t_GetFileAttributesExA   p_GetFileAttributesExA;
112 extern t_GetFileAttributesExW   p_GetFileAttributesExW;
113
114 extern t_SetFileAttributesA   p_SetFileAttributesA;
115 extern t_SetFileAttributesW   p_SetFileAttributesW;
116
117 extern t_CreateFileA   p_CreateFileA;
118 extern t_CreateFileW   p_CreateFileW;
119 extern t_SetProcessShutdownParameters p_SetProcessShutdownParameters;
120 extern t_BackupRead         p_BackupRead;
121 extern t_BackupWrite        p_BackupWrite;
122
123 extern t_WideCharToMultiByte p_WideCharToMultiByte;
124 extern t_MultiByteToWideChar p_MultiByteToWideChar;
125
126 extern t_FindFirstFileA p_FindFirstFileA;
127 extern t_FindFirstFileW p_FindFirstFileW;
128
129 extern t_FindNextFileA p_FindNextFileA;
130 extern t_FindNextFileW p_FindNextFileW;
131
132 extern t_SetCurrentDirectoryA p_SetCurrentDirectoryA;
133 extern t_SetCurrentDirectoryW p_SetCurrentDirectoryW;
134
135 extern t_GetCurrentDirectoryA p_GetCurrentDirectoryA;
136 extern t_GetCurrentDirectoryW p_GetCurrentDirectoryW;
137 #endif
138
139 #endif /* __WINAPI_H */