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.

449 lines
15 KiB

  1. /************************************************************
  2. * FILE: cat.h
  3. * PURPOSE: API for Categorizing IMsg objects.
  4. * HISTORY:
  5. * // jstamerj 980211 13:53:44: Created
  6. ************************************************************/
  7. #ifndef __CAT_H__
  8. #define __CAT_H__
  9. #include <windows.h>
  10. #include <mailmsg.h>
  11. #include <aqueue.h>
  12. #define CATCALLCONV
  13. #define CATEXPDLLCPP extern "C"
  14. /************************************************************
  15. * FUNCTION: CatInit
  16. * DESCRIPTION: Initialzies Categorizer.
  17. * PARAMETERS:
  18. * pszConfig: Indicates where to find configuration defaults
  19. * Config info found in key
  20. * HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services
  21. * \PlatinumIMC\CatSources\szConfig
  22. *
  23. * phCat: Pointer to a handle. Upon successfull initializtion,
  24. * handle to use in subsequent Categorizer calls will be
  25. * plcaed there.
  26. *
  27. * pAQConfig: pointer to an AQConfigInfo structure containing
  28. * per virtual server message cat parameters
  29. *
  30. * pfn: Service routine for periodic callbakcs if any time consuming
  31. * operations are performed
  32. *
  33. * pServiceContext: Context for the pfn function.
  34. *
  35. * pISMTPServer: ISMTPServer interface to use for triggering server
  36. * events for this virtual server
  37. *
  38. * pIDomainInfo: pointer to an interface that contains domain info routines
  39. *
  40. * dwVirtualServerInstance: Virtual Server ID
  41. *
  42. * Return value: S_OK if everything is initialized okay.
  43. *
  44. * HISTORY:
  45. * // jstamerj 980217 15:46:26: Created
  46. * // jstamerj 1998/06/25 12:25:34: Added AQConfig/IMSTPServer.
  47. *
  48. ************************************************************/
  49. typedef void (*PCATSRVFN_CALLBACK)(PVOID);
  50. CATEXPDLLCPP HRESULT CATCALLCONV CatInit(
  51. IN AQConfigInfo *pAQConfig,
  52. IN PCATSRVFN_CALLBACK pfn,
  53. IN PVOID pvServiceContext,
  54. IN ISMTPServer *pISMTPServer,
  55. IN IAdvQueueDomainType *pIDomainInfo,
  56. IN DWORD dwVirtualServerInstance,
  57. OUT HANDLE *phCat);
  58. //+------------------------------------------------------------
  59. //
  60. // Function: CatChangeConfig
  61. //
  62. // Synopsis: Changes the configuration of a virtual categorizer
  63. //
  64. // Arguments:
  65. // hCat: handle of virtual categorizer
  66. // pAQConfig: AQConfigInfo pointer
  67. // pISMTPServer: ISMTPServer to use
  68. // pIDomainInfo: interface that contains domain information
  69. //
  70. // Flags for dwMsgCatFlags in AQConfigInfo
  71. #define MSGCATFLAG_RESOLVELOCAL 0x00000001
  72. #define MSGCATFLAG_RESOLVEREMOTE 0x00000002
  73. #define MSGCATFLAG_RESOLVESENDER 0x00000004
  74. #define MSGCATFLAG_RESOLVERECIPIENTS 0x00000008
  75. //
  76. // Returns:
  77. // S_OK: Success
  78. // E_INVALIDARG: Invalid hCat or pAQConfig
  79. //
  80. // History:
  81. // jstamerj 980521 15:47:42: Created.
  82. //
  83. //-------------------------------------------------------------
  84. CATEXPDLLCPP HRESULT CATCALLCONV CatChangeConfig(
  85. IN HANDLE hCat,
  86. IN AQConfigInfo *pAQConfig,
  87. IN ISMTPServer *pISMTPServer,
  88. IN IAdvQueueDomainType *pIDomainInfo);
  89. /************************************************************
  90. * FUNCTION: PFNCAT_COMPLETION (User supplied)
  91. * DESCRIPTION: Completion routine called to accept a categorized IMsg
  92. * PARAMETERS:
  93. * hr: S_OK unless message categorization was not finished.
  94. * CAT_W_SOME_UNDELIVERABLE_MSGS if one or more
  95. * recipient should not be delivered to...
  96. * pContext: User's value passed into CatMsg
  97. * pImsg: IMsg interface of categorized object -- if message was
  98. * bifurcated this parameter will be NULL
  99. * rpgImsg: NULL unless IMsg was bifurcated -- if message was
  100. * bifurcated, this will be a NULL termianted array of
  101. * ptrs to IMsg interfaces.
  102. * NOTE: Either pImsg or rgpImsg will always be NULL (but never both).
  103. *
  104. * Return Value: S_OK if everything is okay (Categorizer will assert
  105. * check this value)
  106. *
  107. * HISTORY:
  108. * // jstamerj 980217 15:47:20: Created
  109. ************************************************************/
  110. typedef HRESULT (CATCALLCONV *PFNCAT_COMPLETION)(/* IN */ HRESULT hr,
  111. /* IN */ PVOID pContext,
  112. /* IN */ IUnknown *pImsg,
  113. /* IN */ IUnknown **rgpImsg);
  114. /************************************************************
  115. * FUNCTION: CatMsg
  116. * DESCRIPTION: Accepts an IMsg object for async categorization
  117. * PARAMETERS:
  118. * hCat: Handle returned from CatInit
  119. * pImsg: IMsg interface for message to categorize
  120. * pfn: Completion routine to call when finished
  121. * pContext: User value passed to completion routine
  122. *
  123. * Return value: S_OK if everything is okay.
  124. *
  125. * HISTORY:
  126. * // jstamerj 980217 15:46:15: Created
  127. ************************************************************/
  128. CATEXPDLLCPP HRESULT CATCALLCONV CatMsg (/* IN */ HANDLE hCat,
  129. /* IN */ IUnknown *pImsg,
  130. /* IN */ PFNCAT_COMPLETION pfn,
  131. /* IN */ LPVOID pContext);
  132. /************************************************************
  133. * FUNCTION: PFNCAT_DLCOMPLETION (User supplied)
  134. * DESCRIPTION: Completion routine called to accept a categorized message
  135. * PARAMETERS:
  136. * hr: S_OK unless message categorization was not finished.
  137. * pContext: User's value passed into CatMsg
  138. * pImsg: IMsg interface of categorized object (with expanded recipients)
  139. * fMatch: TRUE if your user was found
  140. *
  141. * Return Value: S_OK if everything is okay (Categorizer will assert
  142. * check this value)
  143. *
  144. * HISTORY:
  145. * // jstamerj 980217 15:47:20: Created
  146. ************************************************************/
  147. typedef HRESULT (CATCALLCONV *PFNCAT_DLCOMPLETION)(
  148. /* IN */ HRESULT hr,
  149. /* IN */ PVOID pContext,
  150. /* IN */ IUnknown *pImsg,
  151. /* IN */ BOOL fMatch);
  152. /************************************************************
  153. * FUNCTION: CatDLMsg
  154. * DESCRIPTION: Accepts an IMsg object for async categorization
  155. * PARAMETERS:
  156. * hCat: Handle returned from CatInit
  157. * pImsg: IMsg interface to categorize -- each DL should be a recip
  158. * pfn: Completion routine to call when finished
  159. * pContext: User value passed to completion routine
  160. * fMatchOnly: Stop resolving when a match is found?
  161. * CAType: The address type of pszAddress
  162. * pszAddress: THe address you are looking for
  163. *
  164. * Return value: S_OK if everything is okay.
  165. *
  166. * HISTORY:
  167. * // jstamerj 980217 15:46:15: Created
  168. ************************************************************/
  169. CATEXPDLLCPP HRESULT CATCALLCONV CatDLMsg (
  170. /* IN */ HANDLE hCat,
  171. /* IN */ IUnknown *pImsg,
  172. /* IN */ PFNCAT_DLCOMPLETION pfn,
  173. /* IN */ LPVOID pContext,
  174. /* IN */ BOOL fMatchOnly = FALSE,
  175. /* IN */ CAT_ADDRESS_TYPE CAType = CAT_UNKNOWNTYPE,
  176. /* IN */ LPSTR pszAddress = NULL);
  177. /************************************************************
  178. * FUNCTION: CatTerm
  179. * DESCRIPTION: Called when user wishes to terminate categorizer
  180. * opertions with this handle
  181. * PARAMETERS:
  182. * hCat: Categorizer handle received from CatInit
  183. *
  184. * HISTORY:
  185. * // jstamerj 980217 15:47:20: Created
  186. ************************************************************/
  187. CATEXPDLLCPP VOID CATCALLCONV CatTerm(/* IN */ HANDLE hCat);
  188. /************************************************************
  189. * FUNCTION: CatCancel
  190. * DESCRIPTION: Cancels pending searches for this hCat. User's
  191. * completion routine will be called with an error for
  192. * each pending message.
  193. * PARAMETERS:
  194. * hCat: Categorizer handle received from CatInit
  195. *
  196. * HISTORY:
  197. * // jstamerj 980217 15:52:10: Created
  198. ************************************************************/
  199. CATEXPDLLCPP HRESULT CATCALLCONV CatCancel(/* IN */ HANDLE hCat);
  200. /************************************************************
  201. * FUNCTION: CatPrepareForShutdown
  202. * DESCRIPTION: Begin shutdown for this virtual categorizer (hCat).
  203. * Stop accepting messages for categorization and cancel
  204. * pending categorizations.
  205. * PARAMETERS:
  206. * hCat: Categorizer handle received from CatInit
  207. *
  208. * HISTORY:
  209. * // jstamerj 1999/07/19 22:35:17: Created
  210. ************************************************************/
  211. CATEXPDLLCPP VOID CATCALLCONV CatPrepareForShutdown(/* IN */ HANDLE hCat);
  212. /************************************************************
  213. * FUNCTION: CatVerifySMTPAddress
  214. * DESCRIPTION: Verifies a the address corresponds to a valid user or DL
  215. * PARAMETERS:
  216. * hCat: Categorizer handle received from CatInit
  217. * szSMTPAddr SMTP Address to lookup (ex: "user@domain")
  218. *
  219. * Return Values:
  220. * S_OK User exists
  221. * CAT_I_DL This is a distribution list
  222. * CAT_I_FWD This user has a forwarding address
  223. * CAT_E_NORESULT There is no such user/distribution list in the DS.
  224. ************************************************************/
  225. CATEXPDLLCPP HRESULT CATCALLCONV CatVerifySMTPAddress(
  226. /* IN */ HANDLE hCat,
  227. /* IN */ LPTSTR szSMTPAddr);
  228. /************************************************************
  229. * FUNCTION: CatGetForwaringSMTPAddress
  230. * DESCRIPTION: Retreive a user's forwarding address.
  231. * PARAMETERS:
  232. * hCat: Categorizer handle received from CatInit
  233. * szSMTPAddr: SMTP Address to lookup (ex: "user@domain")
  234. * pdwcc: Size of forwarding address buffer in Chars
  235. * (This is set to actuall size of forwarding address
  236. * string (including NULL terminator) on exit)
  237. * szSMTPForward: Buffer where retreived forwarding SMTP address
  238. * will be copied. (can be NULL if *pdwcc is zero)
  239. *
  240. * Return Values:
  241. * S_OK Success
  242. * HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)
  243. * *pdwcc was not large enough to hold the forwarding
  244. * address string.
  245. * CAT_E_DL This is a distribution list.
  246. * CAT_E_NOFWD This user does not have a forwarding address.
  247. * CAT_E_NORESULT There is no such user/distribution list in the DS.
  248. ************************************************************/
  249. CATEXPDLLCPP HRESULT CATCALLCONV CatGetForwardingSMTPAddress(
  250. /* IN */ HANDLE hCat,
  251. /* IN */ LPCTSTR szSMTPAddr,
  252. /* IN,OUT */ PDWORD pdwcc,
  253. /* OUT */ LPTSTR szSMTPForward);
  254. //
  255. // Com support functions for COM categorizer objects
  256. //
  257. //+------------------------------------------------------------
  258. //
  259. // Function: CatDllMain
  260. //
  261. // Synopsis: Handle what cat needs to do in DLLMain
  262. //
  263. // Arguments:
  264. // hInstance: instance of this DLL
  265. // dwReason: Why are you calling me?
  266. // lpReserved
  267. //
  268. // Returns: TRUE
  269. //
  270. // History:
  271. // jstamerj 1998/12/12 23:06:08: Created.
  272. //
  273. //-------------------------------------------------------------
  274. BOOL WINAPI CatDllMain(
  275. HINSTANCE hInstance,
  276. DWORD dwReason,
  277. LPVOID /* lpReserved */);
  278. //+------------------------------------------------------------
  279. //
  280. // Function: RegisterCatServer
  281. //
  282. // Synopsis: Register the categorizer com objects
  283. //
  284. // Arguments:
  285. //
  286. // Returns:
  287. // S_OK: Success
  288. //
  289. // History:
  290. // jstamerj 1998/12/12 15:07:20: Created.
  291. //
  292. //-------------------------------------------------------------
  293. STDAPI RegisterCatServer();
  294. //+------------------------------------------------------------
  295. //
  296. // Function: UnregisterCatServer
  297. //
  298. // Synopsis: Unregister the categorizer com objects
  299. //
  300. // Arguments: NONE
  301. //
  302. // Returns:
  303. // S_OK: Success
  304. //
  305. // History:
  306. // jstamerj 1998/12/12 15:08:09: Created.
  307. //
  308. //-------------------------------------------------------------
  309. STDAPI UnregisterCatServer();
  310. //+------------------------------------------------------------
  311. //
  312. // Function: DllCanUnloadCatNow
  313. //
  314. // Synopsis: Return to COM wether it's okay or not to unload our dll
  315. //
  316. // Arguments: NONE
  317. //
  318. // Returns:
  319. // S_OK: Success, can unload
  320. // S_FALSE: Success, do not unload
  321. //
  322. // History:
  323. // jstamerj 1998/12/12 15:09:02: Created.
  324. //
  325. //-------------------------------------------------------------
  326. STDAPI DllCanUnloadCatNow();
  327. //+------------------------------------------------------------
  328. //
  329. // Function: DllGetCatClassObject
  330. //
  331. // Synopsis: Return the class factory object (an interface to it)
  332. //
  333. // Arguments:
  334. // clsid: The CLSID of the object you want a class factory for
  335. // iid: the interface you want
  336. // ppv: out param to set to the interface pointer
  337. //
  338. // Returns:
  339. // S_OK: Success
  340. // E_NOINTERFACE: don't support that interface
  341. // CLASS_E_CLASSNOTAVAILABLE: don't support that clsid
  342. //
  343. // History:
  344. // jstamerj 1998/12/12 15:11:48: Created.
  345. //
  346. //-------------------------------------------------------------
  347. STDAPI DllGetCatClassObject(
  348. const CLSID& clsid,
  349. const IID& iid,
  350. void **ppv);
  351. //+------------------------------------------------------------
  352. //
  353. // Function: CatGetPerfCounters
  354. //
  355. // Synopsis: Retrieve the categorizer performance counter block
  356. //
  357. // Arguments:
  358. // hCat: Categorizer handle returned from CatInit
  359. // pCatPerfBlock: struct to fill in with counter values
  360. //
  361. // Returns:
  362. // S_OK: Success
  363. //
  364. // History:
  365. // jstamerj 1999/02/26 14:53:21: Created.
  366. //
  367. //-------------------------------------------------------------
  368. HRESULT CatGetPerfCounters(
  369. HANDLE hCat,
  370. PCATPERFBLOCK pCatPerfBlock);
  371. //+------------------------------------------------------------
  372. //
  373. // Function: CatLogEvent
  374. //
  375. // Synopsis: Log an event to the event log
  376. //
  377. // Arguments:
  378. // pISMTPServer: ISMTPServer interface to use for logging
  379. //
  380. // Returns:
  381. // S_OK: Success
  382. //
  383. // History:
  384. // dbraun 2000/09/13 : Created.
  385. //
  386. //-------------------------------------------------------------
  387. HRESULT CatLogEvent(
  388. ISMTPServer *pISMTPServer,
  389. DWORD idMessage,
  390. WORD cSubstrings,
  391. LPCSTR *rgszSubstrings,
  392. DWORD errCode,
  393. LPCSTR szKey,
  394. DWORD dwOptions,
  395. WORD iDebugLevel,
  396. DWORD iMessageString = 0xffffffff);
  397. HRESULT CatLogEvent(
  398. IN ISMTPServerEx *pISMTPServerEx,
  399. IN DWORD idMessage,
  400. IN WORD cSubStrings,
  401. IN LPCSTR *rgpszSubStrings,
  402. IN DWORD errCode,
  403. IN LPCSTR pszKey,
  404. IN DWORD dwOptions,
  405. IN WORD wLogLevel,
  406. IN DWORD iMessageString = 0xffffffff);
  407. #endif // __CAT_H__