ReactOS 0.4.15-dev-7906-g1b85a5f
inffile.c File Reference
#include <freeldr.h>
#include "inffile.h"
Include dependency graph for inffile.c:

Go to the source code of this file.

Classes

struct  _INFCACHEFIELD
 
struct  _INFCACHELINE
 
struct  _INFCACHESECTION
 
struct  _INFCACHE
 
struct  parser
 

Macros

#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)
 
#define TAG_INF_KEY   'KfnI'
 
#define TAG_INF_FIELD   'ffnI'
 
#define TAG_INF_LINE   'LfnI'
 
#define TAG_INF_SECTION   'SfnI'
 
#define TAG_INF_CACHE   'CfnI'
 
#define TAG_INF_FILE   'FfnI'
 

Typedefs

typedef struct _INFCACHEFIELD INFCACHEFIELD
 
typedef struct _INFCACHEFIELDPINFCACHEFIELD
 
typedef struct _INFCACHELINE INFCACHELINE
 
typedef struct _INFCACHELINEPINFCACHELINE
 
typedef struct _INFCACHESECTION INFCACHESECTION
 
typedef struct _INFCACHESECTIONPINFCACHESECTION
 
typedef struct _INFCACHE INFCACHE
 
typedef struct _INFCACHEPINFCACHE
 
