ReactOS 0.4.17-dev-806-gffa4164
parsing.c File Reference
#include "wine/debug.h"
#include "winbase.h"
#include "wingdi.h"
#include "wine/winternl.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 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 82 of file parsing.c.

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 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 36 of file parsing.c.

◆ TOKEN_ARRAY

#define TOKEN_ARRAY   52

Definition at line 80 of file parsing.c.

◆ TOKEN_CANGLE

#define TOKEN_CANGLE   17

Definition at line 63 of file parsing.c.

◆ TOKEN_CBRACE

#define TOKEN_CBRACE   11

Definition at line 57 of file parsing.c.

◆ TOKEN_CBRACKET

#define TOKEN_CBRACKET   15

Definition at line 61 of file parsing.c.

◆ TOKEN_CHAR

#define TOKEN_CHAR   44

Definition at line 72 of file parsing.c.

◆ TOKEN_COMMA

#define TOKEN_COMMA   19

Definition at line 65 of file parsing.c.

◆ TOKEN_CPAREN

#define TOKEN_CPAREN   13

Definition at line 59 of file parsing.c.

◆ TOKEN_CSTRING

#define TOKEN_CSTRING   51

Definition at line 79 of file parsing.c.

◆ TOKEN_DOT

#define TOKEN_DOT   18

Definition at line 64 of file parsing.c.

◆ TOKEN_DOUBLE

#define TOKEN_DOUBLE   43

Definition at line 71 of file parsing.c.

◆ TOKEN_DWORD

#define TOKEN_DWORD   41

Definition at line 69 of file parsing.c.

◆ TOKEN_ERROR

#define TOKEN_ERROR   0xffff

Definition at line 48 of file parsing.c.

◆ TOKEN_FLOAT

#define TOKEN_FLOAT   42

Definition at line 70 of file parsing.c.

◆ TOKEN_FLOAT_LIST

#define TOKEN_FLOAT_LIST   7

Definition at line 55 of file parsing.c.

◆ TOKEN_GUID

#define TOKEN_GUID   5

Definition at line 53 of file parsing.c.

◆ TOKEN_INTEGER

#define TOKEN_INTEGER   3

Definition at line 52 of file parsing.c.

◆ TOKEN_INTEGER_LIST

#define TOKEN_INTEGER_LIST   6

Definition at line 54 of file parsing.c.

◆ TOKEN_LPSTR

#define TOKEN_LPSTR   49

Definition at line 77 of file parsing.c.

◆ TOKEN_NAME

#define TOKEN_NAME   1

Definition at line 50 of file parsing.c.

◆ TOKEN_NONE

#define TOKEN_NONE   0

Definition at line 49 of file parsing.c.

◆ TOKEN_OANGLE

#define TOKEN_OANGLE   16

Definition at line 62 of file parsing.c.

◆ TOKEN_OBRACE

#define TOKEN_OBRACE   10

Definition at line 56 of file parsing.c.

◆ TOKEN_OBRACKET

#define TOKEN_OBRACKET   14

Definition at line 60 of file parsing.c.

◆ TOKEN_OPAREN

#define TOKEN_OPAREN   12

Definition at line 58 of file parsing.c.

◆ TOKEN_SDWORD

#define TOKEN_SDWORD   47

Definition at line 75 of file parsing.c.

◆ TOKEN_SEMICOLON

#define TOKEN_SEMICOLON   20

Definition at line 66 of file parsing.c.

◆ TOKEN_STRING

#define TOKEN_STRING   2

Definition at line 51 of file parsing.c.

◆ TOKEN_SWORD

#define TOKEN_SWORD   46

Definition at line 74 of file parsing.c.

◆ TOKEN_TEMPLATE

#define TOKEN_TEMPLATE   31

Definition at line 67 of file parsing.c.

◆ TOKEN_UCHAR

#define TOKEN_UCHAR   45

Definition at line 73 of file parsing.c.

◆ TOKEN_UNICODE

#define TOKEN_UNICODE   50

Definition at line 78 of file parsing.c.

◆ TOKEN_VOID

#define TOKEN_VOID   48

Definition at line 76 of file parsing.c.

◆ TOKEN_WORD

#define TOKEN_WORD   40

Definition at line 68 of file parsing.c.

◆ XOFFILE_FORMAT_BINARY

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

Definition at line 40 of file parsing.c.

◆ XOFFILE_FORMAT_BINARY_MSZIP

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

Definition at line 42 of file parsing.c.

◆ XOFFILE_FORMAT_COMPRESSED

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

Definition at line 44 of file parsing.c.

◆ XOFFILE_FORMAT_FLOAT_BITS_32

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

Definition at line 45 of file parsing.c.

◆ XOFFILE_FORMAT_FLOAT_BITS_64

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

Definition at line 46 of file parsing.c.

◆ XOFFILE_FORMAT_MAGIC

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

Definition at line 37 of file parsing.c.

◆ XOFFILE_FORMAT_TEXT

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

Definition at line 41 of file parsing.c.

◆ XOFFILE_FORMAT_TEXT_MSZIP

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

Definition at line 43 of file parsing.c.

◆ XOFFILE_FORMAT_VERSION_302

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

Definition at line 38 of file parsing.c.

◆ XOFFILE_FORMAT_VERSION_303

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

Definition at line 39 of file parsing.c.

Function Documentation

◆ check_buffer()

static BOOL check_buffer ( parse_buffer buf,
ULONG  size 
)
static

Definition at line 1110 of file parsing.c.

1111{
1112 if ((buf->cur_pos_data + size) > buf->capacity)
1113 {
1114 LPBYTE pdata;
1115 ULONG new_capacity = buf->capacity ? 2 * buf->capacity : 100000;
1116
1117 pdata = HeapAlloc(GetProcessHeap(), 0, new_capacity);
1118 if (!pdata)
1119 return FALSE;
1120 memcpy(pdata, buf->pdata, buf->cur_pos_data);
1121 HeapFree(GetProcessHeap(), 0, buf->pdata);
1122 buf->capacity = new_capacity;
1123 buf->pdata = pdata;
1124 buf->pxo->root->pdata = pdata;
1125 }
1126 return TRUE;
1127}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static PROTOCOLDATA * pdata
Definition: protocol.c:163
unsigned char * LPBYTE
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59

Referenced by parse_object_members_list(), and test_WinHttpAddHeaders().

◆ check_TOKEN()

static WORD check_TOKEN ( parse_buffer buf)
static

Definition at line 866 of file parsing.c.

867{
868 if (buf->token_present)
869 return buf->current_token;
870
871 buf->current_token = parse_TOKEN(buf);
872 buf->token_present = TRUE;
873
874 return buf->current_token;
875}
static WORD parse_TOKEN(parse_buffer *buf)
Definition: parsing.c:630

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().

◆ dump_template()

static void dump_template ( xtemplate templates_array,
xtemplate ptemplate 
)
static

Definition at line 118 of file parsing.c.

