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.

482 lines
9.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1995 - 1999
  6. //
  7. // File: viewrow.cpp
  8. //
  9. // Contents: IEnumCERTVIEWROW IDispatch helper functions
  10. //
  11. //--------------------------------------------------------------------------
  12. #include <pch.cpp>
  13. #pragma hdrstop
  14. #include <stdlib.h>
  15. #include "csdisp.h"
  16. #include "csprop.h"
  17. #define __dwFILE__ __dwFILE_CERTLIB_VIEWROW_CPP__
  18. //+------------------------------------------------------------------------
  19. // IEnumCERTVIEWROW dispatch support
  20. //+------------------------------------
  21. // OpenConnection method:
  22. static OLECHAR *_apszNext[] = {
  23. TEXT("Next"),
  24. };
  25. //+------------------------------------
  26. // EnumCertViewColumn method:
  27. static OLECHAR *_apszEnumCertViewColumn[] = {
  28. TEXT("EnumCertViewColumn"),
  29. };
  30. //+------------------------------------
  31. // EnumCertViewAttribute method:
  32. static OLECHAR *_apszEnumCertViewAttribute[] = {
  33. TEXT("EnumCertViewAttribute"),
  34. TEXT("Flags"),
  35. };
  36. //+------------------------------------
  37. // EnumCertViewExtension method:
  38. static OLECHAR *_apszEnumCertViewExtension[] = {
  39. TEXT("EnumCertViewExtension"),
  40. TEXT("Flags"),
  41. };
  42. //+------------------------------------
  43. // Skip method:
  44. static OLECHAR *_apszSkip[] = {
  45. TEXT("Skip"),
  46. TEXT("celt"),
  47. };
  48. //+------------------------------------
  49. // Reset method:
  50. static OLECHAR *_apszReset[] = {
  51. TEXT("Reset"),
  52. };
  53. //+------------------------------------
  54. // Clone method:
  55. static OLECHAR *_apszClone[] = {
  56. TEXT("Clone"),
  57. };
  58. //+------------------------------------
  59. // GetMaxIndex method:
  60. static OLECHAR *_apszGetMaxIndex[] = {
  61. TEXT("GetMaxIndex"),
  62. };
  63. //+------------------------------------
  64. // Dispatch Table:
  65. DISPATCHTABLE g_adtViewRow[] =
  66. {
  67. #define VIEWROW_NEXT 0
  68. DECLARE_DISPATCH_ENTRY(_apszNext)
  69. #define VIEWROW_ENUMCERTVIEWCOLUMN 1
  70. DECLARE_DISPATCH_ENTRY(_apszEnumCertViewColumn)
  71. #define VIEWROW_ENUMCERTVIEWATTRIBUTE 2
  72. DECLARE_DISPATCH_ENTRY(_apszEnumCertViewAttribute)
  73. #define VIEWROW_ENUMCERTVIEWEXTENSION 3
  74. DECLARE_DISPATCH_ENTRY(_apszEnumCertViewExtension)
  75. #define VIEWROW_SKIP 4
  76. DECLARE_DISPATCH_ENTRY(_apszSkip)
  77. #define VIEWROW_RESET 5
  78. DECLARE_DISPATCH_ENTRY(_apszReset)
  79. #define VIEWROW_CLONE 6
  80. DECLARE_DISPATCH_ENTRY(_apszClone)
  81. #define VIEWROW_GETMAXINDEX 7
  82. DECLARE_DISPATCH_ENTRY(_apszGetMaxIndex)
  83. };
  84. #define CVIEWROWDISPATCH (ARRAYSIZE(g_adtViewRow))
  85. HRESULT
  86. ViewRow_Init2(
  87. IN BOOL fIDispatch,
  88. IN IEnumCERTVIEWROW *pEnumRow,
  89. OUT DISPATCHINTERFACE *pdiViewRow)
  90. {
  91. HRESULT hr;
  92. IDispatch *pDispatch = NULL;
  93. pdiViewRow->pDispatchTable = NULL;
  94. pdiViewRow->pDispatch = NULL;
  95. pdiViewRow->pUnknown = NULL;
  96. if (fIDispatch)
  97. {
  98. hr = pEnumRow->QueryInterface(
  99. IID_IDispatch,
  100. (VOID **) &pDispatch);
  101. _JumpIfError(hr, error, "QueryInterface");
  102. hr = DispatchGetIds(
  103. pDispatch,
  104. CVIEWROWDISPATCH,
  105. g_adtViewRow,
  106. pdiViewRow);
  107. _JumpIfError(hr, error, "DispatchGetIds");
  108. pdiViewRow->pDispatch = pDispatch;
  109. pDispatch = NULL;
  110. }
  111. else
  112. {
  113. pEnumRow->AddRef();
  114. pdiViewRow->pUnknown = (IUnknown *) pEnumRow;
  115. hr = S_OK;
  116. }
  117. pdiViewRow->pDispatchTable = g_adtViewRow;
  118. error:
  119. if (NULL != pDispatch)
  120. {
  121. pDispatch->Release();
  122. }
  123. return(hr);
  124. }
  125. VOID
  126. ViewRow_Release(
  127. IN OUT DISPATCHINTERFACE *pdiViewRow)
  128. {
  129. DispatchRelease(pdiViewRow);
  130. }
  131. HRESULT
  132. ViewRow_Next(
  133. IN DISPATCHINTERFACE *pdiViewRow,
  134. OUT LONG *pIndex)
  135. {
  136. HRESULT hr;
  137. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  138. if (NULL != pdiViewRow->pDispatch)
  139. {
  140. hr = DispatchInvoke(
  141. pdiViewRow,
  142. VIEWROW_NEXT,
  143. 0,
  144. NULL,
  145. VT_I4,
  146. pIndex);
  147. _JumpIfError2(hr, error, "Invoke(Next)", S_FALSE);
  148. }
  149. else
  150. {
  151. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->Next(pIndex);
  152. _JumpIfError2(hr, error, "Next", S_FALSE);
  153. }
  154. error:
  155. return(hr);
  156. }
  157. HRESULT
  158. ViewRow_EnumCertViewColumn(
  159. IN DISPATCHINTERFACE *pdiViewRow,
  160. OUT DISPATCHINTERFACE *pdiViewColumn)
  161. {
  162. HRESULT hr;
  163. IEnumCERTVIEWCOLUMN *pEnumColumn = NULL;
  164. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  165. if (NULL != pdiViewRow->pDispatch)
  166. {
  167. hr = DispatchInvoke(
  168. pdiViewRow,
  169. VIEWROW_ENUMCERTVIEWCOLUMN,
  170. 0,
  171. NULL,
  172. VT_DISPATCH,
  173. &pEnumColumn);
  174. _JumpIfError(hr, error, "Invoke(EnumCertViewColumn)");
  175. }
  176. else
  177. {
  178. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->EnumCertViewColumn(
  179. &pEnumColumn);
  180. _JumpIfError(hr, error, "EnumCertViewColumn");
  181. }
  182. hr = ViewColumn_Init2(
  183. NULL != pdiViewRow->pDispatch,
  184. pEnumColumn,
  185. pdiViewColumn);
  186. _JumpIfError(hr, error, "ViewColumn_Init2");
  187. error:
  188. if (NULL != pEnumColumn)
  189. {
  190. pEnumColumn->Release();
  191. }
  192. return(hr);
  193. }
  194. HRESULT
  195. ViewRow_EnumCertViewAttribute(
  196. IN DISPATCHINTERFACE *pdiViewRow,
  197. IN LONG Flags,
  198. OUT DISPATCHINTERFACE *pdiViewAttribute)
  199. {
  200. HRESULT hr;
  201. IEnumCERTVIEWATTRIBUTE *pEnumAttribute = NULL;
  202. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  203. if (NULL != pdiViewRow->pDispatch)
  204. {
  205. VARIANT avar[1];
  206. avar[0].vt = VT_I4;
  207. avar[0].lVal = Flags;
  208. hr = DispatchInvoke(
  209. pdiViewRow,
  210. VIEWROW_ENUMCERTVIEWATTRIBUTE,
  211. ARRAYSIZE(avar),
  212. avar,
  213. VT_DISPATCH,
  214. &pEnumAttribute);
  215. _JumpIfError(hr, error, "Invoke(EnumCertViewAttribute)");
  216. }
  217. else
  218. {
  219. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->EnumCertViewAttribute(
  220. Flags,
  221. &pEnumAttribute);
  222. _JumpIfError(hr, error, "EnumCertViewAttribute");
  223. }
  224. hr = ViewAttribute_Init2(
  225. NULL != pdiViewRow->pDispatch,
  226. pEnumAttribute,
  227. pdiViewAttribute);
  228. _JumpIfError(hr, error, "ViewAttribute_Init2");
  229. error:
  230. if (NULL != pEnumAttribute)
  231. {
  232. pEnumAttribute->Release();
  233. }
  234. return(hr);
  235. }
  236. HRESULT
  237. ViewRow_EnumCertViewExtension(
  238. IN DISPATCHINTERFACE *pdiViewRow,
  239. IN LONG Flags,
  240. OUT DISPATCHINTERFACE *pdiViewExtension)
  241. {
  242. HRESULT hr;
  243. IEnumCERTVIEWEXTENSION *pEnumExtension = NULL;
  244. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  245. if (NULL != pdiViewRow->pDispatch)
  246. {
  247. VARIANT avar[1];
  248. avar[0].vt = VT_I4;
  249. avar[0].lVal = Flags;
  250. hr = DispatchInvoke(
  251. pdiViewRow,
  252. VIEWROW_ENUMCERTVIEWEXTENSION,
  253. ARRAYSIZE(avar),
  254. avar,
  255. VT_DISPATCH,
  256. &pEnumExtension);
  257. _JumpIfError(hr, error, "Invoke(EnumCertViewExtension)");
  258. }
  259. else
  260. {
  261. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->EnumCertViewExtension(
  262. Flags,
  263. &pEnumExtension);
  264. _JumpIfError(hr, error, "EnumCertViewExtension");
  265. }
  266. hr = ViewExtension_Init2(
  267. NULL != pdiViewRow->pDispatch,
  268. pEnumExtension,
  269. pdiViewExtension);
  270. _JumpIfError(hr, error, "ViewExtension_Init2");
  271. error:
  272. if (NULL != pEnumExtension)
  273. {
  274. pEnumExtension->Release();
  275. }
  276. return(hr);
  277. }
  278. HRESULT
  279. ViewRow_Skip(
  280. IN DISPATCHINTERFACE *pdiViewRow,
  281. IN LONG celt)
  282. {
  283. HRESULT hr;
  284. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  285. if (NULL != pdiViewRow->pDispatch)
  286. {
  287. VARIANT avar[1];
  288. avar[0].vt = VT_I4;
  289. avar[0].lVal = celt;
  290. hr = DispatchInvoke(
  291. pdiViewRow,
  292. VIEWROW_SKIP,
  293. ARRAYSIZE(avar),
  294. avar,
  295. 0,
  296. NULL);
  297. _JumpIfError(hr, error, "Invoke(Skip)");
  298. }
  299. else
  300. {
  301. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->Skip(celt);
  302. _JumpIfError(hr, error, "Skip");
  303. }
  304. error:
  305. return(hr);
  306. }
  307. HRESULT
  308. ViewRow_Reset(
  309. IN DISPATCHINTERFACE *pdiViewRow)
  310. {
  311. HRESULT hr;
  312. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  313. if (NULL != pdiViewRow->pDispatch)
  314. {
  315. hr = DispatchInvoke(
  316. pdiViewRow,
  317. VIEWROW_RESET,
  318. 0,
  319. NULL,
  320. 0,
  321. NULL);
  322. _JumpIfError(hr, error, "Invoke(Reset)");
  323. }
  324. else
  325. {
  326. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->Reset();
  327. _JumpIfError(hr, error, "Reset");
  328. }
  329. error:
  330. return(hr);
  331. }
  332. HRESULT
  333. ViewRow_Clone(
  334. IN DISPATCHINTERFACE *pdiViewRow,
  335. OUT DISPATCHINTERFACE *pdiViewRowClone)
  336. {
  337. HRESULT hr;
  338. IEnumCERTVIEWROW *pEnumRow = NULL;
  339. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  340. if (NULL != pdiViewRow->pDispatch)
  341. {
  342. hr = DispatchInvoke(
  343. pdiViewRow,
  344. VIEWROW_CLONE,
  345. 0,
  346. NULL,
  347. VT_DISPATCH,
  348. &pEnumRow);
  349. _JumpIfError(hr, error, "Invoke(Clone)");
  350. }
  351. else
  352. {
  353. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->Clone(&pEnumRow);
  354. _JumpIfError(hr, error, "Clone");
  355. }
  356. hr = ViewRow_Init2(
  357. NULL != pdiViewRow->pDispatch,
  358. pEnumRow,
  359. pdiViewRowClone);
  360. _JumpIfError(hr, error, "ViewRow_Init2");
  361. error:
  362. if (NULL != pEnumRow)
  363. {
  364. pEnumRow->Release();
  365. }
  366. return(hr);
  367. }
  368. HRESULT
  369. ViewRow_GetMaxIndex(
  370. IN DISPATCHINTERFACE *pdiViewRow,
  371. OUT LONG *pIndex)
  372. {
  373. HRESULT hr;
  374. CSASSERT(NULL != pdiViewRow && NULL != pdiViewRow->pDispatchTable);
  375. if (NULL != pdiViewRow->pDispatch)
  376. {
  377. hr = DispatchInvoke(
  378. pdiViewRow,
  379. VIEWROW_GETMAXINDEX,
  380. 0,
  381. NULL,
  382. VT_I4,
  383. pIndex);
  384. _JumpIfError2(hr, error, "Invoke(GetMaxIndex)", E_UNEXPECTED);
  385. }
  386. else
  387. {
  388. hr = ((IEnumCERTVIEWROW *) pdiViewRow->pUnknown)->GetMaxIndex(pIndex);
  389. _JumpIfError2(hr, error, "GetMaxIndex", E_UNEXPECTED);
  390. }
  391. error:
  392. return(hr);
  393. }