Michael Stefaniuc : urlmon: Standardize the COM usage in sec_mgr.c.

Alexandre Julliard julliard at winehq.org
Tue Dec 7 10:59:28 CST 2010


Module: wine
Branch: master
Commit: d98e21035105a826ce243c960dd93fbf64804467
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=d98e21035105a826ce243c960dd93fbf64804467

Author: Michael Stefaniuc <mstefani at redhat.de>
Date:   Mon Dec  6 23:34:25 2010 +0100

urlmon: Standardize the COM usage in sec_mgr.c.

---

 dlls/urlmon/sec_mgr.c |   54 ++++++++++++++++++++++++++++--------------------
 1 files changed, 31 insertions(+), 23 deletions(-)

diff --git a/dlls/urlmon/sec_mgr.c b/dlls/urlmon/sec_mgr.c
index f984aa4..6b12a9a 100644
--- a/dlls/urlmon/sec_mgr.c
+++ b/dlls/urlmon/sec_mgr.c
@@ -295,7 +295,7 @@ static HRESULT get_action_policy(DWORD zone, DWORD action, BYTE *policy, DWORD s
  *
  */
 typedef struct {
-    const IInternetSecurityManagerVtbl* lpInternetSecurityManagerVtbl;
+    IInternetSecurityManager IInternetSecurityManager_iface;
 
     LONG ref;
 
@@ -303,11 +303,14 @@ typedef struct {
     IInternetSecurityManager *custom_manager;
 } SecManagerImpl;
 
-#define SECMGR_THIS(iface) DEFINE_THIS(SecManagerImpl, InternetSecurityManager, iface)
+static inline SecManagerImpl *impl_from_IInternetSecurityManager(IInternetSecurityManager *iface)
+{
+    return CONTAINING_RECORD(iface, SecManagerImpl, IInternetSecurityManager_iface);
+}
 
 static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* iface,REFIID riid,void** ppvObject)
 {
-    SecManagerImpl *This = SECMGR_THIS(iface);
+    SecManagerImpl *This = impl_from_IInternetSecurityManager(iface);
 
     TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppvObject);
 
@@ -337,7 +340,7 @@ static HRESULT WINAPI SecManagerImpl_QueryInterface(IInternetSecurityManager* if
 
 static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface)
 {
-    SecManagerImpl *This = SECMGR_THIS(iface);
+    SecManagerImpl *This = impl_from_IInternetSecurityManager(iface);
     ULONG refCount = InterlockedIncrement(&This->ref);
 
     TRACE("(%p) ref=%u\n", This, refCount);
@@ -347,7 +350,7 @@ static ULONG WINAPI SecManagerImpl_AddRef(IInternetSecurityManager* iface)
 
 static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
 {
-    SecManagerImpl *This = SECMGR_THIS(iface);
+    SecManagerImpl *This = impl_from_IInternetSecurityManager(iface);
     ULONG refCount = InterlockedDecrement(&This->ref);
 
     TRACE("(%p) ref=%u\n", This, refCount);
@@ -370,7 +373,7 @@ static ULONG WINAPI SecManagerImpl_Release(IInternetSecurityManager* iface)
 static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManager *iface,
                                                      IInternetSecurityMgrSite *pSite)
 {
-    SecManagerImpl *This = SECMGR_THIS(iface);
+    SecManagerImpl *This = impl_from_IInternetSecurityManager(iface);
 
     TRACE("(%p)->(%p)\n", This, pSite);
 
@@ -405,7 +408,7 @@ static HRESULT WINAPI SecManagerImpl_SetSecuritySite(IInternetSecurityManager *i
 static HRESULT WINAPI SecManagerImpl_GetSecuritySite(IInternetSecurityManager *iface,
                                                      IInternetSecurityMgrSite **ppSite)
 {
-    SecManagerImpl *This = SECMGR_THIS(iface);
+    SecManagerImpl *This = impl_from_IInternetSecurityManager(iface);
 
     TRACE("(%p)->(%p)\n", This, ppSite);
 
@@ -423,7 +426,7 @@ static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *ifac
                                                   LPCWSTR pwszUrl, DWORD *pdwZone,
                                                   DWORD dwFlags)
 {
-    SecManagerImpl *This = SECMGR_THIS(iface);
+    SecManagerImpl *This = impl_from_IInternetSecurityManager(iface);
     HRESULT hres;
 
     TRACE("(%p)->(%s %p %08x)\n", iface, debugstr_w(pwszUrl), pdwZone, dwFlags);
@@ -449,7 +452,7 @@ static HRESULT WINAPI SecManagerImpl_MapUrlToZone(IInternetSecurityManager *ifac
 static HRESULT WINAPI SecManagerImpl_GetSecurityId(IInternetSecurityManager *iface, 
         LPCWSTR pwszUrl, BYTE *pbSecurityId, DWORD *pcbSecurityId, DWORD_PTR dwReserved)
 {
-    SecManagerImpl *This = SECMGR_THIS(iface);
+    SecManagerImpl *This = impl_from_IInternetSecurityManager(iface);
     LPWSTR url, ptr, ptr2;
     DWORD zone, len;
     HRESULT hres;
@@ -529,7 +532,7 @@ static HRESULT WINAPI SecManagerImpl_ProcessUrlAction(IInternetSecurityManager *
                                                       BYTE *pContext, DWORD cbContext,
                                                       DWORD dwFlags, DWORD dwReserved)
 {
-    SecManagerImpl *This = SECMGR_THIS(iface);
+    SecManagerImpl *This = impl_from_IInternetSecurityManager(iface);
     DWORD zone, policy;
     HRESULT hres;
 
@@ -584,7 +587,7 @@ static HRESULT WINAPI SecManagerImpl_QueryCustomPolicy(IInternetSecurityManager
                                                        BYTE *pContext, DWORD cbContext,
                                                        DWORD dwReserved)
 {
-    SecManagerImpl *This = SECMGR_THIS(iface);
+    SecManagerImpl *This = impl_from_IInternetSecurityManager(iface);
     HRESULT hres;
 
     TRACE("(%p)->(%s %s %p %p %p %08x %08x )\n", iface, debugstr_w(pwszUrl), debugstr_guid(guidKey),
@@ -604,7 +607,7 @@ static HRESULT WINAPI SecManagerImpl_QueryCustomPolicy(IInternetSecurityManager
 static HRESULT WINAPI SecManagerImpl_SetZoneMapping(IInternetSecurityManager *iface,
                                                     DWORD dwZone, LPCWSTR pwszPattern, DWORD dwFlags)
 {
-    SecManagerImpl *This = SECMGR_THIS(iface);
+    SecManagerImpl *This = impl_from_IInternetSecurityManager(iface);
     HRESULT hres;
 
     TRACE("(%p)->(%08x %s %08x)\n", iface, dwZone, debugstr_w(pwszPattern),dwFlags);
@@ -623,7 +626,7 @@ static HRESULT WINAPI SecManagerImpl_SetZoneMapping(IInternetSecurityManager *if
 static HRESULT WINAPI SecManagerImpl_GetZoneMappings(IInternetSecurityManager *iface,
         DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags)
 {
-    SecManagerImpl *This = SECMGR_THIS(iface);
+    SecManagerImpl *This = impl_from_IInternetSecurityManager(iface);
     HRESULT hres;
 
     TRACE("(%p)->(%08x %p %08x)\n", iface, dwZone, ppenumString,dwFlags);
@@ -662,7 +665,7 @@ HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
     This = heap_alloc(sizeof(*This));
 
     /* Initialize the virtual function table. */
-    This->lpInternetSecurityManagerVtbl = &VT_SecManagerImpl;
+    This->IInternetSecurityManager_iface.lpVtbl = &VT_SecManagerImpl;
 
     This->ref = 1;
     This->mgrsite = NULL;
@@ -680,12 +683,17 @@ HRESULT SecManagerImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
  *
  */
 typedef struct {
-    const IInternetZoneManagerEx2Vtbl* lpVtbl;
+    IInternetZoneManagerEx2 IInternetZoneManagerEx2_iface;
     LONG ref;
     LPDWORD *zonemaps;
     DWORD zonemap_count;
 } ZoneMgrImpl;
 
+static inline ZoneMgrImpl *impl_from_IInternetZoneManagerEx2(IInternetZoneManagerEx2 *iface)
+{
+    return CONTAINING_RECORD(iface, ZoneMgrImpl, IInternetZoneManagerEx2_iface);
+}
+
 
 /***********************************************************************
  * build_zonemap_from_reg [internal]
@@ -750,7 +758,7 @@ cleanup:
  */
 static HRESULT WINAPI ZoneMgrImpl_QueryInterface(IInternetZoneManagerEx2* iface, REFIID riid, void** ppvObject)
 {
-    ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
+    ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
 
     TRACE("(%p)->(%s,%p)\n", This, debugstr_guid(riid), ppvObject);
 
@@ -783,7 +791,7 @@ static HRESULT WINAPI ZoneMgrImpl_QueryInterface(IInternetZoneManagerEx2* iface,
  */
 static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManagerEx2* iface)
 {
-    ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
+    ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
     ULONG refCount = InterlockedIncrement(&This->ref);
 
     TRACE("(%p)->(ref before=%u)\n",This, refCount - 1);
@@ -796,7 +804,7 @@ static ULONG WINAPI ZoneMgrImpl_AddRef(IInternetZoneManagerEx2* iface)
  */
 static ULONG WINAPI ZoneMgrImpl_Release(IInternetZoneManagerEx2* iface)
 {
-    ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
+    ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
     ULONG refCount = InterlockedDecrement(&This->ref);
 
     TRACE("(%p)->(ref before=%u)\n",This, refCount + 1);
@@ -818,7 +826,7 @@ static HRESULT WINAPI ZoneMgrImpl_GetZoneAttributes(IInternetZoneManagerEx2* ifa
                                                     DWORD dwZone,
                                                     ZONEATTRIBUTES* pZoneAttributes)
 {
-    ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
+    ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
     HRESULT hr;
     HKEY hcu;
     HKEY hklm = NULL;
@@ -957,7 +965,7 @@ static HRESULT WINAPI ZoneMgrImpl_CreateZoneEnumerator(IInternetZoneManagerEx2*
                                                        DWORD* pdwCount,
                                                        DWORD dwFlags)
 {
-    ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
+    ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
     LPDWORD * new_maps;
     LPDWORD data;
     DWORD i;
@@ -1012,7 +1020,7 @@ static HRESULT WINAPI ZoneMgrImpl_GetZoneAt(IInternetZoneManagerEx2* iface,
                                             DWORD dwIndex,
                                             DWORD* pdwZone)
 {
-    ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
+    ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
     LPDWORD data;
 
     TRACE("(%p)->(0x%08x, %d, %p)\n", This, dwEnum, dwIndex, pdwZone);
@@ -1035,7 +1043,7 @@ static HRESULT WINAPI ZoneMgrImpl_GetZoneAt(IInternetZoneManagerEx2* iface,
 static HRESULT WINAPI ZoneMgrImpl_DestroyZoneEnumerator(IInternetZoneManagerEx2* iface,
                                                         DWORD dwEnum)
 {
-    ZoneMgrImpl* This = (ZoneMgrImpl*)iface;
+    ZoneMgrImpl* This = impl_from_IInternetZoneManagerEx2(iface);
     LPDWORD data;
 
     TRACE("(%p)->(0x%08x)\n", This, dwEnum);
@@ -1202,7 +1210,7 @@ HRESULT ZoneMgrImpl_Construct(IUnknown *pUnkOuter, LPVOID *ppobj)
     ZoneMgrImpl* ret = heap_alloc_zero(sizeof(ZoneMgrImpl));
 
     TRACE("(%p %p)\n", pUnkOuter, ppobj);
-    ret->lpVtbl = &ZoneMgrImplVtbl;
+    ret->IInternetZoneManagerEx2_iface.lpVtbl = &ZoneMgrImplVtbl;
     ret->ref = 1;
     *ppobj = (IInternetZoneManagerEx*)ret;
 




More information about the wine-cvs mailing list