# HG changeset patch # User Mark Doliner # Date 1141105842 0 # Node ID d7b6e358493dd4672900ca723fba4f9f0148650b # Parent 1c2f284986b70e57a2080856b4b43a45750d2f7a [gaim-migrate @ 15715] Change spaces to tabs, and 0 is a valid file descriptor, although I think it is almost always set to one of stdout, stderr or stdin. In Linux, anyway. committer: Tailor Script diff -r 1c2f284986b7 -r d7b6e358493d src/network.c --- a/src/network.c Tue Feb 28 02:00:15 2006 +0000 +++ b/src/network.c Tue Feb 28 05:50:42 2006 +0000 @@ -92,46 +92,50 @@ const char * gaim_network_get_local_system_ip(int fd) { - char buffer[1024]; - static char ip[16]; - char *tmp; - struct ifconf ifc; - struct ifreq *ifr; - struct sockaddr_in *sinptr; - guint32 lhost = htonl(127*256*256*256+1); - long unsigned int add; - int source = fd; + char buffer[1024]; + static char ip[16]; + char *tmp; + struct ifconf ifc; + struct ifreq *ifr; + struct sockaddr_in *sinptr; + guint32 lhost = htonl(127 * 256 * 256 * 256 + 1); + long unsigned int add; + int source = fd; - if(source <= 0) - source = socket(PF_INET,SOCK_STREAM,0); + if (fd < 0) + source = socket(PF_INET,SOCK_STREAM, 0); - ifc.ifc_len = sizeof(buffer); - ifc.ifc_req = (struct ifreq*) buffer; - ioctl(source, SIOCGIFCONF, &ifc); + ifc.ifc_len = sizeof(buffer); + ifc.ifc_req = (struct ifreq *)buffer; + ioctl(source, SIOCGIFCONF, &ifc); - if(fd <= 0) - close(source); + if (fd < 0) + close(source); - tmp = buffer; - while(tmp < buffer + ifc.ifc_len) { - ifr = (struct ifreq *) tmp; - tmp += sizeof(struct ifreq); + tmp = buffer; + while (tmp < buffer + ifc.ifc_len) + { + ifr = (struct ifreq *)tmp; + tmp += sizeof(struct ifreq); - if(ifr->ifr_addr.sa_family == AF_INET) { - sinptr = (struct sockaddr_in *) &ifr->ifr_addr; - if(sinptr->sin_addr.s_addr != lhost) { - add = ntohl(sinptr->sin_addr.s_addr); - g_snprintf(ip, 16, "%lu.%lu.%lu.%lu", - ((add >> 24) & 255), - ((add >> 16) & 255), - ((add >> 8) & 255), - add & 255); + if (ifr->ifr_addr.sa_family == AF_INET) + { + sinptr = (struct sockaddr_in *)&ifr->ifr_addr; + if (sinptr->sin_addr.s_addr != lhost) + { + add = ntohl(sinptr->sin_addr.s_addr); + g_snprintf(ip, 16, "%lu.%lu.%lu.%lu", + ((add >> 24) & 255), + ((add >> 16) & 255), + ((add >> 8) & 255), + add & 255); - return ip; - } - } - } - return "0.0.0.0"; + return ip; + } + } + } + + return "0.0.0.0"; } const char *