ReactOS 0.4.17-dev-940-g8bd6e85
d3dxof_private.h File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "dxfile.h"
#include "wine/debug.h"
Include dependency graph for d3dxof_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  member
 
struct  xtemplate
 
struct  xobject_member
 
struct  _xobject
 
struct  IDirectXFileImpl
 
struct  IDirectXFileBinaryImpl
 
struct  IDirectXFileDataImpl
 
struct  IDirectXFileDataReferenceImpl
 
struct  IDirectXFileObjectImpl
 
struct  parse_buffer
 
struct  IDirectXFileEnumObjectImpl
 
struct  IDirectXFileSaveObjectImpl
 

Macros

#define COBJMACROS
 
#define MAX_NAME_LEN   40
 
#define MAX_ARRAY_DIM   4
 
#define MAX_MEMBERS   50
 
#define MAX_CHILDREN   200
 
#define MAX_TEMPLATES   200
 
#define MAX_OBJECTS   500
 
#define MAX_SUBOBJECTS   2000
 
#define MAX_STRINGS_BUFFER   10000
 

Typedefs

typedef struct _xobject xobject
 

Functions

HRESULT IDirectXFileImpl_Create (IUnknown *pUnkOuter, LPVOID *ppObj)
 
HRESULT parse_header (parse_buffer *buf, BYTE **decomp_buffer_ptr)
 
BOOL parse_object (parse_buffer *buf)
 
BOOL parse_templates (parse_buffer *buf, BOOL templates_only)
 
int mszip_decompress (int inlen, int outlen, char *inbuffer, char *outbuffer)
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 24 of file d3dxof_private.h.

◆ MAX_ARRAY_DIM

#define MAX_ARRAY_DIM   4

Definition at line 34 of file d3dxof_private.h.

◆ MAX_CHILDREN

#define MAX_CHILDREN   200

Definition at line 36 of file d3dxof_private.h.

◆ MAX_MEMBERS

#define MAX_MEMBERS   50

Definition at line 35 of file d3dxof_private.h.

◆ MAX_NAME_LEN

#define MAX_NAME_LEN   40

Definition at line 33 of file d3dxof_private.h.

◆ MAX_OBJECTS

#define MAX_OBJECTS   500

Definition at line 38 of file d3dxof_private.h.

◆ MAX_STRINGS_BUFFER

#define MAX_STRINGS_BUFFER   10000

Definition at line 40 of file d3dxof_private.h.

◆ MAX_SUBOBJECTS

#define MAX_SUBOBJECTS   2000

Definition at line 39 of file d3dxof_private.h.

◆ MAX_TEMPLATES

#define MAX_TEMPLATES   200

Definition at line 37 of file d3dxof_private.h.

Typedef Documentation

◆ xobject

Definition at line 85 of file d3dxof_private.h.

Function Documentation

◆ IDirectXFileImpl_Create()

HRESULT IDirectXFileImpl_Create ( IUnknown *  pUnkOuter,
LPVOID *  ppObj 
)

Definition at line 40 of file d3dxof.c.

41{
43
44 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
45
47 if (!object)
48 return DXFILEERR_BADALLOC;
49
50 object->IDirectXFile_iface.lpVtbl = &IDirectXFile_Vtbl;
51 object->ref = 1;
52
53 /* Reserve first template to handle the case sensitive legacy type indexColor */
54 object->nb_xtemplates = 1;
55 strcpy(object->xtemplates[0].name, "indexColor");
56 object->xtemplates[0].nb_members = 2;
57 object->xtemplates[0].members[0].type = TOKEN_DWORD;
58 object->xtemplates[0].members[0].nb_dims = 0;
59 object->xtemplates[0].members[1].type = TOKEN_FLOAT;
60 object->xtemplates[0].members[1].nb_dims = 1;
61 object->xtemplates[0].members[1].dim_fixed[0] = TRUE;
62 object->xtemplates[0].members[1].dim_value[0] = 4;
63
64 *ppObj = &object->IDirectXFile_iface;
65
66 return S_OK;
67}
#define TOKEN_FLOAT
Definition: d3dxof.c:38
#define TOKEN_DWORD
Definition: d3dxof.c:37
static const struct IDirectXFileVtbl IDirectXFile_Vtbl
Definition: d3dxof.c:26
#define TRUE
Definition: types.h:120
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define DXFILEERR_BADALLOC
Definition: dxfile.h:274
#define S_OK
Definition: intsafe.h:52
strcpy
Definition: string.h:131
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by DirectXFileCreate().

◆ mszip_decompress()

int mszip_decompress ( int  inlen,
int  outlen,
char *  inbuffer,
char *  outbuffer 
)

Referenced by parse_header().

◆ parse_header()