typedef const CHAR *(* parser_state_func) (struct parser *parser, const CHAR *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 , 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 CHARline_start_state (struct parser *parser, const CHAR *pos)
 
static const CHARsection_name_state (struct parser *parser, const CHAR *pos)
 
static const CHARkey_name_state (struct parser *parser, const CHAR *pos)
 
static const CHARvalue_name_state (struct parser *parser, const CHAR *pos)
 
static const CHAReol_backslash_state (struct parser *parser, const CHAR *pos)
 
static const CHARquotes_state (struct parser *parser, const CHAR *pos)
 
static const CHARleading_spaces_state (struct parser *parser, const CHAR *pos)
 
static const CHARtrailing_spaces_state (struct parser *parser, const CHAR *pos)
 
static const CHARcomment_state (struct parser *parser, const CHAR *pos)
 
static PINFCACHELINE InfpCacheFreeLine (PINFCACHELINE Line)
 
static PINFCACHESECTION InfpCacheFreeSection (PINFCACHESECTION Section)
 
static PINFCACHESECTION InfpCacheFindSection (PINFCACHE Cache, PCSTR Name)
 
static PINFCACHESECTION InfpCacheAddSection (PINFCACHE Cache, PCSTR Name)
 
static PINFCACHELINE InfpCacheAddLine (PINFCACHESECTION Section)
 
static PVOID InfpAddKeyToLine (PINFCACHELINE Line, PCSTR Key)
 
static PVOID InfpAddFieldToLine (PINFCACHELINE Line, PCSTR Data)
 
static PINFCACHELINE InfpCacheFindKeyLine (PINFCACHESECTION Section, PCSTR 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 CHAR *ptr)
 
static __inline int is_eol (struct parser *parser, const CHAR *ptr)
 
static int push_token (struct parser *parser, const CHAR *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)
 
static BOOLEAN InfpParseBuffer (PINFCACHE file, PCCHAR buffer, PCCHAR end, PULONG error_line)
 
BOOLEAN InfOpenFile (PHINF InfHandle, PCSTR FileName, PULONG ErrorLine)
 
VOID InfCloseFile (HINF InfHandle)
 
BOOLEAN InfFindFirstLine (HINF InfHandle, PCSTR Section, PCSTR Key, PINFCONTEXT Context)
 
BOOLEAN InfFindNextLine (PINFCONTEXT ContextIn, PINFCONTEXT ContextOut)
 
BOOLEAN InfFindFirstMatchLine (PINFCONTEXT ContextIn, PCSTR Key, PINFCONTEXT ContextOut)
 
BOOLEAN InfFindNextMatchLine (PINFCONTEXT ContextIn, PCSTR Key, PINFCONTEXT ContextOut)
 
LONG InfGetLineCount (HINF InfHandle, PCSTR Section)
 
LONG InfGetFieldCount (PINFCONTEXT Context)
 
BOOLEAN InfGetBinaryField (PINFCONTEXT Context, ULONG FieldIndex, PUCHAR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
 
BOOLEAN InfGetIntField (PINFCONTEXT Context, ULONG FieldIndex, PLONG IntegerValue)
 
BOOLEAN InfGetMultiSzField (PINFCONTEXT Context, ULONG FieldIndex, PCHAR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
 
BOOLEAN InfGetStringField (PINFCONTEXT Context, ULONG FieldIndex, PCHAR ReturnBuffer, ULONG ReturnBufferSize, PULONG RequiredSize)
 
BOOLEAN InfGetData (PINFCONTEXT Context, PCSTR *Key, PCSTR *Data)
 
BOOLEAN InfGetDataField (PINFCONTEXT Context, ULONG FieldIndex, PCSTR *Data)
 

Variables

static const parser_state_func parser_funcs [NB_PARSER_STATES]
 

Macro Definition Documentation

◆ CONTROL_Z

#define CONTROL_Z   '\x1a'

Definition at line 14 of file inffile.c.

◆ MAX_FIELD_LEN

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

Definition at line 16 of file inffile.c.

◆ MAX_SECTION_NAME_LEN

#define MAX_SECTION_NAME_LEN   255

Definition at line 15 of file inffile.c.

◆ MAX_STRING_LEN

#define MAX_STRING_LEN   (MAX_INF_STRING_LENGTH+1)

Definition at line 18 of file inffile.c.

◆ TAG_INF_CACHE

#define TAG_INF_CACHE   'CfnI'

Definition at line 24 of file inffile.c.

◆ TAG_INF_FIELD

#define TAG_INF_FIELD   'ffnI'

Definition at line 21 of file inffile.c.

◆ TAG_INF_FILE

#define TAG_INF_FILE   'FfnI'

Definition at line 25 of file inffile.c.

◆ TAG_INF_KEY

#define TAG_INF_KEY   'KfnI'

Definition at line 20 of file inffile.c.

◆ TAG_INF_LINE

#define TAG_INF_LINE   'LfnI'

Definition at line 22 of file inffile.c.

◆ TAG_INF_SECTION

#define TAG_INF_SECTION   'SfnI'

Definition at line 23 of file inffile.c.

Typedef Documentation

◆ INFCACHE

◆ INFCACHEFIELD

◆ INFCACHELINE

◆ INFCACHESECTION

◆ parser_state_func

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

Definition at line 102 of file inffile.c.

◆ PINFCACHE

◆ PINFCACHEFIELD

◆ PINFCACHELINE

◆ PINFCACHESECTION

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 
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 71 of file inffile.c.

72{
73 LINE_START, /* at beginning of a line */
74 SECTION_NAME, /* parsing a section name */
75 KEY_NAME, /* parsing a key name */
76 VALUE_NAME, /* parsing a value name */
77 EOL_BACKSLASH, /* backslash at end of line */
78 QUOTES, /* inside quotes */
79 LEADING_SPACES, /* leading spaces */
80 TRAILING_SPACES, /* trailing spaces */
81 COMMENT, /* inside a comment */
83};
@ NB_PARSER_STATES
Definition: inffile.c:82
@ SECTION_NAME
Definition: inffile.c:74
@ TRAILING_SPACES
Definition: inffile.c:80
@ QUOTES
Definition: inffile.c:78
@ LINE_START
Definition: inffile.c:73
@ EOL_BACKSLASH
Definition: inffile.c:77
@ COMMENT
Definition: inffile.c:81
@ LEADING_SPACES
Definition: inffile.c:79
@ KEY_NAME
Definition: inffile.c:75
@ VALUE_NAME
Definition: inffile.c:76

Function Documentation

◆ add_field_from_token()

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

Definition at line 490 of file inffile.c.

493{
494 PVOID field;
495
496 if (!parser->line) /* need to start a new line */
497 {
498 if (parser->cur_section == NULL) /* got a line before the first section */
499 {
501 return NULL;
502 }
503
505 if (parser->line == NULL)
506 goto error;
507 }
508 else
509 {
510// assert(!is_key);
511 }
512
513 if (is_key)
514 {
516 }
517 else
518 {
520 }
521
522 if (field != NULL)
523 {
524 parser->token_len = 0;
525 return field;
526 }
527
528error:
529 parser->error = FALSE;
530 return NULL;
531}
#define STATUS_WRONG_INF_STYLE
Definition: inffile.h:13
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
static PVOID InfpAddFieldToLine(PINFCACHELINE Line, PCSTR Data)
Definition: inffile.c:331
static PINFCACHELINE InfpCacheAddLine(PINFCACHESECTION Section)
Definition: inffile.c:271
static PVOID InfpAddKeyToLine(PINFCACHELINE Line, PCSTR Key)
Definition: inffile.c:309
#define error(str)
Definition: mkdosfs.c:1605
Definition: parser.c:44
Definition: import.c:81
PINFCACHESECTION cur_section
Definition: inffile.c:94
CHAR token[MAX_FIELD_LEN+1]
Definition: inffile.c:99
unsigned int token_len
Definition: inffile.c:98
unsigned int error
Definition: inffile.c:97
PINFCACHELINE line
Definition: inffile.c:95

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 458 of file inffile.c.

459{
460 PINFCACHESECTION Section;
461
463 {
464 parser->error = FALSE;
465 return NULL;
466 }
467
469 if (Section == NULL)
470 {
471 /* need to create a new one */
473 if (Section == NULL)
474 {
475 parser->error = FALSE;
476 return NULL;
477 }
478 }
479
480 parser->token_len = 0;
481 parser->cur_section = Section;
482
483 return (PVOID)Section;
484}
static PINFCACHESECTION InfpCacheFindSection(PINFCACHE Cache, PCSTR Name)
Definition: inffile.c:196
static PINFCACHESECTION InfpCacheAddSection(PINFCACHE Cache, PCSTR Name)
Definition: inffile.c:226
#define MAX_SECTION_NAME_LEN
Definition: inffile.c:15
FILE * file
Definition: import.c:82

Referenced by section_name_state().

◆ close_current_line()

static VOID close_current_line ( struct parser parser)
static

Definition at line 537 of file inffile.c.

538{
539 parser->line = NULL;
540}

Referenced by line_start_state().

◆ comment_state()

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

Definition at line 862 of file inffile.c.

865{
866 const CHAR *p = pos;
867
868 while (!is_eol(parser, p))
869 p++;
871 return p;
872}
GLfloat GLfloat p
Definition: glext.h:8902
static __inline int is_eol(struct parser *parser, const CHAR *ptr)
Definition: inffile.c:422
static __inline void pop_state(struct parser *parser)
Definition: inffile.c:398
char CHAR
Definition: xmlstorage.h:175

◆ eol_backslash_state()

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

Definition at line 733 of file inffile.c.

736{
737 const CHAR *p;
738
739 for (p = pos; !is_eof(parser, p); p++)
740 {
741 switch(*p)
742 {
743 case '\r':
744 continue;
745
746 case '\n':
747 parser->line_pos++;
748 parser->start = p + 1;
750 return p + 1;
751
752 case '\\':
753 continue;
754
755 case ';':
758 return p + 1;
759
760 default:
761 if (isspace((unsigned char)*p))
762 continue;
765 return p;
766 }
767 }
768 parser->start = p;
770
771 return p;
772}
#define isspace(c)
Definition: acclib.h:69
static __inline enum parser_state set_state(struct parser *parser, enum parser_state state)
Definition: inffile.c:406
static int push_token(struct parser *parser, const CHAR *pos)
Definition: inffile.c:434
static __inline void push_state(struct parser *parser, enum parser_state state)
Definition: inffile.c:390
static __inline int is_eof(struct parser *parser, const CHAR *ptr)
Definition: inffile.c:415
unsigned int line_pos
Definition: inffile.c:96
const CHAR * start
Definition: inffile.c:87

◆ InfCloseFile()

VOID InfCloseFile ( HINF  InfHandle)

Definition at line 1028 of file inffile.c.

1029{
1031
1032 Cache = (PINFCACHE)InfHandle;
1033
1034 if (Cache == NULL)
1035 {
1036 return;
1037 }
1038
1039 while (Cache->FirstSection != NULL)
1040 {
1041 Cache->FirstSection = InfpCacheFreeSection(Cache->FirstSection);
1042 }
1043 Cache->LastSection = NULL;
1044
1046}
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:197
#define TAG_INF_CACHE
Definition: inffile.c:24
static PINFCACHESECTION InfpCacheFreeSection(PINFCACHESECTION Section)
Definition: inffile.c:170
struct _INFCACHE * PINFCACHE
Definition: fatfs.h:173

◆ InfFindFirstLine()

BOOLEAN InfFindFirstLine ( HINF  InfHandle,
PCSTR  Section,
PCSTR  Key,
PINFCONTEXT  Context 
)

Definition at line 1050 of file inffile.c.

1055{
1057 PINFCACHESECTION CacheSection;
1058 PINFCACHELINE CacheLine;
1059
1060 if ((InfHandle == NULL) || (Section == NULL) || (Context == NULL))
1061 {
1062// DPRINT("Invalid parameter\n");
1063 return FALSE;
1064 }
1065
1066 Cache = (PINFCACHE)InfHandle;
1067
1068 /* Iterate through list of sections */
1069 CacheSection = Cache->FirstSection;
1070 while (CacheSection != NULL)
1071 {
1072// DPRINT("Comparing '%s' and '%s'\n", CacheSection->Name, Section);
1073
1074 /* Are the section names the same? */
1075 if (_stricmp(CacheSection->Name, Section) == 0)
1076 {
1077 if (Key != NULL)
1078 {
1079 CacheLine = InfpCacheFindKeyLine(CacheSection, Key);
1080 }
1081 else
1082 {
1083 CacheLine = CacheSection->FirstLine;
1084 }
1085
1086 if (CacheLine == NULL)
1087 return FALSE;
1088
1089 Context->Inf = (PVOID)Cache;
1090 Context->Section = (PVOID)CacheSection;
1091 Context->Line = (PVOID)CacheLine;
1092
1093 return TRUE;
1094 }
1095
1096 /* Get the next section */
1097 CacheSection = CacheSection->Next;
1098 }
1099
1100// DPRINT("Section not found\n");
1101
1102 return FALSE;
1103}
#define _stricmp
Definition: cat.c:22
#define TRUE
Definition: types.h:120
static PINFCACHELINE InfpCacheFindKeyLine(PINFCACHESECTION Section, PCSTR Key)
Definition: inffile.c:368
struct _INFCACHESECTION * Next
Definition: inffile.c:51
PINFCACHELINE FirstLine
Definition: inffile.c:54
CHAR Name[1]
Definition: inffile.c:59
void * PVOID
Definition: typedefs.h:50

Referenced by LoadReactOSSetup(), SetupFindFirstLineW(), SetupLdrInitErrataInf(), SetupLdrLoadNlsData(), and SetupLdrScanBootDrivers().

◆ InfFindFirstMatchLine()

BOOLEAN InfFindFirstMatchLine ( PINFCONTEXT  ContextIn,
PCSTR  Key,
PINFCONTEXT  ContextOut 
)

Definition at line 1135 of file inffile.c.

1139{
1140 PINFCACHELINE CacheLine;
1141
1142 if ((ContextIn == NULL) || (ContextOut == NULL) || (Key == NULL) || (*Key == 0))
1143 return FALSE;
1144
1145 if (ContextIn->Inf == NULL || ContextIn->Section == NULL)
1146 return FALSE;
1147
1148 CacheLine = ((PINFCACHESECTION)(ContextIn->Section))->FirstLine;
1149 while (CacheLine != NULL)
1150 {
1151 if ((CacheLine->Key != NULL) && (_stricmp(CacheLine->Key, Key) == 0))
1152 {
1153
1154 if (ContextIn != ContextOut)
1155 {
1156 ContextOut->Inf = ContextIn->Inf;
1157 ContextOut->Section = ContextIn->Section;
1158 }
1159 ContextOut->Line = (PVOID)CacheLine;
1160
1161 return TRUE;
1162 }
1163
1164 CacheLine = CacheLine->Next;
1165 }
1166
1167 return FALSE;
1168}
struct _INFCACHESECTION * PINFCACHESECTION
PCHAR Key
Definition: inffile.c:42
struct _INFCACHELINE * Next
Definition: inffile.c:37
HINF Inf
Definition: infsupp.h:24
UINT Line
Definition: infsupp.h:27
UINT Section
Definition: infsupp.h:26

◆ InfFindNextLine()

BOOLEAN InfFindNextLine ( PINFCONTEXT  ContextIn,
PINFCONTEXT  ContextOut 
)

Definition at line 1107 of file inffile.c.

1110{
1111 PINFCACHELINE CacheLine;
1112
1113 if ((ContextIn == NULL) || (ContextOut == NULL))
1114 return FALSE;
1115
1116 if (ContextIn->Line == NULL)
1117 return FALSE;
1118
1119 CacheLine = (PINFCACHELINE)ContextIn->Line;
1120 if (CacheLine->Next == NULL)
1121 return FALSE;
1122
1123 if (ContextIn != ContextOut)
1124 {
1125 ContextOut->Inf = ContextIn->Inf;
1126 ContextOut->Section = ContextIn->Section;
1127 }
1128 ContextOut->Line = (PVOID)(CacheLine->Next);
1129
1130 return TRUE;
1131}
struct _INFCACHELINE * PINFCACHELINE
if(dx< 0)
Definition: linetemp.h:194

◆ InfFindNextMatchLine()

BOOLEAN InfFindNextMatchLine ( PINFCONTEXT  ContextIn,
PCSTR  Key,
PINFCONTEXT  ContextOut 
)

Definition at line 1172 of file inffile.c.

1176{
1177 PINFCACHELINE CacheLine;
1178
1179 if ((ContextIn == NULL) || (ContextOut == NULL) || (Key == NULL) || (*Key == 0))
1180 return FALSE;
1181
1182 if ((ContextIn->Inf == NULL) || (ContextIn->Section == NULL) || (ContextIn->Line == NULL))
1183 return FALSE;
1184
1185 CacheLine = (PINFCACHELINE)ContextIn->Line;
1186 while (CacheLine != NULL)
1187 {
1188 if ((CacheLine->Key != NULL) && (_stricmp(CacheLine->Key, Key) == 0))
1189 {
1190
1191 if (ContextIn != ContextOut)
1192 {
1193 ContextOut->Inf = ContextIn->Inf;
1194 ContextOut->Section = ContextIn->Section;
1195 }
1196 ContextOut->Line = (PVOID)CacheLine;
1197
1198 return TRUE;
1199 }
1200
1201 CacheLine = CacheLine->Next;
1202 }
1203
1204 return FALSE;
1205}
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))

◆ InfGetBinaryField()

BOOLEAN InfGetBinaryField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
PUCHAR  ReturnBuffer,
ULONG  ReturnBufferSize,
PULONG  RequiredSize 
)

Definition at line 1260 of file inffile.c.

1266{
1267 PINFCACHELINE CacheLine;
1268 PINFCACHEFIELD CacheField;
1269 ULONG Index;
1270 ULONG Size;
1271 PUCHAR Ptr;
1272
1273 if ((Context == NULL) || (Context->Line == NULL) || (FieldIndex == 0))
1274 {
1275// DPRINT("Invalid parameter\n");
1276 return FALSE;
1277 }
1278
1279 if (RequiredSize != NULL)
1280 *RequiredSize = 0;
1281
1282 CacheLine = (PINFCACHELINE)Context->Line;
1283
1284 if (FieldIndex > CacheLine->FieldCount)
1285 return FALSE;
1286
1287 CacheField = CacheLine->FirstField;
1288 for (Index = 1; Index < FieldIndex; Index++)
1289 CacheField = CacheField->Next;
1290
1291 Size = CacheLine->FieldCount - FieldIndex + 1;
1292
1293 if (RequiredSize != NULL)
1294 *RequiredSize = Size;
1295
1296 if (ReturnBuffer != NULL)
1297 {
1298 if (ReturnBufferSize < Size)
1299 return FALSE;
1300
1301 /* Copy binary data */
1302 Ptr = ReturnBuffer;
1303 while (CacheField != NULL)
1304 {
1305 *Ptr = (UCHAR)atoi(CacheField->Data); //strtoul(CacheField->Data, NULL, 16);
1306
1307 Ptr++;
1308 CacheField = CacheField->Next;
1309 }
1310 }
1311
1312 return TRUE;
1313}
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
_In_ DWORD FieldIndex
Definition: setupapi.h:1895
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1897
struct _INFCACHEFIELD * Next
Definition: inffile.c:29
CHAR Data[1]
Definition: inffile.c:32
PINFCACHEFIELD FirstField
Definition: inffile.c:44
ULONG FieldCount
Definition: inffile.c:40
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ ULONG _Out_ PVOID _Out_ PULONG RequiredSize
Definition: wdfdevice.h:4439
unsigned char UCHAR
Definition: xmlstorage.h:181

