ReactOS  0.4.13-dev-235-g7373cb3
infcore.c File Reference
#include "inflib.h"
#include <debug.h>
Include dependency graph for infcore.c:

Go to the source code of this file.

Classes

struct  parser
 

Macros

#define NDEBUG
 
#define CONTROL_Z   '\x1a'
 
#define MAX_SECTION_NAME_LEN   255
 
#define MAX_FIELD_LEN   511 /* larger fields get silently truncated */
 
#define MAX_STRING_LEN   (MAX_INF_STRING_LENGTH+1)
 

Typedefs

typedef const WCHAR *(* parser_state_func) (struct parser *parser, const WCHAR *pos)
 

Enumerations

enum  parser_state {
  HEADER, PARSE_WIN31_LINE, LINE_START, KEY_NAME,
  DELETE_KEY, DEFAULT_VALUE_NAME, QUOTED_VALUE_NAME, DATA_START,
  DELETE_VALUE, DATA_TYPE, STRING_DATA, DWORD_DATA,
  HEX_DATA, EOL_BACKSLASH, HEX_MULTILINE, UNKNOWN_DATA,
  SET_VALUE, NB_PARSER_STATES, LINE_START, SECTION_NAME,
  KEY_NAME, VALUE_NAME, EOL_BACKSLASH, QUOTES,
  LEADING_SPACES, TRAILING_SPACES, COMMENT, NB_PARSER_STATES,
  LINE_START, SECTION_NAME, KEY_NAME, VALUE_NAME,
  EOL_BACKSLASH, QUOTES, LEADING_SPACES, TRAILING_SPACES,
  COMMENT, NB_PARSER_STATES, LINE_START, SECTION_NAME,
  KEY_NAME, VALUE_NAME, EOL_BACKSLASH, QUOTES,
  LEADING_SPACES, TRAILING_SPACES, COMMENT, NB_PARSER_STATES
}
 

Functions

static const WCHARline_start_state (struct parser *parser, const WCHAR *pos)
 
static const WCHARsection_name_state (struct parser *parser, const WCHAR *pos)
 
static const WCHARkey_name_state (struct parser *parser, const WCHAR *pos)
 
static const WCHARvalue_name_state (struct parser *parser, const WCHAR *pos)
 
static const WCHAReol_backslash_state (struct parser *parser, const WCHAR *pos)
 
static const WCHARquotes_state (struct parser *parser, const WCHAR *pos)
 
static const WCHARleading_spaces_state (struct parser *parser, const WCHAR *pos)
 
static const WCHARtrailing_spaces_state (struct parser *parser, const WCHAR *pos)
 
static const WCHARcomment_state (struct parser *parser, const WCHAR *pos)
 
static PINFCACHELINE InfpFreeLine (PINFCACHELINE Line)
 
PINFCACHESECTION InfpFreeSection (PINFCACHESECTION Section)
 
PINFCACHESECTION InfpFindSection (PINFCACHE Cache, PCWSTR Name)
 
PINFCACHESECTION InfpAddSection (PINFCACHE Cache, PCWSTR Name)
 
PINFCACHELINE InfpAddLine (PINFCACHESECTION Section)
 
PVOID InfpAddKeyToLine (PINFCACHELINE Line, PCWSTR Key)
 
PVOID InfpAddFieldToLine (PINFCACHELINE Line, PCWSTR Data)
 
PINFCACHELINE InfpFindKeyLine (PINFCACHESECTION Section, PCWSTR Key)
 
static __inline void push_state (struct parser *parser, enum parser_state state)
 
static __inline void pop_state (struct parser *parser)
 
static __inline enum parser_state set_state (struct parser *parser, enum parser_state state)
 
static __inline int is_eof (struct parser *parser, const WCHAR *ptr)
 
static __inline int is_eol (struct parser *parser, const WCHAR *ptr)
 
static int push_token (struct parser *parser, const WCHAR *pos)
 
static PVOID add_section_from_token (struct parser *parser)
 
static struct fieldadd_field_from_token (struct parser *parser, int is_key)
 
static void close_current_line (struct parser *parser)
 
INFSTATUS InfpParseBuffer (PINFCACHE file, const WCHAR *buffer, const WCHAR *end, PULONG error_line)
 

Variables

static const parser_state_func parser_funcs [NB_PARSER_STATES]
 

Macro Definition Documentation

◆ CONTROL_Z

#define CONTROL_Z   '\x1a'

Definition at line 16 of file infcore.c.

◆ MAX_FIELD_LEN

#define MAX_FIELD_LEN   511 /* larger fields get silently truncated */

Definition at line 18 of file infcore.c.

◆ MAX_SECTION_NAME_LEN

#define MAX_SECTION_NAME_LEN   255

Definition at line 17 of file infcore.c.

◆ MAX_STRING_LEN