HRESULT parse_header ( parse_buffer *  buf,
BYTE **  decomp_buffer_ptr 
)

Definition at line 164 of file parsing.c.

165{
166 /* X File common header:
167 * 0-3 -> Magic Number (format identifier)
168 * 4-7 -> Format Version
169 * 8-11 -> Format Type (text or binary, decompressed or compressed)
170 * 12-15 -> Float Size (32 or 64 bits) */
171 DWORD header[4];
172
173 if (!read_bytes(buf, header, sizeof(header)))
175
176 if (TRACE_ON(d3dxof_parsing))
177 {
178 char string[17];
179 memcpy(string, header, 16);
180 string[16] = 0;
181 TRACE("header = '%s'\n", string);
182 }
183
186
189
192 {
193 WARN("File type %s unknown\n", debugstr_fourcc(header[2]));
195 }
196
199
201
203 {
204 /* Extended header for compressed data:
205 * 16-19 -> size of decompressed file including xof header,
206 * 20-21 -> size of first decompressed MSZIP chunk, 22-23 -> size of first compressed MSZIP chunk
207 * 24-xx -> compressed MSZIP data chunk
208 * xx-xx -> size of next decompressed MSZIP chunk, xx-xx -> size of next compressed MSZIP chunk
209 * xx-xx -> compressed MSZIP data chunk
210 * .............................................................................................. */
211 int err;
212 DWORD decomp_file_size;
213 WORD decomp_chunk_size;
214 WORD comp_chunk_size;
215 LPBYTE decomp_buffer;
216
217 if (!read_bytes(buf, &decomp_file_size, sizeof(decomp_file_size)))
219
220 TRACE("Compressed format %s detected: decompressed file size with xof header = %lu.\n",
221 debugstr_fourcc(header[2]), decomp_file_size);
222
223 /* Does not take xof header into account */
224 decomp_file_size -= 16;
225
226 decomp_buffer = HeapAlloc(GetProcessHeap(), 0, decomp_file_size);
227 if (!decomp_buffer)
228 {
229 ERR("Out of memory\n");
230 return DXFILEERR_BADALLOC;
231 }
232 *decomp_buffer_ptr = decomp_buffer;
233
234 while (buf->rem_bytes)
235 {
236 if (!read_bytes(buf, &decomp_chunk_size, sizeof(decomp_chunk_size)))
238 if (!read_bytes(buf, &comp_chunk_size, sizeof(comp_chunk_size)))
240
241 TRACE("Process chunk: compressed_size = %d, decompressed_size = %d\n",
242 comp_chunk_size, decomp_chunk_size);
243
244 err = mszip_decompress(comp_chunk_size, decomp_chunk_size, (char*)buf->buffer, (char*)decomp_buffer);
245 if (err)
246 {
247 WARN("Error while decompressing MSZIP chunk %d\n", err);
248 HeapFree(GetProcessHeap(), 0, decomp_buffer);
249 return DXFILEERR_BADALLOC;
250 }
251 buf->rem_bytes -= comp_chunk_size;
252 buf->buffer += comp_chunk_size;
253 decomp_buffer += decomp_chunk_size;
254 }
255
256 if ((decomp_buffer - *decomp_buffer_ptr) != decomp_file_size)
257 ERR("Size of all decompressed chunks (%Iu) does not match decompressed file size (%lu).\n",
258 decomp_buffer - *decomp_buffer_ptr, decomp_file_size);
259
260 /* Use decompressed data */
261 buf->buffer = *decomp_buffer_ptr;
262 buf->rem_bytes = decomp_file_size;
263 }
264
265 TRACE("Header is correct\n");
266
267 return S_OK;
268}
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
int mszip_decompress(int inlen, int outlen, char *inbuffer, char *outbuffer)
#define TRACE_ON(x)
Definition: compat.h:75
#define HeapFree(x, y, z)
Definition: compat.h:735
#define DXFILEERR_BADFILEVERSION
Definition: dxfile.h:282
#define DXFILEERR_BADFILEFLOATSIZE
Definition: dxfile.h:283
#define DXFILEERR_BADFILETYPE
Definition: dxfile.h:281
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define XOFFILE_FORMAT_MAGIC
Definition: parsing.c:26
#define XOFFILE_FORMAT_FLOAT_BITS_32
Definition: parsing.c:34
#define XOFFILE_FORMAT_VERSION_302
Definition: parsing.c:27
static BOOL read_bytes(parse_buffer *buf, LPVOID data, DWORD size)
Definition: parsing.c:148
#define XOFFILE_FORMAT_BINARY
Definition: parsing.c:29
#define XOFFILE_FORMAT_TEXT
Definition: parsing.c:30
#define XOFFILE_FORMAT_VERSION_303
Definition: parsing.c:28
#define XOFFILE_FORMAT_BINARY_MSZIP
Definition: parsing.c:31
#define XOFFILE_FORMAT_TEXT_MSZIP
Definition: parsing.c:32
#define XOFFILE_FORMAT_FLOAT_BITS_64
Definition: parsing.c:35
#define err(...)
static __inline const char * debugstr_fourcc(unsigned int cc)
Definition: debug.h:397
unsigned char * LPBYTE
Definition: typedefs.h:53

