Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

399 lines
9.7 KiB

  1. //+----------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1996, Microsoft Corporation.
  4. //
  5. // All rights reserved.
  6. //
  7. // File: macport.h
  8. //
  9. // Synopsis: Defintions for unimplemented stubs & functions & structures
  10. // for the Macintosh.
  11. //
  12. //-----------------------------------------------------------------------------
  13. #ifndef _MACPORT_H_
  14. #define _MACPORT_H_
  15. //
  16. // WLM is REALLY bad about calling SetLastError when an error occurs. This
  17. // screws up the upper layer tests pretty badly. Use this macro when you
  18. // know an error exists and that error 0 (S_OK or ERROR_SUCCESS) is defitely
  19. // wrong.
  20. //
  21. #define HRESULT_FROM_ERROR(x) (x ? ((HRESULT) (((x) & 0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000)) : E_FAIL)
  22. #ifndef _MAC
  23. //
  24. // Stub out some Mac calls if were not building for the mac
  25. //
  26. #define MacInitializeCommandLine()
  27. #define FixHr(x) x
  28. #define MacGetFocus()
  29. //
  30. // Process ID's are completely different on the Mac then on Win32.
  31. //
  32. typedef DWORD ProcessId;
  33. #else // _MAC
  34. //
  35. // Ole types
  36. //
  37. #include <variant.h>
  38. #include <dispatch.h>
  39. typedef DWORD CLIPFORMAT;
  40. typedef void * HMETAFILEPICT;
  41. #define PHKEY unsigned long *
  42. typedef DWORD REGSAM;
  43. #define TYMED_ENHMF 64
  44. //
  45. // From wchar.h
  46. //
  47. #ifndef _WCTYPE_T_DEFINED
  48. typedef wchar_t wint_t;
  49. typedef wchar_t wctype_t;
  50. #define _WCTYPE_T_DEFINED
  51. #endif
  52. //
  53. // Wide-char string functions
  54. //
  55. int swprintf( wchar_t *buffer, const wchar_t *format, ... );
  56. int _snwprintf( wchar_t *buffer, size_t count, const wchar_t *format, ... );
  57. wchar_t towupper( wint_t c );
  58. size_t wcslen( const wchar_t *string );
  59. wchar_t *wcscpy( wchar_t *string1, const wchar_t *string2 );
  60. wchar_t *wcsncpy( wchar_t *string1, const wchar_t *string2, size_t count );
  61. int wcscmp( const wchar_t *string1, const wchar_t *string2 );
  62. int _wcsicmp( const wchar_t *string1, const wchar_t *string2 );
  63. wchar_t *wcscat( wchar_t *string1, const wchar_t *string2 );
  64. wchar_t * __cdecl wcschr(const wchar_t *string, wchar_t ch);
  65. wchar_t * __cdecl wcsrchr(const wchar_t *string, wchar_t ch);
  66. wchar_t *wcstok( wchar_t *string1, const wchar_t *string2 );
  67. int iswctype( wint_t c, wctype_t desc );
  68. wchar_t * __cdecl wcsstr(const wchar_t *, const wchar_t *);
  69. long __cdecl wcstol(const wchar_t *, wchar_t **, int);
  70. //
  71. // String conversion functions
  72. //
  73. WINBASEAPI
  74. int
  75. WINAPI
  76. MultiByteToWideChar(
  77. UINT CodePage,
  78. DWORD dwFlags,
  79. LPCSTR lpMultiByteStr,
  80. int cchMultiByte,
  81. LPWSTR lpWideCharStr,
  82. int cchWideChar);
  83. WINBASEAPI
  84. int
  85. WINAPI
  86. WideCharToMultiByte(
  87. UINT CodePage,
  88. DWORD dwFlags,
  89. LPCWSTR lpWideCharStr,
  90. int cchWideChar,
  91. LPSTR lpMultiByteStr,
  92. int cchMultiByte,
  93. LPCSTR lpDefaultChar,
  94. LPBOOL lpUsedDefaultChar);
  95. #define CP_ACP 0
  96. #define CP_OEMCP 1
  97. #define CP_MACCP 2
  98. //
  99. // More miscellaneous string things
  100. //
  101. LANGID GetSystemDefaultLangID();
  102. #ifndef UNICODE_ONLY
  103. WINBASEAPI
  104. DWORD
  105. WINAPI
  106. FormatMessageA(
  107. DWORD dwFlags,
  108. LPCVOID lpSource,
  109. DWORD dwMessageId,
  110. DWORD dwLanguageId,
  111. LPSTR lpBuffer,
  112. DWORD nSize,
  113. va_list *Arguments
  114. );
  115. #endif //!UNICODE_ONLY
  116. #ifndef ANSI_ONLY
  117. WINBASEAPI
  118. DWORD
  119. WINAPI
  120. FormatMessageW(
  121. DWORD dwFlags,
  122. LPCVOID lpSource,
  123. DWORD dwMessageId,
  124. DWORD dwLanguageId,
  125. LPWSTR lpBuffer,
  126. DWORD nSize,
  127. va_list *Arguments
  128. );
  129. #endif //!ANSI_ONLY
  130. #ifdef UNICODE
  131. #define FormatMessage FormatMessageW
  132. #else
  133. #define FormatMessage FormatMessageA
  134. #endif // !UNICODE
  135. //
  136. // Network functions
  137. //
  138. typedef struct _NETRESOURCEA {
  139. DWORD dwScope;
  140. DWORD dwType;
  141. DWORD dwDisplayType;
  142. DWORD dwUsage;
  143. LPSTR lpLocalName;
  144. LPSTR lpRemoteName;
  145. LPSTR lpComment ;
  146. LPSTR lpProvider;
  147. }NETRESOURCEA, *LPNETRESOURCEA;
  148. typedef struct _NETRESOURCEW {
  149. DWORD dwScope;
  150. DWORD dwType;
  151. DWORD dwDisplayType;
  152. DWORD dwUsage;
  153. LPWSTR lpLocalName;
  154. LPWSTR lpRemoteName;
  155. LPWSTR lpComment ;
  156. LPWSTR lpProvider;
  157. }NETRESOURCEW, *LPNETRESOURCEW;
  158. #ifdef UNICODE
  159. typedef NETRESOURCEW NETRESOURCE;
  160. typedef LPNETRESOURCEW LPNETRESOURCE;
  161. #else
  162. typedef NETRESOURCEA NETRESOURCE;
  163. typedef LPNETRESOURCEA LPNETRESOURCE;
  164. #endif // UNICODE
  165. #define RESOURCETYPE_ANY 0x00000000
  166. #define RESOURCETYPE_DISK 0x00000001
  167. #define RESOURCETYPE_PRINT 0x00000002
  168. #define RESOURCETYPE_RESERVED 0x00000008
  169. #define RESOURCETYPE_UNKNOWN 0xFFFFFFFF
  170. DWORD APIENTRY
  171. WNetAddConnection2A(
  172. LPNETRESOURCEA lpNetResource,
  173. LPCSTR lpPassword,
  174. LPCSTR lpUserName,
  175. DWORD dwFlags
  176. );
  177. DWORD APIENTRY
  178. WNetAddConnection2W(
  179. LPNETRESOURCEW lpNetResource,
  180. LPCWSTR lpPassword,
  181. LPCWSTR lpUserName,
  182. DWORD dwFlags
  183. );
  184. #ifdef UNICODE
  185. #define WNetAddConnection2 WNetAddConnection2W
  186. #else
  187. #define WNetAddConnection2 WNetAddConnection2A
  188. #endif // !UNICODE
  189. DWORD APIENTRY
  190. WNetCancelConnectionA(
  191. LPCSTR lpName,
  192. BOOL fForce
  193. );
  194. DWORD APIENTRY
  195. WNetCancelConnectionW(
  196. LPCWSTR lpName,
  197. BOOL fForce
  198. );
  199. #ifdef UNICODE
  200. #define WNetCancelConnection WNetCancelConnectionW
  201. #else
  202. #define WNetCancelConnection WNetCancelConnectionA
  203. #endif // !UNICODE
  204. //
  205. // Command line functions
  206. //
  207. LPSTR GetCommandLineA();
  208. #define GetCommandLine GetCommandLineA
  209. HRESULT MacInitializeCommandLine();
  210. DWORD GetCurrentDirectoryA(
  211. DWORD nBufferLength, // size, in characters, of directory buffer
  212. LPTSTR lpBuffer // address of buffer for current directory
  213. );
  214. //
  215. // Registry functions
  216. //
  217. // Turn off WLM's registry wrappers so we can talk directory to the API's
  218. //
  219. #undef RegCloseKey
  220. #undef RegCreateKey
  221. #undef RegOpenKey
  222. #undef RegSetValue
  223. #undef RegSetValueEx
  224. #undef RegDeleteValue
  225. #undef RegQueryValue
  226. #undef RegQueryValueEx
  227. #undef RegEnumKeyEx
  228. #define RegSetValueEx CtRegSetValueEx
  229. #define RegQueryValueEx CtRegQueryValueEx
  230. LONG RegCreateKeyEx(
  231. HKEY hKey, // handle of an open key
  232. LPCTSTR lpSubKey, // address of subkey name
  233. DWORD Reserved, // reserved
  234. LPTSTR lpClass, // address of class string
  235. DWORD dwOptions, // special options flag
  236. REGSAM samDesired, // desired security access
  237. LPSECURITY_ATTRIBUTES lpSecurityAttributes, // address of key security structure
  238. PHKEY phkResult, // address of buffer for opened handle
  239. LPDWORD lpdwDisposition // address of disposition value buffer
  240. );
  241. LONG RegOpenKeyEx(
  242. HKEY hKey, // handle of open key
  243. LPCTSTR lpSubKey, // address of name of subkey to open
  244. DWORD ulOptions, // reserved
  245. REGSAM samDesired, // security access mask
  246. PHKEY phkResult // address of handle of open key
  247. );
  248. LONG CtRegSetValueEx(
  249. HKEY hKey, // handle of key to set value for
  250. LPCTSTR lpValueName, // address of value to set
  251. DWORD Reserved, // reserved
  252. DWORD dwType, // flag for value type
  253. CONST BYTE *lpData, // address of value data
  254. DWORD cbData // size of value data
  255. );
  256. LONG RegQueryValueEx(
  257. HKEY hKey, // handle of key to query
  258. LPTSTR lpValueName, // address of name of value to query
  259. LPDWORD lpReserved, // reserved
  260. LPDWORD lpType, // address of buffer for value type
  261. LPBYTE lpData, // address of data buffer
  262. LPDWORD lpcbData // address of data buffer size
  263. );
  264. LONG RegEnumKeyEx(
  265. HKEY hKey, // handle of key to enumerate
  266. DWORD dwIndex, // index of subkey to enumerate
  267. LPTSTR lpName, // address of buffer for subkey name
  268. LPDWORD lpcbName, // address for size of subkey buffer
  269. LPDWORD lpReserved, // reserved
  270. LPTSTR lpClass, // address of buffer for class string
  271. LPDWORD lpcbClass, // address for size of class buffer
  272. PFILETIME lpftLastWriteTime // address for time key last written to
  273. );
  274. //
  275. // Process ID's are completely different on the Mac then on Win32.
  276. //
  277. typedef ProcessSerialNumber ProcessId;
  278. #define GetCurrentProcessId MacGetCurrentProcessId
  279. #define OpenProcess MacOpenProcess
  280. #undef CreateProcess
  281. #define CreateProcess MacCreateProcess
  282. struct MAC_PROCESS_INFORMATION
  283. {
  284. HANDLE hProcess;
  285. HANDLE hThread;
  286. ProcessId dwProcessId;
  287. ProcessId dwThreadId;
  288. };
  289. typedef MAC_PROCESS_INFORMATION * LPMAC_PROCESS_INFORMATION;
  290. ProcessId MacGetCurrentProcessId();
  291. HANDLE MacOpenProcess(DWORD, BOOL, ProcessId);
  292. BOOL MacCreateProcess(
  293. LPCTSTR,
  294. LPTSTR,
  295. LPSECURITY_ATTRIBUTES,
  296. LPSECURITY_ATTRIBUTES,
  297. BOOL,
  298. DWORD,
  299. LPVOID,
  300. LPCTSTR,
  301. LPSTARTUPINFO,
  302. LPMAC_PROCESS_INFORMATION);
  303. #define PROCESS_INFORMATION MAC_PROCESS_INFORMATION
  304. #define LPPROCESS_INFORMATION LPMAC_PROCESS_INFORMATION
  305. //
  306. // The WLM IsBadXXX functions just check for NULL, but NULL is ok if the
  307. // byte count is 0.
  308. //
  309. // Use the weird trinary stuff to prevent warnings about constant boolean
  310. // expressions if c is a constant.
  311. //
  312. #define IsBadReadPtr(p, c) ((c) ? IsBadReadPtr((p), (c)) : FALSE)
  313. #define IsBadWritePtr(p, c) ((c) ? IsBadWritePtr((p), (c)) : FALSE)
  314. //
  315. // MacOle uses some old values for HRESULTs
  316. // (like 0x80000008 instead of 0x80004005 for E_FAIL)
  317. // This function just converts such old values to
  318. // new ones
  319. //
  320. HRESULT FixHr (HRESULT hrOld);
  321. //
  322. // On the mac, only the foreground app
  323. // can use the clipboard
  324. //
  325. void MacGetFocus ();
  326. BOOL MacIsFullPath (LPCSTR lpszFileName);
  327. #endif // _MAC
  328. #endif // _MACPORT_H_