52 #define A255 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \ 53 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \ 54 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \ 55 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" 57 #define A400 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \ 58 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" \ 59 "aaaaaaaaaaaaaaaa" A256 60 #define A1200 A400 A400 A400 61 #define A511 A255 A256 62 #define A4096 A256 A256 A256 A256 A256 A256 A256 A256 A256 A256 A256 A256 A256 A256 A256 A256 63 #define A4097 "a" A4096 65 #define STD_HEADER "[Version]\r\nSignature=\"$CHICAGO$\"\r\n" 67 #define STR_SECTION "[Strings]\nfoo=aaa\nbar=bbb\nloop=%loop2%\nloop2=%loop%\n" \ 68 "per%%cent=abcd\nper=1\ncent=2\n22=foo\n" \ 70 "mydrive=\"C:\\\"\n" \ 116 {
"[version]\nsignature=$chicago$", 0, 0,
FALSE },
117 {
"[VERSION]\nSIGNATURE=$CHICAGO$", 0, 0,
FALSE },
118 {
"[Version]\nSignature=$chicago$,abcd", 0, 0,
FALSE },
119 {
"[Version]\nabc=def\nSignature=$chicago$", 0, 0,
FALSE },
120 {
"[Version]\nabc=def\n[Version]\nSignature=$chicago$", 0, 0,
FALSE },
140 {
";comment\ngarbage1\ngarbage2\n[Strings]\n" STD_HEADER, 0, 0,
FALSE },
146 {
";comment\ngarbage1\ngarbage2\n" STD_HEADER "[Strings]\n", 0, 0,
FALSE },
179 ok(
err == 0,
"file %u: Error code set to %u\n",
i,
err );
196 {
STD_HEADER "[TestSection]",
"TestSection", 0 },
197 {
STD_HEADER "[TestSection]\n",
"TestSection", 0 },
198 {
STD_HEADER "[TESTSECTION]\r\n",
"TestSection", 0 },
199 {
STD_HEADER "[TestSection]\n[abc]",
"testsection", 0 },
203 {
STD_HEADER "[TestSection] \r\n",
"TestSection", 0 },
204 {
STD_HEADER " [TestSection]\r\n",
"TestSection", 0 },
205 {
STD_HEADER " [TestSection] dummy\r\n",
"TestSection", 0 },
206 {
STD_HEADER " [TestSection] [foo]\r\n",
"TestSection", 0 },
207 {
STD_HEADER " [ Test Section ] dummy\r\n",
" Test Section ", 0 },
208 {
STD_HEADER "[TestSection] \032\ndummy",
"TestSection", 0 },
209 {
STD_HEADER "[TestSection] \n\032dummy",
"TestSection", 0 },
211 {
STD_HEADER "[Test[Section]\r\n",
"Test[Section", 0 },
212 {
STD_HEADER "[Test[S]ection]\r\n",
"Test[S", 0 },
213 {
STD_HEADER "[Test[[[Section]\r\n",
"Test[[[Section", 0 },
216 {
STD_HEADER "[Test\"Section]\r\n",
"Test\"Section", 0 },
217 {
STD_HEADER "[Test\\Section]\r\n",
"Test\\Section", 0 },
218 {
STD_HEADER "[Test\\ Section]\r\n",
"Test\\ Section", 0 },
219 {
STD_HEADER "[Test;Section]\r\n",
"Test;Section", 0 },
221 {
STD_HEADER " [Test\r\b\tSection] \n",
"Test\r\b\tSection", 0 },
225 static void test_section_names(
void)
242 trace(
"hinf=%p ret=%d err=0x%x\n", hinf,
ret,
err );
247 ok( !
err,
"line %u: bad error code %u\n",
i,
err );
260 static void test_enum_sections(
void)
262 static const char *contents =
STD_HEADER "[s1]\nfoo=bar\n[s2]\nbar=foo\n[s3]\n[strings]\na=b\n";
270 if (!pSetupEnumInfSectionsA)
272 win_skip(
"SetupEnumInfSectionsA not available\n" );
277 ok( hinf !=
NULL,
"Expected valid INF file\n" );
285 ok(
ret,
"SetupEnumInfSectionsA failed\n" );
291 ok( !
ret,
"SetupEnumInfSectionsA succeeded\n" );
301 "bad section '%s'\n",
buffer );
313 const char *fields[10];
317 {
"ab=cd",
"ab", {
"cd" } },
318 {
"ab=cd,ef,gh,ij",
"ab", {
"cd",
"ef",
"gh",
"ij" } },
319 {
"ab",
"ab", {
"ab" } },
320 {
"ab,cd",
NULL, {
"ab",
"cd" } },
321 {
"ab,cd=ef",
NULL, {
"ab",
"cd=ef" } },
322 {
"=abcd,ef",
"", {
"abcd",
"ef" } },
324 {
"ba\\\ncd=ef",
"bacd", {
"ef" } },
325 {
"ab \\ \ncd=ef",
"abcd", {
"ef" } },
326 {
"ab\\\ncd,ef",
NULL, {
"abcd",
"ef" } },
327 {
"ab \\ ;cc\ncd=ef",
"abcd", {
"ef" } },
328 {
"ab \\ \\ \ncd=ef",
"abcd", {
"ef" } },
329 {
"ba \\ dc=xx",
"ba \\ dc", {
"xx" } },
330 {
"ba \\\\ \nc=d",
"bac", {
"d" } },
331 {
"a=b\\\\c",
"a", {
"b\\\\c" } },
332 {
"ab=cd \\ ",
"ab", {
"cd" } },
333 {
"ba=c \\ \n \\ \n a",
"ba", {
"ca" } },
334 {
"ba=c \\ \n \\ a",
"ba", {
"c\\ a" } },
335 {
" \\ a= \\ b",
"\\ a", {
"\\ b" } },
337 {
"Ab\"Cd\"=Ef",
"AbCd", {
"Ef" } },
338 {
"Ab\"Cd=Ef\"",
"AbCd=Ef", {
"AbCd=Ef" } },
339 {
"ab\"\"\"cd,ef=gh\"",
"ab\"cd,ef=gh", {
"ab\"cd,ef=gh" } },
340 {
"ab\"\"cd=ef",
"abcd", {
"ef" } },
341 {
"ab\"\"cd=ef,gh",
"abcd", {
"ef",
"gh" } },
342 {
"ab=cd\"\"ef",
"ab", {
"cdef" } },
343 {
"ab=cd\",\"ef",
"ab", {
"cd,ef" } },
344 {
"ab=cd\",ef",
"ab", {
"cd,ef" } },
345 {
"ab=cd\",ef\\\nab",
"ab", {
"cd,ef\\" } },
348 {
"HKLM,A,B,'C',D",
NULL, {
"HKLM",
"A",
"B",
"'C'",
"D" } },
350 {
" a b = c , d \n",
"a b", {
"c",
"d" } },
351 {
" a b = c ,\" d\" \n",
"a b", {
"c",
" d" } },
352 {
" a b\r = c\r\n",
"a b", {
"c" } },
354 {
"a=b,,,c,,,d",
"a", {
"b",
"",
"",
"c",
"",
"",
"d" } },
355 {
"a=b,\"\",c,\" \",d",
"a", {
"b",
"",
"c",
" ",
"d" } },
356 {
"=,,b",
"", {
"",
"",
"b" } },
357 {
",=,,b",
NULL, {
"",
"=",
"",
"b" } },
358 {
"a=\n",
"a", {
"" } },
361 {
"ab=c\032d",
"ab", {
"c" } },
362 {
"ab\032=cd",
"ab", {
"ab" } },
364 {
"abcd=ef\x0gh",
"abcd", {
"ef" } },
366 {
"[Test2]\nab\n[Test]\nee=ff\n",
"ee", {
"ff" } },
369 {
"%foo%xx=%bar%yy\n" STR_SECTION,
"aaaxx", {
"bbbyy" } },
370 {
"%% %foo%=%bar%\n" STR_SECTION,
"% aaa", {
"bbb" } },
371 {
"%f\"o\"o%=ccc\n" STR_SECTION,
"aaa", {
"ccc" } },
372 {
"abc=%bar;bla%\n" STR_SECTION,
"abc", {
"%bar" } },
373 {
"loop=%loop%\n" STR_SECTION,
"loop", {
"%loop2%" } },
374 {
"%per%%cent%=100\n" STR_SECTION,
"12", {
"100" } },
379 {
"a=%big%%big%%big%%big%%big%%big%%big%%big%%big%%big%%big%\n" STR_SECTION,
"a", {
A4097 } },
384 {
"ab=\"%mydrive%\"\n" STR_SECTION,
"ab", {
"C:\\" } },
385 {
"ab=\"%24%\\fred\"\n" STR_SECTION,
"ab", {
"C:\\fred" } },
386 {
"ab=\"%mydrive%\\fred\"\n" STR_SECTION,
"ab", {
"C:\\\\fred" } },
388 {
"ab=\"%24%\\\\fred\"",
"ab", {
"C:\\\\fred" } },
389 {
"ab=C:\\\\FRED",
"ab", {
"C:\\\\FRED" } },
400 ok( !wanted,
"missing key %s\n", wanted );
406 ok(
err == 0,
"last error set to %u\n",
err );
448 ok(
err == 0,
"line %u: bad error %u\n",
i,
err );
454 "line %u: bad field %s/%s\n",
459 "line %u: bad field %s/%s\n",
464 "line %u: bad field %s/%s\n",
471 ok( 0,
"line %u: got extra field %s\n",
i,
field );
478 "line %u: bad error %u\n",
i,
err );
488 ok(
line !=
NULL,
"line %u: SetupGetLineText failed\n",
i );
496 static void test_close_inf_file(
void)
511 static const char *contents =
"[Version]\n" 512 "Signature=\"$Windows NT$\"\n" 513 "FileVersion=5.1.1.2\n" 515 "RTMQFE=\"%RTMGFE_NAME%\",SP1RTM,"A4097"\n" 517 "RTMQFE_NAME = \"RTMQFE\"\n";
519 static const CHAR getfield_resA[][20] =
526 static const WCHAR getfield_resW[][20] =
528 {
'R',
'T',
'M',
'Q',
'F',
'E',0},
529 {
'%',
'R',
'T',
'M',
'G',
'F',
'E',
'_',
'N',
'A',
'M',
'E',
'%',0},
530 {
'S',
'P',
'1',
'R',
'T',
'M',0},
533 static void test_pSetupGetField(
void)
549 win_skip(
"Using A-functions instead of W\n");
554 ok( hinf !=
NULL,
"Expected valid INF file\n" );
557 ok(
ret,
"Failed to find first line\n" );
561 for (
i = 0;
i < 3;
i++ )
565 fieldW = pSetupGetFieldW( &
context,
i );
566 ok( fieldW !=
NULL,
"Failed to get field %i\n",
i );
567 ok( !
lstrcmpW( getfield_resW[
i], fieldW ),
"Wrong string returned\n" );
571 fieldA = pSetupGetFieldA( &
context,
i );
572 ok( fieldA !=
NULL,
"Failed to get field %i\n",
i );
573 ok( !
lstrcmpA( getfield_resA[
i], fieldA ),
"Wrong string returned\n" );
579 fieldW = pSetupGetFieldW( &
context, 3 );
580 ok( fieldW !=
NULL,
"Failed to get field 3\n" );
584 "Unexpected length, got %d\n",
len );
586 fieldW = pSetupGetFieldW( &
context, 4 );
587 ok( fieldW ==
NULL,
"Expected NULL, got %p\n", fieldW );
589 "Expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError() );
593 fieldA = pSetupGetFieldA( &
context, 3 );
594 ok( fieldA !=
NULL,
"Failed to get field 3\n" );
597 "Unexpected length, got %d\n",
len );
599 fieldA = pSetupGetFieldA( &
context, 4 );
600 ok( fieldA ==
NULL,
"Expected NULL, got %p\n", fieldA );
602 "Expected ERROR_INVALID_PARAMETER, got %u\n",
GetLastError() );
608 static void test_SetupGetIntField(
void)
645 ok( hinf !=
NULL,
"Expected valid INF file\n" );
653 ok( retb,
"%u: Expected success\n",
i );
656 "%u: Expected ERROR_SUCCESS or 0xdeadbeef, got %u\n",
i,
GetLastError() );
660 ok( !retb,
"%u: Expected failure\n",
i );
664 ok( intfield == keys[
i].
value,
"%u: Expected %d, got %d\n",
i, keys[
i].
value, intfield );
670 static void test_GLE(
void)
672 static const char *inf =
674 "Signature=\"$Windows NT$\"\n" 676 "Keyname1=Field1,Field2,Field3\n" 678 "Keyname2=Field4,Field5\n";
689 ok( hinf !=
NULL,
"Expected valid INF file\n" );
693 ok(!retb,
"Expected failure\n");
695 "Expected ERROR_LINE_NOT_FOUND, got %08x\n",
GetLastError());
699 ok(!retb,
"Expected failure\n");
701 "Expected ERROR_LINE_NOT_FOUND, got %08x\n",
GetLastError());
705 ok(retb,
"Expected success\n");
711 ok(!retb,
"Expected failure\n");
713 "Expected ERROR_LINE_NOT_FOUND, got %08x\n",
GetLastError());
717 ok(retb,
"Expected success\n");
723 ok(!retb,
"Expected failure\n");
725 "Expected ERROR_LINE_NOT_FOUND, got %08x\n",
GetLastError());
729 ok(retb,
"Expected success\n");
735 ok(retl == -1,
"Expected -1, got %d\n", retl);
737 "Expected ERROR_SECTION_NOT_FOUND, got %08x\n",
GetLastError());
741 ok(retl == 2,
"Expected 2, got %d\n", retl);
747 ok(!retb,
"Expected failure\n");
749 "Expected ERROR_LINE_NOT_FOUND, got %08x\n",
GetLastError());
753 ok(!retb,
"Expected failure\n");
755 "Expected ERROR_LINE_NOT_FOUND, got %08x\n",
GetLastError());
759 ok(retb,
"Expected success\n");
765 ok(!retb,
"Expected failure\n");
767 "Expected ERROR_LINE_NOT_FOUND, got %08x\n",
GetLastError());
771 ok(retb,
"Expected success\n");
777 ok(!retb,
"Expected failure\n");
779 "Expected ERROR_LINE_NOT_FOUND, got %08x\n",
GetLastError());
788 test_section_names();
789 test_enum_sections();
791 test_close_inf_file();
792 test_pSetupGetField();
793 test_SetupGetIntField();
#define ERROR_INVALID_PARAMETER
BOOL WINAPI SetupFindNextMatchLineA(PINFCONTEXT context_in, PCSTR key, PINFCONTEXT context_out)
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
static const struct @1653 invalid_files[]
#define ERROR_SECTION_NOT_FOUND
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
char * strcat(char *DstString, const char *SrcString)
#define ERROR_NO_MORE_ITEMS
BOOL WINAPI SetupGetLineByIndexA(HINF hinf, PCSTR section, DWORD index, INFCONTEXT *context)
ACPI_SIZE strlen(const char *String)
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
GLuint GLuint GLsizei count
#define ERROR_SECTION_NAME_TOO_LONG
static void init_function_pointers(void)
#define INVALID_HANDLE_VALUE
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
DWORD WINAPI GetLastError(VOID)
GLenum GLuint GLsizei bufsize
#define ERROR_INVALID_USER_BUFFER
GLenum GLuint GLenum GLsizei const GLchar * buf
#define ERROR_EXPECTED_SECTION_NAME
BOOL WINAPI SetupFindFirstLineA(HINF hinf, PCSTR section, PCSTR key, INFCONTEXT *context)
DWORD WINAPI SetupGetFieldCount(PINFCONTEXT context)
BOOL WINAPI DeleteFileA(IN LPCSTR lpFileName)
static LPCSTR(WINAPI *pSetupGetFieldA)(PINFCONTEXT
#define ERROR_LINE_NOT_FOUND
BOOL WINAPI SetupGetLineTextA(PINFCONTEXT context, HINF hinf, PCSTR section_name, PCSTR key_name, PSTR buffer, DWORD size, PDWORD required)
static BOOL(WINAPI *pSetupEnumInfSectionsA)(HINF hinf
#define MAX_INF_STRING_LENGTH
#define todo_wine_if(is_todo)
static const char tmpfilename[]
#define ERROR_BAD_SECTION_NAME_LINE
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
_In_opt_ PVOID _In_ ULONG _In_ PVOID context
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
static const char * get_string_field(INFCONTEXT *context, DWORD index)
GLsizei const GLfloat * value
HINF WINAPI SetupOpenInfFileA(PCSTR name, PCSTR class, DWORD style, UINT *error)
#define ERROR_INVALID_DATA
int WINAPI lstrlenA(LPCSTR lpString)
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
BOOL WINAPI SetupGetStringFieldA(PINFCONTEXT context, DWORD index, PSTR buffer, DWORD size, PDWORD required)
static HINF test_file_contents(const char *data, UINT *err_line)
struct _INFCONTEXT * PINFCONTEXT
static LPCWSTR(WINAPI *pSetupGetFieldW)(PINFCONTEXT
char * strcpy(char *DstString, const char *SrcString)
#define ERROR_WRONG_INF_STYLE
static const char * get_line_text(INFCONTEXT *context)
int strcmp(const char *String1, const char *String2)
#define ERROR_CALL_NOT_IMPLEMENTED
#define GetProcAddress(x, y)
ROSDATA VSC_LPWSTR key_names[]
static void test_invalid_files(void)
#define CreateFileA(a, b, c, d, e, f, g)
static UINT PSTR DWORD size
struct contextA section_names[]
LONG WINAPI SetupGetLineCountA(HINF hinf, PCSTR name)
static UINT PSTR DWORD UINT * need
BOOL WINAPI SetupGetIntField(PINFCONTEXT context, DWORD index, PINT result)
void WINAPI SetupCloseInfFile(HINF hinf)