Juan Lang : crypt32: Add a function to format a CERT_NAME_BLOB as an indented string, and implement CertNameToStrW on top of it.

Alexandre Julliard julliard at winehq.org
Mon Nov 17 09:14:07 CST 2008


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

Author: Juan Lang <juan.lang at gmail.com>
Date:   Fri Nov 14 09:59:00 2008 -0800

crypt32: Add a function to format a CERT_NAME_BLOB as an indented string, and implement CertNameToStrW on top of it.

---

 dlls/crypt32/crypt32_private.h |    7 +++++++
 dlls/crypt32/str.c             |   37 +++++++++++++++++++++++++++++++++----
 2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h
index 119e30e..b0f6101 100644
--- a/dlls/crypt32/crypt32_private.h
+++ b/dlls/crypt32/crypt32_private.h
@@ -287,6 +287,13 @@ BOOL CRYPT_ReadSerializedStoreFromFile(HANDLE file, HCERTSTORE store);
 void CRYPT_FixKeyProvInfoPointers(PCRYPT_KEY_PROV_INFO info);
 
 /**
+ *  String functions
+ */
+
+DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indent,
+ PCERT_NAME_BLOB pName, DWORD dwStrType, LPWSTR psz, DWORD csz);
+
+/**
  *  Context functions
  */
 
diff --git a/dlls/crypt32/str.c b/dlls/crypt32/str.c
index b1ccc91..d3bca2b 100644
--- a/dlls/crypt32/str.c
+++ b/dlls/crypt32/str.c
@@ -338,8 +338,10 @@ static DWORD CRYPT_AddPrefixW(LPCWSTR prefix, LPWSTR psz, DWORD csz)
     return chars;
 }
 
-DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
- DWORD dwStrType, LPWSTR psz, DWORD csz)
+static const WCHAR indent[] = { ' ',' ',' ',' ',' ',0 };
+
+DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indentLevel,
+ PCERT_NAME_BLOB pName, DWORD dwStrType, LPWSTR psz, DWORD csz)
 {
     static const DWORD unsupportedFlags = CERT_NAME_STR_NO_QUOTING_FLAG |
      CERT_NAME_STR_ENABLE_T61_UNICODE_FLAG;
@@ -352,8 +354,6 @@ DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
     BOOL bRet;
     CERT_NAME_INFO *info;
 
-    TRACE("(%d, %p, %08x, %p, %d)\n", dwCertEncodingType, pName, dwStrType,
-     psz, csz);
     if (dwStrType & unsupportedFlags)
         FIXME("unsupported flags: %08x\n", dwStrType & unsupportedFlags);
 
@@ -402,6 +402,22 @@ DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
                     else
                         prefixA = rdn->rgRDNAttr[j].pszObjId;
                 }
+                if (dwStrType & CERT_NAME_STR_CRLF_FLAG)
+                {
+                    DWORD k;
+
+                    for (k = 0; k < indentLevel; k++)
+                    {
+                        if (psz)
+                        {
+                            chars = min(strlenW(indent), csz - ret - 1);
+                            memcpy(psz + ret, indent, chars * sizeof(WCHAR));
+                        }
+                        else
+                            chars = strlenW(indent);
+                        ret += chars;
+                    }
+                }
                 if (prefixW)
                 {
                     /* - 1 is needed to account for the NULL terminator. */
@@ -448,6 +464,19 @@ DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
     }
     else
         ret++;
+    return ret;
+}
+
+DWORD WINAPI CertNameToStrW(DWORD dwCertEncodingType, PCERT_NAME_BLOB pName,
+ DWORD dwStrType, LPWSTR psz, DWORD csz)
+{
+    BOOL ret;
+
+    TRACE("(%d, %p, %08x, %p, %d)\n", dwCertEncodingType, pName, dwStrType,
+     psz, csz);
+
+    ret = cert_name_to_str_with_indent(dwCertEncodingType, 0, pName, dwStrType,
+     psz, csz);
     TRACE("Returning %s\n", debugstr_w(psz));
     return ret;
 }




More information about the wine-cvs mailing list