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