#define MAX_STRING_LEN   (MAX_INF_STRING_LENGTH+1)

Definition at line 20 of file infcore.c.

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file infcore.c.

Typedef Documentation

◆ parser_state_func

typedef const WCHAR*(* parser_state_func) (struct parser *parser, const WCHAR *pos)

Definition at line 56 of file infcore.c.

Enumeration Type Documentation

◆ parser_state

Enumerator
HEADER 
PARSE_WIN31_LINE 
LINE_START 
KEY_NAME 
DELETE_KEY 
DEFAULT_VALUE_NAME 
QUOTED_VALUE_NAME 
DATA_START 
DELETE_VALUE 
DATA_TYPE 
STRING_DATA 
DWORD_DATA 
HEX_DATA 
EOL_BACKSLASH 
HEX_MULTILINE 
UNKNOWN_DATA 
SET_VALUE 
NB_PARSER_STATES 
LINE_START 
SECTION_NAME 
KEY_NAME 
VALUE_NAME 
EOL_BACKSLASH 
QUOTES 
LEADING_SPACES 
TRAILING_SPACES 
COMMENT 
NB_PARSER_STATES 
LINE_START 
SECTION_NAME 
KEY_NAME 
VALUE_NAME 
EOL_BACKSLASH 
QUOTES 
LEADING_SPACES 
TRAILING_SPACES 
COMMENT 
NB_PARSER_STATES 
LINE_START 
SECTION_NAME 
KEY_NAME 
VALUE_NAME 
EOL_BACKSLASH 
QUOTES 
LEADING_SPACES 
TRAILING_SPACES 
COMMENT 
NB_PARSER_STATES 

Definition at line 25 of file infcore.c.

26 {
27  LINE_START, /* at beginning of a line */
28  SECTION_NAME, /* parsing a section name */
29  KEY_NAME, /* parsing a key name */
30  VALUE_NAME, /* parsing a value name */
31  EOL_BACKSLASH, /* backslash at end of line */
32  QUOTES, /* inside quotes */
33  LEADING_SPACES, /* leading spaces */
34  TRAILING_SPACES, /* trailing spaces */
35  COMMENT, /* inside a comment */
37 };
Definition: infcore.c:32

Function Documentation

◆ add_field_from_token()

static struct field* add_field_from_token ( struct parser parser,
int  is_key 
)
static

Definition at line 447 of file infcore.c.

448 {
449  PVOID field;
450 
451  if (!parser->line) /* need to start a new line */
452  {
453  if (parser->cur_section == NULL) /* got a line before the first section */
454  {
456  return NULL;
457  }
458 
460  if (parser->line == NULL)
461  goto error;
462  }
463  else
464  {
465 // assert(!is_key);
466  }
467 
468  if (is_key)
469  {
471  }
472  else
473  {
475  }
476 
477  if (field != NULL)
478  {
479  parser->token_len = 0;
480  return field;
481  }
482 
483 error:
485  return NULL;
486 }
#define error(str)
Definition: mkdosfs.c:1605
PINFCACHELINE InfpAddLine(PINFCACHESECTION Section)
Definition: infcore.c:216
PINFCACHELINE line
Definition: inffile.c:113
#define INF_STATUS_NOT_ENOUGH_MEMORY
Definition: infpriv.h:19
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:43
unsigned int token_len
Definition: inffile.c:116
unsigned int error
Definition: inffile.c:115
PINFCACHESECTION cur_section
Definition: inffile.c:112
CHAR token[MAX_FIELD_LEN+1]
Definition: inffile.c:117
Definition: import.c:86
PVOID InfpAddFieldToLine(PINFCACHELINE Line, PCWSTR Data)
Definition: infcore.c:283
#define INF_STATUS_WRONG_INF_STYLE
Definition: infpriv.h:18
PVOID InfpAddKeyToLine(PINFCACHELINE Line, PCWSTR Key)
Definition: infcore.c:254

Referenced by key_name_state(), and value_name_state().

◆ add_section_from_token()

static PVOID add_section_from_token ( struct parser parser)
static

Definition at line 415 of file infcore.c.

416 {
417  PINFCACHESECTION Section;
418 
420  {
422  return NULL;
423  }
424 
425  Section = InfpFindSection(parser->file,
426  parser->token);
427  if (Section == NULL)
428  {
429  /* need to create a new one */
430  Section= InfpAddSection(parser->file,
431  parser->token);
432  if (Section == NULL)
433  {
435  return NULL;
436  }
437  }
438 
439  parser->token_len = 0;
440  parser->cur_section = Section;
441 
442  return (PVOID)Section;
443 }
PINFCACHESECTION InfpAddSection(PINFCACHE Cache, PCWSTR Name)
Definition: infcore.c:171
PINFCACHESECTION InfpFindSection(PINFCACHE Cache, PCWSTR Name)
Definition: infcore.c:143
#define INF_STATUS_SECTION_NAME_TOO_LONG
Definition: infpriv.h:17
#define INF_STATUS_NOT_ENOUGH_MEMORY
Definition: infpriv.h:19
smooth NULL
Definition: ftsmooth.c:416
#define MAX_SECTION_NAME_LEN
Definition: infcore.c:17
unsigned int token_len
Definition: inffile.c:116
unsigned int error
Definition: inffile.c:115
FILE * file
Definition: import.c:88
PINFCACHESECTION cur_section
Definition: inffile.c:112
CHAR token[MAX_FIELD_LEN+1]
Definition: inffile.c:117
Definition: import.c:86

