ReactOS  0.4.13-dev-551-gf37fb1f
parser.c File Reference
#include "setupapi_private.h"
#include <ndk/obfuncs.h>
Include dependency graph for parser.c:

Go to the source code of this file.

Classes

struct  field
 
struct  line
 
struct  section
 
struct  inf_file
 
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)
 

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 voidgrow_array (void *array, unsigned int *count, size_t elem)
 
static const WCHARget_inf_dir (const struct inf_file *file, unsigned int *len)
 
static int find_section (const struct inf_file *file, const WCHAR *name)
 
static struct linefind_line (struct inf_file *file, int section_index, const WCHAR *name)
 
static int add_section (struct inf_file *file, const WCHAR *name)
 
static struct lineadd_line (struct inf_file *file, int section_index)
 
static struct lineget_line (struct inf_file *file, unsigned int section_index, unsigned int line_index)
 
static struct fieldget_field (struct inf_file *file, int section_index, int line_index, int field_index)
 
static struct fieldadd_field (struct inf_file *file, const WCHAR *text)
 
static const WCHARget_dirid_subst (const struct inf_file *file, int dirid, unsigned int *len)
 
static const WCHARget_string_subst (const struct inf_file *file, const WCHAR *str, unsigned int *len, BOOL no_trailing_slash)
 
static unsigned int PARSER_string_substW (const struct inf_file *file, const WCHAR *text, WCHAR *buffer, unsigned int size)
 
static unsigned int PARSER_string_substA (const struct inf_file *file, const WCHAR *text, char *buffer, unsigned int size)
 
static WCHARpush_string (struct inf_file *file, const WCHAR *string)
 
static void push_state (struct parser *parser, enum parser_state state)
 
static void pop_state (struct parser *parser)
 
static enum parser_state set_state (struct parser *parser, enum parser_state state)
 
static BOOL is_eof (const struct parser *parser, const WCHAR *ptr)
 
static BOOL is_eol (const struct parser *parser, const WCHAR *ptr)
 
static int push_token (struct parser *parser, const WCHAR *pos)
 
static int add_section_from_token (struct parser *parser)
 
static struct fieldadd_field_from_token (struct parser *parser, BOOL is_key)
 
static void close_current_line (struct parser *parser)
 
static void free_inf_file (struct inf_file *file)
 
static DWORD parse_buffer (struct inf_file *file, const WCHAR *buffer, const WCHAR *end, UINT *error_line)
 
static void append_inf_file (struct inf_file *parent, struct inf_file *child)
 
static struct inf_fileparse_file (HANDLE handle, UINT *error_line, DWORD style)
 
const WCHARPARSER_get_inf_filename (HINF hinf)
 
WCHARPARSER_get_src_root (HINF hinf)
 
WCHARPARSER_get_dest_dir (INFCONTEXT *context)
 
HINF WINAPI SetupOpenInfFileA (PCSTR name, PCSTR class, DWORD style, UINT *error)
 
static BOOL PARSER_GetInfClassW (IN HINF hInf, OUT LPGUID ClassGuid, OUT PWSTR ClassName, IN DWORD ClassNameSize, OUT PDWORD RequiredSize OPTIONAL)
 
HINF WINAPI SetupOpenInfFileW (PCWSTR name, PCWSTR class, DWORD style, UINT *error)
 
BOOL WINAPI SetupOpenAppendInfFileA (PCSTR name, HINF parent_hinf, UINT *error)
 
BOOL WINAPI SetupOpenAppendInfFileW (PCWSTR name, HINF parent_hinf, UINT *error)
 
HINF WINAPI SetupOpenMasterInf (VOID)
 
void WINAPI SetupCloseInfFile (HINF hinf)
 
BOOL WINAPI SetupEnumInfSectionsA (HINF hinf, UINT index, PSTR buffer, DWORD size, DWORD *need)
 
BOOL WINAPI SetupEnumInfSectionsW (HINF hinf, UINT index, PWSTR buffer, DWORD size, DWORD *need)
 
LONG WINAPI SetupGetLineCountA (HINF hinf, PCSTR name)
 
LONG WINAPI SetupGetLineCountW (HINF hinf, PCWSTR section)
 
BOOL WINAPI SetupGetLineByIndexA (HINF hinf, PCSTR section, DWORD index, INFCONTEXT *context)
 
BOOL WINAPI SetupGetLineByIndexW (HINF hinf, PCWSTR section, DWORD index, INFCONTEXT *context)
 
BOOL WINAPI SetupFindFirstLineA (HINF hinf, PCSTR section, PCSTR key, INFCONTEXT *context)
 
BOOL WINAPI SetupFindFirstLineW (HINF hinf, PCWSTR section, PCWSTR key, INFCONTEXT *context)
 
BOOL WINAPI SetupFindNextLine (PINFCONTEXT context_in, PINFCONTEXT context_out)
 
BOOL WINAPI SetupFindNextMatchLineA (PINFCONTEXT context_in, PCSTR key, PINFCONTEXT context_out)
 
BOOL WINAPI SetupFindNextMatchLineW (PINFCONTEXT context_in, PCWSTR key, PINFCONTEXT context_out)
 
BOOL WINAPI SetupGetLineTextW (PINFCONTEXT context, HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR buffer, DWORD size, PDWORD required)
 
BOOL WINAPI SetupGetLineTextA (PINFCONTEXT context, HINF hinf, PCSTR section_name, PCSTR key_name, PSTR buffer, DWORD size, PDWORD required)
 
DWORD WINAPI SetupGetFieldCount (PINFCONTEXT context)
 
BOOL WINAPI SetupGetStringFieldA (PINFCONTEXT context, DWORD index, PSTR buffer, DWORD size, PDWORD required)
 
BOOL WINAPI SetupGetStringFieldW (PINFCONTEXT context, DWORD index, PWSTR buffer, DWORD size, PDWORD required)
 
BOOL WINAPI SetupGetIntField (PINFCONTEXT context, DWORD index, PINT result)
 
BOOL WINAPI SetupGetBinaryField (PINFCONTEXT context, DWORD index, BYTE *buffer, DWORD size, LPDWORD required)
 
BOOL WINAPI SetupGetMultiSzFieldA (PINFCONTEXT context, DWORD index, PSTR buffer, DWORD size, LPDWORD required)
 
BOOL WINAPI SetupGetMultiSzFieldW (PINFCONTEXT context, DWORD index, PWSTR buffer, DWORD size, LPDWORD required)
 
LPCWSTR WINAPI pSetupGetField (PINFCONTEXT context, DWORD index)
 
BOOL WINAPI SetupGetInfFileListW (IN PCWSTR DirectoryPath OPTIONAL, IN DWORD InfStyle, IN OUT PWSTR ReturnBuffer OPTIONAL, IN DWORD ReturnBufferSize OPTIONAL, OUT PDWORD RequiredSize OPTIONAL)
 
BOOL WINAPI SetupGetInfFileListA (IN PCSTR DirectoryPath OPTIONAL, IN DWORD InfStyle, IN OUT PSTR ReturnBuffer OPTIONAL, IN DWORD ReturnBufferSize OPTIONAL, OUT PDWORD RequiredSize OPTIONAL)
 
BOOL WINAPI SetupDiGetINFClassW (IN PCWSTR InfName, OUT LPGUID ClassGuid, OUT PWSTR ClassName, IN DWORD ClassNameSize, OUT PDWORD RequiredSize OPTIONAL)
 
BOOL WINAPI SetupDiGetINFClassA (IN PCSTR InfName, OUT LPGUID ClassGuid, OUT PSTR ClassName, IN DWORD ClassNameSize, OUT PDWORD RequiredSize OPTIONAL)
 
BOOL EnumerateSectionsStartingWith (IN HINF hInf, IN LPCWSTR pStr, IN FIND_CALLBACK Callback, IN PVOID Context)
 

Variables

static const WCHAR BackSlash [] = {'\\',0}
 
static const WCHAR Class [] = {'C','l','a','s','s',0}
 
static const WCHAR ClassGUID [] = {'C','l','a','s','s','G','U','I','D',0}
 
static const WCHAR InfDirectory [] = {'i','n','f','\\',0}
 
static const WCHAR InfFileSpecification [] = {'*','.','i','n','f',0}
 
static const parser_state_func parser_funcs [NB_PARSER_STATES]
 
static const WCHAR Version [] = {'V','e','r','s','i','o','n',0}
 
static const WCHAR Signature [] = {'S','i','g','n','a','t','u','r','e',0}
 
static const WCHAR Chicago [] = {'$','C','h','i','c','a','g','o','$',0}
 
static const WCHAR WindowsNT [] = {'$','W','i','n','d','o','w','s',' ','N','T','$',0}
 
static const WCHAR Windows95 [] = {'$','W','i','n','d','o','w','s',' ','9','5','$',0}
 
static const WCHAR LayoutFile [] = {'L','a','y','o','u','t','F','i','l','e',0}
 

Macro Definition Documentation

◆ CONTROL_Z

#define CONTROL_Z   '\x1a'

Definition at line 35 of file parser.c.

◆ MAX_FIELD_LEN

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

Definition at line 37 of file parser.c.

◆ MAX_SECTION_NAME_LEN

#define MAX_SECTION_NAME_LEN   255

Definition at line 36 of file parser.c.

◆ MAX_STRING_LEN

#define MAX_STRING_LEN   (MAX_INF_STRING_LENGTH+1)

Definition at line 39 of file parser.c.

Typedef Documentation

◆ parser_state_func

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

Definition at line 112 of file parser.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 80 of file parser.c.

81 {
82  LINE_START, /* at beginning of a line */
83  SECTION_NAME, /* parsing a section name */
84  KEY_NAME, /* parsing a key name */
85  VALUE_NAME, /* parsing a value name */
86  EOL_BACKSLASH, /* backslash at end of line */
87  QUOTES, /* inside quotes */
88  LEADING_SPACES, /* leading spaces */
89  TRAILING_SPACES, /* trailing spaces */
90  COMMENT, /* inside a comment */
92 };
Definition: parser.c:87
Definition: parser.c:90

Function Documentation

◆ add_field()

static struct field* add_field ( struct inf_file file,
const WCHAR text 
)
static

Definition at line 280 of file parser.c.

281 {
282  struct field *field;
283 
284  if (file->nb_fields >= file->alloc_fields)
285  {
286  if (!(file->fields = grow_array( file->fields, &file->alloc_fields,
287  sizeof(file->fields[0]) ))) return NULL;
288  }
289  field = &file->fields[file->nb_fields++];
290  field->text = text;
291  return field;
292 }
const WCHAR * text
Definition: parser.c:45
const WCHAR * text
Definition: package.c:1827
static void * grow_array(void *array, unsigned int *count, size_t elem)
Definition: parser.c:148
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:43
Definition: fci.c:126

Referenced by add_field_from_token().

◆ add_field_from_token()

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

Definition at line 566 of file parser.c.

567 {
568  struct field *field;
569  WCHAR *text;
570 
571  if (!parser->line) /* need to start a new line */
572  {
573  if (parser->cur_section == -1) /* got a line before the first section */
574  {
576  return NULL;
577  }
578  if (!(parser->line = add_line( parser->file, parser->cur_section ))) goto error;
579  }
580  else ASSERT(!is_key);
581 
583  if ((field = add_field( parser->file, text )))
584  {
585  if (!is_key) parser->line->nb_fields++;
586  else
587  {
588  /* replace first field by key field */
589  parser->line->key_field = parser->line->first_field;
590  parser->line->first_field++;
591  }
592  parser->token_len = 0;
593  return field;
594  }
595  error:
597  return NULL;
598 }
const WCHAR * text
Definition: package.c:1827
static struct field * add_field(struct inf_file *file, const WCHAR *text)
Definition: parser.c:280
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define ERROR_EXPECTED_SECTION_NAME
Definition: setupapi.h:282
PINFCACHELINE line
Definition: inffile.c:113
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
DWORD error
Definition: parser.c:105
static WCHAR * push_string(struct inf_file *file, const WCHAR *string)
Definition: parser.c:474
unsigned int token_len
Definition: inffile.c:116
unsigned int error
Definition: inffile.c:115
FILE * file
Definition: import.c:88
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PINFCACHESECTION cur_section
Definition: inffile.c:112
static struct line * add_line(struct inf_file *file, int section_index)
Definition: parser.c:225
CHAR token[MAX_FIELD_LEN+1]
Definition: inffile.c:117
Definition: import.c:86

Referenced by key_name_state(), and value_name_state().

◆ add_line()

static struct line* add_line ( struct inf_file file,
int  section_index 
)
static

Definition at line 225 of file parser.c.

226 {
227  struct section *section;
228  struct line *line;
229 
230  ASSERT( section_index >= 0 && section_index < file->nb_sections );
231 
232  section = file->sections[section_index];
233  if (section->nb_lines == section->alloc_lines) /* need to grow the section */
234  {
235  int size = sizeof(*section) - sizeof(section->lines) + 2*section->alloc_lines*sizeof(*line);
236  if (!(section = HeapReAlloc( GetProcessHeap(), 0, section, size ))) return NULL;
237  section->alloc_lines *= 2;
238  file->sections[section_index] = section;
239  }
241  line->first_field = file->nb_fields;
242  line->nb_fields = 0;
243  line->key_field = -1;
244  return line;
245 }
int first_field
Definition: parser.c:50
Definition: parser.c:55
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
struct line lines[16]
Definition: parser.c:60
const char * section
Definition: parser.c:191
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
int key_field
Definition: parser.c:52
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
char line[200]
Definition: main.c:97
unsigned int nb_lines
Definition: parser.c:58
#define HeapReAlloc
Definition: compat.h:393
unsigned int alloc_lines
Definition: parser.c:59
int nb_fields
Definition: parser.c:51
Definition: fci.c:126

