diff options
author | Michael Stapelberg <michael@stapelberg.de> | 2009-07-21 20:23:08 +0200 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2009-07-21 20:23:08 +0200 |
commit | 34ba9fa9083c655e5ba06cecd46da157eb07d980 (patch) | |
tree | 0e0674306ce5aab0c4bb9058c417b0b1197369fe /src | |
parent | 6fda988f360b3145d5772b6964f336dd652357ea (diff) |
Correctly handle the order of items
Diffstat (limited to 'src')
-rw-r--r-- | src/config.c | 5 | ||||
-rw-r--r-- | src/general.c | 8 | ||||
-rw-r--r-- | src/output.c | 13 |
3 files changed, 15 insertions, 11 deletions
diff --git a/src/config.c b/src/config.c index 5904512..da1e5d1 100644 --- a/src/config.c +++ b/src/config.c @@ -60,6 +60,8 @@ int load_configuration(const char *configfile) { SIMPLEQ_INSERT_TAIL(&batteries, new, batteries); } OPT("color") use_colors = true; + OPT("get_ipv6") + get_ipv6 = true; OPT("get_ethspeed") get_ethspeed = true; OPT("get_cpu_temperature") { @@ -108,7 +110,7 @@ int load_configuration(const char *configfile) { } OPT("order") { - #define SET_ORDER(opt, idx) { if (strcasecmp(token, opt) == 0) sprintf(order[idx], "%d", c++); } + #define SET_ORDER(opt, idx) { if (strcasecmp(token, opt) == 0) order[idx] = c++; } char *walk, *token; int c = 0; walk = token = dest_value; @@ -117,6 +119,7 @@ int load_configuration(const char *configfile) { walk++; *(walk++) = '\0'; SET_ORDER("run", ORDER_RUN); + SET_ORDER("ipv6", ORDER_IPV6); SET_ORDER("wlan", ORDER_WLAN); SET_ORDER("eth", ORDER_ETH); SET_ORDER("battery", ORDER_BATTERY); diff --git a/src/general.c b/src/general.c index 4016ecd..4c110e4 100644 --- a/src/general.c +++ b/src/general.c @@ -63,8 +63,8 @@ void die(const char *fmt, ...) { * Otherwise, the buffer size would have to be increased. * */ -char *concat(const char *str1, const char *str2) { - static char concatbuf[32]; - (void)snprintf(concatbuf, sizeof(concatbuf), "%s%s", str1, str2); - return concatbuf; +char *order_to_str(int number, char *name) { + static char buf[32]; + (void)snprintf(buf, sizeof(buf), "%d%s", number, name); + return buf; } diff --git a/src/output.c b/src/output.c index 379710e..7fc24f5 100644 --- a/src/output.c +++ b/src/output.c @@ -103,19 +103,20 @@ void setup(void) { /* Wait until wmii_path/rbar exists */ for (; stat(wmii_path, &statbuf) < 0; sleep(interval)); #endif +#define cf(orderidx, name) create_file(order_to_str(order[orderidx], name)); cleanup_rbar_dir(); if (wlan_interface) - create_file(concat(order[ORDER_WLAN],"wlan")); + cf(ORDER_WLAN, "wlan"); if (eth_interface) - create_file(concat(order[ORDER_ETH],"eth")); + cf(ORDER_ETH, "eth"); if (get_cpu_temperature) - create_file(concat(order[ORDER_CPU_TEMPERATURE], "cpu_temperature")); - create_file(concat(order[ORDER_LOAD],"load")); + cf(ORDER_CPU_TEMPERATURE, "cpu_temperature"); + cf(ORDER_LOAD, "load"); if (time_format) - create_file(concat(order[ORDER_TIME],"time")); + cf(ORDER_TIME, "time"); for (i = 0; i < num_run_watches; i += 2) { - snprintf(pathbuf, sizeof(pathbuf), "%s%s", order[ORDER_RUN], run_watches[i]); + snprintf(pathbuf, sizeof(pathbuf), "%d%s", order[ORDER_RUN], run_watches[i]); create_file(pathbuf); } } |