◆ InfGetData()

BOOLEAN InfGetData ( PINFCONTEXT  Context,
PCSTR Key,
PCSTR Data 
)

Definition at line 1491 of file inffile.c.

1495{
1496 PINFCACHELINE CacheKey;
1497
1498 if ((Context == NULL) || (Context->Line == NULL) || (Data == NULL))
1499 {
1500// DPRINT("Invalid parameter\n");
1501 return FALSE;
1502 }
1503
1504 CacheKey = (PINFCACHELINE)Context->Line;
1505 if (Key != NULL)
1506 *Key = CacheKey->Key;
1507
1508 *Data = (CacheKey->FirstField == NULL) ? NULL : CacheKey->FirstField->Data;
1509
1510 return TRUE;
1511}

Referenced by SetupLdrLoadNlsData().

◆ InfGetDataField()

BOOLEAN InfGetDataField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
PCSTR Data 
)

Definition at line 1515 of file inffile.c.

1519{
1520 PINFCACHELINE CacheLine;
1521 PINFCACHEFIELD CacheField;
1522 ULONG Index;
1523
1524 if ((Context == NULL) || (Context->Line == NULL) || (Data == NULL))
1525 {
1526// DPRINT("Invalid parameter\n");
1527 return FALSE;
1528 }
1529
1530 CacheLine = (PINFCACHELINE)Context->Line;
1531
1532 if (FieldIndex > CacheLine->FieldCount)
1533 return FALSE;
1534
1535 if (FieldIndex == 0)
1536 {
1537 *Data = CacheLine->Key;
1538 }
1539 else
1540 {
1541 CacheField = CacheLine->FirstField;
1542 for (Index = 1; Index < FieldIndex; Index++)
1543 CacheField = CacheField->Next;
1544
1545 *Data = CacheField->Data;
1546 }
1547
1548 return TRUE;
1549}

◆ InfGetFieldCount()

LONG InfGetFieldCount ( PINFCONTEXT  Context)

Definition at line 1250 of file inffile.c.

1251{
1252 if ((Context == NULL) || (Context->Line == NULL))
1253 return 0;
1254
1255 return ((PINFCACHELINE)Context->Line)->FieldCount;
1256}

◆ InfGetIntField()

BOOLEAN InfGetIntField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
PLONG  IntegerValue 
)

Definition at line 1317 of file inffile.c.

1321{
1322 PINFCACHELINE CacheLine;
1323 PINFCACHEFIELD CacheField;
1324 ULONG Index;
1325 PCHAR Ptr;
1326
1327 if ((Context == NULL) || (Context->Line == NULL) || (IntegerValue == NULL))
1328 {
1329// DPRINT("Invalid parameter\n");
1330 return FALSE;
1331 }
1332
1333 CacheLine = (PINFCACHELINE)Context->Line;
1334
1335 if (FieldIndex > CacheLine->FieldCount)
1336 {
1337// DPRINT("Invalid parameter\n");
1338 return FALSE;
1339 }
1340
1341 if (FieldIndex == 0)
1342 {
1343 Ptr = CacheLine->Key;
1344 }
1345 else
1346 {
1347 CacheField = CacheLine->FirstField;
1348 for (Index = 1; Index < FieldIndex; Index++)
1349 CacheField = CacheField->Next;
1350
1351 Ptr = CacheField->Data;
1352 }
1353
1354 *IntegerValue = atoi(Ptr); //strtol(Ptr, NULL, 0);
1355
1356 return TRUE;
1357}
char * PCHAR
Definition: typedefs.h:51