Referenced by add_field_from_token().

◆ add_section()

static int add_section ( struct inf_file file,
const WCHAR name 
)
static

Definition at line 206 of file parser.c.

207 {
208  struct section *section;
209 
210  if (file->nb_sections >= file->alloc_sections)
211  {
212  if (!(file->sections = grow_array( file->sections, &file->alloc_sections,
213  sizeof(file->sections[0]) ))) return -1;
214  }
215  if (!(section = HeapAlloc( GetProcessHeap(), 0, sizeof(*section) ))) return -1;
216  section->name = name;
217  section->nb_lines = 0;
218  section->alloc_lines = sizeof(section->lines)/sizeof(section->lines[0]);
219  file->sections[file->nb_sections] = section;
220  return file->nb_sections++;
221 }
Definition: parser.c:55
const WCHAR * name
Definition: parser.c:57
static void * grow_array(void *array, unsigned int *count, size_t elem)
Definition: parser.c:148
struct line lines[16]
Definition: parser.c:60
const char * section
Definition: parser.c:191
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned int nb_lines
Definition: parser.c:58
unsigned int alloc_lines
Definition: parser.c:59
Definition: fci.c:126
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by add_section_from_token(), and hhp_reader::hhp_reader().

◆ add_section_from_token()

static int add_section_from_token ( struct parser parser)
static

Definition at line 540 of file parser.c.

541 {
542  int section_index;
543 
545  {
547  return -1;
548  }
549  if ((section_index = find_section( parser->file, parser->token )) == -1)
550  {
551  /* need to create a new one */
552  const WCHAR *name = push_string( parser->file, parser->token );
553  if ((section_index = add_section( parser->file, name )) == -1)
554  {
556  return -1;
557  }
558  }
559  parser->token_len = 0;
560  parser->cur_section = section_index;
561  return section_index;
562 }
#define ERROR_SECTION_NAME_TOO_LONG
Definition: setupapi.h:284
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
static int add_section(struct inf_file *file, const WCHAR *name)
Definition: parser.c:206
__wchar_t WCHAR
Definition: xmlstorage.h:180
static WCHAR * push_string(struct inf_file *file, const WCHAR *string)
Definition: parser.c:474
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
#define MAX_SECTION_NAME_LEN
Definition: parser.c:36
CHAR token[MAX_FIELD_LEN+1]
Definition: inffile.c:117
static int find_section(const struct inf_file *file, const WCHAR *name)
Definition: parser.c:177
Definition: import.c:86
Definition: name.c:36

Referenced by section_name_state().

◆ append_inf_file()

static void append_inf_file ( struct inf_file parent,
struct inf_file child 
)
static

Definition at line 970 of file parser.c.

971 {
972  struct inf_file **ppnext = &parent->next;
973  child->next = NULL;
974 
975  for (;;)
976  {
977  struct inf_file *next = InterlockedCompareExchangePointer( (void **)ppnext, child, NULL );
978  if (!next) return;
979  ppnext = &next->next;
980  }
981 }
static HWND child
Definition: cursoricon.c:298
#define InterlockedCompareExchangePointer
Definition: interlocked.h:129
smooth NULL
Definition: ftsmooth.c:416
r parent
Definition: btrfs.c:2708
static unsigned __int64 next
Definition: rand_nt.c:6
Definition: inf.c:48

Referenced by SetupOpenAppendInfFileA(), and SetupOpenAppendInfFileW().

◆ close_current_line()

static void close_current_line ( struct parser parser)
static

Definition at line 602 of file parser.c.

603 {
604  struct line *cur_line = parser->line;
605 
606  if (cur_line)
607  {
608  /* if line has a single field and no key, the field is the key too */
609  if (cur_line->nb_fields == 1 && cur_line->key_field == -1)
610  cur_line->key_field = cur_line->first_field;
611  }
612  parser->line = NULL;
613 }
int first_field
Definition: parser.c:50
PINFCACHELINE line
Definition: inffile.c:113
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
int key_field
Definition: parser.c:52
Definition: import.c:86
int nb_fields
Definition: parser.c:51

Referenced by line_start_state().

◆ comment_state()

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

Definition at line 887 of file parser.c.

888 {
889  const WCHAR *p = pos;
890 
891  while (!is_eol( parser, p )) p++;
892  pop_state( parser );
893  return p;
894 }
static void pop_state(struct parser *parser)
Definition: parser.c:492
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL is_eol(const struct parser *parser, const WCHAR *ptr)
Definition: parser.c:516
Definition: import.c:86
GLfloat GLfloat p
Definition: glext.h:8902

◆ EnumerateSectionsStartingWith()

BOOL EnumerateSectionsStartingWith ( IN HINF  hInf,
IN LPCWSTR  pStr,
IN FIND_CALLBACK  Callback,
IN PVOID  Context 
)

Definition at line 2387 of file parser.c.

2392 {
2393  struct inf_file *file = (struct inf_file *)hInf;
2394  size_t len = strlenW(pStr);
2395  unsigned int i;
2396 
2397  for (i = 0; i < file->nb_sections; i++)
2398  {
2399  if (strncmpiW(pStr, file->sections[i]->name, len) == 0)
2400  {
2401  if (!Callback(file->sections[i]->name, Context))
2402  return FALSE;
2403  }
2404  }
2405  return TRUE;
2406 }
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
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
char name[1]
Definition: fci.c:135
GLenum GLsizei len
Definition: glext.h:6722
LPFNPSPCALLBACK Callback
Definition: desk.c:111
Definition: inf.c:48
Definition: fci.c:126

Referenced by SetupDiGetActualSectionToInstallExW().

◆ eol_backslash_state()

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

Definition at line 784 of file parser.c.

785 {
786  const WCHAR *p;
787 
788  for (p = pos; !is_eof( parser, p ); p++)
789  {
790  switch(*p)
791  {
792  case '\n':
793  parser->line_pos++;
794  parser->start = p + 1;
796  return p + 1;
797  case '\\':
798  continue;
799  case ';':
802  return p + 1;
803  default:
804  if (isspaceW(*p)) continue;
805  push_token( parser, p );
806  pop_state( parser );
807  return p;
808  }
809  }
810  parser->start = p;
811  pop_state( parser );
812  return p;
813 }
const CHAR * start
Definition: inffile.c:105
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
static void pop_state(struct parser *parser)
Definition: parser.c:492
static enum parser_state set_state(struct parser *parser, enum parser_state state)
Definition: parser.c:500
static void push_state(struct parser *parser, enum parser_state state)
Definition: parser.c:484
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:90
static BOOL is_eof(const struct parser *parser, const WCHAR *ptr)
Definition: parser.c:509
Definition: import.c:86
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int line_pos
Definition: inffile.c:114
static int push_token(struct parser *parser, const WCHAR *pos)
Definition: parser.c:523

◆ find_line()

static struct line* find_line ( struct inf_file file,
int  section_index,
const WCHAR name 
)
static

Definition at line 188 of file parser.c.

189 {
190  struct section *section;
191  struct line *line;
192  unsigned int i;
193 
194  if (section_index < 0 || section_index >= file->nb_sections) return NULL;
195  section = file->sections[section_index];
196  for (i = 0, line = section->lines; i < section->nb_lines; i++, line++)
197  {
198  if (line->key_field == -1) continue;
199  if (!strcmpiW( name, file->fields[line->key_field].text )) return line;
200  }
201  return NULL;
202 }
Definition: parser.c:55
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
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
struct line lines[16]
Definition: parser.c:60
const char * section
Definition: parser.c:191
int key_field
Definition: parser.c:52
char line[200]
Definition: main.c:97
#define strcmpiW(s1, s2)
Definition: unicode.h:39
Definition: name.c:36
Definition: fci.c:126

Referenced by parse_file().

◆ find_section()

static int find_section ( const struct inf_file file,
const WCHAR name 
)
static

Definition at line 177 of file parser.c.

178 {
179  unsigned int i;
180 
181  for (i = 0; i < file->nb_sections; i++)
182  if (!strcmpiW( name, file->sections[i]->name )) return i;
183  return -1;
184 }
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
char name[1]
Definition: fci.c:135
#define strcmpiW(s1, s2)
Definition: unicode.h:39
Definition: name.c:36
Definition: fci.c:126

Referenced by add_section_from_token(), parse_buffer(), parse_file(), SetupFindFirstLineW(), SetupFindNextLine(), SetupFindNextMatchLineW(), SetupGetLineByIndexW(), and SetupGetLineCountW().

◆ free_inf_file()

static void free_inf_file ( struct inf_file file)
static

Definition at line 897 of file parser.c.

898 {
899  unsigned int i;
900 
901  for (i = 0; i < file->nb_sections; i++) HeapFree( GetProcessHeap(), 0, file->sections[i] );
902  HeapFree( GetProcessHeap(), 0, file->filename );
903  HeapFree( GetProcessHeap(), 0, file->sections );
904  HeapFree( GetProcessHeap(), 0, file->fields );
905  HeapFree( GetProcessHeap(), 0, file->strings );
906  HeapFree( GetProcessHeap(), 0, file );
907 }
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
#define GetProcessHeap()
Definition: compat.h:395
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: fci.c:126

Referenced by parse_file(), and SetupCloseInfFile().

◆ get_dirid_subst()

static const WCHAR* get_dirid_subst ( const struct inf_file file,
int  dirid,
unsigned int len 
)
static

Definition at line 296 of file parser.c.

