Sweden-Number/dlls/comcat/manager.c

121 lines
3.0 KiB
C
Raw Normal View History

/*
* ComCatMgr IUnknown implementation for comcat.dll
*
* Copyright (C) 2002 John K. Hohm
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "comcat_private.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
static ULONG WINAPI COMCAT_IUnknown_AddRef(LPUNKNOWN iface);
/**********************************************************************
* COMCAT_IUnknown_QueryInterface
*/
static HRESULT WINAPI COMCAT_IUnknown_QueryInterface(
LPUNKNOWN iface,
REFIID riid,
LPVOID *ppvObj)
{
ICOM_THIS_MULTI(ComCatMgrImpl, unkVtbl, iface);
TRACE("\n\tIID:\t%s\n",debugstr_guid(riid));
if (This == NULL || ppvObj == NULL) return E_POINTER;
if (IsEqualGUID(riid, &IID_IUnknown)) {
*ppvObj = &This->unkVtbl;
COMCAT_IUnknown_AddRef(iface);
return S_OK;
}
if (IsEqualGUID(riid, &IID_ICatRegister)) {
*ppvObj = &This->regVtbl;
COMCAT_IUnknown_AddRef(iface);
return S_OK;
}
if (IsEqualGUID(riid, &IID_ICatInformation)) {
*ppvObj = &This->infVtbl;
COMCAT_IUnknown_AddRef(iface);
return S_OK;
}
return E_NOINTERFACE;
}
/**********************************************************************
* COMCAT_IUnknown_AddRef
*/
static ULONG WINAPI COMCAT_IUnknown_AddRef(LPUNKNOWN iface)
{
ICOM_THIS_MULTI(ComCatMgrImpl, unkVtbl, iface);
ULONG ref;
TRACE("\n");
if (This == NULL) return E_POINTER;
ref = InterlockedIncrement(&This->ref);
if (ref == 1) {
InterlockedIncrement(&dll_ref);
}
return ref;
}
/**********************************************************************
* COMCAT_IUnknown_Release
*/
static ULONG WINAPI COMCAT_IUnknown_Release(LPUNKNOWN iface)
{
ICOM_THIS_MULTI(ComCatMgrImpl, unkVtbl, iface);
ULONG ref;
TRACE("\n");
if (This == NULL) return E_POINTER;
ref = InterlockedDecrement(&This->ref);
if (ref == 0) {
InterlockedDecrement(&dll_ref);
}
return ref;
}
/**********************************************************************
* COMCAT_IUnknown_Vtbl
*/
static const IUnknownVtbl COMCAT_IUnknown_Vtbl =
{
COMCAT_IUnknown_QueryInterface,
COMCAT_IUnknown_AddRef,
COMCAT_IUnknown_Release
};
/**********************************************************************
* static ComCatMgr instance
*/
const ComCatMgrImpl COMCAT_ComCatMgr =
{
&COMCAT_IUnknown_Vtbl,
&COMCAT_ICatRegister_Vtbl,
&COMCAT_ICatInformation_Vtbl,
0
};