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.

413 lines
15 KiB

  1. /*
  2. * M A P I W I N . H
  3. *
  4. * Definitions used by the MAPI Development Team to aid in
  5. * developing single-source service providers that run on
  6. * both WIN32 and WIN16 platforms.
  7. * There are three sections.
  8. *
  9. * The first section defines how to call something that
  10. * is available by different methods in WIN16 vs. WIN32.
  11. * As such, they are totally new mechanisms.
  12. *
  13. * The second section establishes things that are available
  14. * AS-IS in one environment but we have to define for the
  15. * other environment.
  16. *
  17. * The third section simply defines a few conventions
  18. * (simplifications) for common operations.
  19. *
  20. * Copyright 1993-1995 Microsoft Corporation. All Rights Reserved.
  21. */
  22. /*
  23. * Routines are included in the first section to manage per-instance
  24. * global variables for DLLs. They assume that all of the DLL's
  25. * per-instance global variables live in a single block of memory.
  26. * Functions are provided to install and retrieve the correct block of
  27. * memory for the current instance.
  28. *
  29. * There are only two functions:
  30. *
  31. * PvGetInstanceGlobals Call this to get the address of the
  32. * per-instance globals structure.
  33. * ScSetinstanceGlobals Call this to install the
  34. * per-instance globals structure. It
  35. * may fail if the number of instances
  36. * exceeds a certain limit.
  37. *
  38. * The caller is free to choose the name, size, and allocation
  39. * method of the per-instance global variables structure.
  40. *
  41. * The WIN32 implementation uses a pointer in the DLL's data
  42. * segment. This assumes that the DLL gets a separate instance
  43. * of the default data segment per calling process.
  44. *
  45. * The WIN16 implementation uses a fixed array of pointers and a
  46. * matching fixed array of keys unique to the calling process.
  47. */
  48. /*
  49. * The second section consists largely of Win32 file I/O functions
  50. * that are not supported under Win16. These functions are
  51. * implemented in mapiwin.c, using DOS calls. Most have limitations
  52. * relative to their Win32 counterparts, which are spelled out in
  53. * the comments to the source code.
  54. */
  55. #ifndef __MAPIWIN_H__
  56. #define __MAPIWIN_H__
  57. #include "mapinls.h"
  58. #ifdef __cplusplus
  59. extern "C" {
  60. #endif
  61. /********************************/
  62. /* Our conventions for things */
  63. /* we choose to do differently */
  64. /* on WIN16 vs. WIN32. */
  65. /********************************/
  66. #ifdef WIN16
  67. #define MULDIV(x,y,z) MulDiv32(x,y,z)
  68. #define IsBadReadPtr(lp,cb) FBadReadPtr(lp,cb)
  69. #define cInstMax 50
  70. LPVOID FAR PASCAL PvGetInstanceGlobals(void);
  71. LONG FAR PASCAL ScSetInstanceGlobals(LPVOID pv);
  72. LONG FAR PASCAL ScSetVerifyInstanceGlobals(LPVOID pv, DWORD dwPid);
  73. LPVOID FAR PASCAL PvGetVerifyInstanceGlobals(DWORD dwPid);
  74. LPVOID FAR PASCAL PvSlowGetInstanceGlobals(DWORD dwPid);
  75. BOOL __export FAR PASCAL FCleanupInstanceGlobals(WORD, DWORD);
  76. #elif defined(MAC) /* !WIN16 */
  77. #define MULDIV(x,y,z) MulDiv(x,y,z)
  78. LPVOID FAR PASCAL PvGetInstanceGlobals(WORD wDataSet);
  79. LONG FAR PASCAL ScSetInstanceGlobals(LPVOID pv, WORD wDataSet);
  80. LONG FAR PASCAL ScSetVerifyInstanceGlobals(LPVOID pv, DWORD dwPid,
  81. WORD wDataSet);
  82. LPVOID FAR PASCAL PvGetVerifyInstanceGlobals(DWORD dwPid, DWORD wDataSet);
  83. LPVOID FAR PASCAL PvSlowGetInstanceGlobals(DWORD dwPid, DWORD wDataSet);
  84. BOOL FAR PASCAL FCleanupInstanceGlobals(WORD, DWORD);
  85. #else /* !WIN16 */
  86. #define MULDIV(x,y,z) MulDiv(x,y,z)
  87. extern LPVOID pinstX;
  88. #define PvGetInstanceGlobals() pinstX
  89. #define ScSetInstanceGlobals(_pv) (pinstX = _pv, 0)
  90. #define PvGetVerifyInstanceGlobals(_pid) pinstX
  91. #define ScSetVerifyInstanceGlobals(_pv,_pid) (pinstX = _pv, 0)
  92. #define PvSlowGetInstanceGlobals(_pid) pinstX
  93. #endif /* WIN16 */
  94. #if defined(CHICAGO)
  95. #define szMAPIDLLSuffix "32"
  96. #elif defined(WIN32) && !defined(MAC)
  97. #define szMAPIDLLSuffix "32"
  98. #elif defined(WIN16) || defined(DOS) || defined(MAC)
  99. #define szMAPIDLLSuffix ""
  100. #else
  101. #error "Don't know the suffix for DLLs on this platform"
  102. #endif
  103. /********************************/
  104. /* Things missing from one */
  105. /* system-provided environment */
  106. /* or the other. */
  107. /********************************/
  108. #if !defined(WIN32)
  109. #define ZeroMemory(pb,cb) memset((pb),0,(cb))
  110. #define FillMemory(pb,cb,b) memset((pb),(b),(cb))
  111. #define CopyMemory(pbDst,pbSrc,cb) do \
  112. { \
  113. size_t _cb = (size_t)(cb); \
  114. if (_cb) \
  115. memcpy(pbDst,pbSrc,_cb);\
  116. } while (FALSE)
  117. #define MoveMemory(pbDst,pbSrc,cb) memmove((pbDst),(pbSrc),(cb))
  118. #endif
  119. #if defined(WIN16) || defined(MAC)
  120. #ifndef MAC
  121. #include <error.h> /* for GetLastError() */
  122. #endif
  123. typedef int INT;
  124. typedef unsigned long ULONG;
  125. typedef short SHORT;
  126. typedef unsigned short USHORT;
  127. typedef double LONGLONG;
  128. typedef double DWORDLONG;
  129. typedef unsigned char UCHAR;
  130. typedef unsigned char FAR* PUCHAR;
  131. typedef int BOOL;
  132. #ifndef MAC
  133. typedef char BOOLEAN;
  134. #ifndef _FILETIME_
  135. #define _FILETIME_
  136. typedef struct tagFILETIME
  137. {
  138. DWORD dwLowDateTime;
  139. DWORD dwHighDateTime;
  140. } FILETIME;
  141. #endif /* _FILETIME */
  142. typedef struct _SYSTEMTIME {
  143. WORD wYear;
  144. WORD wMonth;
  145. WORD wDayOfWeek;
  146. WORD wDay;
  147. WORD wHour;
  148. WORD wMinute;
  149. WORD wSecond;
  150. WORD wMilliseconds;
  151. } SYSTEMTIME, *PSYSTEMTIME, FAR *LPSYSTEMTIME;
  152. typedef struct _TIME_ZONE_INFORMATION {
  153. LONG Bias;
  154. CHAR StandardName[ 32 ]; /* was WCHAR */
  155. SYSTEMTIME StandardDate;
  156. LONG StandardBias;
  157. CHAR DaylightName[ 32 ]; /* was WCHAR */
  158. SYSTEMTIME DaylightDate;
  159. LONG DaylightBias;
  160. } TIME_ZONE_INFORMATION, *PTIME_ZONE_INFORMATION, FAR *LPTIME_ZONE_INFORMATION;
  161. #define TEXT(quote) quote
  162. #define APIENTRY WINAPI
  163. #define SetForegroundWindow SetActiveWindow
  164. #define wsprintfA wsprintf
  165. #define GetWindowsDirectoryA GetWindowsDirectory
  166. #define GetSystemDirectoryA GetSystemDirectory
  167. #define GetPrivateProfileStringA GetPrivateProfileString
  168. #define GetPrivateProfileIntA GetPrivateProfileInt
  169. #define GetProfileStringA GetProfileString
  170. #define GetModuleFileNameA GetModuleFileName
  171. #define CharUpperBuffA CharUpperBuff
  172. #define LoadLibraryA LoadLibrary
  173. #define lstrcatA lstrcat
  174. #define RegisterWindowMessageA RegisterWindowMessage
  175. #define MAKEINTRESOURCEA MAKEINTRESOURCE
  176. #define WNDCLASSA WNDCLASS
  177. #endif /* !MAC */
  178. /* Synchronization */
  179. #define InterlockedIncrement(plong) (++(*(plong)))
  180. #define InterlockedDecrement(plong) (--(*(plong)))
  181. #ifndef CreateMutex
  182. #define CreateMutexA CreateMutex
  183. #define CreateMutexW CreateMutex
  184. #define CreateMutex(pv, bool, sz) (INVALID_HANDLE_VALUE)
  185. #endif
  186. #define WaitForSingleObject(hObj, dw) ((void)0)
  187. #define ReleaseMutex(hObj) ((BOOL)1)
  188. #define CloseMutexHandle(hObj) TRUE
  189. #define CRITICAL_SECTION ULONG
  190. #define InitializeCriticalSection(_pcs) ((void)0)
  191. #define DeleteCriticalSection(_pcs) ((void)0)
  192. #define EnterCriticalSection(_pcs) ((void)0)
  193. #define LeaveCriticalSection(_pcs) ((void)0)
  194. #define MAX_PATH 260
  195. #ifndef MAC
  196. /*
  197. * File Access Modes
  198. *
  199. * The possible combination of file access modes as passed into
  200. * the CreateFile() api map to OpenFile() as follows:
  201. *
  202. * GENERIC_READ OPEN_ACCESS_READONLY
  203. * GENERIC_WRITE OPEN_ACCESS_WRITEONLY
  204. * GENERIC_READ | GENERIC_WRITE OPEN_ACCESS_READWRITE
  205. *
  206. * 0 OPEN_SHARE_DENYREADWRITE
  207. * FILE_SHARE_READ OPEN_SHARE_DENYWRITE
  208. * FILE_SHARE_WRITE OPEN_SHARE_DENYREAD
  209. * FILE_SHARE_READ | FILE_SHARE_WRITE OPEN_SHARE_DENYNONE
  210. *
  211. * Due to the mappings we cannot pass them through directly,
  212. * so we will have to use a conversion within APIs that test
  213. * these bits. It would be best to use the WIN32 #defines
  214. * for these flags and convert as needed in the APIs.
  215. */
  216. #define GENERIC_READ (0x80000000) /* from WINNT.H */
  217. #define GENERIC_WRITE (0x40000000) /* from WINNT.H */
  218. #define FILE_SHARE_READ (0x00000001) /* from WINNT.H */
  219. #define FILE_SHARE_WRITE (0x00000002) /* from WINNT.H */
  220. #endif /* MAC */
  221. #define FILE_FLAG_SEQUENTIAL_SCAN 0x08000000
  222. #define CREATE_NEW 1
  223. #define CREATE_ALWAYS 2
  224. #define OPEN_EXISTING 3
  225. #define OPEN_ALWAYS 4
  226. #define TRUNCATE_EXISTING 5
  227. #ifndef MAC
  228. #define INVALID_HANDLE_VALUE ((HANDLE)(-1))
  229. #define DELETE 0x00010000L
  230. #define FILE_BEGIN 0
  231. #define FILE_CURRENT 1
  232. #define FILE_END 2
  233. #endif
  234. #define FILE_ATTRIBUTE_READONLY 0x00000001
  235. #define FILE_ATTRIBUTE_HIDDEN 0x00000002
  236. #define FILE_ATTRIBUTE_SYSTEM 0x00000004
  237. #define FILE_ATTRIBUTE_DIRECTORY 0x00000010
  238. #define FILE_ATTRIBUTE_ARCHIVE 0x00000020
  239. #define FILE_ATTRIBUTE_NORMAL 0x00000080
  240. #define FILE_ATTRIBUTE_TEMPORARY 0x00000100
  241. #define FILE_FLAG_WRITE_THROUGH 0x80000000
  242. #define FILE_FLAG_RANDOM_ACCESS 0x10000000
  243. #ifndef MAC
  244. typedef struct _WIN32_FIND_DATA {
  245. DWORD dwFileAttributes;
  246. FILETIME ftCreationTime;
  247. FILETIME ftLastAccessTime;
  248. FILETIME ftLastWriteTime;
  249. DWORD nFileSizeHigh;
  250. DWORD nFileSizeLow;
  251. DWORD dwReserved0;
  252. DWORD dwReserved1;
  253. CHAR cFileName[ MAX_PATH ];
  254. CHAR cAlternateFileName[ 16 ];
  255. } WIN32_FIND_DATA, *PWIN32_FIND_DATA, *LPWIN32_FIND_DATA;
  256. #define TIME_ZONE_ID_INVALID 0xFFFFFFFF
  257. #endif
  258. #define TIME_ZONE_ID_UNKNOWN 0
  259. #define TIME_ZONE_ID_STANDARD 1
  260. #define TIME_ZONE_ID_DAYLIGHT 2
  261. DWORD WINAPI GetLastError(void);
  262. DWORD WINAPI GetFileAttributes(LPCSTR lpFileName);
  263. DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh);
  264. BOOL WINAPI GetFileTime(HANDLE hFile, FILETIME FAR *lpftCreation,
  265. FILETIME FAR *lpftLastAccess, FILETIME FAR *lpftLastWrite);
  266. #ifndef MAC
  267. HANDLE WINAPI CreateFile(LPCSTR lpFileName, DWORD dwDesiredAccess,
  268. DWORD dwShareMode, LPVOID lpSecurityAttributes,
  269. DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes,
  270. HANDLE hTemplateFile);
  271. BOOL WINAPI ReadFile(HANDLE hFile, LPVOID lpBuffer,
  272. DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead,
  273. LPVOID lpOverlapped);
  274. BOOL WINAPI WriteFile(HANDLE hFile, LPCVOID lpBuffer,
  275. DWORD nNumberOfBytesToWrite, LPDWORD lpNumberOfBytesWritten,
  276. LPVOID lpOverlapped);
  277. #endif
  278. DWORD WINAPI SetFilePointer(HANDLE hFile, LONG lDistanceToMove,
  279. LONG FAR *lpDistanceToMoveHigh, DWORD dwMoveMethod);
  280. BOOL WINAPI SetEndOfFile(HANDLE hFile);
  281. BOOL WINAPI CloseHandle(HANDLE hObject);
  282. DWORD WINAPI GetTempPath(DWORD nBufferLength, LPSTR lpBuffer);
  283. UINT WINAPI GetTempFileName32 (LPCSTR lpPathName, LPCSTR lpPrefixString,
  284. UINT uUnique, LPSTR lpTempFileName);
  285. BOOL WINAPI DeleteFile(LPCSTR lpFileName);
  286. #ifndef MAC
  287. BOOL WINAPI CreateDirectory(LPCSTR lpPathName, LPVOID lpSecurityAttributes);
  288. #endif
  289. BOOL WINAPI RemoveDirectory(LPCSTR lpPathName);
  290. BOOL WINAPI CopyFile(LPCSTR szSrc, LPCSTR szDst, BOOL fFailIfExists);
  291. BOOL WINAPI MoveFile(LPCSTR lpExistingFileName, LPCSTR lpNewFileName);
  292. HANDLE WINAPI FindFirstFile(LPCSTR lpFileName, LPWIN32_FIND_DATA lpFindFileData);
  293. BOOL WINAPI FindNextFile(HANDLE hFindFile, LPWIN32_FIND_DATA lpFindFileData);
  294. BOOL WINAPI FindClose(HANDLE hFindFile);
  295. DWORD WINAPI GetFullPathName(LPCSTR lpFileName, DWORD nBufferLength,
  296. LPSTR lpBuffer, LPSTR *lpFilePart);
  297. void WINAPI Sleep(DWORD dwMilliseconds);
  298. LONG WINAPI CompareFileTime(const FILETIME FAR *, const FILETIME FAR *);
  299. BOOL WINAPI LocalFileTimeToFileTime(const FILETIME FAR *, FILETIME FAR *);
  300. BOOL WINAPI FileTimeToLocalFileTime(const FILETIME FAR *, FILETIME FAR *);
  301. BOOL WINAPI FileTimeToSystemTime(const FILETIME FAR *, SYSTEMTIME FAR *);
  302. BOOL WINAPI SystemTimeToFileTime(const SYSTEMTIME FAR *, FILETIME FAR *);
  303. void WINAPI GetSystemTime(SYSTEMTIME FAR *);
  304. void WINAPI GetLocalTime(SYSTEMTIME FAR *);
  305. BOOL WINAPI FileTimeToDosDateTime(const FILETIME FAR * lpFileTime,
  306. WORD FAR *lpFatDate, WORD FAR *lpFatTime);
  307. BOOL WINAPI DosDateTimeToFileTime(WORD wFatDate, WORD wFatTime,
  308. FILETIME FAR * lpFileTime);
  309. DWORD WINAPI GetTimeZoneInformation(
  310. LPTIME_ZONE_INFORMATION lpTimeZoneInformation);
  311. BOOL WINAPI SetTimeZoneInformation(
  312. const TIME_ZONE_INFORMATION FAR *lpTimeZoneInformation);
  313. DWORD WINAPI GetCurrentProcessId(void);
  314. long WINAPI MulDiv32(long, long, long);
  315. #ifndef MAC
  316. BOOL WINAPI FBadReadPtr(const void FAR* lp, UINT cb);
  317. #endif
  318. #else /* !WIN16 */
  319. /* Remaps GetTempFileName32() to the real 32bit version */
  320. #define GetTempFileName32(_szPath,_szPfx,_n,_lpbuf) GetTempFileName(_szPath,_szPfx,_n,_lpbuf)
  321. #define CloseMutexHandle CloseHandle
  322. #endif /* !WIN16 */
  323. #ifdef MAC
  324. #define CRITICAL_SECTION ULONG
  325. #define InitializeCriticalSection(_pcs) ((void)0)
  326. #define DeleteCriticalSection(_pcs) ((void)0)
  327. #define EnterCriticalSection(_pcs) ((void)0)
  328. #define LeaveCriticalSection(_pcs) ((void)0)
  329. #endif
  330. /********************************/
  331. /* Our private conventions */
  332. /* (common to WIN16/WIN32) */
  333. /********************************/
  334. #define Cbtszsize(_a) ((lstrlen(_a)+1)*sizeof(TCHAR))
  335. #define CbtszsizeA(_a) ((lstrlenA(_a) + 1))
  336. #define CbtszsizeW(_a) ((lstrlenW(_a) + 1) * sizeof(WCHAR))
  337. #define HexCchOf(_s) (sizeof(_s)*2+1)
  338. #define HexSizeOf(_s) (HexCchOf(_s)*sizeof(TCHAR))
  339. BOOL WINAPI IsBadBoundedStringPtr(const void FAR* lpsz, UINT cchMax);
  340. /* FUTURE - obsolete. OLE2 no longer contains these */
  341. #define GetSCode GetScode
  342. #define ReportResult(_a,_b,_c,_d) ResultFromScode(_b)
  343. #ifdef __cplusplus
  344. }
  345. #endif
  346. #endif /* __MAPIWIN_H__ */