Commit 63eed79d authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

crypt32: Share more code between memory store addContext implementations.

parent 23884726
......@@ -110,34 +110,6 @@ void Context_CopyProperties(const void *to, const void *from)
ContextPropertyList_Copy(toProperties, fromProperties);
}
context_t *ContextList_Add(ContextList *list, CRITICAL_SECTION *cs, context_t *toLink,
context_t *existing, struct WINE_CRYPTCERTSTORE *store, BOOL use_link)
{
context_t *context;
TRACE("(%p, %p, %p)\n", list, toLink, existing);
context = toLink->vtbl->clone(toLink, store, use_link);
if (context)
{
TRACE("adding %p\n", context);
EnterCriticalSection(cs);
if (existing)
{
context->u.entry.prev = existing->u.entry.prev;
context->u.entry.next = existing->u.entry.next;
context->u.entry.prev->next = &context->u.entry;
context->u.entry.next->prev = &context->u.entry;
list_init(&existing->u.entry);
Context_Release(existing);
}
else
list_add_head(list, &context->u.entry);
LeaveCriticalSection(cs);
}
return context;
}
context_t *ContextList_Enum(ContextList *list, CRITICAL_SECTION *cs, context_t *prev)
{
struct list *listNext;
......
......@@ -438,9 +438,6 @@ void ContextPropertyList_Free(CONTEXT_PROPERTY_LIST *list) DECLSPEC_HIDDEN;
*/
typedef struct list ContextList;
context_t *ContextList_Add(ContextList *list, CRITICAL_SECTION *cs, context_t *toLink, context_t *toReplace,
struct WINE_CRYPTCERTSTORE *store, BOOL use_link) DECLSPEC_HIDDEN;
context_t *ContextList_Enum(ContextList *list, CRITICAL_SECTION *cs, context_t *prev) DECLSPEC_HIDDEN;
/* Removes a context from the list. Returns TRUE if the context was removed,
......
......@@ -143,25 +143,47 @@ BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0,
return TRUE;
}
static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
static BOOL MemStore_addContext(WINE_MEMSTORE *store, struct list *list, context_t *orig_context,
context_t *existing, context_t **ret_context, BOOL use_link)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
context_t *context;
TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
context = ContextList_Add(&ms->certs, &ms->cs, cert, toReplace, store, use_link);
context = orig_context->vtbl->clone(orig_context, &store->hdr, use_link);
if (!context)
return FALSE;
if (ppStoreContext) {
TRACE("adding %p\n", context);
EnterCriticalSection(&store->cs);
if (existing) {
context->u.entry.prev = existing->u.entry.prev;
context->u.entry.next = existing->u.entry.next;
context->u.entry.prev->next = &context->u.entry;
context->u.entry.next->prev = &context->u.entry;
list_init(&existing->u.entry);
Context_Release(existing);
}else {
list_add_head(list, &context->u.entry);
}
LeaveCriticalSection(&store->cs);
if(ret_context) {
Context_AddRef(context);
*ppStoreContext = context;
*ret_context = context;
}
return TRUE;
}
static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
return MemStore_addContext(ms, &ms->certs, cert, toReplace, ppStoreContext, use_link);
}
static context_t *MemStore_enumCert(WINECRYPT_CERTSTORE *store, context_t *prev)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
......@@ -191,19 +213,10 @@ static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, context_t *crl,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
context_t *context;
TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext);
context = ContextList_Add(&ms->crls, &ms->cs, crl, toReplace, store, use_link);
if (!context)
return FALSE;
if (ppStoreContext) {
Context_AddRef(context);
*ppStoreContext = context;
}
return TRUE;
return MemStore_addContext(ms, &ms->crls, crl, toReplace, ppStoreContext, use_link);
}
static context_t *MemStore_enumCRL(WINECRYPT_CERTSTORE *store, context_t *prev)
......@@ -235,19 +248,10 @@ static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, context_t *ctl,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
context_t *context;
TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext);
context = ContextList_Add(&ms->ctls, &ms->cs, ctl, toReplace, store, use_link);
if (!context)
return FALSE;
if (ppStoreContext) {
Context_AddRef(context);
*ppStoreContext = context;
}
return TRUE;
return MemStore_addContext(ms, &ms->ctls, ctl, toReplace, ppStoreContext, use_link);
}
static context_t *MemStore_enumCTL(WINECRYPT_CERTSTORE *store, context_t *prev)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment