1 | /*--------------------------------*-C-*---------------------------------* |
1 | /*--------------------------------*-C-*---------------------------------* |
2 | * File: netdisp.c |
2 | * File: netdisp.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 1996 Chuck Blake <cblake@BBN.COM> |
6 | * Copyright (c) 1996 Chuck Blake <cblake@BBN.COM> |
7 | * - original version |
7 | * - original version |
… | |
… | |
45 | char buffer[1024], *rval = NULL; |
45 | char buffer[1024], *rval = NULL; |
46 | struct ifconf ifc; |
46 | struct ifconf ifc; |
47 | struct ifreq *ifr; |
47 | struct ifreq *ifr; |
48 | int i, skfd; |
48 | int i, skfd; |
49 | |
49 | |
50 | if (display[0] != ':' && STRNCMP (display, "unix:", 5)) |
50 | if (display[0] != ':' && strncmp (display, "unix:", 5)) |
51 | return (char *) display; /* nothing to do */ |
51 | return (char *) display; /* nothing to do */ |
52 | |
52 | |
53 | ifc.ifc_len = sizeof (buffer); /* Get names of all ifaces */ |
53 | ifc.ifc_len = sizeof (buffer); /* Get names of all ifaces */ |
54 | ifc.ifc_buf = buffer; |
54 | ifc.ifc_buf = buffer; |
55 | |
55 | |
… | |
… | |
68 | i < (ifc.ifc_len / sizeof (struct ifreq)); |
68 | i < (ifc.ifc_len / sizeof (struct ifreq)); |
69 | i++, ifr++) |
69 | i++, ifr++) |
70 | { |
70 | { |
71 | struct ifreq ifr2; |
71 | struct ifreq ifr2; |
72 | |
72 | |
73 | STRCPY (ifr2.ifr_name, ifr->ifr_name); |
73 | strcpy (ifr2.ifr_name, ifr->ifr_name); |
74 | if (ioctl (skfd, SIOCGIFADDR, &ifr2) >= 0) |
74 | if (ioctl (skfd, SIOCGIFADDR, &ifr2) >= 0) |
75 | { |
75 | { |
76 | unsigned long addr; |
76 | unsigned long addr; |
77 | struct sockaddr_in *p_addr; |
77 | struct sockaddr_in *p_addr; |
78 | |
78 | |
… | |
… | |
82 | /* |
82 | /* |
83 | * not "0.0.0.0" or "127.0.0.1" - so format the address |
83 | * not "0.0.0.0" or "127.0.0.1" - so format the address |
84 | */ |
84 | */ |
85 | if (addr && addr != 0x7F000001) |
85 | if (addr && addr != 0x7F000001) |
86 | { |
86 | { |
87 | char *colon = STRCHR (display, ':'); |
87 | char *colon = strchr (display, ':'); |
88 | |
88 | |
89 | if (colon == NULL) |
89 | if (colon == NULL) |
90 | colon = ":0.0"; |
90 | colon = ":0.0"; |
91 | |
91 | |
92 | rval = rxvt_malloc (STRLEN (colon) + 16); |
92 | rval = rxvt_malloc (strlen (colon) + 16); |
93 | sprintf (rval, "%d.%d.%d.%d%s", |
93 | sprintf (rval, "%d.%d.%d.%d%s", |
94 | (int) ((addr >> 030) & 0xFF), |
94 | (int) ((addr >> 030) & 0xFF), |
95 | (int) ((addr >> 020) & 0xFF), |
95 | (int) ((addr >> 020) & 0xFF), |
96 | (int) ((addr >> 010) & 0xFF), |
96 | (int) ((addr >> 010) & 0xFF), |
97 | (int) (addr & 0xFF), colon); |
97 | (int) (addr & 0xFF), colon); |