Robert Shearman : ole: Remove __CLSIDFromStringA.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jan 9 13:52:48 CST 2006


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

Author: Robert Shearman <rob at codeweavers.com>
Date:   Mon Jan  9 18:40:17 2006 +0100

ole: Remove __CLSIDFromStringA.
Move the ANSI implementation of CLSIDFromString to ole16.c and change
CLSIDFromString to only deal with Unicode strings.

---

 dlls/ole32/compobj.c         |   23 ++++-------------
 dlls/ole32/compobj_private.h |    1 -
 dlls/ole32/ole16.c           |   58 +++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 61 insertions(+), 21 deletions(-)

diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c
index b2cf72b..d28728e 100644
--- a/dlls/ole32/compobj.c
+++ b/dlls/ole32/compobj.c
@@ -795,31 +795,23 @@ HRESULT WINAPI CoCreateGuid(GUID *pguid)
  *   S_OK on success
  *   CO_E_CLASSSTRING if idstr is not a valid CLSID
  *
- * BUGS
- *
- * In Windows, if idstr is not a valid CLSID string then it gets
- * treated as a ProgID. Wine currently doesn't do this. If idstr is
- * NULL it's treated as an all-zero GUID.
- *
  * SEE ALSO
  *  StringFromCLSID
  */
-HRESULT WINAPI __CLSIDFromStringA(LPCSTR idstr, CLSID *id)
+static HRESULT WINAPI __CLSIDFromString(LPCWSTR s, CLSID *id)
 {
-  const BYTE *s;
   int	i;
   BYTE table[256];
 
-  if (!idstr) {
+  if (!s) {
     memset( id, 0, sizeof (CLSID) );
     return S_OK;
   }
 
   /* validate the CLSID string */
-  if (strlen(idstr) != 38)
+  if (strlenW(s) != 38)
     return CO_E_CLASSSTRING;
 
-  s = (const BYTE *) idstr;
   if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
     return CO_E_CLASSSTRING;
 
@@ -831,7 +823,7 @@ HRESULT WINAPI __CLSIDFromStringA(LPCSTR
        return CO_E_CLASSSTRING;
   }
 
-  TRACE("%s -> %p\n", s, id);
+  TRACE("%s -> %p\n", debugstr_w(s), id);
 
   /* quick lookup table */
   memset(table, 0, 256);
@@ -868,14 +860,9 @@ HRESULT WINAPI __CLSIDFromStringA(LPCSTR
 
 HRESULT WINAPI CLSIDFromString(LPOLESTR idstr, CLSID *id )
 {
-    char xid[40];
     HRESULT ret;
 
-    if (!WideCharToMultiByte( CP_ACP, 0, idstr, -1, xid, sizeof(xid), NULL, NULL ))
-        return CO_E_CLASSSTRING;
-
-
-    ret = __CLSIDFromStringA(xid,id);
+    ret = __CLSIDFromString(idstr, id);
     if(ret != S_OK) { /* It appears a ProgID is also valid */
         ret = CLSIDFromProgID(idstr, id);
     }
diff --git a/dlls/ole32/compobj_private.h b/dlls/ole32/compobj_private.h
index 790042e..14a33b7 100644
--- a/dlls/ole32/compobj_private.h
+++ b/dlls/ole32/compobj_private.h
@@ -169,7 +169,6 @@ extern void* StdGlobalInterfaceTableInst
 
 /* FIXME: these shouldn't be needed, except for 16-bit functions */
 extern HRESULT WINE_StringFromCLSID(const CLSID *id,LPSTR idstr);
-HRESULT WINAPI __CLSIDFromStringA(LPCSTR idstr, CLSID *id);
 
 HRESULT COM_OpenKeyForCLSID(REFCLSID clsid, LPCWSTR keyname, REGSAM access, HKEY *key);
 HRESULT MARSHAL_GetStandardMarshalCF(LPVOID *ppv);
diff --git a/dlls/ole32/ole16.c b/dlls/ole32/ole16.c
index 117d484..dd90cfd 100644
--- a/dlls/ole32/ole16.c
+++ b/dlls/ole32/ole16.c
@@ -284,8 +284,62 @@ HRESULT WINAPI CLSIDFromString16(
 	LPCOLESTR16 idstr,	/* [in] string representation of guid */
 	CLSID *id)		/* [out] GUID converted from string */
 {
+  const BYTE *s;
+  int	i;
+  BYTE table[256];
 
-  return __CLSIDFromStringA(idstr,id);
+  if (!idstr) {
+    memset( id, 0, sizeof (CLSID) );
+    return S_OK;
+  }
+
+  /* validate the CLSID string */
+  if (strlen(idstr) != 38)
+    return CO_E_CLASSSTRING;
+
+  s = (const BYTE *) idstr;
+  if ((s[0]!='{') || (s[9]!='-') || (s[14]!='-') || (s[19]!='-') || (s[24]!='-') || (s[37]!='}'))
+    return CO_E_CLASSSTRING;
+
+  for (i=1; i<37; i++) {
+    if ((i == 9)||(i == 14)||(i == 19)||(i == 24)) continue;
+    if (!(((s[i] >= '0') && (s[i] <= '9'))  ||
+          ((s[i] >= 'a') && (s[i] <= 'f'))  ||
+          ((s[i] >= 'A') && (s[i] <= 'F'))))
+       return CO_E_CLASSSTRING;
+  }
+
+  TRACE("%s -> %p\n", s, id);
+
+  /* quick lookup table */
+  memset(table, 0, 256);
+
+  for (i = 0; i < 10; i++) {
+    table['0' + i] = i;
+  }
+  for (i = 0; i < 6; i++) {
+    table['A' + i] = i+10;
+    table['a' + i] = i+10;
+  }
+
+  /* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
+
+  id->Data1 = (table[s[1]] << 28 | table[s[2]] << 24 | table[s[3]] << 20 | table[s[4]] << 16 |
+               table[s[5]] << 12 | table[s[6]] << 8  | table[s[7]] << 4  | table[s[8]]);
+  id->Data2 = table[s[10]] << 12 | table[s[11]] << 8 | table[s[12]] << 4 | table[s[13]];
+  id->Data3 = table[s[15]] << 12 | table[s[16]] << 8 | table[s[17]] << 4 | table[s[18]];
+
+  /* these are just sequential bytes */
+  id->Data4[0] = table[s[20]] << 4 | table[s[21]];
+  id->Data4[1] = table[s[22]] << 4 | table[s[23]];
+  id->Data4[2] = table[s[25]] << 4 | table[s[26]];
+  id->Data4[3] = table[s[27]] << 4 | table[s[28]];
+  id->Data4[4] = table[s[29]] << 4 | table[s[30]];
+  id->Data4[5] = table[s[31]] << 4 | table[s[32]];
+  id->Data4[6] = table[s[33]] << 4 | table[s[34]];
+  id->Data4[7] = table[s[35]] << 4 | table[s[36]];
+
+  return S_OK;
 }
 
 /******************************************************************************
@@ -556,7 +610,7 @@ HRESULT WINAPI CLSIDFromProgID16(LPCOLES
                 return CO_E_CLASSSTRING;
 	}
 	RegCloseKey(xhkey);
-	return __CLSIDFromStringA(buf2,riid);
+	return CLSIDFromString16(buf2,riid);
 }
 
 /***********************************************************************




More information about the wine-cvs mailing list