Referenced by section_name_state().

◆ close_current_line()

static void close_current_line ( struct parser parser)
static

Definition at line 490 of file infcore.c.

491 {
492  parser->line = NULL;
493 }
PINFCACHELINE line
Definition: inffile.c:113
smooth NULL
Definition: ftsmooth.c:416
Definition: import.c:86

Referenced by line_start_state().

◆ comment_state()

static const WCHAR * comment_state ( struct parser parser,
const WCHAR pos 
)
static

Definition at line 782 of file infcore.c.

783 {
784  const WCHAR *p = pos;
785 
786  while (!is_eol( parser, p ))
787  p++;
788  pop_state( parser );
789  return p;
790 }
static __inline void pop_state(struct parser *parser)
Definition: infcore.c:349
static __inline int is_eol(struct parser *parser, const WCHAR *ptr)
Definition: infcore.c:373
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: import.c:86
GLfloat GLfloat p
Definition: glext.h:8902

◆ eol_backslash_state()

static const WCHAR * eol_backslash_state ( struct parser parser,
const WCHAR pos 
)
static

Definition at line 669 of file infcore.c.

670 {
671  const WCHAR *p;
672 
673  for (p = pos; !is_eof( parser, p ); p++)
674  {
675  switch(*p)
676  {
677  case '\r':
678  continue;
679 
680  case '\n':
681  parser->line_pos++;
682  parser->start = p + 1;
684  return p + 1;
685 
686  case '\\':
687  continue;
688 
689  case ';':
692  return p + 1;
693 
694  default:
695  if (isspaceW(*p))
696  continue;
697  push_token( parser, p );
698  pop_state( parser );
699  return p;
700  }
701  }
702  parser->start = p;
703  pop_state( parser );
704 
705  return p;
706 }
const CHAR * start
Definition: inffile.c:105
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
static __inline void pop_state(struct parser *parser)
Definition: infcore.c:349
static __inline enum parser_state set_state(struct parser *parser, enum parser_state state)
Definition: infcore.c:357
static __inline int is_eof(struct parser *parser, const WCHAR *ptr)
Definition: infcore.c:366
static __inline void push_state(struct parser *parser, enum parser_state state)
Definition: infcore.c:341
__wchar_t WCHAR
Definition: xmlstorage.h:180
static int push_token(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:384
Definition: import.c:86
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int line_pos
Definition: inffile.c:114

◆ InfpAddFieldToLine()

PVOID InfpAddFieldToLine ( PINFCACHELINE  Line,
PCWSTR  Data 
)

Definition at line 283 of file infcore.c.

285 {
286  PINFCACHEFIELD Field;
287  ULONG Size;
288 
290  Data[strlenW(Data) + 1]);
291  Field = (PINFCACHEFIELD)MALLOC(Size);
292  if (Field == NULL)
293  {
294  DPRINT1("MALLOC() failed\n");
295  return NULL;
296  }
297  ZEROMEMORY (Field,
298  Size);
299  strcpyW(Field->Data, Data);
300 
301  /* Append key */
302  if (Line->FirstField == NULL)
303  {
304  Line->FirstField = Field;
305  Line->LastField = Field;
306  }
307  else
308  {
309  Line->LastField->Next = Field;
310  Field->Prev = Line->LastField;
311  Line->LastField = Field;
312  }
313  Line->FieldCount++;
314 
315  return (PVOID)Field;
316 }
#define MALLOC(Size)
Definition: builddep.h:73
struct _INFCACHEFIELD * Prev
Definition: inffile.c:48
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
struct _INFCACHEFIELD * PINFCACHEFIELD
smooth NULL
Definition: ftsmooth.c:416
Definition: ncftp.h:79
CHAR Data[1]
Definition: inffile.c:50
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define ZEROMEMORY(Area, Size)
Definition: builddep.h:74

Referenced by add_field_from_token().

◆ InfpAddKeyToLine()

PVOID InfpAddKeyToLine ( PINFCACHELINE  Line,
PCWSTR  Key 
)

Definition at line 254 of file infcore.c.

