From b863f216b874dfcd63c3a26dae5005f89af57d19 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 25 Aug 2010 19:16:56 +0200 Subject: [PATCH] Make hddtemp_{host,port} lua settings --- src/conky.cc | 8 -------- src/hddtemp.cc | 27 ++++----------------------- src/hddtemp.h | 2 -- 3 files changed, 4 insertions(+), 33 deletions(-) diff --git a/src/conky.cc b/src/conky.cc index 098609c0..509a1822 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -2918,14 +2918,6 @@ char load_config_file(const char *f) } } #endif /* BUILD_X11 */ -#ifdef HDDTEMP - CONF("hddtemp_host") { - set_hddtemp_host(value); - } - CONF("hddtemp_port") { - set_hddtemp_port(value); - } -#endif /* HDDTEMP */ CONF("pad_percents") { pad_percents = atoi(value); } diff --git a/src/hddtemp.cc b/src/hddtemp.cc index 7238b0ce..b52be620 100644 --- a/src/hddtemp.cc +++ b/src/hddtemp.cc @@ -41,11 +41,9 @@ #include #define BUFLEN 512 -#define DEFAULT_PORT "7634" -#define DEFAULT_HOST "127.0.0.1" -static char *hddtemp_host = NULL; -static char *hddtemp_port = NULL; +static conky::simple_config_setting hddtemp_host("hddtemp_host", "localhost", false); +static conky::simple_config_setting hddtemp_port("hddtemp_port", "7634", false); struct hdd_info { hdd_info() : next(0) {} @@ -57,18 +55,6 @@ struct hdd_info { struct hdd_info hdd_info_head; -void set_hddtemp_host(const char *host) -{ - free_and_zero(hddtemp_host); - hddtemp_host = strdup(host); -} - -void set_hddtemp_port(const char *port) -{ - free_and_zero(hddtemp_port); - hddtemp_port = strdup(port); -} - static void __free_hddtemp_info(struct hdd_info *hdi) { if (hdi->next) @@ -104,20 +90,17 @@ static void add_hddtemp_info(char *dev, short temp, char unit) static char *fetch_hddtemp_output(void) { int sockfd; - const char *dst_host, *dst_port; char *buf = NULL; int buflen, offset = 0, rlen; struct addrinfo hints, *result, *rp; int i; - dst_host = hddtemp_host ? hddtemp_host : DEFAULT_HOST; - dst_port = hddtemp_port ? hddtemp_port : DEFAULT_PORT; - memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; /* XXX: hddtemp has no ipv6 support (yet?) */ hints.ai_socktype = SOCK_STREAM; - if ((i = getaddrinfo(dst_host, dst_port, &hints, &result))) { + if ((i = getaddrinfo(hddtemp_host.get(*state).c_str(), + hddtemp_port.get(*state).c_str(), &hints, &result))) { NORM_ERR("getaddrinfo(): %s", gai_strerror(i)); return NULL; } @@ -236,8 +219,6 @@ int update_hddtemp(void) { void free_hddtemp(struct text_object *obj) { free_hddtemp_info(); - free_and_zero(hddtemp_host); - free_and_zero(hddtemp_port); free_and_zero(obj->data.s); } diff --git a/src/hddtemp.h b/src/hddtemp.h index b4c1cdf5..9ca06eae 100644 --- a/src/hddtemp.h +++ b/src/hddtemp.h @@ -27,8 +27,6 @@ #ifndef HDDTEMP_H_ #define HDDTEMP_H_ -void set_hddtemp_host(const char *); -void set_hddtemp_port(const char *); int update_hddtemp(void); void free_hddtemp(struct text_object *); void print_hddtemp(struct text_object *, char *, int);