summaryrefslogtreecommitdiff
path: root/src/get_wireless_info.c
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2009-10-11 22:11:09 +0200
committerMichael Stapelberg <michael@stapelberg.de>2009-10-11 22:14:29 +0200
commitf947d0a446b1b99020722cbc71127fc0c06086b2 (patch)
tree87b75e70a7e2c0d162685221c66beed5f6b6a9e6 /src/get_wireless_info.c
parent1d122f32e6d2b0ae1f964dd755d769885c7bf1c2 (diff)
Breaks configfiles! Major refactoring of i3status, see below
We finally switched to libconfuse for a configuration file format which does not require much work for the programmer nor for the user. Plus, it avoids the Not-Invented-Here syndrome of yet another config file format. Furthermore, as a consequence of providing format strings for every "module" (ipv6, wireless, …), we directly print the output and thus we needed to drop support for wmii. This allowed us to get rid of quite some complexity. Documentation about the new configuration file and options will follow. This commit is the beginning of what will be i3status v2.0.
Diffstat (limited to 'src/get_wireless_info.c')
-rw-r--r--src/get_wireless_info.c64
1 files changed, 0 insertions, 64 deletions
diff --git a/src/get_wireless_info.c b/src/get_wireless_info.c
deleted file mode 100644
index 1f13764..0000000
--- a/src/get_wireless_info.c
+++ /dev/null
@@ -1,64 +0,0 @@
-// vim:ts=8:expandtab
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <limits.h>
-#include <iwlib.h>
-
-#include "i3status.h"
-
-const char *get_wireless_essid() {
- static char part[512];
-#ifdef LINUX
- int skfd;
- if ((skfd = iw_sockets_open()) < 0) {
- perror("socket");
- exit(-1);
- }
- struct wireless_config cfg;
- if (iw_get_basic_config(skfd, wlan_interface, &cfg) >= 0)
- snprintf(part, sizeof(part), "%s", cfg.essid);
- else part[0] = '\0';
- (void)close(skfd);
-#else
- part[0] = '\0';
-#endif
- return part;
-}
-
-/*
- * Just parses /proc/net/wireless looking for lines beginning with
- * wlan_interface, extracting the quality of the link and adding the
- * current IP address of wlan_interface.
- *
- */
-const char *get_wireless_info() {
- char buf[1024];
- static char part[512];
- char *interfaces;
- memset(buf, 0, sizeof(buf));
- memset(part, 0, sizeof(part));
-
- if (!slurp("/proc/net/wireless", buf, sizeof(buf)))
- die("Could not open \"/proc/net/wireless\"\n");
-
- interfaces = skip_character(buf, '\n', 1) + 1;
- while ((interfaces = skip_character(interfaces, '\n', 1)+1) < buf+strlen(buf)) {
- while (isspace((int)*interfaces))
- interfaces++;
- if (!BEGINS_WITH(interfaces, wlan_interface))
- continue;
- int quality;
- if (sscanf(interfaces, "%*[^:]: 0000 %d", &quality) != 1)
- continue;
- if ((quality == UCHAR_MAX) || (quality == 0)) {
- (void)snprintf(part, sizeof(part), "%sW: down%s", color("#FF0000"), endcolor());
- } else (void)snprintf(part, sizeof(part), "%sW: (%03d%% at %s) %s%s",
- color("#00FF00"), quality, get_wireless_essid(), get_ip_addr(wlan_interface), endcolor());
- return part;
- }
-
- return part;
-}
-