crypt32: Moved store functions to vtbl.

This commit is contained in:
Jacek Caban 2013-10-11 16:12:06 +02:00 committed by Alexandre Julliard
parent 73ca9d2d0b
commit fa0b7b7d3d
4 changed files with 53 additions and 41 deletions

View file

@ -40,9 +40,9 @@ typedef struct _WINE_COLLECTIONSTORE
struct list stores;
} WINE_COLLECTIONSTORE;
static void WINAPI CRYPT_CollectionCloseStore(HCERTSTORE store, DWORD dwFlags)
static void Collection_closeStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags)
{
WINE_COLLECTIONSTORE *cs = store;
WINE_COLLECTIONSTORE *cs = (WINE_COLLECTIONSTORE*)store;
WINE_STORE_LIST_ENTRY *entry, *next;
TRACE("(%p, %08x)\n", store, dwFlags);
@ -439,15 +439,14 @@ static BOOL CRYPT_CollectionDeleteCTL(WINECRYPT_CERTSTORE *store,
return ret;
}
static BOOL WINAPI CRYPT_CollectionControl(HCERTSTORE hCertStore, DWORD dwFlags,
static BOOL Collection_control(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags,
DWORD dwCtrlType, void const *pvCtrlPara)
{
BOOL ret;
WINE_COLLECTIONSTORE *store = hCertStore;
WINE_COLLECTIONSTORE *store = (WINE_COLLECTIONSTORE*)cert_store;
WINE_STORE_LIST_ENTRY *entry;
TRACE("(%p, %08x, %d, %p)\n", hCertStore, dwFlags, dwCtrlType,
pvCtrlPara);
TRACE("(%p, %08x, %d, %p)\n", cert_store, dwFlags, dwCtrlType, pvCtrlPara);
if (!store)
return TRUE;
@ -466,10 +465,9 @@ static BOOL WINAPI CRYPT_CollectionControl(HCERTSTORE hCertStore, DWORD dwFlags,
EnterCriticalSection(&store->cs);
LIST_FOR_EACH_ENTRY(entry, &store->stores, WINE_STORE_LIST_ENTRY, entry)
{
if (entry->store->control)
if (entry->store->vtbl->control)
{
ret = entry->store->control(entry->store, dwFlags, dwCtrlType,
pvCtrlPara);
ret = entry->store->vtbl->control(entry->store, dwFlags, dwCtrlType, pvCtrlPara);
if (!ret)
break;
}
@ -478,6 +476,11 @@ static BOOL WINAPI CRYPT_CollectionControl(HCERTSTORE hCertStore, DWORD dwFlags,
return ret;
}
static const store_vtbl_t CollectionStoreVtbl = {
Collection_closeStore,
Collection_control
};
WINECRYPT_CERTSTORE *CRYPT_CollectionOpenStore(HCRYPTPROV hCryptProv,
DWORD dwFlags, const void *pvPara)
{
@ -494,8 +497,7 @@ WINECRYPT_CERTSTORE *CRYPT_CollectionOpenStore(HCRYPTPROV hCryptProv,
if (store)
{
memset(store, 0, sizeof(WINE_COLLECTIONSTORE));
CRYPT_InitStore(&store->hdr, dwFlags, StoreTypeCollection);
store->hdr.closeStore = CRYPT_CollectionCloseStore;
CRYPT_InitStore(&store->hdr, dwFlags, StoreTypeCollection, &CollectionStoreVtbl);
store->hdr.certs.addContext = CRYPT_CollectionAddCert;
store->hdr.certs.enumContext = CRYPT_CollectionEnumCert;
store->hdr.certs.deleteContext = CRYPT_CollectionDeleteCert;
@ -505,7 +507,6 @@ WINECRYPT_CERTSTORE *CRYPT_CollectionOpenStore(HCRYPTPROV hCryptProv,
store->hdr.ctls.addContext = CRYPT_CollectionAddCTL;
store->hdr.ctls.enumContext = CRYPT_CollectionEnumCTL;
store->hdr.ctls.deleteContext = CRYPT_CollectionDeleteCTL;
store->hdr.control = CRYPT_CollectionControl;
InitializeCriticalSection(&store->cs);
store->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": PWINE_COLLECTIONSTORE->cs");
list_init(&store->stores);

View file

@ -244,22 +244,28 @@ typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST;
* - control is optional, but should be implemented by any store that supports
* persistence
*/
typedef struct {
void (*closeStore)(struct WINE_CRYPTCERTSTORE*,DWORD);
BOOL (*control)(struct WINE_CRYPTCERTSTORE*,DWORD,DWORD,void const*);
} store_vtbl_t;
typedef struct WINE_CRYPTCERTSTORE
{
DWORD dwMagic;
LONG ref;
DWORD dwOpenFlags;
CertStoreType type;
PFN_CERT_STORE_PROV_CLOSE closeStore;
const store_vtbl_t *vtbl;
/* FIXME: Move to vtbl (requires collections clean up) */
CONTEXT_FUNCS certs;
CONTEXT_FUNCS crls;
CONTEXT_FUNCS ctls;
PFN_CERT_STORE_PROV_CONTROL control; /* optional */
CONTEXT_PROPERTY_LIST *properties;
} WINECRYPT_CERTSTORE;
void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags,
CertStoreType type) DECLSPEC_HIDDEN;
CertStoreType type, const store_vtbl_t*) DECLSPEC_HIDDEN;
void CRYPT_FreeStore(WINECRYPT_CERTSTORE *store) DECLSPEC_HIDDEN;
BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0,
DWORD unk1) DECLSPEC_HIDDEN;

View file

@ -41,9 +41,9 @@ typedef struct _WINE_PROVIDERSTORE
PFN_CERT_STORE_PROV_CONTROL provControl;
} WINE_PROVIDERSTORE;
static void WINAPI CRYPT_ProvCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
static void ProvStore_closeStore(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags)
{
WINE_PROVIDERSTORE *store = hCertStore;
WINE_PROVIDERSTORE *store = (WINE_PROVIDERSTORE*)cert_store;
TRACE("(%p, %08x)\n", store, dwFlags);
@ -247,13 +247,12 @@ static BOOL CRYPT_ProvDeleteCTL(WINECRYPT_CERTSTORE *store, void *ctl)
return ret;
}
static BOOL WINAPI CRYPT_ProvControl(HCERTSTORE hCertStore, DWORD dwFlags,
DWORD dwCtrlType, void const *pvCtrlPara)
static BOOL ProvStore_control(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags, DWORD dwCtrlType, void const *pvCtrlPara)
{
WINE_PROVIDERSTORE *store = hCertStore;
WINE_PROVIDERSTORE *store = (WINE_PROVIDERSTORE*)cert_store;
BOOL ret = TRUE;
TRACE("(%p, %08x, %d, %p)\n", hCertStore, dwFlags, dwCtrlType,
TRACE("(%p, %08x, %d, %p)\n", store, dwFlags, dwCtrlType,
pvCtrlPara);
if (store->provControl)
@ -262,6 +261,11 @@ static BOOL WINAPI CRYPT_ProvControl(HCERTSTORE hCertStore, DWORD dwFlags,
return ret;
}
static const store_vtbl_t ProvStoreVtbl = {
ProvStore_closeStore,
ProvStore_control
};
WINECRYPT_CERTSTORE *CRYPT_ProvCreateStore(DWORD dwFlags,
WINECRYPT_CERTSTORE *memStore, const CERT_STORE_PROV_INFO *pProvInfo)
{
@ -269,7 +273,7 @@ WINECRYPT_CERTSTORE *CRYPT_ProvCreateStore(DWORD dwFlags,
if (ret)
{
CRYPT_InitStore(&ret->hdr, dwFlags, StoreTypeProvider);
CRYPT_InitStore(&ret->hdr, dwFlags, StoreTypeProvider, &ProvStoreVtbl);
ret->dwStoreProvFlags = pProvInfo->dwStoreProvFlags;
if (ret->dwStoreProvFlags & CERT_STORE_PROV_EXTERNAL_FLAG)
{
@ -279,7 +283,6 @@ WINECRYPT_CERTSTORE *CRYPT_ProvCreateStore(DWORD dwFlags,
else
ret->memStore = memStore;
ret->hStoreProv = pProvInfo->hStoreProv;
ret->hdr.closeStore = CRYPT_ProvCloseStore;
ret->hdr.certs.addContext = CRYPT_ProvAddCert;
ret->hdr.certs.enumContext = CRYPT_ProvEnumCert;
ret->hdr.certs.deleteContext = CRYPT_ProvDeleteCert;
@ -289,7 +292,6 @@ WINECRYPT_CERTSTORE *CRYPT_ProvCreateStore(DWORD dwFlags,
ret->hdr.ctls.addContext = CRYPT_ProvAddCTL;
ret->hdr.ctls.enumContext = CRYPT_ProvEnumCTL;
ret->hdr.ctls.deleteContext = CRYPT_ProvDeleteCTL;
ret->hdr.control = CRYPT_ProvControl;
if (pProvInfo->cStoreProvFunc > CERT_STORE_PROV_CLOSE_FUNC)
ret->provCloseStore =
pProvInfo->rgpvStoreProvFunc[CERT_STORE_PROV_CLOSE_FUNC];

View file

@ -94,13 +94,13 @@ typedef struct _WINE_MEMSTORE
struct ContextList *ctls;
} WINE_MEMSTORE;
void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags,
CertStoreType type)
void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags, CertStoreType type, const store_vtbl_t *vtbl)
{
store->ref = 1;
store->dwMagic = WINE_CRYPTCERTSTORE_MAGIC;
store->type = type;
store->dwOpenFlags = dwFlags;
store->vtbl = vtbl;
store->properties = NULL;
}
@ -284,16 +284,9 @@ static BOOL CRYPT_MemDeleteCtl(WINECRYPT_CERTSTORE *store, void *pCtlContext)
return ret;
}
static BOOL WINAPI CRYPT_MemControl(HCERTSTORE hCertStore, DWORD dwFlags,
DWORD dwCtrlType, void const *pvCtrlPara)
static void MemStore_closeStore(WINECRYPT_CERTSTORE *cert_store, DWORD dwFlags)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
static void WINAPI CRYPT_MemCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
{
WINE_MEMSTORE *store = hCertStore;
WINE_MEMSTORE *store = (WINE_MEMSTORE*)cert_store;
TRACE("(%p, %08x)\n", store, dwFlags);
if (dwFlags)
@ -305,6 +298,18 @@ static void WINAPI CRYPT_MemCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
CRYPT_FreeStore((WINECRYPT_CERTSTORE*)store);
}
static BOOL MemStore_control(WINECRYPT_CERTSTORE *store, DWORD dwFlags,
DWORD dwCtrlType, void const *pvCtrlPara)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
static const store_vtbl_t MemStoreVtbl = {
MemStore_closeStore,
MemStore_control
};
static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv,
DWORD dwFlags, const void *pvPara)
{
@ -323,8 +328,7 @@ static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv,
if (store)
{
memset(store, 0, sizeof(WINE_MEMSTORE));
CRYPT_InitStore(&store->hdr, dwFlags, StoreTypeMem);
store->hdr.closeStore = CRYPT_MemCloseStore;
CRYPT_InitStore(&store->hdr, dwFlags, StoreTypeMem, &MemStoreVtbl);
store->hdr.certs.addContext = CRYPT_MemAddCert;
store->hdr.certs.enumContext = CRYPT_MemEnumCert;
store->hdr.certs.deleteContext = CRYPT_MemDeleteCert;
@ -334,7 +338,6 @@ static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv,
store->hdr.ctls.addContext = CRYPT_MemAddCtl;
store->hdr.ctls.enumContext = CRYPT_MemEnumCtl;
store->hdr.ctls.deleteContext = CRYPT_MemDeleteCtl;
store->hdr.control = CRYPT_MemControl;
store->certs = ContextList_Create(pCertInterface,
sizeof(CERT_CONTEXT));
store->crls = ContextList_Create(pCRLInterface,
@ -1232,7 +1235,7 @@ BOOL WINAPI CertCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
{
TRACE("%p's ref count is 0, freeing\n", hcs);
hcs->dwMagic = 0;
hcs->closeStore(hcs, dwFlags);
hcs->vtbl->closeStore(hcs, dwFlags);
}
else
TRACE("%p's ref count is %d\n", hcs, hcs->ref);
@ -1254,8 +1257,8 @@ BOOL WINAPI CertControlStore(HCERTSTORE hCertStore, DWORD dwFlags,
ret = FALSE;
else
{
if (hcs->control)
ret = hcs->control(hCertStore, dwFlags, dwCtrlType, pvCtrlPara);
if (hcs->vtbl->control)
ret = hcs->vtbl->control(hcs, dwFlags, dwCtrlType, pvCtrlPara);
else
ret = TRUE;
}