Partial fix for UpnpGetIfInfo with MSVC

This commit is contained in:
Iain Denniston 2011-03-11 18:10:51 +00:00 committed by Marcelo Roberto Jimenez
parent 3a9ae348bc
commit 7338411c08
2 changed files with 36 additions and 0 deletions

View File

@ -2,6 +2,11 @@
Version 1.6.13
*******************************************************************************
2011-03-08 Iain Denniston <iain.denniston(at)gmail.com>
Partial fix for UpnpGetIfInfo with MSVC - convert wchar string to
char string (full fix requires a lot of work - potentially impacting
all supported platforms)
2011-03-11 Marcelo Roberto Jimenez <mroberto(at)users.sourceforge.net>
Created the macros PRIzd and PRIzx to deal with MSVC lack of C99.

View File

@ -3016,16 +3016,47 @@ int UpnpGetIfInfo(const char *IfName)
}
if (ifname_found == 0) {
/* We have found a valid interface name. Keep it. */
#ifdef UPNP_USE_MSVCPP
/*
* Partial fix for VC - friendly name is wchar string,
* but currently gIF_NAME is char string. For now try
* to convert it, which will work with many (but not
* all) adapters. A full fix would require a lot of
* big changes (gIF_NAME to wchar string?).
*/
wcstombs(gIF_NAME, adapts_item->FriendlyName,
sizeof(gIF_NAME));
#else
strncpy(gIF_NAME, adapts_item->FriendlyName,
sizeof(gIF_NAME));
#endif
ifname_found = 1;
} else {
#ifdef UPNP_USE_MSVCPP
/*
* Partial fix for VC - friendly name is wchar string,
* but currently gIF_NAME is char string. For now try
* to convert it, which will work with many (but not
* all) adapters. A full fix would require a lot of
* big changes (gIF_NAME to wchar string?).
*/
char tmpIfName[LINE_SIZE] = { 0 };
wcstombs(tmpIfName, adapts_item->FriendlyName,
sizeof(tmpIfName));
if (strncmp
(gIF_NAME, tmpIfName,
sizeof(gIF_NAME)) != 0) {
/* This is not the interface we're looking for. */
continue;
}
#else
if (strncmp
(gIF_NAME, adapts_item->FriendlyName,
sizeof(gIF_NAME)) != 0) {
/* This is not the interface we're looking for. */
continue;
}
#endif
}
/* Loop thru this adapter's unicast IP addresses. */
uni_addr = adapts_item->FirstUnicastAddress;