◆ InfGetLineCount()

LONG InfGetLineCount ( HINF  InfHandle,
PCSTR  Section 
)

Definition at line 1209 of file inffile.c.

1212{
1214 PINFCACHESECTION CacheSection;
1215
1216 if ((InfHandle == NULL) || (Section == NULL))
1217 {
1218// DPRINT("Invalid parameter\n");
1219 return -1;
1220 }
1221
1222 Cache = (PINFCACHE)InfHandle;
1223
1224 /* Iterate through list of sections */
1225 CacheSection = Cache->FirstSection;
1226 while (CacheSection != NULL)
1227 {
1228// DPRINT("Comparing '%s' and '%s'\n", CacheSection->Name, Section);
1229
1230 /* Are the section names the same? */
1231 if (_stricmp(CacheSection->Name, Section) == 0)
1232 {
1233 return CacheSection->LineCount;
1234 }
1235
1236 /* Get the next section */
1237 CacheSection = CacheSection->Next;
1238 }
1239
1240// DPRINT("Section not found\n");
1241
1242 return -1;
1243}
LONG LineCount
Definition: inffile.c:57

◆ InfGetMultiSzField()

BOOLEAN InfGetMultiSzField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
PCHAR  ReturnBuffer,
ULONG  ReturnBufferSize,
PULONG  RequiredSize 
)

Definition at line 1361 of file inffile.c.

1367{
1368 PINFCACHELINE CacheLine;
1369 PINFCACHEFIELD CacheField;
1370 PINFCACHEFIELD FieldPtr;
1371 ULONG Index;
1372 SIZE_T Size;
1373 PCHAR Ptr;
1374
1375 if ((Context == NULL) || (Context->Line == NULL) || (FieldIndex == 0))
1376 {
1377// DPRINT("Invalid parameter\n");
1378 return FALSE;
1379 }
1380
1381 if (RequiredSize != NULL)
1382 *RequiredSize = 0;
1383
1384 CacheLine = (PINFCACHELINE)Context->Line;
1385
1386 if (FieldIndex > CacheLine->FieldCount)
1387 return FALSE;
1388
1389 CacheField = CacheLine->FirstField;
1390 for (Index = 1; Index < FieldIndex; Index++)
1391 CacheField = CacheField->Next;
1392
1393 /* Calculate the required buffer size */
1394 FieldPtr = CacheField;
1395 Size = 0;
1396 while (FieldPtr != NULL)
1397 {
1398 Size += (strlen(FieldPtr->Data) + 1);
1399 FieldPtr = FieldPtr->Next;
1400 }
1401 Size++;
1402
1403 if (RequiredSize != NULL)
1405
1406 if (ReturnBuffer != NULL)
1407 {
1408 if (ReturnBufferSize < Size)
1409 return FALSE;
1410
1411 /* Copy multi-sz string */
1412 Ptr = ReturnBuffer;
1413 FieldPtr = CacheField;
1414 while (FieldPtr != NULL)
1415 {
1416 Size = strlen(FieldPtr->Data) + 1;
1417
1418 strcpy(Ptr, FieldPtr->Data);
1419
1420 Ptr = Ptr + Size;
1421 FieldPtr = FieldPtr->Next;
1422 }
1423 *Ptr = 0;
1424 }
1425
1426 return TRUE;
1427}
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
ULONG_PTR SIZE_T
Definition: typedefs.h:80

◆ InfGetStringField()

BOOLEAN InfGetStringField ( PINFCONTEXT  Context,
ULONG  FieldIndex,
PCHAR  ReturnBuffer,
ULONG  ReturnBufferSize,
PULONG  RequiredSize 
)

Definition at line 1431 of file inffile.c.

1437{
1438 PINFCACHELINE CacheLine;
1439 PINFCACHEFIELD CacheField;
1440 ULONG Index;
1441 PCHAR Ptr;
1442 SIZE_T Size;
1443
1444 if ((Context == NULL) || (Context->Line == NULL))
1445 {
1446// DPRINT("Invalid parameter\n");
1447 return FALSE;
1448 }
1449
1450 if (RequiredSize != NULL)
1451 *RequiredSize = 0;
1452
1453 CacheLine = (PINFCACHELINE)Context->Line;
1454
1455 if (FieldIndex > CacheLine->FieldCount)
1456 return FALSE;
1457
1458 if (FieldIndex == 0)
1459 {
1460 Ptr = CacheLine->Key;
1461 }
1462 else
1463 {
1464 CacheField = CacheLine->FirstField;
1465 for (Index = 1; Index < FieldIndex; Index++)
1466 CacheField = CacheField->Next;
1467
1468 Ptr = CacheField->Data;
1469 }
1470
1471 Size = strlen(Ptr) + 1;
1472
1473 if (RequiredSize != NULL)
1475
1476 if (ReturnBuffer != NULL)
1477 {
1478 if (ReturnBufferSize < Size)
1479 return FALSE;
1480
1481 strcpy(ReturnBuffer, Ptr);
1482 }
1483
1484 return TRUE;
1485}

◆ InfOpenFile()

BOOLEAN InfOpenFile ( PHINF  InfHandle,
PCSTR  FileName,
PULONG  ErrorLine 
)

Definition at line 918 of file inffile.c.

922{
924 ULONG FileId;
925 PCHAR FileBuffer;
930
931 *InfHandle = NULL;
932 *ErrorLine = (ULONG) - 1;
933
934 //
935 // Open the .inf file
936 //
938 if (Status != ESUCCESS)
939 {
940 return FALSE;
941 }
942
943 //
944 // Query file size
945 //
947 if ((Status != ESUCCESS) || (Information.EndingAddress.HighPart != 0))
948 {
949 ArcClose(FileId);
950 return FALSE;
951 }
952 FileSize = Information.EndingAddress.LowPart;
953
954 //
955 // Allocate buffer to cache the file
956 //
957 FileBuffer = FrLdrTempAlloc(FileSize + 1, TAG_INF_FILE);
958 if (!FileBuffer)
959 {
960 ArcClose(FileId);
961 return FALSE;
962 }
963
964 //
965 // Read file into memory
966 //
967 Status = ArcRead(FileId, FileBuffer, FileSize, &Count);
968 if ((Status != ESUCCESS) || (Count != FileSize))
969 {
970 ArcClose(FileId);
971 FrLdrTempFree(FileBuffer, TAG_INF_FILE);
972 return FALSE;
973 }
974
975 //
976 // We don't need the file anymore. Close it
977 //
978 ArcClose(FileId);
979
980 //
981 // Append string terminator
982 //
983 FileBuffer[FileSize] = 0;
984
985 //
986 // Allocate infcache header
987 //
989 if (!Cache)
990 {
991 FrLdrTempFree(FileBuffer, TAG_INF_FILE);
992 return FALSE;
993 }
994
995 //
996 // Initialize inicache header
997 //
998 RtlZeroMemory(Cache, sizeof(INFCACHE));
999
1000 //
1001 // Parse the inf buffer
1002 //
1004 FileBuffer,
1005 FileBuffer + FileSize,
1006 ErrorLine);
1007 if (!Success)
1008 {
1010 Cache = NULL;
1011 }
1012
1013 //
1014 // Free file buffer, as it has been parsed
1015 //
1016 FrLdrTempFree(FileBuffer, TAG_INF_FILE);
1017
1018 //
1019 // Return .inf parsed contents
1020 //
1021 *InfHandle = (HINF)Cache;
1022
1023 return Success;
1024}
unsigned char BOOLEAN
ARC_STATUS ArcClose(ULONG FileId)
Definition: fs.c:220
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: fs.c:252
ARC_STATUS ArcOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: fs.c:56
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:238
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:188
@ Success
Definition: eventcreate.c:712
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
Status
Definition: gdiplustypes.h:25
static BOOLEAN InfpParseBuffer(PINFCACHE file, PCCHAR buffer, PCCHAR end, PULONG error_line)
Definition: inffile.c:878
#define TAG_INF_FILE
Definition: inffile.c:25
PVOID HINF
Definition: infsupp.h:21
int Count
Definition: noreturn.cpp:7
@ ESUCCESS
Definition: arc.h:32
ULONG ARC_STATUS
Definition: arc.h:4
@ OpenReadOnly
Definition: arc.h:65
char * PSTR
Definition: typedefs.h:51
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
ULONG LowPart
Definition: typedefs.h:106
_In_ WDFREQUEST _In_ NTSTATUS _In_ ULONG_PTR Information
Definition: wdfrequest.h:1049

Referenced by LoadReactOSSetup(), and SetupOpenInfFileExW().

◆ InfpAddFieldToLine()

static PVOID InfpAddFieldToLine ( PINFCACHELINE  Line,
PCSTR  Data 
)
static

Definition at line 331 of file inffile.c.

334{
335 PINFCACHEFIELD Field;
336 SIZE_T Size;
337
338 Size = sizeof(INFCACHEFIELD) + strlen(Data);
340 if (Field == NULL)
341 {
342 return NULL;
343 }
344 memset(Field, 0, Size);
345
346 strcpy(Field->Data, Data);
347
348 /* Append key */
349 if (Line->FirstField == NULL)
350 {
351 Line->FirstField = Field;
352 Line->LastField = Field;
353 }
354 else
355 {
356 Line->LastField->Next = Field;
357 Field->Prev = Line->LastField;
358 Line->LastField = Field;
359 }
360 Line->FieldCount++;
361
362 return (PVOID)Field;
363}
struct _INFCACHEFIELD * PINFCACHEFIELD
#define TAG_INF_FIELD
Definition: inffile.c:21
struct _INFCACHEFIELD INFCACHEFIELD
#define memset(x, y, z)
Definition: compat.h:39
Definition: ncftp.h:79
struct _INFCACHEFIELD * Prev
Definition: inffile.c:30

Referenced by add_field_from_token(), and InfpAddField().

◆ InfpAddKeyToLine()

static PVOID InfpAddKeyToLine ( PINFCACHELINE  Line,
PCSTR  Key 
)
static

Definition at line 309 of file inffile.c.

312{
313 if (Line == NULL)
314 return NULL;
315
316 if (Line->Key != NULL)
317 return NULL;
318
320 if (Line->Key == NULL)
321 return NULL;
322
323 strcpy(Line->Key, Key);
324
325 return (PVOID)Line->Key;
326}
#define TAG_INF_KEY
Definition: inffile.c:20

Referenced by add_field_from_token(), and InfpAddLineWithKey().

◆ InfpCacheAddLine()

static PINFCACHELINE InfpCacheAddLine ( PINFCACHESECTION  Section)
static

Definition at line 271 of file inffile.c.

272{
274
275 if (Section == NULL)
276 {
277// DPRINT("Invalid parameter\n");
278 return NULL;
279 }
280
282 if (Line == NULL)
283 {
284// DPRINT("RtlAllocateHeap() failed\n");
285 return NULL;
286 }
287 memset(Line, 0, sizeof(INFCACHELINE));
288
289 /* Append line */
290 if (Section->FirstLine == NULL)
291 {
292 Section->FirstLine = Line;
293 Section->LastLine = Line;
294 }
295 else
296 {
297 Section->LastLine->Next = Line;
298 Line->Prev = Section->LastLine;
299 Section->LastLine = Line;
300 }
301 Section->LineCount++;
302
303 return Line;
304}
#define TAG_INF_LINE
Definition: inffile.c:22
PINFCACHELINE LastLine
Definition: inffile.c:55

Referenced by add_field_from_token().

◆ InfpCacheAddSection()

static PINFCACHESECTION InfpCacheAddSection ( PINFCACHE  Cache,
PCSTR  Name 
)
static

Definition at line 226 of file inffile.c.

229{
230 PINFCACHESECTION Section = NULL;
231 SIZE_T Size;
232
233 if ((Cache == NULL) || (Name == NULL))
234 {
235// DPRINT("Invalid parameter\n");
236 return NULL;
237 }
238
239 /* Allocate and initialize the new section */
240 Size = sizeof(INFCACHESECTION) + strlen(Name);
242 if (Section == NULL)
243 {
244// DPRINT("RtlAllocateHeap() failed\n");
245 return NULL;
246 }
247 memset(Section, 0, Size);
248
249 /* Copy section name */
250 strcpy(Section->Name, Name);
251
252 /* Append section */
253 if (Cache->FirstSection == NULL)
254 {
255 Cache->FirstSection = Section;
256 Cache->LastSection = Section;
257 }
258 else
259 {
260 Cache->LastSection->Next = Section;
261 Section->Prev = Cache->LastSection;
262 Cache->LastSection = Section;
263 }
264
265 return Section;
266}
struct _INFCACHESECTION INFCACHESECTION
#define TAG_INF_SECTION
Definition: inffile.c:23
struct _INFCACHESECTION * Prev
Definition: inffile.c:52

Referenced by add_section_from_token().

◆ InfpCacheFindKeyLine()

static PINFCACHELINE InfpCacheFindKeyLine ( PINFCACHESECTION  Section,
PCSTR  Key 
)
static

Definition at line 368 of file inffile.c.

371{
373
374 Line = Section->FirstLine;
375 while (Line != NULL)
376 {
377 if ((Line->Key != NULL) && (_stricmp(Line->Key, Key) == 0))
378 {
379 return Line;
380 }
381
382 Line = Line->Next;
383 }
384
385 return NULL;
386}

Referenced by InfFindFirstLine().

◆ InfpCacheFindSection()

static PINFCACHESECTION InfpCacheFindSection ( PINFCACHE  Cache,
PCSTR  Name 
)
static

Definition at line 196 of file inffile.c.

199{
200 PINFCACHESECTION Section = NULL;
201
202 if (Cache == NULL || Name == NULL)
203 {
204 return NULL;
205 }
206
207 /* iterate through list of sections */
208 Section = Cache->FirstSection;
209 while (Section != NULL)
210 {
211 if (_stricmp(Section->Name, Name) == 0)
212 {
213 return Section;
214 }
215
216 /* get the next section*/
217 Section = Section->Next;
218 }
219
220 return NULL;
221}

Referenced by add_section_from_token(), and InfpParseBuffer().

◆ InfpCacheFreeLine()

static PINFCACHELINE InfpCacheFreeLine ( PINFCACHELINE  Line)
static

Definition at line 135 of file inffile.c.

137{
138 PINFCACHELINE Next;
139 PINFCACHEFIELD Field;
140
141 if (Line == NULL)
142 {
143 return NULL;
144 }
145
146 Next = Line->Next;
147 if (Line->Key != NULL)
148 {
150 Line->Key = NULL;
151 }
152
153 /* Remove data fields */
154 while (Line->FirstField != NULL)
155 {
156 Field = Line->FirstField->Next;
157 FrLdrTempFree(Line->FirstField, TAG_INF_FIELD);
158 Line->FirstField = Field;
159 }
160 Line->LastField = NULL;
161
163
164 return Next;
165}

Referenced by InfpCacheFreeSection().

◆ InfpCacheFreeSection()

static PINFCACHESECTION InfpCacheFreeSection ( PINFCACHESECTION  Section)
static

Definition at line 170 of file inffile.c.

172{
173 PINFCACHESECTION Next;
174
175 if (Section == NULL)
176 {
177 return NULL;
178 }
179
180 /* Release all keys */
181 Next = Section->Next;
182 while (Section->FirstLine != NULL)
183 {
184 Section->FirstLine = InfpCacheFreeLine(Section->FirstLine);
185 }
186 Section->LastLine = NULL;
187
189
190 return Next;
191}
static PINFCACHELINE InfpCacheFreeLine(PINFCACHELINE Line)
Definition: inffile.c:135

Referenced by InfCloseFile().

◆ InfpParseBuffer()

static BOOLEAN InfpParseBuffer ( PINFCACHE  file,
PCCHAR  buffer,
PCCHAR  end,
PULONG  error_line 
)
static

Definition at line 878 of file inffile.c.

883{
884 struct parser parser;
885 const CHAR* pos = buffer;
886
888 parser.end = end;
889 parser.file = file;
890 parser.line = NULL;
892 parser.stack_pos = 0;
894 parser.line_pos = 1;
895 parser.error = TRUE;
896 parser.token_len = 0;
897
898 /* parser main loop */
899 while (pos)
901
902 if (parser.error)
903 {
904 if (error_line)
905 *error_line = parser.line_pos;
906 return parser.error;
907 }
908
909 /* find the [strings] section */
910 file->StringsSection = InfpCacheFindSection(file, "Strings");
911
912 return TRUE;
913}
GLuint GLuint end
Definition: gl.h:1545
GLuint buffer
Definition: glext.h:5915
static const parser_state_func parser_funcs[NB_PARSER_STATES]
Definition: inffile.c:117
Definition: fci.c:127
int stack_pos
Definition: inffile.c:92
const CHAR * end
Definition: inffile.c:88
enum parser_state state
Definition: import.c:95

Referenced by InfHostOpenBufferedFile(), InfHostOpenFile(), InfOpenBufferedFile(), and InfOpenFile().

◆ is_eof()

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

Definition at line 415 of file inffile.c.

416{
417 return (ptr >= parser->end || *ptr == CONTROL_Z);
418}
#define CONTROL_Z
Definition: inffile.c:14
static PVOID ptr
Definition: dispmode.c:27

Referenced by eol_backslash_state(), and line_start_state().

◆ is_eol()

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

Definition at line 422 of file inffile.c.

423{
424 return ((ptr >= parser->end) ||
425 (*ptr == CONTROL_Z) ||
426 (*ptr == '\n') ||
427 ((*ptr == '\r') && (*(ptr + 1) == '\n')));
428}

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

◆ key_name_state()

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

Definition at line 618 of file inffile.c.

621{
622 const CHAR *p, *token_end = parser->start;
623
624 for (p = pos; !is_eol(parser, p); p++)
625 {
626 if (*p == ',') break;
627 switch(*p)
628 {
629
630 case '=':
631 push_token(parser, token_end);
632 if (!add_field_from_token(parser, 1)) return NULL;
633 parser->start = p + 1;
636 return p + 1;
637 case ';':
638 push_token(parser, token_end);
639 if (!add_field_from_token(parser, 0)) return NULL;
642 return p + 1;
643 case '"':
644 push_token(parser, token_end);
645 parser->start = p + 1;
648 return p + 1;
649 case '\\':
650 push_token(parser, token_end);
651 parser->start = p;
654 return p;
655 default:
656 if (!isspace((unsigned char)*p)) token_end = p + 1;
657 else
658 {
662 return p;
663 }
664 break;
665 }
666 }
667 push_token(parser, token_end);
669 return p;
670}
static struct field * add_field_from_token(struct parser *parser, int is_key)
Definition: inffile.c:490

◆ leading_spaces_state()

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

Definition at line 812 of file inffile.c.

815{
816 const CHAR *p;
817
818 for (p = pos; !is_eol(parser, p); p++)
819 {
820 if (*p == '\\')
821 {
822 parser->start = p;
824 return p;
825 }
826 if (!isspace((unsigned char)*p))
827 break;
828 }
829 parser->start = p;
831 return p;
832}

◆ line_start_state()

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

Definition at line 546 of file inffile.c.

549{
550 const CHAR *p;
551
552 for (p = pos; !is_eof(parser, p); p++)
553 {
554 switch(*p)
555 {
556 case '\r':
557 continue;
558
559 case '\n':
560 parser->line_pos++;
562 break;
563
564 case ';':
567 return p + 1;
568
569 case '[':
570 parser->start = p + 1;
572 return p + 1;
573
574 default:
575 if (!isspace((unsigned char)*p))
576 {
577 parser->start = p;
579 return p;
580 }
581 break;
582 }
583 }
585 return NULL;
586}
static VOID close_current_line(struct parser *parser)
Definition: inffile.c:537

◆ pop_state()

static __inline void pop_state ( struct parser parser)
static

Definition at line 398 of file inffile.c.

399{
400// assert( parser->stack_pos );
402}
enum parser_state stack[4]
Definition: inffile.c:91

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 390 of file inffile.c.

391{
392// assert(parser->stack_pos < sizeof(parser->stack)/sizeof(parser->stack[0]));
394}
static int state
Definition: maze.c:121

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 CHAR pos 
)
static

Definition at line 434 of file inffile.c.

437{
439 const CHAR *src = parser->start;
441
444
446 for ( ; len > 0; len--, dst++, src++)
447 *dst = *src ? (CHAR)*src : L' ';
448 *dst = 0;
449 parser->start = pos;
450
451 return 0;
452}
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
GLenum GLsizei len
Definition: glext.h:6722
#define MAX_FIELD_LEN
Definition: inffile.c:16
#define L(x)
Definition: ntvdm.h:50

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

◆ quotes_state()

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

Definition at line 778 of file inffile.c.

781{
782 const CHAR *p, *token_end = parser->start;
783
784 for (p = pos; !is_eol(parser, p); p++)
785 {
786 if (*p == '"')
787 {
788 if (p + 1 < parser->end && p[1] == '"') /* double quotes */
789 {
790 push_token(parser, p + 1);
791 parser->start = token_end = p + 2;
792 p++;
793 }
794 else /* end of quotes */
795 {
797 parser->start = p + 1;
799 return p + 1;
800 }
801 }
802 }
805 return p;
806}

◆ section_name_state()

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

Definition at line 592 of file inffile.c.

595{
596 const CHAR *p;
597
598 for (p = pos; !is_eol(parser, p); p++)
599 {
600 if (*p == ']')
601 {
604 return NULL;
606 set_state(parser, COMMENT); /* ignore everything else on the line */
607 return p + 1;
608 }
609 }
610 parser->error = STATUS_BAD_SECTION_NAME_LINE; /* unfinished section name */
611 return NULL;
612}
#define STATUS_BAD_SECTION_NAME_LINE
Definition: inffile.h:11
static PVOID add_section_from_token(struct parser *parser)
Definition: inffile.c:458

◆ set_state()

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

◆ trailing_spaces_state()

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

Definition at line 838 of file inffile.c.

841{
842 const CHAR *p;
843
844 for (p = pos; !is_eol(parser, p); p++)
845 {
846 if (*p == '\\')
847 {
849 return p;
850 }
851 if (!isspace((unsigned char)*p))
852 break;
853 }
855 return p;
856}

◆ value_name_state()

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

Definition at line 676 of file inffile.c.

679{
680 const CHAR *p, *token_end = parser->start;
681
682 for (p = pos; !is_eol(parser, p); p++)
683 {
684 switch(*p)
685 {
686 case ';':
687 push_token(parser, token_end);
688 if (!add_field_from_token(parser, 0)) return NULL;
691 return p + 1;
692 case ',':
693 push_token(parser, token_end);
694 if (!add_field_from_token(parser, 0)) return NULL;
695 parser->start = p + 1;
698 return p + 1;
699 case '"':
700 push_token(parser, token_end);
701 parser->start = p + 1;
704 return p + 1;
705 case '\\':
706 push_token(parser, token_end);
707 parser->start = p;
710 return p;
711 default:
712 if (!isspace((unsigned char)*p)) token_end = p + 1;
713 else
714 {
718 return p;
719 }
720 break;
721 }
722 }
723 push_token(parser, token_end);
724 if (!add_field_from_token(parser, 0)) return NULL;
726 return p;
727}

Variable Documentation

◆ parser_funcs

Initial value:
=
{
}
static const CHAR * value_name_state(struct parser *parser, const CHAR *pos)
Definition: inffile.c:676
static const CHAR * comment_state(struct parser *parser, const CHAR *pos)
Definition: inffile.c:862
static const CHAR * line_start_state(struct parser *parser, const CHAR *pos)
Definition: inffile.c:546
static const CHAR * key_name_state(struct parser *parser, const CHAR *pos)
Definition: inffile.c:618
static const CHAR * quotes_state(struct parser *parser, const CHAR *pos)
Definition: inffile.c:778
static const CHAR * trailing_spaces_state(struct parser *parser, const CHAR *pos)
Definition: inffile.c:838
static const CHAR * section_name_state(struct parser *parser, const CHAR *pos)
Definition: inffile.c:592
static const CHAR * leading_spaces_state(struct parser *parser, const CHAR *pos)
Definition: inffile.c:812
static const CHAR * eol_backslash_state(struct parser *parser, const CHAR *pos)
Definition: inffile.c:733

Definition at line 117 of file inffile.c.

Referenced by InfpParseBuffer().