--- rxvt-unicode/src/netdisp.C 2004/04/08 20:31:45 1.7 +++ rxvt-unicode/src/netdisp.C 2005/12/22 15:28:15 1.9 @@ -47,7 +47,7 @@ struct ifreq *ifr; int i, skfd; - if (display[0] != ':' && STRNCMP (display, "unix:", 5)) + if (display[0] != ':' && strncmp (display, "unix:", 5)) return (char *) display; /* nothing to do */ ifc.ifc_len = sizeof (buffer); /* Get names of all ifaces */ @@ -58,25 +58,28 @@ perror ("socket"); return NULL; } + if (ioctl (skfd, SIOCGIFCONF, &ifc) < 0) { perror ("SIOCGIFCONF"); close (skfd); return NULL; } + for (i = 0, ifr = ifc.ifc_req; i < (ifc.ifc_len / sizeof (struct ifreq)); i++, ifr++) { - struct ifreq ifr2; + struct ifreq ifr2; + + strcpy (ifr2.ifr_name, ifr->ifr_name); - STRCPY (ifr2.ifr_name, ifr->ifr_name); if (ioctl (skfd, SIOCGIFADDR, &ifr2) >= 0) { - unsigned long addr; + unsigned long addr; struct sockaddr_in *p_addr; - p_addr = (struct sockaddr_in *)& (ifr2.ifr_addr); + p_addr = (struct sockaddr_in *) &ifr2.ifr_addr; addr = htonl ((unsigned long)p_addr->sin_addr.s_addr); /* @@ -84,12 +87,12 @@ */ if (addr && addr != 0x7F000001) { - char *colon = STRCHR (display, ':'); + char *colon = strchr (display, ':'); if (colon == NULL) colon = ":0.0"; - rval = rxvt_malloc (STRLEN (colon) + 16); + rval = rxvt_malloc (strlen (colon) + 16); sprintf (rval, "%d.%d.%d.%d%s", (int) ((addr >> 030) & 0xFF), (int) ((addr >> 020) & 0xFF), @@ -101,6 +104,7 @@ } close (skfd); + return rval; } #endif /* DISPLAY_IS_IP */