297 {
298  const WCHAR *ret;
299 
300  if (dirid == DIRID_SRCPATH) return get_inf_dir( file, len );
301  ret = DIRID_get_string( dirid );
302  if (ret) *len = strlenW(ret);
303  return ret;
304 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define DIRID_SRCPATH
Definition: setupapi.h:186
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR * get_inf_dir(const struct inf_file *file, unsigned int *len)
Definition: parser.c:168
int ret
GLenum GLsizei len
Definition: glext.h:6722
const WCHAR * DIRID_get_string(int dirid)
Definition: dirid.c:159
Definition: fci.c:126

Referenced by get_string_subst(), and PARSER_get_dest_dir().

◆ get_field()

static struct field* get_field ( struct inf_file file,
int  section_index,
int  line_index,
int  field_index 
)
static

Definition at line 262 of file parser.c.

264 {
265  struct line *line = get_line( file, section_index, line_index );
266 
267  if (!line) return NULL;
268  if (!field_index) /* get the key */
269  {
270  if (line->key_field == -1) return NULL;
271  return &file->fields[line->key_field];
272  }
273  field_index--;
274  if (field_index >= line->nb_fields) return NULL;
275  return &file->fields[line->first_field + field_index];
276 }
int first_field
Definition: parser.c:50
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
int key_field
Definition: parser.c:52
static struct line * get_line(struct inf_file *file, unsigned int section_index, unsigned int line_index)
Definition: parser.c:249
int nb_fields
Definition: parser.c:51
Definition: fci.c:126

Referenced by pSetupGetField(), SetupGetStringFieldA(), and SetupGetStringFieldW().

◆ get_inf_dir()

static const WCHAR* get_inf_dir ( const struct inf_file file,
unsigned int len 
)
static

Definition at line 168 of file parser.c.

169 {
170  const WCHAR *p = strrchrW( file->filename, '\\' );
171  *len = p ? (p + 1 - file->filename) : 0;
172  return file->filename;
173 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLenum GLsizei len
Definition: glext.h:6722
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
GLfloat GLfloat p
Definition: glext.h:8902
Definition: fci.c:126

Referenced by get_dirid_subst(), and PARSER_get_src_root().

◆ get_line()

static struct line* get_line ( struct inf_file file,
unsigned int  section_index,
unsigned int  line_index 
)
inlinestatic

Definition at line 249 of file parser.c.

251 {
252  struct section *section;
253 
254  if (section_index >= file->nb_sections) return NULL;
255  section = file->sections[section_index];
256  if (line_index >= section->nb_lines) return NULL;
257  return &section->lines[line_index];
258 }
Definition: parser.c:55
smooth NULL
Definition: ftsmooth.c:416
struct line lines[16]
Definition: parser.c:60
const char * section
Definition: parser.c:191
unsigned int nb_lines
Definition: parser.c:58
Definition: fci.c:126

Referenced by get_field(), SetupGetBinaryField(), SetupGetFieldCount(), SetupGetLineTextA(), SetupGetLineTextW(), SetupGetMultiSzFieldA(), and SetupGetMultiSzFieldW().

◆ get_string_subst()

static const WCHAR* get_string_subst ( const struct inf_file file,
const WCHAR str,
unsigned int len,
BOOL  no_trailing_slash 
)
static

Definition at line 309 of file parser.c.

311 {
312  static const WCHAR percent = '%';
313 
314  struct section *strings_section;
315  struct line *line;
316  struct field *field;
317  unsigned int i, j;
318  int dirid;
319  WCHAR *dirid_str, *end;
320  const WCHAR *ret = NULL;
321  WCHAR StringLangId[13] = {'S','t','r','i','n','g','s','.',0};
322  TCHAR Lang[5];
323 
324  if (!*len) /* empty string (%%) is replaced by single percent */
325  {
326  *len = 1;
327  return &percent;
328  }
329  if (file->strings_section == -1) goto not_found;
330  strings_section = file->sections[file->strings_section];
331  for (j = 0, line = strings_section->lines; j < strings_section->nb_lines; j++, line++)
332  {
333  if (line->key_field == -1) continue;
334  if (strncmpiW( str, file->fields[line->key_field].text, *len )) continue;
335  if (!file->fields[line->key_field].text[*len]) break;
336  }
337  if (j == strings_section->nb_lines || !line->nb_fields) goto not_found;
338  field = &file->fields[line->first_field];
339  GetLocaleInfo(LOCALE_SYSTEM_DEFAULT, LOCALE_ILANGUAGE, Lang, sizeof(Lang)/sizeof(TCHAR)); // get the current system locale for translated strings
340 
341  strcpyW(StringLangId + 8, Lang + 2);
342  // now you have e.g. Strings.07 for german neutral translations
343  for (i = 0; i < file->nb_sections; i++) // search in all sections
344  {
345  if (!strcmpiW(file->sections[i]->name,StringLangId)) // if the section is a Strings.* section
346  {
347  strings_section = file->sections[i]; // select this section for further use
348  for (j = 0, line = strings_section->lines; j < strings_section->nb_lines; j++, line++) // process all lines in this section
349  {
350  if (line->key_field == -1) continue; // if no key then skip
351  if (strncmpiW( str, file->fields[line->key_field].text, *len )) continue; // if wrong key name, then skip
352  if (!file->fields[line->key_field].text[*len]) // if value exist
353  {
354  field = &file->fields[line->first_field]; // then extract value and
355  break; // no more search necessary
356  }
357  }
358  }
359  }
360 
361  strcpyW(StringLangId + 8, Lang); // append the Language identifier from GetLocaleInfo
362  // now you have e.g. Strings.0407 for german translations
363  for (i = 0; i < file->nb_sections; i++) // search in all sections
364  {
365  if (!strcmpiW(file->sections[i]->name,StringLangId)) // if the section is a Strings.* section
366  {
367  strings_section = file->sections[i]; // select this section for further use
368  for (j = 0, line = strings_section->lines; j < strings_section->nb_lines; j++, line++) // process all lines in this section
369  {
370  if (line->key_field == -1) continue; // if no key then skip
371  if (strncmpiW( str, file->fields[line->key_field].text, *len )) continue; // if wrong key name, then skip
372  if (!file->fields[line->key_field].text[*len]) // if value exist
373  {
374  field = &file->fields[line->first_field]; // then extract value and
375  break; // no more search necessary
376  }
377  }
378  }
379  }
380  *len = strlenW( field->text ); // set length
381  ret = field->text; // return the english or translated string
382  return ret;
383 
384 
385  not_found: /* check for integer id */
386  if ((dirid_str = HeapAlloc( GetProcessHeap(), 0, (*len+1) * sizeof(WCHAR) )))
387  {
388  memcpy( dirid_str, str, *len * sizeof(WCHAR) );
389  dirid_str[*len] = 0;
390  dirid = strtolW( dirid_str, &end, 10 );
391  if (!*end) ret = get_dirid_subst( file, dirid, len );
392  if (no_trailing_slash && ret && *len && ret[*len - 1] == '\\') *len -= 1;
393  HeapFree( GetProcessHeap(), 0, dirid_str );
394  return ret;
395  }
396  return NULL;
397 }
const WCHAR * text
Definition: parser.c:45
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define strtolW(s, e, b)
Definition: unicode.h:33
int first_field
Definition: parser.c:50
#define GetLocaleInfo
Definition: winnls.h:1183
GLuint GLuint end
Definition: gl.h:1545
#define LOCALE_ILANGUAGE
Definition: winnls.h:25
Definition: parser.c:55
#define strncmpiW(s1, s2, n)
Definition: unicode.h:40
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
char name[1]
Definition: fci.c:135
static const WCHAR * get_dirid_subst(const struct inf_file *file, int dirid, unsigned int *len)
Definition: parser.c:296
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
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
struct line lines[16]
Definition: parser.c:60
char TCHAR
Definition: xmlstorage.h:189
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
int key_field
Definition: parser.c:52
#define LOCALE_SYSTEM_DEFAULT
int ret
char line[200]
Definition: main.c:97
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define strcmpiW(s1, s2)
Definition: unicode.h:39
unsigned int nb_lines
Definition: parser.c:58
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
int nb_fields
Definition: parser.c:51
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: fci.c:126

Referenced by PARSER_string_substW().

◆ grow_array()

static void* grow_array ( void array,
unsigned int count,
size_t  elem 
)
static

Definition at line 148 of file parser.c.

149 {
150  void *new_array;
151  unsigned int new_count = *count + *count / 2;
152  if (new_count < 32) new_count = 32;
153 
154  if (array)
155  new_array = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, array, new_count * elem );
156  else
157  new_array = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, new_count * elem );
158 
159  if (new_array)
160  *count = new_count;
161  else
162  HeapFree( GetProcessHeap(), 0, array );
163  return new_array;
164 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
static size_t elem
Definition: string.c:68
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define HeapReAlloc
Definition: compat.h:393
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by add_field(), and add_section().

◆ is_eof()

static BOOL is_eof ( const struct parser parser,
const WCHAR ptr 
)
inlinestatic

Definition at line 509 of file parser.c.

510 {
511  return (ptr >= parser->end || *ptr == CONTROL_Z);
512 }
static PVOID ptr
Definition: dispmode.c:27
#define CONTROL_Z
Definition: parser.c:35
const CHAR * end
Definition: inffile.c:106
Definition: import.c:86

Referenced by eol_backslash_state(), and line_start_state().

◆ is_eol()

static BOOL is_eol ( const struct parser parser,
const WCHAR ptr 
)
inlinestatic

Definition at line 516 of file parser.c.

517 {
518  return (ptr >= parser->end || *ptr == CONTROL_Z || *ptr == '\n');
519 }
static PVOID ptr
Definition: dispmode.c:27
#define CONTROL_Z
Definition: parser.c:35
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 677 of file parser.c.

678 {
679  const WCHAR *p, *token_end = parser->start;
680 
681  for (p = pos; !is_eol( parser, p ); p++)
682  {
683  if (*p == ',') break;
684  switch(*p)
685  {
686 
687  case '=':
688  push_token( parser, token_end );
689  if (!add_field_from_token( parser, TRUE )) return NULL;
690  parser->start = p + 1;
693  return p + 1;
694  case ';':
695  push_token( parser, token_end );
696  if (!add_field_from_token( parser, FALSE )) return NULL;
699  return p + 1;
700  case '"':
701  push_token( parser, p );
702  parser->start = p + 1;
704  set_state( parser, QUOTES );
705  return p + 1;
706  case '\\':
707  push_token( parser, token_end );
708  parser->start = p;
711  return p;
712  default:
713  if (!isspaceW(*p)) token_end = p + 1;
714  else
715  {
716  push_token( parser, p );
719  return p;
720  }
721  break;
722  }
723  }
724  push_token( parser, token_end );
726  return p;
727 }
const CHAR * start
Definition: inffile.c:105
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
Definition: parser.c:87
static enum parser_state set_state(struct parser *parser, enum parser_state state)
Definition: parser.c:500
static void push_state(struct parser *parser, enum parser_state state)
Definition: parser.c:484
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL is_eol(const struct parser *parser, const WCHAR *ptr)
Definition: parser.c:516
Definition: parser.c:90
Definition: import.c:86
static struct field * add_field_from_token(struct parser *parser, BOOL is_key)
Definition: parser.c:566
GLfloat GLfloat p
Definition: glext.h:8902
static int push_token(struct parser *parser, const WCHAR *pos)
Definition: parser.c:523

◆ leading_spaces_state()

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

Definition at line 847 of file parser.c.

848 {
849  const WCHAR *p;
850 
851  for (p = pos; !is_eol( parser, p ); p++)
852  {
853  if (*p == '\\')
854  {
855  parser->start = p;
857  return p;
858  }
859  if (!isspaceW(*p)) break;
860  }
861  parser->start = p;
862  pop_state( parser );
863  return p;
864 }
const CHAR * start
Definition: inffile.c:105
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
static void pop_state(struct parser *parser)
Definition: parser.c:492
static enum parser_state set_state(struct parser *parser, enum parser_state state)
Definition: parser.c:500
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL is_eol(const struct parser *parser, const WCHAR *ptr)
Definition: parser.c:516
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 617 of file parser.c.

618 {
619  const WCHAR *p;
620 
621  for (p = pos; !is_eof( parser, p ); p++)
622  {
623  switch(*p)
624  {
625  case '\n':
626  parser->line_pos++;
628  break;
629  case ';':
632  return p + 1;
633  case '[':
634  parser->start = p + 1;
636  return p + 1;
637  default:
638  if (isspaceW(*p)) break;
639  if (parser->cur_section != -1)
640  {
641  parser->start = p;
643  return p;
644  }
645  if (!parser->broken_line)
647  break;
648  }
649  }
651  return NULL;
652 }
const CHAR * start
Definition: inffile.c:105
WINE_UNICODE_INLINE int isspaceW(WCHAR wc)
Definition: unicode.h:165
unsigned int broken_line
Definition: parser.c:106
static enum parser_state set_state(struct parser *parser, enum parser_state state)
Definition: parser.c:500
static void push_state(struct parser *parser, enum parser_state state)
Definition: parser.c:484
smooth NULL
Definition: ftsmooth.c:416
static void close_current_line(struct parser *parser)
Definition: parser.c:602
__wchar_t WCHAR
Definition: xmlstorage.h:180
PINFCACHESECTION cur_section
Definition: inffile.c:112
Definition: parser.c:90
static BOOL is_eof(const struct parser *parser, const WCHAR *ptr)
Definition: parser.c:509
Definition: import.c:86
GLfloat GLfloat p
Definition: glext.h:8902
unsigned int line_pos
Definition: inffile.c:114

◆ parse_buffer()

static DWORD parse_buffer ( struct inf_file file,
const WCHAR buffer,
const WCHAR end,
UINT error_line 
)
static

Definition at line 911 of file parser.c.

913 {
914  static const WCHAR Strings[] = {'S','t','r','i','n','g','s',0};
915 
916  struct parser parser;
917  const WCHAR *pos = buffer;
918 
919  parser.start = buffer;
920  parser.end = end;
921  parser.file = file;
922  parser.line = NULL;
924  parser.stack_pos = 0;
925  parser.cur_section = -1;
926  parser.line_pos = 1;
927  parser.broken_line = 0;
928  parser.error = 0;
929  parser.token_len = 0;
930 
931  /* parser main loop */
932  while (pos) pos = (parser_funcs[parser.state])( &parser, pos );
933 
934  /* trim excess buffer space */
935  if (file->alloc_sections > file->nb_sections)
936  {
937  file->sections = HeapReAlloc( GetProcessHeap(), 0, file->sections,
938  file->nb_sections * sizeof(file->sections[0]) );
939  file->alloc_sections = file->nb_sections;
940  }
941  if (file->alloc_fields > file->nb_fields)
942  {
943  file->fields = HeapReAlloc( GetProcessHeap(), 0, file->fields,
944  file->nb_fields * sizeof(file->fields[0]) );
945  file->alloc_fields = file->nb_fields;
946  }
948  (file->string_pos - file->strings) * sizeof(WCHAR) );
949 
950  if (parser.error)
951  {
952  if (error_line) *error_line = parser.line_pos;
953  return parser.error;
954  }
955 
956  /* find the [strings] section */
957  file->strings_section = find_section( file, Strings );
958 
959  if (file->strings_section == -1 && parser.broken_line)
960  {
961  if (error_line) *error_line = parser.broken_line;
963  }
964 
965  return 0;
966 }
int stack_pos
Definition: inffile.c:110
const CHAR * start
Definition: inffile.c:105
enum parser_state state
Definition: import.c:100
GLuint GLuint end
Definition: gl.h:1545
unsigned int broken_line
Definition: parser.c:106
static const parser_state_func parser_funcs[NB_PARSER_STATES]
Definition: parser.c:125
#define ERROR_EXPECTED_SECTION_NAME
Definition: setupapi.h:282
PINFCACHELINE line
Definition: inffile.c:113
smooth NULL
Definition: ftsmooth.c:416
static UINT PSTR buffer
Definition: parser.c:36
#define GetProcessHeap()
Definition: compat.h:395
__wchar_t WCHAR
Definition: xmlstorage.h:180
const char file[]
Definition: icontest.c:11
unsigned int token_len
Definition: inffile.c:116
static const WCHAR Strings[]
Definition: reg.c:35
unsigned int error
Definition: inffile.c:115
FILE * file
Definition: import.c:88
PINFCACHESECTION cur_section
Definition: inffile.c:112
const CHAR * end
Definition: inffile.c:106
#define HeapReAlloc
Definition: compat.h:393
static int find_section(const struct inf_file *file, const WCHAR *name)
Definition: parser.c:177
Definition: import.c:86
unsigned int line_pos
Definition: inffile.c:114
#define HEAP_REALLOC_IN_PLACE_ONLY
Definition: nt_native.h:1696
Definition: fci.c:126

Referenced by parse_file().

◆ parse_file()

static struct inf_file* parse_file ( HANDLE  handle,
UINT error_line,
DWORD  style 
)
static

Definition at line 989 of file parser.c.

