summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2009-07-21 20:26:53 +0200
committerMichael Stapelberg <michael@stapelberg.de>2009-07-21 20:26:53 +0200
commit230f3167b70b5d73b3d9c0c650c9a654c06ccb51 (patch)
treeffb0bd3f9abc4c5c9bd88c566ae5a08078662f17 /src
parent34ba9fa9083c655e5ba06cecd46da157eb07d980 (diff)
Add modelines and retab! all files
Diffstat (limited to 'src')
-rw-r--r--src/config.c1
-rw-r--r--src/general.c11
-rw-r--r--src/get_battery_info.c3
-rw-r--r--src/get_cpu_temperature.c5
-rw-r--r--src/get_eth_info.c1
-rw-r--r--src/get_ip_addr.c11
-rw-r--r--src/get_ipv6_addr.c93
-rw-r--r--src/get_load.c31
-rw-r--r--src/get_wireless_info.c3
-rw-r--r--src/output.c1
-rw-r--r--src/process_runs.c1
11 files changed, 86 insertions, 75 deletions
diff --git a/src/config.c b/src/config.c
index da1e5d1..99e3e07 100644
--- a/src/config.c
+++ b/src/config.c
@@ -1,3 +1,4 @@
+// vim:ts=8:expandtab
#include <sys/stat.h>
#include <stdio.h>
#include <string.h>
diff --git a/src/general.c b/src/general.c
index 4c110e4..62d242d 100644
--- a/src/general.c
+++ b/src/general.c
@@ -1,3 +1,4 @@
+// vim:ts=8:expandtab
#include <sys/types.h>
#include <string.h>
#include <stdarg.h>
@@ -13,13 +14,13 @@
*
*/
void slurp(char *filename, char *destination, int size) {
- int fd;
+ int fd;
- if ((fd = open(filename, O_RDONLY)) == -1)
- die("Could not open \"%s\"\n", filename);
+ if ((fd = open(filename, O_RDONLY)) == -1)
+ die("Could not open \"%s\"\n", filename);
- (void)read(fd, destination, size);
- (void)close(fd);
+ (void)read(fd, destination, size);
+ (void)close(fd);
}
/*
diff --git a/src/get_battery_info.c b/src/get_battery_info.c
index b81eb8e..707afde 100644
--- a/src/get_battery_info.c
+++ b/src/get_battery_info.c
@@ -1,3 +1,4 @@
+// vim:ts=8:expandtab
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
@@ -19,7 +20,7 @@ const char *get_battery_info(struct battery *bat) {
present_rate = -1;
charging_status_t status = CS_DISCHARGING;
- slurp(bat->path, buf, sizeof(buf));
+ slurp(bat->path, buf, sizeof(buf));
for (walk = buf, last = buf; (walk-buf) < 1024; walk++) {
if (*walk == '\n') {
diff --git a/src/get_cpu_temperature.c b/src/get_cpu_temperature.c
index 56a559c..d000d2d 100644
--- a/src/get_cpu_temperature.c
+++ b/src/get_cpu_temperature.c
@@ -1,3 +1,4 @@
+// vim:ts=8:expandtab
#include <stdlib.h>
#include <limits.h>
#include <stdio.h>
@@ -13,8 +14,8 @@ const char *get_cpu_temperature_info() {
static char buf[16];
long int temp;
- slurp(thermal_zone, buf, sizeof(buf));
- temp = strtol(buf, NULL, 10);
+ slurp(thermal_zone, buf, sizeof(buf));
+ temp = strtol(buf, NULL, 10);
if (temp == LONG_MIN || temp == LONG_MAX || temp <= 0)
(void)snprintf(buf, sizeof(buf), "T: ? C");
diff --git a/src/get_eth_info.c b/src/get_eth_info.c
index 7561421..5e9ab54 100644
--- a/src/get_eth_info.c
+++ b/src/get_eth_info.c
@@ -1,3 +1,4 @@
+// vim:ts=8:expandtab
#include <string.h>
#include <limits.h>
#include <stdio.h>
diff --git a/src/get_ip_addr.c b/src/get_ip_addr.c
index de03d8c..ba39a3d 100644
--- a/src/get_ip_addr.c
+++ b/src/get_ip_addr.c
@@ -1,3 +1,4 @@
+// vim:ts=8:expandtab
#include <net/if.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
@@ -32,11 +33,11 @@ const char *get_ip_addr(const char *interface) {
if (ioctl(general_socket, SIOCGIFADDR, &ifr) < 0)
return "no IP";
- int ret;
- if ((ret = getnameinfo(&ifr.ifr_addr, len, part, sizeof(part), NULL, 0, NI_NUMERICHOST)) != 0) {
- fprintf(stderr, "getnameinfo(): %s\n", gai_strerror(ret));
- return "no IP";
- }
+ int ret;
+ if ((ret = getnameinfo(&ifr.ifr_addr, len, part, sizeof(part), NULL, 0, NI_NUMERICHOST)) != 0) {
+ fprintf(stderr, "getnameinfo(): %s\n", gai_strerror(ret));
+ return "no IP";
+ }
return part;
}
diff --git a/src/get_ipv6_addr.c b/src/get_ipv6_addr.c
index 44edc7a..95a06a6 100644
--- a/src/get_ipv6_addr.c
+++ b/src/get_ipv6_addr.c
@@ -1,3 +1,4 @@
+// vim:ts=8:expandtab
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@@ -12,50 +13,50 @@
*
*/
const char *get_ipv6_addr() {
- static char buf[INET6_ADDRSTRLEN+1];
- struct addrinfo hints;
- struct addrinfo *result, *resp;
- int fd;
-
- memset(&hints, 0, sizeof(struct addrinfo));
- hints.ai_family = AF_INET6;
-
- if (getaddrinfo("k.root-servers.net", "domain", &hints, &result) != 0) {
- perror("getaddrinfo()");
- return "no IP";
- }
-
- for (resp = result; resp != NULL; resp = resp->ai_next) {
- if ((fd = socket(resp->ai_family, SOCK_STREAM, 0)) == -1) {
- perror("socket()");
- continue;
- }
-
- if (connect(fd, resp->ai_addr, resp->ai_addrlen) == -1) {
- perror("connect()");
- continue;
- }
-
- struct sockaddr_storage local;
- socklen_t local_len = sizeof(struct sockaddr_storage);
- if (getsockname(fd, (struct sockaddr*)&local, &local_len) == -1) {
- perror("getsockname()");
- return "no IP";
- }
-
- memset(buf, 0, INET6_ADDRSTRLEN + 1);
- int ret;
- if ((ret = getnameinfo((struct sockaddr*)&local, local_len, buf, sizeof(buf), NULL, 0, NI_NUMERICHOST)) != 0) {
- fprintf(stderr, "getnameinfo(): %s\n", gai_strerror(ret));
- return "no IP";
- }
-
- (void)close(fd);
-
- free(result);
- return buf;
- }
-
- free(result);
- return "no IP";
+ static char buf[INET6_ADDRSTRLEN+1];
+ struct addrinfo hints;
+ struct addrinfo *result, *resp;
+ int fd;
+
+ memset(&hints, 0, sizeof(struct addrinfo));
+ hints.ai_family = AF_INET6;
+
+ if (getaddrinfo("k.root-servers.net", "domain", &hints, &result) != 0) {
+ perror("getaddrinfo()");
+ return "no IP";
+ }
+
+ for (resp = result; resp != NULL; resp = resp->ai_next) {
+ if ((fd = socket(resp->ai_family, SOCK_STREAM, 0)) == -1) {
+ perror("socket()");
+ continue;
+ }
+
+ if (connect(fd, resp->ai_addr, resp->ai_addrlen) == -1) {
+ perror("connect()");
+ continue;
+ }
+
+ struct sockaddr_storage local;
+ socklen_t local_len = sizeof(struct sockaddr_storage);
+ if (getsockname(fd, (struct sockaddr*)&local, &local_len) == -1) {
+ perror("getsockname()");
+ return "no IP";
+ }
+
+ memset(buf, 0, INET6_ADDRSTRLEN + 1);
+ int ret;
+ if ((ret = getnameinfo((struct sockaddr*)&local, local_len, buf, sizeof(buf), NULL, 0, NI_NUMERICHOST)) != 0) {
+ fprintf(stderr, "getnameinfo(): %s\n", gai_strerror(ret));
+ return "no IP";
+ }
+
+ (void)close(fd);
+
+ free(result);
+ return buf;
+ }
+
+ free(result);
+ return "no IP";
}
diff --git a/src/get_load.c b/src/get_load.c
index 7d5349f..4f82813 100644
--- a/src/get_load.c
+++ b/src/get_load.c
@@ -1,25 +1,26 @@
+// vim:ts=8:expandtab
#include "i3status.h"
const char *get_load() {
- static char part[512];
+ static char part[512];
/* Get load */
#ifdef LINUX
- slurp("/proc/loadavg", part, sizeof(part));
- *skip_character(part, ' ', 3) = '\0';
+ slurp("/proc/loadavg", part, sizeof(part));
+ *skip_character(part, ' ', 3) = '\0';
#else
- /* TODO: correctly check for NetBSD, check if it works the same on *BSD */
- struct loadavg load;
- size_t length = sizeof(struct loadavg);
- int mib[2] = { CTL_VM, VM_LOADAVG };
- if (sysctl(mib, 2, &load, &length, NULL, 0) < 0)
- die("Could not sysctl({ CTL_VM, VM_LOADAVG })\n");
- double scale = load.fscale;
- (void)snprintf(part, sizeof(part), "%.02f %.02f %.02f",
- (double)load.ldavg[0] / scale,
- (double)load.ldavg[1] / scale,
- (double)load.ldavg[2] / scale);
+ /* TODO: correctly check for NetBSD, check if it works the same on *BSD */
+ struct loadavg load;
+ size_t length = sizeof(struct loadavg);
+ int mib[2] = { CTL_VM, VM_LOADAVG };
+ if (sysctl(mib, 2, &load, &length, NULL, 0) < 0)
+ die("Could not sysctl({ CTL_VM, VM_LOADAVG })\n");
+ double scale = load.fscale;
+ (void)snprintf(part, sizeof(part), "%.02f %.02f %.02f",
+ (double)load.ldavg[0] / scale,
+ (double)load.ldavg[1] / scale,
+ (double)load.ldavg[2] / scale);
#endif
- return part;
+ return part;
}
diff --git a/src/get_wireless_info.c b/src/get_wireless_info.c
index fd0c60b..4d8d0b2 100644
--- a/src/get_wireless_info.c
+++ b/src/get_wireless_info.c
@@ -1,3 +1,4 @@
+// vim:ts=8:expandtab
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -19,7 +20,7 @@ const char *get_wireless_info() {
memset(buf, 0, sizeof(buf));
memset(part, 0, sizeof(part));
- slurp("/proc/net/wireless", buf, sizeof(buf));
+ slurp("/proc/net/wireless", buf, sizeof(buf));
interfaces = skip_character(buf, '\n', 1) + 1;
while ((interfaces = skip_character(interfaces, '\n', 1)+1) < buf+strlen(buf)) {
diff --git a/src/output.c b/src/output.c
index 7fc24f5..901a940 100644
--- a/src/output.c
+++ b/src/output.c
@@ -1,3 +1,4 @@
+// vim:ts=8:expandtab
#include <stdbool.h>
#include <string.h>
#include <stdio.h>
diff --git a/src/process_runs.c b/src/process_runs.c
index 5e13de7..bf4e919 100644
--- a/src/process_runs.c
+++ b/src/process_runs.c
@@ -1,3 +1,4 @@
+// vim:ts=8:expandtab
#include <stdbool.h>
#include <glob.h>
#include <string.h>