if2ip.[ch]: fix compilation with MinGW

Avoid 'interface' literal that some MinGW versions define as a macro
This commit is contained in:
Yang Tse 2011-12-13 18:37:33 +01:00
parent de6f4f356e
commit 4c4e8ba1f0
2 changed files with 14 additions and 14 deletions

View File

@ -71,7 +71,7 @@
#if defined(HAVE_GETIFADDRS) #if defined(HAVE_GETIFADDRS)
bool Curl_if_is_interface_name(const char *interface) bool Curl_if_is_interface_name(const char *interf)
{ {
bool result = FALSE; bool result = FALSE;
@ -79,7 +79,7 @@ bool Curl_if_is_interface_name(const char *interface)
if(getifaddrs(&head) >= 0) { if(getifaddrs(&head) >= 0) {
for(iface=head; iface != NULL; iface=iface->ifa_next) { for(iface=head; iface != NULL; iface=iface->ifa_next) {
if(curl_strequal(iface->ifa_name, interface)) { if(curl_strequal(iface->ifa_name, interf)) {
result = TRUE; result = TRUE;
break; break;
} }
@ -89,7 +89,7 @@ bool Curl_if_is_interface_name(const char *interface)
return result; return result;
} }
char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size)
{ {
struct ifaddrs *iface, *head; struct ifaddrs *iface, *head;
char *ip = NULL; char *ip = NULL;
@ -98,7 +98,7 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size)
for(iface=head; iface != NULL; iface=iface->ifa_next) { for(iface=head; iface != NULL; iface=iface->ifa_next) {
if((iface->ifa_addr != NULL) && if((iface->ifa_addr != NULL) &&
(iface->ifa_addr->sa_family == af) && (iface->ifa_addr->sa_family == af) &&
curl_strequal(iface->ifa_name, interface)) { curl_strequal(iface->ifa_name, interf)) {
void *addr; void *addr;
char scope[12]=""; char scope[12]="";
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
@ -127,17 +127,17 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size)
#elif defined(HAVE_IOCTL_SIOCGIFADDR) #elif defined(HAVE_IOCTL_SIOCGIFADDR)
bool Curl_if_is_interface_name(const char *interface) bool Curl_if_is_interface_name(const char *interf)
{ {
/* This is here just to support the old interfaces */ /* This is here just to support the old interfaces */
char buf[256]; char buf[256];
char *ip = Curl_if2ip(AF_INET, interface, buf, sizeof(buf)); char *ip = Curl_if2ip(AF_INET, interf, buf, sizeof(buf));
return (ip != NULL) ? TRUE : FALSE; return (ip != NULL) ? TRUE : FALSE;
} }
char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size) char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size)
{ {
struct ifreq req; struct ifreq req;
struct in_addr in; struct in_addr in;
@ -146,10 +146,10 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size)
size_t len; size_t len;
char *ip; char *ip;
if(!interface || (af != AF_INET)) if(!interf || (af != AF_INET))
return NULL; return NULL;
len = strlen(interface); len = strlen(interf);
if(len >= sizeof(req.ifr_name)) if(len >= sizeof(req.ifr_name))
return NULL; return NULL;
@ -158,7 +158,7 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size)
return NULL; return NULL;
memset(&req, 0, sizeof(req)); memset(&req, 0, sizeof(req));
memcpy(req.ifr_name, interface, len+1); memcpy(req.ifr_name, interf, len+1);
req.ifr_addr.sa_family = AF_INET; req.ifr_addr.sa_family = AF_INET;
if(ioctl(dummy, SIOCGIFADDR, &req) < 0) { if(ioctl(dummy, SIOCGIFADDR, &req) < 0) {
@ -176,9 +176,9 @@ char *Curl_if2ip(int af, const char *interface, char *buf, int buf_size)
#else #else
bool Curl_if_is_interface_name(const char *interface) bool Curl_if_is_interface_name(const char *interf)
{ {
(void) interface; (void) interf;
return FALSE; return FALSE;
} }

View File

@ -23,8 +23,8 @@
***************************************************************************/ ***************************************************************************/
#include "setup.h" #include "setup.h"
extern bool Curl_if_is_interface_name(const char *interface); bool Curl_if_is_interface_name(const char *interf);
extern char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size); char *Curl_if2ip(int af, const char *interf, char *buf, int buf_size);
#ifdef __INTERIX #ifdef __INTERIX
#include <sys/socket.h> #include <sys/socket.h>