10 * Just parses /proc/net/wireless looking for lines beginning with
11 * wlan_interface, extracting the quality of the link and adding the
12 * current IP address of wlan_interface.
15 const char *get_wireless_info() {
17 static char part[512];
19 memset(buf, 0, sizeof(buf));
20 memset(part, 0, sizeof(part));
22 slurp("/proc/net/wireless", buf, sizeof(buf));
24 interfaces = skip_character(buf, '\n', 1) + 1;
25 while ((interfaces = skip_character(interfaces, '\n', 1)+1) < buf+strlen(buf)) {
26 while (isspace((int)*interfaces))
28 if (!BEGINS_WITH(interfaces, wlan_interface))
31 if (sscanf(interfaces, "%*[^:]: 0000 %d", &quality) != 1)
33 if ((quality == UCHAR_MAX) || (quality == 0)) {
35 (void)snprintf(part, sizeof(part), "%sW: down", color("#FF0000"));
36 else (void)snprintf(part, sizeof(part), "W: down");
37 } else (void)snprintf(part, sizeof(part), "%sW: (%03d%%) %s",
38 color("#00FF00"), quality, get_ip_addr(wlan_interface));