#include "inflib.h"
#include <debug.h>
Go to the source code of this file.
|
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
, 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
} |
|
|
static const WCHAR * | line_start_state (struct parser *parser, const WCHAR *pos) |
|
static const WCHAR * | section_name_state (struct parser *parser, const WCHAR *pos) |
|
static const WCHAR * | key_name_state (struct parser *parser, const WCHAR *pos) |
|
static const WCHAR * | value_name_state (struct parser *parser, const WCHAR *pos) |
|
static const WCHAR * | eol_backslash_state (struct parser *parser, const WCHAR *pos) |
|
static const WCHAR * | quotes_state (struct parser *parser, const WCHAR *pos) |
|
static const WCHAR * | leading_spaces_state (struct parser *parser, const WCHAR *pos) |
|
static const WCHAR * | trailing_spaces_state (struct parser *parser, const WCHAR *pos) |
|
static const WCHAR * | comment_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) |
|
PINFCACHESECTION | InfpFindSectionById (PINFCACHE Cache, UINT Id) |
|
PINFCACHESECTION | InfpGetSectionForContext (PINFCONTEXT Context) |
|
PINFCACHELINE | InfpFindLineById (PINFCACHESECTION Section, UINT Id) |
|
PINFCACHELINE | InfpGetLineForContext (PINFCONTEXT Context) |
|
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 field * | add_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) |
|
◆ CONTROL_Z
◆ MAX_FIELD_LEN
◆ MAX_SECTION_NAME_LEN
#define MAX_SECTION_NAME_LEN 255 |
◆ MAX_STRING_LEN
◆ NDEBUG
◆ parser_state_func
◆ 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 | |
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.
◆ add_field_from_token()
Definition at line 517 of file infcore.c.
518{
520
522 {
524 {
527 }
528
532 }
533 else
534 {
535
536 }
537
538 if (is_key)
539 {
541 }
542 else
543 {
545 }
546
548 {
551 }
552
556}
PVOID InfpAddKeyToLine(PINFCACHELINE Line, PCWSTR Key)
PVOID InfpAddFieldToLine(PINFCACHELINE Line, PCWSTR Data)
PINFCACHELINE InfpAddLine(PINFCACHESECTION Section)
#define INF_STATUS_WRONG_INF_STYLE
#define INF_STATUS_NOT_ENOUGH_MEMORY
PINFCACHESECTION cur_section
CHAR token[MAX_FIELD_LEN+1]
Referenced by key_name_state(), and value_name_state().
◆ add_section_from_token()
Definition at line 485 of file infcore.c.
486{
488
490 {
493 }
494
498 {
499
503 {
506 }
507 }
508
511
512 return (
PVOID)Section;
513}
PINFCACHESECTION InfpFindSection(PINFCACHE Cache, PCWSTR Name)
#define MAX_SECTION_NAME_LEN
PINFCACHESECTION InfpAddSection(PINFCACHE Cache, PCWSTR Name)
#define INF_STATUS_SECTION_NAME_TOO_LONG
Referenced by section_name_state().
◆ close_current_line()
◆ comment_state()
Definition at line 852 of file infcore.c.
853{
855
860}
static __inline int is_eol(struct parser *parser, const WCHAR *ptr)
static __inline void pop_state(struct parser *parser)
◆ eol_backslash_state()
Definition at line 739 of file infcore.c.
740{
742
744 {
746 {
747 case '\r':
748 continue;
749
750 case '\n':
755
756 case '\\':
757 continue;
758
759 case ';':
763
764 default:
766 continue;
770 }
771 }
774
776}
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 void push_state(struct parser *parser, enum parser_state state)
static int push_token(struct parser *parser, const WCHAR *pos)
◆ InfpAddFieldToLine()
Definition at line 353 of file infcore.c.
355{
358
363 {
366 }
370
371
373 {
374 Line->FirstField = Field;
375 Line->LastField = Field;
376 }
377 else
378 {
379 Line->LastField->Next = Field;
381 Line->LastField = Field;
382 }
384
386}
#define ZEROMEMORY(Area, Size)
struct _INFCACHEFIELD * PINFCACHEFIELD
struct _INFCACHEFIELD * Prev
#define FIELD_OFFSET(t, f)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Referenced by add_field_from_token().
◆ InfpAddKeyToLine()
◆ InfpAddLine()
◆ InfpAddSection()
Definition at line 171 of file infcore.c.
173{
176
178 {
179 DPRINT(
"Invalid parameter\n");
181 }
182
183
188 {
189 DPRINT(
"MALLOC() failed\n");
191 }
194 Section->
Id = ++
Cache->NextSectionId;
195
196
198
199
201 {
202 Cache->FirstSection = Section;
203 Cache->LastSection = Section;
204 }
205 else
206 {
207 Cache->LastSection->Next = Section;
209 Cache->LastSection = Section;
210 }
211
212 return Section;
213}
struct _INFCACHESECTION * PINFCACHESECTION
struct _INFCACHESECTION * Prev
Referenced by add_section_from_token(), and InfpFindOrAddSection().
◆ InfpFindKeyLine()
◆ InfpFindLineById()
◆ InfpFindSection()
◆ InfpFindSectionById()
◆ InfpFreeLine()
Definition at line 86 of file infcore.c.
87{
90
92 {
94 }
95
98 {
101 }
102
103
105 {
106 Field =
Line->FirstField->Next;
108 Line->FirstField = Field;
109 }
111
113
114 return Next;
115}
Referenced by InfpFreeSection().
◆ InfpFreeSection()
Definition at line 119 of file infcore.c.
120{
122
124 {
126 }
127
128
129 Next = Section->
Next;
131 {
133 }
135
137
138 return Next;
139}
static PINFCACHELINE InfpFreeLine(PINFCACHELINE Line)
Referenced by InfCloseFile(), and InfHostCloseFile().
◆ InfpGetLineForContext()
Definition at line 310 of file infcore.c.
311{
313
316 {
318 }
319
321}
PINFCACHELINE InfpFindLineById(PINFCACHESECTION Section, UINT Id)
PINFCACHESECTION InfpGetSectionForContext(PINFCONTEXT Context)
Referenced by InfpAddField(), InfpFindNextLine(), InfpFindNextMatchLine(), InfpGetBinaryField(), InfpGetData(), InfpGetDataField(), InfpGetFieldCount(), InfpGetIntField(), InfpGetMultiSzField(), and InfpGetStringField().
◆ InfpGetSectionForContext()
◆ InfpParseBuffer()
Definition at line 865 of file infcore.c.
869{
872
883
884
887
889 {
890 if (error_line)
893 }
894
895
898
900}
#define INF_STATUS_SUCCESS
static const parser_state_func parser_funcs[NB_PARSER_STATES]
◆ is_eof()
◆ is_eol()
◆ key_name_state()
Definition at line 632 of file infcore.c.
633{
635
637 {
638 if (*
p ==
',')
break;
640 {
641
642 case '=':
649 case ';':
655 case '"':
661 case '\\':
667 default:
669 else
670 {
675 }
676 break;
677 }
678 }
682}
static struct field * add_field_from_token(struct parser *parser, int is_key)
◆ leading_spaces_state()
Definition at line 810 of file infcore.c.
811{
813
815 {
817 {
821 }
823 break;
824 }
828}
◆ line_start_state()
Definition at line 568 of file infcore.c.
569{
571
573 {
575 {
576 case '\r':
577 continue;
578
579 case '\n':
582 break;
583
584 case ';':
588
589 case '[':
593
594 default:
596 {
600 }
601 break;
602 }
603 }
606}
static void close_current_line(struct parser *parser)
◆ pop_state()
◆ push_state()
◆ push_token()
◆ quotes_state()
Definition at line 780 of file infcore.c.
781{
783
785 {
787 {
789 {
793 }
794 else
795 {
800 }
801 }
802 }
806}
◆ section_name_state()
Definition at line 610 of file infcore.c.
611{
613
615 {
617 {
624 }
625 }
628}
static PVOID add_section_from_token(struct parser *parser)
#define INF_STATUS_BAD_SECTION_NAME_LINE
◆ set_state()
◆ trailing_spaces_state()
Definition at line 832 of file infcore.c.
833{
835
837 {
839 {
842 }
844 break;
845 }
848}
◆ value_name_state()
Definition at line 686 of file infcore.c.
687{
689
691 {
693 {
694 case ';':
700 case ',':
707 case '"':
713 case '\\':
719 default:
721 else
722 {
727 }
728 break;
729 }
730 }
735}
◆ parser_funcs
Initial value:=
{
}
static const WCHAR * key_name_state(struct parser *parser, const WCHAR *pos)
static const WCHAR * value_name_state(struct parser *parser, const WCHAR *pos)
static const WCHAR * section_name_state(struct parser *parser, const WCHAR *pos)
static const WCHAR * leading_spaces_state(struct parser *parser, const WCHAR *pos)
static const WCHAR * line_start_state(struct parser *parser, const WCHAR *pos)
static const WCHAR * eol_backslash_state(struct parser *parser, const WCHAR *pos)
static const WCHAR * quotes_state(struct parser *parser, const WCHAR *pos)
static const WCHAR * comment_state(struct parser *parser, const WCHAR *pos)
static const WCHAR * trailing_spaces_state(struct parser *parser, const WCHAR *pos)
Definition at line 69 of file infcore.c.
Referenced by InfpParseBuffer().