Module: wine Branch: master Commit: 7b6dd2c9f8339a0bc14aa7f466f5c5a0bb03da06 URL: http://source.winehq.org/git/wine.git/?a=commit;h=7b6dd2c9f8339a0bc14aa7f466...
Author: Alexandre Julliard julliard@winehq.org Date: Wed Mar 11 17:28:21 2009 +0100
ole32: Get rid of WINE_StringFromCLSID and A->W conversions.
---
dlls/ole32/compobj.c | 69 ++++++++++-------------------------------- dlls/ole32/compobj_private.h | 3 -- 2 files changed, 16 insertions(+), 56 deletions(-)
diff --git a/dlls/ole32/compobj.c b/dlls/ole32/compobj.c index 0faaf7e..3eb0182 100644 --- a/dlls/ole32/compobj.c +++ b/dlls/ole32/compobj.c @@ -1429,40 +1429,6 @@ HRESULT WINAPI CLSIDFromString(LPOLESTR idstr, CLSID *id ) return ret; }
-/* Converts a GUID into the respective string representation. */ -HRESULT WINE_StringFromCLSID( - const CLSID *id, /* [in] GUID to be converted */ - LPSTR idstr /* [out] pointer to buffer to contain converted guid */ -) { - static const char hex[] = "0123456789ABCDEF"; - char *s; - int i; - - if (!id) - { ERR("called with id=Null\n"); - *idstr = 0x00; - return E_FAIL; - } - - sprintf(idstr, "{%08X-%04X-%04X-%02X%02X-", - id->Data1, id->Data2, id->Data3, - id->Data4[0], id->Data4[1]); - s = &idstr[25]; - - /* 6 hex bytes */ - for (i = 2; i < 8; i++) { - *s++ = hex[id->Data4[i]>>4]; - *s++ = hex[id->Data4[i] & 0xf]; - } - - *s++ = '}'; - *s++ = '\0'; - - TRACE("%p->%s\n", id, idstr); - - return S_OK; -} -
/****************************************************************************** * StringFromCLSID [OLE32.@] @@ -1484,20 +1450,13 @@ HRESULT WINE_StringFromCLSID( */ HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr) { - char buf[80]; - HRESULT ret; - LPMALLOC mllc; - - if ((ret = CoGetMalloc(0,&mllc))) - return ret; + HRESULT ret; + LPMALLOC mllc;
- ret=WINE_StringFromCLSID(id,buf); - if (ret == S_OK) { - DWORD len = MultiByteToWideChar( CP_ACP, 0, buf, -1, NULL, 0 ); - *idstr = IMalloc_Alloc( mllc, len * sizeof(WCHAR) ); - MultiByteToWideChar( CP_ACP, 0, buf, -1, *idstr, len ); - } - return ret; + if ((ret = CoGetMalloc(0,&mllc))) return ret; + if (!(*idstr = IMalloc_Alloc( mllc, CHARS_IN_GUID * sizeof(WCHAR) ))) return E_OUTOFMEMORY; + StringFromGUID2( id, *idstr, CHARS_IN_GUID ); + return S_OK; }
/****************************************************************************** @@ -1517,11 +1476,15 @@ HRESULT WINAPI StringFromCLSID(REFCLSID id, LPOLESTR *idstr) */ INT WINAPI StringFromGUID2(REFGUID id, LPOLESTR str, INT cmax) { - char xguid[80]; - - if (WINE_StringFromCLSID(id,xguid)) - return 0; - return MultiByteToWideChar( CP_ACP, 0, xguid, -1, str, cmax ); + static const WCHAR formatW[] = { '{','%','0','8','X','-','%','0','4','X','-', + '%','0','4','X','-','%','0','2','X','%','0','2','X','-', + '%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X', + '%','0','2','X','%','0','2','X','}',0 }; + if (cmax < CHARS_IN_GUID) return 0; + sprintfW( str, formatW, id->Data1, id->Data2, id->Data3, + id->Data4[0], id->Data4[1], id->Data4[2], id->Data4[3], + id->Data4[4], id->Data4[5], id->Data4[6], id->Data4[7] ); + return CHARS_IN_GUID; }
/* open HKCR\CLSID\{string form of clsid}\{keyname} key */ diff --git a/dlls/ole32/compobj_private.h b/dlls/ole32/compobj_private.h index 38a6475..65d459f 100644 --- a/dlls/ole32/compobj_private.h +++ b/dlls/ole32/compobj_private.h @@ -196,9 +196,6 @@ extern void* StdGlobalInterfaceTable_Construct(void); extern HRESULT StdGlobalInterfaceTable_GetFactory(LPVOID *ppv); extern void* StdGlobalInterfaceTableInstance;
-/* FIXME: these shouldn't be needed, except for 16-bit functions */ -extern HRESULT WINE_StringFromCLSID(const CLSID *id,LPSTR idstr); - HRESULT COM_OpenKeyForCLSID(REFCLSID clsid, LPCWSTR keyname, REGSAM access, HKEY *key); HRESULT COM_OpenKeyForAppIdFromCLSID(REFCLSID clsid, REGSAM access, HKEY *subkey); HRESULT MARSHAL_GetStandardMarshalCF(LPVOID *ppv);