2004-06-03 02:03:23 +02:00
|
|
|
/*
|
|
|
|
* Implementation of DirectX File Interfaces
|
|
|
|
*
|
2008-08-18 15:10:25 +02:00
|
|
|
* Copyright 2004, 2008 Christian Costa
|
2004-06-03 02:03:23 +02:00
|
|
|
*
|
|
|
|
* This file contains the (internal) driver registration functions,
|
|
|
|
* driver enumeration APIs and DirectDraw creation functions.
|
|
|
|
*
|
|
|
|
* 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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-06-03 02:03:23 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
|
|
|
|
#include "d3dxof_private.h"
|
|
|
|
#include "dxfile.h"
|
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3dxof);
|
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
#define MAKEFOUR(a,b,c,d) ((DWORD)a + ((DWORD)b << 8) + ((DWORD)c << 16) + ((DWORD)d << 24))
|
|
|
|
#define XOFFILE_FORMAT_MAGIC MAKEFOUR('x','o','f',' ')
|
2008-11-11 12:38:52 +01:00
|
|
|
#define XOFFILE_FORMAT_VERSION_302 MAKEFOUR('0','3','0','2')
|
|
|
|
#define XOFFILE_FORMAT_VERSION_303 MAKEFOUR('0','3','0','3')
|
2008-08-18 15:10:25 +02:00
|
|
|
#define XOFFILE_FORMAT_BINARY MAKEFOUR('b','i','n',' ')
|
|
|
|
#define XOFFILE_FORMAT_TEXT MAKEFOUR('t','x','t',' ')
|
|
|
|
#define XOFFILE_FORMAT_COMPRESSED MAKEFOUR('c','m','p',' ')
|
|
|
|
#define XOFFILE_FORMAT_FLOAT_BITS_32 MAKEFOUR('0','0','3','2')
|
|
|
|
#define XOFFILE_FORMAT_FLOAT_BITS_64 MAKEFOUR('0','0','6','4')
|
|
|
|
|
|
|
|
#define TOKEN_NAME 1
|
|
|
|
#define TOKEN_STRING 2
|
|
|
|
#define TOKEN_INTEGER 3
|
|
|
|
#define TOKEN_GUID 5
|
|
|
|
#define TOKEN_INTEGER_LIST 6
|
|
|
|
#define TOKEN_FLOAT_LIST 7
|
|
|
|
#define TOKEN_OBRACE 10
|
|
|
|
#define TOKEN_CBRACE 11
|
|
|
|
#define TOKEN_OPAREN 12
|
|
|
|
#define TOKEN_CPAREN 13
|
|
|
|
#define TOKEN_OBRACKET 14
|
|
|
|
#define TOKEN_CBRACKET 15
|
|
|
|
#define TOKEN_OANGLE 16
|
|
|
|
#define TOKEN_CANGLE 17
|
|
|
|
#define TOKEN_DOT 18
|
|
|
|
#define TOKEN_COMMA 19
|
|
|
|
#define TOKEN_SEMICOLON 20
|
|
|
|
#define TOKEN_TEMPLATE 31
|
|
|
|
#define TOKEN_WORD 40
|
|
|
|
#define TOKEN_DWORD 41
|
|
|
|
#define TOKEN_FLOAT 42
|
|
|
|
#define TOKEN_DOUBLE 43
|
|
|
|
#define TOKEN_CHAR 44
|
|
|
|
#define TOKEN_UCHAR 45
|
|
|
|
#define TOKEN_SWORD 46
|
|
|
|
#define TOKEN_SDWORD 47
|
|
|
|
#define TOKEN_VOID 48
|
|
|
|
#define TOKEN_LPSTR 49
|
|
|
|
#define TOKEN_UNICODE 50
|
|
|
|
#define TOKEN_CSTRING 51
|
|
|
|
#define TOKEN_ARRAY 52
|
|
|
|
|
2008-08-29 11:11:54 +02:00
|
|
|
#define CLSIDFMT "<%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X>"
|
2008-08-22 13:16:58 +02:00
|
|
|
|
2008-11-16 19:44:51 +01:00
|
|
|
#define MAX_INPUT_SIZE 2000000
|
2008-11-30 12:18:08 +01:00
|
|
|
#define MAX_DATA_SIZE 400000
|
2008-08-18 15:10:25 +02:00
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
static const struct IDirectXFileVtbl IDirectXFile_Vtbl;
|
|
|
|
static const struct IDirectXFileBinaryVtbl IDirectXFileBinary_Vtbl;
|
|
|
|
static const struct IDirectXFileDataVtbl IDirectXFileData_Vtbl;
|
|
|
|
static const struct IDirectXFileDataReferenceVtbl IDirectXFileDataReference_Vtbl;
|
|
|
|
static const struct IDirectXFileEnumObjectVtbl IDirectXFileEnumObject_Vtbl;
|
|
|
|
static const struct IDirectXFileObjectVtbl IDirectXFileObject_Vtbl;
|
|
|
|
static const struct IDirectXFileSaveObjectVtbl IDirectXFileSaveObject_Vtbl;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
static BOOL parse_object_parts(parse_buffer * buf, BOOL allow_optional);
|
|
|
|
static BOOL parse_object(parse_buffer * buf);
|
2008-10-16 22:21:43 +02:00
|
|
|
static const char* get_primitive_string(WORD token);
|
2008-11-09 11:09:07 +01:00
|
|
|
static WORD check_TOKEN(parse_buffer * buf);
|
|
|
|
static BOOL parse_template(parse_buffer * buf);
|
2008-12-04 12:47:20 +01:00
|
|
|
static HRESULT IDirectXFileDataReferenceImpl_Create(IDirectXFileDataReferenceImpl** ppObj);
|
|
|
|
static HRESULT IDirectXFileEnumObjectImpl_Create(IDirectXFileEnumObjectImpl** ppObj);
|
2008-12-16 20:55:22 +01:00
|
|
|
static HRESULT IDirectXFileSaveObjectImpl_Create(IDirectXFileSaveObjectImpl** ppObj);
|
2008-10-16 22:21:43 +02:00
|
|
|
|
|
|
|
static void dump_template(xtemplate* templates_array, xtemplate* ptemplate)
|
|
|
|
{
|
|
|
|
int j, k;
|
|
|
|
GUID* clsid;
|
|
|
|
|
|
|
|
clsid = &ptemplate->class_id;
|
|
|
|
|
|
|
|
DPRINTF("template %s\n", ptemplate->name);
|
|
|
|
DPRINTF("{\n");
|
|
|
|
DPRINTF(CLSIDFMT "\n", clsid->Data1, clsid->Data2, clsid->Data3, clsid->Data4[0],
|
|
|
|
clsid->Data4[1], clsid->Data4[2], clsid->Data4[3], clsid->Data4[4], clsid->Data4[5], clsid->Data4[6], clsid->Data4[7]);
|
|
|
|
for (j = 0; j < ptemplate->nb_members; j++)
|
|
|
|
{
|
|
|
|
if (ptemplate->members[j].nb_dims)
|
|
|
|
DPRINTF("array ");
|
|
|
|
if (ptemplate->members[j].type == TOKEN_NAME)
|
|
|
|
DPRINTF("%s ", templates_array[ptemplate->members[j].idx_template].name);
|
|
|
|
else
|
|
|
|
DPRINTF("%s ", get_primitive_string(ptemplate->members[j].type));
|
|
|
|
DPRINTF("%s", ptemplate->members[j].name);
|
|
|
|
for (k = 0; k < ptemplate->members[j].nb_dims; k++)
|
|
|
|
{
|
|
|
|
if (ptemplate->members[j].dim_fixed[k])
|
|
|
|
DPRINTF("[%d]", ptemplate->members[j].dim_value[k]);
|
|
|
|
else
|
|
|
|
DPRINTF("[%s]", ptemplate->members[ptemplate->members[j].dim_value[k]].name);
|
|
|
|
}
|
|
|
|
DPRINTF(";\n");
|
|
|
|
}
|
|
|
|
if (ptemplate->open)
|
|
|
|
DPRINTF("[...]\n");
|
|
|
|
else if (ptemplate->nb_childs)
|
|
|
|
{
|
|
|
|
DPRINTF("[%s", ptemplate->childs[0]);
|
|
|
|
for (j = 1; j < ptemplate->nb_childs; j++)
|
|
|
|
DPRINTF(",%s", ptemplate->childs[j]);
|
|
|
|
DPRINTF("]\n");
|
|
|
|
}
|
|
|
|
DPRINTF("}\n");
|
|
|
|
}
|
2008-09-16 22:22:28 +02:00
|
|
|
|
2004-06-04 21:36:56 +02:00
|
|
|
HRESULT IDirectXFileImpl_Create(IUnknown* pUnkOuter, LPVOID* ppObj)
|
2004-06-03 02:03:23 +02:00
|
|
|
{
|
2004-06-04 21:36:56 +02:00
|
|
|
IDirectXFileImpl* object;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2004-06-04 21:36:56 +02:00
|
|
|
TRACE("(%p,%p)\n", pUnkOuter, ppObj);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectXFileImpl));
|
2008-12-14 18:55:10 +01:00
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Out of memory\n");
|
|
|
|
return DXFILEERR_BADALLOC;
|
|
|
|
}
|
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
object->lpVtbl.lpVtbl = &IDirectXFile_Vtbl;
|
|
|
|
object->ref = 1;
|
|
|
|
|
|
|
|
*ppObj = object;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileImpl_QueryInterface(IDirectXFile* iface, REFIID riid, void** ppvObject)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileImpl *This = (IDirectXFileImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2004-06-04 21:36:56 +02:00
|
|
|
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDirectXFile))
|
|
|
|
{
|
|
|
|
IClassFactory_AddRef(iface);
|
|
|
|
*ppvObject = This;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectXFileImpl_AddRef(IDirectXFile* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileImpl *This = (IDirectXFileImpl *)iface;
|
2005-01-20 11:53:56 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
TRACE("(%p/%p): AddRef from %d\n", iface, This, ref - 1);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
return ref;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectXFileImpl_Release(IDirectXFile* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileImpl *This = (IDirectXFileImpl *)iface;
|
2005-01-20 11:53:56 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
TRACE("(%p/%p): ReleaseRef to %d\n", iface, This, ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
if (!ref)
|
2004-06-03 02:03:23 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
return ref;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDirectXFile methods ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileImpl_CreateEnumObject(IDirectXFile* iface, LPVOID pvSource, DXFILELOADOPTIONS dwLoadOptions, LPDIRECTXFILEENUMOBJECT* ppEnumObj)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileImpl *This = (IDirectXFileImpl *)iface;
|
2008-08-19 00:28:03 +02:00
|
|
|
IDirectXFileEnumObjectImpl* object;
|
|
|
|
HRESULT hr;
|
2008-09-01 22:55:44 +02:00
|
|
|
DWORD header[4];
|
|
|
|
DWORD size;
|
|
|
|
HANDLE hFile = INVALID_HANDLE_VALUE;
|
2008-11-11 12:40:31 +01:00
|
|
|
LPDXFILELOADMEMORY lpdxflm = NULL;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-22 20:27:09 +02:00
|
|
|
TRACE("(%p/%p)->(%p,%x,%p)\n", This, iface, pvSource, dwLoadOptions, ppEnumObj);
|
2008-09-01 22:55:44 +02:00
|
|
|
|
|
|
|
if (!ppEnumObj)
|
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
if (dwLoadOptions == DXFILELOAD_FROMFILE)
|
2004-06-03 02:03:23 +02:00
|
|
|
{
|
2008-08-18 15:10:25 +02:00
|
|
|
TRACE("Open source file '%s'\n", (char*)pvSource);
|
2008-09-01 22:55:44 +02:00
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
hFile = CreateFileA((char*)pvSource, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
|
|
|
|
if (hFile == INVALID_HANDLE_VALUE)
|
|
|
|
{
|
|
|
|
TRACE("File '%s' not found\n", (char*)pvSource);
|
|
|
|
return DXFILEERR_FILENOTFOUND;
|
|
|
|
}
|
2008-09-01 22:55:44 +02:00
|
|
|
|
|
|
|
if (!ReadFile(hFile, header, 16, &size, NULL))
|
|
|
|
{
|
|
|
|
hr = DXFILEERR_BADVALUE;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size < 16)
|
|
|
|
{
|
|
|
|
hr = DXFILEERR_BADFILETYPE;
|
|
|
|
goto error;
|
|
|
|
}
|
2008-11-11 12:40:31 +01:00
|
|
|
}
|
|
|
|
else if (dwLoadOptions == DXFILELOAD_FROMMEMORY)
|
|
|
|
{
|
|
|
|
lpdxflm = (LPDXFILELOADMEMORY)pvSource;
|
2008-09-01 22:55:44 +02:00
|
|
|
|
2008-11-16 19:42:38 +01:00
|
|
|
TRACE("Source in memory at %p with size %d\n", lpdxflm->lpMemory, lpdxflm->dSize);
|
2008-11-11 12:40:31 +01:00
|
|
|
|
|
|
|
memcpy(header, (char*)lpdxflm->lpMemory, 16);
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Source type %d is not handled yet\n", dwLoadOptions);
|
2008-09-01 22:55:44 +02:00
|
|
|
hr = DXFILEERR_NOTDONEYET;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2008-11-11 12:40:31 +01:00
|
|
|
if (TRACE_ON(d3dxof))
|
|
|
|
{
|
|
|
|
char string[17];
|
|
|
|
memcpy(string, header, 16);
|
|
|
|
string[16] = 0;
|
|
|
|
TRACE("header = '%s'\n", string);
|
|
|
|
}
|
|
|
|
|
2008-09-01 22:55:44 +02:00
|
|
|
if (header[0] != XOFFILE_FORMAT_MAGIC)
|
|
|
|
{
|
|
|
|
hr = DXFILEERR_BADFILETYPE;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
2008-11-11 12:38:52 +01:00
|
|
|
if ((header[1] != XOFFILE_FORMAT_VERSION_302) && (header[1] != XOFFILE_FORMAT_VERSION_303))
|
2008-09-01 22:55:44 +02:00
|
|
|
{
|
|
|
|
hr = DXFILEERR_BADFILEVERSION;
|
|
|
|
goto error;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
2008-09-01 22:55:44 +02:00
|
|
|
if ((header[2] != XOFFILE_FORMAT_BINARY) && (header[2] != XOFFILE_FORMAT_TEXT) && (header[2] != XOFFILE_FORMAT_COMPRESSED))
|
|
|
|
{
|
|
|
|
hr = DXFILEERR_BADFILETYPE;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (header[2] == XOFFILE_FORMAT_COMPRESSED)
|
|
|
|
{
|
2008-09-05 13:15:10 +02:00
|
|
|
FIXME("Compressed formats not supported yet\n");
|
2008-09-01 22:55:44 +02:00
|
|
|
hr = DXFILEERR_BADVALUE;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((header[3] != XOFFILE_FORMAT_FLOAT_BITS_32) && (header[3] != XOFFILE_FORMAT_FLOAT_BITS_64))
|
|
|
|
{
|
|
|
|
hr = DXFILEERR_BADFILEFLOATSIZE;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Header is correct\n");
|
|
|
|
|
2008-08-19 00:28:03 +02:00
|
|
|
hr = IDirectXFileEnumObjectImpl_Create(&object);
|
2008-10-08 01:35:37 +02:00
|
|
|
if (FAILED(hr))
|
2008-09-01 22:55:44 +02:00
|
|
|
goto error;
|
|
|
|
|
|
|
|
object->source = dwLoadOptions;
|
|
|
|
object->hFile = hFile;
|
2008-09-16 22:22:28 +02:00
|
|
|
object->pDirectXFile = This;
|
|
|
|
object->buf.pdxf = This;
|
2008-11-11 12:41:11 +01:00
|
|
|
object->buf.txt = (header[2] == XOFFILE_FORMAT_TEXT);
|
2008-09-20 12:34:00 +02:00
|
|
|
object->buf.token_present = FALSE;
|
2008-09-16 22:22:28 +02:00
|
|
|
object->buf.cur_subobject = 0;
|
|
|
|
|
2008-11-11 12:40:31 +01:00
|
|
|
if (dwLoadOptions == DXFILELOAD_FROMFILE)
|
2008-09-16 22:22:28 +02:00
|
|
|
{
|
2008-11-11 12:40:31 +01:00
|
|
|
object->buf.buffer = HeapAlloc(GetProcessHeap(), 0, MAX_INPUT_SIZE+1);
|
|
|
|
if (!object->buf.buffer)
|
|
|
|
{
|
2008-12-14 18:55:10 +01:00
|
|
|
ERR("Out of memory\n");
|
2008-11-11 12:40:31 +01:00
|
|
|
hr = DXFILEERR_BADALLOC;
|
|
|
|
goto error;
|
|
|
|
}
|
2008-09-16 22:22:28 +02:00
|
|
|
|
2008-11-11 12:40:31 +01:00
|
|
|
ReadFile(hFile, object->buf.buffer, MAX_INPUT_SIZE+1, &object->buf.rem_bytes, NULL);
|
|
|
|
if (object->buf.rem_bytes > MAX_INPUT_SIZE)
|
|
|
|
{
|
|
|
|
FIXME("File size > %d not supported yet\n", MAX_INPUT_SIZE);
|
|
|
|
HeapFree(GetProcessHeap(), 0, object->buf.buffer);
|
|
|
|
hr = DXFILEERR_PARSEERROR;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2008-09-16 22:22:28 +02:00
|
|
|
{
|
2008-11-11 12:40:31 +01:00
|
|
|
object->buf.buffer = ((LPBYTE)lpdxflm->lpMemory) + 16;
|
|
|
|
object->buf.rem_bytes = lpdxflm->dSize;
|
2008-09-16 22:22:28 +02:00
|
|
|
}
|
2008-11-11 12:40:31 +01:00
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
TRACE("Read %d bytes\n", object->buf.rem_bytes);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
*ppEnumObj = (LPDIRECTXFILEENUMOBJECT)object;
|
2008-08-19 00:28:03 +02:00
|
|
|
|
2008-11-09 11:09:07 +01:00
|
|
|
while (object->buf.rem_bytes && (check_TOKEN(&object->buf) == TOKEN_TEMPLATE))
|
|
|
|
{
|
|
|
|
if (!parse_template(&object->buf))
|
|
|
|
{
|
|
|
|
TRACE("Template is not correct\n");
|
|
|
|
hr = DXFILEERR_BADVALUE;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE("Template successfully parsed:\n");
|
|
|
|
if (TRACE_ON(d3dxof))
|
|
|
|
dump_template(This->xtemplates, &This->xtemplates[This->nb_xtemplates - 1]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (TRACE_ON(d3dxof))
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
TRACE("Registered templates (%d):\n", This->nb_xtemplates);
|
|
|
|
for (i = 0; i < This->nb_xtemplates; i++)
|
|
|
|
DPRINTF("%s - %s\n", This->xtemplates[i].name, debugstr_guid(&This->xtemplates[i].class_id));
|
|
|
|
}
|
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILE_OK;
|
2008-09-01 22:55:44 +02:00
|
|
|
|
|
|
|
error:
|
|
|
|
if (hFile != INVALID_HANDLE_VALUE)
|
|
|
|
CloseHandle(hFile);
|
|
|
|
*ppEnumObj = NULL;
|
|
|
|
|
|
|
|
return hr;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileImpl_CreateSaveObject(IDirectXFile* iface, LPCSTR szFileName, DXFILEFORMAT dwFileFormat, LPDIRECTXFILESAVEOBJECT* ppSaveObj)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileImpl *This = (IDirectXFileImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-12-16 20:55:22 +01:00
|
|
|
FIXME("(%p/%p)->(%s,%x,%p) partial stub!\n", This, iface, szFileName, dwFileFormat, ppSaveObj);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-12-16 20:55:22 +01:00
|
|
|
if (!szFileName || !ppSaveObj)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
return IDirectXFileSaveObjectImpl_Create((IDirectXFileSaveObjectImpl**)ppSaveObj);
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
static BOOL read_bytes(parse_buffer * buf, LPVOID data, DWORD size)
|
|
|
|
{
|
|
|
|
if (buf->rem_bytes < size)
|
|
|
|
return FALSE;
|
|
|
|
memcpy(data, buf->buffer, size);
|
|
|
|
buf->buffer += size;
|
|
|
|
buf->rem_bytes -= size;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void dump_TOKEN(WORD token)
|
|
|
|
{
|
|
|
|
#define DUMP_TOKEN(t) case t: TRACE(#t "\n"); break
|
|
|
|
switch(token)
|
|
|
|
{
|
|
|
|
DUMP_TOKEN(TOKEN_NAME);
|
|
|
|
DUMP_TOKEN(TOKEN_STRING);
|
|
|
|
DUMP_TOKEN(TOKEN_INTEGER);
|
|
|
|
DUMP_TOKEN(TOKEN_GUID);
|
|
|
|
DUMP_TOKEN(TOKEN_INTEGER_LIST);
|
|
|
|
DUMP_TOKEN(TOKEN_FLOAT_LIST);
|
|
|
|
DUMP_TOKEN(TOKEN_OBRACE);
|
|
|
|
DUMP_TOKEN(TOKEN_CBRACE);
|
|
|
|
DUMP_TOKEN(TOKEN_OPAREN);
|
|
|
|
DUMP_TOKEN(TOKEN_CPAREN);
|
|
|
|
DUMP_TOKEN(TOKEN_OBRACKET);
|
|
|
|
DUMP_TOKEN(TOKEN_CBRACKET);
|
|
|
|
DUMP_TOKEN(TOKEN_OANGLE);
|
|
|
|
DUMP_TOKEN(TOKEN_CANGLE);
|
|
|
|
DUMP_TOKEN(TOKEN_DOT);
|
|
|
|
DUMP_TOKEN(TOKEN_COMMA);
|
|
|
|
DUMP_TOKEN(TOKEN_SEMICOLON);
|
|
|
|
DUMP_TOKEN(TOKEN_TEMPLATE);
|
|
|
|
DUMP_TOKEN(TOKEN_WORD);
|
|
|
|
DUMP_TOKEN(TOKEN_DWORD);
|
|
|
|
DUMP_TOKEN(TOKEN_FLOAT);
|
|
|
|
DUMP_TOKEN(TOKEN_DOUBLE);
|
|
|
|
DUMP_TOKEN(TOKEN_CHAR);
|
|
|
|
DUMP_TOKEN(TOKEN_UCHAR);
|
|
|
|
DUMP_TOKEN(TOKEN_SWORD);
|
|
|
|
DUMP_TOKEN(TOKEN_SDWORD);
|
|
|
|
DUMP_TOKEN(TOKEN_VOID);
|
|
|
|
DUMP_TOKEN(TOKEN_LPSTR);
|
|
|
|
DUMP_TOKEN(TOKEN_UNICODE);
|
|
|
|
DUMP_TOKEN(TOKEN_CSTRING);
|
|
|
|
DUMP_TOKEN(TOKEN_ARRAY);
|
|
|
|
default:
|
|
|
|
if (0)
|
|
|
|
TRACE("Unknown token %d\n", token);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#undef DUMP_TOKEN
|
|
|
|
}
|
|
|
|
|
2008-08-19 14:00:32 +02:00
|
|
|
static BOOL is_space(char c)
|
2008-08-18 15:10:25 +02:00
|
|
|
{
|
2008-08-19 14:00:32 +02:00
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
case 0x00:
|
|
|
|
case 0x0D:
|
|
|
|
case 0x0A:
|
|
|
|
case ' ':
|
|
|
|
case '\t':
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-08-18 15:10:25 +02:00
|
|
|
|
2008-08-19 14:00:32 +02:00
|
|
|
static BOOL is_operator(char c)
|
|
|
|
{
|
|
|
|
switch(c)
|
2008-08-18 15:10:25 +02:00
|
|
|
{
|
2008-08-19 14:00:32 +02:00
|
|
|
case '{':
|
|
|
|
case '}':
|
|
|
|
case '[':
|
|
|
|
case ']':
|
|
|
|
case '(':
|
|
|
|
case ')':
|
|
|
|
case '<':
|
|
|
|
case '>':
|
|
|
|
case ',':
|
|
|
|
case ';':
|
|
|
|
return TRUE;
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
2008-08-19 14:00:32 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline BOOL is_separator(char c)
|
|
|
|
{
|
|
|
|
return is_space(c) || is_operator(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
static WORD get_operator_token(char c)
|
|
|
|
{
|
|
|
|
switch(c)
|
|
|
|
{
|
|
|
|
case '{':
|
|
|
|
return TOKEN_OBRACE;
|
|
|
|
case '}':
|
|
|
|
return TOKEN_CBRACE;
|
|
|
|
case '[':
|
|
|
|
return TOKEN_OBRACKET;
|
|
|
|
case ']':
|
|
|
|
return TOKEN_CBRACKET;
|
|
|
|
case '(':
|
|
|
|
return TOKEN_OPAREN;
|
|
|
|
case ')':
|
|
|
|
return TOKEN_CPAREN;
|
|
|
|
case '<':
|
|
|
|
return TOKEN_OANGLE;
|
|
|
|
case '>':
|
|
|
|
return TOKEN_CANGLE;
|
|
|
|
case ',':
|
|
|
|
return TOKEN_COMMA;
|
|
|
|
case ';':
|
|
|
|
return TOKEN_SEMICOLON;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_keyword(parse_buffer* buf, const char* keyword)
|
|
|
|
{
|
|
|
|
DWORD len = strlen(keyword);
|
2008-11-27 22:10:11 +01:00
|
|
|
if (!strncasecmp((char*)buf->buffer, keyword,len) && is_separator(*(buf->buffer+len)))
|
2008-08-19 14:00:32 +02:00
|
|
|
{
|
|
|
|
buf->buffer += len;
|
|
|
|
buf->rem_bytes -= len;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static WORD get_keyword_token(parse_buffer* buf)
|
|
|
|
{
|
|
|
|
if (is_keyword(buf, "template"))
|
|
|
|
return TOKEN_TEMPLATE;
|
|
|
|
if (is_keyword(buf, "WORD"))
|
|
|
|
return TOKEN_WORD;
|
|
|
|
if (is_keyword(buf, "DWORD"))
|
|
|
|
return TOKEN_DWORD;
|
|
|
|
if (is_keyword(buf, "FLOAT"))
|
|
|
|
return TOKEN_FLOAT;
|
|
|
|
if (is_keyword(buf, "DOUBLE"))
|
|
|
|
return TOKEN_DOUBLE;
|
|
|
|
if (is_keyword(buf, "CHAR"))
|
|
|
|
return TOKEN_CHAR;
|
|
|
|
if (is_keyword(buf, "UCHAR"))
|
|
|
|
return TOKEN_UCHAR;
|
|
|
|
if (is_keyword(buf, "SWORD"))
|
|
|
|
return TOKEN_SWORD;
|
|
|
|
if (is_keyword(buf, "SDWORD"))
|
|
|
|
return TOKEN_SDWORD;
|
|
|
|
if (is_keyword(buf, "VOID"))
|
|
|
|
return TOKEN_VOID;
|
2008-08-30 11:52:39 +02:00
|
|
|
if (is_keyword(buf, "STRING"))
|
2008-08-19 14:00:32 +02:00
|
|
|
return TOKEN_LPSTR;
|
|
|
|
if (is_keyword(buf, "UNICODE"))
|
|
|
|
return TOKEN_UNICODE;
|
|
|
|
if (is_keyword(buf, "CSTRING"))
|
|
|
|
return TOKEN_CSTRING;
|
|
|
|
if (is_keyword(buf, "array"))
|
|
|
|
return TOKEN_ARRAY;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_guid(parse_buffer* buf)
|
|
|
|
{
|
2008-08-25 12:37:12 +02:00
|
|
|
char tmp[50];
|
2008-08-19 14:00:32 +02:00
|
|
|
DWORD pos = 1;
|
2008-08-22 13:16:58 +02:00
|
|
|
GUID class_id;
|
|
|
|
DWORD tab[10];
|
|
|
|
int ret;
|
2008-08-19 14:00:32 +02:00
|
|
|
|
|
|
|
if (*buf->buffer != '<')
|
|
|
|
return FALSE;
|
|
|
|
tmp[0] = '<';
|
|
|
|
while (*(buf->buffer+pos) != '>')
|
|
|
|
{
|
|
|
|
tmp[pos] = *(buf->buffer+pos);
|
|
|
|
pos++;
|
|
|
|
}
|
|
|
|
tmp[pos++] = '>';
|
|
|
|
tmp[pos] = 0;
|
2008-08-29 11:11:54 +02:00
|
|
|
if (pos != 38 /* <+36+> */)
|
2008-08-19 14:00:32 +02:00
|
|
|
{
|
2008-09-01 17:02:50 +02:00
|
|
|
TRACE("Wrong guid %s (%d)\n", tmp, pos);
|
2008-08-19 14:00:32 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
buf->buffer += pos;
|
|
|
|
buf->rem_bytes -= pos;
|
|
|
|
|
2008-08-22 13:16:58 +02:00
|
|
|
ret = sscanf(tmp, CLSIDFMT, &class_id.Data1, tab, tab+1, tab+2, tab+3, tab+4, tab+5, tab+6, tab+7, tab+8, tab+9);
|
|
|
|
if (ret != 11)
|
|
|
|
{
|
2008-09-01 17:02:50 +02:00
|
|
|
TRACE("Wrong guid %s (%d)\n", tmp, pos);
|
2008-08-22 13:16:58 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-09-01 17:02:50 +02:00
|
|
|
TRACE("Found guid %s (%d)\n", tmp, pos);
|
2008-08-22 13:16:58 +02:00
|
|
|
|
|
|
|
class_id.Data2 = tab[0];
|
|
|
|
class_id.Data3 = tab[1];
|
|
|
|
class_id.Data4[0] = tab[2];
|
|
|
|
class_id.Data4[1] = tab[3];
|
|
|
|
class_id.Data4[2] = tab[4];
|
|
|
|
class_id.Data4[3] = tab[5];
|
|
|
|
class_id.Data4[4] = tab[6];
|
|
|
|
class_id.Data4[5] = tab[7];
|
|
|
|
class_id.Data4[6] = tab[8];
|
|
|
|
class_id.Data4[7] = tab[9];
|
|
|
|
|
|
|
|
*(GUID*)buf->value = class_id;
|
|
|
|
|
2008-08-19 14:00:32 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL is_name(parse_buffer* buf)
|
|
|
|
{
|
2008-08-25 12:37:12 +02:00
|
|
|
char tmp[50];
|
2008-08-19 14:00:32 +02:00
|
|
|
DWORD pos = 0;
|
|
|
|
char c;
|
|
|
|
BOOL error = 0;
|
|
|
|
while (!is_separator(c = *(buf->buffer+pos)))
|
|
|
|
{
|
2008-11-16 19:42:38 +01:00
|
|
|
if (!(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9')) || (c == '_') || (c == '-')))
|
2008-08-19 14:00:32 +02:00
|
|
|
error = 1;
|
|
|
|
tmp[pos++] = c;
|
|
|
|
}
|
|
|
|
tmp[pos] = 0;
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
TRACE("Wrong name %s\n", tmp);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf->buffer += pos;
|
|
|
|
buf->rem_bytes -= pos;
|
|
|
|
|
|
|
|
TRACE("Found name %s\n", tmp);
|
2008-08-22 13:16:58 +02:00
|
|
|
strcpy((char*)buf->value, tmp);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
static BOOL is_float(parse_buffer* buf)
|
|
|
|
{
|
|
|
|
char tmp[50];
|
|
|
|
DWORD pos = 0;
|
|
|
|
char c;
|
|
|
|
float decimal;
|
|
|
|
BOOL dot = 0;
|
|
|
|
|
|
|
|
while (!is_separator(c = *(buf->buffer+pos)))
|
|
|
|
{
|
|
|
|
if (!((!pos && (c == '-')) || ((c >= '0') && (c <= '9')) || (!dot && (c == '.'))))
|
|
|
|
return FALSE;
|
|
|
|
if (c == '.')
|
|
|
|
dot = TRUE;
|
|
|
|
tmp[pos++] = c;
|
|
|
|
}
|
|
|
|
tmp[pos] = 0;
|
|
|
|
|
|
|
|
buf->buffer += pos;
|
|
|
|
buf->rem_bytes -= pos;
|
|
|
|
|
|
|
|
sscanf(tmp, "%f", &decimal);
|
|
|
|
|
|
|
|
TRACE("Found float %s - %f\n", tmp, decimal);
|
|
|
|
|
|
|
|
*(float*)buf->value = decimal;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-08-22 13:16:58 +02:00
|
|
|
static BOOL is_integer(parse_buffer* buf)
|
|
|
|
{
|
2008-08-25 12:37:12 +02:00
|
|
|
char tmp[50];
|
2008-08-22 13:16:58 +02:00
|
|
|
DWORD pos = 0;
|
|
|
|
char c;
|
|
|
|
DWORD integer;
|
|
|
|
|
|
|
|
while (!is_separator(c = *(buf->buffer+pos)))
|
|
|
|
{
|
|
|
|
if (!((c >= '0') && (c <= '9')))
|
|
|
|
return FALSE;
|
|
|
|
tmp[pos++] = c;
|
|
|
|
}
|
|
|
|
tmp[pos] = 0;
|
|
|
|
|
|
|
|
buf->buffer += pos;
|
|
|
|
buf->rem_bytes -= pos;
|
|
|
|
|
|
|
|
sscanf(tmp, "%d", &integer);
|
|
|
|
|
|
|
|
TRACE("Found integer %s - %d\n", tmp, integer);
|
|
|
|
|
2008-09-13 00:09:57 +02:00
|
|
|
*(DWORD*)buf->value = integer;
|
2008-08-19 14:00:32 +02:00
|
|
|
|
|
|
|
return TRUE;
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
|
|
|
|
2008-10-16 22:23:46 +02:00
|
|
|
static BOOL is_string(parse_buffer* buf)
|
|
|
|
{
|
|
|
|
char tmp[32];
|
2008-11-09 11:11:40 +01:00
|
|
|
DWORD pos = 0;
|
2008-10-16 22:23:46 +02:00
|
|
|
char c;
|
|
|
|
BOOL ok = 0;
|
|
|
|
|
|
|
|
if (*buf->buffer != '"')
|
|
|
|
return FALSE;
|
|
|
|
|
2008-11-09 11:11:40 +01:00
|
|
|
while (!is_separator(c = *(buf->buffer+pos+1)) && (pos < 31))
|
2008-10-16 22:23:46 +02:00
|
|
|
{
|
|
|
|
if (c == '"')
|
|
|
|
{
|
|
|
|
ok = 1;
|
|
|
|
break;
|
|
|
|
}
|
2008-11-09 11:11:40 +01:00
|
|
|
tmp[pos++] = c;
|
2008-10-16 22:23:46 +02:00
|
|
|
}
|
|
|
|
tmp[pos] = 0;
|
|
|
|
|
|
|
|
if (!ok)
|
|
|
|
{
|
|
|
|
TRACE("Wrong string %s\n", tmp);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-11-09 11:11:40 +01:00
|
|
|
buf->buffer += pos + 2;
|
|
|
|
buf->rem_bytes -= pos + 2;
|
2008-10-16 22:23:46 +02:00
|
|
|
|
|
|
|
TRACE("Found string %s\n", tmp);
|
|
|
|
strcpy((char*)buf->value, tmp);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-09-20 12:34:00 +02:00
|
|
|
static WORD parse_TOKEN(parse_buffer * buf)
|
2008-08-18 15:10:25 +02:00
|
|
|
{
|
|
|
|
WORD token;
|
|
|
|
|
2008-08-19 14:00:32 +02:00
|
|
|
if (buf->txt)
|
|
|
|
{
|
|
|
|
while(1)
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
if (!read_bytes(buf, &c, 1))
|
|
|
|
return 0;
|
|
|
|
/*TRACE("char = '%c'\n", is_space(c) ? ' ' : c);*/
|
2008-09-01 23:21:52 +02:00
|
|
|
if ((c == '#') || (c == '/'))
|
|
|
|
{
|
|
|
|
/* Handle comment (# or //) */
|
|
|
|
if (c == '/')
|
|
|
|
{
|
|
|
|
if (!read_bytes(buf, &c, 1))
|
|
|
|
return 0;
|
|
|
|
if (c != '/')
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
c = 0;
|
|
|
|
while (c != 0x0A)
|
|
|
|
{
|
|
|
|
if (!read_bytes(buf, &c, 1))
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
2008-08-19 14:00:32 +02:00
|
|
|
if (is_space(c))
|
|
|
|
continue;
|
|
|
|
if (is_operator(c) && (c != '<'))
|
|
|
|
{
|
|
|
|
token = get_operator_token(c);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (c == '.')
|
|
|
|
{
|
|
|
|
token = TOKEN_DOT;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buf->buffer -= 1;
|
|
|
|
buf->rem_bytes += 1;
|
|
|
|
|
|
|
|
if ((token = get_keyword_token(buf)))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (is_guid(buf))
|
|
|
|
{
|
|
|
|
token = TOKEN_GUID;
|
|
|
|
break;
|
|
|
|
}
|
2008-08-22 13:16:58 +02:00
|
|
|
if (is_integer(buf))
|
|
|
|
{
|
|
|
|
token = TOKEN_INTEGER;
|
|
|
|
break;
|
|
|
|
}
|
2008-09-16 22:22:28 +02:00
|
|
|
if (is_float(buf))
|
|
|
|
{
|
|
|
|
token = TOKEN_FLOAT;
|
|
|
|
break;
|
|
|
|
}
|
2008-10-16 22:23:46 +02:00
|
|
|
if (is_string(buf))
|
|
|
|
{
|
|
|
|
token = TOKEN_LPSTR;
|
|
|
|
break;
|
|
|
|
}
|
2008-08-19 14:00:32 +02:00
|
|
|
if (is_name(buf))
|
|
|
|
{
|
|
|
|
token = TOKEN_NAME;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
FIXME("Unrecognize element\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-16 19:45:38 +01:00
|
|
|
static int nb_elem;
|
|
|
|
static int is_float;
|
|
|
|
|
|
|
|
if (!nb_elem)
|
|
|
|
{
|
|
|
|
if (!read_bytes(buf, &token, 2))
|
|
|
|
return 0;
|
|
|
|
|
2008-11-23 21:30:37 +01:00
|
|
|
/* Convert integer and float list into separate elements */
|
2008-11-16 19:45:38 +01:00
|
|
|
if (token == TOKEN_INTEGER_LIST)
|
|
|
|
{
|
|
|
|
if (!read_bytes(buf, &nb_elem, 4))
|
|
|
|
return 0;
|
|
|
|
token = TOKEN_INTEGER;
|
|
|
|
is_float = FALSE;
|
|
|
|
TRACE("Integer list (TOKEN_INTEGER_LIST) of size %d\n", nb_elem);
|
|
|
|
}
|
|
|
|
else if (token == TOKEN_FLOAT_LIST)
|
|
|
|
{
|
|
|
|
if (!read_bytes(buf, &nb_elem, 4))
|
|
|
|
return 0;
|
|
|
|
token = TOKEN_FLOAT;
|
|
|
|
is_float = TRUE;
|
|
|
|
TRACE("Float list (TOKEN_FLOAT_LIST) of size %d\n", nb_elem);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nb_elem)
|
|
|
|
{
|
|
|
|
token = is_float ? TOKEN_FLOAT : TOKEN_INTEGER;
|
|
|
|
nb_elem--;
|
|
|
|
{
|
|
|
|
DWORD integer;
|
|
|
|
|
|
|
|
if (!read_bytes(buf, &integer, 4))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
*(DWORD*)buf->value = integer;
|
|
|
|
}
|
|
|
|
dump_TOKEN(token);
|
|
|
|
return token;
|
|
|
|
}
|
2008-08-18 15:10:25 +02:00
|
|
|
|
2008-11-16 19:45:38 +01:00
|
|
|
switch (token)
|
2008-09-13 00:09:57 +02:00
|
|
|
{
|
|
|
|
case TOKEN_NAME:
|
|
|
|
{
|
|
|
|
DWORD count;
|
|
|
|
char strname[100];
|
|
|
|
|
|
|
|
if (!read_bytes(buf, &count, 4))
|
|
|
|
return 0;
|
|
|
|
if (!read_bytes(buf, strname, count))
|
|
|
|
return 0;
|
|
|
|
strname[count] = 0;
|
|
|
|
/*TRACE("name = %s\n", strname);*/
|
|
|
|
|
|
|
|
strcpy((char*)buf->value, strname);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TOKEN_INTEGER:
|
|
|
|
{
|
|
|
|
DWORD integer;
|
|
|
|
|
|
|
|
if (!read_bytes(buf, &integer, 4))
|
|
|
|
return 0;
|
|
|
|
/*TRACE("integer = %ld\n", integer);*/
|
|
|
|
|
|
|
|
*(DWORD*)buf->value = integer;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TOKEN_GUID:
|
|
|
|
{
|
2008-11-10 13:20:03 +01:00
|
|
|
char strguid[39];
|
2008-09-13 00:09:57 +02:00
|
|
|
GUID class_id;
|
|
|
|
|
|
|
|
if (!read_bytes(buf, &class_id, 16))
|
|
|
|
return 0;
|
|
|
|
sprintf(strguid, CLSIDFMT, class_id.Data1, class_id.Data2, class_id.Data3, class_id.Data4[0],
|
|
|
|
class_id.Data4[1], class_id.Data4[2], class_id.Data4[3], class_id.Data4[4], class_id.Data4[5],
|
|
|
|
class_id.Data4[6], class_id.Data4[7]);
|
|
|
|
/*TRACE("guid = {%s}\n", strguid);*/
|
|
|
|
|
|
|
|
*(GUID*)buf->value = class_id;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TOKEN_STRING:
|
2008-11-16 19:45:38 +01:00
|
|
|
{
|
|
|
|
DWORD count;
|
|
|
|
WORD tmp_token;
|
|
|
|
char strname[100];
|
|
|
|
if (!read_bytes(buf, &count, 4))
|
|
|
|
return 0;
|
|
|
|
if (!read_bytes(buf, strname, count))
|
|
|
|
return 0;
|
|
|
|
strname[count] = 0;
|
|
|
|
if (!read_bytes(buf, &tmp_token, 2))
|
|
|
|
return 0;
|
|
|
|
if ((tmp_token != TOKEN_COMMA) && (tmp_token != TOKEN_SEMICOLON))
|
|
|
|
ERR("No comma or semicolon (got %d)\n", tmp_token);
|
|
|
|
/*TRACE("name = %s\n", strname);*/
|
|
|
|
|
|
|
|
strcpy((char*)buf->value, strname);
|
|
|
|
token = TOKEN_LPSTR;
|
|
|
|
}
|
|
|
|
break;
|
2008-09-13 00:09:57 +02:00
|
|
|
case TOKEN_OBRACE:
|
|
|
|
case TOKEN_CBRACE:
|
|
|
|
case TOKEN_OPAREN:
|
|
|
|
case TOKEN_CPAREN:
|
|
|
|
case TOKEN_OBRACKET:
|
|
|
|
case TOKEN_CBRACKET:
|
|
|
|
case TOKEN_OANGLE:
|
|
|
|
case TOKEN_CANGLE:
|
|
|
|
case TOKEN_DOT:
|
|
|
|
case TOKEN_COMMA:
|
|
|
|
case TOKEN_SEMICOLON:
|
|
|
|
case TOKEN_TEMPLATE:
|
|
|
|
case TOKEN_WORD:
|
|
|
|
case TOKEN_DWORD:
|
|
|
|
case TOKEN_FLOAT:
|
|
|
|
case TOKEN_DOUBLE:
|
|
|
|
case TOKEN_CHAR:
|
|
|
|
case TOKEN_UCHAR:
|
|
|
|
case TOKEN_SWORD:
|
|
|
|
case TOKEN_SDWORD:
|
|
|
|
case TOKEN_VOID:
|
|
|
|
case TOKEN_LPSTR:
|
|
|
|
case TOKEN_UNICODE:
|
|
|
|
case TOKEN_CSTRING:
|
|
|
|
case TOKEN_ARRAY:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
|
|
|
|
2008-09-20 12:34:00 +02:00
|
|
|
dump_TOKEN(token);
|
2008-08-18 15:10:25 +02:00
|
|
|
|
|
|
|
return token;
|
|
|
|
}
|
|
|
|
|
2008-08-22 13:16:58 +02:00
|
|
|
static const char* get_primitive_string(WORD token)
|
|
|
|
{
|
|
|
|
switch(token)
|
|
|
|
{
|
|
|
|
case TOKEN_WORD:
|
|
|
|
return "WORD";
|
|
|
|
case TOKEN_DWORD:
|
|
|
|
return "DWORD";
|
|
|
|
case TOKEN_FLOAT:
|
|
|
|
return "FLOAT";
|
|
|
|
case TOKEN_DOUBLE:
|
|
|
|
return "DOUBLE";
|
|
|
|
case TOKEN_CHAR:
|
|
|
|
return "CHAR";
|
|
|
|
case TOKEN_UCHAR:
|
|
|
|
return "UCHAR";
|
|
|
|
case TOKEN_SWORD:
|
|
|
|
return "SWORD";
|
|
|
|
case TOKEN_SDWORD:
|
|
|
|
return "SDWORD";
|
|
|
|
case TOKEN_VOID:
|
|
|
|
return "VOID";
|
|
|
|
case TOKEN_LPSTR:
|
2008-08-30 11:52:39 +02:00
|
|
|
return "STRING";
|
2008-08-22 13:16:58 +02:00
|
|
|
case TOKEN_UNICODE:
|
|
|
|
return "UNICODE";
|
|
|
|
case TOKEN_CSTRING:
|
|
|
|
return "CSTRING ";
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2008-09-20 12:34:00 +02:00
|
|
|
static WORD get_TOKEN(parse_buffer * buf)
|
2008-08-19 14:00:32 +02:00
|
|
|
{
|
2008-09-20 12:34:00 +02:00
|
|
|
if (buf->token_present)
|
|
|
|
{
|
|
|
|
buf->token_present = FALSE;
|
|
|
|
return buf->current_token;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf->current_token = parse_TOKEN(buf);
|
|
|
|
|
|
|
|
return buf->current_token;
|
2008-08-19 14:00:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static WORD check_TOKEN(parse_buffer * buf)
|
|
|
|
{
|
2008-09-20 12:34:00 +02:00
|
|
|
if (buf->token_present)
|
|
|
|
return buf->current_token;
|
2008-08-19 14:00:32 +02:00
|
|
|
|
2008-09-20 12:34:00 +02:00
|
|
|
buf->current_token = parse_TOKEN(buf);
|
|
|
|
buf->token_present = TRUE;
|
2008-08-19 14:00:32 +02:00
|
|
|
|
2008-09-20 12:34:00 +02:00
|
|
|
return buf->current_token;
|
2008-08-19 14:00:32 +02:00
|
|
|
}
|
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
static inline BOOL is_primitive_type(WORD token)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
switch(token)
|
|
|
|
{
|
|
|
|
case TOKEN_WORD:
|
|
|
|
case TOKEN_DWORD:
|
|
|
|
case TOKEN_FLOAT:
|
|
|
|
case TOKEN_DOUBLE:
|
|
|
|
case TOKEN_CHAR:
|
|
|
|
case TOKEN_UCHAR:
|
|
|
|
case TOKEN_SWORD:
|
|
|
|
case TOKEN_SDWORD:
|
|
|
|
case TOKEN_LPSTR:
|
|
|
|
case TOKEN_UNICODE:
|
|
|
|
case TOKEN_CSTRING:
|
|
|
|
ret = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL parse_template_option_info(parse_buffer * buf)
|
|
|
|
{
|
2008-08-22 13:16:58 +02:00
|
|
|
xtemplate* cur_template = &buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates];
|
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
if (check_TOKEN(buf) == TOKEN_DOT)
|
|
|
|
{
|
2008-09-20 12:34:00 +02:00
|
|
|
get_TOKEN(buf);
|
|
|
|
if (get_TOKEN(buf) != TOKEN_DOT)
|
2008-08-18 15:10:25 +02:00
|
|
|
return FALSE;
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_DOT)
|
2008-08-18 15:10:25 +02:00
|
|
|
return FALSE;
|
2008-08-22 13:16:58 +02:00
|
|
|
cur_template->open = TRUE;
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
while (1)
|
|
|
|
{
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_NAME)
|
2008-08-18 15:10:25 +02:00
|
|
|
return FALSE;
|
2008-08-22 13:16:58 +02:00
|
|
|
strcpy(cur_template->childs[cur_template->nb_childs], (char*)buf->value);
|
2008-08-18 15:10:25 +02:00
|
|
|
if (check_TOKEN(buf) == TOKEN_GUID)
|
2008-09-20 12:34:00 +02:00
|
|
|
get_TOKEN(buf);
|
2008-08-22 13:16:58 +02:00
|
|
|
cur_template->nb_childs++;
|
2008-08-18 15:10:25 +02:00
|
|
|
if (check_TOKEN(buf) != TOKEN_COMMA)
|
|
|
|
break;
|
2008-09-20 12:34:00 +02:00
|
|
|
get_TOKEN(buf);
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
2008-08-22 13:16:58 +02:00
|
|
|
cur_template->open = FALSE;
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
2008-08-22 13:16:58 +02:00
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL parse_template_members_list(parse_buffer * buf)
|
|
|
|
{
|
2008-08-22 13:16:58 +02:00
|
|
|
int idx_member = 0;
|
|
|
|
member* cur_member;
|
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
while (1)
|
|
|
|
{
|
2008-09-13 00:09:57 +02:00
|
|
|
BOOL array = 0;
|
|
|
|
int nb_dims = 0;
|
2008-08-22 13:16:58 +02:00
|
|
|
cur_member = &buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[idx_member];
|
2008-09-13 00:09:57 +02:00
|
|
|
|
|
|
|
if (check_TOKEN(buf) == TOKEN_ARRAY)
|
|
|
|
{
|
2008-09-20 12:34:00 +02:00
|
|
|
get_TOKEN(buf);
|
2008-09-13 00:09:57 +02:00
|
|
|
array = 1;
|
|
|
|
}
|
2008-08-22 13:16:58 +02:00
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
if (check_TOKEN(buf) == TOKEN_NAME)
|
|
|
|
{
|
2008-09-20 12:34:00 +02:00
|
|
|
cur_member->type = get_TOKEN(buf);
|
2008-09-13 00:09:57 +02:00
|
|
|
cur_member->idx_template = 0;
|
2008-08-22 13:16:58 +02:00
|
|
|
while (cur_member->idx_template < buf->pdxf->nb_xtemplates)
|
|
|
|
{
|
2008-12-28 11:27:29 +01:00
|
|
|
if (!strcasecmp((char*)buf->value, buf->pdxf->xtemplates[cur_member->idx_template].name))
|
2008-08-22 13:16:58 +02:00
|
|
|
break;
|
|
|
|
cur_member->idx_template++;
|
|
|
|
}
|
|
|
|
if (cur_member->idx_template == buf->pdxf->nb_xtemplates)
|
|
|
|
{
|
2008-12-28 11:27:29 +01:00
|
|
|
ERR("Reference to a nonexistent template '%s'\n", (char*)buf->value);
|
2008-08-22 13:16:58 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
2008-09-13 00:09:57 +02:00
|
|
|
else if (is_primitive_type(check_TOKEN(buf)))
|
2008-09-20 12:34:00 +02:00
|
|
|
cur_member->type = get_TOKEN(buf);
|
2008-09-13 00:09:57 +02:00
|
|
|
else
|
|
|
|
break;
|
2008-08-22 13:16:58 +02:00
|
|
|
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_NAME)
|
2008-09-13 00:09:57 +02:00
|
|
|
return FALSE;
|
|
|
|
strcpy(cur_member->name, (char*)buf->value);
|
|
|
|
|
|
|
|
if (array)
|
|
|
|
{
|
2008-08-18 15:10:25 +02:00
|
|
|
while (check_TOKEN(buf) == TOKEN_OBRACKET)
|
|
|
|
{
|
2008-11-23 21:31:13 +01:00
|
|
|
if (nb_dims >= MAX_ARRAY_DIM)
|
|
|
|
{
|
|
|
|
FIXME("Too many dimensions (%d) for multi-dimensional array\n", nb_dims + 1);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-09-20 12:34:00 +02:00
|
|
|
get_TOKEN(buf);
|
2008-08-18 15:10:25 +02:00
|
|
|
if (check_TOKEN(buf) == TOKEN_INTEGER)
|
|
|
|
{
|
2008-09-20 12:34:00 +02:00
|
|
|
get_TOKEN(buf);
|
2008-08-22 13:16:58 +02:00
|
|
|
cur_member->dim_fixed[nb_dims] = TRUE;
|
|
|
|
cur_member->dim_value[nb_dims] = *(DWORD*)buf->value;
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-11-23 21:30:00 +01:00
|
|
|
int i;
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_NAME)
|
2008-09-13 00:09:57 +02:00
|
|
|
return FALSE;
|
2008-11-23 21:30:00 +01:00
|
|
|
for (i = 0; i < idx_member; i++)
|
|
|
|
{
|
|
|
|
if (!strcmp((char*)buf->value, buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[i].name))
|
|
|
|
{
|
|
|
|
if (buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[i].nb_dims)
|
|
|
|
{
|
|
|
|
ERR("Array cannot be used to specify variable array size\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[i].type != TOKEN_DWORD)
|
|
|
|
{
|
|
|
|
FIXME("Only DWORD supported to specify variable array size\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == idx_member)
|
|
|
|
{
|
|
|
|
ERR("Reference to unknown member %s\n", (char*)buf->value);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-08-22 13:16:58 +02:00
|
|
|
cur_member->dim_fixed[nb_dims] = FALSE;
|
2008-11-23 21:30:00 +01:00
|
|
|
cur_member->dim_value[nb_dims] = i;
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_CBRACKET)
|
2008-09-13 00:09:57 +02:00
|
|
|
return FALSE;
|
2008-08-22 13:16:58 +02:00
|
|
|
nb_dims++;
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
2008-09-13 00:09:57 +02:00
|
|
|
if (!nb_dims)
|
|
|
|
return FALSE;
|
2008-08-22 13:16:58 +02:00
|
|
|
cur_member->nb_dims = nb_dims;
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_SEMICOLON)
|
2008-09-13 00:09:57 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
idx_member++;
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
2008-08-22 13:16:58 +02:00
|
|
|
|
|
|
|
buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].nb_members = idx_member;
|
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL parse_template_parts(parse_buffer * buf)
|
|
|
|
{
|
2008-09-13 00:09:57 +02:00
|
|
|
if (!parse_template_members_list(buf))
|
|
|
|
return FALSE;
|
2008-08-18 15:10:25 +02:00
|
|
|
if (check_TOKEN(buf) == TOKEN_OBRACKET)
|
|
|
|
{
|
2008-09-20 12:34:00 +02:00
|
|
|
get_TOKEN(buf);
|
2008-08-18 15:10:25 +02:00
|
|
|
if (!parse_template_option_info(buf))
|
|
|
|
return FALSE;
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_CBRACKET)
|
2008-09-13 00:09:57 +02:00
|
|
|
return FALSE;
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2008-11-30 12:18:46 +01:00
|
|
|
static void go_to_next_definition(parse_buffer * buf)
|
|
|
|
{
|
|
|
|
while (buf->rem_bytes)
|
|
|
|
{
|
|
|
|
char c = *buf->buffer;
|
|
|
|
if ((c == '#') || (c == '/'))
|
|
|
|
{
|
|
|
|
read_bytes(buf, &c, 1);
|
|
|
|
/* Handle comment (# or //) */
|
|
|
|
if (c == '/')
|
|
|
|
{
|
|
|
|
if (!read_bytes(buf, &c, 1))
|
|
|
|
return;
|
|
|
|
if (c != '/')
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
c = 0;
|
|
|
|
while (c != 0x0A)
|
|
|
|
{
|
|
|
|
if (!read_bytes(buf, &c, 1))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (is_space(*buf->buffer))
|
|
|
|
{
|
|
|
|
buf->buffer++;
|
|
|
|
buf->rem_bytes--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
static BOOL parse_template(parse_buffer * buf)
|
|
|
|
{
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_TEMPLATE)
|
2008-08-18 15:10:25 +02:00
|
|
|
return FALSE;
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_NAME)
|
2008-08-18 15:10:25 +02:00
|
|
|
return FALSE;
|
2008-08-22 13:16:58 +02:00
|
|
|
strcpy(buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].name, (char*)buf->value);
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_OBRACE)
|
2008-08-18 15:10:25 +02:00
|
|
|
return FALSE;
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_GUID)
|
2008-08-18 15:10:25 +02:00
|
|
|
return FALSE;
|
2008-08-22 13:16:58 +02:00
|
|
|
buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].class_id = *(GUID*)buf->value;
|
2008-08-18 15:10:25 +02:00
|
|
|
if (!parse_template_parts(buf))
|
|
|
|
return FALSE;
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_CBRACE)
|
2008-08-18 15:10:25 +02:00
|
|
|
return FALSE;
|
2008-08-19 14:00:32 +02:00
|
|
|
if (buf->txt)
|
|
|
|
{
|
|
|
|
/* Go to the next template */
|
2008-11-30 12:18:46 +01:00
|
|
|
go_to_next_definition(buf);
|
2008-08-19 14:00:32 +02:00
|
|
|
}
|
2008-08-22 13:16:58 +02:00
|
|
|
|
|
|
|
TRACE("%d - %s - %s\n", buf->pdxf->nb_xtemplates, buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].name, debugstr_guid(&buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].class_id));
|
|
|
|
buf->pdxf->nb_xtemplates++;
|
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
static HRESULT WINAPI IDirectXFileImpl_RegisterTemplates(IDirectXFile* iface, LPVOID pvData, DWORD cbSize)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileImpl *This = (IDirectXFileImpl *)iface;
|
2008-08-18 15:10:25 +02:00
|
|
|
DWORD token_header;
|
|
|
|
parse_buffer buf;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
buf.buffer = (LPBYTE)pvData;
|
|
|
|
buf.rem_bytes = cbSize;
|
2008-08-19 14:00:32 +02:00
|
|
|
buf.txt = FALSE;
|
2008-09-20 12:34:00 +02:00
|
|
|
buf.token_present = FALSE;
|
2008-08-22 13:16:58 +02:00
|
|
|
buf.pdxf = This;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
TRACE("(%p/%p)->(%p,%d)\n", This, iface, pvData, cbSize);
|
2008-08-18 15:10:25 +02:00
|
|
|
|
|
|
|
if (!pvData)
|
|
|
|
return DXFILEERR_BADVALUE;
|
|
|
|
|
|
|
|
if (cbSize < 16)
|
|
|
|
return DXFILEERR_BADFILETYPE;
|
|
|
|
|
|
|
|
if (TRACE_ON(d3dxof))
|
|
|
|
{
|
|
|
|
char string[17];
|
|
|
|
memcpy(string, pvData, 16);
|
|
|
|
string[16] = 0;
|
|
|
|
TRACE("header = '%s'\n", string);
|
|
|
|
}
|
|
|
|
|
|
|
|
read_bytes(&buf, &token_header, 4);
|
|
|
|
|
|
|
|
if (token_header != XOFFILE_FORMAT_MAGIC)
|
|
|
|
return DXFILEERR_BADFILETYPE;
|
|
|
|
|
|
|
|
read_bytes(&buf, &token_header, 4);
|
|
|
|
|
2008-11-11 12:38:52 +01:00
|
|
|
if ((token_header != XOFFILE_FORMAT_VERSION_302) && (token_header != XOFFILE_FORMAT_VERSION_303))
|
2008-08-18 15:10:25 +02:00
|
|
|
return DXFILEERR_BADFILEVERSION;
|
|
|
|
|
|
|
|
read_bytes(&buf, &token_header, 4);
|
|
|
|
|
|
|
|
if ((token_header != XOFFILE_FORMAT_BINARY) && (token_header != XOFFILE_FORMAT_TEXT) && (token_header != XOFFILE_FORMAT_COMPRESSED))
|
|
|
|
return DXFILEERR_BADFILETYPE;
|
|
|
|
|
|
|
|
if (token_header == XOFFILE_FORMAT_TEXT)
|
|
|
|
{
|
2008-08-19 14:00:32 +02:00
|
|
|
buf.txt = TRUE;
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (token_header == XOFFILE_FORMAT_COMPRESSED)
|
|
|
|
{
|
2008-09-01 17:02:50 +02:00
|
|
|
FIXME("Compressed formats not supported yet\n");
|
2008-08-18 15:10:25 +02:00
|
|
|
return DXFILEERR_BADVALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
read_bytes(&buf, &token_header, 4);
|
|
|
|
|
|
|
|
if ((token_header != XOFFILE_FORMAT_FLOAT_BITS_32) && (token_header != XOFFILE_FORMAT_FLOAT_BITS_64))
|
|
|
|
return DXFILEERR_BADFILEFLOATSIZE;
|
|
|
|
|
2008-08-19 14:00:32 +02:00
|
|
|
TRACE("Header is correct\n");
|
|
|
|
|
2008-08-18 15:10:25 +02:00
|
|
|
while (buf.rem_bytes)
|
|
|
|
{
|
|
|
|
if (!parse_template(&buf))
|
|
|
|
{
|
|
|
|
TRACE("Template is not correct\n");
|
|
|
|
return DXFILEERR_BADVALUE;
|
|
|
|
}
|
|
|
|
else
|
2008-08-22 13:16:58 +02:00
|
|
|
{
|
2008-08-18 15:10:25 +02:00
|
|
|
TRACE("Template successfully parsed:\n");
|
|
|
|
if (TRACE_ON(d3dxof))
|
2008-10-16 22:21:43 +02:00
|
|
|
dump_template(This->xtemplates, &This->xtemplates[This->nb_xtemplates - 1]);
|
2008-08-22 13:16:58 +02:00
|
|
|
}
|
2008-08-18 15:10:25 +02:00
|
|
|
}
|
|
|
|
|
2008-08-22 13:16:58 +02:00
|
|
|
if (TRACE_ON(d3dxof))
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
TRACE("Registered templates (%d):\n", This->nb_xtemplates);
|
|
|
|
for (i = 0; i < This->nb_xtemplates; i++)
|
|
|
|
DPRINTF("%s - %s\n", This->xtemplates[i].name, debugstr_guid(&This->xtemplates[i].class_id));
|
|
|
|
}
|
2008-08-18 15:10:25 +02:00
|
|
|
|
|
|
|
return DXFILE_OK;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
static const IDirectXFileVtbl IDirectXFile_Vtbl =
|
2004-06-03 02:03:23 +02:00
|
|
|
{
|
|
|
|
IDirectXFileImpl_QueryInterface,
|
|
|
|
IDirectXFileImpl_AddRef,
|
|
|
|
IDirectXFileImpl_Release,
|
|
|
|
IDirectXFileImpl_CreateEnumObject,
|
|
|
|
IDirectXFileImpl_CreateSaveObject,
|
|
|
|
IDirectXFileImpl_RegisterTemplates
|
|
|
|
};
|
|
|
|
|
2008-12-16 20:57:45 +01:00
|
|
|
static HRESULT IDirectXFileBinaryImpl_Create(IDirectXFileBinaryImpl** ppObj)
|
|
|
|
{
|
|
|
|
IDirectXFileBinaryImpl* object;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", ppObj);
|
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectXFileBinaryImpl));
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Out of memory\n");
|
|
|
|
return DXFILEERR_BADALLOC;
|
|
|
|
}
|
|
|
|
|
|
|
|
object->lpVtbl.lpVtbl = &IDirectXFileBinary_Vtbl;
|
|
|
|
object->ref = 1;
|
|
|
|
|
|
|
|
*ppObj = object;
|
|
|
|
|
|
|
|
return DXFILE_OK;
|
|
|
|
}
|
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileBinaryImpl_QueryInterface(IDirectXFileBinary* iface, REFIID riid, void** ppvObject)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileBinaryImpl *This = (IDirectXFileBinaryImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2004-06-04 21:36:56 +02:00
|
|
|
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
2004-06-04 21:36:56 +02:00
|
|
|
|| IsEqualGUID(riid, &IID_IDirectXFileObject)
|
2004-06-03 02:03:23 +02:00
|
|
|
|| IsEqualGUID(riid, &IID_IDirectXFileBinary))
|
|
|
|
{
|
|
|
|
IClassFactory_AddRef(iface);
|
|
|
|
*ppvObject = This;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-09-23 23:25:48 +02:00
|
|
|
/* Do not print an error for interfaces that can be queried to retrieve the type of the object */
|
|
|
|
if (!IsEqualGUID(riid, &IID_IDirectXFileData)
|
|
|
|
&& !IsEqualGUID(riid, &IID_IDirectXFileDataReference))
|
|
|
|
ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
|
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectXFileBinaryImpl_AddRef(IDirectXFileBinary* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileBinaryImpl *This = (IDirectXFileBinaryImpl *)iface;
|
2005-01-20 11:53:56 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
TRACE("(%p/%p): AddRef from %d\n", iface, This, ref - 1);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
return ref;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectXFileBinaryImpl_Release(IDirectXFileBinary* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileBinaryImpl *This = (IDirectXFileBinaryImpl *)iface;
|
2005-01-20 11:53:56 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
TRACE("(%p/%p): ReleaseRef to %d\n", iface, This, ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
if (!ref)
|
2004-06-03 02:03:23 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
return ref;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDirectXFileObject methods ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileBinaryImpl_GetName(IDirectXFileBinary* iface, LPSTR pstrNameBuf, LPDWORD pdwBufLen)
|
|
|
|
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileBinaryImpl *This = (IDirectXFileBinaryImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%p,%p) stub!\n", This, iface, pstrNameBuf, pdwBufLen);
|
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileBinaryImpl_GetId(IDirectXFileBinary* iface, LPGUID pGuid)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileBinaryImpl *This = (IDirectXFileBinaryImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%p) stub!\n", This, iface, pGuid);
|
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDirectXFileBinary methods ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileBinaryImpl_GetSize(IDirectXFileBinary* iface, DWORD* pcbSize)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileBinaryImpl *This = (IDirectXFileBinaryImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%p) stub!\n", This, iface, pcbSize);
|
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileBinaryImpl_GetMimeType(IDirectXFileBinary* iface, LPCSTR* pszMimeType)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileBinaryImpl *This = (IDirectXFileBinaryImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%p) stub!\n", This, iface, pszMimeType);
|
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileBinaryImpl_Read(IDirectXFileBinary* iface, LPVOID pvData, DWORD cbSize, LPDWORD pcbRead)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileBinaryImpl *This = (IDirectXFileBinaryImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
FIXME("(%p/%p)->(%p, %d, %p) stub!\n", This, iface, pvData, cbSize, pcbRead);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
static const IDirectXFileBinaryVtbl IDirectXFileBinary_Vtbl =
|
2004-06-03 02:03:23 +02:00
|
|
|
{
|
|
|
|
IDirectXFileBinaryImpl_QueryInterface,
|
|
|
|
IDirectXFileBinaryImpl_AddRef,
|
|
|
|
IDirectXFileBinaryImpl_Release,
|
|
|
|
IDirectXFileBinaryImpl_GetName,
|
|
|
|
IDirectXFileBinaryImpl_GetId,
|
|
|
|
IDirectXFileBinaryImpl_GetSize,
|
|
|
|
IDirectXFileBinaryImpl_GetMimeType,
|
|
|
|
IDirectXFileBinaryImpl_Read
|
|
|
|
};
|
|
|
|
|
2008-12-04 12:47:20 +01:00
|
|
|
static HRESULT IDirectXFileDataImpl_Create(IDirectXFileDataImpl** ppObj)
|
2004-06-04 21:36:56 +02:00
|
|
|
{
|
|
|
|
IDirectXFileDataImpl* object;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", ppObj);
|
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectXFileDataImpl));
|
2008-12-14 18:55:10 +01:00
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Out of memory\n");
|
|
|
|
return DXFILEERR_BADALLOC;
|
|
|
|
}
|
|
|
|
|
2004-06-04 21:36:56 +02:00
|
|
|
object->lpVtbl.lpVtbl = &IDirectXFileData_Vtbl;
|
|
|
|
object->ref = 1;
|
|
|
|
|
|
|
|
*ppObj = object;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileDataImpl_QueryInterface(IDirectXFileData* iface, REFIID riid, void** ppvObject)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2004-06-04 21:36:56 +02:00
|
|
|
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
2004-06-04 21:36:56 +02:00
|
|
|
|| IsEqualGUID(riid, &IID_IDirectXFileObject)
|
2004-06-03 02:03:23 +02:00
|
|
|
|| IsEqualGUID(riid, &IID_IDirectXFileData))
|
|
|
|
{
|
|
|
|
IClassFactory_AddRef(iface);
|
|
|
|
*ppvObject = This;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-10-10 13:44:43 +02:00
|
|
|
/* Do not print an error for interfaces that can be queried to retrieve the type of the object */
|
2008-09-23 23:25:48 +02:00
|
|
|
if (!IsEqualGUID(riid, &IID_IDirectXFileBinary)
|
|
|
|
&& !IsEqualGUID(riid, &IID_IDirectXFileDataReference))
|
|
|
|
ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
|
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectXFileDataImpl_AddRef(IDirectXFileData* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
|
2005-01-20 11:53:56 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
TRACE("(%p/%p): AddRef from %d\n", iface, This, ref - 1);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
return ref;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectXFileDataImpl_Release(IDirectXFileData* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
|
2005-01-20 11:53:56 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
TRACE("(%p/%p): ReleaseRef to %d\n", iface, This, ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
if (!ref)
|
2008-12-23 11:57:32 +01:00
|
|
|
{
|
|
|
|
if (!This->level)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->pdata);
|
|
|
|
HeapFree(GetProcessHeap(), 0, This->pstrings);
|
|
|
|
}
|
2004-06-03 02:03:23 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2008-12-23 11:57:32 +01:00
|
|
|
}
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
return ref;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDirectXFileObject methods ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileDataImpl_GetName(IDirectXFileData* iface, LPSTR pstrNameBuf, LPDWORD pdwBufLen)
|
|
|
|
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
TRACE("(%p/%p)->(%p,%p)\n", This, iface, pstrNameBuf, pdwBufLen);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
if (!pstrNameBuf)
|
|
|
|
return DXFILEERR_BADVALUE;
|
|
|
|
|
|
|
|
strcpy(pstrNameBuf, This->pobj->name);
|
|
|
|
|
|
|
|
return DXFILE_OK;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileDataImpl_GetId(IDirectXFileData* iface, LPGUID pGuid)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pGuid);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
if (!pGuid)
|
|
|
|
return DXFILEERR_BADVALUE;
|
|
|
|
|
|
|
|
memcpy(pGuid, &This->pobj->class_id, 16);
|
|
|
|
|
|
|
|
return DXFILE_OK;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDirectXFileData methods ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileDataImpl_GetData(IDirectXFileData* iface, LPCSTR szMember, DWORD* pcbSize, void** ppvData)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
TRACE("(%p/%p)->(%s,%p,%p)\n", This, iface, szMember, pcbSize, ppvData);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
if (!pcbSize || !ppvData)
|
|
|
|
return DXFILEERR_BADVALUE;
|
|
|
|
|
|
|
|
if (szMember)
|
|
|
|
{
|
|
|
|
FIXME("Specifying a member is not supported yet!\n");
|
|
|
|
return DXFILEERR_BADVALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*pcbSize = This->pobj->size;
|
|
|
|
*ppvData = This->pobj->pdata;
|
|
|
|
|
|
|
|
return DXFILE_OK;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileDataImpl_GetType(IDirectXFileData* iface, const GUID** pguid)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
|
2008-09-16 22:22:28 +02:00
|
|
|
static GUID guid;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pguid);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
if (!pguid)
|
|
|
|
return DXFILEERR_BADVALUE;
|
|
|
|
|
2008-09-18 21:47:40 +02:00
|
|
|
memcpy(&guid, &This->pobj->type, 16);
|
2008-09-16 22:22:28 +02:00
|
|
|
*pguid = &guid;
|
|
|
|
|
|
|
|
return DXFILE_OK;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileDataImpl_GetNextObject(IDirectXFileData* iface, LPDIRECTXFILEOBJECT* ppChildObj)
|
|
|
|
{
|
2008-09-22 20:27:09 +02:00
|
|
|
HRESULT hr;
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-22 20:27:09 +02:00
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, ppChildObj);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
if (This->cur_enum_object >= This->pobj->nb_childs)
|
|
|
|
return DXFILEERR_NOMOREOBJECTS;
|
|
|
|
|
2008-10-07 22:52:55 +02:00
|
|
|
if (This->from_ref && (This->level >= 1))
|
|
|
|
{
|
|
|
|
/* Only 2 levels can enumerated if the object is obtained from a reference */
|
|
|
|
return DXFILEERR_NOMOREOBJECTS;
|
|
|
|
}
|
|
|
|
|
2008-12-16 20:57:45 +01:00
|
|
|
if (This->pobj->childs[This->cur_enum_object]->binary)
|
|
|
|
{
|
|
|
|
IDirectXFileBinaryImpl *object;
|
|
|
|
|
|
|
|
hr = IDirectXFileBinaryImpl_Create(&object);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
|
|
|
|
*ppChildObj = (LPDIRECTXFILEOBJECT)object;
|
|
|
|
}
|
|
|
|
else if (This->pobj->childs[This->cur_enum_object]->ptarget)
|
2008-09-24 22:38:29 +02:00
|
|
|
{
|
|
|
|
IDirectXFileDataReferenceImpl *object;
|
2008-09-22 20:27:09 +02:00
|
|
|
|
2008-09-24 22:38:29 +02:00
|
|
|
hr = IDirectXFileDataReferenceImpl_Create(&object);
|
2008-12-14 18:55:10 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2008-09-24 22:38:29 +02:00
|
|
|
|
|
|
|
object->ptarget = This->pobj->childs[This->cur_enum_object++]->ptarget;
|
|
|
|
|
|
|
|
*ppChildObj = (LPDIRECTXFILEOBJECT)object;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
IDirectXFileDataImpl *object;
|
|
|
|
|
|
|
|
hr = IDirectXFileDataImpl_Create(&object);
|
2008-12-14 18:55:10 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2008-09-22 20:27:09 +02:00
|
|
|
|
2008-09-24 22:38:29 +02:00
|
|
|
object->pobj = This->pobj->childs[This->cur_enum_object++];
|
|
|
|
object->cur_enum_object = 0;
|
2008-10-07 22:52:55 +02:00
|
|
|
object->from_ref = This->from_ref;
|
|
|
|
object->level = This->level + 1;
|
2008-09-24 22:38:29 +02:00
|
|
|
|
|
|
|
*ppChildObj = (LPDIRECTXFILEOBJECT)object;
|
|
|
|
}
|
2008-09-22 20:27:09 +02:00
|
|
|
|
|
|
|
return DXFILE_OK;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileDataImpl_AddDataObject(IDirectXFileData* iface, LPDIRECTXFILEDATA pDataObj)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%p) stub!\n", This, iface, pDataObj);
|
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileDataImpl_AddDataReference(IDirectXFileData* iface, LPCSTR szRef, const GUID* pguidRef)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%s,%p) stub!\n", This, iface, szRef, pguidRef);
|
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileDataImpl_AddBinaryObject(IDirectXFileData* iface, LPCSTR szName, const GUID* pguid, LPCSTR szMimeType, LPVOID pvData, DWORD cbSize)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataImpl *This = (IDirectXFileDataImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
FIXME("(%p/%p)->(%s,%p,%s,%p,%d) stub!\n", This, iface, szName, pguid, szMimeType, pvData, cbSize);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
static const IDirectXFileDataVtbl IDirectXFileData_Vtbl =
|
2004-06-03 02:03:23 +02:00
|
|
|
{
|
|
|
|
IDirectXFileDataImpl_QueryInterface,
|
|
|
|
IDirectXFileDataImpl_AddRef,
|
|
|
|
IDirectXFileDataImpl_Release,
|
|
|
|
IDirectXFileDataImpl_GetName,
|
|
|
|
IDirectXFileDataImpl_GetId,
|
|
|
|
IDirectXFileDataImpl_GetData,
|
|
|
|
IDirectXFileDataImpl_GetType,
|
|
|
|
IDirectXFileDataImpl_GetNextObject,
|
|
|
|
IDirectXFileDataImpl_AddDataObject,
|
|
|
|
IDirectXFileDataImpl_AddDataReference,
|
|
|
|
IDirectXFileDataImpl_AddBinaryObject
|
|
|
|
};
|
|
|
|
|
2008-12-04 12:47:20 +01:00
|
|
|
static HRESULT IDirectXFileDataReferenceImpl_Create(IDirectXFileDataReferenceImpl** ppObj)
|
2004-06-04 21:36:56 +02:00
|
|
|
{
|
|
|
|
IDirectXFileDataReferenceImpl* object;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", ppObj);
|
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectXFileDataReferenceImpl));
|
2008-12-14 18:55:10 +01:00
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Out of memory\n");
|
|
|
|
return DXFILEERR_BADALLOC;
|
|
|
|
}
|
2004-06-04 21:36:56 +02:00
|
|
|
|
|
|
|
object->lpVtbl.lpVtbl = &IDirectXFileDataReference_Vtbl;
|
|
|
|
object->ref = 1;
|
|
|
|
|
|
|
|
*ppObj = object;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileDataReferenceImpl_QueryInterface(IDirectXFileDataReference* iface, REFIID riid, void** ppvObject)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataReferenceImpl *This = (IDirectXFileDataReferenceImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2004-06-04 21:36:56 +02:00
|
|
|
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
2004-06-04 21:36:56 +02:00
|
|
|
|| IsEqualGUID(riid, &IID_IDirectXFileObject)
|
2004-06-03 02:03:23 +02:00
|
|
|
|| IsEqualGUID(riid, &IID_IDirectXFileDataReference))
|
|
|
|
{
|
|
|
|
IClassFactory_AddRef(iface);
|
|
|
|
*ppvObject = This;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2008-10-10 13:44:43 +02:00
|
|
|
/* Do not print an error for interfaces that can be queried to retrieve the type of the object */
|
2008-09-23 23:25:48 +02:00
|
|
|
if (!IsEqualGUID(riid, &IID_IDirectXFileData)
|
|
|
|
&& !IsEqualGUID(riid, &IID_IDirectXFileBinary))
|
|
|
|
ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
|
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectXFileDataReferenceImpl_AddRef(IDirectXFileDataReference* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataReferenceImpl *This = (IDirectXFileDataReferenceImpl *)iface;
|
2005-01-20 11:53:56 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
TRACE("(%p/%p): AddRef from %d\n", iface, This, ref - 1);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
return ref;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectXFileDataReferenceImpl_Release(IDirectXFileDataReference* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataReferenceImpl *This = (IDirectXFileDataReferenceImpl *)iface;
|
2005-01-20 11:53:56 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
TRACE("(%p/%p): ReleaseRef to %d\n", iface, This, ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
if (!ref)
|
2004-06-03 02:03:23 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
return ref;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDirectXFileObject methods ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileDataReferenceImpl_GetName(IDirectXFileDataReference* iface, LPSTR pstrNameBuf, LPDWORD pdwBufLen)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataReferenceImpl *This = (IDirectXFileDataReferenceImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-24 22:38:29 +02:00
|
|
|
TRACE("(%p/%p)->(%p,%p)\n", This, iface, pstrNameBuf, pdwBufLen);
|
|
|
|
|
|
|
|
if (!pstrNameBuf)
|
|
|
|
return DXFILEERR_BADVALUE;
|
|
|
|
|
|
|
|
strcpy(pstrNameBuf, This->ptarget->name);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileDataReferenceImpl_GetId(IDirectXFileDataReference* iface, LPGUID pGuid)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataReferenceImpl *This = (IDirectXFileDataReferenceImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-24 22:38:29 +02:00
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, pGuid);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-24 22:38:29 +02:00
|
|
|
if (!pGuid)
|
|
|
|
return DXFILEERR_BADVALUE;
|
|
|
|
|
|
|
|
memcpy(pGuid, &This->ptarget->class_id, 16);
|
|
|
|
|
|
|
|
return DXFILE_OK;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*** IDirectXFileDataReference ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileDataReferenceImpl_Resolve(IDirectXFileDataReference* iface, LPDIRECTXFILEDATA* ppDataObj)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileDataReferenceImpl *This = (IDirectXFileDataReferenceImpl *)iface;
|
2008-09-24 22:38:29 +02:00
|
|
|
IDirectXFileDataImpl *object;
|
|
|
|
HRESULT hr;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-24 22:38:29 +02:00
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, ppDataObj);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-09-24 22:38:29 +02:00
|
|
|
if (!ppDataObj)
|
|
|
|
return DXFILEERR_BADVALUE;
|
|
|
|
|
|
|
|
hr = IDirectXFileDataImpl_Create(&object);
|
2008-12-14 18:55:10 +01:00
|
|
|
if (FAILED(hr))
|
|
|
|
return hr;
|
2008-09-24 22:38:29 +02:00
|
|
|
|
|
|
|
object->pobj = This->ptarget;
|
|
|
|
object->cur_enum_object = 0;
|
2008-10-07 22:52:55 +02:00
|
|
|
object->level = 0;
|
|
|
|
object->from_ref = TRUE;
|
2008-09-24 22:38:29 +02:00
|
|
|
|
|
|
|
*ppDataObj = (LPDIRECTXFILEDATA)object;
|
|
|
|
|
|
|
|
return DXFILE_OK;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
static const IDirectXFileDataReferenceVtbl IDirectXFileDataReference_Vtbl =
|
2004-06-03 02:03:23 +02:00
|
|
|
{
|
|
|
|
IDirectXFileDataReferenceImpl_QueryInterface,
|
|
|
|
IDirectXFileDataReferenceImpl_AddRef,
|
|
|
|
IDirectXFileDataReferenceImpl_Release,
|
|
|
|
IDirectXFileDataReferenceImpl_GetName,
|
|
|
|
IDirectXFileDataReferenceImpl_GetId,
|
|
|
|
IDirectXFileDataReferenceImpl_Resolve
|
|
|
|
};
|
|
|
|
|
2008-12-04 12:47:20 +01:00
|
|
|
static HRESULT IDirectXFileEnumObjectImpl_Create(IDirectXFileEnumObjectImpl** ppObj)
|
2004-06-04 21:36:56 +02:00
|
|
|
{
|
|
|
|
IDirectXFileEnumObjectImpl* object;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", ppObj);
|
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectXFileEnumObjectImpl));
|
2008-12-14 18:55:10 +01:00
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Out of memory\n");
|
|
|
|
return DXFILEERR_BADALLOC;
|
|
|
|
}
|
2004-06-04 21:36:56 +02:00
|
|
|
|
|
|
|
object->lpVtbl.lpVtbl = &IDirectXFileEnumObject_Vtbl;
|
|
|
|
object->ref = 1;
|
|
|
|
|
|
|
|
*ppObj = object;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileEnumObjectImpl_QueryInterface(IDirectXFileEnumObject* iface, REFIID riid, void** ppvObject)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileEnumObjectImpl *This = (IDirectXFileEnumObjectImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2004-06-04 21:36:56 +02:00
|
|
|
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDirectXFileEnumObject))
|
|
|
|
{
|
|
|
|
IClassFactory_AddRef(iface);
|
|
|
|
*ppvObject = This;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectXFileEnumObjectImpl_AddRef(IDirectXFileEnumObject* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileEnumObjectImpl *This = (IDirectXFileEnumObjectImpl *)iface;
|
2005-01-20 11:53:56 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
TRACE("(%p/%p): AddRef from %d\n", iface, This, ref - 1);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
return ref;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectXFileEnumObjectImpl_Release(IDirectXFileEnumObject* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileEnumObjectImpl *This = (IDirectXFileEnumObjectImpl *)iface;
|
2005-01-20 11:53:56 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
TRACE("(%p/%p): ReleaseRef to %d\n", iface, This, ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
if (!ref)
|
2008-11-09 11:09:56 +01:00
|
|
|
{
|
2008-12-23 12:47:48 +01:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < This->nb_xobjects; i++)
|
2008-12-24 11:03:33 +01:00
|
|
|
{
|
2008-12-23 12:47:48 +01:00
|
|
|
IDirectXFileData_Release(This->pRefObjects[i]);
|
2008-12-24 11:03:33 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->xobjects[i]);
|
|
|
|
}
|
2008-12-23 11:57:32 +01:00
|
|
|
if (This->source == DXFILELOAD_FROMFILE)
|
2008-12-24 11:04:02 +01:00
|
|
|
{
|
2008-12-23 11:57:32 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->buf.buffer);
|
|
|
|
CloseHandle(This->hFile);
|
2008-12-24 11:04:02 +01:00
|
|
|
}
|
2004-06-03 02:03:23 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
2008-11-09 11:09:56 +01:00
|
|
|
}
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
return ref;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
static BOOL parse_object_members_list(parse_buffer * buf)
|
|
|
|
{
|
|
|
|
DWORD token;
|
|
|
|
int i;
|
|
|
|
xtemplate* pt = buf->pxt[buf->level];
|
|
|
|
DWORD last_dword = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < pt->nb_members; i++)
|
|
|
|
{
|
2008-11-23 21:31:13 +01:00
|
|
|
int k;
|
|
|
|
int nb_elems = 1;
|
2008-09-16 22:22:28 +02:00
|
|
|
|
2008-12-27 12:01:00 +01:00
|
|
|
buf->pxo->members[i].name = pt->members[i].name;
|
2008-11-23 21:31:13 +01:00
|
|
|
buf->pxo->members[i].start = buf->cur_pdata;
|
|
|
|
|
|
|
|
for (k = 0; k < pt->members[i].nb_dims; k++)
|
2008-09-16 22:22:28 +02:00
|
|
|
{
|
2008-11-23 21:31:13 +01:00
|
|
|
if (pt->members[i].dim_fixed[k])
|
|
|
|
nb_elems *= pt->members[i].dim_value[k];
|
2008-09-16 22:22:28 +02:00
|
|
|
else
|
2008-11-23 21:31:13 +01:00
|
|
|
nb_elems *= *(DWORD*)buf->pxo->members[pt->members[i].dim_value[k]].start;
|
2008-09-16 22:22:28 +02:00
|
|
|
}
|
2008-11-23 21:31:13 +01:00
|
|
|
|
|
|
|
TRACE("Elements to consider: %d\n", nb_elems);
|
2008-09-16 22:22:28 +02:00
|
|
|
|
|
|
|
for (k = 0; k < nb_elems; k++)
|
|
|
|
{
|
2008-11-11 12:41:11 +01:00
|
|
|
if (buf->txt && k)
|
2008-09-16 22:22:28 +02:00
|
|
|
{
|
2008-10-07 22:52:12 +02:00
|
|
|
token = check_TOKEN(buf);
|
|
|
|
if (token == TOKEN_COMMA)
|
|
|
|
{
|
|
|
|
get_TOKEN(buf);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Allow comma omission */
|
2008-11-30 12:17:20 +01:00
|
|
|
if (!((token == TOKEN_FLOAT) || (token == TOKEN_INTEGER)))
|
2008-10-07 22:52:12 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-09-16 22:22:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pt->members[i].type == TOKEN_NAME)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
|
2008-11-23 21:30:37 +01:00
|
|
|
TRACE("Found sub-object %s\n", buf->pdxf->xtemplates[pt->members[i].idx_template].name);
|
2008-09-16 22:22:28 +02:00
|
|
|
buf->level++;
|
|
|
|
/* To do template lookup */
|
|
|
|
for (j = 0; j < buf->pdxf->nb_xtemplates; j++)
|
|
|
|
{
|
2008-12-28 11:27:29 +01:00
|
|
|
if (!strcasecmp(buf->pdxf->xtemplates[pt->members[i].idx_template].name, buf->pdxf->xtemplates[j].name))
|
2008-09-16 22:22:28 +02:00
|
|
|
{
|
|
|
|
buf->pxt[buf->level] = &buf->pdxf->xtemplates[j];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (j == buf->pdxf->nb_xtemplates)
|
|
|
|
{
|
2008-12-28 11:27:29 +01:00
|
|
|
ERR("Unknown template %s\n", (char*)buf->value);
|
2008-09-16 22:22:28 +02:00
|
|
|
buf->level--;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
TRACE("Enter %s\n", buf->pdxf->xtemplates[pt->members[i].idx_template].name);
|
|
|
|
if (!parse_object_parts(buf, FALSE))
|
|
|
|
{
|
|
|
|
buf->level--;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
buf->level--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
token = check_TOKEN(buf);
|
|
|
|
if (token == TOKEN_INTEGER)
|
|
|
|
{
|
2008-09-20 12:34:00 +02:00
|
|
|
get_TOKEN(buf);
|
2008-09-16 22:22:28 +02:00
|
|
|
last_dword = *(DWORD*)buf->value;
|
|
|
|
TRACE("%s = %d\n", pt->members[i].name, *(DWORD*)buf->value);
|
|
|
|
/* Assume larger size */
|
2008-11-16 19:44:51 +01:00
|
|
|
if ((buf->cur_pdata - buf->pdata + 4) > MAX_DATA_SIZE)
|
2008-09-16 22:22:28 +02:00
|
|
|
{
|
2008-11-16 19:44:51 +01:00
|
|
|
FIXME("Buffer too small\n");
|
2008-09-16 22:22:28 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (pt->members[i].type == TOKEN_WORD)
|
|
|
|
{
|
|
|
|
*(((WORD*)(buf->cur_pdata))) = (WORD)(*(DWORD*)buf->value);
|
|
|
|
buf->cur_pdata += 2;
|
|
|
|
}
|
|
|
|
else if (pt->members[i].type == TOKEN_DWORD)
|
|
|
|
{
|
|
|
|
*(((DWORD*)(buf->cur_pdata))) = (DWORD)(*(DWORD*)buf->value);
|
|
|
|
buf->cur_pdata += 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Token %d not supported\n", pt->members[i].type);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (token == TOKEN_FLOAT)
|
|
|
|
{
|
2008-09-20 12:34:00 +02:00
|
|
|
get_TOKEN(buf);
|
2008-09-16 22:22:28 +02:00
|
|
|
TRACE("%s = %f\n", pt->members[i].name, *(float*)buf->value);
|
|
|
|
/* Assume larger size */
|
2008-11-16 19:44:51 +01:00
|
|
|
if ((buf->cur_pdata - buf->pdata + 4) > MAX_DATA_SIZE)
|
2008-09-16 22:22:28 +02:00
|
|
|
{
|
2008-11-16 19:44:51 +01:00
|
|
|
FIXME("Buffer too small\n");
|
2008-09-16 22:22:28 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (pt->members[i].type == TOKEN_FLOAT)
|
|
|
|
{
|
|
|
|
*(((float*)(buf->cur_pdata))) = (float)(*(float*)buf->value);
|
|
|
|
buf->cur_pdata += 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Token %d not supported\n", pt->members[i].type);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2008-10-16 22:23:46 +02:00
|
|
|
else if (token == TOKEN_LPSTR)
|
|
|
|
{
|
|
|
|
get_TOKEN(buf);
|
|
|
|
TRACE("%s = %s\n", pt->members[i].name, (char*)buf->value);
|
|
|
|
/* Assume larger size */
|
2008-11-16 19:44:51 +01:00
|
|
|
if ((buf->cur_pdata - buf->pdata + 4) > MAX_DATA_SIZE)
|
2008-10-16 22:23:46 +02:00
|
|
|
{
|
2008-11-16 19:44:51 +01:00
|
|
|
FIXME("Buffer too small\n");
|
2008-10-16 22:23:46 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (pt->members[i].type == TOKEN_LPSTR)
|
|
|
|
{
|
2008-11-09 11:11:40 +01:00
|
|
|
int len = strlen((char*)buf->value) + 1;
|
|
|
|
if ((buf->cur_pstrings - buf->pstrings + len) > MAX_STRINGS_BUFFER)
|
|
|
|
{
|
2008-11-16 19:44:51 +01:00
|
|
|
FIXME("Buffer too small %p %p %d\n", buf->cur_pstrings, buf->pstrings, len);
|
2008-11-09 11:11:40 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
strcpy((char*)buf->cur_pstrings, (char*)buf->value);
|
|
|
|
*(((LPCSTR*)(buf->cur_pdata))) = (char*)buf->cur_pstrings;
|
|
|
|
buf->cur_pstrings += len;
|
2008-10-16 22:23:46 +02:00
|
|
|
buf->cur_pdata += 4;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FIXME("Token %d not supported\n", pt->members[i].type);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
2008-09-16 22:22:28 +02:00
|
|
|
else
|
2008-10-16 22:23:46 +02:00
|
|
|
{
|
|
|
|
FIXME("Unexpected token %d\n", token);
|
2008-09-16 22:22:28 +02:00
|
|
|
return FALSE;
|
2008-10-16 22:23:46 +02:00
|
|
|
}
|
2008-09-16 22:22:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-30 12:17:20 +01:00
|
|
|
if (buf->txt && (check_TOKEN(buf) != TOKEN_CBRACE))
|
2008-09-16 22:22:28 +02:00
|
|
|
{
|
2008-11-11 12:41:11 +01:00
|
|
|
token = get_TOKEN(buf);
|
2008-11-30 12:17:20 +01:00
|
|
|
if ((token != TOKEN_SEMICOLON) && (token != TOKEN_COMMA))
|
2008-11-11 12:41:11 +01:00
|
|
|
{
|
|
|
|
/* Allow comma instead of semicolon in some specific cases */
|
|
|
|
if (!((token == TOKEN_COMMA) && ((i+1) < pt->nb_members) && (pt->members[i].type == pt->members[i+1].type)
|
|
|
|
&& (!pt->members[i].nb_dims) && (!pt->members[i+1].nb_dims)))
|
|
|
|
return FALSE;
|
|
|
|
}
|
2008-09-16 22:22:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL parse_object_parts(parse_buffer * buf, BOOL allow_optional)
|
|
|
|
{
|
|
|
|
if (!parse_object_members_list(buf))
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (allow_optional)
|
|
|
|
{
|
2008-09-22 20:27:09 +02:00
|
|
|
buf->pxo->size = buf->cur_pdata - buf->pxo->pdata;
|
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
/* Skip trailing semicolon */
|
|
|
|
while (check_TOKEN(buf) == TOKEN_SEMICOLON)
|
2008-09-20 12:34:00 +02:00
|
|
|
get_TOKEN(buf);
|
2008-09-16 22:22:28 +02:00
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
if (check_TOKEN(buf) == TOKEN_OBRACE)
|
|
|
|
{
|
2008-10-07 22:54:09 +02:00
|
|
|
int i, j;
|
2008-09-20 12:34:00 +02:00
|
|
|
get_TOKEN(buf);
|
|
|
|
if (get_TOKEN(buf) != TOKEN_NAME)
|
2008-09-16 22:22:28 +02:00
|
|
|
return FALSE;
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_CBRACE)
|
2008-09-16 22:22:28 +02:00
|
|
|
return FALSE;
|
2008-09-24 22:38:29 +02:00
|
|
|
TRACE("Found optional reference %s\n", (char*)buf->value);
|
|
|
|
for (i = 0; i < buf->nb_pxo_globals; i++)
|
|
|
|
{
|
2008-12-23 11:56:27 +01:00
|
|
|
for (j = 0; j < (buf->pxo_globals[i])[0].nb_subobjects; j++)
|
2008-10-07 22:54:09 +02:00
|
|
|
{
|
2008-12-23 11:56:27 +01:00
|
|
|
if (!strcmp((buf->pxo_globals[i])[j].name, (char*)buf->value))
|
2008-10-07 22:54:09 +02:00
|
|
|
goto _exit;
|
|
|
|
}
|
2008-09-24 22:38:29 +02:00
|
|
|
}
|
2008-10-07 22:54:09 +02:00
|
|
|
_exit:
|
2008-09-24 22:38:29 +02:00
|
|
|
if (i == buf->nb_pxo_globals)
|
|
|
|
{
|
|
|
|
ERR("Reference to unknown object %s\n", (char*)buf->value);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
buf->pxo->childs[buf->pxo->nb_childs] = &buf->pxo_tab[buf->cur_subobject++];
|
2008-12-23 11:56:27 +01:00
|
|
|
buf->pxo->childs[buf->pxo->nb_childs]->ptarget = &(buf->pxo_globals[i])[j];
|
2008-09-24 22:38:29 +02:00
|
|
|
buf->pxo->nb_childs++;
|
2008-09-16 22:22:28 +02:00
|
|
|
}
|
|
|
|
else if (check_TOKEN(buf) == TOKEN_NAME)
|
|
|
|
{
|
2008-09-22 20:27:09 +02:00
|
|
|
xobject* pxo = buf->pxo;
|
|
|
|
buf->pxo = buf->pxo->childs[buf->pxo->nb_childs] = &buf->pxo_tab[buf->cur_subobject++];
|
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
TRACE("Enter optional %s\n", (char*)buf->value);
|
|
|
|
buf->level++;
|
|
|
|
if (!parse_object(buf))
|
|
|
|
{
|
|
|
|
buf->level--;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
buf->level--;
|
2008-09-22 20:27:09 +02:00
|
|
|
buf->pxo = pxo;
|
|
|
|
buf->pxo->nb_childs++;
|
2008-09-16 22:22:28 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-11-09 11:10:56 +01:00
|
|
|
if (buf->pxo->nb_childs > MAX_CHILDS)
|
|
|
|
{
|
|
|
|
FIXME("Too many childs %d\n", buf->pxo->nb_childs);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL parse_object(parse_buffer * buf)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
2008-09-22 20:27:09 +02:00
|
|
|
buf->pxo->pdata = buf->cur_pdata;
|
2008-09-24 22:38:29 +02:00
|
|
|
buf->pxo->ptarget = NULL;
|
2008-09-22 20:27:09 +02:00
|
|
|
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_NAME)
|
2008-09-16 22:22:28 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* To do template lookup */
|
|
|
|
for (i = 0; i < buf->pdxf->nb_xtemplates; i++)
|
|
|
|
{
|
2008-12-28 11:27:29 +01:00
|
|
|
if (!strcasecmp((char*)buf->value, buf->pdxf->xtemplates[i].name))
|
2008-09-16 22:22:28 +02:00
|
|
|
{
|
|
|
|
buf->pxt[buf->level] = &buf->pdxf->xtemplates[i];
|
2008-09-18 21:47:40 +02:00
|
|
|
memcpy(&buf->pxo->type, &buf->pdxf->xtemplates[i].class_id, 16);
|
2008-09-16 22:22:28 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == buf->pdxf->nb_xtemplates)
|
|
|
|
{
|
2008-12-28 11:27:29 +01:00
|
|
|
ERR("Unknown template %s\n", (char*)buf->value);
|
2008-09-16 22:22:28 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2008-09-18 21:47:40 +02:00
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
if (check_TOKEN(buf) == TOKEN_NAME)
|
|
|
|
{
|
2008-09-20 12:34:00 +02:00
|
|
|
get_TOKEN(buf);
|
2008-09-16 22:22:28 +02:00
|
|
|
strcpy(buf->pxo->name, (char*)buf->value);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
buf->pxo->name[0] = 0;
|
|
|
|
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_OBRACE)
|
2008-09-16 22:22:28 +02:00
|
|
|
return FALSE;
|
|
|
|
if (check_TOKEN(buf) == TOKEN_GUID)
|
|
|
|
{
|
2008-09-20 12:34:00 +02:00
|
|
|
get_TOKEN(buf);
|
2008-09-16 22:22:28 +02:00
|
|
|
memcpy(&buf->pxo->class_id, buf->value, 16);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
memset(&buf->pxo->class_id, 0, 16);
|
|
|
|
|
|
|
|
if (!parse_object_parts(buf, TRUE))
|
|
|
|
return FALSE;
|
2008-09-20 12:34:00 +02:00
|
|
|
if (get_TOKEN(buf) != TOKEN_CBRACE)
|
2008-09-16 22:22:28 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if (buf->txt)
|
|
|
|
{
|
|
|
|
/* Go to the next object */
|
2008-11-30 12:18:46 +01:00
|
|
|
go_to_next_definition(buf);
|
2008-09-16 22:22:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
/*** IDirectXFileEnumObject methods ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetNextDataObject(IDirectXFileEnumObject* iface, LPDIRECTXFILEDATA* ppDataObj)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileEnumObjectImpl *This = (IDirectXFileEnumObjectImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
IDirectXFileDataImpl* object;
|
2008-08-19 00:29:09 +02:00
|
|
|
HRESULT hr;
|
2008-12-23 11:55:36 +01:00
|
|
|
LPBYTE pdata = NULL;
|
|
|
|
LPBYTE pstrings = NULL;
|
2008-10-16 22:22:52 +02:00
|
|
|
|
2008-09-22 20:27:09 +02:00
|
|
|
TRACE("(%p/%p)->(%p)\n", This, iface, ppDataObj);
|
2008-09-16 22:22:28 +02:00
|
|
|
|
2008-11-11 12:39:46 +01:00
|
|
|
if (This->nb_xobjects >= MAX_OBJECTS)
|
|
|
|
{
|
|
|
|
ERR("Too many objects\n");
|
|
|
|
return DXFILEERR_NOMOREOBJECTS;
|
|
|
|
}
|
|
|
|
|
2008-09-16 22:22:28 +02:00
|
|
|
if (!This->buf.rem_bytes)
|
|
|
|
return DXFILEERR_NOMOREOBJECTS;
|
|
|
|
|
2008-08-19 00:29:09 +02:00
|
|
|
hr = IDirectXFileDataImpl_Create(&object);
|
2008-10-08 01:35:37 +02:00
|
|
|
if (FAILED(hr))
|
2008-08-19 00:29:09 +02:00
|
|
|
return hr;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2008-12-23 11:56:27 +01:00
|
|
|
This->buf.pxo_globals = This->xobjects;
|
2008-09-24 22:38:29 +02:00
|
|
|
This->buf.nb_pxo_globals = This->nb_xobjects;
|
2008-12-23 11:56:27 +01:00
|
|
|
This->buf.cur_subobject = 1;
|
2008-11-09 11:11:40 +01:00
|
|
|
This->buf.level = 0;
|
2008-09-16 22:22:28 +02:00
|
|
|
|
2008-12-23 11:56:27 +01:00
|
|
|
This->buf.pxo_tab = HeapAlloc(GetProcessHeap(), 0, sizeof(xobject)*MAX_SUBOBJECTS);
|
|
|
|
if (!This->buf.pxo_tab)
|
|
|
|
{
|
|
|
|
ERR("Out of memory\n");
|
|
|
|
hr = DXFILEERR_BADALLOC;
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
This->buf.pxo = This->xobjects[This->nb_xobjects] = This->buf.pxo_tab;
|
|
|
|
|
2008-09-22 20:27:09 +02:00
|
|
|
pdata = HeapAlloc(GetProcessHeap(), 0, MAX_DATA_SIZE);
|
|
|
|
if (!pdata)
|
2008-09-16 22:22:28 +02:00
|
|
|
{
|
2008-12-14 18:55:10 +01:00
|
|
|
ERR("Out of memory\n");
|
2008-12-23 11:55:36 +01:00
|
|
|
hr = DXFILEERR_BADALLOC;
|
|
|
|
goto error;
|
2008-09-16 22:22:28 +02:00
|
|
|
}
|
2008-12-23 11:57:32 +01:00
|
|
|
This->buf.cur_pdata = This->buf.pdata = object->pdata = pdata;
|
2008-11-09 11:11:40 +01:00
|
|
|
|
|
|
|
pstrings = HeapAlloc(GetProcessHeap(), 0, MAX_STRINGS_BUFFER);
|
|
|
|
if (!pstrings)
|
|
|
|
{
|
2008-12-14 18:55:10 +01:00
|
|
|
ERR("Out of memory\n");
|
2008-12-23 11:55:36 +01:00
|
|
|
hr = DXFILEERR_BADALLOC;
|
|
|
|
goto error;
|
2008-11-09 11:11:40 +01:00
|
|
|
}
|
2008-12-23 11:57:32 +01:00
|
|
|
This->buf.cur_pstrings = This->buf.pstrings = object->pstrings = pstrings;
|
2008-09-16 22:22:28 +02:00
|
|
|
|
|
|
|
if (!parse_object(&This->buf))
|
|
|
|
{
|
|
|
|
TRACE("Object is not correct\n");
|
2008-12-23 11:55:36 +01:00
|
|
|
hr = DXFILEERR_PARSEERROR;
|
|
|
|
goto error;
|
2008-09-16 22:22:28 +02:00
|
|
|
}
|
|
|
|
|
2008-10-07 22:53:38 +02:00
|
|
|
This->buf.pxo->nb_subobjects = This->buf.cur_subobject;
|
2008-11-09 11:10:56 +01:00
|
|
|
if (This->buf.cur_subobject > MAX_SUBOBJECTS)
|
|
|
|
{
|
|
|
|
FIXME("Too many suobjects %d\n", This->buf.cur_subobject);
|
2008-12-23 11:55:36 +01:00
|
|
|
hr = DXFILEERR_BADALLOC;
|
|
|
|
goto error;
|
2008-11-09 11:10:56 +01:00
|
|
|
}
|
2008-10-07 22:53:38 +02:00
|
|
|
|
2008-11-09 11:11:40 +01:00
|
|
|
object->pstrings = pstrings;
|
2008-09-16 22:22:28 +02:00
|
|
|
object->pobj = This->buf.pxo;
|
2008-09-22 20:27:09 +02:00
|
|
|
object->cur_enum_object = 0;
|
2008-10-07 22:52:55 +02:00
|
|
|
object->level = 0;
|
|
|
|
object->from_ref = FALSE;
|
2008-09-16 22:22:28 +02:00
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
*ppDataObj = (LPDIRECTXFILEDATA)object;
|
|
|
|
|
2008-12-23 12:47:48 +01:00
|
|
|
/* Get a reference to created object */
|
|
|
|
This->pRefObjects[This->nb_xobjects] = (LPDIRECTXFILEDATA)object;
|
|
|
|
IDirectXFileData_AddRef(This->pRefObjects[This->nb_xobjects]);
|
|
|
|
|
2008-09-24 22:38:29 +02:00
|
|
|
This->nb_xobjects++;
|
|
|
|
|
2008-08-19 00:29:09 +02:00
|
|
|
return DXFILE_OK;
|
2008-12-23 11:55:36 +01:00
|
|
|
|
|
|
|
error:
|
|
|
|
|
2008-12-23 11:56:27 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->buf.pxo_tab);
|
2008-12-23 11:55:36 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, pdata);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pstrings);
|
|
|
|
|
|
|
|
return hr;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetDataObjectById(IDirectXFileEnumObject* iface, REFGUID rguid, LPDIRECTXFILEDATA* ppDataObj)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileEnumObjectImpl *This = (IDirectXFileEnumObjectImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%p,%p) stub!\n", This, iface, rguid, ppDataObj);
|
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileEnumObjectImpl_GetDataObjectByName(IDirectXFileEnumObject* iface, LPCSTR szName, LPDIRECTXFILEDATA* ppDataObj)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileEnumObjectImpl *This = (IDirectXFileEnumObjectImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%s,%p) stub!\n", This, iface, szName, ppDataObj);
|
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
static const IDirectXFileEnumObjectVtbl IDirectXFileEnumObject_Vtbl =
|
2004-06-03 02:03:23 +02:00
|
|
|
{
|
|
|
|
IDirectXFileEnumObjectImpl_QueryInterface,
|
|
|
|
IDirectXFileEnumObjectImpl_AddRef,
|
|
|
|
IDirectXFileEnumObjectImpl_Release,
|
|
|
|
IDirectXFileEnumObjectImpl_GetNextDataObject,
|
|
|
|
IDirectXFileEnumObjectImpl_GetDataObjectById,
|
|
|
|
IDirectXFileEnumObjectImpl_GetDataObjectByName
|
|
|
|
};
|
|
|
|
|
2008-12-16 20:55:22 +01:00
|
|
|
static HRESULT IDirectXFileSaveObjectImpl_Create(IDirectXFileSaveObjectImpl** ppObj)
|
|
|
|
{
|
|
|
|
IDirectXFileSaveObjectImpl* object;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", ppObj);
|
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IDirectXFileSaveObjectImpl));
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Out of memory\n");
|
|
|
|
return DXFILEERR_BADALLOC;
|
|
|
|
}
|
|
|
|
|
|
|
|
object->lpVtbl.lpVtbl = &IDirectXFileSaveObject_Vtbl;
|
|
|
|
object->ref = 1;
|
|
|
|
|
|
|
|
*ppObj = object;
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2004-06-03 02:03:23 +02:00
|
|
|
/*** IUnknown methods ***/
|
|
|
|
static HRESULT WINAPI IDirectXFileSaveObjectImpl_QueryInterface(IDirectXFileSaveObject* iface, REFIID riid, void** ppvObject)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileSaveObjectImpl *This = (IDirectXFileSaveObjectImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2004-06-04 21:36:56 +02:00
|
|
|
TRACE("(%p/%p)->(%s,%p)\n", iface, This, debugstr_guid(riid), ppvObject);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
if (IsEqualGUID(riid, &IID_IUnknown)
|
|
|
|
|| IsEqualGUID(riid, &IID_IDirectXFileSaveObject))
|
|
|
|
{
|
|
|
|
IClassFactory_AddRef(iface);
|
|
|
|
*ppvObject = This;
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ERR("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectXFileSaveObjectImpl_AddRef(IDirectXFileSaveObject* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileSaveObjectImpl *This = (IDirectXFileSaveObjectImpl *)iface;
|
2005-01-20 11:53:56 +01:00
|
|
|
ULONG ref = InterlockedIncrement(&This->ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
TRACE("(%p/%p): AddRef from %d\n", iface, This, ref - 1);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
return ref;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IDirectXFileSaveObjectImpl_Release(IDirectXFileSaveObject* iface)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileSaveObjectImpl *This = (IDirectXFileSaveObjectImpl *)iface;
|
2005-01-20 11:53:56 +01:00
|
|
|
ULONG ref = InterlockedDecrement(&This->ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
TRACE("(%p/%p): ReleaseRef to %d\n", iface, This, ref);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
if (!ref)
|
2004-06-03 02:03:23 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
|
|
|
|
2005-01-20 11:53:56 +01:00
|
|
|
return ref;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileSaveObjectImpl_SaveTemplates(IDirectXFileSaveObject* iface, DWORD cTemplates, const GUID** ppguidTemplates)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileSaveObjectImpl *This = (IDirectXFileSaveObjectImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
FIXME("(%p/%p)->(%d,%p) stub!\n", This, iface, cTemplates, ppguidTemplates);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileSaveObjectImpl_CreateDataObject(IDirectXFileSaveObject* iface, REFGUID rguidTemplate, LPCSTR szName, const GUID* pguid, DWORD cbSize, LPVOID pvData, LPDIRECTXFILEDATA* ppDataObj)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileSaveObjectImpl *This = (IDirectXFileSaveObjectImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2006-10-08 18:59:55 +02:00
|
|
|
FIXME("(%p/%p)->(%p,%s,%p,%d,%p,%p) stub!\n", This, iface, rguidTemplate, szName, pguid, cbSize, pvData, ppDataObj);
|
2004-06-03 02:03:23 +02:00
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI IDirectXFileSaveObjectImpl_SaveData(IDirectXFileSaveObject* iface, LPDIRECTXFILEDATA ppDataObj)
|
|
|
|
{
|
2004-09-06 22:34:29 +02:00
|
|
|
IDirectXFileSaveObjectImpl *This = (IDirectXFileSaveObjectImpl *)iface;
|
2004-06-03 02:03:23 +02:00
|
|
|
|
|
|
|
FIXME("(%p/%p)->(%p) stub!\n", This, iface, ppDataObj);
|
|
|
|
|
2007-11-08 05:55:01 +01:00
|
|
|
return DXFILEERR_BADVALUE;
|
2004-06-03 02:03:23 +02:00
|
|
|
}
|
|
|
|
|
2005-05-27 22:17:35 +02:00
|
|
|
static const IDirectXFileSaveObjectVtbl IDirectXFileSaveObject_Vtbl =
|
2004-06-03 02:03:23 +02:00
|
|
|
{
|
|
|
|
IDirectXFileSaveObjectImpl_QueryInterface,
|
|
|
|
IDirectXFileSaveObjectImpl_AddRef,
|
|
|
|
IDirectXFileSaveObjectImpl_Release,
|
|
|
|
IDirectXFileSaveObjectImpl_SaveTemplates,
|
|
|
|
IDirectXFileSaveObjectImpl_CreateDataObject,
|
|
|
|
IDirectXFileSaveObjectImpl_SaveData
|
|
|
|
};
|