ReactOS  0.4.13-dev-242-g611e6d7
parsing.c File Reference
#include "config.h"
#include "wine/port.h"
#include "wine/debug.h"
#include "winbase.h"
#include "wingdi.h"
#include "d3dxof_private.h"
#include "dxfile.h"
#include <stdio.h>
Include dependency graph for parsing.c:

Go to the source code of this file.

Macros

#define COBJMACROS
 
#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',' ')
 
#define XOFFILE_FORMAT_VERSION_302   MAKEFOUR('0','3','0','2')
 
#define XOFFILE_FORMAT_VERSION_303   MAKEFOUR('0','3','0','3')
 
#define XOFFILE_FORMAT_BINARY   MAKEFOUR('b','i','n',' ')
 
#define XOFFILE_FORMAT_TEXT   MAKEFOUR('t','x','t',' ')
 
#define XOFFILE_FORMAT_BINARY_MSZIP   MAKEFOUR('b','z','i','p')
 
#define XOFFILE_FORMAT_TEXT_MSZIP   MAKEFOUR('t','z','i','p')
 
#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_ERROR   0xffff
 
#define TOKEN_NONE   0
 
#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
 
#define CLSIDFMT   "<%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X>"
 
#define DUMP_TOKEN(t)   case t: TRACE(#t "\n"); break
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3dxof_parsing)
 
static const chardebugstr_fourcc (DWORD fourcc)
 
static const charget_primitive_string (DWORD token)
 
static void dump_template (xtemplate *templates_array, xtemplate *ptemplate)
 
static BOOL read_bytes (parse_buffer *buf, LPVOID data, DWORD size)
 
static void rewind_bytes (parse_buffer *buf, DWORD size)
 
HRESULT parse_header (parse_buffer *buf, BYTE **decomp_buffer_ptr)
 
static void dump_TOKEN (WORD token)
 
static BOOL is_space (char c)
 
static BOOL is_operator (char c)
 
static BOOL is_separator (char c)
 
static WORD get_operator_token (char c)
 
static BOOL is_keyword (parse_buffer *buf, const char *keyword)
 
static WORD get_keyword_token (parse_buffer *buf)
 
static BOOL is_guid (parse_buffer *buf)
 
static BOOL is_name (parse_buffer *buf)
 
static BOOL is_float (parse_buffer *buf)
 
static BOOL is_integer (parse_buffer *buf)
 
static BOOL is_string (parse_buffer *buf)
 
static WORD parse_TOKEN (parse_buffer *buf)
 
static WORD get_TOKEN (parse_buffer *buf)
 
static WORD check_TOKEN (parse_buffer *buf)
 
static BOOL is_primitive_type (WORD token)
 
static BOOL parse_template_option_info (parse_buffer *buf)
 
static BOOL parse_template_members_list (parse_buffer *buf)
 
static BOOL parse_template_parts (parse_buffer *buf)
 
static BOOL parse_template (parse_buffer *buf)
 
BOOL parse_templates (parse_buffer *buf, BOOL templates_only)
 
static BOOL check_buffer (parse_buffer *buf, ULONG size)
 
static BOOL parse_object_parts (parse_buffer *buf, BOOL allow_optional)
 
static BOOL parse_object_members_list (parse_buffer *buf)
 
BOOL parse_object (parse_buffer *buf)
 

Macro Definition Documentation

◆ CLSIDFMT

#define CLSIDFMT   "<%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X>"

Definition at line 83 of file parsing.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 25 of file parsing.c.

◆ DUMP_TOKEN

#define DUMP_TOKEN (   t)    case t: TRACE(#t "\n"); break

◆ MAKEFOUR

#define MAKEFOUR (   a,
  b,
  c,
  d 
)    ((DWORD)a + ((DWORD)b << 8) + ((DWORD)c << 16) + ((DWORD)d << 24))

Definition at line 37 of file parsing.c.

◆ TOKEN_ARRAY

#define TOKEN_ARRAY   52

Definition at line 81 of file parsing.c.

◆ TOKEN_CANGLE

#define TOKEN_CANGLE   17

Definition at line 64 of file parsing.c.

◆ TOKEN_CBRACE

#define TOKEN_CBRACE   11

Definition at line 58 of file parsing.c.

◆ TOKEN_CBRACKET

#define TOKEN_CBRACKET   15

Definition at line 62 of file parsing.c.

◆ TOKEN_CHAR

#define TOKEN_CHAR   44

Definition at line 73 of file parsing.c.

◆ TOKEN_COMMA

#define TOKEN_COMMA   19

Definition at line 66 of file parsing.c.

◆ TOKEN_CPAREN

#define TOKEN_CPAREN   13

Definition at line 60 of file parsing.c.

◆ TOKEN_CSTRING

#define TOKEN_CSTRING   51

Definition at line 80 of file parsing.c.

◆ TOKEN_DOT

#define TOKEN_DOT   18

Definition at line 65 of file parsing.c.

◆ TOKEN_DOUBLE

#define TOKEN_DOUBLE   43

Definition at line 72 of file parsing.c.

◆ TOKEN_DWORD

#define TOKEN_DWORD   41

Definition at line 70 of file parsing.c.

◆ TOKEN_ERROR

#define TOKEN_ERROR   0xffff

Definition at line 49 of file parsing.c.

◆ TOKEN_FLOAT

#define TOKEN_FLOAT   42

Definition at line 71 of file parsing.c.

◆ TOKEN_FLOAT_LIST

#define TOKEN_FLOAT_LIST   7

Definition at line 56 of file parsing.c.

◆ TOKEN_GUID

#define TOKEN_GUID   5

Definition at line 54 of file parsing.c.

◆ TOKEN_INTEGER

#define TOKEN_INTEGER   3

Definition at line 53 of file parsing.c.

◆ TOKEN_INTEGER_LIST

#define TOKEN_INTEGER_LIST   6

Definition at line 55 of file parsing.c.

◆ TOKEN_LPSTR

#define TOKEN_LPSTR   49

Definition at line 78 of file parsing.c.

◆ TOKEN_NAME

#define TOKEN_NAME   1

Definition at line 51 of file parsing.c.

◆ TOKEN_NONE

#define TOKEN_NONE   0

Definition at line 50 of file parsing.c.

◆ TOKEN_OANGLE

#define TOKEN_OANGLE   16

Definition at line 63 of file parsing.c.

◆ TOKEN_OBRACE

#define TOKEN_OBRACE   10

Definition at line 57 of file parsing.c.

◆ TOKEN_OBRACKET

#define TOKEN_OBRACKET   14

Definition at line 61 of file parsing.c.

◆ TOKEN_OPAREN

#define TOKEN_OPAREN   12

Definition at line 59 of file parsing.c.

◆ TOKEN_SDWORD

#define TOKEN_SDWORD   47

Definition at line 76 of file parsing.c.

◆ TOKEN_SEMICOLON

#define TOKEN_SEMICOLON   20

Definition at line 67 of file parsing.c.

◆ TOKEN_STRING

#define TOKEN_STRING   2

Definition at line 52 of file parsing.c.

◆ TOKEN_SWORD

#define TOKEN_SWORD   46

Definition at line 75 of file parsing.c.

◆ TOKEN_TEMPLATE

#define TOKEN_TEMPLATE   31

Definition at line 68 of file parsing.c.

◆ TOKEN_UCHAR

#define TOKEN_UCHAR   45

Definition at line 74 of file parsing.c.

◆ TOKEN_UNICODE

#define TOKEN_UNICODE   50

Definition at line 79 of file parsing.c.

◆ TOKEN_VOID

#define TOKEN_VOID   48

Definition at line 77 of file parsing.c.

◆ TOKEN_WORD

#define TOKEN_WORD   40

Definition at line 69 of file parsing.c.

◆ XOFFILE_FORMAT_BINARY

#define XOFFILE_FORMAT_BINARY   MAKEFOUR('b','i','n',' ')

Definition at line 41 of file parsing.c.

◆ XOFFILE_FORMAT_BINARY_MSZIP

#define XOFFILE_FORMAT_BINARY_MSZIP   MAKEFOUR('b','z','i','p')

Definition at line 43 of file parsing.c.

◆ XOFFILE_FORMAT_COMPRESSED

#define XOFFILE_FORMAT_COMPRESSED   MAKEFOUR('c','m','p',' ')

Definition at line 45 of file parsing.c.

◆ XOFFILE_FORMAT_FLOAT_BITS_32

#define XOFFILE_FORMAT_FLOAT_BITS_32   MAKEFOUR('0','0','3','2')

Definition at line 46 of file parsing.c.

◆ XOFFILE_FORMAT_FLOAT_BITS_64

#define XOFFILE_FORMAT_FLOAT_BITS_64   MAKEFOUR('0','0','6','4')

Definition at line 47 of file parsing.c.

◆ XOFFILE_FORMAT_MAGIC

#define XOFFILE_FORMAT_MAGIC   MAKEFOUR('x','o','f',' ')

Definition at line 38 of file parsing.c.

◆ XOFFILE_FORMAT_TEXT

#define XOFFILE_FORMAT_TEXT   MAKEFOUR('t','x','t',' ')

Definition at line 42 of file parsing.c.

◆ XOFFILE_FORMAT_TEXT_MSZIP

#define XOFFILE_FORMAT_TEXT_MSZIP   MAKEFOUR('t','z','i','p')

Definition at line 44 of file parsing.c.

◆ XOFFILE_FORMAT_VERSION_302

#define XOFFILE_FORMAT_VERSION_302   MAKEFOUR('0','3','0','2')

Definition at line 39 of file parsing.c.

◆ XOFFILE_FORMAT_VERSION_303

#define XOFFILE_FORMAT_VERSION_303   MAKEFOUR('0','3','0','3')

Definition at line 40 of file parsing.c.

Function Documentation

◆ check_buffer()

static BOOL check_buffer ( parse_buffer buf,
ULONG  size 
)
static

