summaryrefslogtreecommitdiff
path: root/src/print_load.c
diff options
context:
space:
mode:
authorMichael Stapelberg <michael@stapelberg.de>2015-03-16 10:00:32 +0100
committerMichael Stapelberg <michael@stapelberg.de>2015-03-16 10:01:07 +0100
commitd74e904bf4bdd7f1d767a8db09987b90de809579 (patch)
tree07ab4f610c2f222a662daf417f1356154806c29e /src/print_load.c
parent6996f0a4a34e0744f09dbce39a2164c6fcee875e (diff)
clang-format-3.5 -i **/*.[ch], update modeline
From here on, we’ll use clang-format to automatically format the source. This has worked well in i3, so we are introducing it for i3status.
Diffstat (limited to 'src/print_load.c')
-rw-r--r--src/print_load.c82
1 files changed, 41 insertions, 41 deletions
diff --git a/src/print_load.c b/src/print_load.c
index 6e61ae6..7ba4ae1 100644
--- a/src/print_load.c
+++ b/src/print_load.c
@@ -1,4 +1,4 @@
-// vim:ts=8:expandtab
+// vim:ts=4:sw=4:expandtab
#include "i3status.h"
#include <stdlib.h>
#include <stdio.h>
@@ -7,51 +7,51 @@
#include <yajl/yajl_version.h>
void print_load(yajl_gen json_gen, char *buffer, const char *format, const float max_threshold) {
- char *outwalk = buffer;
- /* Get load */
+ char *outwalk = buffer;
+/* Get load */
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(linux) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__APPLE__) || defined(sun) || defined(__DragonFly__)
- double loadavg[3];
- const char *walk;
- bool colorful_output = false;
-
- if (getloadavg(loadavg, 3) == -1)
- goto error;
-
- for (walk = format; *walk != '\0'; walk++) {
- if (*walk != '%') {
- *(outwalk++) = *walk;
- continue;
- }
- if (loadavg[0] >= max_threshold) {
- START_COLOR("color_bad");
- colorful_output = true;
- }
-
- if (BEGINS_WITH(walk+1, "1min")) {
- outwalk += sprintf(outwalk, "%1.2f", loadavg[0]);
- walk += strlen("1min");
- }
-
- if (BEGINS_WITH(walk+1, "5min")) {
- outwalk += sprintf(outwalk, "%1.2f", loadavg[1]);
- walk += strlen("5min");
- }
-
- if (BEGINS_WITH(walk+1, "15min")) {
- outwalk += sprintf(outwalk, "%1.2f", loadavg[2]);
- walk += strlen("15min");
- }
- if (colorful_output)
- END_COLOR;
+ double loadavg[3];
+ const char *walk;
+ bool colorful_output = false;
+
+ if (getloadavg(loadavg, 3) == -1)
+ goto error;
+
+ for (walk = format; *walk != '\0'; walk++) {
+ if (*walk != '%') {
+ *(outwalk++) = *walk;
+ continue;
+ }
+ if (loadavg[0] >= max_threshold) {
+ START_COLOR("color_bad");
+ colorful_output = true;
+ }
+
+ if (BEGINS_WITH(walk + 1, "1min")) {
+ outwalk += sprintf(outwalk, "%1.2f", loadavg[0]);
+ walk += strlen("1min");
+ }
+
+ if (BEGINS_WITH(walk + 1, "5min")) {
+ outwalk += sprintf(outwalk, "%1.2f", loadavg[1]);
+ walk += strlen("5min");
+ }
+
+ if (BEGINS_WITH(walk + 1, "15min")) {
+ outwalk += sprintf(outwalk, "%1.2f", loadavg[2]);
+ walk += strlen("15min");
}
+ if (colorful_output)
+ END_COLOR;
+ }
- *outwalk = '\0';
- OUTPUT_FULL_TEXT(buffer);
+ *outwalk = '\0';
+ OUTPUT_FULL_TEXT(buffer);
- return;
+ return;
error:
#endif
- OUTPUT_FULL_TEXT("cant read load");
- (void)fputs("i3status: Cannot read system load using getloadavg()\n", stderr);
+ OUTPUT_FULL_TEXT("cant read load");
+ (void)fputs("i3status: Cannot read system load using getloadavg()\n", stderr);
}