combase: Move IIDFromString().
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
94b5ccef81
commit
e64908b9a8
|
@ -1075,6 +1075,29 @@ HRESULT WINAPI CLSIDFromString(LPCOLESTR str, LPCLSID clsid)
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/******************************************************************************
|
||||||
|
* IIDFromString (combase.@)
|
||||||
|
*/
|
||||||
|
HRESULT WINAPI IIDFromString(LPCOLESTR str, IID *iid)
|
||||||
|
{
|
||||||
|
TRACE("%s, %p\n", debugstr_w(str), iid);
|
||||||
|
|
||||||
|
if (!str)
|
||||||
|
{
|
||||||
|
memset(iid, 0, sizeof(*iid));
|
||||||
|
return S_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* length mismatch is a special case */
|
||||||
|
if (lstrlenW(str) + 1 != CHARS_IN_GUID)
|
||||||
|
return E_INVALIDARG;
|
||||||
|
|
||||||
|
if (str[0] != '{')
|
||||||
|
return CO_E_IIDSTRING;
|
||||||
|
|
||||||
|
return guid_from_string(str, iid) ? S_OK : CO_E_IIDSTRING;
|
||||||
|
}
|
||||||
|
|
||||||
static void init_multi_qi(DWORD count, MULTI_QI *mqi, HRESULT hr)
|
static void init_multi_qi(DWORD count, MULTI_QI *mqi, HRESULT hr)
|
||||||
{
|
{
|
||||||
ULONG i;
|
ULONG i;
|
||||||
|
|
|
@ -231,7 +231,7 @@
|
||||||
@ stdcall HWND_UserSize(ptr long ptr)
|
@ stdcall HWND_UserSize(ptr long ptr)
|
||||||
@ stdcall HWND_UserUnmarshal(ptr ptr ptr)
|
@ stdcall HWND_UserUnmarshal(ptr ptr ptr)
|
||||||
@ stub HkOleRegisterObject
|
@ stub HkOleRegisterObject
|
||||||
@ stdcall IIDFromString(wstr ptr) ole32.IIDFromString
|
@ stdcall IIDFromString(wstr ptr)
|
||||||
@ stub InternalAppInvokeExceptionFilter
|
@ stub InternalAppInvokeExceptionFilter
|
||||||
@ stub InternalCCFreeUnused
|
@ stub InternalCCFreeUnused
|
||||||
@ stub InternalCCGetClassInformationForDde
|
@ stub InternalCCGetClassInformationForDde
|
||||||
|
|
|
@ -2186,114 +2186,6 @@ HRESULT WINAPI CoDisconnectObject( LPUNKNOWN lpUnk, DWORD reserved )
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline BOOL is_valid_hex(WCHAR c)
|
|
||||||
{
|
|
||||||
if (!(((c >= '0') && (c <= '9')) ||
|
|
||||||
((c >= 'a') && (c <= 'f')) ||
|
|
||||||
((c >= 'A') && (c <= 'F'))))
|
|
||||||
return FALSE;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const BYTE guid_conv_table[256] =
|
|
||||||
{
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */
|
|
||||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, /* 0x30 */
|
|
||||||
0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 */
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 */
|
|
||||||
0, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf /* 0x60 */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* conversion helper for CLSIDFromString/IIDFromString */
|
|
||||||
static BOOL guid_from_string(LPCWSTR s, GUID *id)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!s || s[0]!='{') {
|
|
||||||
memset( id, 0, sizeof (CLSID) );
|
|
||||||
if(!s) return TRUE;
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
TRACE("%s -> %p\n", debugstr_w(s), id);
|
|
||||||
|
|
||||||
/* in form {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX} */
|
|
||||||
|
|
||||||
id->Data1 = 0;
|
|
||||||
for (i = 1; i < 9; i++) {
|
|
||||||
if (!is_valid_hex(s[i])) return FALSE;
|
|
||||||
id->Data1 = (id->Data1 << 4) | guid_conv_table[s[i]];
|
|
||||||
}
|
|
||||||
if (s[9]!='-') return FALSE;
|
|
||||||
|
|
||||||
id->Data2 = 0;
|
|
||||||
for (i = 10; i < 14; i++) {
|
|
||||||
if (!is_valid_hex(s[i])) return FALSE;
|
|
||||||
id->Data2 = (id->Data2 << 4) | guid_conv_table[s[i]];
|
|
||||||
}
|
|
||||||
if (s[14]!='-') return FALSE;
|
|
||||||
|
|
||||||
id->Data3 = 0;
|
|
||||||
for (i = 15; i < 19; i++) {
|
|
||||||
if (!is_valid_hex(s[i])) return FALSE;
|
|
||||||
id->Data3 = (id->Data3 << 4) | guid_conv_table[s[i]];
|
|
||||||
}
|
|
||||||
if (s[19]!='-') return FALSE;
|
|
||||||
|
|
||||||
for (i = 20; i < 37; i+=2) {
|
|
||||||
if (i == 24) {
|
|
||||||
if (s[i]!='-') return FALSE;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
if (!is_valid_hex(s[i]) || !is_valid_hex(s[i+1])) return FALSE;
|
|
||||||
id->Data4[(i-20)/2] = guid_conv_table[s[i]] << 4 | guid_conv_table[s[i+1]];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (s[37] == '}' && s[38] == '\0')
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************
|
|
||||||
* IIDFromString [OLE32.@]
|
|
||||||
*
|
|
||||||
* Converts an interface identifier from its string representation to
|
|
||||||
* the IID struct.
|
|
||||||
*
|
|
||||||
* PARAMS
|
|
||||||
* idstr [I] The string representation of the GUID.
|
|
||||||
* id [O] IID converted from the string.
|
|
||||||
*
|
|
||||||
* RETURNS
|
|
||||||
* S_OK on success
|
|
||||||
* CO_E_IIDSTRING if idstr is not a valid IID
|
|
||||||
*
|
|
||||||
* SEE ALSO
|
|
||||||
* StringFromIID
|
|
||||||
*/
|
|
||||||
HRESULT WINAPI IIDFromString(LPCOLESTR s, IID *iid)
|
|
||||||
{
|
|
||||||
TRACE("%s -> %p\n", debugstr_w(s), iid);
|
|
||||||
|
|
||||||
if (!s)
|
|
||||||
{
|
|
||||||
memset(iid, 0, sizeof(*iid));
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* length mismatch is a special case */
|
|
||||||
if (lstrlenW(s) + 1 != CHARS_IN_GUID)
|
|
||||||
return E_INVALIDARG;
|
|
||||||
|
|
||||||
if (s[0] != '{')
|
|
||||||
return CO_E_IIDSTRING;
|
|
||||||
|
|
||||||
return guid_from_string(s, iid) ? S_OK : CO_E_IIDSTRING;
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* StringFromCLSID [OLE32.@]
|
* StringFromCLSID [OLE32.@]
|
||||||
* StringFromIID [OLE32.@]
|
* StringFromIID [OLE32.@]
|
||||||
|
|
|
@ -171,7 +171,7 @@
|
||||||
@ stdcall HWND_UserMarshal(ptr ptr ptr) combase.HWND_UserMarshal
|
@ stdcall HWND_UserMarshal(ptr ptr ptr) combase.HWND_UserMarshal
|
||||||
@ stdcall HWND_UserSize(ptr long ptr) combase.HWND_UserSize
|
@ stdcall HWND_UserSize(ptr long ptr) combase.HWND_UserSize
|
||||||
@ stdcall HWND_UserUnmarshal(ptr ptr ptr) combase.HWND_UserUnmarshal
|
@ stdcall HWND_UserUnmarshal(ptr ptr ptr) combase.HWND_UserUnmarshal
|
||||||
@ stdcall IIDFromString(wstr ptr)
|
@ stdcall IIDFromString(wstr ptr) combase.IIDFromString
|
||||||
@ stub I_RemoteMain
|
@ stub I_RemoteMain
|
||||||
@ stdcall IsAccelerator(long long ptr ptr)
|
@ stdcall IsAccelerator(long long ptr ptr)
|
||||||
@ stdcall IsEqualGUID(ptr ptr)
|
@ stdcall IsEqualGUID(ptr ptr)
|
||||||
|
|
Loading…
Reference in New Issue