Commit cc4669cc authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

ole: Remove __CLSIDFromStringA.

Move the ANSI implementation of CLSIDFromString to ole16.c and change CLSIDFromString to only deal with Unicode strings.
parent 1926b6da
......@@ -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 idstr, CLSID *id)
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 idstr, CLSID *id)
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);
}
......
......@@ -169,7 +169,6 @@ extern void* StdGlobalInterfaceTableInstance;
/* 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);
......
......@@ -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(LPCOLESTR16 progid, LPCLSID riid)
return CO_E_CLASSSTRING;
}
RegCloseKey(xhkey);
return __CLSIDFromStringA(buf2,riid);
return CLSIDFromString16(buf2,riid);
}
/***********************************************************************
......
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