256 {
257  if (Line == NULL)
258  {
259  DPRINT1("Invalid Line\n");
260  return NULL;
261  }
262 
263  if (Line->Key != NULL)
264  {
265  DPRINT1("Line already has a key\n");
266  return NULL;
267  }
268 
269  Line->Key = (PWCHAR)MALLOC((strlenW(Key) + 1) * sizeof(WCHAR));
270  if (Line->Key == NULL)
271  {
272  DPRINT1("MALLOC() failed\n");
273  return NULL;
274  }
275 
276  strcpyW(Line->Key, Key);
277 
278  return (PVOID)Line->Key;
279 }
#define MALLOC(Size)
Definition: builddep.h:73
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
uint16_t * PWCHAR
Definition: typedefs.h:54
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: ncftp.h:79
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define DPRINT1
Definition: precomp.h:8

Referenced by add_field_from_token().

◆ InfpAddLine()

PINFCACHELINE InfpAddLine ( PINFCACHESECTION  Section)

Definition at line 216 of file infcore.c.

217 {
219 
220  if (Section == NULL)
221  {
222  DPRINT("Invalid parameter\n");
223  return NULL;
224  }
225 
227  if (Line == NULL)
228  {
229  DPRINT("MALLOC() failed\n");
230  return NULL;
231  }
233  sizeof(INFCACHELINE));
234 
235  /* Append line */
236  if (Section->FirstLine == NULL)
237  {
238  Section->FirstLine = Line;
239  Section->LastLine = Line;
240  }
241  else
242  {
243  Section->LastLine->Next = Line;
244  Line->Prev = Section->LastLine;
245  Section->LastLine = Line;
246  }
247  Section->LineCount++;
248 
249  return Line;
250 }
LONG LineCount
Definition: inffile.c:75
#define MALLOC(Size)
Definition: builddep.h:73
struct _INFCACHELINE * PINFCACHELINE
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
Definition: ncftp.h:79
PINFCACHELINE FirstLine
Definition: inffile.c:72
struct _INFCACHELINE * Next
Definition: inffile.c:55
PINFCACHELINE LastLine
Definition: inffile.c:73
#define ZEROMEMORY(Area, Size)
Definition: builddep.h:74
struct Line Line

Referenced by add_field_from_token(), and InfpAddLineWithKey().

◆ InfpAddSection()

PINFCACHESECTION InfpAddSection ( PINFCACHE  Cache,
PCWSTR  Name 
)

Definition at line 171 of file infcore.c.

173 {
174  PINFCACHESECTION Section = NULL;
175  ULONG Size;
176 
177  if (Cache == NULL || Name == NULL)
178  {
179  DPRINT("Invalid parameter\n");
180  return NULL;
181  }
182 
183  /* Allocate and initialize the new section */
185  Name[strlenW(Name) + 1]);
186  Section = (PINFCACHESECTION)MALLOC(Size);
187  if (Section == NULL)
188  {
189  DPRINT("MALLOC() failed\n");
190  return NULL;
191  }
192  ZEROMEMORY (Section,
193  Size);
194 
195  /* Copy section name */
196  strcpyW(Section->Name, Name);
197 
198  /* Append section */
199  if (Cache->FirstSection == NULL)
200  {
201  Cache->FirstSection = Section;
202  Cache->LastSection = Section;
203  }
204  else
205  {
206  Cache->LastSection->Next = Section;
207  Section->Prev = Cache->LastSection;
208  Cache->LastSection = Section;
209  }
210 
211  return Section;
212 }
CHAR Name[1]
Definition: inffile.c:77
#define MALLOC(Size)
Definition: builddep.h:73
struct _INFCACHESECTION * PINFCACHESECTION
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
Definition: fatfs.h:173
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
struct _INFCACHESECTION * Prev
Definition: inffile.c:70
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int ULONG
Definition: retypes.h:1
#define ZEROMEMORY(Area, Size)
Definition: builddep.h:74

Referenced by add_section_from_token(), and InfpFindOrAddSection().

◆ InfpFindKeyLine()

PINFCACHELINE InfpFindKeyLine ( PINFCACHESECTION  Section,
PCWSTR  Key 
)

Definition at line 320 of file infcore.c.

322 {
324 
325  Line = Section->FirstLine;
326  while (Line != NULL)
327  {
328  if (Line->Key != NULL && strcmpiW(Line->Key, Key) == 0)
329  {
330  return Line;
331  }
332 
333  Line = Line->Next;
334  }
335 
336  return NULL;
337 }
smooth NULL
Definition: ftsmooth.c:416
Definition: ncftp.h:79
#define strcmpiW(s1, s2)
Definition: unicode.h:39
PINFCACHELINE FirstLine
Definition: inffile.c:72
struct Line Line

Referenced by InfpFindFirstLine().

◆ InfpFindSection()

PINFCACHESECTION InfpFindSection ( PINFCACHE  Cache,
PCWSTR  Name 
)

