Module: wine Branch: master Commit: 05a308a80ba8acef2f25732d652a5ffd5361479b URL: http://source.winehq.org/git/wine.git/?a=commit;h=05a308a80ba8acef2f25732d65...
Author: Stefan Leichter Stefan.Leichter@camline.com Date: Mon Apr 5 19:37:58 2010 +0200
setupapi: Implement SetupGetInfFileListA.
---
dlls/setupapi/install.c | 34 ++++++++++++++++++++++ dlls/setupapi/setupapi.spec | 2 +- dlls/setupapi/tests/install.c | 62 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 1 deletions(-)
diff --git a/dlls/setupapi/install.c b/dlls/setupapi/install.c index 354f105..a71f274 100644 --- a/dlls/setupapi/install.c +++ b/dlls/setupapi/install.c @@ -1463,6 +1463,40 @@ BOOL WINAPI SetupInstallServicesFromInfSectionA( HINF Inf, PCSTR SectionName, DW
/*********************************************************************** + * SetupGetInfFileListA (SETUPAPI.@) + */ +BOOL WINAPI SetupGetInfFileListA(PCSTR dir, DWORD style, PSTR buffer, + DWORD insize, PDWORD outsize) +{ + UNICODE_STRING dirW; + PWSTR bufferW = NULL; + BOOL ret = FALSE; + DWORD outsizeA, outsizeW; + + if ( dir ) + RtlCreateUnicodeStringFromAsciiz( &dirW, dir ); + else + dirW.Buffer = NULL; + + if ( buffer ) + bufferW = HeapAlloc( GetProcessHeap(), 0, insize * sizeof( WCHAR )); + + ret = SetupGetInfFileListW( dirW.Buffer, style, bufferW, insize, &outsizeW); + + if ( ret ) + { + outsizeA = WideCharToMultiByte( CP_ACP, 0, bufferW, outsizeW, + buffer, insize, NULL, NULL); + if ( outsize ) *outsize = outsizeA; + } + + HeapFree( GetProcessHeap(), 0, bufferW ); + RtlFreeUnicodeString( &dirW ); + return ret; +} + + +/*********************************************************************** * SetupGetInfFileListW (SETUPAPI.@) */ BOOL WINAPI SetupGetInfFileListW(PCWSTR dir, DWORD style, PWSTR buffer, diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec index 5532aaa..1f77305 100644 --- a/dlls/setupapi/setupapi.spec +++ b/dlls/setupapi/setupapi.spec @@ -412,7 +412,7 @@ @ stdcall SetupGetFileCompressionInfoW(wstr ptr ptr ptr ptr) @ stdcall SetupGetFileQueueCount(long long ptr) @ stdcall SetupGetFileQueueFlags(long ptr) -@ stub SetupGetInfFileListA +@ stdcall SetupGetInfFileListA(str long ptr long ptr) @ stdcall SetupGetInfFileListW(wstr long ptr long ptr) @ stdcall SetupGetInfInformationA(ptr long ptr long ptr) @ stdcall SetupGetInfInformationW(ptr long ptr long ptr) diff --git a/dlls/setupapi/tests/install.c b/dlls/setupapi/tests/install.c index 668b2c2..f5df3df 100644 --- a/dlls/setupapi/tests/install.c +++ b/dlls/setupapi/tests/install.c @@ -53,6 +53,7 @@ static char CURR_DIR[MAX_PATH];
static void (WINAPI *pInstallHinfSectionA)(HWND, HINSTANCE, LPCSTR, INT); static void (WINAPI *pInstallHinfSectionW)(HWND, HINSTANCE, LPCWSTR, INT); +static BOOL (WINAPI *pSetupGetInfFileListA)(PCSTR, DWORD, PSTR, DWORD, PDWORD); static BOOL (WINAPI *pSetupGetInfFileListW)(PCWSTR, DWORD, PWSTR, DWORD, PDWORD);
/* @@ -468,6 +469,65 @@ cleanup: DeleteFile(inffile); }
+static void test_inffilelistA(void) +{ + static const char inffile2[] = "test2.inf"; + static const char *inf = + "[Version]\n" + "Signature="$Chicago$""; + + char buffer[MAX_PATH] = { 0 }; + char dir[MAX_PATH], *p; + DWORD expected, outsize; + BOOL ret; + + if(!pSetupGetInfFileListA) + { + win_skip("SetupGetInfFileListA not present\n"); + return; + } + + /* create a private directory, the temp directory may contain some + * inf files left over from old installations + */ + if (!GetTempFileNameA(CURR_DIR, "inftest", 1, dir)) + { + win_skip("GetTempFileNameA failed with error %d\n", GetLastError()); + return; + } + if (!CreateDirectoryA(dir, NULL )) + { + win_skip("CreateDirectoryA(%s) failed with error %d\n", dir, GetLastError()); + return; + } + if (!SetCurrentDirectoryA(dir)) + { + win_skip("SetCurrentDirectoryA failed with error %d\n", GetLastError()); + RemoveDirectoryA(dir); + return; + } + + create_inf_file(inffile, inf); + create_inf_file(inffile2, inf); + + /* mixed style + */ + expected = 3 + strlen(inffile) + strlen(inffile2); + ret = pSetupGetInfFileListA(dir, INF_STYLE_OLDNT | INF_STYLE_WIN4, buffer, + MAX_PATH, &outsize); + ok(ret, "expected SetupGetInfFileListA to succeed!\n"); + ok(expected == outsize, "expected required buffersize to be %d, got %d\n", + expected, outsize); + for(p = buffer; lstrlenA(p) && (outsize > (p - buffer)); p+=lstrlenA(p) + 1) + ok(!lstrcmpA(p,inffile2) || !lstrcmpA(p,inffile), + "unexpected filename %s\n",p); + + DeleteFile(inffile); + DeleteFile(inffile2); + SetCurrentDirectoryA(CURR_DIR); + RemoveDirectoryA(dir); +} + static void test_inffilelist(void) { static const char inffile2[] = "test2.inf"; @@ -656,6 +716,7 @@ START_TEST(install)
pInstallHinfSectionA = (void *)GetProcAddress(hsetupapi, "InstallHinfSectionA"); pInstallHinfSectionW = (void *)GetProcAddress(hsetupapi, "InstallHinfSectionW"); + pSetupGetInfFileListA = (void *)GetProcAddress(hsetupapi, "SetupGetInfFileListA"); pSetupGetInfFileListW = (void *)GetProcAddress(hsetupapi, "SetupGetInfFileListW");
if (pInstallHinfSectionA) @@ -695,6 +756,7 @@ START_TEST(install) }
test_inffilelist(); + test_inffilelistA();
SetCurrentDirectory(prev_path); }