From 230f3167b70b5d73b3d9c0c650c9a654c06ccb51 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Tue, 21 Jul 2009 20:26:53 +0200 Subject: [PATCH] Add modelines and retab! all files --- src/config.c | 1 + src/general.c | 11 ++--- src/get_battery_info.c | 3 +- src/get_cpu_temperature.c | 5 ++- src/get_eth_info.c | 1 + src/get_ip_addr.c | 11 ++--- src/get_ipv6_addr.c | 93 ++++++++++++++++++++------------------- src/get_load.c | 31 ++++++------- src/get_wireless_info.c | 3 +- src/output.c | 1 + src/process_runs.c | 1 + 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 #include #include 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 #include #include @@ -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 #include #include @@ -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 #include #include @@ -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 #include #include 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 #include #include @@ -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 #include #include @@ -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 #include #include @@ -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 #include #include 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 #include #include -- 2.39.5