Definition at line 143 of file infcore.c.

145 {
146  PINFCACHESECTION Section = NULL;
147 
148  if (Cache == NULL || Name == NULL)
149  {
150  return NULL;
151  }
152 
153  /* iterate through list of sections */
154  Section = Cache->FirstSection;
155  while (Section != NULL)
156  {
157  if (strcmpiW(Section->Name, Name) == 0)
158  {
159  return Section;
160  }
161 
162  /* get the next section*/
163  Section = Section->Next;
164  }
165 
166  return NULL;
167 }
CHAR Name[1]
Definition: inffile.c:77
Definition: fatfs.h:173
struct _INFCACHESECTION * Next
Definition: inffile.c:69
smooth NULL
Definition: ftsmooth.c:416
#define strcmpiW(s1, s2)
Definition: unicode.h:39

Referenced by add_section_from_token(), InfpFindFirstLine(), InfpFindOrAddSection(), and InfpParseBuffer().

◆ InfpFreeLine()

static PINFCACHELINE InfpFreeLine ( PINFCACHELINE  Line)
static

Definition at line 86 of file infcore.c.

87 {
88  PINFCACHELINE Next;
89  PINFCACHEFIELD Field;
90 
91  if (Line == NULL)
92  {
93  return NULL;
94  }
95 
96  Next = Line->Next;
97  if (Line->Key != NULL)
98  {
99  FREE (Line->Key);
100  Line->Key = NULL;
101  }
102 
103  /* Remove data fields */
104  while (Line->FirstField != NULL)
105  {
106  Field = Line->FirstField->Next;
107  FREE (Line->FirstField);
108  Line->FirstField = Field;
109  }
110  Line->LastField = NULL;
111 
112  FREE (Line);
113 
114  return Next;
115 }
smooth NULL
Definition: ftsmooth.c:416
Definition: ncftp.h:79
#define FREE(ptr, size)
Definition: auth_des.c:64

Referenced by InfpFreeSection().

◆ InfpFreeSection()

PINFCACHESECTION InfpFreeSection ( PINFCACHESECTION  Section)

Definition at line 119 of file infcore.c.

120 {
121  PINFCACHESECTION Next;
122 
123  if (Section == NULL)
124  {
125  return NULL;
126  }
127 
128  /* Release all keys */
129  Next = Section->Next;
130  while (Section->FirstLine != NULL)
131  {
132  Section->FirstLine = InfpFreeLine (Section->FirstLine);
133  }
134  Section->LastLine = NULL;
135 
136  FREE (Section);
137 
138  return Next;
139 }
static PINFCACHELINE InfpFreeLine(PINFCACHELINE Line)
Definition: infcore.c:86
struct _INFCACHESECTION * Next
Definition: inffile.c:69
smooth NULL
Definition: ftsmooth.c:416
#define FREE(ptr, size)
Definition: auth_des.c:64
PINFCACHELINE FirstLine
Definition: inffile.c:72
PINFCACHELINE LastLine
Definition: inffile.c:73

Referenced by InfCloseFile(), and InfHostCloseFile().

◆ InfpParseBuffer()

INFSTATUS InfpParseBuffer ( PINFCACHE  file,
const WCHAR buffer,
const WCHAR end,
PULONG  error_line 
)

Definition at line 795 of file infcore.c.

799 {
800  struct parser parser;
801  const WCHAR *pos = buffer;
802 
803  parser.start = buffer;
804  parser.end = end;
805  parser.file = file;
806  parser.line = NULL;
808  parser.stack_pos = 0;
810  parser.line_pos = 1;
811  parser.error = 0;
812  parser.token_len = 0;
813 
814  /* parser main loop */
815  while (pos)
817 
818  if (parser.error)
819  {
820  if (error_line)
821  *error_line = parser.line_pos;
822  return parser.error;
823  }
824 
825  /* find the [strings] section */
826  file->StringsSection = InfpFindSection(file,
827  L"Strings");
828 
829  return INF_STATUS_SUCCESS;
830 }
int stack_pos
Definition: inffile.c:110
const CHAR * start
Definition: inffile.c:105
enum parser_state state
Definition: import.c:100
GLuint buffer
Definition: glext.h:5915
GLuint GLuint end
Definition: gl.h:1545
PINFCACHESECTION InfpFindSection(PINFCACHE Cache, PCWSTR Name)
Definition: infcore.c:143
PINFCACHELINE line
Definition: inffile.c:113
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
const char file[]
Definition: icontest.c:11
unsigned int token_len
Definition: inffile.c:116
unsigned int error
Definition: inffile.c:115
FILE * file
Definition: import.c:88
static const WCHAR L[]
Definition: oid.c:1250
PINFCACHESECTION cur_section
Definition: inffile.c:112
const CHAR * end
Definition: inffile.c:106
#define INF_STATUS_SUCCESS
Definition: builddep.h:77
Definition: import.c:86
unsigned int line_pos
Definition: inffile.c:114
static const parser_state_func parser_funcs[NB_PARSER_STATES]
Definition: infcore.c:69
Definition: fci.c:126