119{
120 ULONG j, k;
121 GUID* clsid;
122
123 clsid = &ptemplate->class_id;
124
125 wine_dbg_printf("template %s\n", ptemplate->name);
126 wine_dbg_printf("{\n");
127 wine_dbg_printf(CLSIDFMT "\n", clsid->Data1, clsid->Data2, clsid->Data3, clsid->Data4[0],
128 clsid->Data4[1], clsid->Data4[2], clsid->Data4[3], clsid->Data4[4], clsid->Data4[5], clsid->Data4[6], clsid->Data4[7]);
129 for (j = 0; j < ptemplate->nb_members; j++)
130 {
131 if (ptemplate->members[j].nb_dims)
132 wine_dbg_printf("array ");
133 if (ptemplate->members[j].type == TOKEN_NAME)
134 wine_dbg_printf("%s ", templates_array[ptemplate->members[j].idx_template].name);
135 else
137 wine_dbg_printf("%s", ptemplate->members[j].name);
138 for (k = 0; k < ptemplate->members[j].nb_dims; k++)
139 {
140 if (ptemplate->members[j].dim_fixed[k])
141 wine_dbg_printf("[%d]", ptemplate->members[j].dim_value[k]);
142 else
143 wine_dbg_printf("[%s]", ptemplate->members[ptemplate->members[j].dim_value[k]].name);
144 }
145 wine_dbg_printf(";\n");
146 }
147 if (ptemplate->open)
148 wine_dbg_printf("[...]\n");
149 else if (ptemplate->nb_children)
150 {
151 wine_dbg_printf("[%s", ptemplate->children[0]);
152 for (j = 1; j < ptemplate->nb_children; j++)
153 wine_dbg_printf(",%s", ptemplate->children[j]);
154 wine_dbg_printf("]\n");
155 }
156 wine_dbg_printf("}\n");
157}
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
int k
Definition: mpi.c:3369
const CLSID * clsid
Definition: msctf.cpp:50
#define TOKEN_NAME
Definition: parsing.c:50
static const char * get_primitive_string(DWORD token)
Definition: parsing.c:84
#define CLSIDFMT
Definition: parsing.c:82
const char int wine_dbg_printf(const char *format,...) __WINE_PRINTF_ATTR(1
ULONG nb_dims
LONG idx_template
BOOL dim_fixed[MAX_ARRAY_DIM]
char name[MAX_NAME_LEN]
DWORD type
ULONG dim_value[MAX_ARRAY_DIM]
member members[MAX_MEMBERS]
ULONG nb_members
ULONG nb_children
char name[MAX_NAME_LEN]
char children[MAX_CHILDREN][MAX_NAME_LEN]

Referenced by parse_templates().

◆ dump_TOKEN()

static void dump_TOKEN ( WORD  token)
static

Definition at line 281 of file parsing.c.

282{
283#define DUMP_TOKEN(t) case t: TRACE(#t "\n"); break
284 switch(token)
285 {
317 default:
318 if (0)
319 TRACE("Unknown token %d\n", token);
320 break;
321 }
322#undef DUMP_TOKEN
323}
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_GUID
Definition: parsing.c:53
#define TOKEN_LPSTR
Definition: parsing.c:77
#define TOKEN_UNICODE
Definition: parsing.c:78
#define TOKEN_INTEGER
Definition: parsing.c:52
#define TOKEN_FLOAT
Definition: parsing.c:70
#define TOKEN_VOID
Definition: parsing.c:76
#define TOKEN_CHAR
Definition: parsing.c:72
#define TOKEN_TEMPLATE
Definition: parsing.c:67
#define TOKEN_SWORD
Definition: parsing.c:74
#define TOKEN_CANGLE
Definition: parsing.c:63
#define TOKEN_CBRACKET
Definition: parsing.c:61
#define TOKEN_DWORD
Definition: parsing.c:69
#define TOKEN_OBRACE
Definition: parsing.c:56
#define TOKEN_DOUBLE
Definition: parsing.c:71
#define TOKEN_STRING
Definition: parsing.c:51
#define TOKEN_COMMA
Definition: parsing.c:65
#define TOKEN_WORD
Definition: parsing.c:68
#define TOKEN_CBRACE
Definition: parsing.c:57
#define TOKEN_OANGLE
Definition: parsing.c:62
#define TOKEN_OBRACKET
Definition: parsing.c:60
#define TOKEN_DOT
Definition: parsing.c:64
#define DUMP_TOKEN(t)
#define TOKEN_OPAREN
Definition: parsing.c:58
#define TOKEN_SEMICOLON
Definition: parsing.c:66
#define TOKEN_SDWORD
Definition: parsing.c:75
#define TOKEN_INTEGER_LIST
Definition: parsing.c:54
#define TOKEN_CPAREN
Definition: parsing.c:59
#define TOKEN_ARRAY
Definition: parsing.c:80
#define TOKEN_CSTRING
Definition: parsing.c:79
#define TOKEN_UCHAR
Definition: parsing.c:73
#define TOKEN_FLOAT_LIST
Definition: parsing.c:55
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by parse_TOKEN().

◆ get_keyword_token()

static WORD get_keyword_token ( parse_buffer buf)
static

Definition at line 415 of file parsing.c.

416{
417 if (is_keyword(buf, "template"))
418 return TOKEN_TEMPLATE;
419 if (is_keyword(buf, "WORD"))
420 return TOKEN_WORD;
421 if (is_keyword(buf, "DWORD"))
422 return TOKEN_DWORD;
423 if (is_keyword(buf, "FLOAT"))
424 return TOKEN_FLOAT;
425 if (is_keyword(buf, "DOUBLE"))
426 return TOKEN_DOUBLE;
427 if (is_keyword(buf, "CHAR"))
428 return TOKEN_CHAR;
429 if (is_keyword(buf, "UCHAR"))
430 return TOKEN_UCHAR;
431 if (is_keyword(buf, "SWORD"))
432 return TOKEN_SWORD;
433 if (is_keyword(buf, "SDWORD"))
434 return TOKEN_SDWORD;
435 if (is_keyword(buf, "VOID"))
436 return TOKEN_VOID;
437 if (is_keyword(buf, "STRING"))
438 return TOKEN_LPSTR;
439 if (is_keyword(buf, "UNICODE"))
440 return TOKEN_UNICODE;
441 if (is_keyword(buf, "CSTRING"))
442 return TOKEN_CSTRING;
443 if (is_keyword(buf, "array"))
444 return TOKEN_ARRAY;
445
446 return 0;
447}
static BOOL is_keyword(parse_buffer *buf, const char *keyword)
Definition: parsing.c:391

Referenced by parse_TOKEN().

◆ get_operator_token()

static WORD get_operator_token ( char  c)
static

Definition at line 363 of file parsing.c.

364{
365 switch(c)
366 {
367 case '{':
368 return TOKEN_OBRACE;
369 case '}':
370 return TOKEN_CBRACE;
371 case '[':
372 return TOKEN_OBRACKET;
373 case ']':
374 return TOKEN_CBRACKET;
375 case '(':
376 return TOKEN_OPAREN;
377 case ')':
378 return TOKEN_CPAREN;
379 case '<':
380 return TOKEN_OANGLE;
381 case '>':
382 return TOKEN_CANGLE;
383 case ',':
384 return TOKEN_COMMA;
385 case ';':
386 return TOKEN_SEMICOLON;
387 }
388 return 0;
389}
const GLubyte * c
Definition: glext.h:8905

Referenced by parse_TOKEN().

◆ get_primitive_string()

static const char * get_primitive_string ( DWORD  token)
static

Definition at line 84 of file parsing.c.

85{
86 switch(token)
87 {
88 case TOKEN_WORD:
89 return "WORD";
90 case TOKEN_DWORD:
91 return "DWORD";
92 case TOKEN_FLOAT:
93 return "FLOAT";
94 case TOKEN_DOUBLE:
95 return "DOUBLE";
96 case TOKEN_CHAR:
97 return "CHAR";
98 case TOKEN_UCHAR:
99 return "UCHAR";
100 case TOKEN_SWORD:
101 return "SWORD";
102 case TOKEN_SDWORD:
103 return "SDWORD";
104 case TOKEN_VOID:
105 return "VOID";
106 case TOKEN_LPSTR:
107 return "STRING";
108 case TOKEN_UNICODE:
109 return "UNICODE";
110 case TOKEN_CSTRING:
111 return "CSTRING ";
112 default:
113 break;
114 }
115 return NULL;
116}
#define NULL
Definition: types.h:112

Referenced by dump_template().

◆ get_TOKEN()

static WORD get_TOKEN ( parse_buffer buf)
static

Definition at line 853 of file parsing.c.

854{
855 if (buf->token_present)
856 {
857 buf->token_present = FALSE;
858 return buf->current_token;
859 }
860
861 buf->current_token = parse_TOKEN(buf);
862
863 return buf->current_token;
864}

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 530 of file parsing.c.

531{
532 char tmp[512];
533 DWORD pos = 0;
534 char c;
535 float decimal;
536 BOOL dot = FALSE;
537
538 while (pos < buf->rem_bytes && !is_separator(c = *(buf->buffer+pos)))
539 {
540 if (!((!pos && (c == '-')) || ((c >= '0') && (c <= '9')) || (!dot && (c == '.'))))
541 return FALSE;
542 if (c == '.')
543 dot = TRUE;
544 if (pos < sizeof(tmp))
545 tmp[pos] = c;
546 pos++;
547 }
548 tmp[min(pos, sizeof(tmp) - 1)] = 0;
549
550 buf->buffer += pos;
551 buf->rem_bytes -= pos;
552
553 sscanf(tmp, "%f", &decimal);
554
555 TRACE("Found float %s - %f\n", tmp, decimal);
556
557 *(float*)buf->value = decimal;
558
559 return TRUE;
560}
_ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl _ACRTIMP int __cdecl sscanf(const char *, const char *,...) __WINE_CRT_SCANF_ATTR(2
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define c
Definition: ke_i.h:80
#define min(a, b)
Definition: monoChain.cc:55
static BOOL is_separator(char c)
Definition: parsing.c:358

Referenced by parse_TOKEN().

◆ is_guid()

static BOOL is_guid ( parse_buffer buf)
static

Definition at line 449 of file parsing.c.

450{
451 char tmp[50];
452 DWORD pos = 1;
453 GUID class_id;
454 DWORD tab[10];
455 int ret;
456
457 if (buf->rem_bytes < 38 || *buf->buffer != '<')
458 return FALSE;
459 tmp[0] = '<';
460 while (pos < sizeof(tmp) - 2 && *(buf->buffer+pos) != '>')
461 {
462 tmp[pos] = *(buf->buffer+pos);
463 pos++;
464 }
465 tmp[pos++] = '>';
466 tmp[pos] = 0;
467 if (pos != 38 /* <+36+> */)
468 {
469 TRACE("Wrong guid %s (%d)\n", tmp, pos);
470 return FALSE;
471 }
472 buf->buffer += pos;
473 buf->rem_bytes -= pos;
474
475 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);
476 if (ret != 11)
477 {
478 TRACE("Wrong guid %s (%d)\n", tmp, pos);
479 return FALSE;
480 }
481 TRACE("Found guid %s (%d)\n", tmp, pos);
482
483 class_id.Data2 = tab[0];
484 class_id.Data3 = tab[1];
485 class_id.Data4[0] = tab[2];
486 class_id.Data4[1] = tab[3];
487 class_id.Data4[2] = tab[4];
488 class_id.Data4[3] = tab[5];
489 class_id.Data4[4] = tab[6];
490 class_id.Data4[5] = tab[7];
491 class_id.Data4[6] = tab[8];
492 class_id.Data4[7] = tab[9];
493
494 *(GUID*)buf->value = class_id;
495
496 return TRUE;
497}
return ret
Definition: mutex.c:147
static struct wctab tab[]

Referenced by parse_TOKEN().

◆ is_integer()

static BOOL is_integer ( parse_buffer buf)
static

Definition at line 562 of file parsing.c.

563{
564 char tmp[512];
565 DWORD pos = 0;
566 char c;
568
569 while (pos < buf->rem_bytes && !is_separator(c = *(buf->buffer+pos)))
570 {
571 if (!((c >= '0') && (c <= '9')))
572 return FALSE;
573 if (pos < sizeof(tmp))
574 tmp[pos] = c;
575 pos++;
576 }
577 tmp[min(pos, sizeof(tmp) - 1)] = 0;
578
579 buf->buffer += pos;
580 buf->rem_bytes -= pos;
581
582 sscanf(tmp, "%d", &integer);
583
584 TRACE("Found integer %s - %d\n", tmp, integer);
585
586 *(DWORD*)buf->value = integer;
587
588 return TRUE;
589}

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

◆ is_keyword()

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

Definition at line 391 of file parsing.c.

392{
393 char tmp[8]; /* longest keyword size (template) */
395
396 if (!read_bytes(buf, tmp, len))
397 return FALSE;
398 if (_strnicmp(tmp, keyword, len))
399 {
401 return FALSE;
402 }
403
404 if (!read_bytes(buf, tmp, 1))
405 return TRUE;
406 if (is_separator(tmp[0]))
407 {
408 rewind_bytes(buf, 1);
409 return TRUE;
410 }
411 rewind_bytes(buf, len+1);
412 return FALSE;
413}
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
GLenum GLsizei len
Definition: glext.h:6722
static BOOL read_bytes(parse_buffer *buf, LPVOID data, DWORD size)
Definition: parsing.c:159
static void rewind_bytes(parse_buffer *buf, DWORD size)
Definition: parsing.c:169

Referenced by get_keyword_token().

◆ is_name()

static BOOL is_name ( parse_buffer buf)
static

Definition at line 499 of file parsing.c.

500{
501 char tmp[512];
502 DWORD pos = 0;
503 char c;
504 BOOL error = FALSE;
505 while (pos < buf->rem_bytes && !is_separator(c = *(buf->buffer+pos)))
506 {
507 if (!(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9')) || (c == '_') || (c == '-')))
508 error = TRUE;
509 if (pos < sizeof(tmp))
510 tmp[pos] = c;
511 pos++;
512 }
513 tmp[min(pos, sizeof(tmp) - 1)] = 0;
514
515 if (error)
516 {
517 TRACE("Wrong name %s\n", tmp);
518 return FALSE;
519 }
520
521 buf->buffer += pos;
522 buf->rem_bytes -= pos;
523
524 TRACE("Found name %s\n", tmp);
525 strcpy((char*)buf->value, tmp);
526
527 return TRUE;
528}
#define error(str)
Definition: mkdosfs.c:1605
strcpy
Definition: string.h:131

Referenced by parse_TOKEN().

◆ is_operator()

static BOOL is_operator ( char  c)
static

Definition at line 339 of file parsing.c.

340{
341 switch(c)
342 {
343 case '{':
344 case '}':
345 case '[':
346 case ']':
347 case '(':
348 case ')':
349 case '<':
350 case '>':
351 case ',':
352 case ';':
353 return TRUE;
354 }
355 return FALSE;
356}

Referenced by is_separator(), and parse_TOKEN().

◆ is_primitive_type()

static BOOL is_primitive_type ( WORD  token)
inlinestatic

Definition at line 877 of file parsing.c.

878{
879 BOOL ret;
880 switch(token)
881 {
882 case TOKEN_WORD:
883 case TOKEN_DWORD:
884 case TOKEN_FLOAT:
885 case TOKEN_DOUBLE:
886 case TOKEN_CHAR:
887 case TOKEN_UCHAR:
888 case TOKEN_SWORD:
889 case TOKEN_SDWORD:
890 case TOKEN_LPSTR:
891 case TOKEN_UNICODE:
892 case TOKEN_CSTRING:
893 ret = TRUE;
894 break;
895 default:
896 ret = FALSE;
897 break;
898 }
899 return ret;
900}

Referenced by parse_template_members_list().

◆ is_separator()

static BOOL is_separator ( char  c)
inlinestatic

Definition at line 358 of file parsing.c.

359{
360 return is_space(c) || is_operator(c);
361}
#define is_space(c)
Definition: astoll.c:38
static BOOL is_operator(char c)
Definition: parsing.c:339

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

◆ is_space()

static BOOL is_space ( char  c)
static

Definition at line 325 of file parsing.c.

326{
327 switch (c)
328 {
329 case 0x00:
330 case 0x0D:
331 case 0x0A:
332 case ' ':
333 case '\t':
334 return TRUE;
335 }
336 return FALSE;
337}

◆ is_string()

static BOOL is_string ( parse_buffer buf)
static

Definition at line 591 of file parsing.c.

592{
593 char tmp[512];
594 DWORD pos = 0;
595 char c;
596 BOOL ok = FALSE;
597
598 if (*buf->buffer != '"')
599 return FALSE;
600
601 while ((pos+1) < buf->rem_bytes)
602 {
603 c = *(buf->buffer+pos+1);
604 if (c == '"')
605 {
606 ok = TRUE;
607 break;
608 }
609 if (pos < sizeof(tmp))
610 tmp[pos] = c;
611 pos++;
612 }
613 tmp[min(pos, sizeof(tmp) - 1)] = 0;
614
615 if (!ok)
616 {
617 TRACE("Wrong string %s\n", tmp);
618 return FALSE;
619 }
620
621 buf->buffer += pos + 2;
622 buf->rem_bytes -= pos + 2;
623
624 TRACE("Found string %s\n", tmp);
625 strcpy((char*)buf->value, tmp);
626
627 return TRUE;
628}
#define ok(value,...)
Definition: atltest.h:57

Referenced by builtin_eval(), DateConstr_value(), do_make_empty_object(), equal_values(), handle_mid(), interp_add(), interp_set_member(), JSON_stringify(), less_eval(), parse_TOKEN(), and variant_date_to_string().

◆ parse_header()

HRESULT parse_header ( parse_buffer buf,
BYTE **  decomp_buffer_ptr 
)

Definition at line 175 of file parsing.c.

176{
177 /* X File common header:
178 * 0-3 -> Magic Number (format identifier)
179 * 4-7 -> Format Version
180 * 8-11 -> Format Type (text or binary, decompressed or compressed)
181 * 12-15 -> Float Size (32 or 64 bits) */
182 DWORD header[4];
183
184 if (!read_bytes(buf, header, sizeof(header)))
186
187 if (TRACE_ON(d3dxof_parsing))
188 {
189 char string[17];
190 memcpy(string, header, 16);
191 string[16] = 0;
192 TRACE("header = '%s'\n", string);
193 }
194
197
200
203 {
204 WARN("File type %s unknown\n", debugstr_fourcc(header[2]));
206 }
207
210
212
214 {
215 /* Extended header for compressed data:
216 * 16-19 -> size of decompressed file including xof header,
217 * 20-21 -> size of first decompressed MSZIP chunk, 22-23 -> size of first compressed MSZIP chunk
218 * 24-xx -> compressed MSZIP data chunk
219 * xx-xx -> size of next decompressed MSZIP chunk, xx-xx -> size of next compressed MSZIP chunk
220 * xx-xx -> compressed MSZIP data chunk
221 * .............................................................................................. */
222 int err;
223 DWORD decomp_file_size;
224 WORD decomp_chunk_size;
225 WORD comp_chunk_size;
226 LPBYTE decomp_buffer;
227
228 if (!read_bytes(buf, &decomp_file_size, sizeof(decomp_file_size)))
230
231 TRACE("Compressed format %s detected: decompressed file size with xof header = %d\n",
232 debugstr_fourcc(header[2]), decomp_file_size);
233
234 /* Does not take xof header into account */
235 decomp_file_size -= 16;
236
237 decomp_buffer = HeapAlloc(GetProcessHeap(), 0, decomp_file_size);
238 if (!decomp_buffer)
239 {
240 ERR("Out of memory\n");
241 return DXFILEERR_BADALLOC;
242 }
243 *decomp_buffer_ptr = decomp_buffer;
244
245 while (buf->rem_bytes)
246 {
247 if (!read_bytes(buf, &decomp_chunk_size, sizeof(decomp_chunk_size)))
249 if (!read_bytes(buf, &comp_chunk_size, sizeof(comp_chunk_size)))
251
252 TRACE("Process chunk: compressed_size = %d, decompressed_size = %d\n",
253 comp_chunk_size, decomp_chunk_size);
254
255 err = mszip_decompress(comp_chunk_size, decomp_chunk_size, (char*)buf->buffer, (char*)decomp_buffer);
256 if (err)
257 {
258 WARN("Error while decompressing MSZIP chunk %d\n", err);
259 HeapFree(GetProcessHeap(), 0, decomp_buffer);
260 return DXFILEERR_BADALLOC;
261 }
262 buf->rem_bytes -= comp_chunk_size;
263 buf->buffer += comp_chunk_size;
264 decomp_buffer += decomp_chunk_size;
265 }
266
267 if ((decomp_buffer - *decomp_buffer_ptr) != decomp_file_size)
268 ERR("Size of all decompressed chunks (%u) does not match decompressed file size (%u)\n",
269 (DWORD)(decomp_buffer - *decomp_buffer_ptr), decomp_file_size);
270
271 /* Use decompressed data */
272 buf->buffer = *decomp_buffer_ptr;
273 buf->rem_bytes = decomp_file_size;
274 }
275
276 TRACE("Header is correct\n");
277
278 return S_OK;
279}
#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) DECLSPEC_HIDDEN
#define TRACE_ON(x)
Definition: compat.h:75
#define DXFILEERR_BADALLOC
Definition: dxfile.h:274
#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
#define S_OK
Definition: intsafe.h:52
#define XOFFILE_FORMAT_MAGIC
Definition: parsing.c:37
#define XOFFILE_FORMAT_FLOAT_BITS_32
Definition: parsing.c:45
#define XOFFILE_FORMAT_VERSION_302
Definition: parsing.c:38
#define XOFFILE_FORMAT_BINARY
Definition: parsing.c:40
#define XOFFILE_FORMAT_TEXT
Definition: parsing.c:41
#define XOFFILE_FORMAT_VERSION_303
Definition: parsing.c:39
#define XOFFILE_FORMAT_BINARY_MSZIP
Definition: parsing.c:42
#define XOFFILE_FORMAT_TEXT_MSZIP
Definition: parsing.c:43
#define XOFFILE_FORMAT_FLOAT_BITS_64
Definition: parsing.c:46
#define err(...)

Referenced by IDirectXFileImpl_CreateEnumObject(), and IDirectXFileImpl_RegisterTemplates().

◆ parse_object()

BOOL parse_object ( parse_buffer buf)

Definition at line 1370 of file parsing.c.

1371{
1372 ULONG i;
1373
1374 buf->pxo->pos_data = buf->cur_pos_data;
1375 buf->pxo->ptarget = NULL;
1376 buf->pxo->binary = FALSE;
1377 buf->pxo->root = buf->pxo_tab;
1378
1379 if (get_TOKEN(buf) != TOKEN_NAME)
1380 return FALSE;
1381
1382 /* To do template lookup */
1383 for (i = 0; i < buf->pdxf->nb_xtemplates; i++)
1384 {
1385 if (!_strnicmp((char*)buf->value, buf->pdxf->xtemplates[i].name, -1))
1386 {
1387 buf->pxt[buf->level] = &buf->pdxf->xtemplates[i];
1388 memcpy(&buf->pxo->type, &buf->pdxf->xtemplates[i].class_id, 16);
1389 break;
1390 }
1391 }
1392 if (i == buf->pdxf->nb_xtemplates)
1393 {
1394 ERR("Unknown template %s\n", (char*)buf->value);
1395 return FALSE;
1396 }
1397
1398 if (check_TOKEN(buf) == TOKEN_NAME)
1399 {
1400 get_TOKEN(buf);
1401 strcpy(buf->pxo->name, (char*)buf->value);
1402 }
1403 else
1404 buf->pxo->name[0] = 0;
1405
1406 if (get_TOKEN(buf) != TOKEN_OBRACE)
1407 return FALSE;
1408 if (check_TOKEN(buf) == TOKEN_GUID)
1409 {
1410 get_TOKEN(buf);
1411 memcpy(&buf->pxo->class_id, buf->value, 16);
1412 }
1413 else
1414 memset(&buf->pxo->class_id, 0, 16);
1415
1417 return FALSE;
1418 if (get_TOKEN(buf) != TOKEN_CBRACE)
1419 return FALSE;
1420
1421 /* For seeking to a possibly eof to avoid parsing another object next time */
1423
1424 return TRUE;
1425}
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
static BOOL parse_object_parts(parse_buffer *buf, BOOL allow_optional)
Definition: parsing.c:1284
static WORD check_TOKEN(parse_buffer *buf)
Definition: parsing.c:866
static WORD get_TOKEN(parse_buffer *buf)
Definition: parsing.c:853
#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 1130 of file parsing.c.

1131{
1132 DWORD token;
1133 ULONG i;
1134 xtemplate* pt = buf->pxt[buf->level];
1135
1136 buf->pxo->nb_members = pt->nb_members;
1137
1138 for (i = 0; i < pt->nb_members; i++)
1139 {
1140 ULONG k;
1141 ULONG nb_elems = 1;
1142 BOOL basic_type = TRUE;
1143
1144 buf->pxo->members[i].name = pt->members[i].name;
1145 buf->pxo->members[i].start = buf->cur_pos_data;
1146
1147 for (k = 0; k < pt->members[i].nb_dims; k++)
1148 {
1149 if (pt->members[i].dim_fixed[k])
1150 nb_elems *= pt->members[i].dim_value[k];
1151 else
1152 nb_elems *= *(DWORD*)(buf->pxo->root->pdata + buf->pxo->members[pt->members[i].dim_value[k]].start);
1153 }
1154
1155 TRACE("Elements to consider: %u\n", nb_elems);
1156
1157 for (k = 0; k < nb_elems; k++)
1158 {
1159 if (pt->members[i].type == TOKEN_NAME)
1160 {
1161 ULONG j;
1162
1163 TRACE("Found sub-object %s\n", buf->pdxf->xtemplates[pt->members[i].idx_template].name);
1164 basic_type = FALSE;
1165 buf->level++;
1166 /* To do template lookup */
1167 for (j = 0; j < buf->pdxf->nb_xtemplates; j++)
1168 {
1169 if (!_strnicmp(buf->pdxf->xtemplates[pt->members[i].idx_template].name, buf->pdxf->xtemplates[j].name, -1))
1170 {
1171 buf->pxt[buf->level] = &buf->pdxf->xtemplates[j];
1172 break;
1173 }
1174 }
1175 if (j == buf->pdxf->nb_xtemplates)
1176 {
1177 ERR("Unknown template %s\n", (char*)buf->value);
1178 buf->level--;
1179 return FALSE;
1180 }
1181 TRACE("Enter %s\n", buf->pdxf->xtemplates[pt->members[i].idx_template].name);
1183 {
1184 buf->level--;
1185 return FALSE;
1186 }
1187 buf->level--;
1188 }
1189 else
1190 {
1192 if (token == TOKEN_INTEGER)
1193 {
1194 get_TOKEN(buf);
1195 TRACE("%s = %d\n", pt->members[i].name, *(DWORD*)buf->value);
1196 /* Assume larger size */
1197 if (!check_buffer(buf, 4))
1198 return FALSE;
1199 if (pt->members[i].type == TOKEN_WORD)
1200 {
1201 *(WORD *)(buf->pdata + buf->cur_pos_data) = *(DWORD *)buf->value;
1202 buf->cur_pos_data += 2;
1203 }
1204 else if (pt->members[i].type == TOKEN_DWORD)
1205 {
1206 *(DWORD *)(buf->pdata + buf->cur_pos_data) = *(DWORD *)buf->value;
1207 buf->cur_pos_data += 4;
1208 }
1209 else
1210 {
1211 FIXME("Token %d not supported\n", pt->members[i].type);
1212 return FALSE;
1213 }
1214 }
1215 else if (token == TOKEN_FLOAT)
1216 {
1217 get_TOKEN(buf);
1218 TRACE("%s = %f\n", pt->members[i].name, *(float*)buf->value);
1219 if (!check_buffer(buf, 4))
1220 return FALSE;
1221 if (pt->members[i].type == TOKEN_FLOAT)
1222 {
1223 *(float *)(buf->pdata + buf->cur_pos_data) = *(float *)buf->value;
1224 buf->cur_pos_data += 4;
1225 }
1226 else
1227 {
1228 FIXME("Token %d not supported\n", pt->members[i].type);
1229 return FALSE;
1230 }
1231 }
1232 else if (token == TOKEN_LPSTR)
1233 {
1234 get_TOKEN(buf);
1235 TRACE("%s = %s\n", pt->members[i].name, (char*)buf->value);
1236 if (!check_buffer(buf, sizeof(LPSTR)))
1237 return FALSE;
1238 if (pt->members[i].type == TOKEN_LPSTR)
1239 {
1240 int len = strlen((char*)buf->value) + 1;
1241 if ((buf->cur_pstrings - buf->pstrings + len) > MAX_STRINGS_BUFFER)
1242 {
1243 FIXME("Buffer too small %p %p %d\n", buf->cur_pstrings, buf->pstrings, len);
1244 return FALSE;
1245 }
1246 strcpy((char*)buf->cur_pstrings, (char*)buf->value);
1247 *(((LPCSTR*)(buf->pdata + buf->cur_pos_data))) = (char*)buf->cur_pstrings;
1248 buf->cur_pstrings += len;
1249 buf->cur_pos_data += sizeof(LPSTR);
1250 }
1251 else
1252 {
1253 FIXME("Token %d not supported\n", pt->members[i].type);
1254 return FALSE;
1255 }
1256 }
1257 else
1258 {
1259 WARN("Unexpected token %d\n", token);
1260 return FALSE;
1261 }
1262 }
1263
1264 if (basic_type)
1265 {
1266 /* Handle separator only for basic types */
1268 if ((token != TOKEN_COMMA) && (token != TOKEN_SEMICOLON))
1269 return FALSE;
1270 /* Allow multi-semicolons + single comma separator */
1271 while (check_TOKEN(buf) == TOKEN_SEMICOLON)
1272 get_TOKEN(buf);
1273 if (check_TOKEN(buf) == TOKEN_COMMA)
1274 get_TOKEN(buf);
1275 }
1276 }
1277
1278 buf->pxo->members[i].size = buf->cur_pos_data - buf->pxo->members[i].start;
1279 }
1280
1281 return TRUE;
1282}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define MAX_STRINGS_BUFFER
#define pt(x, y)
Definition: drawing.c:79
static BOOL check_buffer(parse_buffer *buf, ULONG size)
Definition: parsing.c:1110
char * value
Definition: compiler.c:67
char * name
Definition: compiler.c:66
const char * LPCSTR
Definition: typedefs.h:52
char * LPSTR
Definition: typedefs.h:51

Referenced by parse_object_parts().

◆ parse_object_parts()

static BOOL parse_object_parts ( parse_buffer buf,
BOOL  allow_optional 
)
static

Definition at line 1284 of file parsing.c.

1285{
1286 buf->pxo->nb_children = 0;
1287
1289 return FALSE;
1290
1291 if (allow_optional)
1292 {
1293 buf->pxo->size = buf->cur_pos_data - buf->pxo->pos_data;
1294
1295 while (1)
1296 {
1298 {
1299 ULONG i, j;
1300 get_TOKEN(buf);
1301 if (get_TOKEN(buf) != TOKEN_NAME)
1302 return FALSE;
1303 if (get_TOKEN(buf) != TOKEN_CBRACE)
1304 return FALSE;
1305 TRACE("Found optional reference %s\n", (char*)buf->value);
1306 for (i = 0; i < (buf->nb_pxo_globals+1); i++)
1307 {
1308 for (j = 0; j < (buf->pxo_globals[i])[0].nb_subobjects; j++)
1309 {
1310 if (!strcmp((buf->pxo_globals[i])[j].name, (char*)buf->value))
1311 goto _exit;
1312 }
1313 }
1314_exit:
1315 if (i == (buf->nb_pxo_globals+1))
1316 {
1317 ERR("Reference to unknown object %s\n", (char*)buf->value);
1318 return FALSE;
1319 }
1320
1321 if (buf->pxo->root->nb_subobjects >= MAX_SUBOBJECTS)
1322 {
1323 FIXME("Too many sub-objects\n");
1324 return FALSE;
1325 }
1326
1327 buf->pxo->children[buf->pxo->nb_children] = &buf->pxo_tab[buf->pxo->root->nb_subobjects++];
1328 buf->pxo->children[buf->pxo->nb_children]->ptarget = &(buf->pxo_globals[i])[j];
1329 buf->pxo->children[buf->pxo->nb_children]->binary = FALSE;
1330 buf->pxo->nb_children++;
1331 }
1332 else if (check_TOKEN(buf) == TOKEN_NAME)
1333 {
1334 xobject* pxo = buf->pxo;
1335
1336 if (buf->pxo->root->nb_subobjects >= MAX_SUBOBJECTS)
1337 {
1338 FIXME("Too many sub-objects\n");
1339 return FALSE;
1340 }
1341
1342 buf->pxo = buf->pxo->children[buf->pxo->nb_children] = &buf->pxo_tab[buf->pxo->root->nb_subobjects];
1343 pxo->root->nb_subobjects++;
1344
1345 TRACE("Enter optional %s\n", (char*)buf->value);
1346 buf->level++;
1347 if (!parse_object(buf))
1348 {
1349 buf->level--;
1350 return FALSE;
1351 }
1352 buf->level--;
1353 buf->pxo = pxo;
1354 buf->pxo->nb_children++;
1355 }
1356 else
1357 break;
1358 }
1359 }
1360
1361 if (buf->pxo->nb_children > MAX_CHILDREN)
1362 {
1363 FIXME("Too many children %d\n", buf->pxo->nb_children);
1364 return FALSE;
1365 }
1366
1367 return TRUE;
1368}
#define MAX_SUBOBJECTS
#define MAX_CHILDREN
void CDECL _exit(int exitcode)
Definition: exit.c:187
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3324
BOOL parse_object(parse_buffer *buf)
Definition: parsing.c:1370
static BOOL parse_object_members_list(parse_buffer *buf)
Definition: parsing.c:1130
_In_ XLATEOBJ _In_ XFORMOBJ * pxo
Definition: winddi.h:3811

Referenced by parse_object(), and parse_object_members_list().

◆ parse_template()

static BOOL parse_template ( parse_buffer buf)
static

Definition at line 1066 of file parsing.c.

1067{
1069 return FALSE;
1070 if (get_TOKEN(buf) != TOKEN_NAME)
1071 return FALSE;
1072 strcpy(buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].name, (char*)buf->value);
1073 if (get_TOKEN(buf) != TOKEN_OBRACE)
1074 return FALSE;
1075 if (get_TOKEN(buf) != TOKEN_GUID)
1076 return FALSE;
1077 buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].class_id = *(GUID*)buf->value;
1079 return FALSE;
1080 if (get_TOKEN(buf) != TOKEN_CBRACE)
1081 return FALSE;
1082
1083 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));
1084 buf->pdxf->nb_xtemplates++;
1085
1086 return TRUE;
1087}
#define debugstr_guid
Definition: kernel32.h:35
if(dx< 0)
Definition: linetemp.h:194
static BOOL parse_template_parts(parse_buffer *buf)
Definition: parsing.c:1050

Referenced by parse_templates().

◆ parse_template_members_list()

static BOOL parse_template_members_list ( parse_buffer buf)
static

Definition at line 935 of file parsing.c.

936{
937 int idx_member = 0;
938 member* cur_member;
939
940 while (1)
941 {
942 BOOL array = FALSE;
943 int nb_dims = 0;
944 cur_member = &buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[idx_member];
945
947 {
948 get_TOKEN(buf);
949 array = TRUE;
950 }
951
952 if (check_TOKEN(buf) == TOKEN_NAME)
953 {
954 cur_member->type = get_TOKEN(buf);
955 if (!strcmp((char*)buf->value, "indexColor"))
956 {
957 /* Case sensitive legacy type indexColor is described in the first template */
958 cur_member->idx_template = 0;
959 }
960 else
961 {
962 cur_member->idx_template = 1;
963 while (cur_member->idx_template < buf->pdxf->nb_xtemplates)
964 {
965 if (!_strnicmp((char*)buf->value, buf->pdxf->xtemplates[cur_member->idx_template].name, -1))
966 break;
967 cur_member->idx_template++;
968 }
969 if (cur_member->idx_template == buf->pdxf->nb_xtemplates)
970 {
971 WARN("Reference to a nonexistent template '%s'\n", (char*)buf->value);
972 return FALSE;
973 }
974 }
975 }
977 cur_member->type = get_TOKEN(buf);
978 else
979 break;
980
981 if (get_TOKEN(buf) != TOKEN_NAME)
982 return FALSE;
983 strcpy(cur_member->name, (char*)buf->value);
984
985 if (array)
986 {
987 while (check_TOKEN(buf) == TOKEN_OBRACKET)
988 {
989 if (nb_dims >= MAX_ARRAY_DIM)
990 {
991 FIXME("Too many dimensions (%d) for multi-dimensional array\n", nb_dims + 1);
992 return FALSE;
993 }
994 get_TOKEN(buf);
996 {
997 get_TOKEN(buf);
998 cur_member->dim_fixed[nb_dims] = TRUE;
999 cur_member->dim_value[nb_dims] = *(DWORD*)buf->value;
1000 }
1001 else
1002 {
1003 int i;
1004 if (get_TOKEN(buf) != TOKEN_NAME)
1005 return FALSE;
1006 for (i = 0; i < idx_member; i++)
1007 {
1008 if (!strcmp((char*)buf->value, buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[i].name))
1009 {
1010 if (buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[i].nb_dims)
1011 {
1012 ERR("Array cannot be used to specify variable array size\n");
1013 return FALSE;
1014 }
1015 if (buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].members[i].type != TOKEN_DWORD)
1016 {
1017 FIXME("Only DWORD supported to specify variable array size\n");
1018 return FALSE;
1019 }
1020 break;
1021 }
1022 }
1023 if (i == idx_member)
1024 {
1025 ERR("Reference to unknown member %s\n", (char*)buf->value);
1026 return FALSE;
1027 }
1028 cur_member->dim_fixed[nb_dims] = FALSE;
1029 cur_member->dim_value[nb_dims] = i;
1030 }
1032 return FALSE;
1033 nb_dims++;
1034 }
1035 if (!nb_dims)
1036 return FALSE;
1037 cur_member->nb_dims = nb_dims;
1038 }
1040 return FALSE;
1041
1042 idx_member++;
1043 }
1044
1045 buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].nb_members = idx_member;
1046
1047 return TRUE;
1048}
#define MAX_ARRAY_DIM
static BOOL is_primitive_type(WORD token)
Definition: parsing.c:877
Definition: undname.c:54

Referenced by parse_template_parts().

◆ parse_template_option_info()

static BOOL parse_template_option_info ( parse_buffer buf)
static

Definition at line 902 of file parsing.c.

903{
904 xtemplate* cur_template = &buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates];
905
906 if (check_TOKEN(buf) == TOKEN_DOT)
907 {
908 get_TOKEN(buf);
909 if (get_TOKEN(buf) != TOKEN_DOT)
910 return FALSE;
911 if (get_TOKEN(buf) != TOKEN_DOT)
912 return FALSE;
913 cur_template->open = TRUE;
914 }
915 else
916 {
917 while (1)
918 {
919 if (get_TOKEN(buf) != TOKEN_NAME)
920 return FALSE;
921 strcpy(cur_template->children[cur_template->nb_children], (char*)buf->value);
922 if (check_TOKEN(buf) == TOKEN_GUID)
923 get_TOKEN(buf);
924 cur_template->nb_children++;
926 break;
927 get_TOKEN(buf);
928 }
929 cur_template->open = FALSE;
930 }
931
932 return TRUE;
933}

Referenced by parse_template_parts().

◆ parse_template_parts()

static BOOL parse_template_parts ( parse_buffer buf)
static

Definition at line 1050 of file parsing.c.

1051{
1053 return FALSE;
1055 {
1056 get_TOKEN(buf);
1058 return FALSE;
1060 return FALSE;
1061 }
1062
1063 return TRUE;
1064}
static BOOL parse_template_members_list(parse_buffer *buf)
Definition: parsing.c:935
static BOOL parse_template_option_info(parse_buffer *buf)
Definition: parsing.c:902

