iphlpapi: Implement ConvertGuidToString[AW]().
Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
805e30ee43
commit
8f12e295ff
|
@ -10,8 +10,8 @@
|
||||||
@ stdcall AllocateAndGetUdpTableFromStack( ptr long long long )
|
@ stdcall AllocateAndGetUdpTableFromStack( ptr long long long )
|
||||||
@ stdcall CancelIPChangeNotify( ptr )
|
@ stdcall CancelIPChangeNotify( ptr )
|
||||||
@ stdcall CancelMibChangeNotify2( ptr )
|
@ stdcall CancelMibChangeNotify2( ptr )
|
||||||
#@ stub ConvertGuidToStringA
|
@ stdcall ConvertGuidToStringA( ptr ptr long )
|
||||||
#@ stub ConvertGuidToStringW
|
@ stdcall ConvertGuidToStringW( ptr ptr long )
|
||||||
@ stdcall ConvertInterfaceAliasToLuid( ptr ptr )
|
@ stdcall ConvertInterfaceAliasToLuid( ptr ptr )
|
||||||
@ stdcall ConvertInterfaceGuidToLuid( ptr ptr )
|
@ stdcall ConvertInterfaceGuidToLuid( ptr ptr )
|
||||||
@ stdcall ConvertInterfaceIndexToLuid( long ptr )
|
@ stdcall ConvertInterfaceIndexToLuid( long ptr )
|
||||||
|
|
|
@ -73,6 +73,30 @@ WINE_DEFAULT_DEBUG_CHANNEL(iphlpapi);
|
||||||
#define INADDR_NONE ~0UL
|
#define INADDR_NONE ~0UL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define CHARS_IN_GUID 39
|
||||||
|
|
||||||
|
DWORD WINAPI ConvertGuidToStringA( const GUID *guid, char *str, DWORD len )
|
||||||
|
{
|
||||||
|
if (len < CHARS_IN_GUID) return ERROR_INSUFFICIENT_BUFFER;
|
||||||
|
sprintf( str, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
||||||
|
guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], guid->Data4[2],
|
||||||
|
guid->Data4[3], guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD WINAPI ConvertGuidToStringW( const GUID *guid, WCHAR *str, DWORD len )
|
||||||
|
{
|
||||||
|
static const WCHAR fmt[] = { '{','%','0','8','X','-','%','0','4','X','-','%','0','4','X','-',
|
||||||
|
'%','0','2','X','%','0','2','X','-','%','0','2','X','%','0','2','X',
|
||||||
|
'%','0','2','X','%','0','2','X','%','0','2','X','%','0','2','X','}',0 };
|
||||||
|
|
||||||
|
if (len < CHARS_IN_GUID) return ERROR_INSUFFICIENT_BUFFER;
|
||||||
|
sprintfW( str, fmt,
|
||||||
|
guid->Data1, guid->Data2, guid->Data3, guid->Data4[0], guid->Data4[1], guid->Data4[2],
|
||||||
|
guid->Data4[3], guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
|
||||||
|
return ERROR_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
* AddIPAddress (IPHLPAPI.@)
|
* AddIPAddress (IPHLPAPI.@)
|
||||||
*
|
*
|
||||||
|
@ -989,7 +1013,7 @@ static ULONG adapterAddressesFromIndex(ULONG family, ULONG flags, IF_INDEX index
|
||||||
}
|
}
|
||||||
|
|
||||||
total_size = sizeof(IP_ADAPTER_ADDRESSES);
|
total_size = sizeof(IP_ADAPTER_ADDRESSES);
|
||||||
total_size += 39; /* "{00000000-0000-0000-0000-000000000000}" */
|
total_size += CHARS_IN_GUID;
|
||||||
total_size += IF_NAMESIZE * sizeof(WCHAR);
|
total_size += IF_NAMESIZE * sizeof(WCHAR);
|
||||||
if (!(flags & GAA_FLAG_SKIP_FRIENDLY_NAME))
|
if (!(flags & GAA_FLAG_SKIP_FRIENDLY_NAME))
|
||||||
total_size += IF_NAMESIZE * sizeof(WCHAR);
|
total_size += IF_NAMESIZE * sizeof(WCHAR);
|
||||||
|
@ -1030,7 +1054,7 @@ static ULONG adapterAddressesFromIndex(ULONG family, ULONG flags, IF_INDEX index
|
||||||
guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5],
|
guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5],
|
||||||
guid.Data4[6], guid.Data4[7]);
|
guid.Data4[6], guid.Data4[7]);
|
||||||
aa->AdapterName = ptr;
|
aa->AdapterName = ptr;
|
||||||
ptr += 39;
|
ptr += CHARS_IN_GUID;
|
||||||
|
|
||||||
getInterfaceNameByIndex(index, name);
|
getInterfaceNameByIndex(index, name);
|
||||||
if (!(flags & GAA_FLAG_SKIP_FRIENDLY_NAME))
|
if (!(flags & GAA_FLAG_SKIP_FRIENDLY_NAME))
|
||||||
|
|
|
@ -67,6 +67,9 @@ static DWORD (WINAPI *pNotifyUnicastIpAddressChange)(ADDRESS_FAMILY, PUNICAST_IP
|
||||||
PVOID, BOOLEAN, HANDLE *);
|
PVOID, BOOLEAN, HANDLE *);
|
||||||
static DWORD (WINAPI *pCancelMibChangeNotify2)(HANDLE);
|
static DWORD (WINAPI *pCancelMibChangeNotify2)(HANDLE);
|
||||||
|
|
||||||
|
DWORD WINAPI ConvertGuidToStringA( const GUID *, char *, DWORD );
|
||||||
|
DWORD WINAPI ConvertGuidToStringW( const GUID *, WCHAR *, DWORD );
|
||||||
|
|
||||||
static void loadIPHlpApi(void)
|
static void loadIPHlpApi(void)
|
||||||
{
|
{
|
||||||
hLibrary = LoadLibraryA("iphlpapi.dll");
|
hLibrary = LoadLibraryA("iphlpapi.dll");
|
||||||
|
@ -2331,6 +2334,26 @@ static void test_NotifyUnicastIpAddressChange(void)
|
||||||
ok(!CloseHandle(handle), "CloseHandle() succeeded.\n");
|
ok(!CloseHandle(handle), "CloseHandle() succeeded.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_ConvertGuidToString( void )
|
||||||
|
{
|
||||||
|
DWORD err;
|
||||||
|
char bufA[39];
|
||||||
|
WCHAR bufW[39];
|
||||||
|
GUID guid = { 0xa, 0xb, 0xc, { 0xd, 0, 0xe, 0xf } };
|
||||||
|
|
||||||
|
err = ConvertGuidToStringA( &guid, bufA, 38 );
|
||||||
|
ok( err, "got %d\n", err );
|
||||||
|
err = ConvertGuidToStringA( &guid, bufA, 39 );
|
||||||
|
ok( !err, "got %d\n", err );
|
||||||
|
ok( !strcmp( bufA, "{0000000A-000B-000C-0D00-0E0F00000000}" ), "got %s\n", bufA );
|
||||||
|
|
||||||
|
err = ConvertGuidToStringW( &guid, bufW, 38 );
|
||||||
|
ok( err, "got %d\n", err );
|
||||||
|
err = ConvertGuidToStringW( &guid, bufW, 39 );
|
||||||
|
ok( !err, "got %d\n", err );
|
||||||
|
ok( !wcscmp( bufW, L"{0000000A-000B-000C-0D00-0E0F00000000}" ), "got %s\n", debugstr_w( bufW ) );
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(iphlpapi)
|
START_TEST(iphlpapi)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -2363,6 +2386,7 @@ START_TEST(iphlpapi)
|
||||||
test_GetUdp6Table();
|
test_GetUdp6Table();
|
||||||
test_ParseNetworkString();
|
test_ParseNetworkString();
|
||||||
test_NotifyUnicastIpAddressChange();
|
test_NotifyUnicastIpAddressChange();
|
||||||
|
test_ConvertGuidToString();
|
||||||
freeIPHlpApi();
|
freeIPHlpApi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue