From 712caa8ab30e7935092c6203ef3c36c73aa931ac Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Mon, 16 Nov 2009 01:41:53 +0100 Subject: [PATCH] convert obsd_* to callbacks.print (completely untested) --- src/conky.c | 8 -------- src/core.c | 2 ++ src/openbsd.c | 16 ++++++++++------ src/openbsd.h | 4 ++-- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/conky.c b/src/conky.c index 8c07e507..7366281d 100644 --- a/src/conky.c +++ b/src/conky.c @@ -910,14 +910,6 @@ void generate_text_internal(char *p, int p_max_size, } } #endif -#ifdef __OpenBSD__ - OBJ(obsd_vendor) { - get_obsd_vendor(p, p_max_size); - } - OBJ(obsd_product) { - get_obsd_product(p, p_max_size); - } -#endif /* __OpenBSD__ */ #ifdef X11 OBJ(font) { new_font(p, obj->data.s); diff --git a/src/core.c b/src/core.c index 57094ab0..7b2957ac 100644 --- a/src/core.c +++ b/src/core.c @@ -367,7 +367,9 @@ struct text_object *construct_text_object(const char *s, const char *arg, long parse_obsd_sensor(obj, arg); obj->callbacks.print = &print_obsd_sensors_volt; END OBJ(obsd_vendor, 0) + obj->callbacks.print = &get_obsd_vendor; END OBJ(obsd_product, 0) + obj->callbacks.print = &get_obsd_product; #endif /* __OpenBSD__ */ END OBJ(buffers, &update_meminfo) END OBJ(cached, &update_meminfo) diff --git a/src/openbsd.c b/src/openbsd.c index 2d7dde41..f62fbe2e 100644 --- a/src/openbsd.c +++ b/src/openbsd.c @@ -547,14 +547,16 @@ void print_obsd_sensors_volt(struct text_object *obj, char *p, int p_max_size) } /* chipset vendor */ -void get_obsd_vendor(char *buf, size_t client_buffer_size) +void get_obsd_vendor(struct text_object *obj, char *buf, size_t client_buffer_size) { int mib[2]; + char vendor[64]; + size_t size = sizeof(vendor); + + (void)obj; mib[0] = CTL_HW; mib[1] = HW_VENDOR; - char vendor[64]; - size_t size = sizeof(vendor); if (sysctl(mib, 2, vendor, &size, NULL, 0) == -1) { NORM_ERR("error reading vendor"); @@ -565,14 +567,16 @@ void get_obsd_vendor(char *buf, size_t client_buffer_size) } /* chipset name */ -void get_obsd_product(char *buf, size_t client_buffer_size) +void get_obsd_product(struct text_object *obj, char *buf, size_t client_buffer_size) { int mib[2]; + char product[64]; + size_t size = sizeof(product); + + (void)obj; mib[0] = CTL_HW; mib[1] = HW_PRODUCT; - char product[64]; - size_t size = sizeof(product); if (sysctl(mib, 2, product, &size, NULL, 0) == -1) { NORM_ERR("error reading product"); diff --git a/src/openbsd.h b/src/openbsd.h index a60aeade..cd46f27d 100644 --- a/src/openbsd.h +++ b/src/openbsd.h @@ -13,8 +13,8 @@ void parse_obsd_sensor(struct text_object *, const char *); void print_obsd_sensors_temp(struct text_object *, char *, int); void print_obsd_sensors_fan(struct text_object *, char *, int); void print_obsd_sensors_volt(struct text_object *, char *, int); -void get_obsd_vendor(char *buf, size_t client_buffer_size); -void get_obsd_product(char *buf, size_t client_buffer_size); +void get_obsd_vendor(struct text_object *, char *buf, size_t client_buffer_size); +void get_obsd_product(struct text_object *, char *buf, size_t client_buffer_size); #if defined(i386) || defined(__i386__) typedef struct apm_power_info *apm_info_t;