Commit 84096382 authored by Vijay Kiran Kamuju's avatar Vijay Kiran Kamuju Committed by Alexandre Julliard

msasn1: Implement ASN1_CreateModule function.

Based on patch from Austin English. Wine-Bug: https:/bugs.winehq.org/show_bug.cgi?id=38020 Signed-off-by: 's avatarVijay Kiran Kamuju <infyquest@gmail.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 1976685a
......@@ -23,6 +23,7 @@
#include "winbase.h"
#include "msasn1.h"
#include "wine/heap.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(msasn1);
......@@ -49,10 +50,37 @@ ASN1module_t WINAPI ASN1_CreateModule(ASN1uint32_t ver, ASN1encodingrule_e rule,
{
ASN1module_t module = NULL;
FIXME("(%08x %08x %08x %u %p %p %p %p %u): Stub!\n", ver, rule, flags, pdu, encoder, decoder, freemem, size, magic);
TRACE("(%08x %08x %08x %u %p %p %p %p %u)\n", ver, rule, flags, pdu, encoder, decoder, freemem, size, magic);
if (!encoder || !decoder || !freemem || !size)
return module;
module = heap_alloc(sizeof(module));
if (module)
{
module->nModuleName = magic;
module->eRule = rule;
module->dwFlags = flags;
module->cPDUs = pdu;
module->apfnFreeMemory = freemem;
module->acbStructSize = size;
if (rule & ASN1_PER_RULE)
{
module->PER.apfnEncoder = (ASN1PerEncFun_t *)encoder;
module->PER.apfnDecoder = (ASN1PerDecFun_t *)decoder;
}
else if (rule & ASN1_BER_RULE)
{
module->BER.apfnEncoder = (ASN1BerEncFun_t *)encoder;
module->BER.apfnDecoder = (ASN1BerDecFun_t *)decoder;
}
else
{
module->PER.apfnEncoder = NULL;
module->PER.apfnDecoder = NULL;
}
}
return module;
}
......@@ -46,10 +46,39 @@ static void test_CreateModule(void)
ok(!mod, "Expected Failure.\n");
mod = ASN1_CreateModule(0, 0, 0, 0, encfn, decfn, freefn, size, 0);
todo_wine ok(!!mod, "Failed to create module.\n");
ok(!!mod, "Failed to create module.\n");
ok(mod->nModuleName==0, "Got Module name = %d\n.",mod->nModuleName);
ok(mod->eRule==0, "Got eRule = %08x\n.",mod->eRule);
ok(mod->dwFlags==0, "Got Flags = %08x\n.",mod->dwFlags);
ok(mod->cPDUs==0, "Got PDUs = %08x\n.",mod->cPDUs);
ok(mod->apfnFreeMemory==freefn, "Free function = %p.\n",mod->apfnFreeMemory);
ok(mod->acbStructSize==size, "Struct size = %p.\n",mod->acbStructSize);
ok(!mod->PER.apfnEncoder, "Encoder function should not be s et.\n");
ok(!mod->PER.apfnDecoder, "Decoder function should not be set.\n");
mod = ASN1_CreateModule(ASN1_THIS_VERSION, ASN1_BER_RULE_DER, ASN1FLAGS_NOASSERT, 1, encfn, decfn, freefn, size, name);
todo_wine ok(!!mod, "Failed to create module.\n");
ok(!!mod, "Failed to create module.\n");
ok(mod->nModuleName==name, "Got Module name = %d\n.",mod->nModuleName);
ok(mod->eRule==ASN1_BER_RULE_DER, "Got eRule = %08x\n.",mod->eRule);
ok(mod->cPDUs==1, "Got PDUs = %08x\n.",mod->cPDUs);
ok(mod->dwFlags==ASN1FLAGS_NOASSERT, "Got Flags = %08x\n.",mod->dwFlags);
ok(mod->apfnFreeMemory==freefn, "Free function = %p.\n",mod->apfnFreeMemory);
ok(mod->acbStructSize==size, "Struct size = %p.\n",mod->acbStructSize);
ok(mod->BER.apfnEncoder==(ASN1BerEncFun_t *)encfn, "Encoder function = %p.\n",mod->BER.apfnEncoder);
ok(mod->BER.apfnDecoder==(ASN1BerDecFun_t *)decfn, "Decoder function = %p.\n",mod->BER.apfnDecoder);
mod = ASN1_CreateModule(ASN1_THIS_VERSION, ASN1_PER_RULE_ALIGNED, ASN1FLAGS_NOASSERT, 1, encfn, decfn, freefn, size, name);
ok(!!mod, "Failed to create module.\n");
ok(mod->nModuleName==name, "Got Module name = %d\n.",mod->nModuleName);
ok(mod->eRule==ASN1_PER_RULE_ALIGNED, "Got eRule = %08x\n.",mod->eRule);
ok(mod->cPDUs==1, "Got PDUs = %08x\n.",mod->cPDUs);
ok(mod->dwFlags==ASN1FLAGS_NOASSERT, "Got Flags = %08x\n.",mod->dwFlags);
ok(mod->apfnFreeMemory==freefn, "Free function = %p.\n",mod->apfnFreeMemory);
ok(mod->acbStructSize==size, "Struct size = %p.\n",mod->acbStructSize);
ok(mod->PER.apfnEncoder==(ASN1PerEncFun_t *)encfn /* WINXP & WIN2008 */ ||
broken(!mod->PER.apfnEncoder), "Encoder function = %p.\n",mod->PER.apfnEncoder);
ok(mod->PER.apfnDecoder==(ASN1PerDecFun_t *)decfn /* WINXP & WIN2008 */ ||
broken(!mod->PER.apfnDecoder), "Decoder function = %p.\n",mod->PER.apfnDecoder);
}
START_TEST(asn1)
......
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