ReactOS  0.4.14-dev-98-gb0d4763
parser.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winreg.h"
#include "setupapi.h"
#include "wine/test.h"
Include dependency graph for parser.c:

Go to the source code of this file.

Macros

#define A255
 
#define A256   "a" A255
 
#define A400
 
#define A1200   A400 A400 A400
 
#define A511   A255 A256
 
#define A4096   A256 A256 A256 A256 A256 A256 A256 A256 A256 A256 A256 A256 A256 A256 A256 A256
 
#define A4097   "a" A4096
 
#define STD_HEADER   "[Version]\r\nSignature=\"$CHICAGO$\"\r\n"
 
#define STR_SECTION
 

Functions

static LPCSTR (WINAPI *pSetupGetFieldA)(PINFCONTEXT
 
static LPCWSTR (WINAPI *pSetupGetFieldW)(PINFCONTEXT
 
static BOOL (WINAPI *pSetupEnumInfSectionsA)(HINF hinf
 
static void init_function_pointers (void)
 
static HINF test_file_contents (const char *data, UINT *err_line)
 
static const charget_string_field (INFCONTEXT *context, DWORD index)
 
static const charget_line_text (INFCONTEXT *context)
 
static void test_invalid_files (void)
 

Variables

static HMODULE hSetupAPI
 
static DWORD
 
static UINT index
 
static UINT PSTR buffer
 
static UINT PSTR DWORD size
 
static UINT PSTR DWORD UINTneed
 
static const char tmpfilename [] = ".\\tmp.inf"
 
struct {
   const char *   data
 
   DWORD   error
 
   UINT   err_line
 
   BOOL   todo
 
invalid_files []
 

Macro Definition Documentation

◆ A1200

#define A1200   A400 A400 A400

Definition at line 60 of file parser.c.

◆ A255

#define A255
Value:
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"

Definition at line 52 of file parser.c.

◆ A256

#define A256   "a" A255

Definition at line 56 of file parser.c.

◆ A400

#define A400
Value:
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \
"aaaaaaaaaaaaaaaa" A256
#define A256
Definition: parser.c:56

Definition at line 57 of file parser.c.

◆ A4096

Definition at line 62 of file parser.c.

◆ A4097

#define A4097   "a" A4096

Definition at line 63 of file parser.c.

◆ A511

#define A511   A255 A256

Definition at line 61 of file parser.c.

◆ STD_HEADER

#define STD_HEADER   "[Version]\r\nSignature=\"$CHICAGO$\"\r\n"

Definition at line 65 of file parser.c.

◆ STR_SECTION

#define STR_SECTION
Value:
"[Strings]\nfoo=aaa\nbar=bbb\nloop=%loop2%\nloop2=%loop%\n" \
"per%%cent=abcd\nper=1\ncent=2\n22=foo\n" \
"big=" A400 "\n" \
"mydrive=\"C:\\\"\n" \
"verybig=" A1200 "\n"
#define A400
Definition: parser.c:57
#define A1200
Definition: parser.c:60

Definition at line 67 of file parser.c.

Function Documentation

◆ BOOL()

static BOOL ( WINAPI pSetupEnumInfSectionsA)
static

◆ get_line_text()

static const char* get_line_text ( INFCONTEXT context)
static

Definition at line 92 of file parser.c.

93 {
94  static char buffer[MAX_INF_STRING_LENGTH+32];
95  if (SetupGetLineTextA( context, 0, 0, 0, buffer, sizeof(buffer), NULL )) return buffer;
96  return NULL;
97 }
Definition: http.c:6587
GLuint buffer
Definition: glext.h:5915
smooth NULL
Definition: ftsmooth.c:416
static UINT PSTR buffer
Definition: parser.c:36
BOOL WINAPI SetupGetLineTextA(PINFCONTEXT context, HINF hinf, PCSTR section_name, PCSTR key_name, PSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1807
#define MAX_INF_STRING_LENGTH
Definition: infsupp.h:34

◆ get_string_field()

static const char* get_string_field ( INFCONTEXT context,
DWORD  index 
)
static

Definition at line 85 of file parser.c.

86 {
87  static char buffer[MAX_INF_STRING_LENGTH+32];
88  if (SetupGetStringFieldA( context, index, buffer, sizeof(buffer), NULL )) return buffer;
89  return NULL;
90 }
Definition: http.c:6587
GLuint buffer
Definition: glext.h:5915
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
static UINT PSTR buffer
Definition: parser.c:36
#define MAX_INF_STRING_LENGTH
Definition: infsupp.h:34
BOOL WINAPI SetupGetStringFieldA(PINFCONTEXT context, DWORD index, PSTR buffer, DWORD size, PDWORD required)
Definition: parser.c:1871

◆ init_function_pointers()

static void init_function_pointers ( void  )
static

Definition at line 38 of file parser.c.

39 {
40  hSetupAPI = GetModuleHandleA("setupapi.dll");
41 
42  /* Nice, pSetupGetField is either A or W depending on the Windows version! The actual test
43  * takes care of this difference */
44  pSetupGetFieldA = (void *)GetProcAddress(hSetupAPI, "pSetupGetField");
45  pSetupGetFieldW = (void *)GetProcAddress(hSetupAPI, "pSetupGetField");
46  pSetupEnumInfSectionsA = (void *)GetProcAddress(hSetupAPI, "SetupEnumInfSectionsA" );
47 }
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
Definition: loader.c:821
static HMODULE hSetupAPI
Definition: parser.c:33
#define GetProcAddress(x, y)
Definition: compat.h:410

◆ LPCSTR()

static LPCSTR ( WINAPI pSetupGetFieldA)
static

◆ LPCWSTR()

static LPCWSTR ( WINAPI pSetupGetFieldW)
static

◆ test_file_contents()

static HINF test_file_contents ( const char data,
UINT err_line 
)
static

Definition at line 74 of file parser.c.

75 {
76  DWORD res;
79  if (handle == INVALID_HANDLE_VALUE) return 0;
80  if (!WriteFile( handle, data, strlen(data), &res, NULL )) trace( "write error\n" );
83 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:398
#define INF_STYLE_WIN4
Definition: infsupp.h:41
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_SHARE_READ
Definition: compat.h:125
#define GENERIC_WRITE
Definition: nt_native.h:90
smooth NULL
Definition: ftsmooth.c:416
#define trace
Definition: atltest.h:70
static const char tmpfilename[]
Definition: parser.c:49
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define GENERIC_READ
Definition: compat.h:124
HINF WINAPI SetupOpenInfFileA(PCSTR name, PCSTR class, DWORD style, UINT *error)
Definition: parser.c:1139
#define CREATE_ALWAYS
Definition: disk.h:72
UINT err_line
Definition: parser.c:106
GLuint res
Definition: glext.h:9613
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:399

Referenced by test_invalid_files().

◆ test_invalid_files()

static void test_invalid_files ( void  )
static

Definition at line 151 of file parser.c.

152 {
153  unsigned int i;
154  UINT err_line;
155  HINF hinf;
156  DWORD err;
157 
158  for (i = 0; i < ARRAY_SIZE(invalid_files); i++)
159  {
160  SetLastError( 0xdeadbeef );
161  err_line = 0xdeadbeef;
163  err = GetLastError();
164  trace( "hinf=%p err=0x%x line=%d\n", hinf, err, err_line );
165  if (invalid_files[i].error) /* should fail */
166  {
167  ok( hinf == INVALID_HANDLE_VALUE, "file %u: Open succeeded\n", i );
169  {
170  ok( err == invalid_files[i].error, "file %u: Bad error %u/%u\n",
171  i, err, invalid_files[i].error );
172  ok( err_line == invalid_files[i].err_line, "file %u: Bad error line %d/%d\n",
174  }
175  }
176  else /* should succeed */
177  {
178  ok( hinf != INVALID_HANDLE_VALUE, "file %u: Open failed\n", i );
179  ok( err == 0, "file %u: Error code set to %u\n", i, err );
180  }
181  SetupCloseInfFile( hinf );
182  }
183 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
BOOL todo
Definition: parser.c:107
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 todo_wine_if(is_todo)
Definition: test.h:155
#define trace
Definition: atltest.h:70
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD error
Definition: parser.c:105
#define SetLastError(x)
Definition: compat.h:409
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static const struct @1636 invalid_files[]
#define err(...)
#define ARRAY_SIZE(a)
Definition: main.h:24
#define ok(value,...)
Definition: atltest.h:57
static HINF test_file_contents(const char *data, UINT *err_line)
Definition: parser.c:74
unsigned int UINT
Definition: ndis.h:50
UINT err_line
Definition: parser.c:106
void WINAPI SetupCloseInfFile(HINF hinf)
Definition: parser.c:1393

Variable Documentation

◆ buffer

◆ data

Definition at line 104 of file parser.c.

◆ DWORD

Definition at line 34 of file parser.c.

Referenced by SetupGetInfFileListW().

◆ err_line

◆ error

◆ hSetupAPI

HMODULE hSetupAPI
static

Definition at line 33 of file parser.c.

Referenced by init_function_pointers().

◆ index

◆ invalid_files

const { ... } invalid_files[]

Referenced by test_invalid_files().

◆ need

◆ section

◆ size

Definition at line 36 of file parser.c.

Referenced by xmlParseBalancedChunkMemoryInternal().

◆ tmpfilename

◆ todo

BOOL todo

Definition at line 107 of file parser.c.

Referenced by test_invalid_files().