Module: wine Branch: master Commit: ae64a62241ce8868c5cd0420792217549e2f2145 URL: http://source.winehq.org/git/wine.git/?a=commit;h=ae64a62241ce8868c5cd042079...
Author: Hans Leidekker hans@it.vu.nl Date: Tue Nov 14 15:16:04 2006 +0100
setupapi: Implement SetupGetSourceInfo{A,W}.
---
dlls/setupapi/query.c | 91 +++++++++++++++++++++++++++++++++++++++++++ dlls/setupapi/setupapi.spec | 4 +- dlls/setupapi/stubs.c | 22 ---------- include/setupapi.h | 7 +++ 4 files changed, 100 insertions(+), 24 deletions(-)
diff --git a/dlls/setupapi/query.c b/dlls/setupapi/query.c index e11ea59..bda2f3a 100644 --- a/dlls/setupapi/query.c +++ b/dlls/setupapi/query.c @@ -425,3 +425,94 @@ BOOL WINAPI SetupGetSourceFileLocationW( } return TRUE; } + +/*********************************************************************** + * SetupGetSourceInfoA (SETUPAPI.@) + */ + +BOOL WINAPI SetupGetSourceInfoA( HINF hinf, UINT source_id, UINT info, + PSTR buffer, DWORD buffer_size, LPDWORD required_size ) +{ + BOOL ret = FALSE; + WCHAR *bufferW = NULL; + DWORD required; + INT size; + + TRACE("%p, %d, %d, %p, %d, %p\n", hinf, source_id, info, buffer, buffer_size, + required_size); + + if (!SetupGetSourceInfoW( hinf, source_id, info, NULL, 0, &required )) + return FALSE; + + if (!(bufferW = HeapAlloc( GetProcessHeap(), 0, required * sizeof(WCHAR) ))) + return FALSE; + + if (!SetupGetSourceInfoW( hinf, source_id, info, bufferW, required, NULL )) + goto done; + + size = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL ); + if (required_size) *required_size = size; + + if (buffer) + { + if (buffer_size >= size) + WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, buffer_size, NULL, NULL ); + else + { + SetLastError( ERROR_INSUFFICIENT_BUFFER ); + goto done; + } + } + ret = TRUE; + + done: + HeapFree( GetProcessHeap(), 0, bufferW ); + return ret; +} + +/*********************************************************************** + * SetupGetSourceInfoW (SETUPAPI.@) + */ + +BOOL WINAPI SetupGetSourceInfoW( HINF hinf, UINT source_id, UINT info, + PWSTR buffer, DWORD buffer_size, LPDWORD required_size ) +{ + INFCONTEXT ctx; + WCHAR source_id_str[11]; + static const WCHAR fmt[] = {'%','d',0}; + DWORD index; + + TRACE("%p, %d, %d, %p, %d, %p\n", hinf, source_id, info, buffer, buffer_size, + required_size); + + sprintfW( source_id_str, fmt, source_id ); + + if (!SetupFindFirstLineW( hinf, source_disks_names_platform, source_id_str, &ctx ) && + !SetupFindFirstLineW( hinf, source_disks_names, source_id_str, &ctx )) + return FALSE; + + switch (info) + { + case SRCINFO_PATH: index = 4; break; + case SRCINFO_TAGFILE: index = 2; break; + case SRCINFO_DESCRIPTION: index = 1; break; + default: + WARN("unknown info level: %d\n", info); + return FALSE; + } + + if (SetupGetStringFieldW( &ctx, index, buffer, buffer_size, required_size )) + return TRUE; + + if (required_size) *required_size = 1; + if (buffer) + { + if (buffer_size >= 1) buffer[0] = 0; + else + { + SetLastError( ERROR_INSUFFICIENT_BUFFER ); + return FALSE; + } + } + return TRUE; +} diff --git a/dlls/setupapi/setupapi.spec b/dlls/setupapi/setupapi.spec index 4ea80f5..0575339 100644 --- a/dlls/setupapi/setupapi.spec +++ b/dlls/setupapi/setupapi.spec @@ -417,8 +417,8 @@ # Yes, Microsoft really misspelled this @ stdcall SetupGetSourceFileLocationW(ptr ptr wstr ptr ptr long ptr) @ stub SetupGetSourceFileSizeA @ stub SetupGetSourceFileSizeW -@ stdcall SetupGetSourceInfoA(ptr long long str long ptr) -@ stdcall SetupGetSourceInfoW(ptr long long wstr long ptr) +@ stdcall SetupGetSourceInfoA(ptr long long ptr long ptr) +@ stdcall SetupGetSourceInfoW(ptr long long ptr long ptr) @ stdcall SetupGetStringFieldA(ptr long ptr long ptr) @ stdcall SetupGetStringFieldW(ptr long ptr long ptr) @ stub SetupGetTargetPathA diff --git a/dlls/setupapi/stubs.c b/dlls/setupapi/stubs.c index a250924..faf6a1f 100644 --- a/dlls/setupapi/stubs.c +++ b/dlls/setupapi/stubs.c @@ -140,28 +140,6 @@ BOOL WINAPI SetupCopyOEMInfW(PCWSTR sour }
/*********************************************************************** - * SetupGetSourceInfoA (SETUPAPI.@) - */ -BOOL WINAPI SetupGetSourceInfoA(HINF InfHandle, UINT SourceId, UINT InfoDesired, - PSTR ReturnBuffer, DWORD ReturnBufferSize, LPDWORD RequiredSize) -{ - FIXME("(%p, %d, %d, %p, %d, %p): stub\n", InfHandle, SourceId, InfoDesired, - ReturnBuffer, ReturnBufferSize, RequiredSize); - return FALSE; -} - -/*********************************************************************** - * SetupGetSourceInfoW (SETUPAPI.@) - */ -BOOL WINAPI SetupGetSourceInfoW(HINF InfHandle, UINT SourceId, UINT InfoDesired, - PWSTR ReturnBuffer, DWORD ReturnBufferSize, LPDWORD RequiredSize) -{ - FIXME("(%p, %d, %d, %p, %d, %p): stub\n", InfHandle, SourceId, InfoDesired, - ReturnBuffer, ReturnBufferSize, RequiredSize); - return FALSE; -} - -/*********************************************************************** * SetupInitializeFileLogW(SETUPAPI.@) */ HANDLE WINAPI SetupInitializeFileLogW(LPWSTR LogFileName, DWORD Flags) diff --git a/include/setupapi.h b/include/setupapi.h index f74bd5b..74faf64 100644 --- a/include/setupapi.h +++ b/include/setupapi.h @@ -692,6 +692,10 @@ #define LogSevError 0x00000002 #define LogSevFatalError 0x00000003 #define LogSevMaximum 0x00000004
+#define SRCINFO_PATH 1 +#define SRCINFO_TAGFILE 2 +#define SRCINFO_DESCRIPTION 3 + LONG WINAPI AddTagToGroupOrderList(PCWSTR lpGroupName, DWORD dwUnknown2, DWORD dwUnknown3); DWORD WINAPI CaptureAndConvertAnsiArg(PCSTR lpSrc, PWSTR *lpDst); DWORD WINAPI CaptureStringArg(PCWSTR lpSrc, PWSTR *lpDst); @@ -817,6 +821,9 @@ #define SetupGetMultiSzField WIN BOOL WINAPI SetupGetSourceFileLocationA( HINF hinf, PINFCONTEXT context, PCSTR filename, PUINT source_id, PSTR buffer, DWORD buffer_size, PDWORD required_size ); BOOL WINAPI SetupGetSourceFileLocationW( HINF hinf, PINFCONTEXT context, PCWSTR filename, PUINT source_id, PWSTR buffer, DWORD buffer_size, PDWORD required_size ); #define SetupGetSourceFileLocation WINELIB_NAME_AW(SetupGetSourceFileLocation) +BOOL WINAPI SetupGetSourceInfoA( HINF hinf, UINT source_id, UINT info, PSTR buffer, DWORD buffer_size, LPDWORD required_size ); +BOOL WINAPI SetupGetSourceInfoW( HINF hinf, UINT source_id, UINT info, PWSTR buffer, DWORD buffer_size, LPDWORD required_size ); +#define SetupGetSourceInfo WINELIB_NAME_AW(SetupGetSourceInfo) 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 ); #define SetupGetStringField WINELIB_NAME_AW(SetupGetStringField)