2013-06-14 02:23:43 +02:00
|
|
|
/* OLE DB ErrorInfo
|
|
|
|
*
|
|
|
|
* Copyright 2013 Alistair Leslie-Hughes
|
|
|
|
*
|
|
|
|
* 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
#include "oleauto.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "oledb.h"
|
|
|
|
#include "oledberr.h"
|
|
|
|
|
|
|
|
#include "oledb_private.h"
|
|
|
|
|
2018-02-03 00:17:56 +01:00
|
|
|
#include "wine/heap.h"
|
2013-06-14 02:23:43 +02:00
|
|
|
#include "wine/list.h"
|
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(oledb);
|
|
|
|
|
|
|
|
struct ErrorEntry
|
|
|
|
{
|
2013-08-19 03:13:34 +02:00
|
|
|
ERRORINFO info;
|
2013-06-14 02:23:43 +02:00
|
|
|
DISPPARAMS dispparams;
|
2016-11-15 18:26:49 +01:00
|
|
|
IUnknown *custom_error;
|
2013-06-14 02:23:43 +02:00
|
|
|
DWORD lookupID;
|
|
|
|
};
|
|
|
|
|
2016-11-16 14:48:34 +01:00
|
|
|
typedef struct errorrecords
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
|
|
|
IErrorInfo IErrorInfo_iface;
|
|
|
|
IErrorRecords IErrorRecords_iface;
|
|
|
|
LONG ref;
|
|
|
|
|
2016-11-15 18:26:47 +01:00
|
|
|
struct ErrorEntry *records;
|
|
|
|
unsigned int allocated;
|
|
|
|
unsigned int count;
|
2016-11-16 14:48:34 +01:00
|
|
|
} errorrecords;
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-11-16 14:48:34 +01:00
|
|
|
static inline errorrecords *impl_from_IErrorInfo( IErrorInfo *iface )
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
return CONTAINING_RECORD(iface, errorrecords, IErrorInfo_iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
}
|
|
|
|
|
2016-11-16 14:48:34 +01:00
|
|
|
static inline errorrecords *impl_from_IErrorRecords( IErrorRecords *iface )
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
return CONTAINING_RECORD(iface, errorrecords, IErrorRecords_iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
}
|
|
|
|
|
2016-11-16 14:48:34 +01:00
|
|
|
static HRESULT WINAPI errorrecords_QueryInterface(IErrorInfo* iface, REFIID riid, void **ppvoid)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorInfo(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid),ppvoid);
|
|
|
|
|
|
|
|
*ppvoid = NULL;
|
|
|
|
|
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) || IsEqualIID(riid, &IID_IErrorInfo))
|
|
|
|
{
|
|
|
|
*ppvoid = &This->IErrorInfo_iface;
|
|
|
|
}
|
|
|
|
else if (IsEqualIID(riid, &IID_IErrorRecords))
|
|
|
|
{
|
|
|
|
*ppvoid = &This->IErrorRecords_iface;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(*ppvoid)
|
|
|
|
{
|
|
|
|
IUnknown_AddRef( (IUnknown*)*ppvoid );
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("interface %s not implemented\n", debugstr_guid(riid));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
2016-11-16 14:48:34 +01:00
|
|
|
static ULONG WINAPI errorrecords_AddRef(IErrorInfo* iface)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorInfo(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
TRACE("(%p)->%u\n",This,This->ref);
|
|
|
|
return InterlockedIncrement(&This->ref);
|
|
|
|
}
|
|
|
|
|
2016-11-16 14:48:34 +01:00
|
|
|
static ULONG WINAPI errorrecords_Release(IErrorInfo* iface)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorInfo(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
|
|
|
|
|
|
|
TRACE("(%p)->%u\n",This,ref+1);
|
|
|
|
|
|
|
|
if (!ref)
|
|
|
|
{
|
2016-11-15 18:26:47 +01:00
|
|
|
unsigned int i;
|
2013-08-19 03:13:34 +02:00
|
|
|
|
2016-11-15 18:26:47 +01:00
|
|
|
for (i = 0; i < This->count; i++)
|
|
|
|
{
|
2016-11-16 14:48:35 +01:00
|
|
|
DISPPARAMS *dispparams = &This->records[i].dispparams;
|
|
|
|
unsigned int j;
|
|
|
|
|
2016-11-15 18:26:49 +01:00
|
|
|
if (This->records[i].custom_error)
|
|
|
|
IUnknown_Release(This->records[i].custom_error);
|
2016-11-16 14:48:35 +01:00
|
|
|
|
|
|
|
for (j = 0; j < dispparams->cArgs && dispparams->rgvarg; j++)
|
|
|
|
VariantClear(&dispparams->rgvarg[i]);
|
|
|
|
CoTaskMemFree(dispparams->rgvarg);
|
|
|
|
CoTaskMemFree(dispparams->rgdispidNamedArgs);
|
2013-08-19 03:13:34 +02:00
|
|
|
}
|
2016-11-15 18:26:47 +01:00
|
|
|
heap_free(This->records);
|
2013-08-02 07:53:58 +02:00
|
|
|
heap_free(This);
|
2013-06-14 02:23:43 +02:00
|
|
|
}
|
|
|
|
return ref;
|
|
|
|
}
|
|
|
|
|
2016-11-16 14:48:34 +01:00
|
|
|
static HRESULT WINAPI errorrecords_GetGUID(IErrorInfo* iface, GUID *guid)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorInfo(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, guid);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
if (!guid)
|
2013-06-14 02:23:43 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
*guid = GUID_NULL;
|
2013-06-14 02:23:43 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-11-16 14:48:34 +01:00
|
|
|
static HRESULT WINAPI errorrecords_GetSource(IErrorInfo* iface, BSTR *source)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorInfo(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, source);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
if (!source)
|
2013-06-14 02:23:43 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
*source = NULL;
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
return E_FAIL;
|
2013-06-14 02:23:43 +02:00
|
|
|
}
|
|
|
|
|
2016-11-16 14:48:34 +01:00
|
|
|
static HRESULT WINAPI errorrecords_GetDescription(IErrorInfo* iface, BSTR *description)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorInfo(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, description);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
if (!description)
|
2013-06-14 02:23:43 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
*description = NULL;
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
return E_FAIL;
|
2013-06-14 02:23:43 +02:00
|
|
|
}
|
|
|
|
|
2016-11-16 14:48:34 +01:00
|
|
|
static HRESULT WINAPI errorrecords_GetHelpFile(IErrorInfo* iface, BSTR *helpfile)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorInfo(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, helpfile);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
if (!helpfile)
|
2013-06-14 02:23:43 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
*helpfile = NULL;
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
return E_FAIL;
|
2013-06-14 02:23:43 +02:00
|
|
|
}
|
|
|
|
|
2016-11-16 14:48:34 +01:00
|
|
|
static HRESULT WINAPI errorrecords_GetHelpContext(IErrorInfo* iface, DWORD *context)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorInfo(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
TRACE("(%p)->(%p)\n", This, context);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
if (!context)
|
2013-06-14 02:23:43 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
*context = 0;
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-06-03 08:55:36 +02:00
|
|
|
return E_FAIL;
|
2013-06-14 02:23:43 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const IErrorInfoVtbl ErrorInfoVtbl =
|
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords_QueryInterface,
|
|
|
|
errorrecords_AddRef,
|
|
|
|
errorrecords_Release,
|
|
|
|
errorrecords_GetGUID,
|
|
|
|
errorrecords_GetSource,
|
|
|
|
errorrecords_GetDescription,
|
|
|
|
errorrecords_GetHelpFile,
|
|
|
|
errorrecords_GetHelpContext
|
2013-06-14 02:23:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
static HRESULT WINAPI errorrec_QueryInterface(IErrorRecords *iface, REFIID riid, void **ppvObject)
|
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorRecords(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
return IErrorInfo_QueryInterface(&This->IErrorInfo_iface, riid, ppvObject);
|
|
|
|
}
|
|
|
|
|
2019-05-28 22:03:40 +02:00
|
|
|
static ULONG WINAPI errorrec_AddRef(IErrorRecords *iface)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorRecords(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
return IErrorInfo_AddRef(&This->IErrorInfo_iface);
|
|
|
|
}
|
|
|
|
|
2019-05-28 22:03:40 +02:00
|
|
|
static ULONG WINAPI errorrec_Release(IErrorRecords *iface)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorRecords(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
return IErrorInfo_Release(&This->IErrorInfo_iface);
|
|
|
|
}
|
|
|
|
|
2016-11-16 14:48:35 +01:00
|
|
|
static HRESULT dup_dispparams(DISPPARAMS *src, DISPPARAMS *dest)
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
|
|
|
|
if (!src)
|
|
|
|
{
|
|
|
|
memset(dest, 0, sizeof(*dest));
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
*dest = *src;
|
|
|
|
|
|
|
|
if (src->cArgs)
|
|
|
|
{
|
|
|
|
dest->rgvarg = CoTaskMemAlloc(dest->cArgs * sizeof(*dest->rgvarg));
|
|
|
|
for (i = 0; i < src->cArgs; i++)
|
|
|
|
{
|
|
|
|
VariantInit(&dest->rgvarg[i]);
|
|
|
|
VariantCopy(&dest->rgvarg[i], &src->rgvarg[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (src->cNamedArgs)
|
|
|
|
{
|
|
|
|
dest->rgdispidNamedArgs = CoTaskMemAlloc(dest->cNamedArgs * sizeof(*dest->rgdispidNamedArgs));
|
|
|
|
memcpy(dest->rgdispidNamedArgs, src->rgdispidNamedArgs, dest->cNamedArgs * sizeof(*dest->rgdispidNamedArgs));
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2013-06-14 02:23:43 +02:00
|
|
|
static HRESULT WINAPI errorrec_AddErrorRecord(IErrorRecords *iface, ERRORINFO *pErrorInfo,
|
|
|
|
DWORD dwLookupID, DISPPARAMS *pdispparams, IUnknown *punkCustomError, DWORD dwDynamicErrorID)
|
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorRecords(iface);
|
2013-08-19 03:13:34 +02:00
|
|
|
struct ErrorEntry *entry;
|
2016-11-16 14:48:35 +01:00
|
|
|
HRESULT hr;
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2013-08-19 03:13:34 +02:00
|
|
|
TRACE("(%p)->(%p %d %p %p %d)\n", This, pErrorInfo, dwLookupID, pdispparams, punkCustomError, dwDynamicErrorID);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2013-08-19 03:13:34 +02:00
|
|
|
if(!pErrorInfo)
|
2013-06-14 02:23:43 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-11-15 18:26:47 +01:00
|
|
|
if (!This->records)
|
|
|
|
{
|
|
|
|
const unsigned int initial_size = 16;
|
|
|
|
if (!(This->records = heap_alloc(initial_size * sizeof(*This->records))))
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->allocated = initial_size;
|
|
|
|
}
|
|
|
|
else if (This->count == This->allocated)
|
|
|
|
{
|
|
|
|
struct ErrorEntry *new_ptr;
|
|
|
|
|
|
|
|
new_ptr = heap_realloc(This->records, 2 * This->allocated * sizeof(*This->records));
|
|
|
|
if (!new_ptr)
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->records = new_ptr;
|
|
|
|
This->allocated *= 2;
|
|
|
|
}
|
2013-08-19 03:13:34 +02:00
|
|
|
|
2016-11-15 18:26:47 +01:00
|
|
|
entry = This->records + This->count;
|
2013-08-19 03:13:34 +02:00
|
|
|
entry->info = *pErrorInfo;
|
2016-11-16 14:48:35 +01:00
|
|
|
|
|
|
|
if (FAILED(hr = dup_dispparams(pdispparams, &entry->dispparams)))
|
|
|
|
return hr;
|
|
|
|
|
2016-11-15 18:26:49 +01:00
|
|
|
entry->custom_error = punkCustomError;
|
|
|
|
if (entry->custom_error)
|
|
|
|
IUnknown_AddRef(entry->custom_error);
|
2013-08-19 03:13:34 +02:00
|
|
|
entry->lookupID = dwDynamicErrorID;
|
|
|
|
|
2016-11-15 18:26:47 +01:00
|
|
|
This->count++;
|
2013-08-19 03:13:34 +02:00
|
|
|
|
2013-06-14 02:23:43 +02:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2016-11-15 18:26:50 +01:00
|
|
|
static HRESULT WINAPI errorrec_GetBasicErrorInfo(IErrorRecords *iface, ULONG index, ERRORINFO *info)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorRecords(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-11-15 18:26:50 +01:00
|
|
|
TRACE("(%p)->(%u %p)\n", This, index, info);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-11-15 18:26:50 +01:00
|
|
|
if (!info)
|
2013-06-14 02:23:43 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-11-15 18:26:48 +01:00
|
|
|
if (index >= This->count)
|
2013-06-14 02:23:43 +02:00
|
|
|
return DB_E_BADRECORDNUM;
|
|
|
|
|
2016-11-15 18:26:50 +01:00
|
|
|
index = This->count - index - 1;
|
|
|
|
*info = This->records[index].info;
|
|
|
|
return S_OK;
|
2013-06-14 02:23:43 +02:00
|
|
|
}
|
|
|
|
|
2016-11-15 18:26:48 +01:00
|
|
|
static HRESULT WINAPI errorrec_GetCustomErrorObject(IErrorRecords *iface, ULONG index,
|
2016-11-15 18:26:49 +01:00
|
|
|
REFIID riid, IUnknown **object)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorRecords(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-11-15 18:26:49 +01:00
|
|
|
TRACE("(%p)->(%u %s %p)\n", This, index, debugstr_guid(riid), object);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-11-15 18:26:49 +01:00
|
|
|
if (!object)
|
2013-06-14 02:23:43 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-11-15 18:26:49 +01:00
|
|
|
*object = NULL;
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-11-15 18:26:48 +01:00
|
|
|
if (index >= This->count)
|
2013-06-14 02:23:43 +02:00
|
|
|
return DB_E_BADRECORDNUM;
|
|
|
|
|
2016-11-15 18:26:49 +01:00
|
|
|
index = This->count - index - 1;
|
|
|
|
if (This->records[index].custom_error)
|
|
|
|
return IUnknown_QueryInterface(This->records[index].custom_error, riid, (void **)object);
|
|
|
|
else
|
|
|
|
return S_OK;
|
2013-06-14 02:23:43 +02:00
|
|
|
}
|
|
|
|
|
2016-11-15 18:26:48 +01:00
|
|
|
static HRESULT WINAPI errorrec_GetErrorInfo(IErrorRecords *iface, ULONG index,
|
2013-06-14 02:23:43 +02:00
|
|
|
LCID lcid, IErrorInfo **ppErrorInfo)
|
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorRecords(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-11-15 18:26:48 +01:00
|
|
|
FIXME("(%p)->(%u %d, %p)\n", This, index, lcid, ppErrorInfo);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
|
|
|
if (!ppErrorInfo)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-11-15 18:26:48 +01:00
|
|
|
if (index >= This->count)
|
2013-06-14 02:23:43 +02:00
|
|
|
return DB_E_BADRECORDNUM;
|
|
|
|
|
2020-11-27 09:14:44 +01:00
|
|
|
return IErrorInfo_QueryInterface(&This->IErrorInfo_iface, &IID_IErrorInfo, (void **)ppErrorInfo);
|
2013-06-14 02:23:43 +02:00
|
|
|
}
|
|
|
|
|
2016-11-15 18:26:48 +01:00
|
|
|
static HRESULT WINAPI errorrec_GetErrorParameters(IErrorRecords *iface, ULONG index, DISPPARAMS *pdispparams)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorRecords(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-11-16 14:48:35 +01:00
|
|
|
TRACE("(%p)->(%u %p)\n", This, index, pdispparams);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
|
|
|
if (!pdispparams)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-11-15 18:26:48 +01:00
|
|
|
if (index >= This->count)
|
2013-06-14 02:23:43 +02:00
|
|
|
return DB_E_BADRECORDNUM;
|
|
|
|
|
2016-11-16 14:48:35 +01:00
|
|
|
index = This->count - index - 1;
|
|
|
|
return dup_dispparams(&This->records[index].dispparams, pdispparams);
|
2013-06-14 02:23:43 +02:00
|
|
|
}
|
|
|
|
|
2016-11-15 18:26:47 +01:00
|
|
|
static HRESULT WINAPI errorrec_GetRecordCount(IErrorRecords *iface, ULONG *count)
|
2013-06-14 02:23:43 +02:00
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This = impl_from_IErrorRecords(iface);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-11-15 18:26:47 +01:00
|
|
|
TRACE("(%p)->(%p)\n", This, count);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-11-15 18:26:47 +01:00
|
|
|
if(!count)
|
2013-06-14 02:23:43 +02:00
|
|
|
return E_INVALIDARG;
|
|
|
|
|
2016-11-15 18:26:47 +01:00
|
|
|
*count = This->count;
|
2013-06-14 02:23:43 +02:00
|
|
|
|
2016-11-15 18:26:47 +01:00
|
|
|
TRACE("<--(%u)\n", *count);
|
2013-06-14 02:23:43 +02:00
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const IErrorRecordsVtbl ErrorRecordsVtbl =
|
|
|
|
{
|
|
|
|
errorrec_QueryInterface,
|
|
|
|
errorrec_AddRef,
|
|
|
|
errorrec_Release,
|
|
|
|
errorrec_AddErrorRecord,
|
|
|
|
errorrec_GetBasicErrorInfo,
|
|
|
|
errorrec_GetCustomErrorObject,
|
|
|
|
errorrec_GetErrorInfo,
|
|
|
|
errorrec_GetErrorParameters,
|
|
|
|
errorrec_GetRecordCount
|
|
|
|
};
|
|
|
|
|
|
|
|
HRESULT create_error_info(IUnknown *outer, void **obj)
|
|
|
|
{
|
2016-11-16 14:48:34 +01:00
|
|
|
errorrecords *This;
|
2013-06-14 02:23:43 +02:00
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", outer, obj);
|
|
|
|
|
|
|
|
*obj = NULL;
|
|
|
|
|
|
|
|
if(outer) return CLASS_E_NOAGGREGATION;
|
|
|
|
|
2013-08-02 07:53:58 +02:00
|
|
|
This = heap_alloc(sizeof(*This));
|
2013-06-14 02:23:43 +02:00
|
|
|
if(!This) return E_OUTOFMEMORY;
|
|
|
|
|
|
|
|
This->IErrorInfo_iface.lpVtbl = &ErrorInfoVtbl;
|
|
|
|
This->IErrorRecords_iface.lpVtbl = &ErrorRecordsVtbl;
|
|
|
|
This->ref = 1;
|
|
|
|
|
2016-11-15 18:26:47 +01:00
|
|
|
This->records = NULL;
|
|
|
|
This->allocated = 0;
|
|
|
|
This->count = 0;
|
2013-06-14 02:23:43 +02:00
|
|
|
|
|
|
|
*obj = &This->IErrorInfo_iface;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|