Vijay Kiran Kamuju : msasn1: Implement ASN1_CreateModule function.

Alexandre Julliard julliard at winehq.org
Wed May 6 15:34:27 CDT 2020


Module: wine
Branch: master
Commit: 84096382fc4ca80f5fc59908bf287e28a291bae8
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=84096382fc4ca80f5fc59908bf287e28a291bae8

Author: Vijay Kiran Kamuju <infyquest at gmail.com>
Date:   Tue May  5 13:51:36 2020 +0200

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: Vijay Kiran Kamuju <infyquest at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msasn1/main.c       | 30 +++++++++++++++++++++++++++++-
 dlls/msasn1/tests/asn1.c | 33 +++++++++++++++++++++++++++++++--
 2 files changed, 60 insertions(+), 3 deletions(-)

diff --git a/dlls/msasn1/main.c b/dlls/msasn1/main.c
index 90c4a8a9c9..6882fbf6c9 100644
--- a/dlls/msasn1/main.c
+++ b/dlls/msasn1/main.c
@@ -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;
 }
diff --git a/dlls/msasn1/tests/asn1.c b/dlls/msasn1/tests/asn1.c
index 19019fc72b..adbf547efa 100644
--- a/dlls/msasn1/tests/asn1.c
+++ b/dlls/msasn1/tests/asn1.c
@@ -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)




More information about the wine-cvs mailing list