From ae64a62241ce8868c5cd0420792217549e2f2145 Mon Sep 17 00:00:00 2001 From: Hans Leidekker Date: Tue, 14 Nov 2006 15:16:04 +0100 Subject: [PATCH] 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 e11ea59da0a..bda2f3aaf73 100644 --- a/dlls/setupapi/query.c +++ b/dlls/setupapi/query.c @@ -425,3 +425,94 @@ BOOL WINAPI SetupGetSourceFileLocationW( HINF hinf, PINFCONTEXT context, PCWSTR } 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 4ea80f53f90..0575339332c 100644 --- a/dlls/setupapi/setupapi.spec +++ b/dlls/setupapi/setupapi.spec @@ -417,8 +417,8 @@ @ 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 a2509241422..faf6a1f919f 100644 --- a/dlls/setupapi/stubs.c +++ b/dlls/setupapi/stubs.c @@ -140,28 +140,6 @@ BOOL WINAPI SetupCopyOEMInfW(PCWSTR sourceinffile, PCWSTR sourcemedialoc, } /*********************************************************************** - * 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 f74bd5baf00..74faf64b6c9 100644 --- a/include/setupapi.h +++ b/include/setupapi.h @@ -692,6 +692,10 @@ DECL_WINELIB_SETUPAPI_TYPE_AW(PFILEPATHS) #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 @@ BOOL WINAPI SetupGetMultiSzFieldW( PINFCONTEXT context, DWORD index, PWSTR b 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) -- 2.11.4.GIT