990 {
991  void *buffer;
992  DWORD err = 0;
993  struct inf_file *file;
994 
997  if (!mapping) return NULL;
999  NtClose( mapping );
1000  if (!buffer) return NULL;
1001 
1002  if (!(file = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*file) )))
1003  {
1005  goto done;
1006  }
1007 
1008  /* we won't need more strings space than the size of the file,
1009  * so we can preallocate it here
1010  */
1011  if (!(file->strings = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) )))
1012  {
1014  goto done;
1015  }
1016  file->string_pos = file->strings;
1017  file->strings_section = -1;
1018 
1019  if (!RtlIsTextUnicode( buffer, size, NULL ))
1020  {
1021  static const BYTE utf8_bom[3] = { 0xef, 0xbb, 0xbf };
1022  WCHAR *new_buff;
1023  UINT codepage = CP_ACP;
1024  UINT offset = 0;
1025 
1026  if (size > sizeof(utf8_bom) && !memcmp( buffer, utf8_bom, sizeof(utf8_bom) ))
1027  {
1028  codepage = CP_UTF8;
1029  offset = sizeof(utf8_bom);
1030  }
1031 
1032  if ((new_buff = HeapAlloc( GetProcessHeap(), 0, size * sizeof(WCHAR) )))
1033  {
1035  size - offset, new_buff, size );
1036  err = parse_buffer( file, new_buff, new_buff + len, error_line );
1037  HeapFree( GetProcessHeap(), 0, new_buff );
1038  }
1039  }
1040  else
1041  {
1042  WCHAR *new_buff = buffer;
1043  /* UCS-16 files should start with the Unicode BOM; we should skip it */
1044  if (*new_buff == 0xfeff)
1045  new_buff++;
1046  err = parse_buffer( file, new_buff, (WCHAR *)((char *)buffer + size), error_line );
1047  }
1048 
1049  if (!err) /* now check signature */
1050  {
1051  int version_index = find_section( file, Version );
1052  if (version_index != -1)
1053  {
1054  struct line *line = find_line( file, version_index, Signature );
1055  if (line && line->nb_fields > 0)
1056  {
1057  struct field *field = file->fields + line->first_field;
1058  if (!strcmpiW( field->text, Chicago )) goto done;
1059  if (!strcmpiW( field->text, WindowsNT )) goto done;
1060  if (!strcmpiW( field->text, Windows95 )) goto done;
1061  }
1062  }
1063  if (error_line) *error_line = 0;
1065  }
1066 
1067  done:
1069  if (err)
1070  {
1071  if (file) free_inf_file( file );
1072  SetLastError( err );
1073  file = NULL;
1074  }
1075  return file;
1076 }
const WCHAR * text
Definition: parser.c:45
static struct line * find_line(struct inf_file *file, int section_index, const WCHAR *name)
Definition: parser.c:188
static void free_inf_file(struct inf_file *file)
Definition: parser.c:897
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define INF_STYLE_WIN4
Definition: infsupp.h:41
#define MapViewOfFile
Definition: compat.h:402
#define CP_ACP
Definition: compat.h:99
static char utf8_bom[3]
Definition: file.c:108
int first_field
Definition: parser.c:50
GLintptr offset
Definition: glext.h:5920
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
GLuint buffer
Definition: glext.h:5915
NTSYSAPI BOOLEAN NTAPI RtlIsTextUnicode(_In_ CONST VOID *Buffer, _In_ INT Size, _Inout_opt_ INT *Flags)
#define CP_UTF8
Definition: nls.h:20
static const WCHAR Chicago[]
Definition: parser.c:142
int codepage
Definition: win_iconv.c:156
static const WCHAR Windows95[]
Definition: parser.c:144
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
#define FILE_MAP_READ
Definition: compat.h:427
static UINT PSTR buffer
Definition: parser.c:36
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
#define CreateFileMappingW(a, b, c, d, e, f)
Definition: compat.h:401
const char file[]
Definition: icontest.c:11
static DWORD parse_buffer(struct inf_file *file, const WCHAR *buffer, const WCHAR *end, UINT *error_line)
Definition: parser.c:911
unsigned long DWORD
Definition: ntddk_ex.h:95
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
DWORD WINAPI GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:481
#define SetLastError(x)
Definition: compat.h:409
static const WCHAR WindowsNT[]
Definition: parser.c:143
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
GLenum GLsizei len
Definition: glext.h:6722
unsigned char BYTE
Definition: mem.h:68
#define err(...)
#define strcmpiW(s1, s2)
Definition: unicode.h:39
unsigned int UINT
Definition: ndis.h:50
#define PAGE_READONLY
Definition: compat.h:127
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define MultiByteToWideChar
Definition: compat.h:100
static int find_section(const struct inf_file *file, const WCHAR *name)
Definition: parser.c:177
#define ERROR_WRONG_INF_STYLE
Definition: setupapi.h:286
int nb_fields
Definition: parser.c:51
#define UnmapViewOfFile
Definition: compat.h:403
Arabic default style
Definition: afstyles.h:93
static const WCHAR Signature[]
Definition: parser.c:141
#define HeapFree(x, y, z)
Definition: compat.h:394
Definition: inf.c:48
Definition: fci.c:126

Referenced by SetupOpenInfFileW().

◆ PARSER_get_dest_dir()

WCHAR* PARSER_get_dest_dir ( INFCONTEXT context)

Definition at line 1116 of file parser.c.

1117 {
1118  const WCHAR *dir;
1119  WCHAR *ptr, *ret;
1120  INT dirid;
1121  unsigned int len1;
1122  DWORD len2;
1123 
1124  if (!SetupGetIntField( context, 1, &dirid )) return NULL;
1125  if (!(dir = get_dirid_subst( context->Inf, dirid, &len1 ))) return NULL;
1126  if (!SetupGetStringFieldW( context, 2, NULL, 0, &len2 )) len2 = 0;
1127  if (!(ret = HeapAlloc( GetProcessHeap(), 0, (len1+len2+1) * sizeof(WCHAR) ))) return NULL;
1128  memcpy( ret, dir, len1 * sizeof(WCHAR) );
1129  ptr = ret + len1;
1130  if (len2 && ptr > ret && ptr[-1] != '\\') *ptr++ = '\\';
1131  if (!SetupGetStringFieldW( context, 2, ptr, len2, NULL )) *ptr = 0;
1132  return ret;
1133 }
Definition: http.c:6587
BOOL WINAPI SetupGetStringFieldW(PINFCONTEXT context, DWORD index, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1902
int32_t INT
Definition: typedefs.h:56
static const WCHAR * get_dirid_subst(const struct inf_file *file, int dirid, unsigned int *len)
Definition: parser.c:296
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
unsigned int dir
Definition: maze.c:112
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOL WINAPI SetupGetIntField(PINFCONTEXT context, DWORD index, PINT result)
Definition: parser.c:1933

Referenced by get_destination_dir(), register_dlls_callback(), and SetupGetTargetPathW().

◆ PARSER_get_inf_filename()

const WCHAR* PARSER_get_inf_filename ( HINF  hinf)

Definition at line 1084 of file parser.c.

1085 {
1086  struct inf_file *file = hinf;
1087  return file->filename;
1088 }
Definition: inf.c:48
Definition: fci.c:126

Referenced by fill_inf_info().

◆ PARSER_get_src_root()

WCHAR* PARSER_get_src_root ( HINF  hinf)

Definition at line 1096 of file parser.c.

1097 {
1098  unsigned int len;
1099  const WCHAR *dir = get_inf_dir( hinf, &len );
1100  WCHAR *ret = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) );
1101  if (ret)
1102  {
1103  memcpy( ret, dir, len * sizeof(WCHAR) );
1104  ret[len] = 0;
1105  }
1106  return ret;
1107 }
unsigned int dir
Definition: maze.c:112
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR * get_inf_dir(const struct inf_file *file, unsigned int *len)
Definition: parser.c:168
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722

Referenced by get_src_file_info().

◆ PARSER_GetInfClassW()

static BOOL PARSER_GetInfClassW ( IN HINF  hInf,
OUT LPGUID  ClassGuid,
OUT PWSTR  ClassName,
IN DWORD  ClassNameSize,
OUT PDWORD RequiredSize  OPTIONAL 
)
static

Definition at line 1161 of file parser.c.

