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.

283 lines
17 KiB

  1. // --------------------------------------------------------------------------------
  2. // Symcache.h
  3. // Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  4. // --------------------------------------------------------------------------------
  5. #ifndef __SYMCACHE_H
  6. #define __SYMCACHE_H
  7. // --------------------------------------------------------------------------------
  8. // Depends
  9. // --------------------------------------------------------------------------------
  10. #include "containx.h"
  11. #include "exrwlck.h"
  12. // --------------------------------------------------------------------------------
  13. // Forward Decls
  14. // --------------------------------------------------------------------------------
  15. class CPropertySymbolCache;
  16. typedef class CPropertySymbolCache *LPSYMBOLCACHE;
  17. // --------------------------------------------------------------------------------
  18. // Don't let this flag overlap with MIMEPROPFLAGS
  19. // --------------------------------------------------------------------------------
  20. #define MPF_NODIRTY FLAG28 // Property does not allow container to get dirty
  21. #define MPF_HEADER FLAG29 // Property is a header and should be persisted
  22. #define MPF_PARAMETER FLAG30 // Property is a header parameter
  23. #define MPF_ATTRIBUTE FLAG31 // Property is a non-persisting attribute
  24. #define MPF_KNOWN FLAG32 // Property is known by mimeole (it holds const data)
  25. // --------------------------------------------------------------------------------
  26. // Forward Typedefs
  27. // --------------------------------------------------------------------------------
  28. typedef struct tagPROPSYMBOL const *LPCPROPSYMBOL;
  29. typedef struct tagPROPSYMBOL *LPPROPSYMBOL;
  30. // --------------------------------------------------------------------------------
  31. // PROPSYMBOL
  32. // --------------------------------------------------------------------------------
  33. typedef struct tagPROPSYMBOL {
  34. LPSTR pszName; // Property Name
  35. ULONG cchName; // Property Name Length
  36. DWORD dwPropId; // Property Id (PID_UNKNOWN if not known)
  37. DWORD dwFlags; // Property Flags
  38. DWORD dwAdrType; // Address Type
  39. WORD wHashIndex; // Symbol's Hash Index in the Property Container
  40. DWORD dwSort; // By Name Sort Position
  41. DWORD dwRowNumber; // Header Line Persist Postion
  42. VARTYPE vtDefault; // Default data type
  43. LPPROPSYMBOL pLink; // Link to property id for parameter properties
  44. LPSYMBOLTRIGGER pTrigger; // Proerty Notification Handler
  45. } PROPSYMBOL;
  46. // --------------------------------------------------------------------------------
  47. // Macro used to define global property symbols
  48. // --------------------------------------------------------------------------------
  49. #ifdef DEFINE_PROPSYMBOLS
  50. #define DEFINESYMBOL(_NAME, _vtDefault, _dwFlags, _dwAdrType, _pLink, _pfnDispatch) \
  51. PROPSYMBOL rSYM_##_NAME = \
  52. { \
  53. /* PROPSYMBOL::pszName */ (LPSTR)(STR_##_NAME), \
  54. /* PROPSYMBOL::cchName */ sizeof(STR_##_NAME) - 1, \
  55. /* PROPSYMBOL::dwPropId */ PID_##_NAME, \
  56. /* PROPSYMBOL::dwFlags */ (_dwFlags | MPF_KNOWN), \
  57. /* PROPSYMBOL::dwAdrType */ _dwAdrType, \
  58. /* PROPSYMBOL::wHashIndex */ 0, \
  59. /* PROPSYMBOL::dwSort */ 0, \
  60. /* PROPSYMBOL::dwRowNumber */ 0, \
  61. /* PROPSYMBOL::vtDefault */ _vtDefault, \
  62. /* PROPSYMBOL::pLink */ _pLink, \
  63. /* PROPSYMBOL::pfnDispatch */ _pfnDispatch \
  64. }; \
  65. LPPROPSYMBOL SYM_##_NAME = &rSYM_##_NAME;
  66. #else
  67. #define DEFINESYMBOL(_NAME, _vtDefault, _dwFlags, _dwAdrType, _pLink, _pfnDispatch) \
  68. extern LPPROPSYMBOL SYM_##_NAME;
  69. #endif
  70. // --------------------------------------------------------------------------------
  71. // Property Flags Groups
  72. // --------------------------------------------------------------------------------
  73. #define MPG_GROUP01 (MPF_HEADER)
  74. #define MPG_GROUP02 (MPF_HEADER)
  75. #define MPG_GROUP03 (MPF_HEADER | MPF_INETCSET | MPF_RFC1522 | MPF_ADDRESS)
  76. #define MPG_GROUP04 (MPF_HEADER | MPF_INETCSET | MPF_RFC1522)
  77. #define MPG_GROUP05 (MPF_HEADER | MPF_MIME)
  78. #define MPG_GROUP06 (MPF_HEADER | MPF_MIME | MPF_HASPARAMS)
  79. #define MPG_GROUP07 (MPF_HEADER | MPF_MIME)
  80. #define MPG_GROUP08 (MPF_HEADER | MPF_MIME | MPF_INETCSET | MPF_RFC1522)
  81. #define MPG_GROUP09 (MPF_PARAMETER | MPF_MIME)
  82. #define MPG_GROUP10 (MPF_PARAMETER | MPF_MIME | MPF_INETCSET | MPF_RFC1522)
  83. #define MPG_GROUP11 (MPF_ATTRIBUTE | MPF_INETCSET | MPF_RFC1522)
  84. #define MPG_GROUP12 (MPF_ATTRIBUTE)
  85. #define MPG_GROUP13 (MPF_ATTRIBUTE | MPF_INETCSET | MPF_RFC1522)
  86. #define MPG_GROUP14 (MPF_HEADER | MPF_INETCSET | MPF_RFC1522)
  87. #define MPG_GROUP15 (MPF_ATTRIBUTE | MPF_INETCSET | MPF_RFC1522 | MPF_READONLY)
  88. #define MPG_GROUP16 (MPF_ATTRIBUTE | MPF_READONLY)
  89. #define MPG_GROUP17 (MPF_ATTRIBUTE | MPF_NODIRTY)
  90. // --------------------------------------------------------------------------------
  91. // Header Property Tag Definitions
  92. // --------------------------------------------------------------------------------
  93. DEFINESYMBOL(HDR_RECEIVED, VT_LPSTR, MPG_GROUP01, IAT_UNKNOWN, NULL, NULL);
  94. DEFINESYMBOL(HDR_XMAILER, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  95. DEFINESYMBOL(HDR_XUNSENT, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  96. DEFINESYMBOL(HDR_XNEWSRDR, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  97. DEFINESYMBOL(HDR_RETURNPATH, VT_LPSTR, MPG_GROUP03, IAT_RETURNPATH, NULL, NULL);
  98. DEFINESYMBOL(HDR_RETRCPTTO, VT_LPSTR, MPG_GROUP03, IAT_RETRCPTTO, NULL, NULL);
  99. DEFINESYMBOL(HDR_RR, VT_LPSTR, MPG_GROUP03, IAT_RR, NULL, NULL);
  100. DEFINESYMBOL(HDR_REPLYTO, VT_LPSTR, MPG_GROUP03, IAT_REPLYTO, NULL, NULL);
  101. DEFINESYMBOL(HDR_APPARTO, VT_LPSTR, MPG_GROUP03, IAT_APPARTO, NULL, NULL);
  102. DEFINESYMBOL(HDR_FROM, VT_LPSTR, MPG_GROUP03, IAT_FROM, NULL, NULL);
  103. DEFINESYMBOL(HDR_SENDER, VT_LPSTR, MPG_GROUP03, IAT_SENDER, NULL, NULL);
  104. DEFINESYMBOL(HDR_TO, VT_LPSTR, MPG_GROUP03, IAT_TO, NULL, NULL);
  105. DEFINESYMBOL(HDR_CC, VT_LPSTR, MPG_GROUP03, IAT_CC, NULL, NULL);
  106. DEFINESYMBOL(HDR_BCC, VT_LPSTR, MPG_GROUP03, IAT_BCC, NULL, NULL);
  107. DEFINESYMBOL(HDR_NEWSGROUPS, VT_LPSTR, MPG_GROUP04, IAT_UNKNOWN, NULL, NULL);
  108. DEFINESYMBOL(HDR_PATH, VT_LPSTR, MPG_GROUP04, IAT_UNKNOWN, NULL, NULL);
  109. DEFINESYMBOL(HDR_FOLLOWUPTO, VT_LPSTR, MPG_GROUP04, IAT_UNKNOWN, NULL, NULL);
  110. DEFINESYMBOL(HDR_REFS, VT_LPSTR, MPG_GROUP04, IAT_UNKNOWN, NULL, NULL);
  111. DEFINESYMBOL(HDR_SUBJECT, VT_LPSTR, MPG_GROUP04, IAT_UNKNOWN, NULL, LPTRIGGER_HDR_SUBJECT);
  112. DEFINESYMBOL(HDR_ORG, VT_LPSTR, MPG_GROUP04, IAT_UNKNOWN, NULL, NULL);
  113. DEFINESYMBOL(HDR_DATE, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  114. DEFINESYMBOL(HDR_EXPIRES, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  115. DEFINESYMBOL(HDR_CONTROL, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  116. DEFINESYMBOL(HDR_DISTRIB, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  117. DEFINESYMBOL(HDR_KEYWORDS, VT_LPSTR, MPG_GROUP04, IAT_UNKNOWN, NULL, NULL);
  118. DEFINESYMBOL(HDR_SUMMARY, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  119. DEFINESYMBOL(HDR_APPROVED, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  120. DEFINESYMBOL(HDR_LINES, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  121. DEFINESYMBOL(HDR_XREF, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  122. DEFINESYMBOL(HDR_XPRI, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  123. DEFINESYMBOL(HDR_XMSPRI, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  124. DEFINESYMBOL(HDR_MESSAGEID, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  125. DEFINESYMBOL(HDR_MIMEVER, VT_LPSTR, MPG_GROUP05, IAT_UNKNOWN, NULL, NULL);
  126. DEFINESYMBOL(HDR_CNTTYPE, VT_LPSTR, MPG_GROUP06, IAT_UNKNOWN, NULL, LPTRIGGER_HDR_CNTTYPE);
  127. DEFINESYMBOL(HDR_CNTDISP, VT_LPSTR, MPG_GROUP06, IAT_UNKNOWN, NULL, NULL);
  128. DEFINESYMBOL(HDR_CNTXFER, VT_LPSTR, MPG_GROUP07, IAT_UNKNOWN, NULL, LPTRIGGER_HDR_CNTXFER);
  129. DEFINESYMBOL(HDR_CNTID, VT_LPSTR, MPG_GROUP07, IAT_UNKNOWN, NULL, NULL);
  130. DEFINESYMBOL(HDR_CNTDESC, VT_LPSTR, MPG_GROUP08, IAT_UNKNOWN, NULL, NULL);
  131. DEFINESYMBOL(HDR_CNTBASE, VT_LPSTR, MPG_GROUP08, IAT_UNKNOWN, NULL, NULL);
  132. DEFINESYMBOL(HDR_CNTLOC, VT_LPSTR, MPG_GROUP08, IAT_UNKNOWN, NULL, NULL);
  133. DEFINESYMBOL(HDR_COMMENT, VT_LPSTR, MPG_GROUP14, IAT_UNKNOWN, NULL, NULL);
  134. DEFINESYMBOL(HDR_ENCODING, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  135. DEFINESYMBOL(HDR_ENCRYPTED, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  136. DEFINESYMBOL(HDR_OFFSETS, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  137. DEFINESYMBOL(HDR_ARTICLEID, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  138. DEFINESYMBOL(HDR_NEWSGROUP, VT_LPSTR, MPG_GROUP02, IAT_UNKNOWN, NULL, NULL);
  139. DEFINESYMBOL(HDR_DISP_NOTIFICATION_TO, VT_LPSTR, MPG_GROUP03, IAT_DISP_NOTIFICATION_TO, NULL, NULL);
  140. // --------------------------------------------------------------------------------
  141. // Parameter Property Tags Definitions
  142. // --------------------------------------------------------------------------------
  143. DEFINESYMBOL(PAR_BOUNDARY, VT_LPSTR, MPG_GROUP09, IAT_UNKNOWN, SYM_HDR_CNTTYPE, NULL);
  144. DEFINESYMBOL(PAR_CHARSET, VT_LPSTR, MPG_GROUP09, IAT_UNKNOWN, SYM_HDR_CNTTYPE, NULL);
  145. DEFINESYMBOL(PAR_FILENAME, VT_LPSTR, MPG_GROUP10, IAT_UNKNOWN, SYM_HDR_CNTDISP, LPTRIGGER_PAR_FILENAME);
  146. DEFINESYMBOL(PAR_NAME, VT_LPSTR, MPG_GROUP10, IAT_UNKNOWN, SYM_HDR_CNTTYPE, LPTRIGGER_PAR_NAME);
  147. // --------------------------------------------------------------------------------
  148. // Attribute Property Tags Definitions
  149. // --------------------------------------------------------------------------------
  150. DEFINESYMBOL(ATT_FILENAME, VT_LPSTR, MPG_GROUP11, IAT_UNKNOWN, NULL, LPTRIGGER_ATT_FILENAME);
  151. DEFINESYMBOL(ATT_GENFNAME, VT_LPSTR, MPG_GROUP15, IAT_UNKNOWN, NULL, LPTRIGGER_ATT_GENFNAME);
  152. DEFINESYMBOL(ATT_NORMSUBJ, VT_LPSTR, MPG_GROUP15, IAT_UNKNOWN, NULL, LPTRIGGER_ATT_NORMSUBJ);
  153. DEFINESYMBOL(ATT_ILLEGAL, VT_LPSTR, MPG_GROUP13, IAT_UNKNOWN, NULL, NULL);
  154. DEFINESYMBOL(ATT_PRITYPE, VT_LPSTR, MPG_GROUP12, IAT_UNKNOWN, SYM_HDR_CNTTYPE, LPTRIGGER_ATT_PRITYPE);
  155. DEFINESYMBOL(ATT_SUBTYPE, VT_LPSTR, MPG_GROUP12, IAT_UNKNOWN, SYM_HDR_CNTTYPE, LPTRIGGER_ATT_SUBTYPE);
  156. DEFINESYMBOL(ATT_RENDERED, VT_UI4, MPG_GROUP17, IAT_UNKNOWN, NULL, NULL);
  157. DEFINESYMBOL(ATT_SENTTIME, VT_FILETIME, MPG_GROUP12, IAT_UNKNOWN, SYM_HDR_DATE, LPTRIGGER_ATT_SENTTIME);
  158. DEFINESYMBOL(ATT_RECVTIME, VT_FILETIME, MPG_GROUP16, IAT_UNKNOWN, SYM_HDR_RECEIVED, LPTRIGGER_ATT_RECVTIME);
  159. DEFINESYMBOL(ATT_PRIORITY, VT_UI4, MPG_GROUP12, IAT_UNKNOWN, NULL, LPTRIGGER_ATT_PRIORITY);
  160. DEFINESYMBOL(ATT_SERVER, VT_LPSTR, MPG_GROUP12, IAT_UNKNOWN, NULL, NULL);
  161. DEFINESYMBOL(ATT_ACCOUNTID, VT_LPSTR, MPG_GROUP12, IAT_UNKNOWN, NULL, NULL);
  162. DEFINESYMBOL(ATT_UIDL, VT_LPSTR, MPG_GROUP12, IAT_UNKNOWN, NULL, NULL);
  163. DEFINESYMBOL(ATT_STOREMSGID, VT_UI4, MPG_GROUP12, IAT_UNKNOWN, NULL, NULL);
  164. DEFINESYMBOL(ATT_USERNAME, VT_LPSTR, MPG_GROUP12, IAT_UNKNOWN, NULL, NULL);
  165. DEFINESYMBOL(ATT_FORWARDTO, VT_LPSTR, MPG_GROUP12, IAT_UNKNOWN, NULL, NULL);
  166. DEFINESYMBOL(ATT_STOREFOLDERID, VT_UI4, MPG_GROUP12, IAT_UNKNOWN, NULL, NULL);
  167. DEFINESYMBOL(ATT_GHOSTED, VT_I4, MPG_GROUP12, IAT_UNKNOWN, NULL, NULL);
  168. DEFINESYMBOL(ATT_UNCACHEDSIZE, VT_UI4, MPG_GROUP12, IAT_UNKNOWN, NULL, NULL);
  169. DEFINESYMBOL(ATT_COMBINED, VT_UI4, MPG_GROUP12, IAT_UNKNOWN, NULL, NULL);
  170. DEFINESYMBOL(ATT_AUTOINLINED, VT_UI4, MPG_GROUP17, IAT_UNKNOWN, NULL, NULL);
  171. // --------------------------------------------------------------------------------
  172. // ADDRSYMBOL
  173. // --------------------------------------------------------------------------------
  174. typedef struct tagADDRSYMBOL {
  175. DWORD dwAdrType; // Address Type (bitmask)
  176. LPPROPSYMBOL pSymbol; // Property Symbol
  177. } ADDRSYMBOL, *LPADDRSYMBOL;
  178. // --------------------------------------------------------------------------------
  179. // Internet Property Tag Table (Sorted by Name)
  180. // --------------------------------------------------------------------------------
  181. typedef struct tagSYMBOLTABLE {
  182. ULONG cSymbols; // Number of elements in prgTag
  183. ULONG cAlloc; // Number of elements allocated in prgTag
  184. LPPROPSYMBOL *prgpSymbol; // Array of pointers to inet properties
  185. } SYMBOLTABLE, *LPSYMBOLTABLE;
  186. // --------------------------------------------------------------------------------
  187. // CPropertySymbolCache
  188. // --------------------------------------------------------------------------------
  189. class CPropertySymbolCache : public IMimePropertySchema
  190. {
  191. public:
  192. // ----------------------------------------------------------------------------
  193. // Construction
  194. // ----------------------------------------------------------------------------
  195. CPropertySymbolCache(void);
  196. ~CPropertySymbolCache(void);
  197. // -------------------------------------------------------------------
  198. // IUnknown Members
  199. // -------------------------------------------------------------------
  200. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppv);
  201. STDMETHODIMP_(ULONG) AddRef(void);
  202. STDMETHODIMP_(ULONG) Release(void);
  203. // -------------------------------------------------------------------
  204. // IMimePropertySchema Members
  205. // -------------------------------------------------------------------
  206. STDMETHODIMP RegisterProperty(LPCSTR pszName, DWORD dwFlags, DWORD dwRowNumber, VARTYPE vtDefault, LPDWORD pdwPropId);
  207. STDMETHODIMP ModifyProperty(LPCSTR pszName, DWORD dwFlags, DWORD dwRowNumber, VARTYPE vtDefault);
  208. STDMETHODIMP RegisterAddressType(LPCSTR pszName, LPDWORD pdwAdrType);
  209. STDMETHODIMP GetPropertyId(LPCSTR pszName, LPDWORD pdwPropId);
  210. STDMETHODIMP GetPropertyName(DWORD dwPropId, LPSTR *ppszName);
  211. // -------------------------------------------------------------------
  212. // CPropertySymbolCache Members
  213. // -------------------------------------------------------------------
  214. HRESULT Init(void);
  215. HRESULT HrOpenSymbol(LPCSTR pszName, BOOL fCreate, LPPROPSYMBOL *ppSymbol);
  216. HRESULT HrOpenSymbol(DWORD dwAdrType, LPPROPSYMBOL *ppSymbol);
  217. // -------------------------------------------------------------------
  218. // GetCount
  219. // -------------------------------------------------------------------
  220. ULONG GetCount(void) {
  221. m_lock.ShareLock();
  222. ULONG c = m_rTable.cSymbols;
  223. m_lock.ShareUnlock();
  224. return c;
  225. }
  226. private:
  227. // -------------------------------------------------------------------
  228. // Private Utilities
  229. // -------------------------------------------------------------------
  230. HRESULT _HrOpenSymbolWithLockOption(LPCSTR pszName, BOOL fCreate, LPPROPSYMBOL *ppSymbol,BOOL fLockOption);
  231. void _FreeTableElements(void);
  232. void _FreeSymbol(LPPROPSYMBOL pSymbol);
  233. void _SortTableElements(LONG left, LONG right);
  234. HRESULT _HrFindSymbol(LPCSTR pszName, LPPROPSYMBOL *ppSymbol);
  235. ULONG _UlComputeHashIndex(LPCSTR pszName, ULONG cchName);
  236. HRESULT _HrGetParameterLinkSymbol(LPCSTR pszName, ULONG cchName, LPPROPSYMBOL *ppSymbol);
  237. HRESULT _HrGetParameterLinkSymbolWithLockOption(LPCSTR pszName, ULONG cchName, LPPROPSYMBOL *ppSymbol,BOOL fLockOption);
  238. private:
  239. // -------------------------------------------------------------------
  240. // Private Data
  241. // -------------------------------------------------------------------
  242. LONG m_cRef; // Reference Count
  243. DWORD m_dwNextPropId; // NextProperty Id to be assigned
  244. DWORD m_cSymbolsInit; // Base symbol propert id for new props
  245. SYMBOLTABLE m_rTable; // Property Symbol Table
  246. LPPROPSYMBOL m_prgIndex[PID_LAST]; // Index of Known Property Symbols
  247. CExShareLock m_lock; //Thread Safety
  248. };
  249. // --------------------------------------------------------------------------------
  250. // Prototypes
  251. // --------------------------------------------------------------------------------
  252. HRESULT HrIsValidPropFlags(DWORD dwFlags);
  253. HRESULT HrIsValidSymbol(LPCPROPSYMBOL pSymbol);
  254. WORD WGetHashTableIndex(LPCSTR pszName, ULONG cchName);
  255. #endif // __SYMCACHE_H