Referenced by parse_template().

◆ parse_templates()

BOOL parse_templates ( parse_buffer buf,
BOOL  templates_only 
)

Definition at line 1089 of file parsing.c.

1090{
1091 while (check_TOKEN(buf) != TOKEN_NONE)
1092 {
1093 if (templates_only && (check_TOKEN(buf) != TOKEN_TEMPLATE))
1094 return TRUE;
1095 if (!parse_template(buf))
1096 {
1097 WARN("Template is not correct\n");
1098 return FALSE;
1099 }
1100 else
1101 {
1102 TRACE("Template successfully parsed:\n");
1103 if (TRACE_ON(d3dxof_parsing))
1104 dump_template(buf->pdxf->xtemplates, &buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates - 1]);
1105 }
1106 }
1107 return TRUE;
1108}
static void dump_template(xtemplate *templates_array, xtemplate *ptemplate)
Definition: parsing.c:118
static BOOL parse_template(parse_buffer *buf)
Definition: parsing.c:1066
#define TOKEN_NONE
Definition: parsing.c:49

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

◆ parse_TOKEN()

static WORD parse_TOKEN ( parse_buffer buf)
static

Definition at line 630 of file parsing.c.

631{
632 WORD token;
633
634 if (buf->txt)
635 {
636 while(1)
637 {
638 char c;
639 if (!read_bytes(buf, &c, 1))
640 return TOKEN_NONE;
641 if ((c == '#') || (c == '/'))
642 {
643 /* Handle comment (# or //) */
644 if (c == '/')
645 {
646 if (!read_bytes(buf, &c, 1))
647 return TOKEN_ERROR;
648 if (c != '/')
649 return TOKEN_ERROR;
650 }
651 c = 0;
652 while (c != 0x0A)
653 {
654 if (!read_bytes(buf, &c, 1))
655 return TOKEN_NONE;
656 }
657 continue;
658 }
659 if (is_space(c))
660 continue;
661 if (is_operator(c) && (c != '<'))
662 {
664 break;
665 }
666 else if (c == '.')
667 {
669 break;
670 }
671 else
672 {
673 rewind_bytes(buf, 1);
674
675 if ((token = get_keyword_token(buf)))
676 break;
677
678 if (is_guid(buf))
679 {
681 break;
682 }
683 if (is_integer(buf))
684 {
686 break;
687 }
688 if (is_float(buf))
689 {
691 break;
692 }
693 if (is_string(buf))
694 {
696 break;
697 }
698 if (is_name(buf))
699 {
701 break;
702 }
703
704 FIXME("Unrecognize element\n");
705 return TOKEN_ERROR;
706 }
707 }
708 }
709 else
710 {
711 if (!buf->list_nb_elements)
712 {
713 if (!read_bytes(buf, &token, 2))
714 return TOKEN_NONE;
715
716 /* Convert integer and float list into separate elements */
718 {
719 if (!read_bytes(buf, &buf->list_nb_elements, 4))
720 return TOKEN_ERROR;
722 buf->list_type_float = FALSE;
723 TRACE("Integer list (TOKEN_INTEGER_LIST) of size %d\n", buf->list_nb_elements);
724 }
725 else if (token == TOKEN_FLOAT_LIST)
726 {
727 if (!read_bytes(buf, &buf->list_nb_elements, 4))
728 return TOKEN_ERROR;
730 buf->list_type_float = TRUE;
731 TRACE("Float list (TOKEN_FLOAT_LIST) of size %d\n", buf->list_nb_elements);
732 }
733 }
734
735 if (buf->list_nb_elements)
736 {
737 if (buf->list_separator)
738 {
739 buf->list_nb_elements--;
740 buf->list_separator = FALSE;
741 /* Insert separator between each value, and since list does not accept separator at the end
742 use a comma so any extra separator will generate an error */
744 }
745 else
746 {
747 DWORD value;
748
749 if (!read_bytes(buf, &value, 4))
750 return TOKEN_ERROR;
751 *(DWORD*)buf->value = value;
752
753 buf->list_separator = TRUE;
754 /* Convert list into a series of their basic type counterpart */
755 token = buf->list_type_float ? TOKEN_FLOAT : TOKEN_INTEGER;
756 }
758 return token;
759 }
760
761 switch (token)
762 {
763 case TOKEN_NAME:
764 {
765 DWORD count;
766 char *name = (char*)buf->value;
767
768 if (!read_bytes(buf, &count, 4))
769 return TOKEN_ERROR;
770 if (!read_bytes(buf, name, count))
771 return TOKEN_ERROR;
772 name[count] = 0;
773 TRACE("name = %s\n", name);
774 }
775 break;
776 case TOKEN_INTEGER:
777 {
779
780 if (!read_bytes(buf, &integer, 4))
781 return TOKEN_ERROR;
782 TRACE("integer = %u\n", integer);
783
784 *(DWORD*)buf->value = integer;
785 }
786 break;
787 case TOKEN_GUID:
788 {
789 char strguid[39];
790 GUID class_id;
791
792 if (!read_bytes(buf, &class_id, 16))
793 return TOKEN_ERROR;
794 sprintf(strguid, CLSIDFMT, class_id.Data1, class_id.Data2, class_id.Data3, class_id.Data4[0],
795 class_id.Data4[1], class_id.Data4[2], class_id.Data4[3], class_id.Data4[4], class_id.Data4[5],
796 class_id.Data4[6], class_id.Data4[7]);
797 TRACE("guid = %s\n", strguid);
798
799 *(GUID*)buf->value = class_id;
800 }
801 break;
802 case TOKEN_STRING:
803 {
804 DWORD count;
805 char *string = (char*)buf->value;
806
807 if (!read_bytes(buf, &count, 4))
808 return TOKEN_ERROR;
809 if (!read_bytes(buf, string, count))
810 return TOKEN_ERROR;
811 string[count] = 0;
812 TRACE("string = %s\n", string);
813
815 }
816 break;
817 case TOKEN_OBRACE:
818 case TOKEN_CBRACE:
819 case TOKEN_OPAREN:
820 case TOKEN_CPAREN:
821 case TOKEN_OBRACKET:
822 case TOKEN_CBRACKET:
823 case TOKEN_OANGLE:
824 case TOKEN_CANGLE:
825 case TOKEN_DOT:
826 case TOKEN_COMMA:
827 case TOKEN_SEMICOLON:
828 case TOKEN_TEMPLATE:
829 case TOKEN_WORD:
830 case TOKEN_DWORD:
831 case TOKEN_FLOAT:
832 case TOKEN_DOUBLE:
833 case TOKEN_CHAR:
834 case TOKEN_UCHAR:
835 case TOKEN_SWORD:
836 case TOKEN_SDWORD:
837 case TOKEN_VOID:
838 case TOKEN_LPSTR:
839 case TOKEN_UNICODE:
840 case TOKEN_CSTRING:
841 case TOKEN_ARRAY:
842 break;
843 default:
844 return TOKEN_ERROR;
845 }
846 }
847
849
850 return token;
851}
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define sprintf
Definition: sprintf.c:45
static WORD get_operator_token(char c)
Definition: parsing.c:363
#define TOKEN_ERROR
Definition: parsing.c:48
static void dump_TOKEN(WORD token)
Definition: parsing.c:281
static BOOL is_float(parse_buffer *buf)
Definition: parsing.c:530
static BOOL is_name(parse_buffer *buf)
Definition: parsing.c:499
static BOOL is_integer(parse_buffer *buf)
Definition: parsing.c:562
static WORD get_keyword_token(parse_buffer *buf)
Definition: parsing.c:415
static BOOL is_guid(parse_buffer *buf)
Definition: parsing.c:449
static BOOL is_string(parse_buffer *buf)
Definition: parsing.c:591
Definition: name.c:39
Definition: pdh_main.c:96

Referenced by check_TOKEN(), and get_TOKEN().

◆ read_bytes()

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

Definition at line 159 of file parsing.c.

160{
161 if (buf->rem_bytes < size)
162 return FALSE;
163 memcpy(data, buf->buffer, size);
164 buf->buffer += size;
165 buf->rem_bytes -= size;
166 return TRUE;
167}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950

Referenced by _fgets(), _overlapped_read_async(), _overlapped_read_sync(), async_read_file_proc(), chunked_read(), FT_Stream_EnterFrame(), FT_Stream_ReadAt(), FT_Stream_TryRead(), image_check_debug_link(), 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 169 of file parsing.c.

170{
171 buf->buffer -= size;
172 buf->rem_bytes += size;
173}

Referenced by is_keyword(), and parse_TOKEN().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3dxof_parsing  )