diff --git a/ChangeLog b/ChangeLog index 3ae0475..1907ecb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,11 @@ Version 1.6.13 ******************************************************************************* +2011-03-08 Iain Denniston + 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 Created the macros PRIzd and PRIzx to deal with MSVC lack of C99. diff --git a/upnp/src/api/upnpapi.c b/upnp/src/api/upnpapi.c index 52f6d20..f715fd5 100644 --- a/upnp/src/api/upnpapi.c +++ b/upnp/src/api/upnpapi.c @@ -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;