ReactOS 0.4.17-dev-966-gf06eace
parsing.c File Reference
#include "d3dxof_private.h"
Include dependency graph for parsing.c:

Go to the source code of this file.

Macros

#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 char * get_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 71 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 25 of file parsing.c.

◆ TOKEN_ARRAY

#define TOKEN_ARRAY   52

Definition at line 69 of file parsing.c.

◆ TOKEN_CANGLE

#define TOKEN_CANGLE   17

Definition at line 52 of file parsing.c.

◆ TOKEN_CBRACE

#define TOKEN_CBRACE   11

Definition at line 46 of file parsing.c.

◆ TOKEN_CBRACKET

#define TOKEN_CBRACKET   15

Definition at line 50 of file parsing.c.

◆ TOKEN_CHAR

#define TOKEN_CHAR   44

Definition at line 61 of file parsing.c.

◆ TOKEN_COMMA

#define TOKEN_COMMA   19

Definition at line 54 of file parsing.c.

◆ TOKEN_CPAREN

#define TOKEN_CPAREN   13

Definition at line 48 of file parsing.c.

◆ TOKEN_CSTRING

#define TOKEN_CSTRING   51

Definition at line 68 of file parsing.c.

◆ TOKEN_DOT

#define TOKEN_DOT   18

Definition at line 53 of file parsing.c.

◆ TOKEN_DOUBLE

#define TOKEN_DOUBLE   43

Definition at line 60 of file parsing.c.

◆ TOKEN_DWORD

#define TOKEN_DWORD   41

Definition at line 58 of file parsing.c.

◆ TOKEN_ERROR

#define TOKEN_ERROR   0xffff

Definition at line 37 of file parsing.c.

◆ TOKEN_FLOAT

#define TOKEN_FLOAT   42

Definition at line 59 of file parsing.c.

◆ TOKEN_FLOAT_LIST

#define TOKEN_FLOAT_LIST   7

Definition at line 44 of file parsing.c.

◆ TOKEN_GUID

#define TOKEN_GUID   5

Definition at line 42 of file parsing.c.

◆ TOKEN_INTEGER

#define TOKEN_INTEGER   3

Definition at line 41 of file parsing.c.

◆ TOKEN_INTEGER_LIST

#define TOKEN_INTEGER_LIST   6

Definition at line 43 of file parsing.c.

◆ TOKEN_LPSTR

#define TOKEN_LPSTR   49

Definition at line 66 of file parsing.c.

◆ TOKEN_NAME

#define TOKEN_NAME   1

Definition at line 39 of file parsing.c.

◆ TOKEN_NONE

#define TOKEN_NONE   0

Definition at line 38 of file parsing.c.

◆ TOKEN_OANGLE

#define TOKEN_OANGLE   16

Definition at line 51 of file parsing.c.

◆ TOKEN_OBRACE

#define TOKEN_OBRACE   10

Definition at line 45 of file parsing.c.

◆ TOKEN_OBRACKET

#define TOKEN_OBRACKET   14

Definition at line 49 of file parsing.c.

◆ TOKEN_OPAREN

#define TOKEN_OPAREN   12

Definition at line 47 of file parsing.c.

◆ TOKEN_SDWORD

#define TOKEN_SDWORD   47

Definition at line 64 of file parsing.c.

◆ TOKEN_SEMICOLON

#define TOKEN_SEMICOLON   20

Definition at line 55 of file parsing.c.

◆ TOKEN_STRING

#define TOKEN_STRING   2

Definition at line 40 of file parsing.c.

◆ TOKEN_SWORD

#define TOKEN_SWORD   46

Definition at line 63 of file parsing.c.

◆ TOKEN_TEMPLATE

#define TOKEN_TEMPLATE   31

Definition at line 56 of file parsing.c.

◆ TOKEN_UCHAR

#define TOKEN_UCHAR   45

Definition at line 62 of file parsing.c.

◆ TOKEN_UNICODE

#define TOKEN_UNICODE   50

Definition at line 67 of file parsing.c.

◆ TOKEN_VOID

#define TOKEN_VOID   48

Definition at line 65 of file parsing.c.

◆ TOKEN_WORD

#define TOKEN_WORD   40

Definition at line 57 of file parsing.c.

◆ XOFFILE_FORMAT_BINARY

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

Definition at line 29 of file parsing.c.

◆ XOFFILE_FORMAT_BINARY_MSZIP

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

Definition at line 31 of file parsing.c.

◆ XOFFILE_FORMAT_COMPRESSED

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

Definition at line 33 of file parsing.c.

◆ XOFFILE_FORMAT_FLOAT_BITS_32

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

Definition at line 34 of file parsing.c.

◆ XOFFILE_FORMAT_FLOAT_BITS_64

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

Definition at line 35 of file parsing.c.

◆ XOFFILE_FORMAT_MAGIC

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

Definition at line 26 of file parsing.c.

◆ XOFFILE_FORMAT_TEXT

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

Definition at line 30 of file parsing.c.

◆ XOFFILE_FORMAT_TEXT_MSZIP

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

Definition at line 32 of file parsing.c.

◆ XOFFILE_FORMAT_VERSION_302

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

Definition at line 27 of file parsing.c.

◆ XOFFILE_FORMAT_VERSION_303

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

Definition at line 28 of file parsing.c.

Function Documentation

◆ check_buffer()

static BOOL check_buffer ( parse_buffer *  buf,
ULONG  size 
)
static

Definition at line 1101 of file parsing.c.

1102{
1103 if ((buf->cur_pos_data + size) > buf->capacity)
1104 {
1105 LPBYTE pdata;
1106 ULONG new_capacity = buf->capacity ? 2 * buf->capacity : 100000;
1107
1108 pdata = HeapAlloc(GetProcessHeap(), 0, new_capacity);
1109 if (!pdata)
1110 return FALSE;
1111 memcpy(pdata, buf->pdata, buf->cur_pos_data);
1112 HeapFree(GetProcessHeap(), 0, buf->pdata);
1113 buf->capacity = new_capacity;
1114 buf->pdata = pdata;
1115 buf->pxo->root->pdata = pdata;
1116 }
1117 return TRUE;
1118}
#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 856 of file parsing.c.

857{
858 if (buf->token_present)
859 return buf->current_token;
860
861 buf->current_token = parse_TOKEN(buf);
862 buf->token_present = TRUE;
863
864 return buf->current_token;
865}
static WORD parse_TOKEN(parse_buffer *buf)
Definition: parsing.c:620

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

108{
109 ULONG j, k;
110 GUID* clsid;
111
112 clsid = &ptemplate->class_id;
113
114 wine_dbg_printf("template %s\n", ptemplate->name);
115 wine_dbg_printf("{\n");
116 wine_dbg_printf(CLSIDFMT "\n", clsid->Data1, clsid->Data2, clsid->Data3, clsid->Data4[0],
117 clsid->Data4[1], clsid->Data4[2], clsid->Data4[3], clsid->Data4[4], clsid->Data4[5], clsid->Data4[6], clsid->Data4[7]);
118 for (j = 0; j < ptemplate->nb_members; j++)
119 {
120 if (ptemplate->members[j].nb_dims)
121 wine_dbg_printf("array ");
122 if (ptemplate->members[j].type == TOKEN_NAME)
123 wine_dbg_printf("%s ", templates_array[ptemplate->members[j].idx_template].name);
124 else
126 wine_dbg_printf("%s", ptemplate->members[j].name);
127 for (k = 0; k < ptemplate->members[j].nb_dims; k++)
128 {
129 if (ptemplate->members[j].dim_fixed[k])
130 wine_dbg_printf("[%ld]", ptemplate->members[j].dim_value[k]);
131 else
132 wine_dbg_printf("[%s]", ptemplate->members[ptemplate->members[j].dim_value[k]].name);
133 }
134 wine_dbg_printf(";\n");
135 }
136 if (ptemplate->open)
137 wine_dbg_printf("[...]\n");
138 else if (ptemplate->nb_children)
139 {
140 wine_dbg_printf("[%s", ptemplate->children[0]);
141 for (j = 1; j < ptemplate->nb_children; j++)
142 wine_dbg_printf(",%s", ptemplate->children[j]);
143 wine_dbg_printf("]\n");
144 }
145 wine_dbg_printf("}\n");
146}
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:39
static const char * get_primitive_string(DWORD token)
Definition: parsing.c:73
#define CLSIDFMT
Definition: parsing.c:71
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 270 of file parsing.c.

271{
272#define DUMP_TOKEN(t) case t: TRACE(#t "\n"); break
273 switch(token)
274 {
306 default:
307 if (0)
308 TRACE("Unknown token %d\n", token);
309 break;
310 }
311#undef DUMP_TOKEN
312}
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:42
#define TOKEN_LPSTR
Definition: parsing.c:66
#define TOKEN_UNICODE
Definition: parsing.c:67
#define TOKEN_INTEGER
Definition: parsing.c:41
#define TOKEN_FLOAT
Definition: parsing.c:59
#define TOKEN_VOID
Definition: parsing.c:65
#define TOKEN_CHAR
Definition: parsing.c:61
#define TOKEN_TEMPLATE
Definition: parsing.c:56
#define TOKEN_SWORD
Definition: parsing.c:63
#define TOKEN_CANGLE
Definition: parsing.c:52
#define TOKEN_CBRACKET
Definition: parsing.c:50
#define TOKEN_DWORD
Definition: parsing.c:58
#define TOKEN_OBRACE
Definition: parsing.c:45
#define TOKEN_DOUBLE
Definition: parsing.c:60
#define TOKEN_STRING
Definition: parsing.c:40
#define TOKEN_COMMA
Definition: parsing.c:54
#define TOKEN_WORD
Definition: parsing.c:57
#define TOKEN_CBRACE
Definition: parsing.c:46
#define TOKEN_OANGLE
Definition: parsing.c:51
#define TOKEN_OBRACKET
Definition: parsing.c:49
#define TOKEN_DOT
Definition: parsing.c:53
#define DUMP_TOKEN(t)
#define TOKEN_OPAREN
Definition: parsing.c:47
#define TOKEN_SEMICOLON
Definition: parsing.c:55
#define TOKEN_SDWORD
Definition: parsing.c:64
#define TOKEN_INTEGER_LIST
Definition: parsing.c:43
#define TOKEN_CPAREN
Definition: parsing.c:48
#define TOKEN_ARRAY
Definition: parsing.c:69
#define TOKEN_CSTRING
Definition: parsing.c:68
#define TOKEN_UCHAR
Definition: parsing.c:62
#define TOKEN_FLOAT_LIST
Definition: parsing.c:44
#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 404 of file parsing.c.

405{
406 if (is_keyword(buf, "template"))
407 return TOKEN_TEMPLATE;
408 if (is_keyword(buf, "WORD"))
409 return TOKEN_WORD;
410 if (is_keyword(buf, "DWORD"))
411 return TOKEN_DWORD;
412 if (is_keyword(buf, "FLOAT"))
413 return TOKEN_FLOAT;
414 if (is_keyword(buf, "DOUBLE"))
415 return TOKEN_DOUBLE;
416 if (is_keyword(buf, "CHAR"))
417 return TOKEN_CHAR;
418 if (is_keyword(buf, "UCHAR"))
419 return TOKEN_UCHAR;
420 if (is_keyword(buf, "SWORD"))
421 return TOKEN_SWORD;
422 if (is_keyword(buf, "SDWORD"))
423 return TOKEN_SDWORD;
424 if (is_keyword(buf, "VOID"))
425 return TOKEN_VOID;
426 if (is_keyword(buf, "STRING"))
427 return TOKEN_LPSTR;
428 if (is_keyword(buf, "UNICODE"))
429 return TOKEN_UNICODE;
430 if (is_keyword(buf, "CSTRING"))
431 return TOKEN_CSTRING;
432 if (is_keyword(buf, "array"))
433 return TOKEN_ARRAY;
434
435 return 0;
436}
static BOOL is_keyword(parse_buffer *buf, const char *keyword)
Definition: parsing.c:380

Referenced by parse_TOKEN().

◆ get_operator_token()

static WORD get_operator_token ( char  c)
static

Definition at line 352 of file parsing.c.

353{
354 switch(c)
355 {
356 case '{':
357 return TOKEN_OBRACE;
358 case '}':
359 return TOKEN_CBRACE;
360 case '[':
361 return TOKEN_OBRACKET;
362 case ']':
363 return TOKEN_CBRACKET;
364 case '(':
365 return TOKEN_OPAREN;
366 case ')':
367 return TOKEN_CPAREN;
368 case '<':
369 return TOKEN_OANGLE;
370 case '>':
371 return TOKEN_CANGLE;
372 case ',':
373 return TOKEN_COMMA;
374 case ';':
375 return TOKEN_SEMICOLON;
376 }
377 return 0;
378}
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 73 of file parsing.c.

74{
75 switch(token)
76 {
77 case TOKEN_WORD:
78 return "WORD";
79 case TOKEN_DWORD:
80 return "DWORD";
81 case TOKEN_FLOAT:
82 return "FLOAT";
83 case TOKEN_DOUBLE:
84 return "DOUBLE";
85 case TOKEN_CHAR:
86 return "CHAR";
87 case TOKEN_UCHAR:
88 return "UCHAR";
89 case TOKEN_SWORD:
90 return "SWORD";
91 case TOKEN_SDWORD:
92 return "SDWORD";
93 case TOKEN_VOID:
94 return "VOID";
95 case TOKEN_LPSTR:
96 return "STRING";
97 case TOKEN_UNICODE:
98 return "UNICODE";
99 case TOKEN_CSTRING:
100 return "CSTRING ";
101 default:
102 break;
103 }
104 return NULL;
105}
#define NULL
Definition: types.h:112

Referenced by dump_template().

◆ get_TOKEN()

static WORD get_TOKEN ( parse_buffer *  buf)
static

Definition at line 843 of file parsing.c.

844{
845 if (buf->token_present)
846 {
847 buf->token_present = FALSE;
848 return buf->current_token;
849 }
850
851 buf->current_token = parse_TOKEN(buf);
852
853 return buf->current_token;
854}

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

521{
522 char tmp[512];
523 DWORD pos = 0;
524 char c;
525 float decimal;
526 BOOL dot = FALSE;
527
528 while (pos < buf->rem_bytes && !is_separator(c = *(buf->buffer+pos)))
529 {
530 if (!((!pos && (c == '-')) || ((c >= '0') && (c <= '9')) || (!dot && (c == '.'))))
531 return FALSE;
532 if (c == '.')
533 dot = TRUE;
534 if (pos < sizeof(tmp))
535 tmp[pos] = c;
536 pos++;
537 }
538 tmp[min(pos, sizeof(tmp) - 1)] = 0;
539
540 buf->buffer += pos;
541 buf->rem_bytes -= pos;
542
543 sscanf(tmp, "%f", &decimal);
544
545 TRACE("Found float %s - %f\n", tmp, decimal);
546
547 *(float*)buf->value = decimal;
548
549 return TRUE;
550}
_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:347

Referenced by map_wave_alu_op(), parse_TOKEN(), and sm6_dx_map_wave_op().

◆ is_guid()

static BOOL is_guid ( parse_buffer *  buf)
static

Definition at line 438 of file parsing.c.

439{
440 char tmp[50];
441 DWORD pos = 1;
442 GUID class_id;
443 DWORD tab[10];
444 int ret;
445
446 if (buf->rem_bytes < 38 || *buf->buffer != '<')
447 return FALSE;
448 tmp[0] = '<';
449 while (pos < sizeof(tmp) - 2 && *(buf->buffer+pos) != '>')
450 {
451 tmp[pos] = *(buf->buffer+pos);
452 pos++;
453 }
454 tmp[pos++] = '>';
455 tmp[pos] = 0;
456 if (pos != 38 /* <+36+> */)
457 {
458 TRACE("Wrong guid %s (%lu).\n", tmp, pos);
459 return FALSE;
460 }
461 buf->buffer += pos;
462 buf->rem_bytes -= pos;
463
464 ret = sscanf(tmp, "<%08lx-%04lx-%04lx-%02lx%02lx-%02lx%02lx%02lx%02lx%02lx%02lx>",
465 &class_id.Data1, tab, tab+1, tab+2, tab+3, tab+4, tab+5, tab+6, tab+7, tab+8, tab+9);
466 if (ret != 11)
467 {
468 TRACE("Wrong guid %s (%lu).\n", tmp, pos);
469 return FALSE;
470 }
471 TRACE("Found guid %s (%lu).\n", tmp, pos);
472
473 class_id.Data2 = tab[0];
474 class_id.Data3 = tab[1];
475 class_id.Data4[0] = tab[2];
476 class_id.Data4[1] = tab[3];
477 class_id.Data4[2] = tab[4];
478 class_id.Data4[3] = tab[5];
479 class_id.Data4[4] = tab[6];
480 class_id.Data4[5] = tab[7];
481 class_id.Data4[6] = tab[8];
482 class_id.Data4[7] = tab[9];
483
484 *(GUID*)buf->value = class_id;
485
486 return TRUE;
487}
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 552 of file parsing.c.

553{
554 char tmp[512];
555 DWORD pos = 0;
556 char c;
558
559 while (pos < buf->rem_bytes && !is_separator(c = *(buf->buffer+pos)))
560 {
561 if (!((c >= '0') && (c <= '9')))
562 return FALSE;
563 if (pos < sizeof(tmp))
564 tmp[pos] = c;
565 pos++;
566 }
567 tmp[min(pos, sizeof(tmp) - 1)] = 0;
568
569 buf->buffer += pos;
570 buf->rem_bytes -= pos;
571
572 sscanf(tmp, "%ld", &integer);
573
574 TRACE("Found integer %s - %ld.\n", tmp, integer);
575
576 *(DWORD*)buf->value = integer;
577
578 return TRUE;
579}

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

◆ is_keyword()

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

Definition at line 380 of file parsing.c.

381{
382 char tmp[8]; /* longest keyword size (template) */
384
385 if (!read_bytes(buf, tmp, len))
386 return FALSE;
387 if (_strnicmp(tmp, keyword, len))
388 {
390 return FALSE;
391 }
392
393 if (!read_bytes(buf, tmp, 1))
394 return TRUE;
395 if (is_separator(tmp[0]))
396 {
397 rewind_bytes(buf, 1);
398 return TRUE;
399 }
400 rewind_bytes(buf, len+1);
401 return FALSE;
402}
#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:148
static void rewind_bytes(parse_buffer *buf, DWORD size)
Definition: parsing.c:158

Referenced by get_keyword_token().

◆ is_name()

static BOOL is_name ( parse_buffer *  buf)
static

Definition at line 489 of file parsing.c.

490{
491 char tmp[512];
492 DWORD pos = 0;
493 char c;
494 BOOL error = FALSE;
495 while (pos < buf->rem_bytes && !is_separator(c = *(buf->buffer+pos)))
496 {
497 if (!(((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z')) || ((c >= '0') && (c <= '9')) || (c == '_') || (c == '-')))
498 error = TRUE;
499 if (pos < sizeof(tmp))
500 tmp[pos] = c;
501 pos++;
502 }
503 tmp[min(pos, sizeof(tmp) - 1)] = 0;
504
505 if (error)
506 {
507 TRACE("Wrong name %s\n", tmp);
508 return FALSE;
509 }
510
511 buf->buffer += pos;
512 buf->rem_bytes -= pos;
513
514 TRACE("Found name %s\n", tmp);
515 strcpy((char*)buf->value, tmp);
516
517 return TRUE;
518}
#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 328 of file parsing.c.

329{
330 switch(c)
331 {
332 case '{':
333 case '}':
334 case '[':
335 case ']':
336 case '(':
337 case ')':
338 case '<':
339 case '>':
340 case ',':
341 case ';':
342 return TRUE;
343 }
344 return FALSE;
345}

Referenced by is_separator(), and parse_TOKEN().

◆ is_primitive_type()

static BOOL is_primitive_type ( WORD  token)
inlinestatic

Definition at line 867 of file parsing.c.

868{
869 BOOL ret;
870 switch(token)
871 {
872 case TOKEN_WORD:
873 case TOKEN_DWORD:
874 case TOKEN_FLOAT:
875 case TOKEN_DOUBLE:
876 case TOKEN_CHAR:
877 case TOKEN_UCHAR:
878 case TOKEN_SWORD:
879 case TOKEN_SDWORD:
880 case TOKEN_LPSTR:
881 case TOKEN_UNICODE:
882 case TOKEN_CSTRING:
883 ret = TRUE;
884 break;
885 default:
886 ret = FALSE;
887 break;
888 }
889 return ret;
890}

Referenced by parse_template_members_list().

◆ is_separator()

static BOOL is_separator ( char  c)
inlinestatic

Definition at line 347 of file parsing.c.

348{
349 return is_space(c) || is_operator(c);
350}
#define is_space(c)
Definition: astoll.c:38
static BOOL is_operator(char c)
Definition: parsing.c:328

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

◆ is_space()

static BOOL is_space ( char  c)
static

Definition at line 314 of file parsing.c.

315{
316 switch (c)
317 {
318 case 0x00:
319 case 0x0D:
320 case 0x0A:
321 case ' ':
322 case '\t':
323 return TRUE;
324 }
325 return FALSE;
326}

◆ is_string()

static BOOL is_string ( parse_buffer *  buf)
static

Definition at line 581 of file parsing.c.

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

Referenced by builtin_eval(), DateConstr_value(), do_make_empty_object(), equal_values(), handle_mid(), hlsl_dump_var_default_values(), 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 164 of file parsing.c.

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

Referenced by IDirectXFileImpl_CreateEnumObject(), and IDirectXFileImpl_RegisterTemplates().

◆ parse_object()

BOOL parse_object ( parse_buffer *  buf)

Definition at line 1361 of file parsing.c.

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

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

1276{
1277 buf->pxo->nb_children = 0;
1278
1280 return FALSE;
1281
1282 if (allow_optional)
1283 {
1284 buf->pxo->size = buf->cur_pos_data - buf->pxo->pos_data;
1285
1286 while (1)
1287 {
1289 {
1290 ULONG i, j;
1291 get_TOKEN(buf);
1292 if (get_TOKEN(buf) != TOKEN_NAME)
1293 return FALSE;
1294 if (get_TOKEN(buf) != TOKEN_CBRACE)
1295 return FALSE;
1296 TRACE("Found optional reference %s\n", (char*)buf->value);
1297 for (i = 0; i < (buf->nb_pxo_globals+1); i++)
1298 {
1299 for (j = 0; j < (buf->pxo_globals[i])[0].nb_subobjects; j++)
1300 {
1301 if (!strcmp((buf->pxo_globals[i])[j].name, (char*)buf->value))
1302 goto _exit;
1303 }
1304 }
1305_exit:
1306 if (i == (buf->nb_pxo_globals+1))
1307 {
1308 ERR("Reference to unknown object %s\n", (char*)buf->value);
1309 return FALSE;
1310 }
1311
1312 if (buf->pxo->root->nb_subobjects >= MAX_SUBOBJECTS)
1313 {
1314 FIXME("Too many sub-objects\n");
1315 return FALSE;
1316 }
1317
1318 buf->pxo->children[buf->pxo->nb_children] = &buf->pxo_tab[buf->pxo->root->nb_subobjects++];
1319 buf->pxo->children[buf->pxo->nb_children]->ptarget = &(buf->pxo_globals[i])[j];
1320 buf->pxo->children[buf->pxo->nb_children]->binary = FALSE;
1321 buf->pxo->nb_children++;
1322 }
1323 else if (check_TOKEN(buf) == TOKEN_NAME)
1324 {
1325 xobject* pxo = buf->pxo;
1326
1327 if (buf->pxo->root->nb_subobjects >= MAX_SUBOBJECTS)
1328 {
1329 FIXME("Too many sub-objects\n");
1330 return FALSE;
1331 }
1332
1333 buf->pxo = buf->pxo->children[buf->pxo->nb_children] = &buf->pxo_tab[buf->pxo->root->nb_subobjects];
1334 pxo->root->nb_subobjects++;
1335
1336 TRACE("Enter optional %s\n", (char*)buf->value);
1337 buf->level++;
1338 if (!parse_object(buf))
1339 {
1340 buf->level--;
1341 return FALSE;
1342 }
1343 buf->level--;
1344 buf->pxo = pxo;
1345 buf->pxo->nb_children++;
1346 }
1347 else
1348 break;
1349 }
1350 }
1351
1352 if (buf->pxo->nb_children > MAX_CHILDREN)
1353 {
1354 FIXME("Too many children: %lu.\n", buf->pxo->nb_children);
1355 return FALSE;
1356 }
1357
1358 return TRUE;
1359}
#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:1361
static BOOL parse_object_members_list(parse_buffer *buf)
Definition: parsing.c:1121
_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 1056 of file parsing.c.

1057{
1059 return FALSE;
1060 if (get_TOKEN(buf) != TOKEN_NAME)
1061 return FALSE;
1062 strcpy(buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].name, (char*)buf->value);
1063 if (get_TOKEN(buf) != TOKEN_OBRACE)
1064 return FALSE;
1065 if (get_TOKEN(buf) != TOKEN_GUID)
1066 return FALSE;
1067 buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].class_id = *(GUID*)buf->value;
1069 return FALSE;
1070 if (get_TOKEN(buf) != TOKEN_CBRACE)
1071 return FALSE;
1072
1073 TRACE("%lu - %s - %s\n", buf->pdxf->nb_xtemplates, buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].name,
1074 debugstr_guid(&buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates].class_id));
1075 buf->pdxf->nb_xtemplates++;
1076
1077 return TRUE;
1078}
#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:1040

Referenced by parse_templates().

◆ parse_template_members_list()

static BOOL parse_template_members_list ( parse_buffer *  buf)
static

Definition at line 925 of file parsing.c.

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

893{
894 xtemplate* cur_template = &buf->pdxf->xtemplates[buf->pdxf->nb_xtemplates];
895
896 if (check_TOKEN(buf) == TOKEN_DOT)
897 {
898 get_TOKEN(buf);
899 if (get_TOKEN(buf) != TOKEN_DOT)
900 return FALSE;
901 if (get_TOKEN(buf) != TOKEN_DOT)
902 return FALSE;
903 cur_template->open = TRUE;
904 }
905 else
906 {
907 while (1)
908 {
909 if (get_TOKEN(buf) != TOKEN_NAME)
910 return FALSE;
911 strcpy(cur_template->children[cur_template->nb_children], (char*)buf->value);
912 if (check_TOKEN(buf) == TOKEN_GUID)
913 get_TOKEN(buf);
914 cur_template->nb_children++;
916 break;
917 get_TOKEN(buf);
918 }
919 cur_template->open = FALSE;
920 }
921
922 return TRUE;
923}

Referenced by parse_template_parts().

◆ parse_template_parts()

static BOOL parse_template_parts ( parse_buffer *  buf)
static

Definition at line 1040 of file parsing.c.

1041{
1043 return FALSE;
1045 {
1046 get_TOKEN(buf);
1048 return FALSE;
1050 return FALSE;
1051 }
1052
1053 return TRUE;
1054}
static BOOL parse_template_members_list(parse_buffer *buf)
Definition: parsing.c:925
static BOOL parse_template_option_info(parse_buffer *buf)
Definition: parsing.c:892

Referenced by parse_template().

◆ parse_templates()

BOOL parse_templates ( parse_buffer *  buf,
BOOL  templates_only 
)

Definition at line 1080 of file parsing.c.

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

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

◆ parse_TOKEN()

static WORD parse_TOKEN ( parse_buffer *  buf)
static

Definition at line 620 of file parsing.c.

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

Referenced by check_TOKEN(), and get_TOKEN().

◆ read_bytes()

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

Definition at line 148 of file parsing.c.

149{
150 if (buf->rem_bytes < size)
151 return FALSE;
152 memcpy(data, buf->buffer, size);
153 buf->buffer += size;
154 buf->rem_bytes -= size;
155 return TRUE;
156}
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 158 of file parsing.c.

159{
160 buf->buffer -= size;
161 buf->rem_bytes += size;
162}

Referenced by is_keyword(), and parse_TOKEN().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3dxof_parsing  )