Commit 454d99f0 authored by John K. Hohm's avatar John K. Hohm Committed by Alexandre Julliard

More comcat.dll implementation, swprintf fix, winerror.h additions.

parent c9654a7d
......@@ -20,7 +20,9 @@
#include "windef.h"
#include "winbase.h"
#include "winreg.h"
#include "winerror.h"
#include "ntddk.h"
#include "ole2.h"
#include "wine/obj_base.h"
......
......@@ -63,7 +63,7 @@ static ULONG WINAPI COMCAT_IClassFactory_AddRef(LPCLASSFACTORY iface)
if (InterlockedIncrement(&This->ref) == 1) {
InterlockedIncrement(&dll_ref);
}
return S_OK;
return This->ref;
}
/**********************************************************************
......@@ -79,7 +79,7 @@ static ULONG WINAPI COMCAT_IClassFactory_Release(LPCLASSFACTORY iface)
if (InterlockedDecrement(&This->ref) == 0) {
InterlockedDecrement(&dll_ref);
}
return S_OK;
return This->ref;;
}
/**********************************************************************
......
......@@ -18,12 +18,17 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <string.h>
#include "comcat.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
static LPENUMCATEGORYINFO COMCAT_IEnumCATEGORYINFO_Construct(LCID lcid);
static HRESULT COMCAT_GetCategoryDesc(HKEY key, LCID lcid, PWCHAR pszDesc,
ULONG buf_wchars);
/**********************************************************************
* COMCAT_ICatInformation_QueryInterface
*/
......@@ -74,10 +79,15 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumCategories(
LCID lcid,
LPENUMCATEGORYINFO *ppenumCatInfo)
{
ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
FIXME("(): stub\n");
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
TRACE("\n");
return E_NOTIMPL;
if (iface == NULL || ppenumCatInfo == NULL) return E_POINTER;
*ppenumCatInfo = COMCAT_IEnumCATEGORYINFO_Construct(lcid);
if (*ppenumCatInfo == NULL) return E_OUTOFMEMORY;
IEnumCATEGORYINFO_AddRef(*ppenumCatInfo);
return S_OK;
}
/**********************************************************************
......@@ -89,10 +99,38 @@ static HRESULT WINAPI COMCAT_ICatInformation_GetCategoryDesc(
LCID lcid,
PWCHAR *ppszDesc)
{
ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
FIXME("(): stub\n");
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
WCHAR keyname[60] = { 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n',
't', ' ', 'C', 'a', 't', 'e', 'g', 'o',
'r', 'i', 'e', 's', '\\', 0 };
HKEY key;
HRESULT res;
return E_NOTIMPL;
TRACE("\n\tCATID:\t%s\n\tLCID:\t%lX\n",debugstr_guid(rcatid), lcid);
if (rcatid == NULL || ppszDesc == NULL) return E_INVALIDARG;
/* Open the key for this category. */
if (!StringFromGUID2(rcatid, keyname + 21, 39)) return E_FAIL;
res = RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &key);
if (res != ERROR_SUCCESS) return CAT_E_CATIDNOEXIST;
/* Allocate a sensible amount of memory for the description. */
*ppszDesc = (PWCHAR) CoTaskMemAlloc(128 * sizeof(WCHAR));
if (*ppszDesc == NULL) {
RegCloseKey(key);
return E_OUTOFMEMORY;
}
/* Get the description, and make sure it's null terminated. */
res = COMCAT_GetCategoryDesc(key, lcid, *ppszDesc, 128);
RegCloseKey(key);
if (FAILED(res)) {
CoTaskMemFree(*ppszDesc);
return res;
}
return S_OK;
}
/**********************************************************************
......@@ -106,7 +144,7 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumClassesOfCategories(
CATID *rgcatidReq,
LPENUMCLSID *ppenumCLSID)
{
ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
FIXME("(): stub\n");
return E_NOTIMPL;
......@@ -123,7 +161,7 @@ static HRESULT WINAPI COMCAT_ICatInformation_IsClassOfCategories(
ULONG cRequired,
CATID *rgcatidReq)
{
ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
FIXME("(): stub\n");
return E_NOTIMPL;
......@@ -137,7 +175,7 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumImplCategoriesOfClass(
REFCLSID rclsid,
LPENUMCATID *ppenumCATID)
{
ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
FIXME("(): stub\n");
return E_NOTIMPL;
......@@ -151,7 +189,7 @@ static HRESULT WINAPI COMCAT_ICatInformation_EnumReqCategoriesOfClass(
REFCLSID rclsid,
LPENUMCATID *ppenumCATID)
{
ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface);
/* ICOM_THIS_MULTI(ComCatMgrImpl, infVtbl, iface); */
FIXME("(): stub\n");
return E_NOTIMPL;
......@@ -173,3 +211,188 @@ ICOM_VTABLE(ICatInformation) COMCAT_ICatInformation_Vtbl =
COMCAT_ICatInformation_EnumImplCategoriesOfClass,
COMCAT_ICatInformation_EnumReqCategoriesOfClass
};
/**********************************************************************
* IEnumCATEGORYINFO implementation
*
* This implementation is not thread-safe. The manager itself is, but
* I can't imagine a valid use of an enumerator in several threads.
*/
typedef struct
{
ICOM_VFIELD(IEnumCATEGORYINFO);
DWORD ref;
LCID lcid;
HKEY key;
DWORD next_index;
} IEnumCATEGORYINFOImpl;
static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_AddRef(LPENUMCATEGORYINFO iface)
{
ICOM_THIS(IEnumCATEGORYINFOImpl, iface);
TRACE("\n");
if (This == NULL) return E_POINTER;
return ++(This->ref);
}
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_QueryInterface(
LPENUMCATEGORYINFO iface,
REFIID riid,
LPVOID *ppvObj)
{
ICOM_THIS(IEnumCATEGORYINFOImpl, iface);
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
if (This == NULL || ppvObj == NULL) return E_POINTER;
if (IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IEnumCATEGORYINFO))
{
*ppvObj = (LPVOID)iface;
COMCAT_IEnumCATEGORYINFO_AddRef(iface);
return S_OK;
}
return E_NOINTERFACE;
}
static ULONG WINAPI COMCAT_IEnumCATEGORYINFO_Release(LPENUMCATEGORYINFO iface)
{
ICOM_THIS(IEnumCATEGORYINFOImpl, iface);
TRACE("\n");
if (This == NULL) return E_POINTER;
if (--(This->ref) == 0) {
if (This->key) RegCloseKey(This->key);
HeapFree(GetProcessHeap(), 0, This);
return 0;
}
return This->ref;
}
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Next(
LPENUMCATEGORYINFO iface,
ULONG celt,
CATEGORYINFO *rgelt,
ULONG *pceltFetched)
{
ICOM_THIS(IEnumCATEGORYINFOImpl, iface);
ULONG fetched = 0;
TRACE("\n");
if (This == NULL || rgelt == NULL) return E_POINTER;
if (This->key) while (fetched < celt) {
HRESULT res;
WCHAR catid[39];
DWORD cName = 39;
HKEY subkey;
res = RegEnumKeyExW(This->key, This->next_index, catid, &cName,
NULL, NULL, NULL, NULL);
if (res != ERROR_SUCCESS && res != ERROR_MORE_DATA) break;
++(This->next_index);
res = CLSIDFromString(catid, &rgelt->catid);
if (FAILED(res)) continue;
res = RegOpenKeyExW(This->key, catid, 0, KEY_READ, &subkey);
if (res != ERROR_SUCCESS) continue;
res = COMCAT_GetCategoryDesc(subkey, This->lcid,
rgelt->szDescription, 128);
RegCloseKey(subkey);
if (FAILED(res)) continue;
rgelt->lcid = This->lcid;
++fetched;
++rgelt;
}
if (pceltFetched) *pceltFetched = fetched;
return fetched == celt ? S_OK : S_FALSE;
}
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Skip(
LPENUMCATEGORYINFO iface,
ULONG celt)
{
/* ICOM_THIS(IEnumCATEGORYINFOImpl, iface); */
FIXME("(): stub\n");
return E_NOTIMPL;
}
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Reset(LPENUMCATEGORYINFO iface)
{
/* ICOM_THIS(IEnumCATEGORYINFOImpl, iface); */
FIXME("(): stub\n");
return E_NOTIMPL;
}
static HRESULT WINAPI COMCAT_IEnumCATEGORYINFO_Clone(
LPENUMCATEGORYINFO iface,
IEnumCATEGORYINFO **ppenum)
{
/* ICOM_THIS(IEnumCATEGORYINFOImpl, iface); */
FIXME("(): stub\n");
return E_NOTIMPL;
}
ICOM_VTABLE(IEnumCATEGORYINFO) COMCAT_IEnumCATEGORYINFO_Vtbl =
{
ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
COMCAT_IEnumCATEGORYINFO_QueryInterface,
COMCAT_IEnumCATEGORYINFO_AddRef,
COMCAT_IEnumCATEGORYINFO_Release,
COMCAT_IEnumCATEGORYINFO_Next,
COMCAT_IEnumCATEGORYINFO_Skip,
COMCAT_IEnumCATEGORYINFO_Reset,
COMCAT_IEnumCATEGORYINFO_Clone
};
static LPENUMCATEGORYINFO COMCAT_IEnumCATEGORYINFO_Construct(LCID lcid)
{
IEnumCATEGORYINFOImpl *This;
This = (IEnumCATEGORYINFOImpl *) HeapAlloc(
GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IEnumCATEGORYINFOImpl));
if (This) {
WCHAR keyname[21] = { 'C', 'o', 'm', 'p', 'o', 'n', 'e', 'n',
't', ' ', 'C', 'a', 't', 'e', 'g', 'o',
'r', 'i', 'e', 's', 0 };
ICOM_VTBL(This) = &COMCAT_IEnumCATEGORYINFO_Vtbl;
This->lcid = lcid;
RegOpenKeyExW(HKEY_CLASSES_ROOT, keyname, 0, KEY_READ, &This->key);
}
return (LPENUMCATEGORYINFO)This;
}
/**********************************************************************
* COMCAT_GetCategoryDesc
*/
static HRESULT COMCAT_GetCategoryDesc(HKEY key, LCID lcid, PWCHAR pszDesc,
ULONG buf_wchars)
{
WCHAR fmt[4] = { '%', 'l', 'X', 0 };
WCHAR valname[5];
HRESULT res;
DWORD type, size = (buf_wchars - 1) * sizeof(WCHAR);
if (pszDesc == NULL) return E_INVALIDARG;
/* FIXME: lcid comparisons are more complex than this! */
swprintf(valname, fmt, lcid);
res = RegQueryValueExW(key, valname, 0, &type, (LPBYTE)pszDesc, &size);
if (res != ERROR_SUCCESS || type != REG_SZ) return CAT_E_NODESCRIPTION;
pszDesc[size / sizeof(WCHAR)] = (WCHAR)0;
return S_OK;
}
......@@ -73,7 +73,7 @@ static ULONG WINAPI COMCAT_IUnknown_AddRef(LPUNKNOWN iface)
if (InterlockedIncrement(&This->ref) == 1) {
InterlockedIncrement(&dll_ref);
}
return S_OK;
return This->ref;
}
/**********************************************************************
......@@ -89,7 +89,7 @@ static ULONG WINAPI COMCAT_IUnknown_Release(LPUNKNOWN iface)
if (InterlockedDecrement(&This->ref) == 0) {
InterlockedDecrement(&dll_ref);
}
return S_OK;
return This->ref;
}
/**********************************************************************
......
......@@ -74,7 +74,7 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterCategories(
ULONG cCategories,
CATEGORYINFO *rgCategoryInfo)
{
ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
FIXME("(): stub\n");
return E_NOTIMPL;
......@@ -88,7 +88,7 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterCategories(
ULONG cCategories,
CATID *rgcatid)
{
ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
FIXME("(): stub\n");
return E_NOTIMPL;
......@@ -103,7 +103,7 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassImplCategories(
ULONG cCategories,
CATID *rgcatid)
{
ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
FIXME("(): stub\n");
return E_NOTIMPL;
......@@ -118,7 +118,7 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassImplCategories(
ULONG cCategories,
CATID *rgcatid)
{
ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
FIXME("(): stub\n");
return E_NOTIMPL;
......@@ -133,7 +133,7 @@ static HRESULT WINAPI COMCAT_ICatRegister_RegisterClassReqCategories(
ULONG cCategories,
CATID *rgcatid)
{
ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
FIXME("(): stub\n");
return E_NOTIMPL;
......@@ -148,7 +148,7 @@ static HRESULT WINAPI COMCAT_ICatRegister_UnRegisterClassReqCategories(
ULONG cCategories,
CATID *rgcatid)
{
ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface);
/* ICOM_THIS_MULTI(ComCatMgrImpl, regVtbl, iface); */
FIXME("(): stub\n");
return E_NOTIMPL;
......
......@@ -451,10 +451,7 @@ static int __cdecl NTDLL_vsnwprintf(WCHAR *str, unsigned int len,
}
if (*iter == (WCHAR)L'h' ||
*iter == (WCHAR)L'l')
{
*fmta++ = *iter++;
*fmta++ = *iter++;
}
switch (*iter)
{
......
......@@ -1749,6 +1749,11 @@ extern int WIN32_LastError;
#define REGDB_E_IIDNOTREG 0x80040155L
#define REGDB_E_LAST 0x8004015FL
#define CAT_E_FIRST 0x80040160L
#define CAT_E_CATIDNOEXIST 0x80040160L
#define CAT_E_NODESCRIPTION 0x80040161L
#define CAT_E_LAST 0x80040161L
#define CACHE_S_FIRST 0x00040170L
#define CACHE_S_FORMATETC_NOTSUPPORTED 0x00040170L
#define CACHE_S_SAMECACHE 0x00040171L
......
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