Definition at line 1120 of file parsing.c.

1121 {
1122  if ((buf->cur_pos_data + size) > buf->capacity)
1123  {
1124  LPBYTE pdata;
1125  ULONG new_capacity = buf->capacity ? 2 * buf->capacity : 100000;
1126 
1127  pdata = HeapAlloc(GetProcessHeap(), 0, new_capacity);
1128  if (!pdata)
1129  return FALSE;
1130  memcpy(pdata, buf->pdata, buf->cur_pos_data);
1131  HeapFree(GetProcessHeap(), 0, buf->pdata);
1132  buf->capacity = new_capacity;
1133  buf->pdata = pdata;
1134  buf->pxo->root->pdata = pdata;
1135  }
1136  return TRUE;
1137 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
unsigned char * LPBYTE
Definition: typedefs.h:52
static PROTOCOLDATA * pdata
Definition: protocol.c:157
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned int ULONG
Definition: retypes.h:1
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by parse_object_members_list(), and test_WinHttpAddHeaders().

◆ check_TOKEN()

static WORD check_TOKEN ( parse_buffer buf)
static

Definition at line 876 of file parsing.c.

877 {
878  if (buf->token_present)
879  return buf->current_token;
880 
881  buf->current_token = parse_TOKEN(buf);
882  buf->token_present = TRUE;
883 
884  return buf->current_token;
885 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static WORD parse_TOKEN(parse_buffer *buf)
Definition: parsing.c:640

Referenced by parse_object(), parse_object_members_list(), parse_object_parts(), parse_template_members_list(), parse_template_option_info(), parse_template_parts(), and parse_templates().

◆ debugstr_fourcc()

static const char* debugstr_fourcc ( DWORD  fourcc)
static

Definition at line 86 of file parsing.c.

87 {
88  if (!fourcc) return "'null'";
89  return wine_dbg_sprintf ("\'%c%c%c%c\'",
90  (char)(fourcc), (char)(fourcc >> 8),
91  (char)(fourcc >> 16), (char)(fourcc >> 24));
92 }
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:271

Referenced by IDirectMusicInstrumentImpl_CustomLoad(), IPersistStreamImpl_Load(), load_region(), and parse_header().

◆ dump_template()

static void dump_template ( xtemplate templates_array,
xtemplate ptemplate 
)
static

Definition at line 128 of file parsing.c.

129 {
130  ULONG j, k;
131  GUID* clsid;
132 
133  clsid = &ptemplate->class_id;
134 
135  DPRINTF("template %s\n", ptemplate->name);
136  DPRINTF("{\n");
137  DPRINTF(CLSIDFMT "\n", clsid->Data1, clsid->Data2, clsid->Data3, clsid->Data4[0],
138  clsid->Data4[1], clsid->Data4[2], clsid->Data4[3], clsid->Data4[4], clsid->Data4[5], clsid->Data4[6], clsid->Data4[7]);
139  for (j = 0; j < ptemplate->nb_members; j++)
140  {
141  if (ptemplate->members[j].nb_dims)
142  DPRINTF("array ");
143  if (ptemplate->members[j].type == TOKEN_NAME)
144  DPRINTF("%s ", templates_array[ptemplate->members[j].idx_template].name);
145  else
146  DPRINTF("%s ", get_primitive_string(ptemplate->members[j].type));
147  DPRINTF("%s", ptemplate->members[j].name);
148  for (k = 0; k < ptemplate->members[j].nb_dims; k++)
149  {
150  if (ptemplate->members[j].dim_fixed[k])
151  DPRINTF("[%d]", ptemplate->members[j].dim_value[k]);
152  else
153  DPRINTF("[%s]", ptemplate->members[ptemplate->members[j].dim_value[k]].name);
154  }
155  DPRINTF(";\n");
156  }
157  if (ptemplate->open)
158  DPRINTF("[...]\n");
159  else if (ptemplate->nb_children)
160  {
161  DPRINTF("[%s", ptemplate->children[0]);
162  for (j = 1; j < ptemplate->nb_children; j++)
163  DPRINTF(",%s", ptemplate->children[j]);
164  DPRINTF("]\n");
165  }
166  DPRINTF("}\n");
167 }
char children[MAX_CHILDREN][MAX_NAME_LEN]
ULONG dim_value[MAX_ARRAY_DIM]
member members[MAX_MEMBERS]
char name[MAX_NAME_LEN]
BOOL dim_fixed[MAX_ARRAY_DIM]
ULONG nb_members
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 GLint GLint j
Definition: glfuncs.h:250
ULONG nb_children
#define CLSIDFMT
Definition: parsing.c:83
REFCLSID clsid
Definition: msctf.c:84
char name[MAX_NAME_LEN]
LONG idx_template
DWORD type
ULONG nb_dims
#define DPRINTF
Definition: debug.h:413
static const char * get_primitive_string(DWORD token)
Definition: parsing.c:94
#define TOKEN_NAME
Definition: parsing.c:51
unsigned int ULONG
Definition: retypes.h:1
int k
Definition: mpi.c:3369

Referenced by parse_templates().

◆ dump_TOKEN()

static void dump_TOKEN ( WORD  token)
static

Definition at line 291 of file parsing.c.

292 {
293 #define DUMP_TOKEN(t) case t: TRACE(#t "\n"); break
294  switch(token)
295  {
327  default:
328  if (0)
329  TRACE("Unknown token %d\n", token);
330  break;
331  }
332 #undef DUMP_TOKEN
333 }
#define TOKEN_DOUBLE
Definition: parsing.c:72
#define TOKEN_OBRACE
Definition: parsing.c:57
#define TOKEN_CSTRING
Definition: parsing.c:80
#define DUMP_TOKEN(t)
#define TOKEN_GUID
Definition: parsing.c:54
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 token
Definition: glfuncs.h:210
#define TOKEN_WORD
Definition: parsing.c:69
#define TOKEN_TEMPLATE
Definition: parsing.c:68
#define TOKEN_CBRACKET
Definition: parsing.c:62
#define TOKEN_SWORD
Definition: parsing.c:75
#define TOKEN_UCHAR
Definition: parsing.c:74
#define TOKEN_SEMICOLON
Definition: parsing.c:67
#define TOKEN_SDWORD
Definition: parsing.c:76
#define TOKEN_INTEGER_LIST
Definition: parsing.c:55
#define TRACE(s)
Definition: solgame.cpp:4
#define TOKEN_ARRAY
Definition: parsing.c:81
#define TOKEN_CHAR
Definition: parsing.c:73
#define TOKEN_LPSTR
Definition: parsing.c:78
#define TOKEN_VOID
Definition: parsing.c:77
#define TOKEN_OANGLE
Definition: parsing.c:63
#define TOKEN_OBRACKET
Definition: parsing.c:61
#define TOKEN_UNICODE
Definition: parsing.c:79
#define TOKEN_COMMA
Definition: parsing.c:66
#define TOKEN_FLOAT
Definition: parsing.c:71
#define TOKEN_NAME
Definition: parsing.c:51
#define TOKEN_FLOAT_LIST
Definition: parsing.c:56
#define TOKEN_CANGLE
Definition: parsing.c:64
#define TOKEN_DWORD
Definition: parsing.c:70
#define TOKEN_DOT
Definition: parsing.c:65
#define TOKEN_INTEGER
Definition: parsing.c:53
#define TOKEN_CBRACE
Definition: parsing.c:58
#define TOKEN_OPAREN
Definition: parsing.c:59
#define TOKEN_CPAREN
Definition: parsing.c:60
#define TOKEN_STRING
Definition: parsing.c:52

Referenced by parse_TOKEN().

◆ get_keyword_token()

static WORD get_keyword_token ( parse_buffer buf)
static

Definition at line 425 of file parsing.c.

426 {
427  if (is_keyword(buf, "template"))
428  return TOKEN_TEMPLATE;
429  if (is_keyword(buf, "WORD"))
430  return TOKEN_WORD;
431  if (is_keyword(buf, "DWORD"))
432  return TOKEN_DWORD;
433  if (is_keyword(buf, "FLOAT"))
434  return TOKEN_FLOAT;
435  if (is_keyword(buf, "DOUBLE"))
436  return TOKEN_DOUBLE;
437  if (is_keyword(buf, "CHAR"))
438  return TOKEN_CHAR;
439  if (is_keyword(buf, "UCHAR"))
440  return TOKEN_UCHAR;
441  if (is_keyword(buf, "SWORD"))
442  return TOKEN_SWORD;
443  if (is_keyword(buf, "SDWORD"))
444  return TOKEN_SDWORD;
445  if (is_keyword(buf, "VOID"))
446  return TOKEN_VOID;
447  if (is_keyword(buf, "STRING"))
448  return TOKEN_LPSTR;
449  if (is_keyword(buf, "UNICODE"))
450  return TOKEN_UNICODE;
451  if (is_keyword(buf, "CSTRING"))
452  return TOKEN_CSTRING;
453  if (is_keyword(buf, "array"))
454  return TOKEN_ARRAY;
455 
456  return 0;
457 }
#define TOKEN_DOUBLE
Definition: parsing.c:72
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TOKEN_CSTRING
Definition: parsing.c:80
#define TOKEN_WORD
Definition: parsing.c:69
#define TOKEN_TEMPLATE
Definition: parsing.c:68
#define TOKEN_SWORD
Definition: parsing.c:75
#define TOKEN_UCHAR
Definition: parsing.c:74
#define TOKEN_SDWORD
Definition: parsing.c:76
#define TOKEN_ARRAY
Definition: parsing.c:81
#define TOKEN_CHAR
Definition: parsing.c:73
#define TOKEN_LPSTR
Definition: parsing.c:78
#define TOKEN_VOID
Definition: parsing.c:77
static BOOL is_keyword(parse_buffer *buf, const char *keyword)
Definition: parsing.c:401
#define TOKEN_UNICODE
Definition: parsing.c:79
#define TOKEN_FLOAT
Definition: parsing.c:71
#define TOKEN_DWORD
Definition: parsing.c:70

Referenced by parse_TOKEN().

◆ get_operator_token()

static WORD get_operator_token ( char  c)
static

Definition at line 373 of file parsing.c.

374 {
375  switch(c)
376  {
377  case '{':
378  return TOKEN_OBRACE;
379  case '}':
380  return TOKEN_CBRACE;
381  case '[':
382  return TOKEN_OBRACKET;
383  case ']':
384  return TOKEN_CBRACKET;
385  case '(':
386  return TOKEN_OPAREN;
387  case ')':
388  return TOKEN_CPAREN;
389  case '<':
390  return TOKEN_OANGLE;
391  case '>':
392  return TOKEN_CANGLE;
393  case ',':
394  return TOKEN_COMMA;
395  case ';':
396  return TOKEN_SEMICOLON;
397  }
398  return 0;
399 }
#define TOKEN_OBRACE
Definition: parsing.c:57
#define TOKEN_CBRACKET
Definition: parsing.c:62
#define TOKEN_SEMICOLON
Definition: parsing.c:67
const GLubyte * c
Definition: glext.h:8905
#define TOKEN_OANGLE
Definition: parsing.c:63
#define TOKEN_OBRACKET
Definition: parsing.c:61
#define TOKEN_COMMA
Definition: parsing.c:66
#define TOKEN_CANGLE
Definition: parsing.c:64
#define TOKEN_CBRACE
Definition: parsing.c:58
#define TOKEN_OPAREN
Definition: parsing.c:59
#define TOKEN_CPAREN
Definition: parsing.c:60

Referenced by parse_TOKEN().

◆ get_primitive_string()

static const char* get_primitive_string ( DWORD  token)
static

Definition at line 94 of file parsing.c.

95 {
96  switch(token)
97  {
98  case TOKEN_WORD:
99  return "WORD";
100  case TOKEN_DWORD:
101  return "DWORD";
102  case TOKEN_FLOAT:
103  return "FLOAT";
104  case TOKEN_DOUBLE:
105  return "DOUBLE";
106  case TOKEN_CHAR:
107  return "CHAR";
108  case TOKEN_UCHAR:
109  return "UCHAR";
110  case TOKEN_SWORD:
111  return "SWORD";
112  case TOKEN_SDWORD:
113  return "SDWORD";
114  case TOKEN_VOID:
115  return "VOID";
116  case TOKEN_LPSTR:
117  return "STRING";
118  case TOKEN_UNICODE:
119  return "UNICODE";
120  case TOKEN_CSTRING:
121  return "CSTRING ";
122  default:
123  break;
124  }
125  return NULL;
126 }
#define TOKEN_DOUBLE
Definition: parsing.c:72
#define TOKEN_CSTRING
Definition: parsing.c:80
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 token
Definition: glfuncs.h:210
#define TOKEN_WORD
Definition: parsing.c:69
smooth NULL
Definition: ftsmooth.c:416
#define TOKEN_SWORD
Definition: parsing.c:75
#define TOKEN_UCHAR
Definition: parsing.c:74
#define TOKEN_SDWORD
Definition: parsing.c:76
#define TOKEN_CHAR
Definition: parsing.c:73
#define TOKEN_LPSTR
Definition: parsing.c:78
#define TOKEN_VOID
Definition: parsing.c:77
#define TOKEN_UNICODE
Definition: parsing.c:79
#define TOKEN_FLOAT
Definition: parsing.c:71
#define TOKEN_DWORD
Definition: parsing.c:70

Referenced by dump_template().

◆ get_TOKEN()

static WORD get_TOKEN ( parse_buffer buf)
static

Definition at line 863 of file parsing.c.

864 {
865  if (buf->token_present)
866  {
867  buf->token_present = FALSE;
868  return buf->current_token;
869  }
870 
871  buf->current_token = parse_TOKEN(buf);
872 
873  return buf->current_token;
874 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static WORD parse_TOKEN(parse_buffer *buf)
Definition: parsing.c:640

Referenced by parse_object(), parse_object_members_list(), parse_object_parts(), parse_template(), parse_template_members_list(), parse_template_option_info(), and parse_template_parts().

◆ is_float()

static BOOL is_float ( parse_buffer buf)
static

Definition at line 540 of file parsing.c.

541 {
542  char tmp[512];
543  DWORD pos = 0;
544  char c;
545  float decimal;
546  BOOL dot = FALSE;
547 
548  while (pos < buf->rem_bytes && !is_separator(c = *(buf->buffer+pos)))
549  {
550  if (!((!pos && (c == '-')) || ((c >= '0') && (c <= '9')) || (!dot && (c == '.'))))
551  return FALSE;
552  if (c == '.')
553  dot = TRUE;
554  if (pos < sizeof(tmp))
555  tmp[pos] = c;
556  pos++;
557  }
558  tmp[min(pos, sizeof(tmp) - 1)] = 0;
559 
560  buf->buffer += pos;
561  buf->rem_bytes -= pos;
562 
563  sscanf(tmp, "%f", &decimal);
564 
565  TRACE("Found float %s - %f\n", tmp, decimal);
566 
567  *(float*)buf->value = decimal;
568 
569  return TRUE;
570 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static BOOL is_separator(char c)
Definition: parsing.c:368
unsigned int BOOL
Definition: ntddk_ex.h:94
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define TRACE(s)
Definition: solgame.cpp:4
const GLubyte * c
Definition: glext.h:8905
unsigned long DWORD
Definition: ntddk_ex.h:95
#define min(a, b)
Definition: monoChain.cc:55
#define c
Definition: ke_i.h:80

Referenced by parse_TOKEN().

◆ is_guid()

static BOOL is_guid ( parse_buffer buf)
static

Definition at line 459 of file parsing.c.

460 {
461  char tmp[50];
462  DWORD pos = 1;
463  GUID class_id;
464  DWORD tab[10];
465  int ret;
466 
467  if (buf->rem_bytes < 38 || *buf->buffer != '<')
468  return FALSE;
469  tmp[0] = '<';
470  while (pos < sizeof(tmp) - 2 && *(buf->buffer+pos) != '>')
471  {
472  tmp[pos] = *(buf->buffer+pos);
473  pos++;
474  }
475  tmp[pos++] = '>';
476  tmp[pos] = 0;
477  if (pos != 38 /* <+36+> */)
478  {
479  TRACE("Wrong guid %s (%d)\n", tmp, pos);
480  return FALSE;
481  }
482  buf->buffer += pos;
483  buf->rem_bytes -= pos;
484 
485  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);
486  if (ret != 11)
487  {
488  TRACE("Wrong guid %s (%d)\n", tmp, pos);
489  return FALSE;
490  }
491  TRACE("Found guid %s (%d)\n", tmp, pos);
492 
493  class_id.Data2 = tab[0];
494  class_id.Data3 = tab[1];
495  class_id.Data4[0] = tab[2];
496  class_id.Data4[1] = tab[3];
497  class_id.Data4[2] = tab[4];
498  class_id.Data4[3] = tab[5];
499  class_id.Data4[4] = tab[6];
500  class_id.Data4[5] = tab[7];
501  class_id.Data4[6] = tab[8];
502  class_id.Data4[7] = tab[9];
503 
504  *(GUID*)buf->value = class_id;
505 
506  return TRUE;
507 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define TRACE(s)
Definition: solgame.cpp:4
#define CLSIDFMT
Definition: parsing.c:83
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret

Referenced by parse_TOKEN().

◆ is_integer()

static BOOL is_integer ( parse_buffer buf)
static

Definition at line 572 of file parsing.c.

573 {
574  char tmp[512];
575  DWORD pos = 0;
576  char c;
577  DWORD integer;
578 
579  while (pos < buf->rem_bytes && !is_separator(c = *(buf->buffer+pos)))
580  {
581  if (!((c >= '0') && (c <= '9')))
582  return FALSE;
583  if (pos < sizeof(tmp))
584  tmp[pos] = c;
585  pos++;
586  }
587  tmp[min(pos, sizeof(tmp) - 1)] = 0;
588 
589  buf->buffer += pos;
590  buf->rem_bytes -= pos;
591 
592  sscanf(tmp, "%d", &integer);
593 
594  TRACE("Found integer %s - %d\n", tmp, integer);
595 
596  *(DWORD*)buf->value = integer;
597 
598  return TRUE;
599 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static BOOL is_separator(char c)
Definition: parsing.c:368
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
#define TRACE(s)
Definition: solgame.cpp:4
const GLubyte * c
Definition: glext.h:8905
unsigned long DWORD
Definition: ntddk_ex.h:95
#define min(a, b)
Definition: monoChain.cc:55
#define c
Definition: ke_i.h:80

Referenced by TypeTraitsTest::integer(), parse_TOKEN(), test_float_limits(), and test_integral_limits_base().

◆ is_keyword()

static BOOL is_keyword ( parse_buffer buf,
const char keyword 
)
static

Definition at line 401 of file parsing.c.

402 {
403  char tmp[8]; /* longest keyword size (template) */
404  DWORD len = strlen(keyword);
405 
406  if (!read_bytes(buf, tmp, len))
407  return FALSE;
408  if (strncasecmp(tmp, keyword, len))
409  {
410  rewind_bytes(buf, len);
411  return FALSE;
412  }
413 
414  if (!read_bytes(buf, tmp, 1))
415  return TRUE;
416  if (is_separator(tmp[0]))
417  {
418  rewind_bytes(buf, 1);
419  return TRUE;
420  }
421  rewind_bytes(buf, len+1);
422  return FALSE;
423 }
#define TRUE
Definition: types.h:120
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static BOOL read_bytes(parse_buffer *buf, LPVOID data, DWORD size)
Definition: parsing.c:169
static BOOL is_separator(char c)
Definition: parsing.c:368
#define strncasecmp
Definition: fake.h:10
static void rewind_bytes(parse_buffer *buf, DWORD size)
Definition: parsing.c:179
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLsizei len
Definition: glext.h:6722

Referenced by get_keyword_token().

◆ is_name()

static BOOL is_name ( parse_buffer buf)
static

Definition at line 509 of file parsing.c.

510 {
511  char tmp[512];
512  DWORD pos = 0;
513  char c;
514  BOOL error = FALSE;
515  while (pos < buf->rem_bytes && !is_separator(c = *(buf->buffer+pos)))
516  {
517  if (!(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9')) || (c == '_') || (c == '-')))
518  error = TRUE;
519  if (pos < sizeof(tmp))
520  tmp[pos] = c;
521  pos++;
522  }
523  tmp[min(pos, sizeof(tmp) - 1)] = 0;
524 
525  if (error)
526  {
527  TRACE("Wrong name %s\n", tmp);
528  return FALSE;
529  }
530 
531  buf->buffer += pos;
532  buf->rem_bytes -= pos;
533 
534  TRACE("Found name %s\n", tmp);
535  strcpy((char*)buf->value, tmp);
536 
537  return TRUE;
538 }
#define TRUE
Definition: types.h:120
#define error(str)
Definition: mkdosfs.c:1605
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static BOOL is_separator(char c)
Definition: parsing.c:368
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
const GLubyte * c
Definition: glext.h:8905
unsigned long DWORD
Definition: ntddk_ex.h:95
#define min(a, b)
Definition: monoChain.cc:55
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define c
Definition: ke_i.h:80

Referenced by parse_TOKEN().

◆ is_operator()

static BOOL is_operator ( char  c)
static

Definition at line 349 of file parsing.c.

350 {
351  switch(c)
352  {
353  case '{':
354  case '}':
355  case '[':
356  case ']':
357  case '(':
358  case ')':
359  case '<':
360  case '>':
361  case ',':
362  case ';':
363  return TRUE;
364  }
365  return FALSE;
366 }
#define TRUE
Definition: types.h:120
const GLubyte * c
Definition: glext.h:8905

Referenced by is_separator(), and parse_TOKEN().

◆ is_primitive_type()

static BOOL is_primitive_type ( WORD  token)
inlinestatic

Definition at line 887 of file parsing.c.

888 {
889  BOOL ret;
890  switch(token)
891  {
892  case TOKEN_WORD:
893  case TOKEN_DWORD:
894  case TOKEN_FLOAT:
895  case TOKEN_DOUBLE:
896  case TOKEN_CHAR:
897  case TOKEN_UCHAR:
898  case TOKEN_SWORD:
899  case TOKEN_SDWORD:
900  case TOKEN_LPSTR:
901  case TOKEN_UNICODE:
902  case TOKEN_CSTRING:
903  ret = TRUE;
904  break;
905  default:
906  ret = FALSE;
907  break;
908  }
909  return ret;
910 }
#define TOKEN_DOUBLE
Definition: parsing.c:72
#define TRUE
Definition: types.h:120
#define TOKEN_CSTRING
Definition: parsing.c:80
unsigned int BOOL
Definition: ntddk_ex.h:94
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 token
Definition: glfuncs.h:210
#define TOKEN_WORD
Definition: parsing.c:69
#define TOKEN_SWORD
Definition: parsing.c:75
#define TOKEN_UCHAR
Definition: parsing.c:74
#define TOKEN_SDWORD
Definition: parsing.c:76
#define TOKEN_CHAR
Definition: parsing.c:73
#define TOKEN_LPSTR
Definition: parsing.c:78
int ret
#define TOKEN_UNICODE
Definition: parsing.c:79
#define TOKEN_FLOAT
Definition: parsing.c:71
#define TOKEN_DWORD
Definition: parsing.c:70

Referenced by parse_template_members_list().

◆ is_separator()

static BOOL is_separator ( char  c)
inlinestatic

Definition at line 368 of file parsing.c.

369 {
370  return is_space(c) || is_operator(c);
371 }
static BOOL is_space(char c)
Definition: parsing.c:335
const GLubyte * c
Definition: glext.h:8905
static BOOL is_operator(char c)
Definition: parsing.c:349

Referenced by is_float(), is_integer(), is_keyword(), and is_name().

◆ is_space()

static BOOL is_space ( char  c)
static

Definition at line 335 of file parsing.c.

336 {
337  switch (c)
338  {
339  case 0x00:
340  case 0x0D:
341  case 0x0A:
342  case ' ':
343  case '\t':
344  return TRUE;
345  }
346  return FALSE;
347 }
#define TRUE
Definition: types.h:120
const GLubyte * c
Definition: glext.h:8905

Referenced by is_separator(), and parse_TOKEN().

◆ is_string()

static BOOL is_string ( parse_buffer buf)
static

Definition at line 601 of file parsing.c.

602 {
603  char tmp[512];
604  DWORD pos = 0;
605  char c;
606  BOOL ok = FALSE;
607 
608  if (*buf->buffer != '"')
609  return FALSE;
610 
611  while ((pos+1) < buf->rem_bytes)
612  {
613  c = *(buf->buffer+pos+1);
614  if (c == '"')
615  {
616  ok = TRUE;
617  break;
618  }
619  if (pos < sizeof(tmp))
620  tmp[pos] = c;
621  pos++;
622  }
623  tmp[min(pos, sizeof(tmp) - 1)] = 0;
624 
625  if (!ok)
626  {
627  TRACE("Wrong string %s\n", tmp);
628  return FALSE;
629  }
630 
631  buf->buffer += pos + 2;
632  buf->rem_bytes -= pos + 2;
633 
634  TRACE("Found string %s\n", tmp);
635  strcpy((char*)buf->value, tmp);
636 
637  return TRUE;
638 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ok(value,...)
#define TRACE(s)
Definition: solgame.cpp:4
const GLubyte * c
Definition: glext.h:8905
unsigned long DWORD
Definition: ntddk_ex.h:95
#define min(a, b)
Definition: monoChain.cc:55
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define c
Definition: ke_i.h:80

Referenced by add_eval(), create_regexp_var(), DateConstr_value(), equal_values(), JSGlobal_eval(), JSON_stringify(), less_eval(), and parse_TOKEN().

◆ parse_header()

HRESULT parse_header ( parse_buffer buf,
BYTE **  decomp_buffer_ptr 
)

Definition at line 185 of file parsing.c.

186 {
187  /* X File common header:
188  * 0-3 -> Magic Number (format identifier)
189  * 4-7 -> Format Version
190  * 8-11 -> Format Type (text or binary, decompressed or compressed)
191  * 12-15 -> Float Size (32 or 64 bits) */
192  DWORD header[4];
193 
194  if (!read_bytes(buf, header, sizeof(header)))
195  return DXFILEERR_BADFILETYPE;
196 
197  if (TRACE_ON(d3dxof_parsing))
198  {
199  char string[17];
200  memcpy(string, header, 16);
201  string[16] = 0;
202  TRACE("header = '%s'\n", string);
203  }
204 
205  if (header[0] != XOFFILE_FORMAT_MAGIC)
206  return DXFILEERR_BADFILETYPE;
207 
210 
213  {
214  WARN("File type %s unknown\n", debugstr_fourcc(header[2]));
215  return DXFILEERR_BADFILETYPE;
216  }
217 
220 
222 
224  {
225  /* Extended header for compressed data:
226  * 16-19 -> size of decompressed file including xof header,
227  * 20-21 -> size of first decompressed MSZIP chunk, 22-23 -> size of first compressed MSZIP chunk
228  * 24-xx -> compressed MSZIP data chunk
229  * xx-xx -> size of next decompressed MSZIP chunk, xx-xx -> size of next compressed MSZIP chunk
230  * xx-xx -> compressed MSZIP data chunk
231  * .............................................................................................. */
232  int err;
233  DWORD decomp_file_size;
234  WORD decomp_chunk_size;
235  WORD comp_chunk_size;
236  LPBYTE decomp_buffer;
237 
238  if (!read_bytes(buf, &decomp_file_size, sizeof(decomp_file_size)))
239  return DXFILEERR_BADFILETYPE;
240 
241  TRACE("Compressed format %s detected: decompressed file size with xof header = %d\n",
242  debugstr_fourcc(header[2]), decomp_file_size);
243 
244  /* Does not take xof header into account */
245  decomp_file_size -= 16;
246 
247  decomp_buffer = HeapAlloc(GetProcessHeap(), 0, decomp_file_size);
248  if (!decomp_buffer)
249  {
250  ERR("Out of memory\n");
251  return DXFILEERR_BADALLOC;
252  }
253  *decomp_buffer_ptr = decomp_buffer;
254 
255  while (buf->rem_bytes)
256  {
257  if (!read_bytes(buf, &decomp_chunk_size, sizeof(decomp_chunk_size)))
258  return DXFILEERR_BADFILETYPE;
259  if (!read_bytes(buf, &comp_chunk_size, sizeof(comp_chunk_size)))
260  return DXFILEERR_BADFILETYPE;
261 
262  TRACE("Process chunk: compressed_size = %d, decompressed_size = %d\n",
263  comp_chunk_size, decomp_chunk_size);
264 
265  err = mszip_decompress(comp_chunk_size, decomp_chunk_size, (char*)buf->buffer, (char*)decomp_buffer);
266  if (err)
267  {
268  WARN("Error while decompressing MSZIP chunk %d\n", err);
269  HeapFree(GetProcessHeap(), 0, decomp_buffer);
270  return DXFILEERR_BADALLOC;
271  }
272  buf->rem_bytes -= comp_chunk_size;
273  buf->buffer += comp_chunk_size;
274  decomp_buffer += decomp_chunk_size;
275  }
276 
277  if ((decomp_buffer - *decomp_buffer_ptr) != decomp_file_size)
278  ERR("Size of all decompressed chunks (%u) does not match decompressed file size (%u)\n",
279  (DWORD)(decomp_buffer - *decomp_buffer_ptr), decomp_file_size);
280 
281  /* Use decompressed data */
282  buf->buffer = *decomp_buffer_ptr;
283  buf->rem_bytes = decomp_file_size;
284  }
285 
286  TRACE("Header is correct\n");
287 
288  return S_OK;
289 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define WARN(fmt,...)
Definition: debug.h:111
static BOOL read_bytes(parse_buffer *buf, LPVOID data, DWORD size)
Definition: parsing.c:169
#define XOFFILE_FORMAT_VERSION_302
Definition: parsing.c:39
#define DXFILEERR_BADFILETYPE
Definition: dxfile.h:281
int mszip_decompress(int inlen, int outlen, char *inbuffer, char *outbuffer) DECLSPEC_HIDDEN
unsigned char * LPBYTE
Definition: typedefs.h:52
static const char * debugstr_fourcc(DWORD fourcc)
Definition: parsing.c:86
#define XOFFILE_FORMAT_MAGIC
Definition: parsing.c:38
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define XOFFILE_FORMAT_BINARY
Definition: parsing.c:41
#define XOFFILE_FORMAT_TEXT
Definition: parsing.c:42
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define err(...)
#define XOFFILE_FORMAT_TEXT_MSZIP
Definition: parsing.c:44
#define ERR(fmt,...)
Definition: debug.h:109
#define S_OK
Definition: intsafe.h:59
#define XOFFILE_FORMAT_FLOAT_BITS_32
Definition: parsing.c:46
#define DXFILEERR_BADFILEFLOATSIZE
Definition: dxfile.h:283
#define DXFILEERR_BADALLOC
Definition: dxfile.h:274
#define DXFILEERR_BADFILEVERSION
Definition: dxfile.h:282
#define TRACE_ON(x)
Definition: compat.h:65
#define XOFFILE_FORMAT_BINARY_MSZIP
Definition: parsing.c:43
#define HeapFree(x, y, z)
Definition: compat.h:394
struct CFHEADER header
Definition: fdi.c:109
#define XOFFILE_FORMAT_FLOAT_BITS_64
Definition: parsing.c:47
#define XOFFILE_FORMAT_VERSION_303
Definition: parsing.c:40

Referenced by IDirectXFileImpl_CreateEnumObject(), and IDirectXFileImpl_RegisterTemplates().

◆ parse_object()

BOOL parse_object ( parse_buffer buf)

Definition at line 1380 of file parsing.c.

1381 {
1382  ULONG i;
1383 
1384  buf->pxo->pos_data = buf->cur_pos_data;
1385  buf->pxo->ptarget = NULL;
1386  buf->pxo->binary = FALSE;
1387  buf->pxo->root = buf->pxo_tab;
1388 
1389  if (get_TOKEN(buf) != TOKEN_NAME)
1390  return FALSE;
1391 
1392  /* To do template lookup */
1393  for (i = 0; i < buf->pdxf->nb_xtemplates; i++)
1394  {
1395  if (!strcasecmp((char*)buf->value, buf->pdxf->xtemplates[i].name))
1396  {
1397  buf->pxt[buf->level] = &buf->pdxf->xtemplates[i];
1398  memcpy(&buf->pxo->type, &buf->pdxf->xtemplates[i].class_id, 16);
1399  break;
1400  }
1401  }
1402  if (i == buf->pdxf->nb_xtemplates)
1403  {
1404  ERR("Unknown template %s\n", (char*)buf->value);
1405  return FALSE;
1406  }
1407 
1408  if (check_TOKEN(buf) == TOKEN_NAME)
1409  {
1410  get_TOKEN(buf);
1411  strcpy(buf->pxo->name, (char*)buf->value);
1412  }
1413  else
1414  buf->pxo->name[0] = 0;
1415 
1416  if (get_TOKEN(buf) != TOKEN_OBRACE)
1417  return FALSE;
1418  if (check_TOKEN(buf) == TOKEN_GUID)
1419  {
1420  get_TOKEN(buf);
1421  memcpy(&buf->pxo->class_id, buf->value, 16);
1422  }
1423  else
1424  memset(&buf->pxo->class_id, 0, 16);
1425 
1426  if (!parse_object_parts(buf, TRUE))
1427  return FALSE;
1428  if (get_TOKEN(buf) != TOKEN_CBRACE)
1429  return FALSE;
1430 
1431  /* For seeking to a possibly eof to avoid parsing another object next time */
1432  check_TOKEN(buf);
1433 
1434  return TRUE;
1435 }
#define TRUE
Definition: types.h:120
#define strcasecmp
Definition: fake.h:9
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TOKEN_OBRACE
Definition: parsing.c:57
static WORD check_TOKEN(parse_buffer *buf)
Definition: parsing.c:876
#define TOKEN_GUID
Definition: parsing.c:54
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
smooth NULL
Definition: ftsmooth.c:416
static BOOL parse_object_parts(parse_buffer *buf, BOOL allow_optional)
Definition: parsing.c:1294
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERR(fmt,...)
Definition: debug.h:109
#define TOKEN_NAME
Definition: parsing.c:51
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned int ULONG
Definition: retypes.h:1
#define TOKEN_CBRACE
Definition: parsing.c:58
static WORD get_TOKEN(parse_buffer *buf)
Definition: parsing.c:863
#define memset(x, y, z)
Definition: compat.h:39

Referenced by IDirectXFileEnumObjectImpl_GetNextDataObject(), and parse_object_parts().

◆ parse_object_members_list()

static BOOL parse_object_members_list ( parse_buffer buf)
static

Definition at line 1140 of file parsing.c.

1141 {
1142  DWORD token;
1143  ULONG i;
1144  xtemplate* pt = buf->pxt[buf->level];
1145 
1146  buf->pxo->nb_members = pt->nb_members;
1147 
1148  for (i = 0; i < pt->nb_members; i++)
1149  {
1150  ULONG k;
1151  ULONG nb_elems = 1;
1152  BOOL basic_type = TRUE;
1153 
1154  buf->pxo->members[i].name = pt->members[i].name;
1155  buf->pxo->members[i].start = buf->cur_pos_data;
1156 
1157  for (k = 0; k < pt->members[i].nb_dims; k++)
1158  {
1159  if (pt->members[i].dim_fixed[k])
1160  nb_elems *= pt->members[i].dim_value[k];
1161  else
1162  nb_elems *= *(DWORD*)(buf->pxo->root->pdata + buf->pxo->members[pt->members[i].dim_value[k]].start);
1163  }
1164 
1165  TRACE("Elements to consider: %u\n", nb_elems);
1166 
1167  for (k = 0; k < nb_elems; k++)
1168  {
1169  if (pt->members[i].type == TOKEN_NAME)
1170  {
1171  ULONG j;
1172 
1173  TRACE("Found sub-object %s\n", buf->pdxf->xtemplates[pt->members[i].idx_template].name);
1174  basic_type = FALSE;
1175  buf->level++;
1176  /* To do template lookup */
1177  for (j = 0; j < buf->pdxf->nb_xtemplates; j++)
1178  {
1179  if (!strcasecmp(buf->pdxf->xtemplates[pt->members[i].idx_template].name, buf->pdxf->xtemplates[j].name))
1180  {
1181  buf->pxt[buf->level] = &buf->pdxf->xtemplates[j];
1182  break;
1183  }
1184  }
1185  if (j == buf->pdxf->nb_xtemplates)
1186  {
1187  ERR("Unknown template %s\n", (char*)buf->value);
1188  buf->level--;
1189  return FALSE;
1190  }
1191  TRACE("Enter %s\n", buf->pdxf->xtemplates[pt->members[i].idx_template].name);
1192  if (!parse_object_parts(buf, FALSE))
1193  {
1194  buf->level--;
1195  return FALSE;
1196  }
1197  buf->level--;
1198  }
1199  else
1200  {
1201  token = check_TOKEN(buf);
1202  if (token == TOKEN_INTEGER)
1203  {
1204  get_TOKEN(buf);
1205  TRACE("%s = %d\n", pt->members[i].name, *(DWORD*)buf->value);
1206  /* Assume larger size */
1207  if (!check_buffer(buf, 4))
1208  return FALSE;
1209  if (pt->members[i].type == TOKEN_WORD)
1210  {
1211  *(((WORD*)(buf->pdata + buf->cur_pos_data))) = (WORD)(*(DWORD*)buf->value);
1212  buf->cur_pos_data += 2;
1213  }
1214  else if (pt->members[i].type == TOKEN_DWORD)
1215  {
1216  *(((DWORD*)(buf->pdata + buf->cur_pos_data))) = (DWORD)(*(DWORD*)buf->value);
1217  buf->cur_pos_data += 4;
1218  }
1219  else
1220  {
1221  FIXME("Token %d not supported\n", pt->members[i].type);
1222  return FALSE;
1223  }
1224  }
1225  else if (token == TOKEN_FLOAT)
1226  {
1227  get_TOKEN(buf);
1228  TRACE("%s = %f\n", pt->members[i].name, *(float*)buf->value);
1229  if (!check_buffer(buf, 4))
1230  return FALSE;
1231  if (pt->members[i].type == TOKEN_FLOAT)
1232  {
1233  *(((float*)(buf->pdata + buf->cur_pos_data))) = (float)(*(float*)buf->value);
1234  buf->cur_pos_data += 4;
1235  }
1236  else
1237  {
1238  FIXME("Token %d not supported\n", pt->members[i].type);
1239  return FALSE;
1240  }
1241  }
1242  else if (token == TOKEN_LPSTR)
1243  {
1244  get_TOKEN(buf);
1245  TRACE("%s = %s\n", pt->members[i].name, (char*)buf->value);
1246  if (!check_buffer(buf, sizeof(LPSTR)))
1247  return FALSE;
1248  if (pt->members[i].type == TOKEN_LPSTR)
1249  {
1250  int len = strlen((char*)buf->value) + 1;
1251  if ((buf->cur_pstrings - buf->pstrings + len) > MAX_STRINGS_BUFFER)
1252  {
1253  FIXME("Buffer too small %p %p %d\n", buf->cur_pstrings, buf->pstrings, len);
1254  return FALSE;
1255  }
1256  strcpy((char*)buf->cur_pstrings, (char*)buf->value);
1257  *(((LPCSTR*)(buf->pdata + buf->cur_pos_data))) = (char*)buf->cur_pstrings;
1258  buf->cur_pstrings += len;
1259  buf->cur_pos_data += sizeof(LPSTR);
1260  }
1261  else
1262  {
1263  FIXME("Token %d not supported\n", pt->members[i].type);
1264  return FALSE;
1265  }
1266  }
1267  else
1268  {
1269  WARN("Unexpected token %d\n", token);
1270  return FALSE;
1271  }
1272  }
1273 
1274  if (basic_type)
1275  {
1276  /* Handle separator only for basic types */
1277  token = check_TOKEN(buf);
1278  if ((token != TOKEN_COMMA) && (token != TOKEN_SEMICOLON))
1279  return FALSE;
1280  /* Allow multi-semicolons + single comma separator */
1281  while (check_TOKEN(buf) == TOKEN_SEMICOLON)
1282  get_TOKEN(buf);
1283  if (check_TOKEN(buf) == TOKEN_COMMA)
1284  get_TOKEN(buf);
1285  }
1286  }
1287 
1288  buf->pxo->members[i].size = buf->cur_pos_data - buf->pxo->members[i].start;
1289  }
1290 
1291  return TRUE;
1292 }
char * name
Definition: wpp.c:36
#define MAX_STRINGS_BUFFER
#define TRUE
Definition: types.h:120
#define strcasecmp
Definition: fake.h:9
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define pt(x, y)
Definition: drawing.c:79
#define WARN(fmt,...)
Definition: debug.h:111
char * LPSTR
Definition: xmlstorage.h:182
#define DWORD
Definition: nt_native.h:44
static WORD check_TOKEN(parse_buffer *buf)
Definition: parsing.c:876
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
unsigned int BOOL
Definition: ntddk_ex.h:94
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 token
Definition: glfuncs.h:210
#define FIXME(fmt,...)
Definition: debug.h:110
#define TOKEN_WORD
Definition: parsing.c:69
const char * LPCSTR
Definition: xmlstorage.h:183
#define TOKEN_SEMICOLON
Definition: parsing.c:67
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 GLint GLint j
Definition: glfuncs.h:250
static BOOL check_buffer(parse_buffer *buf, ULONG size)
Definition: parsing.c:1120
#define TRACE(s)
Definition: solgame.cpp:4
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
static BOOL parse_object_parts(parse_buffer *buf, BOOL allow_optional)
Definition: parsing.c:1294
#define TOKEN_LPSTR
Definition: parsing.c:78
GLenum GLsizei len
Definition: glext.h:6722
#define ERR(fmt,...)
Definition: debug.h:109
#define TOKEN_COMMA
Definition: parsing.c:66
#define TOKEN_FLOAT
Definition: parsing.c:71
#define TOKEN_NAME
Definition: parsing.c:51
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
unsigned int ULONG
Definition: retypes.h:1
#define TOKEN_DWORD
Definition: parsing.c:70
#define TOKEN_INTEGER
Definition: parsing.c:53
static WORD get_TOKEN(parse_buffer *buf)
Definition: parsing.c:863
int k
Definition: mpi.c:3369

Referenced by parse_object_parts().

◆ parse_object_parts()

static BOOL parse_object_parts ( parse_buffer buf,
BOOL  allow_optional 
)
static

Definition at line 1294 of file parsing.c.

1295 {
1296  buf->pxo->nb_children = 0;
1297 
1299  return FALSE;
1300 
1301  if (allow_optional)
1302  {
1303  buf->pxo->size = buf->cur_pos_data - buf->pxo->pos_data;
1304 
1305  while (1)
1306  {
1307  if (check_TOKEN(buf) == TOKEN_OBRACE)
1308  {
1309  ULONG i, j;
1310  get_TOKEN(buf);
1311  if (get_TOKEN(buf) != TOKEN_NAME)
1312  return FALSE;
1313  if (get_TOKEN(buf) != TOKEN_CBRACE)
1314  return FALSE;
1315  TRACE("Found optional reference %s\n", (char*)buf->value);
1316  for (i = 0; i < (buf->nb_pxo_globals+1); i++)
1317  {
1318  for (j = 0; j < (buf->pxo_globals[i])[0].nb_subobjects; j++)
1319  {
1320  if (!strcmp((buf->pxo_globals[i])[j].name, (char*)buf->value))
1321  goto _exit;
1322  }
1323  }
1324 _exit:
1325  if (i == (buf->nb_pxo_globals+1))
1326  {
1327  ERR("Reference to unknown object %s\n", (char*)buf->value);
1328  return FALSE;
1329  }
1330 
1331  if (buf->pxo->root->nb_subobjects >= MAX_SUBOBJECTS)
1332  {
1333  FIXME("Too many sub-objects\n");
1334  return FALSE;
1335  }
1336 
1337  buf->pxo->children[buf->pxo->nb_children] = &buf->pxo_tab[buf->pxo->root->nb_subobjects++];
1338  buf->pxo->children[buf->pxo->nb_children]->ptarget = &(buf->pxo_globals[i])[j];
1339  buf->pxo->children[buf->pxo->nb_children]->binary = FALSE;
1340  buf->pxo->nb_children++;
1341  }
1342  else if (check_TOKEN(buf) == TOKEN_NAME)
1343  {
1344  xobject* pxo = buf->pxo;
1345 
1346  if (buf->pxo->root->nb_subobjects >= MAX_SUBOBJECTS)
1347  {
1348  FIXME("Too many sub-objects\n");
1349  return FALSE;
1350  }
1351 
1352  buf->pxo = buf->pxo->children[buf->pxo->nb_children] = &buf->pxo_tab[buf->pxo->root->nb_subobjects];
1353  pxo->root->nb_subobjects++;
1354 
1355  TRACE("Enter optional %s\n", (char*)buf->value);
1356  buf->level++;
1357  if (!parse_object(buf))
1358  {
1359  buf->level--;
1360  return FALSE;
1361  }
1362  buf->level--;
1363  buf->pxo = pxo;
1364  buf->pxo->nb_children++;
1365  }
1366  else
1367  break;
1368  }
1369  }
1370 
1371  if (buf->pxo->nb_children > MAX_CHILDREN)
1372  {
1373  FIXME("Too many children %d\n", buf->pxo->nb_children);
1374  return FALSE;
1375  }
1376 
1377  return TRUE;
1378 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TOKEN_OBRACE
Definition: parsing.c:57
static WORD check_TOKEN(parse_buffer *buf)
Definition: parsing.c:876
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 FIXME(fmt,...)
Definition: debug.h:110
void _exit(int exitcode)
Definition: _exit.c:25
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 GLint GLint j
Definition: glfuncs.h:250
#define TRACE(s)
Definition: solgame.cpp:4
#define MAX_SUBOBJECTS
#define ERR(fmt,...)
Definition: debug.h:109
static BOOL parse_object_members_list(parse_buffer *buf)
Definition: parsing.c:1140
#define MAX_CHILDREN
_In_ XLATEOBJ _In_ XFORMOBJ * pxo
Definition: winddi.h:3810
#define TOKEN_NAME
Definition: parsing.c:51
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define TOKEN_CBRACE
Definition: parsing.c:58
static WORD get_TOKEN(parse_buffer *buf)
Definition: parsing.c:863
BOOL parse_object(parse_buffer *buf)
Definition: parsing.c:1380

Referenced by parse_object(), and parse_object_members_list().

◆ parse_template()

static BOOL parse_template ( parse_buffer buf)
static

Definition at line 1076 of file parsing.c.

1077 {
1078  if (get_TOKEN(buf) != TOKEN_TEMPLATE)
1079  return FALSE;
1080  if (get_TOKEN(buf) != TOKEN_NAME)
1081  return FALSE;
1082  strcpy(buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].name, (char*)buf->value);
1083  if (get_TOKEN(buf) != TOKEN_OBRACE)
1084  return FALSE;
1085  if (get_TOKEN(buf) != TOKEN_GUID)
1086  return FALSE;
1087  buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].class_id = *(GUID*)buf->value;
1089  return FALSE;
1090  if (get_TOKEN(buf) != TOKEN_CBRACE)
1091  return FALSE;
1092 
1093  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));
1094  buf->pdxf->nb_xtemplates++;
1095 
1096  return TRUE;
1097 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define TOKEN_OBRACE
Definition: parsing.c:57
#define TOKEN_GUID
Definition: parsing.c:54
#define TOKEN_TEMPLATE
Definition: parsing.c:68
static BOOL parse_template_parts(parse_buffer *buf)
Definition: parsing.c:1060
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define TOKEN_NAME
Definition: parsing.c:51
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define TOKEN_CBRACE
Definition: parsing.c:58
static WORD get_TOKEN(parse_buffer *buf)
Definition: parsing.c:863

Referenced by parse_templates().

◆ parse_template_members_list()

static BOOL parse_template_members_list ( parse_buffer buf)
static

Definition at line 945 of file parsing.c.

946 {
947  int idx_member = 0;
948  member* cur_member;
949 
950  while (1)
951  {
952  BOOL array = FALSE;
953  int nb_dims = 0;
954  cur_member = &buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[idx_member];
955 
956  if (check_TOKEN(buf) == TOKEN_ARRAY)
957  {
958  get_TOKEN(buf);
959  array = TRUE;
960  }
961 
962  if (check_TOKEN(buf) == TOKEN_NAME)
963  {
964  cur_member->type = get_TOKEN(buf);
965  if (!strcmp((char*)buf->value, "indexColor"))
966  {
967  /* Case sensitive legacy type indexColor is described in the first template */
968  cur_member->idx_template = 0;
969  }
970  else
971  {
972  cur_member->idx_template = 1;
973  while (cur_member->idx_template < buf->pdxf->nb_xtemplates)
974  {
975  if (!strcasecmp((char*)buf->value, buf->pdxf->xtemplates[cur_member->idx_template].name))
976  break;
977  cur_member->idx_template++;
978  }
979  if (cur_member->idx_template == buf->pdxf->nb_xtemplates)
980  {
981  WARN("Reference to a nonexistent template '%s'\n", (char*)buf->value);
982  return FALSE;
983  }
984  }
985  }
986  else if (is_primitive_type(check_TOKEN(buf)))
987  cur_member->type = get_TOKEN(buf);
988  else
989  break;
990 
991  if (get_TOKEN(buf) != TOKEN_NAME)
992  return FALSE;
993  strcpy(cur_member->name, (char*)buf->value);
994 
995  if (array)
996  {
997  while (check_TOKEN(buf) == TOKEN_OBRACKET)
998  {
999  if (nb_dims >= MAX_ARRAY_DIM)
1000  {
1001  FIXME("Too many dimensions (%d) for multi-dimensional array\n", nb_dims + 1);
1002  return FALSE;
1003  }
1004  get_TOKEN(buf);
1005  if (check_TOKEN(buf) == TOKEN_INTEGER)
1006  {
1007  get_TOKEN(buf);
1008  cur_member->dim_fixed[nb_dims] = TRUE;
1009  cur_member->dim_value[nb_dims] = *(DWORD*)buf->value;
1010  }
1011  else
1012  {
1013  int i;
1014  if (get_TOKEN(buf) != TOKEN_NAME)
1015  return FALSE;
1016  for (i = 0; i < idx_member; i++)
1017  {
1018  if (!strcmp((char*)buf->value, buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[i].name))
1019  {
1020  if (buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[i].nb_dims)
1021  {
1022  ERR("Array cannot be used to specify variable array size\n");
1023  return FALSE;
1024  }
1025  if (buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[i].type != TOKEN_DWORD)
1026  {
1027  FIXME("Only DWORD supported to specify variable array size\n");
1028  return FALSE;
1029  }
1030  break;
1031  }
1032  }
1033  if (i == idx_member)
1034  {
1035  ERR("Reference to unknown member %s\n", (char*)buf->value);
1036  return FALSE;
1037  }
1038  cur_member->dim_fixed[nb_dims] = FALSE;
1039  cur_member->dim_value[nb_dims] = i;
1040  }
1041  if (get_TOKEN(buf) != TOKEN_CBRACKET)
1042  return FALSE;
1043  nb_dims++;
1044  }
1045  if (!nb_dims)
1046  return FALSE;
1047  cur_member->nb_dims = nb_dims;
1048  }
1049  if (get_TOKEN(buf) != TOKEN_SEMICOLON)
1050  return FALSE;
1051 
1052  idx_member++;
1053  }
1054 
1055  buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].nb_members = idx_member;
1056 
1057  return TRUE;
1058 }
#define TRUE
Definition: types.h:120
#define strcasecmp
Definition: fake.h:9
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define WARN(fmt,...)
Definition: debug.h:111
ULONG dim_value[MAX_ARRAY_DIM]
static WORD check_TOKEN(parse_buffer *buf)
Definition: parsing.c:876
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
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:110
#define TOKEN_CBRACKET
Definition: parsing.c:62
char name[MAX_NAME_LEN]
#define TOKEN_SEMICOLON
Definition: parsing.c:67
BOOL dim_fixed[MAX_ARRAY_DIM]
#define TOKEN_ARRAY
Definition: parsing.c:81
#define MAX_ARRAY_DIM
unsigned long DWORD
Definition: ntddk_ex.h:95
LONG idx_template
#define ERR(fmt,...)
Definition: debug.h:109
static BOOL is_primitive_type(WORD token)
Definition: parsing.c:887
DWORD type
#define TOKEN_OBRACKET
Definition: parsing.c:61
ULONG nb_dims
#define TOKEN_NAME
Definition: parsing.c:51
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define TOKEN_DWORD
Definition: parsing.c:70
#define TOKEN_INTEGER
Definition: parsing.c:53
static WORD get_TOKEN(parse_buffer *buf)
Definition: parsing.c:863

Referenced by parse_template_parts().

◆ parse_template_option_info()

static BOOL parse_template_option_info ( parse_buffer buf)
static

Definition at line 912 of file parsing.c.

913 {
914  xtemplate* cur_template = &buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates];
915 
916  if (check_TOKEN(buf) == TOKEN_DOT)
917  {
918  get_TOKEN(buf);
919  if (get_TOKEN(buf) != TOKEN_DOT)
920  return FALSE;
921  if (get_TOKEN(buf) != TOKEN_DOT)
922  return FALSE;
923  cur_template->open = TRUE;
924  }
925  else
926  {
927  while (1)
928  {
929  if (get_TOKEN(buf) != TOKEN_NAME)
930  return FALSE;
931  strcpy(cur_template->children[cur_template->nb_children], (char*)buf->value);
932  if (check_TOKEN(buf) == TOKEN_GUID)
933  get_TOKEN(buf);
934  cur_template->nb_children++;
935  if (check_TOKEN(buf) != TOKEN_COMMA)
936  break;
937  get_TOKEN(buf);
938  }
939  cur_template->open = FALSE;
940  }
941 
942  return TRUE;
943 }
char children[MAX_CHILDREN][MAX_NAME_LEN]
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static WORD check_TOKEN(parse_buffer *buf)
Definition: parsing.c:876
#define TOKEN_GUID
Definition: parsing.c:54
ULONG nb_children
#define TOKEN_COMMA
Definition: parsing.c:66
#define TOKEN_NAME
Definition: parsing.c:51
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define TOKEN_DOT
Definition: parsing.c:65
static WORD get_TOKEN(parse_buffer *buf)
Definition: parsing.c:863

Referenced by parse_template_parts().

◆ parse_template_parts()

static BOOL parse_template_parts ( parse_buffer buf)
static

Definition at line 1060 of file parsing.c.

1061 {
1063  return FALSE;
1064  if (check_TOKEN(buf) == TOKEN_OBRACKET)
1065  {
1066  get_TOKEN(buf);
1068  return FALSE;
1069  if (get_TOKEN(buf) != TOKEN_CBRACKET)
1070  return FALSE;
1071  }
1072 
1073  return TRUE;
1074 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static WORD check_TOKEN(parse_buffer *buf)
Definition: parsing.c:876
#define TOKEN_CBRACKET
Definition: parsing.c:62
static BOOL parse_template_members_list(parse_buffer *buf)
Definition: parsing.c:945
#define TOKEN_OBRACKET
Definition: parsing.c:61
static BOOL parse_template_option_info(parse_buffer *buf)
Definition: parsing.c:912
static WORD get_TOKEN(parse_buffer *buf)
Definition: parsing.c:863

Referenced by parse_template().

◆ parse_templates()

BOOL parse_templates ( parse_buffer buf,
BOOL  templates_only 
)

Definition at line 1099 of file parsing.c.

1100 {
1101  while (check_TOKEN(buf) != TOKEN_NONE)
1102  {
1103  if (templates_only && (check_TOKEN(buf) != TOKEN_TEMPLATE))
1104  return TRUE;
1105  if (!parse_template(buf))
1106  {
1107  WARN("Template is not correct\n");
1108  return FALSE;
1109  }
1110  else
1111  {
1112  TRACE("Template successfully parsed:\n");
1113  if (TRACE_ON(d3dxof_parsing))
1114  dump_template(buf->pdxf->xtemplates, &buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates - 1]);
1115  }
1116  }
1117  return TRUE;
1118 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define WARN(fmt,...)
Definition: debug.h:111
static BOOL parse_template(parse_buffer *buf)
Definition: parsing.c:1076
static WORD check_TOKEN(parse_buffer *buf)
Definition: parsing.c:876
#define TOKEN_NONE
Definition: parsing.c:50
#define TOKEN_TEMPLATE
Definition: parsing.c:68
#define TRACE(s)
Definition: solgame.cpp:4
static void dump_template(xtemplate *templates_array, xtemplate *ptemplate)
Definition: parsing.c:128
#define TRACE_ON(x)
Definition: compat.h:65

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

◆ parse_TOKEN()

static WORD parse_TOKEN ( parse_buffer buf)
static

Definition at line 640 of file parsing.c.

641 {
642  WORD token;
643 
644  if (buf->txt)
645  {
646  while(1)
647  {
648  char c;
649  if (!read_bytes(buf, &c, 1))
650  return TOKEN_NONE;
651  if ((c == '#') || (c == '/'))
652  {
653  /* Handle comment (# or //) */
654  if (c == '/')
655  {
656  if (!read_bytes(buf, &c, 1))
657  return TOKEN_ERROR;
658  if (c != '/')
659  return TOKEN_ERROR;
660  }
661  c = 0;
662  while (c != 0x0A)
663  {
664  if (!read_bytes(buf, &c, 1))
665  return TOKEN_NONE;
666  }
667  continue;
668  }
669  if (is_space(c))
670  continue;
671  if (is_operator(c) && (c != '<'))
672  {
674  break;
675  }
676  else if (c == '.')
677  {
678  token = TOKEN_DOT;
679  break;
680  }
681  else
682  {
683  rewind_bytes(buf, 1);
684 
685  if ((token = get_keyword_token(buf)))
686  break;
687 
688  if (is_guid(buf))
689  {
690  token = TOKEN_GUID;
691  break;
692  }
693  if (is_integer(buf))
694  {
696  break;
697  }
698  if (is_float(buf))
699  {
700  token = TOKEN_FLOAT;
701  break;
702  }
703  if (is_string(buf))
704  {
705  token = TOKEN_LPSTR;
706  break;
707  }
708  if (is_name(buf))
709  {
710  token = TOKEN_NAME;
711  break;
712  }
713 
714  FIXME("Unrecognize element\n");
715  return TOKEN_ERROR;
716  }
717  }
718  }
719  else
720  {
721  if (!buf->list_nb_elements)
722  {
723  if (!read_bytes(buf, &token, 2))
724  return TOKEN_NONE;
725 
726  /* Convert integer and float list into separate elements */
727  if (token == TOKEN_INTEGER_LIST)
728  {
729  if (!read_bytes(buf, &buf->list_nb_elements, 4))
730  return TOKEN_ERROR;
732  buf->list_type_float = FALSE;
733  TRACE("Integer list (TOKEN_INTEGER_LIST) of size %d\n", buf->list_nb_elements);
734  }
735  else if (token == TOKEN_FLOAT_LIST)
736  {
737  if (!read_bytes(buf, &buf->list_nb_elements, 4))
738  return TOKEN_ERROR;
739  token = TOKEN_FLOAT;
740  buf->list_type_float = TRUE;
741  TRACE("Float list (TOKEN_FLOAT_LIST) of size %d\n", buf->list_nb_elements);
742  }
743  }
744 
745  if (buf->list_nb_elements)
746  {
747  if (buf->list_separator)
748  {
749  buf->list_nb_elements--;
750  buf->list_separator = FALSE;
751  /* Insert separator between each value, and since list does not accept separator at the end
752  use a comma so any extra separator will generate an error */
753  token = TOKEN_COMMA;
754  }
755  else
756  {
757  DWORD value;
758 
759  if (!read_bytes(buf, &value, 4))
760  return TOKEN_ERROR;
761  *(DWORD*)buf->value = value;
762 
763  buf->list_separator = TRUE;
764  /* Convert list into a series of their basic type counterpart */
765  token = buf->list_type_float ? TOKEN_FLOAT : TOKEN_INTEGER;
766  }
767  dump_TOKEN(token);
768  return token;
769  }
770 
771  switch (token)
772  {
773  case TOKEN_NAME:
774  {
775  DWORD count;
776  char *name = (char*)buf->value;
777 
778  if (!read_bytes(buf, &count, 4))
779  return TOKEN_ERROR;
780  if (!read_bytes(buf, name, count))
781  return TOKEN_ERROR;
782  name[count] = 0;
783  TRACE("name = %s\n", name);
784  }
785  break;
786  case TOKEN_INTEGER:
787  {
788  DWORD integer;
789 
790  if (!read_bytes(buf, &integer, 4))
791  return TOKEN_ERROR;
792  TRACE("integer = %u\n", integer);
793 
794  *(DWORD*)buf->value = integer;
795  }
796  break;
797  case TOKEN_GUID:
798  {
799  char strguid[39];
800  GUID class_id;
801 
802  if (!read_bytes(buf, &class_id, 16))
803  return TOKEN_ERROR;
804  sprintf(strguid, CLSIDFMT, class_id.Data1, class_id.Data2, class_id.Data3, class_id.Data4[0],
805  class_id.Data4[1], class_id.Data4[2], class_id.Data4[3], class_id.Data4[4], class_id.Data4[5],
806  class_id.Data4[6], class_id.Data4[7]);
807  TRACE("guid = %s\n", strguid);
808 
809  *(GUID*)buf->value = class_id;
810  }
811  break;
812  case TOKEN_STRING:
813  {
814  DWORD count;
815  char *string = (char*)buf->value;
816 
817  if (!read_bytes(buf, &count, 4))
818  return TOKEN_ERROR;
819  if (!read_bytes(buf, string, count))
820  return TOKEN_ERROR;
821  string[count] = 0;
822  TRACE("string = %s\n", string);
823 
824  token = TOKEN_LPSTR;
825  }
826  break;
827  case TOKEN_OBRACE:
828  case TOKEN_CBRACE:
829  case TOKEN_OPAREN:
830  case TOKEN_CPAREN:
831  case TOKEN_OBRACKET:
832  case TOKEN_CBRACKET:
833  case TOKEN_OANGLE:
834  case TOKEN_CANGLE:
835  case TOKEN_DOT:
836  case TOKEN_COMMA:
837  case TOKEN_SEMICOLON:
838  case TOKEN_TEMPLATE:
839  case TOKEN_WORD:
840  case TOKEN_DWORD:
841  case TOKEN_FLOAT:
842  case TOKEN_DOUBLE:
843  case TOKEN_CHAR:
844  case TOKEN_UCHAR:
845  case TOKEN_SWORD:
846  case TOKEN_SDWORD:
847  case TOKEN_VOID:
848  case TOKEN_LPSTR:
849  case TOKEN_UNICODE:
850  case TOKEN_CSTRING:
851  case TOKEN_ARRAY:
852  break;
853  default:
854  return TOKEN_ERROR;
855  }
856  }
857 
858  dump_TOKEN(token);
859 
860  return token;
861 }
#define TOKEN_DOUBLE
Definition: parsing.c:72
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
static BOOL is_guid(parse_buffer *buf)
Definition: parsing.c:459
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define TOKEN_OBRACE
Definition: parsing.c:57
static BOOL is_space(char c)
Definition: parsing.c:335
static BOOL is_string(parse_buffer *buf)
Definition: parsing.c:601
static BOOL read_bytes(parse_buffer *buf, LPVOID data, DWORD size)
Definition: parsing.c:169
char * value
Definition: wpp.c:37
#define TOKEN_CSTRING
Definition: parsing.c:80
#define TOKEN_NONE
Definition: parsing.c:50
#define TOKEN_GUID
Definition: parsing.c:54
#define sprintf(buf, format,...)
Definition: sprintf.c:55
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 token
Definition: glfuncs.h:210
#define FIXME(fmt,...)
Definition: debug.h:110
#define TOKEN_WORD
Definition: parsing.c:69
#define TOKEN_TEMPLATE
Definition: parsing.c:68
#define TOKEN_CBRACKET
Definition: parsing.c:62
#define TOKEN_SWORD
Definition: parsing.c:75
#define TOKEN_UCHAR
Definition: parsing.c:74
#define TOKEN_SEMICOLON
Definition: parsing.c:67
#define TOKEN_SDWORD
Definition: parsing.c:76
#define TOKEN_INTEGER_LIST
Definition: parsing.c:55
static void rewind_bytes(parse_buffer *buf, DWORD size)
Definition: parsing.c:179
#define TRACE(s)
Definition: solgame.cpp:4
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define TOKEN_ARRAY
Definition: parsing.c:81
#define TOKEN_CHAR
Definition: parsing.c:73
const GLubyte * c
Definition: glext.h:8905
#define CLSIDFMT
Definition: parsing.c:83
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TOKEN_ERROR
Definition: parsing.c:49
#define TOKEN_LPSTR
Definition: parsing.c:78
#define TOKEN_VOID
Definition: parsing.c:77
GLsizei const GLfloat * value
Definition: glext.h:6069
#define TOKEN_OANGLE
Definition: parsing.c:63
static WORD get_operator_token(char c)
Definition: parsing.c:373
#define TOKEN_OBRACKET
Definition: parsing.c:61
static void dump_TOKEN(WORD token)
Definition: parsing.c:291
#define TOKEN_UNICODE
Definition: parsing.c:79
#define TOKEN_COMMA
Definition: parsing.c:66
#define TOKEN_FLOAT
Definition: parsing.c:71
Definition: name.c:36
#define TOKEN_NAME
Definition: parsing.c:51
#define c
Definition: ke_i.h:80
#define TOKEN_FLOAT_LIST
Definition: parsing.c:56
#define TOKEN_CANGLE
Definition: parsing.c:64
#define TOKEN_DWORD
Definition: parsing.c:70
static BOOL is_name(parse_buffer *buf)
Definition: parsing.c:509
#define TOKEN_DOT
Definition: parsing.c:65
#define TOKEN_INTEGER
Definition: parsing.c:53
#define TOKEN_CBRACE
Definition: parsing.c:58
static BOOL is_float(parse_buffer *buf)
Definition: parsing.c:540
#define TOKEN_OPAREN
Definition: parsing.c:59
static WORD get_keyword_token(parse_buffer *buf)
Definition: parsing.c:425
#define TOKEN_CPAREN
Definition: parsing.c:60
#define TOKEN_STRING
Definition: parsing.c:52
static BOOL is_integer(parse_buffer *buf)
Definition: parsing.c:572
static BOOL is_operator(char c)
Definition: parsing.c:349

Referenced by check_TOKEN(), and get_TOKEN().

◆ read_bytes()

static BOOL read_bytes ( parse_buffer buf,
LPVOID  data,
DWORD  size 
)
static

Definition at line 169 of file parsing.c.

170 {
171  if (buf->rem_bytes < size)
172  return FALSE;
173  memcpy(data, buf->buffer, size);
174  buf->buffer += size;
175  buf->rem_bytes -= size;
176  return TRUE;
177 }
#define TRUE
Definition: types.h:120
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizeiptr size
Definition: glext.h:5919
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by _fgets(), _overlapped_read_async(), _overlapped_read_sync(), async_read_file_proc(), chunked_read(), FT_Stream_EnterFrame(), FT_Stream_ReadAt(), FT_Stream_TryRead(), is_keyword(), parse_header(), parse_TOKEN(), refill_read_buffer(), test_OpenProcess(), and test_overlapped_transport().

◆ rewind_bytes()

static void rewind_bytes ( parse_buffer buf,
DWORD  size 
)
static

Definition at line 179 of file parsing.c.

180 {
181  buf->buffer -= size;
182  buf->rem_bytes += size;
183 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLsizeiptr size
Definition: glext.h:5919

Referenced by is_keyword(), and parse_TOKEN().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3dxof_parsing  )