Referenced by IDirectXFileImpl_CreateEnumObject(), and IDirectXFileImpl_RegisterTemplates().

◆ parse_object()

BOOL parse_object ( parse_buffer *  buf)

Definition at line 1361 of file parsing.c.

1362{
1363 ULONG i;
1364
1365 buf->pxo->pos_data = buf->cur_pos_data;
1366 buf->pxo->ptarget = NULL;
1367 buf->pxo->binary = FALSE;
1368 buf->pxo->root = buf->pxo_tab;
1369
1370 if (get_TOKEN(buf) != TOKEN_NAME)
1371 return FALSE;
1372
1373 /* To do template lookup */
1374 for (i = 0; i < buf->pdxf->nb_xtemplates; i++)
1375 {
1376 if (!stricmp((char*)buf->value, buf->pdxf->xtemplates[i].name))
1377 {
1378 buf->pxt[buf->level] = &buf->pdxf->xtemplates[i];
1379 memcpy(&buf->pxo->type, &buf->pdxf->xtemplates[i].class_id, 16);
1380 break;
1381 }
1382 }
1383 if (i == buf->pdxf->nb_xtemplates)
1384 {
1385 ERR("Unknown template %s\n", (char*)buf->value);
1386 return FALSE;
1387 }
1388
1389 if (check_TOKEN(buf) == TOKEN_NAME)
1390 {
1391 get_TOKEN(buf);
1392 strcpy(buf->pxo->name, (char*)buf->value);
1393 }
1394 else
1395 buf->pxo->name[0] = 0;
1396
1397 if (get_TOKEN(buf) != TOKEN_OBRACE)
1398 return FALSE;
1399 if (check_TOKEN(buf) == TOKEN_GUID)
1400 {
1401 get_TOKEN(buf);
1402 memcpy(&buf->pxo->class_id, buf->value, 16);
1403 }
1404 else
1405 memset(&buf->pxo->class_id, 0, 16);
1406
1408 return FALSE;
1409 if (get_TOKEN(buf) != TOKEN_CBRACE)
1410 return FALSE;
1411
1412 /* For seeking to a possibly eof to avoid parsing another object next time */
1414
1415 return TRUE;
1416}
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define stricmp(_String1, _String2)
Definition: compat.h:24
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define TOKEN_GUID
Definition: parsing.c:42
#define TOKEN_NAME
Definition: parsing.c:39
static BOOL parse_object_parts(parse_buffer *buf, BOOL allow_optional)
Definition: parsing.c:1275
#define TOKEN_OBRACE
Definition: parsing.c:45
static WORD check_TOKEN(parse_buffer *buf)
Definition: parsing.c:856
#define TOKEN_CBRACE
Definition: parsing.c:46
static WORD get_TOKEN(parse_buffer *buf)
Definition: parsing.c:843
#define memset(x, y, z)
Definition: compat.h:39
uint32_t ULONG
Definition: typedefs.h:59

Referenced by IDirectXFileEnumObjectImpl_GetNextDataObject(), and parse_object_parts().

◆ parse_templates()

BOOL parse_templates ( parse_buffer *  buf,
BOOL  templates_only 
)

Definition at line 1080 of file parsing.c.

1081{
1082 while (check_TOKEN(buf) != TOKEN_NONE)
1083 {
1084 if (templates_only && (check_TOKEN(buf) != TOKEN_TEMPLATE))
1085 return TRUE;
1086 if (!parse_template(buf))
1087 {
1088 WARN("Template is not correct\n");
1089 return FALSE;
1090 }
1091 else
1092 {
1093 TRACE("Template successfully parsed:\n");
1094 if (TRACE_ON(d3dxof_parsing))
1095 dump_template(buf->pdxf->xtemplates, &buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates - 1]);
1096 }
1097 }
1098 return TRUE;
1099}
static void dump_template(xtemplate *templates_array, xtemplate *ptemplate)
Definition: parsing.c:107
#define TOKEN_TEMPLATE
Definition: parsing.c:56
static BOOL parse_template(parse_buffer *buf)
Definition: parsing.c:1056
#define TOKEN_NONE
Definition: parsing.c:38

Referenced by IDirectXFileEnumObjectImpl_GetNextDataObject(), IDirectXFileImpl_CreateEnumObject(), and IDirectXFileImpl_RegisterTemplates().