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.

409 lines
12 KiB

  1. //
  2. // DC Groupware Common stuff
  3. //
  4. #ifndef _H_DCG
  5. #define _H_DCG
  6. #include <stddef.h>
  7. #include <stdarg.h>
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <ctype.h>
  11. #include <string.h>
  12. #include <time.h>
  13. #include <memory.h>
  14. #ifdef DLL_DISP
  15. #ifdef IS_16
  16. //
  17. // Win16 Display Driver
  18. //
  19. #define STRICT
  20. #define UNALIGNED
  21. #include <windows.h>
  22. #include <windowsx.h>
  23. #define abs(A) (((A) < 0)? -(A) : (A))
  24. #define FIELD_OFFSET(type, field) FIELDOFFSET(type, field)
  25. #else
  26. //
  27. // Windows NT DDK include files (used to replace standard windows.h)
  28. //
  29. // The display driver runs in the Kernel space and so MUST NOT access any
  30. // Win32 functions or data. Instead we can only use the Win32k functions
  31. // as described in the DDK.
  32. //
  33. #include <ntddk.h>
  34. #include <windef.h>
  35. #include <wingdi.h>
  36. #include <ntddvdeo.h>
  37. #endif // IS_16
  38. // DDI
  39. #include <winddi.h>
  40. // Debugging Macros
  41. #include <drvdbg.h>
  42. #else
  43. #ifndef STRICT
  44. #define STRICT
  45. #endif
  46. #define OEMRESOURCE
  47. #include <windows.h>
  48. #include <windowsx.h>
  49. #include <commctrl.h>
  50. #include <winable.h>
  51. #include <mlzdbg.h> // multi-level zone debug header file
  52. #include <oprahcom.h>
  53. #endif // DLL_DISP
  54. //
  55. // DC_DATA macros to generate extern declarations.
  56. // NOTE: Keep this section in ssync with datainit.h, the header included
  57. // by a file to actually generate storage for variables declared using the
  58. // DC_DATA macros
  59. //
  60. #define DC_DATA(TYPE, Name) \
  61. extern TYPE Name
  62. #define DC_DATA_VAL(TYPE, Name, Value) \
  63. extern TYPE Name
  64. #define DC_CONST_DATA(TYPE, Name, Value) \
  65. extern const TYPE Name
  66. #define DC_DATA_ARRAY(TYPE, Name, Size) \
  67. extern TYPE Name[Size]
  68. #define DC_CONST_DATA_ARRAY(TYPE, Name, Size, Value) \
  69. extern const TYPE Name[Size]
  70. #define DC_DATA_2D_ARRAY(TYPE, Name, Size1, Size2) \
  71. extern TYPE Name[Size1][Size2]
  72. #define DC_CONST_DATA_2D_ARRAY(TYPE, Name, Size1, Size2, Value) \
  73. extern const TYPE Name[Size1][Size2]
  74. typedef UINT FAR* LPUINT;
  75. typedef UINT MCSID;
  76. #define MCSID_NULL ((MCSID)0)
  77. //
  78. // T.128 PROTOCOL STRUCTURES
  79. // These are defined in a way that keeps the offsets and total sizes the
  80. // same, regardless of whether this header is included in 32-bit code,
  81. // 16-bit code, big-endian code, etc.
  82. //
  83. // We make special types to avoid inadvertenly altering something else and
  84. // breaking the structure. The TSHR_ prefix helps make this clear.
  85. //
  86. #include <t_share.h>
  87. //
  88. // Defines the maximum number of BYTES allowed in a translated "shared by "
  89. // string.
  90. //
  91. #define DC_MAX_SHARED_BY_BUFFER 64
  92. #define DC_MAX_SHAREDDESKTOP_BUFFER 64
  93. //
  94. // Registry prefix.
  95. //
  96. #define DC_REG_PREFIX TEXT("SOFTWARE\\Microsoft\\Conferencing\\AppSharing\\")
  97. //
  98. // Limits
  99. //
  100. #define MAX_TSHR_UINT16 65535
  101. //
  102. // Return codes
  103. //
  104. #define UT_BASE_RC 0x0000
  105. #define OM_BASE_RC 0x0200
  106. #define OM_LAST_RC 0x02FF
  107. #define WB_BASE_RC 0x0300
  108. #define WB_LAST_RC 0x03FF
  109. #define NET_BASE_RC 0x0700
  110. #define NET_LAST_RC 0x07FF
  111. #define CM_BASE_RC 0x0800
  112. #define CM_LAST_RC 0x08FF
  113. #define AL_BASE_RC 0x0a00
  114. #define AL_LAST_RC 0x0aFF
  115. //
  116. // Events
  117. // ======
  118. // This section lists the ranges available for each component when defining
  119. // its events. A component must not define events outside its permitted
  120. // range.
  121. //
  122. #define UT_BASE_EVENT (0x0600) // Utility service events
  123. #define UT_LAST_EVENT (0x06FF) // are in this range
  124. #define OM_BASE_EVENT (0x0700) // Object Manager events
  125. #define OM_LAST_EVENT (0x07FF) // are in this range
  126. #define NET_BASE_EVENT (0x0800) // Network layer events
  127. #define NET_LAST_EVENT (0x08FF) // are in this range
  128. #define CM_BASE_EVENT (0x0900) // Call Manager events
  129. #define CM_LAST_EVENT (0x09FF) // are in this range
  130. #define AL_BASE_EVENT (0x0A00) // Application Loader evts
  131. #define AL_LAST_EVENT (0x0AFF) // are in this range
  132. #define SPI_BASE_EVENT (0x0B00) // SPI event numbers
  133. #define SPI_LAST_EVENT (0x0BFF)
  134. #define S20_BASE_EVENT (0x0C00) // S20 event numbers
  135. #define S20_LAST_EVENT (0x0CFF)
  136. //
  137. // NOTE: Keep this above WM_USER; WB reposts the events using the event
  138. // as the message. So it CANNOT conflict with an existing Win message.
  139. //
  140. #define WB_BASE_EVENT (0x0D00) // Whiteboard events
  141. #define WB_LAST_EVENT (0x0DFF) // are in this range
  142. #define SC_BASE_EVENT (0x0E00) // SC event numbers
  143. #define SC_LAST_EVENT (0x0EFF)
  144. #define DBG_INI_SECTION_NAME "Debug"
  145. //
  146. // The GCC channel keys used with MG_ChannelJoinByKey. They must be
  147. // unique.
  148. //
  149. // SFR6043: Modified these values from 41-43 to 421-423. These values now
  150. // represent the default static channel numbers used.
  151. //
  152. // FT (potentially) uses all key numbers in the range 600-1100. If you add
  153. // a new channel key, do not use a number in that range.
  154. //
  155. #define GCC_OBMAN_CHANNEL_KEY 421
  156. #define GCC_AS_CHANNEL_KEY 422
  157. //
  158. // GCC Token keys
  159. //
  160. #define GCC_OBMAN_TOKEN_KEY 500
  161. //
  162. //
  163. // MACROS
  164. //
  165. //
  166. #define DC_QUIT goto DC_EXIT_POINT
  167. //
  168. // DEBUG structure type stamps, to help us track memory leaks
  169. //
  170. #ifdef _DEBUG
  171. typedef struct tagDBGSTAMP
  172. {
  173. char idStamp[8];
  174. }
  175. DBGSTAMP;
  176. #define STRUCTURE_STAMP DBGSTAMP stamp;
  177. #define SET_STAMP(lpv, st) lstrcpyn((lpv)->stamp.idStamp, "AS"#st, sizeof(DBGSTAMP))
  178. #else
  179. #define STRUCTURE_STAMP
  180. #define SET_STAMP(lpv, st)
  181. #endif // _DEBUG
  182. //
  183. // Cousin of the the FIELD macros supplied by 16-bit windows.h.
  184. //
  185. #define FIELD_SIZE(type, field) (sizeof(((type FAR *)0L)->field))
  186. //
  187. // Macro to round up a number to the nearest multiple of four.
  188. //
  189. #define DC_ROUND_UP_4(x) (((x) + 3L) & ~(3L))
  190. //
  191. // Unaligned pointer access macros -- first macros to extract an integer
  192. // from an UNALIGNED pointer. Note that these macros assume that the
  193. // integer is in local byte order
  194. //
  195. #ifndef DC_NO_UNALIGNED
  196. #define EXTRACT_TSHR_UINT16_UA(pA) (*(LPTSHR_UINT16_UA)(pA))
  197. #define EXTRACT_TSHR_INT16_UA(pA) (*(LPTSHR_INT16_UA)(pA))
  198. #define EXTRACT_TSHR_UINT32_UA(pA) (*(LPTSHR_UINT32_UA)(pA))
  199. #define EXTRACT_TSHR_INT32_UA(pA) (*(LPTSHR_INT32_UA)(pA))
  200. #define INSERT_TSHR_UINT16_UA(pA,V) (*(LPTSHR_UINT16_UA)(pA)) = (V)
  201. #define INSERT_TSHR_INT16_UA(pA,V) (*(LPTSHR_INT16_UA)(pA)) = (V)
  202. #define INSERT_TSHR_UINT32_UA(pA,V) (*(LPTSHR_UINT32_UA)(pA)) = (V)
  203. #define INSERT_TSHR_INT32_UA(pA,V) (*(LPTSHR_INT32_UA)(pA)) = (V)
  204. #else
  205. #define EXTRACT_TSHR_UINT16_UA(pA) ((TSHR_UINT16) (((LPBYTE)(pA))[0]) | \
  206. (TSHR_UINT16) ((((LPBYTE)(pA))[1]) << 8) )
  207. #define EXTRACT_TSHR_INT16_UA(pA) ((TSHR_INT16) (((LPBYTE)(pA))[0]) | \
  208. (TSHR_INT16) ((((LPBYTE)(pA))[1]) << 8) )
  209. #define EXTRACT_TSHR_UINT32_UA(pA) ((TSHR_UINT32) (((LPBYTE)(pA))[0]) | \
  210. (TSHR_UINT32) ((((LPBYTE)(pA))[1]) << 8) | \
  211. (TSHR_UINT32) ((((LPBYTE)(pA))[2]) << 16) | \
  212. (TSHR_UINT32) ((((LPBYTE)(pA))[3]) << 24) )
  213. #define EXTRACT_TSHR_INT32_UA(pA) ((TSHR_INT32) (((LPBYTE)(pA))[0]) | \
  214. (TSHR_INT32) ((((LPBYTE)(pA))[1]) << 8) | \
  215. (TSHR_INT32) ((((LPBYTE)(pA))[2]) << 16) | \
  216. (TSHR_INT32) ((((LPBYTE)(pA))[3]) << 24) )
  217. #define INSERT_TSHR_UINT16_UA(pA,V) \
  218. { \
  219. (((LPBYTE)(pA))[0]) = (BYTE)( (V) & 0x00FF); \
  220. (((LPBYTE)(pA))[1]) = (BYTE)(((V)>>8) & 0x00FF); \
  221. }
  222. #define INSERT_TSHR_INT16_UA(pA,V) INSERT_TSHR_UINT16_UA(pA,V)
  223. #define INSERT_TSHR_UINT32_UA(pA,V) \
  224. { \
  225. (((LPBYTE)(pA))[0]) = (BYTE)( (V) & 0x000000FF); \
  226. (((LPBYTE)(pA))[1]) = (BYTE)(((V)>>8) & 0x000000FF); \
  227. (((LPBYTE)(pA))[2]) = (BYTE)(((V)>>16) & 0x000000FF); \
  228. (((LPBYTE)(pA))[3]) = (BYTE)(((V)>>24) & 0x000000FF); \
  229. }
  230. #define INSERT_TSHR_INT32_UA(pA,V) INSERT_TSHR_UINT32_UA(pA,V)
  231. #endif
  232. //
  233. // Stamp type and macro: each module should use these when stamping its
  234. // data structures.
  235. //
  236. typedef TSHR_UINT32 DC_ID_STAMP;
  237. #define DC_MAKE_ID_STAMP(X1, X2, X3, X4) \
  238. ((DC_ID_STAMP) (((DC_ID_STAMP) X4) << 24) | \
  239. (((DC_ID_STAMP) X3) << 16) | \
  240. (((DC_ID_STAMP) X2) << 8) | \
  241. (((DC_ID_STAMP) X1) << 0) )
  242. //
  243. // BOGUS LAURABU!
  244. // COM_SIZEOF_RECT() was the old name of COM_SIZEOF_RECT_EXCLUSIVE(). But
  245. // it was being used in the display driver on INCLUSIVE rects. I fixed this,
  246. // I changed it to use COM_SIZEOF_RECT_INCLUSIVE. But this may uncover
  247. // other bugs. The reason I found this--my 16-bit display driver generates
  248. // no orders yet, all the DDI calls just add screen data. So each little
  249. // patblted strip, one pixel wide/high, gets sent via draw bounds as screen
  250. // data.
  251. //
  252. __inline DWORD COM_SizeOfRectInclusive(LPRECT prc)
  253. {
  254. return((DWORD)(prc->right+1-prc->left) * (DWORD)(prc->bottom+1-prc->top));
  255. }
  256. __inline DWORD COM_SizeOfRectExclusive(LPRECT prc)
  257. {
  258. return((DWORD)(prc->right-prc->left) * (DWORD)(prc->bottom-prc->top));
  259. }
  260. //
  261. // NORMAL rect<->rectl conversions
  262. //
  263. __inline void RECTL_TO_RECT(const RECTL FAR* lprclSrc, LPRECT lprcDst)
  264. {
  265. lprcDst->left = lprclSrc->left;
  266. lprcDst->top = lprclSrc->top;
  267. lprcDst->right = lprclSrc->right;
  268. lprcDst->bottom = lprclSrc->bottom;
  269. }
  270. __inline void RECT_TO_RECTL(const RECT FAR* lprcSrc, LPRECTL lprclDst)
  271. {
  272. lprclDst->left = lprcSrc->left;
  273. lprclDst->top = lprcSrc->top;
  274. lprclDst->right = lprcSrc->right;
  275. lprclDst->bottom = lprcSrc->bottom;
  276. }
  277. //
  278. // This macro works on 32 bit unsigned ticks and returns TRUE if TIME is
  279. // between BEGIN and END (both inclusive) allowing for the wraparound.
  280. //
  281. #define IN_TIME_RANGE(BEGIN, END, TIME) \
  282. (((BEGIN) < (END)) ? \
  283. (((TIME) >= (BEGIN)) && ((TIME) <= (END))) : \
  284. (((TIME) >= (BEGIN)) || ((TIME) <= (END))))
  285. //
  286. // Convert BPP to number of colors.
  287. //
  288. #define COLORS_FOR_BPP(BPP) (((BPP) > 8) ? 0 : (1 << (BPP)))
  289. #define MAX_ITOA_LENGTH 18
  290. #endif // _H_DCG