1167 {
1168  DWORD requiredSize;
1169  WCHAR guidW[MAX_GUID_STRING_LEN + 1];
1170  BOOL ret = FALSE;
1171 
1172  /* Read class Guid */
1173  if (!SetupGetLineTextW(NULL, hInf, Version, ClassGUID, guidW, sizeof(guidW), NULL))
1174  goto cleanup;
1175  guidW[37] = '\0'; /* Replace the } by a NULL character */
1176  if (UuidFromStringW(&guidW[1], ClassGuid) != RPC_S_OK)
1177  goto cleanup;
1178 
1179  /* Read class name */
1180  ret = SetupGetLineTextW(NULL, hInf, Version, Class, ClassName, ClassNameSize, &requiredSize);
1181  if (ret && ClassName == NULL && ClassNameSize == 0)
1182  {
1183  if (RequiredSize)
1184  *RequiredSize = requiredSize;
1186  ret = FALSE;
1187  goto cleanup;
1188  }
1189  if (!ret)
1190  {
1192  {
1193  if (RequiredSize)
1194  *RequiredSize = requiredSize;
1195  goto cleanup;
1196  }
1197  else if (!SetupDiClassNameFromGuidW(ClassGuid, ClassName, ClassNameSize, &requiredSize))
1198  {
1200  {
1201  if (RequiredSize)
1202  *RequiredSize = requiredSize;
1203  goto cleanup;
1204  }
1205  /* Return a NULL class name */
1206  if (RequiredSize)
1207  *RequiredSize = 1;
1208  if (ClassNameSize < 1)
1209  {
1211  goto cleanup;
1212  }
1213  memcpy(ClassGuid, &GUID_NULL, sizeof(GUID));
1214  *ClassName = UNICODE_NULL;
1215  }
1216  }
1217 
1218  ret = TRUE;
1219 
1220 cleanup:
1221  TRACE("Returning %d\n", ret);
1222  return ret;
1223 }
#define TRUE
Definition: types.h:120
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL WINAPI SetupDiClassNameFromGuidW(const GUID *ClassGuid, PWSTR ClassName, DWORD ClassNameSize, PDWORD RequiredSize)
Definition: devinst.c:1076
static const WCHAR ClassGUID[]
Definition: parser.c:31
#define UNICODE_NULL
RPC_STATUS WINAPI UuidFromStringW(RPC_WSTR s, UUID *uuid)
Definition: rpcrt4_main.c:615
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_GUID_STRING_LEN
Definition: apphelp.c:29
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define GUID_NULL
Definition: ks.h:106
char * cleanup(char *str)
Definition: wpickclick.c:99
#define RPC_S_OK
Definition: rpcnterr.h:22
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI SetupGetLineTextW(PINFCONTEXT context, HINF hinf, PCWSTR section_name, PCWSTR key_name, PWSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1756

Referenced by SetupDiGetINFClassW(), and SetupOpenInfFileW().

◆ PARSER_string_substA()

static unsigned int PARSER_string_substA ( const struct inf_file file,
const WCHAR text,
char buffer,
unsigned int  size 
)
static

Definition at line 456 of file parser.c.

458 {
459  WCHAR buffW[MAX_STRING_LEN+1];
460  DWORD ret;
461 
462  unsigned int len = PARSER_string_substW( file, text, buffW, sizeof(buffW)/sizeof(WCHAR) );
463  if (!buffer) RtlUnicodeToMultiByteSize( &ret, buffW, len * sizeof(WCHAR) );
464  else
465  {
466  RtlUnicodeToMultiByteN( buffer, size-1, &ret, buffW, len * sizeof(WCHAR) );
467  buffer[ret] = 0;
468  }
469  return ret;
470 }
const WCHAR * text
Definition: package.c:1827
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteSize(PULONG MbSize, PCWCH UnicodeString, ULONG UnicodeSize)
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteN(PCHAR MbString, ULONG MbSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
GLenum GLsizei len
Definition: glext.h:6722
#define MAX_STRING_LEN
Definition: parser.c:39
static unsigned int PARSER_string_substW(const struct inf_file *file, const WCHAR *text, WCHAR *buffer, unsigned int size)
Definition: parser.c:403
Definition: fci.c:126

Referenced by SetupGetLineTextA(), SetupGetMultiSzFieldA(), and SetupGetStringFieldA().

◆ PARSER_string_substW()

static unsigned int PARSER_string_substW ( const struct inf_file file,
const WCHAR text,
WCHAR buffer,
unsigned int  size 
)
static

Definition at line 403 of file parser.c.

405 {
406  const WCHAR *start, *subst, *p;
407  unsigned int len, total = 0;
408  BOOL inside = FALSE;
409 
410  if (!buffer) size = MAX_STRING_LEN + 1;
411  for (p = start = text; *p; p++)
412  {
413  if (*p != '%') continue;
414  inside = !inside;
415  if (inside) /* start of a %xx% string */
416  {
417  len = p - start;
418  if (len > size - 1) len = size - 1;
419  if (buffer) memcpy( buffer + total, start, len * sizeof(WCHAR) );
420  total += len;
421  size -= len;
422  start = p;
423  }
424  else /* end of the %xx% string, find substitution */
425  {
426  len = p - start - 1;
427  subst = get_string_subst( file, start + 1, &len, p[1] == '\\' );
428  if (!subst)
429  {
430  subst = start;
431  len = p - start + 1;
432  }
433  if (len > size - 1) len = size - 1;
434  if (buffer) memcpy( buffer + total, subst, len * sizeof(WCHAR) );
435  total += len;
436  size -= len;
437  start = p + 1;
438  }
439  }
440 
441  if (start != p) /* unfinished string, copy it */
442  {
443  len = p - start;
444  if (len > size - 1) len = size - 1;
445  if (buffer) memcpy( buffer + total, start, len * sizeof(WCHAR) );
446  total += len;
447  }
448  if (buffer && size) buffer[total] = 0;
449  return total;
450 }
static const WCHAR * get_string_subst(const struct inf_file *file, const WCHAR *str, unsigned int *len, BOOL no_trailing_slash)
Definition: parser.c:309
const WCHAR * text
Definition: package.c:1827
GLuint buffer
Definition: glext.h:5915
unsigned int BOOL
Definition: ntddk_ex.h:94
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
GLuint start
Definition: gl.h:1545
#define MAX_STRING_LEN
Definition: parser.c:39
GLfloat GLfloat p
Definition: glext.h:8902
Definition: fci.c:126

Referenced by PARSER_string_substA(), SetupGetLineTextW(), SetupGetMultiSzFieldW(), and SetupGetStringFieldW().

◆ pop_state()

static void pop_state ( struct parser parser)
inlinestatic

Definition at line 492 of file parser.c.

493 {
494  ASSERT( parser->stack_pos );
496 }
int stack_pos
Definition: inffile.c:110
enum parser_state state
Definition: import.c:100
enum parser_state stack[4]
Definition: inffile.c:109
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Definition: import.c:86

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

◆ pSetupGetField()

LPCWSTR WINAPI pSetupGetField ( PINFCONTEXT  context,
DWORD  index 
)

Definition at line 2122 of file parser.c.

2123 {
2124  struct inf_file *file = context->CurrentInf;
2125  struct field *field = get_field( file, context->Section, context->Line, index );
2126 
2127  if (!field)
2128  {
2130  return NULL;
2131  }
2132  return field->text;
2133 }
const WCHAR * text
Definition: parser.c:45
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
Definition: http.c:6587
smooth NULL
Definition: ftsmooth.c:416
static struct field * get_field(struct inf_file *file, int section_index, int line_index, int field_index)
Definition: parser.c:262
GLuint index
Definition: glext.h:6031
Definition: parser.c:43
#define SetLastError(x)
Definition: compat.h:409
Definition: inf.c:48
Definition: fci.c:126

◆ push_state()

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

Definition at line 484 of file parser.c.

485 {
486  ASSERT( parser->stack_pos < sizeof(parser->stack)/sizeof(parser->stack[0]) );
488 }
int stack_pos
Definition: inffile.c:110
enum parser_state stack[4]
Definition: inffile.c:109
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
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_string()

static WCHAR* push_string ( struct inf_file file,
const WCHAR string 
)
static

Definition at line 474 of file parser.c.

475 {
476  WCHAR *ret = file->string_pos;
477  strcpyW( ret, string );
478  file->string_pos += strlenW( ret ) + 1;
479  return ret;
480 }
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
Definition: fci.c:126

Referenced by add_field_from_token(), and add_section_from_token().

◆ push_token()

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

Definition at line 523 of file parser.c.

524 {
525  int len = pos - parser->start;
526  const WCHAR *src = parser->start;
528 
530 
531  parser->token_len += len;
532  for ( ; len > 0; len--, dst++, src++) *dst = *src ? *src : ' ';
533  *dst = 0;
534  parser->start = pos;
535  return 0;
536 }
const CHAR * start
Definition: inffile.c:105
#define MAX_FIELD_LEN
Definition: parser.c:37
__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
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 817 of file parser.c.

818 {
819  const WCHAR *p;
820 
821  for (p = pos; !is_eol( parser, p ); p++)
822  {
823  if (*p == '"')
824  {
825  if (p+1 < parser->end && p[1] == '"') /* double quotes */
826  {
827  push_token( parser, p + 1 );
828  parser->start = p + 2;
829  p++;
830  }
831  else /* end of quotes */
832  {
833  push_token( parser, p );
834  parser->start = p + 1;
835  pop_state( parser );
836  return p + 1;
837  }
838  }
839  }
840  push_token( parser, p );
841  pop_state( parser );
842  return p;
843 }
const CHAR * start
Definition: inffile.c:105
static void pop_state(struct parser *parser)
Definition: parser.c:492
__wchar_t WCHAR
Definition: xmlstorage.h:180
static BOOL is_eol(const struct parser *parser, const WCHAR *ptr)
Definition: parser.c:516
const CHAR * end
Definition: inffile.c:106
Definition: import.c:86
GLfloat GLfloat p
Definition: glext.h:8902
static int push_token(struct parser *parser, const WCHAR *pos)
Definition: parser.c:523

◆ section_name_state()

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

Definition at line 656 of file parser.c.

657 {
658  const WCHAR *p;
659 
660  for (p = pos; !is_eol( parser, p ); p++)
661  {
662  if (*p == ']')
663  {
664  push_token( parser, p );
665  if (add_section_from_token( parser ) == -1) return NULL;
667  set_state( parser, COMMENT ); /* ignore everything else on the line */
668  return p + 1;
669  }
670  }
671  parser->error = ERROR_BAD_SECTION_NAME_LINE; /* unfinished section name */
672  return NULL;
673 }
static enum parser_state set_state(struct parser *parser, enum parser_state state)
Definition: parser.c:500
static int add_section_from_token(struct parser *parser)
Definition: parser.c:540
static void push_state(struct parser *parser, enum parser_state state)
Definition: parser.c:484
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned int error
Definition: inffile.c:115
#define ERROR_BAD_SECTION_NAME_LINE
Definition: setupapi.h:283
static BOOL is_eol(const struct parser *parser, const WCHAR *ptr)
Definition: parser.c:516
Definition: parser.c:90
Definition: import.c:86
GLfloat GLfloat p
Definition: glext.h:8902
static int push_token(struct parser *parser, const WCHAR *pos)
Definition: parser.c:523

◆ set_state()

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

Definition at line 500 of file parser.c.

501 {
502  enum parser_state ret = parser->state;
503  parser->state = state;
504  return ret;
505 }
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().

◆ SetupCloseInfFile()

void WINAPI SetupCloseInfFile ( HINF  hinf)

Definition at line 1393 of file parser.c.

1394 {
1395  struct inf_file *file = hinf;
1396 
1397  if (!hinf || (hinf == INVALID_HANDLE_VALUE)) return;
1398 
1399  free_inf_file( file );
1400 }
static void free_inf_file(struct inf_file *file)
Definition: parser.c:897
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
Definition: inf.c:48
Definition: fci.c:126

Referenced by SetupDiGetINFClassW(), SetupGetInfFileListW(), SetupOpenInfFileW(), and test_invalid_files().

◆ SetupDiGetINFClassA()

BOOL WINAPI SetupDiGetINFClassA ( IN PCSTR  InfName,
OUT LPGUID  ClassGuid,
OUT PSTR  ClassName,
IN DWORD  ClassNameSize,
OUT PDWORD RequiredSize  OPTIONAL 
)

Definition at line 2347 of file parser.c.

2353 {
2354  PWSTR InfNameW = NULL;
2355  PWSTR ClassNameW = NULL;
2356  BOOL ret = FALSE;
2357 
2358  TRACE("%s %p %p %ld %p\n", debugstr_a(InfName), ClassGuid,
2359  ClassName, ClassNameSize, RequiredSize);
2360 
2361  if (InfName != NULL)
2362  {
2363  InfNameW = pSetupMultiByteToUnicode(InfName, CP_ACP);
2364  if (InfNameW == NULL) goto Cleanup;
2365  }
2366 
2367  if (ClassName != NULL && ClassNameSize != 0)
2368  {
2369  ClassNameW = MyMalloc(ClassNameSize * sizeof(WCHAR));
2370  if (ClassNameW == NULL) goto Cleanup;
2371  }
2372 
2373  ret = SetupDiGetINFClassW(InfNameW, ClassGuid, ClassNameW, ClassNameSize, RequiredSize);
2374 
2375  if (ret && ClassNameW != NULL)
2376  {
2377  ret = WideCharToMultiByte(CP_ACP, 0, ClassNameW, -1, ClassName, ClassNameSize, NULL, NULL) != 0;
2378  }
2379 
2380 Cleanup:
2381  MyFree(InfNameW);
2382  MyFree(ClassNameW);
2383 
2384  return ret;
2385 }
#define WideCharToMultiByte
Definition: compat.h:101
uint16_t * PWSTR
Definition: typedefs.h:54
#define CP_ACP
Definition: compat.h:99
BOOL WINAPI SetupDiGetINFClassW(IN PCWSTR InfName, OUT LPGUID ClassGuid, OUT PWSTR ClassName, IN DWORD ClassNameSize, OUT PDWORD RequiredSize OPTIONAL)
Definition: parser.c:2316
LPWSTR WINAPI pSetupMultiByteToUnicode(LPCSTR lpMultiByteStr, UINT uCodePage)
Definition: misc.c:281
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
int ret
static const WCHAR Cleanup[]
Definition: register.c:80
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128

Referenced by test_get_inf_class().

◆ SetupDiGetINFClassW()

BOOL WINAPI SetupDiGetINFClassW ( IN PCWSTR  InfName,
OUT LPGUID  ClassGuid,
OUT PWSTR  ClassName,
IN DWORD  ClassNameSize,
OUT PDWORD RequiredSize  OPTIONAL 
)

Definition at line 2316 of file parser.c.

2322 {
2323  HINF hInf = INVALID_HANDLE_VALUE;
2324  BOOL ret = FALSE;
2325 
2326  TRACE("%s %p %p %ld %p\n", debugstr_w(InfName), ClassGuid,
2327  ClassName, ClassNameSize, RequiredSize);
2328 
2329  /* Open .inf file */
2330  hInf = SetupOpenInfFileW(InfName, NULL, INF_STYLE_WIN4, NULL);
2331  if (hInf == INVALID_HANDLE_VALUE)
2332  goto cleanup;
2333 
2334  ret = PARSER_GetInfClassW(hInf, ClassGuid, ClassName, ClassNameSize, RequiredSize);
2335 
2336 cleanup:
2337  if (hInf != INVALID_HANDLE_VALUE)
2338  SetupCloseInfFile(hInf);
2339 
2340  TRACE("Returning %d\n", ret);
2341  return ret;
2342 }
#define INF_STYLE_WIN4
Definition: infsupp.h:41
static BOOL PARSER_GetInfClassW(IN HINF hInf, OUT LPGUID ClassGuid, OUT PWSTR ClassName, IN DWORD ClassNameSize, OUT PDWORD RequiredSize OPTIONAL)
Definition: parser.c:1161
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define TRACE(s)
Definition: solgame.cpp:4
int ret
char * cleanup(char *str)
Definition: wpickclick.c:99
void WINAPI SetupCloseInfFile(HINF hinf)
Definition: parser.c:1393

Referenced by SetupDiGetINFClassA(), and SetupDiInstallDevice().

◆ SetupEnumInfSectionsA()

BOOL WINAPI SetupEnumInfSectionsA ( HINF  hinf,
UINT  index,
PSTR  buffer,
DWORD  size,
DWORD need 
)

Definition at line 1406 of file parser.c.

1407 {
1408  struct inf_file *file = hinf;
1409 
1410  for (file = hinf; file; file = file->next)
1411  {
1413  {
1414  DWORD len = WideCharToMultiByte( CP_ACP, 0, file->sections[index]->name, -1,
1415  NULL, 0, NULL, NULL );
1416  if (need) *need = len;
1417  if (!buffer)
1418  {
1419  if (!size) return TRUE;
1421  return FALSE;
1422  }
1423  if (len > size)
1424  {
1426  return FALSE;
1427  }
1428  WideCharToMultiByte( CP_ACP, 0, file->sections[index]->name, -1, buffer, size, NULL, NULL );
1429  return TRUE;
1430  }
1431  index -= file->nb_sections;
1432  }
1434  return FALSE;
1435 }
#define TRUE
Definition: types.h:120
#define WideCharToMultiByte
Definition: compat.h:101
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
#define CP_ACP
Definition: compat.h:99
GLuint buffer
Definition: glext.h:5915
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091
char name[1]
Definition: fci.c:135
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
GLsizeiptr size
Definition: glext.h:5919
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
GLenum GLsizei len
Definition: glext.h:6722
unsigned int nb_sections
Definition: parser.c:68
static UINT PSTR DWORD UINT * need
Definition: parser.c:36
Definition: inf.c:48
Definition: fci.c:126
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ SetupEnumInfSectionsW()

BOOL WINAPI SetupEnumInfSectionsW ( HINF  hinf,
UINT  index,
PWSTR  buffer,
DWORD  size,
DWORD need 
)

Definition at line 1441 of file parser.c.

1442 {
1443  struct inf_file *file = hinf;
1444 
1445  for (file = hinf; file; file = file->next)
1446  {
1448  {
1449  DWORD len = strlenW( file->sections[index]->name ) + 1;
1450  if (need) *need = len;
1451  if (!buffer)
1452  {
1453  if (!size) return TRUE;
1455  return FALSE;
1456  }
1457  if (len > size)
1458  {
1460  return FALSE;
1461  }
1462  memcpy( buffer, file->sections[index]->name, len * sizeof(WCHAR) );
1463  return TRUE;
1464  }
1465  index -= file->nb_sections;
1466  }
1468  return FALSE;
1469 }
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
GLuint buffer
Definition: glext.h:5915
#define ERROR_INVALID_USER_BUFFER
Definition: winerror.h:1091
char name[1]
Definition: fci.c:135
GLuint index
Definition: glext.h:6031
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
unsigned int nb_sections
Definition: parser.c:68
static UINT PSTR DWORD UINT * need
Definition: parser.c:36
Definition: inf.c:48
Definition: fci.c:126
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ SetupFindFirstLineA()

BOOL WINAPI SetupFindFirstLineA ( HINF  hinf,
PCSTR  section,
PCSTR  key,
INFCONTEXT context 
)

Definition at line 1564 of file parser.c.

1565 {
1566  UNICODE_STRING sectionW, keyW;
1567  BOOL ret = FALSE;
1568 
1569  if (!RtlCreateUnicodeStringFromAsciiz( &sectionW, section ))
1570  {
1572  return FALSE;
1573  }
1574 
1575  if (!key) ret = SetupFindFirstLineW( hinf, sectionW.Buffer, NULL, context );
1576  else
1577  {
1579  {
1580  ret = SetupFindFirstLineW( hinf, sectionW.Buffer, keyW.Buffer, context );
1582  }
1584  }
1585  RtlFreeUnicodeString( &sectionW );
1586  return ret;
1587 }
Definition: http.c:6587
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
Definition: parser.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
BOOL WINAPI SetupFindFirstLineW(HINF hinf, PCWSTR section, PCWSTR key, INFCONTEXT *context)
Definition: parser.c:1593
static const WCHAR keyW[]
Definition: tokenize.c:60
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
int ret
Definition: path.c:42

Referenced by SetupGetLineTextA().

◆ SetupFindFirstLineW()

BOOL WINAPI SetupFindFirstLineW ( HINF  hinf,
PCWSTR  section,
PCWSTR  key,
INFCONTEXT context 
)

Definition at line 1593 of file parser.c.

1594 {
1595  struct inf_file *file;
1596  int section_index;
1597 
1598  for (file = hinf; file; file = file->next)
1599  {
1600  if ((section_index = find_section( file, section )) == -1) continue;
1601  if (key)
1602  {
1603  INFCONTEXT ctx;
1604  ctx.Inf = hinf;
1605  ctx.CurrentInf = file;
1606  ctx.Section = section_index;
1607  ctx.Line = -1;
1608  return SetupFindNextMatchLineW( &ctx, key, context );
1609  }
1610  if (file->sections[section_index]->nb_lines)
1611  {
1612  context->Inf = hinf;
1613  context->CurrentInf = file;
1614  context->Section = section_index;
1615  context->Line = 0;
1616  SetLastError( 0 );
1617  TRACE( "(%p,%s,%s): returning %d/0\n",
1618  hinf, debugstr_w(section), debugstr_w(key), section_index );
1619  return TRUE;
1620  }
1621  }
1622  TRACE( "(%p,%s,%s): not found\n", hinf, debugstr_w(section), debugstr_w(key) );
1624  return FALSE;
1625 }
#define TRUE
Definition: types.h:120
Definition: http.c:6587
Definition: parser.c:55
HINF CurrentInf
Definition: infsupp.h:25
#define debugstr_w
Definition: kernel32.h:32
#define ERROR_LINE_NOT_FOUND
Definition: setupapi.h:289
#define TRACE(s)
Definition: solgame.cpp:4
const char file[]
Definition: icontest.c:11
#define SetLastError(x)
Definition: compat.h:409
UINT Section
Definition: infsupp.h:26
static int find_section(const struct inf_file *file, const WCHAR *name)
Definition: parser.c:177
HINF Inf
Definition: infsupp.h:24
BOOL WINAPI SetupFindNextMatchLineW(PINFCONTEXT context_in, PCWSTR key, PINFCONTEXT context_out)
Definition: parser.c:1694
Definition: inf.c:48
UINT Line
Definition: infsupp.h:27
Definition: path.c:42
Definition: fci.c:126

Referenced by SetupFindFirstLineA(), SetupGetLineTextW(), and SetupOpenAppendInfFileW().

◆ SetupFindNextLine()

BOOL WINAPI SetupFindNextLine ( PINFCONTEXT  context_in,
PINFCONTEXT  context_out 
)

Definition at line 1631 of file parser.c.

1632 {
1633  struct inf_file *file = context_in->CurrentInf;
1634  struct section *section;
1635 
1636  if (context_in->Section >= file->nb_sections) goto error;
1637 
1638  section = file->sections[context_in->Section];
1639  if (context_in->Line+1 < section->nb_lines)
1640  {
1641  if (context_out != context_in) *context_out = *context_in;
1642  context_out->Line++;
1643  SetLastError( 0 );
1644  return TRUE;
1645  }
1646 
1647  /* now search the appended files */
1648 
1649  for (file = file->next; file; file = file->next)
1650  {
1651  int section_index = find_section( file, section->name );
1652  if (section_index == -1) continue;
1653  if (file->sections[section_index]->nb_lines)
1654  {
1655  context_out->Inf = context_in->Inf;
1656  context_out->CurrentInf = file;
1657  context_out->Section = section_index;
1658  context_out->Line = 0;
1659  SetLastError( 0 );
1660  return TRUE;
1661  }
1662  }
1663  error:
1665  return FALSE;
1666 }
#define TRUE
Definition: types.h:120
Definition: parser.c:55
HINF CurrentInf
Definition: infsupp.h:25
const WCHAR * name
Definition: parser.c:57
#define ERROR_LINE_NOT_FOUND
Definition: setupapi.h:289
const char * section
Definition: parser.c:191
const char file[]
Definition: icontest.c:11
DWORD error
Definition: parser.c:105
#define SetLastError(x)
Definition: compat.h:409
unsigned int nb_lines
Definition: parser.c:58
UINT Section
Definition: infsupp.h:26
static int find_section(const struct inf_file *file, const WCHAR *name)
Definition: parser.c:177
HINF Inf
Definition: infsupp.h:24
Definition: inf.c:48
UINT Line
Definition: infsupp.h:27
Definition: fci.c:126

Referenced by SetupFindNextMatchLineA(), and SetupFindNextMatchLineW().

◆ SetupFindNextMatchLineA()

BOOL WINAPI SetupFindNextMatchLineA ( PINFCONTEXT  context_in,
PCSTR  key,
PINFCONTEXT  context_out 
)

Definition at line 1672 of file parser.c.

1674 {
1676  BOOL ret = FALSE;
1677 
1678  if (!key) return SetupFindNextLine( context_in, context_out );
1679 
1682  else
1683  {
1684  ret = SetupFindNextMatchLineW( context_in, keyW.Buffer, context_out );
1686  }
1687  return ret;
1688 }
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
static const WCHAR keyW[]
Definition: tokenize.c:60
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
int ret
BOOL WINAPI SetupFindNextLine(PINFCONTEXT context_in, PINFCONTEXT context_out)
Definition: parser.c:1631
BOOL WINAPI SetupFindNextMatchLineW(PINFCONTEXT context_in, PCWSTR key, PINFCONTEXT context_out)
Definition: parser.c:1694
Definition: path.c:42

◆ SetupFindNextMatchLineW()

BOOL WINAPI SetupFindNextMatchLineW ( PINFCONTEXT  context_in,
PCWSTR  key,
PINFCONTEXT  context_out 
)

Definition at line 1694 of file parser.c.

1696 {
1697  struct inf_file *file = context_in->CurrentInf;
1698  struct section *section;
1699  struct line *line;
1700  unsigned int i;
1701 
1702  if (!key) return SetupFindNextLine( context_in, context_out );
1703 
1704  if (context_in->Section >= file->nb_sections) goto error;
1705 
1706  section = file->sections[context_in->Section];
1707 
1708  for (i = context_in->Line+1, line = &section->lines[i]; i < section->nb_lines; i++, line++)
1709  {
1710  if (line->key_field == -1) continue;
1711  if (!strcmpiW( key, file->fields[line->key_field].text ))
1712  {
1713  if (context_out != context_in) *context_out = *context_in;
1714  context_out->Line = i;
1715  SetLastError( 0 );
1716  TRACE( "(%p,%s,%s): returning %d\n",
1718  return TRUE;
1719  }
1720  }
1721 
1722  /* now search the appended files */
1723 
1724  for (file = file->next; file; file = file->next)
1725  {
1726  int section_index = find_section( file, section->name );
1727  if (section_index == -1) continue;
1728  section = file->sections[section_index];
1729  for (i = 0, line = section->lines; i < section->nb_lines; i++, line++)
1730  {
1731  if (line->key_field == -1) continue;
1732  if (!strcmpiW( key, file->fields[line->key_field].text ))
1733  {
1734  context_out->Inf = context_in->Inf;
1735  context_out->CurrentInf = file;
1736  context_out->Section = section_index;
1737  context_out->Line = i;
1738  SetLastError( 0 );
1739  TRACE( "(%p,%s,%s): returning %d/%d\n",
1740  file, debugstr_w(section->name), debugstr_w(key), section_index, i );
1741  return TRUE;
1742  }
1743  }
1744  }
1745  TRACE( "(%p,%s,%s): not found\n",
1746  context_in->CurrentInf, debugstr_w(section->name), debugstr_w(key) );
1747  error:
1749  return FALSE;
1750 }
#define TRUE
Definition: types.h:120
Definition: parser.c:55
HINF CurrentInf
Definition: infsupp.h:25
const WCHAR * name
Definition: parser.c:57
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
#define debugstr_w
Definition: kernel32.h:32
Definition: parser.c:48
#define ERROR_LINE_NOT_FOUND
Definition: setupapi.h:289
struct line lines[16]
Definition: parser.c:60
const char * section
Definition: parser.c:191
#define TRACE(s)
Definition: solgame.cpp:4
int key_field
Definition: parser.c:52
const char file[]
Definition: icontest.c:11
DWORD error
Definition: parser.c:105
#define SetLastError(x)
Definition: compat.h:409
char line[200]
Definition: main.c:97
#define strcmpiW(s1, s2)
Definition: unicode.h:39
UINT Section
Definition: infsupp.h:26
static int find_section(const struct inf_file *file, const WCHAR *name)
Definition: parser.c:177
BOOL WINAPI SetupFindNextLine(PINFCONTEXT context_in, PINFCONTEXT context_out)
Definition: parser.c:1631
HINF Inf
Definition: infsupp.h:24
Definition: inf.c:48
UINT Line
Definition: infsupp.h:27
Definition: path.c:42
Definition: fci.c:126

Referenced by iterate_section_fields(), SetupDiInstallDeviceInterfaces(), SetupFindFirstLineW(), SetupFindNextMatchLineA(), and SetupInstallServicesFromInfSectionExW().

◆ SetupGetBinaryField()

BOOL WINAPI SetupGetBinaryField ( PINFCONTEXT  context,
DWORD  index,
BYTE buffer,
DWORD  size,
LPDWORD  required 
)

Definition at line 1969 of file parser.c.

1971 {
1972  struct inf_file *file = context->CurrentInf;
1973  struct line *line = get_line( file, context->Section, context->Line );
1974  struct field *field;
1975  int i;
1976 
1977  if (!line)
1978  {
1980  return FALSE;
1981  }
1982  if (!index || index > line->nb_fields)
1983  {
1985  return FALSE;
1986  }
1987  index--; /* fields start at 0 */
1988  if (required) *required = line->nb_fields - index;
1989  if (!buffer) return TRUE;
1990  if (size < line->nb_fields - index)
1991  {
1993  return FALSE;
1994  }
1995  field = &file->fields[line->first_field + index];
1996  for (i = index; i < line->nb_fields; i++, field++)
1997  {
1998  const WCHAR *p;
1999  DWORD value = 0;
2000  for (p = field->text; *p && isxdigitW(*p); p++)
2001  {
2002  if ((value <<= 4) > 255)
2003  {
2005  return FALSE;
2006  }
2007  if (*p <= '9') value |= (*p - '0');
2008  else value |= (tolowerW(*p) - 'a' + 10);
2009  }
2010  buffer[i - index] = value;
2011  }
2012  if (TRACE_ON(setupapi))
2013  {
2014  TRACE( "%p/%p/%d/%d index %d returning:\n",
2015  context->Inf, context->CurrentInf, context->Section, context->Line, index );
2016  for (i = index; i < line->nb_fields; i++) TRACE( " %02x\n", buffer[i - index] );
2017  }
2018  return TRUE;
2019 }
const WCHAR * text
Definition: parser.c:45
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
Definition: http.c:6587
static UINT index
Definition: parser.c:36
int first_field
Definition: parser.c:50
GLuint buffer
Definition: glext.h:5915
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
Definition: parser.c:48
#define ERROR_LINE_NOT_FOUND
Definition: setupapi.h:289
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
Definition: parser.c:43
WINE_UNICODE_INLINE WCHAR tolowerW(WCHAR ch)
Definition: unicode.h:135
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
WINE_UNICODE_INLINE int isxdigitW(WCHAR wc)
Definition: unicode.h:175
static struct line * get_line(struct inf_file *file, unsigned int section_index, unsigned int line_index)
Definition: parser.c:249
GLsizei const GLfloat * value
Definition: glext.h:6069
#define ERROR_INVALID_DATA
Definition: winerror.h:116
GLfloat GLfloat p
Definition: glext.h:8902
int nb_fields
Definition: parser.c:51
#define TRACE_ON(x)
Definition: compat.h:65
Definition: inf.c:48
Definition: fci.c:126
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ SetupGetFieldCount()

DWORD WINAPI SetupGetFieldCount ( PINFCONTEXT  context)

Definition at line 1858 of file parser.c.

1859 {
1860  struct inf_file *file = context->CurrentInf;
1861  struct line *line = get_line( file, context->Section, context->Line );
1862 
1863  if (!line) return 0;
1864  return line->nb_fields;
1865 }
Definition: http.c:6587
Definition: parser.c:48
static struct line * get_line(struct inf_file *file, unsigned int section_index, unsigned int line_index)
Definition: parser.c:249
int nb_fields
Definition: parser.c:51
Definition: inf.c:48
Definition: fci.c:126

◆ SetupGetInfFileListA()

BOOL WINAPI SetupGetInfFileListA ( IN PCSTR DirectoryPath  OPTIONAL,
IN DWORD  InfStyle,
IN OUT PSTR ReturnBuffer  OPTIONAL,
IN DWORD ReturnBufferSize  OPTIONAL,
OUT PDWORD RequiredSize  OPTIONAL 
)

Definition at line 2272 of file parser.c.

2278 {
2279  PWSTR DirectoryPathW = NULL;
2280  PWSTR ReturnBufferW = NULL;
2281  BOOL ret = FALSE;
2282 
2283  TRACE("%s %lx %p %ld %p\n", debugstr_a(DirectoryPath), InfStyle,
2284  ReturnBuffer, ReturnBufferSize, RequiredSize);
2285 
2286  if (DirectoryPath != NULL)
2287  {
2288  DirectoryPathW = pSetupMultiByteToUnicode(DirectoryPath, CP_ACP);
2289  if (DirectoryPathW == NULL) goto Cleanup;
2290  }
2291 
2292  if (ReturnBuffer != NULL && ReturnBufferSize != 0)
2293  {
2294  ReturnBufferW = MyMalloc(ReturnBufferSize * sizeof(WCHAR));
2295  if (ReturnBufferW == NULL) goto Cleanup;
2296  }
2297 
2298  ret = SetupGetInfFileListW(DirectoryPathW, InfStyle, ReturnBufferW, ReturnBufferSize, RequiredSize);
2299 
2300  if (ret && ReturnBufferW != NULL)
2301  {
2302  ret = WideCharToMultiByte(CP_ACP, 0, ReturnBufferW, -1, ReturnBuffer, ReturnBufferSize, NULL, NULL) != 0;
2303  }
2304 
2305 Cleanup:
2306  MyFree(DirectoryPathW);
2307  MyFree(ReturnBufferW);
2308 
2309  return ret;
2310 }
#define WideCharToMultiByte
Definition: compat.h:101
uint16_t * PWSTR
Definition: typedefs.h:54
#define CP_ACP
Definition: compat.h:99
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1892
BOOL WINAPI SetupGetInfFileListW(IN PCWSTR DirectoryPath OPTIONAL, IN DWORD InfStyle, IN OUT PWSTR ReturnBuffer OPTIONAL, IN DWORD ReturnBufferSize OPTIONAL, OUT PDWORD RequiredSize OPTIONAL)
Definition: parser.c:2139
LPWSTR WINAPI pSetupMultiByteToUnicode(LPCSTR lpMultiByteStr, UINT uCodePage)
Definition: misc.c:281
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
int ret
static const WCHAR Cleanup[]
Definition: register.c:80
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128

Referenced by test_inffilelistA().

◆ SetupGetInfFileListW()

BOOL WINAPI SetupGetInfFileListW ( IN PCWSTR DirectoryPath  OPTIONAL,
IN DWORD  InfStyle,
IN OUT PWSTR ReturnBuffer  OPTIONAL,
IN DWORD ReturnBufferSize  OPTIONAL,
OUT PDWORD RequiredSize  OPTIONAL 
)

Definition at line 2139 of file parser.c.

2145 {
2146  HANDLE hSearch;
2147  LPWSTR pFullFileName = NULL;
2148  LPWSTR pFileName; /* Pointer into pFullFileName buffer */
2149  LPWSTR pBuffer = ReturnBuffer;
2150  WIN32_FIND_DATAW wfdFileInfo;
2151  size_t len;
2152  DWORD requiredSize = 0;
2153  BOOL ret = FALSE;
2154 
2155  TRACE("%s %lx %p %ld %p\n", debugstr_w(DirectoryPath), InfStyle,
2156  ReturnBuffer, ReturnBufferSize, RequiredSize);
2157 
2158  if (InfStyle & ~(INF_STYLE_OLDNT | INF_STYLE_WIN4))
2159  {
2160  TRACE("Unknown flags: 0x%08lx\n", InfStyle & ~(INF_STYLE_OLDNT | INF_STYLE_WIN4));
2162  goto cleanup;
2163  }
2164  else if (ReturnBufferSize == 0 && ReturnBuffer != NULL)
2165  {
2167  goto cleanup;
2168  }
2169  else if (ReturnBufferSize > 0 && ReturnBuffer == NULL)
2170  {
2172  goto cleanup;
2173  }
2174 
2175  /* Allocate memory for file filter */
2176  if (DirectoryPath != NULL)
2177  /* "DirectoryPath\" form */
2178  len = strlenW(DirectoryPath) + 1 + 1;
2179  else
2180  /* "%SYSTEMROOT%\Inf\" form */
2181  len = MAX_PATH + 1 + strlenW(InfDirectory) + 1;
2182  len += MAX_PATH; /* To contain file name or "*.inf" string */
2183  pFullFileName = MyMalloc(len * sizeof(WCHAR));
2184  if (pFullFileName == NULL)
2185  {
2187  goto cleanup;
2188  }
2189 
2190  /* Fill file filter buffer */
2191  if (DirectoryPath)
2192  {
2193  strcpyW(pFullFileName, DirectoryPath);
2194  if (*pFullFileName && pFullFileName[strlenW(pFullFileName) - 1] != '\\')
2195  strcatW(pFullFileName, BackSlash);
2196  }
2197  else
2198  {
2199  len = GetSystemWindowsDirectoryW(pFullFileName, MAX_PATH);
2200  if (len == 0 || len > MAX_PATH)
2201  goto cleanup;
2202  if (pFullFileName[strlenW(pFullFileName) - 1] != '\\')
2203  strcatW(pFullFileName, BackSlash);
2204  strcatW(pFullFileName, InfDirectory);
2205  }
2206  pFileName = &pFullFileName[strlenW(pFullFileName)];
2207 
2208  /* Search for the first file */
2209  strcpyW(pFileName, InfFileSpecification);
2210  hSearch = FindFirstFileW(pFullFileName, &wfdFileInfo);
2211  if (hSearch == INVALID_HANDLE_VALUE)
2212  {
2213  TRACE("No file returned by %s\n", debugstr_w(pFullFileName));
2214  goto cleanup;
2215  }
2216 
2217  do
2218  {
2219  HINF hInf;
2220 
2221  strcpyW(pFileName, wfdFileInfo.cFileName);
2222  hInf = SetupOpenInfFileW(
2223  pFullFileName,
2224  NULL, /* Inf class */
2225  InfStyle,
2226  NULL /* Error line */);
2227  if (hInf == INVALID_HANDLE_VALUE)
2228  {
2230  {
2231  /* InfStyle was not correct. Skip this file */
2232  continue;
2233  }
2234  TRACE("Invalid .inf file %s\n", debugstr_w(pFullFileName));
2235  continue;
2236  }
2237 
2238  len = strlenW(wfdFileInfo.cFileName) + 1;
2239  requiredSize += (DWORD)len;
2240  if (requiredSize <= ReturnBufferSize)
2241  {
2242  strcpyW(pBuffer, wfdFileInfo.cFileName);
2243  pBuffer = &pBuffer[len];
2244  }
2245  SetupCloseInfFile(hInf);
2246  } while (FindNextFileW(hSearch, &wfdFileInfo));
2247  FindClose(hSearch);
2248 
2249  requiredSize += 1; /* Final NULL char */
2250  if (requiredSize <= ReturnBufferSize)
2251  {
2252  *pBuffer = '\0';
2253  ret = TRUE;
2254  }
2255  else
2256  {
2258  ret = FALSE;
2259  }
2260  if (RequiredSize)
2261  *RequiredSize = requiredSize;
2262 
2263 cleanup:
2264  MyFree(pFullFileName);
2265  return ret;
2266 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
UINT WINAPI GetSystemWindowsDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2396
#define TRUE
Definition: types.h:120
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define INF_STYLE_WIN4
Definition: infsupp.h:41
#define INF_STYLE_OLDNT
Definition: infsupp.h:37
static const WCHAR BackSlash[]
Definition: parser.c:29
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_In_ DWORD _In_ DWORD ReturnBufferSize
Definition: setupapi.h:1892
HINF WINAPI SetupOpenInfFileW(PCWSTR name, PCWSTR class, DWORD style, UINT *error)
Definition: parser.c:1229
unsigned int BOOL
Definition: ntddk_ex.h:94
#define debugstr_w
Definition: kernel32.h:32
#define ERROR_CLASS_MISMATCH
Definition: setupapi.h:292
smooth NULL
Definition: ftsmooth.c:416
PVOID pBuffer
_Inout_ PRTL_BUFFER _In_ SIZE_T RequiredSize
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD
Definition: parser.c:34
#define SetLastError(x)
Definition: compat.h:409
int ret
GLenum GLsizei len
Definition: glext.h:6722
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
static const WCHAR InfDirectory[]
Definition: parser.c:32
WINE_UNICODE_INLINE WCHAR * strcatW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:242
char * cleanup(char *str)
Definition: wpickclick.c:99
LPVOID WINAPI MyMalloc(DWORD dwSize)
Definition: misc.c:147
WCHAR * LPWSTR
Definition: xmlstorage.h:184
VOID WINAPI MyFree(LPVOID lpMem)
Definition: misc.c:128
static const WCHAR InfFileSpecification[]
Definition: parser.c:33
void WINAPI SetupCloseInfFile(HINF hinf)
Definition: parser.c:1393
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502

Referenced by SetupDiBuildDriverInfoList(), SetupGetInfFileListA(), and test_inffilelist().

◆ SetupGetIntField()

BOOL WINAPI SetupGetIntField ( PINFCONTEXT  context,
DWORD  index,
PINT  result 
)

Definition at line 1933 of file parser.c.

1934 {
1935  char localbuff[20];
1936  char *end, *buffer = localbuff;
1937  DWORD required;
1938  INT res;
1939  BOOL ret;
1940 
1941  if (!(ret = SetupGetStringFieldA( context, index, localbuff, sizeof(localbuff), &required )))
1942  {
1943  if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FALSE;
1944  if (!(buffer = HeapAlloc( GetProcessHeap(), 0, required ))) return FALSE;
1945  if (!(ret = SetupGetStringFieldA( context, index, buffer, required, NULL ))) goto done;
1946  }
1947  /* The call to SetupGetStringFieldA succeeded. If buffer is empty we have an optional field */
1948  if (!*buffer) *result = 0;
1949  else
1950  {
1951  res = strtol( buffer, &end, 0 );
1952  if (end != buffer && !*end) *result = res;
1953  else
1954  {
1956  ret = FALSE;
1957  }
1958  }
1959 
1960  done:
1961  if (buffer != localbuff) HeapFree( GetProcessHeap(), 0, buffer );
1962  return ret;
1963 }
Definition: http.c:6587
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
GLuint buffer
Definition: glext.h:5915
GLuint GLuint end
Definition: gl.h:1545
int32_t INT
Definition: typedefs.h:56
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
int ret
#define ERROR_INVALID_DATA
Definition: winerror.h:116
BOOL WINAPI SetupGetStringFieldA(PINFCONTEXT context, DWORD index, PSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1871
_Check_return_ long __cdecl strtol(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix)
GLuint res
Definition: glext.h:9613
GLuint64EXT * result
Definition: glext.h:11304
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by PARSER_get_dest_dir().

◆ SetupGetLineByIndexA()

BOOL WINAPI SetupGetLineByIndexA ( HINF  hinf,
PCSTR  section,
DWORD  index,
INFCONTEXT context 
)

Definition at line 1515 of file parser.c.

1516 {
1517  UNICODE_STRING sectionW;
1518  BOOL ret = FALSE;
1519 
1520  if (!RtlCreateUnicodeStringFromAsciiz( &sectionW, section ))
1522  else
1523  {
1524  ret = SetupGetLineByIndexW( hinf, sectionW.Buffer, index, context );
1525  RtlFreeUnicodeString( &sectionW );
1526  }
1527  return ret;
1528 }
Definition: http.c:6587
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
BOOL WINAPI SetupGetLineByIndexW(HINF hinf, PCWSTR section, DWORD index, INFCONTEXT *context)
Definition: parser.c:1534
Definition: parser.c:55
unsigned int BOOL
Definition: ntddk_ex.h:94
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
GLuint index
Definition: glext.h:6031
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
int ret

◆ SetupGetLineByIndexW()

BOOL WINAPI SetupGetLineByIndexW ( HINF  hinf,
PCWSTR  section,
DWORD  index,
INFCONTEXT context 
)

Definition at line 1534 of file parser.c.

1535 {
1536  struct inf_file *file = hinf;
1537  int section_index;
1538 
1539  for (file = hinf; file; file = file->next)
1540  {
1541  if ((section_index = find_section( file, section )) == -1) continue;
1542  if (index < file->sections[section_index]->nb_lines)
1543  {
1544  context->Inf = hinf;
1545  context->CurrentInf = file;
1546  context->Section = section_index;
1547  context->Line = index;
1548  SetLastError( 0 );
1549  TRACE( "(%p,%s): returning %d/%d\n",
1550  hinf, debugstr_w(section), section_index, index );
1551  return TRUE;
1552  }
1553  index -= file->sections[section_index]->nb_lines;
1554  }
1555  TRACE( "(%p,%s) not found\n", hinf, debugstr_w(section) );
1557  return FALSE;
1558 }
#define TRUE
Definition: types.h:120
Definition: http.c:6587
static UINT index
Definition: parser.c:36
Definition: parser.c:55
struct section sections[2]
Definition: diskspace.c:792
#define debugstr_w
Definition: kernel32.h:32
#define ERROR_LINE_NOT_FOUND
Definition: setupapi.h:289
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
const char file[]
Definition: icontest.c:11
#define SetLastError(x)
Definition: compat.h:409
static int find_section(const struct inf_file *file, const WCHAR *name)
Definition: parser.c:177
Definition: inf.c:48
Definition: fci.c:126

Referenced by SetupGetLineByIndexA().

◆ SetupGetLineCountA()

LONG WINAPI SetupGetLineCountA ( HINF  hinf,
PCSTR  name 
)

Definition at line 1475 of file parser.c.

1476 {
1477  UNICODE_STRING sectionW;
1478  LONG ret = -1;
1479 
1480  if (!RtlCreateUnicodeStringFromAsciiz( &sectionW, name ))
1482  else
1483  {
1484  ret = SetupGetLineCountW( hinf, sectionW.Buffer );
1485  RtlFreeUnicodeString( &sectionW );
1486  }
1487  return ret;
1488 }
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
long LONG
Definition: pedump.c:60
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
int ret
Definition: name.c:36
LONG WINAPI SetupGetLineCountW(HINF hinf, PCWSTR section)
Definition: parser.c:1494

◆ SetupGetLineCountW()

LONG WINAPI SetupGetLineCountW ( HINF  hinf,
PCWSTR  section 
)

Definition at line 1494 of file parser.c.

1495 {
1496  struct inf_file *file = hinf;
1497  int section_index;
1498  LONG ret = -1;
1499 
1500  for (file = hinf; file; file = file->next)
1501  {
1502  if ((section_index = find_section( file, section )) == -1) continue;
1503  if (ret == -1) ret = 0;
1504  ret += file->sections[section_index]->nb_lines;
1505  }
1506  TRACE( "(%p,%s) returning %d\n", hinf, debugstr_w(section), ret );
1507  SetLastError( (ret == -1) ? ERROR_SECTION_NOT_FOUND : 0 );
1508  return ret;
1509 }
#define ERROR_SECTION_NOT_FOUND
Definition: setupapi.h:288
Definition: parser.c:55
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
const char file[]
Definition: icontest.c:11
#define SetLastError(x)
Definition: compat.h:409
int ret
static int find_section(const struct inf_file *file, const WCHAR *name)
Definition: parser.c:177
Definition: inf.c:48
Definition: fci.c:126

Referenced by SetupGetLineCountA(), and StartComponentRegistration().

◆ SetupGetLineTextA()

BOOL WINAPI SetupGetLineTextA ( PINFCONTEXT  context,
HINF  hinf,
PCSTR  section_name,
PCSTR  key_name,
PSTR  buffer,
DWORD  size,
PDWORD  required 
)

Definition at line 1807 of file parser.c.

1809 {
1810  struct inf_file *file;
1811  struct line *line;
1812  struct field *field;
1813  int i;
1814  DWORD total = 0;
1815 
1816  if (!context)
1817  {
1818  INFCONTEXT new_context;
1819  if (!SetupFindFirstLineA( hinf, section_name, key_name, &new_context )) return FALSE;
1820  file = new_context.CurrentInf;
1821  line = get_line( file, new_context.Section, new_context.Line );
1822  }
1823  else
1824  {
1825  file = context->CurrentInf;
1826  if (!(line = get_line( file, context->Section, context->Line )))
1827  {
1829  return FALSE;
1830  }
1831  }
1832 
1833  for (i = 0, field = &file->fields[line->first_field]; i < line->nb_fields; i++, field++)
1834  total += PARSER_string_substA( file, field->text, NULL, 0 ) + 1;
1835 
1836  if (required) *required = total;
1837  if (buffer)
1838  {
1839  if (total > size)
1840  {
1842  return FALSE;
1843  }
1844  for (i = 0, field = &file->fields[line->first_field]; i < line->nb_fields; i++, field++)
1845  {
1846  unsigned int len = PARSER_string_substA( file, field->text, buffer, size );
1847  if (i+1 < line->nb_fields) buffer[len] = ',';
1848  buffer += len + 1;
1849  }
1850  }
1851  return TRUE;
1852 }
const WCHAR * text
Definition: parser.c:45
#define TRUE
Definition: types.h:120
Definition: http.c:6587
int first_field
Definition: parser.c:50
GLuint buffer
Definition: glext.h:5915
HINF CurrentInf
Definition: infsupp.h:25
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
BOOL WINAPI SetupFindFirstLineA(HINF hinf, PCSTR section, PCSTR key, INFCONTEXT *context)
Definition: parser.c:1564
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
#define ERROR_LINE_NOT_FOUND
Definition: setupapi.h:289
GLsizeiptr size
Definition: glext.h:5919
Definition: parser.c:43
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static unsigned int PARSER_string_substA(const struct inf_file *file, const WCHAR *text, char *buffer, unsigned int size)
Definition: parser.c:456
static struct line * get_line(struct inf_file *file, unsigned int section_index, unsigned int line_index)
Definition: parser.c:249
char line[200]
Definition: main.c:97
GLenum GLsizei len
Definition: glext.h:6722
UINT Section
Definition: infsupp.h:26
int nb_fields
Definition: parser.c:51
Definition: inf.c:48
UINT Line
Definition: infsupp.h:27
Definition: fci.c:126
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by get_line_text().

◆ SetupGetLineTextW()

BOOL WINAPI SetupGetLineTextW ( PINFCONTEXT  context,
HINF  hinf,
PCWSTR  section_name,
PCWSTR  key_name,
PWSTR  buffer,
DWORD  size,
PDWORD  required 
)

Definition at line 1756 of file parser.c.

1758 {
1759  struct inf_file *file;
1760  struct line *line;
1761  struct field *field;
1762  int i;
1763  DWORD total = 0;
1764 
1765  if (!context)
1766  {
1767  INFCONTEXT new_context;
1768  if (!SetupFindFirstLineW( hinf, section_name, key_name, &new_context )) return FALSE;
1769  file = new_context.CurrentInf;
1770  line = get_line( file, new_context.Section, new_context.Line );
1771  }
1772  else
1773  {
1774  file = context->CurrentInf;
1775  if (!(line = get_line( file, context->Section, context->Line )))
1776  {
1778  return FALSE;
1779  }
1780  }
1781 
1782  for (i = 0, field = &file->fields[line->first_field]; i < line->nb_fields; i++, field++)
1783  total += PARSER_string_substW( file, field->text, NULL, 0 ) + 1;
1784 
1785  if (required) *required = total;
1786  if (buffer)
1787  {
1788  if (total > size)
1789  {
1791  return FALSE;
1792  }
1793  for (i = 0, field = &file->fields[line->first_field]; i < line->nb_fields; i++, field++)
1794  {
1795  unsigned int len = PARSER_string_substW( file, field->text, buffer, size );
1796  if (i+1 < line->nb_fields) buffer[len] = ',';
1797  buffer += len + 1;
1798  }
1799  }
1800  return TRUE;
1801 }
const WCHAR * text
Definition: parser.c:45
#define TRUE
Definition: types.h:120
Definition: http.c:6587
int first_field
Definition: parser.c:50
GLuint buffer
Definition: glext.h:5915
HINF CurrentInf
Definition: infsupp.h:25
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
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
#define ERROR_LINE_NOT_FOUND
Definition: setupapi.h:289
BOOL WINAPI SetupFindFirstLineW(HINF hinf, PCWSTR section, PCWSTR key, INFCONTEXT *context)
Definition: parser.c:1593
GLsizeiptr size
Definition: glext.h:5919
Definition: parser.c:43
const char file[]
Definition: icontest.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static struct line * get_line(struct inf_file *file, unsigned int section_index, unsigned int line_index)
Definition: parser.c:249
char line[200]
Definition: main.c:97
GLenum GLsizei len
Definition: glext.h:6722
UINT Section
Definition: infsupp.h:26
static unsigned int PARSER_string_substW(const struct inf_file *file, const WCHAR *text, WCHAR *buffer, unsigned int size)
Definition: parser.c:403
int nb_fields
Definition: parser.c:51
Definition: inf.c:48
UINT Line
Definition: infsupp.h:27
Definition: fci.c:126
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by del_dirs_callback(), GetLineText(), GetVersionInformationFromInfFile(), PARSER_GetInfClassW(), per_user_install_callback(), registry_callback(), run_setup_commands_callback(), set_ldids(), SETUP_CreateClassKey(), SetupQueryInfOriginalFileInformationW(), SetupQueueCopySectionW(), TranslateInfStringExW(), and TranslateInfStringW().

◆ SetupGetMultiSzFieldA()

BOOL WINAPI SetupGetMultiSzFieldA ( PINFCONTEXT  context,
DWORD  index,
PSTR  buffer,
DWORD  size,
LPDWORD  required 
)

Definition at line 2025 of file parser.c.

2027 {
2028  struct inf_file *file = context->CurrentInf;
2029  struct line *line = get_line( file, context->Section, context->Line );
2030  struct field *field;
2031  unsigned int len;
2032  int i;
2033  DWORD total = 1;
2034 
2035  if (!line)
2036  {
2038  return FALSE;
2039  }
2040  if (!index || index > line->nb_fields)
2041  {
2043  return FALSE;
2044  }
2045  index--; /* fields start at 0 */
2046  field = &file->fields[line->first_field + index];
2047  for (i = index; i < line->nb_fields; i++, field++)
2048  {
2049  if (!(len = PARSER_string_substA( file, field->text, NULL, 0 ))) break;
2050  total += len + 1;
2051  }
2052 
2053  if (required) *required = total;
2054  if (!buffer) return TRUE;
2055  if (total > size)
2056  {
2058  return FALSE;
2059  }
2060  field = &file->fields[line->first_field + index];
2061  for (i = index; i < line->nb_fields; i++, field++)
2062  {
2063  if (!(len = PARSER_string_substA( file, field->text, buffer, size ))) break;
2064  buffer += len + 1;
2065  }
2066  *buffer = 0; /* add final null */
2067  return TRUE;
2068 }
const WCHAR * text
Definition: parser.c:45
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
Definition: http.c:6587
static UINT index
Definition: parser.c:36
int first_field
Definition: parser.c:50
GLuint buffer
Definition: glext.h:5915
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
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
#define ERROR_LINE_NOT_FOUND
Definition: setupapi.h:289
GLuint index
Definition: glext.h:6031
GLsizeiptr size
Definition: glext.h:5919
Definition: parser.c:43
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
static unsigned int PARSER_string_substA(const struct inf_file *file, const WCHAR *text, char *buffer, unsigned int size)
Definition: parser.c:456
static struct line * get_line(struct inf_file *file, unsigned int section_index, unsigned int line_index)
Definition: parser.c:249
GLenum GLsizei len
Definition: glext.h:6722
int nb_fields
Definition: parser.c:51
Definition: inf.c:48
Definition: fci.c:126
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ SetupGetMultiSzFieldW()

BOOL WINAPI SetupGetMultiSzFieldW ( PINFCONTEXT  context,
DWORD  index,
PWSTR  buffer,
DWORD  size,
LPDWORD  required 
)

Definition at line 2074 of file parser.c.

2076 {
2077  struct inf_file *file = context->CurrentInf;
2078  struct line *line = get_line( file, context->Section, context->Line );
2079  struct field *field;
2080  unsigned int len;
2081  int i;
2082  DWORD total = 1;
2083 
2084  if (!line)
2085  {
2087  return FALSE;
2088  }
2089  if (!index || index > line->nb_fields)
2090  {
2092  return FALSE;
2093  }
2094  index--; /* fields start at 0 */
2095  field = &file->fields[line->first_field + index];
2096  for (i = index; i < line->nb_fields; i++, field++)
2097  {
2098  if (!(len = PARSER_string_substW( file, field->text, NULL, 0 ))) break;
2099  total += len + 1;
2100  }
2101 
2102  if (required) *required = total;
2103  if (!buffer) return TRUE;
2104  if (total > size)
2105  {
2107  return FALSE;
2108  }
2109  field = &file->fields[line->first_field + index];
2110  for (i = index; i < line->nb_fields; i++, field++)
2111  {
2112  if (!(len = PARSER_string_substW( file, field->text, buffer, size ))) break;
2113  buffer += len + 1;
2114  }
2115  *buffer = 0; /* add final null */
2116  return TRUE;
2117 }
const WCHAR * text
Definition: parser.c:45
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
Definition: http.c:6587
static UINT index
Definition: parser.c:36
int first_field
Definition: parser.c:50
GLuint buffer
Definition: glext.h:5915
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
smooth NULL
Definition: ftsmooth.c:416
Definition: parser.c:48
#define ERROR_LINE_NOT_FOUND
Definition: setupapi.h:289
GLuint index
Definition: glext.h:6031
GLsizeiptr size
Definition: glext.h:5919
Definition: