From f8fa7d16f85db817b32238cfff287ed8341af307 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Sat, 7 Oct 2006 15:02:43 +0000 Subject: [PATCH] move the string parsing routine into it's own function so it can be used with DeviceProblemWizard_RunDLL when required. svn path=/trunk/; revision=24434 --- reactos/dll/win32/devmgr/advprop.c | 111 ++++++++++++++++------------- 1 file changed, 63 insertions(+), 48 deletions(-) diff --git a/reactos/dll/win32/devmgr/advprop.c b/reactos/dll/win32/devmgr/advprop.c index 7ff9baa9ad2..12089e8d5c4 100644 --- a/reactos/dll/win32/devmgr/advprop.c +++ b/reactos/dll/win32/devmgr/advprop.c @@ -1502,6 +1502,64 @@ Cleanup: } +static BOOL +GetDeviceAndComputerName(LPWSTR lpString, + WCHAR szDeviceID[], + WCHAR szMachineName[]) +{ + BOOL ret = FALSE; + + szDeviceID[0] = L'\0'; + szMachineName[0] = L'\0'; + + while (*lpString != L'\0') + { + if (*lpString == L'/') + { + lpString++; + if(!wcsnicmp(lpString, L"DeviceID", 8)) + { + lpString += 9; + if (*lpString != L'\0') + { + int i = 0; + while ((*lpString != L' ') && + (*lpString != L'\0') && + (i <= MAX_DEVICE_ID_LEN)) + { + szDeviceID[i++] = *lpString++; + } + szDeviceID[i] = L'\0'; + ret = TRUE; + } + } + else if (!wcsnicmp(lpString, L"MachineName", 11)) + { + lpString += 12; + if (*lpString != L'\0') + { + int i = 0; + while ((*lpString != L' ') && + (*lpString != L'\0') && + (i <= MAX_COMPUTERNAME_LENGTH)) + { + szMachineName[i++] = *lpString++; + } + szMachineName[i] = L'\0'; + } + } + /* knock the pointer back one and let the next + * pointer deal with incrementing, otherwise we + * go past the end of the string */ + lpString--; + } + lpString++; + } + + return ret; +} + + /*************************************************************************** * NAME EXPORTED * DeviceAdvancedPropertiesW @@ -1908,56 +1966,13 @@ DeviceProperties_RunDLLW(HWND hWndParent, WCHAR szMachineName[MAX_COMPUTERNAME_LENGTH+1]; LPWSTR lpString = (LPWSTR)lpDeviceCmd; - szDeviceID[0] = L'\0'; - szMachineName[0] = L'\0'; - - while (*lpString != L'\0') + if (!GetDeviceAndComputerName(lpString, + szDeviceID, + szMachineName)) { - if (*lpString == L'/') - { - lpString++; - if(!wcsnicmp(lpString, L"DeviceID", 8)) - { - lpString += 9; - if (*lpString != L'\0') - { - int i = 0; - while ((*lpString != L' ') && - (*lpString != L'\0') && - (i <= MAX_DEVICE_ID_LEN)) - { - szDeviceID[i++] = *lpString++; - } - szDeviceID[i] = L'\0'; - } - } - else if (!wcsnicmp(lpString, L"MachineName", 11)) - { - lpString += 12; - if (*lpString != L'\0') - { - int i = 0; - while ((*lpString != L' ') && - (*lpString != L'\0') && - (i <= MAX_COMPUTERNAME_LENGTH)) - { - szMachineName[i++] = *lpString++; - } - szMachineName[i] = L'\0'; - } - } - /* knock the pointer back one and let the next - * pointer deal with incrementing, otherwise we - * go past the end of the string */ - lpString--; - } - lpString++; - } - - //DPRINT("DeviceID: %S, MachineName: %S\n", szDeviceID, szMachineName); - - if (szDeviceID == L'\0') + DPRINT1("DeviceProperties_RunDLLW DeviceID: %S, MachineName: %S\n", szDeviceID, szMachineName); return; + } DevicePropertiesW(hWndParent, hInst,