◆ is_eof()

static __inline int is_eof ( struct parser parser,
const WCHAR ptr 
)
static

Definition at line 366 of file infcore.c.

367 {
368  return (ptr >= parser->end || *ptr == CONTROL_Z || *ptr == 0);
369 }
#define CONTROL_Z
Definition: infcore.c:16
static PVOID ptr
Definition: dispmode.c:27
const CHAR * end
Definition: inffile.c:106
Definition: import.c:86

Referenced by eol_backslash_state(), and line_start_state().

◆ is_eol()

static __inline int is_eol ( struct parser parser,
const WCHAR ptr 
)
static

Definition at line 373 of file infcore.c.

374 {
375  return (ptr >= parser->end ||
376  *ptr == CONTROL_Z ||
377  *ptr == '\n' ||
378  (*ptr == '\r' && *(ptr + 1) == '\n') ||
379  *ptr == 0);
380 }
#define CONTROL_Z
Definition: infcore.c:16
static PVOID ptr
Definition: dispmode.c:27
const CHAR * end
Definition: inffile.c:106
Definition: import.c:86

Referenced by comment_state(), key_name_state(), leading_spaces_state(), quotes_state(), section_name_state(), trailing_spaces_state(), and value_name_state().

◆ key_name_state()

static const WCHAR * key_name_state ( struct parser parser,
const WCHAR pos 
)
static

Definition at line 562 of file infcore.c.

563 {
564  const WCHAR *p, *token_end = parser->start;
565 
566  for (p = pos; !is_eol( parser, p ); p++)
567  {
568  if (*p == ',') break;
569  switch(*p)
570  {
571 
572  case '=':
573  push_token( parser, token_end );
574  if (!add_field_from_token( parser, 1 )) return NULL;
575  parser->start = p + 1;
578  return p + 1;
579  case ';':
580  push_token( parser, token_end );
581  if (!add_field_from_token( parser, 0 )) return NULL;
584  return p + 1;
585  case '"':
586  push_token( parser, token_end );
587  parser->start = p + 1;
589  set_state( parser, QUOTES );
590  return p + 1;
591  case '\\':
592  push_token( parser, token_end );
593  parser->start = p;
596  return p;
597  default:
598  if (!isspaceW(*p)) token_end = p + 1;
599  else
600  {
601  push_token( parser, p );
604  return p;
605  }
606  break;
607  }
608  }
609  push_token( parser, token_end );
611  return p;
612 }
const CHAR * start
Definition: inffile.c:105
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
static __inline enum parser_state set_state(struct parser *parser, enum parser_state state)
Definition: infcore.c:357
smooth NULL
Definition: ftsmooth.c:416
static __inline int is_eol(struct parser *parser, const WCHAR *ptr)
Definition: infcore.c:373
static __inline void push_state(struct parser *parser, enum parser_state state)
Definition: infcore.c:341
Definition: infcore.c:32
__wchar_t WCHAR
Definition: xmlstorage.h:180
static struct field * add_field_from_token(struct parser *parser, int is_key)
Definition: infcore.c:447
static int push_token(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:384
Definition: import.c:86
GLfloat GLfloat p
Definition: glext.h:8902

◆ leading_spaces_state()

static const WCHAR * leading_spaces_state ( struct parser parser,
const WCHAR pos 
)
static

Definition at line 740 of file infcore.c.

741 {
742  const WCHAR *p;
743 
744  for (p = pos; !is_eol( parser, p ); p++)
745  {
746  if (*p == '\\')
747  {
748  parser->start = p;
750  return p;
751  }
752  if (!isspaceW(*p))
753  break;
754  }
755  parser->start = p;
756  pop_state( parser );
757  return p;
758 }
const CHAR * start
Definition: inffile.c:105
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
static __inline void pop_state(struct parser *parser)
Definition: infcore.c:349
static __inline enum parser_state set_state(struct parser *parser, enum parser_state state)
Definition: infcore.c:357
static __inline int is_eol(struct parser *parser, const WCHAR *ptr)
Definition: infcore.c:373
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: import.c:86
GLfloat GLfloat p
Definition: glext.h:8902

◆ line_start_state()

static const WCHAR * line_start_state ( struct parser parser,
const WCHAR pos 
)
static

Definition at line 498 of file infcore.c.

499 {
500  const WCHAR *p;
501 
502  for (p = pos; !is_eof( parser, p ); p++)
503  {
504  switch(*p)
505  {
506  case '\r':
507  continue;
508 
509  case '\n':
510  parser->line_pos++;
512  break;
513 
514  case ';':
517  return p + 1;
518 
519  case '[':
520  parser->start = p + 1;
522  return p + 1;
523 
524  default:
525  if (!isspaceW(*p))
526  {
527  parser->start = p;
529  return p;
530  }
531  break;
532  }
533  }
535  return NULL;
536 }
const CHAR * start
Definition: inffile.c:105
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
static __inline enum parser_state set_state(struct parser *parser, enum parser_state state)
Definition: infcore.c:357
static __inline int is_eof(struct parser *parser, const WCHAR *ptr)
Definition: infcore.c:366
smooth NULL
Definition: ftsmooth.c:416
static __inline void push_state(struct parser *parser, enum parser_state state)
Definition: infcore.c:341
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: import.c:86
static void close_current_line(struct parser *parser)
Definition: infcore.c:490
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int line_pos
Definition: inffile.c:114

◆ pop_state()

static __inline void pop_state ( struct parser parser)
static

Definition at line 349 of file infcore.c.

350 {
351 // assert( parser->stack_pos );
353 }
int stack_pos
Definition: inffile.c:110
enum parser_state state
Definition: import.c:100
enum parser_state stack[4]
Definition: inffile.c:109
Definition: import.c:86

Referenced by comment_state(), eol_backslash_state(), leading_spaces_state(), quotes_state(), and trailing_spaces_state().

◆ push_state()

static __inline void push_state ( struct parser parser,
enum parser_state  state 
)
static

Definition at line 341 of file infcore.c.

342 {
343 // assert( parser->stack_pos < sizeof(parser->stack)/sizeof(parser->stack[0]) );
345 }
int stack_pos
Definition: inffile.c:110
enum parser_state stack[4]
Definition: inffile.c:109
static int state
Definition: maze.c:121
Definition: import.c:86

Referenced by eol_backslash_state(), key_name_state(), line_start_state(), section_name_state(), and value_name_state().

◆ push_token()

static int push_token ( struct parser parser,
const WCHAR pos 
)
static

Definition at line 384 of file infcore.c.

385 {
386  UINT len = (UINT)(pos - parser->start);
387  const WCHAR *src = parser->start;
389 
392 
393  parser->token_len += len;
394  for ( ; len > 0; len--, dst++, src++)
395  {
396  if (*src)
397  {
398  *dst = *src;
399  }
400  else
401  {
402  *dst = ' ';
403  }
404  }
405 
406  *dst = 0;
407  parser->start = pos;
408 
409  return 0;
410 }
const CHAR * start
Definition: inffile.c:105
#define MAX_FIELD_LEN
Definition: infcore.c:18
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned int token_len
Definition: inffile.c:116
GLenum GLsizei len
Definition: glext.h:6722
GLenum src
Definition: glext.h:6340
CHAR token[MAX_FIELD_LEN+1]
Definition: inffile.c:117
GLenum GLenum dst
Definition: glext.h:6340
unsigned int UINT
Definition: ndis.h:50
Definition: import.c:86

Referenced by eol_backslash_state(), key_name_state(), quotes_state(), section_name_state(), and value_name_state().

◆ quotes_state()

static const WCHAR * quotes_state ( struct parser parser,
const WCHAR pos 
)
static

Definition at line 710 of file infcore.c.

711 {
712  const WCHAR *p, *token_end = parser->start;
713 
714  for (p = pos; !is_eol( parser, p ); p++)
715  {
716  if (*p == '"')
717  {
718  if (p+1 < parser->end && p[1] == '"') /* double quotes */
719  {
720  push_token( parser, p + 1 );
721  parser->start = token_end = p + 2;
722  p++;
723  }
724  else /* end of quotes */
725  {
726  push_token( parser, p );
727  parser->start = p + 1;
728  pop_state( parser );
729  return p + 1;
730  }
731  }
732  }
733  push_token( parser, p );
734  pop_state( parser );
735  return p;
736 }
const CHAR * start
Definition: inffile.c:105
static __inline void pop_state(struct parser *parser)
Definition: infcore.c:349
static __inline int is_eol(struct parser *parser, const WCHAR *ptr)
Definition: infcore.c:373
__wchar_t WCHAR
Definition: xmlstorage.h:180
static int push_token(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:384
const CHAR * end
Definition: inffile.c:106
Definition: import.c:86
GLfloat GLfloat p
Definition: glext.h:8902

◆ section_name_state()

static const WCHAR * section_name_state ( struct parser parser,
const WCHAR pos 
)
static

Definition at line 540 of file infcore.c.

541 {
542  const WCHAR *p;
543 
544  for (p = pos; !is_eol( parser, p ); p++)
545  {
546  if (*p == ']')
547  {
548  push_token( parser, p );
550  return NULL;
552  set_state( parser, COMMENT ); /* ignore everything else on the line */
553  return p + 1;
554  }
555  }
556  parser->error = INF_STATUS_BAD_SECTION_NAME_LINE; /* unfinished section name */
557  return NULL;
558 }
static PVOID add_section_from_token(struct parser *parser)
Definition: infcore.c:415
static __inline enum parser_state set_state(struct parser *parser, enum parser_state state)
Definition: infcore.c:357
smooth NULL
Definition: ftsmooth.c:416
static __inline int is_eol(struct parser *parser, const WCHAR *ptr)
Definition: infcore.c:373
static __inline void push_state(struct parser *parser, enum parser_state state)
Definition: infcore.c:341
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define INF_STATUS_BAD_SECTION_NAME_LINE
Definition: infpriv.h:16
unsigned int error
Definition: inffile.c:115
static int push_token(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:384
Definition: import.c:86
GLfloat GLfloat p
Definition: glext.h:8902

◆ set_state()

static __inline enum parser_state set_state ( struct parser parser,
enum parser_state  state 
)
static

Definition at line 357 of file infcore.c.

358 {
359  enum parser_state ret = parser->state;
360  parser->state = state;
361  return ret;
362 }
enum parser_state state
Definition: import.c:100
int ret
static int state
Definition: maze.c:121
parser_state
Definition: import.c:64
Definition: import.c:86

Referenced by eol_backslash_state(), key_name_state(), leading_spaces_state(), line_start_state(), section_name_state(), trailing_spaces_state(), and value_name_state().

◆ trailing_spaces_state()

static const WCHAR * trailing_spaces_state ( struct parser parser,
const WCHAR pos 
)
static

Definition at line 762 of file infcore.c.

763 {
764  const WCHAR *p;
765 
766  for (p = pos; !is_eol( parser, p ); p++)
767  {
768  if (*p == '\\')
769  {
771  return p;
772  }
773  if (!isspaceW(*p))
774  break;
775  }
776  pop_state( parser );
777  return p;
778 }
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
static __inline void pop_state(struct parser *parser)
Definition: infcore.c:349
static __inline enum parser_state set_state(struct parser *parser, enum parser_state state)
Definition: infcore.c:357
static __inline int is_eol(struct parser *parser, const WCHAR *ptr)
Definition: infcore.c:373
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: import.c:86
GLfloat GLfloat p
Definition: glext.h:8902

◆ value_name_state()

static const WCHAR * value_name_state ( struct parser parser,
const WCHAR pos 
)
static

Definition at line 616 of file infcore.c.

617 {
618  const WCHAR *p, *token_end = parser->start;
619 
620  for (p = pos; !is_eol( parser, p ); p++)
621  {
622  switch(*p)
623  {
624  case ';':
625  push_token( parser, token_end );
626  if (!add_field_from_token( parser, 0 )) return NULL;
629  return p + 1;
630  case ',':
631  push_token( parser, token_end );
632  if (!add_field_from_token( parser, 0 )) return NULL;
633  parser->start = p + 1;
636  return p + 1;
637  case '"':
638  push_token( parser, token_end );
639  parser->start = p + 1;
641  set_state( parser, QUOTES );
642  return p + 1;
643  case '\\':
644  push_token( parser, token_end );
645  parser->start = p;
648  return p;
649  default:
650  if (!isspaceW(*p)) token_end = p + 1;
651  else
652  {
653  push_token( parser, p );
656  return p;
657  }
658  break;
659  }
660  }
661  push_token( parser, token_end );
662  if (!add_field_from_token( parser, 0 )) return NULL;
664  return p;
665 }
const CHAR * start
Definition: inffile.c:105
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
static __inline enum parser_state set_state(struct parser *parser, enum parser_state state)
Definition: infcore.c:357
smooth NULL
Definition: ftsmooth.c:416
static __inline int is_eol(struct parser *parser, const WCHAR *ptr)
Definition: infcore.c:373
static __inline void push_state(struct parser *parser, enum parser_state state)
Definition: infcore.c:341
Definition: infcore.c:32
__wchar_t WCHAR
Definition: xmlstorage.h:180
static struct field * add_field_from_token(struct parser *parser, int is_key)
Definition: infcore.c:447
static int push_token(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:384
Definition: import.c:86
GLfloat GLfloat p
Definition: glext.h:8902

Variable Documentation

◆ parser_funcs

Initial value:
=
{
}
static const WCHAR * section_name_state(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:540
static const WCHAR * trailing_spaces_state(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:762
static const WCHAR * line_start_state(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:498
static const WCHAR * value_name_state(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:616
static const WCHAR * eol_backslash_state(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:669
static const WCHAR * comment_state(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:782
static const WCHAR * quotes_state(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:710
static const WCHAR * key_name_state(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:562
static const WCHAR * leading_spaces_state(struct parser *parser, const WCHAR *pos)
Definition: infcore.c:740

Definition at line 69 of file infcore.c.

Referenced by InfpParseBuffer().