diff --git a/src/conky.c b/src/conky.c index 6b800785..4bcbdb58 100644 --- a/src/conky.c +++ b/src/conky.c @@ -1101,15 +1101,6 @@ void generate_text_internal(char *p, int p_max_size, } } -#ifdef HAVE_ICONV - OBJ(iconv_start) { - do_iconv_start(obj); - } - OBJ(iconv_stop) { - do_iconv_stop(); - } -#endif /* HAVE_ICONV */ - break; } #undef DO_JUMP diff --git a/src/core.c b/src/core.c index fb472a36..fa775fbb 100644 --- a/src/core.c +++ b/src/core.c @@ -1042,8 +1042,11 @@ struct text_object *construct_text_object(const char *s, const char *arg, long #ifdef HAVE_ICONV END OBJ_ARG(iconv_start, 0, "Iconv requires arguments") init_iconv_start(obj, free_at_crash, arg); + obj->callbacks.print = &print_iconv_start; + obj->callbacks.free = &free_iconv; END OBJ(iconv_stop, 0) init_iconv_stop(); + obj->callbacks.print = &print_iconv_stop; #endif END OBJ(totaldown, &update_net_stats) parse_net_stat_arg(obj, arg, free_at_crash); @@ -1832,11 +1835,6 @@ void free_text_objects(struct text_object *root, int internal) case OBJ_text: free(data.s); break; -#ifdef HAVE_ICONV - case OBJ_iconv_start: - free_iconv(); - break; -#endif #ifdef __linux__ case OBJ_if_gw: case OBJ_gw_iface: diff --git a/src/iconv_tools.c b/src/iconv_tools.c index bf4a2463..54a24b6d 100644 --- a/src/iconv_tools.c +++ b/src/iconv_tools.c @@ -58,10 +58,12 @@ int register_iconv(iconv_t *new_iconv) return iconv_count; } -void free_iconv(void) +void free_iconv(struct text_object *obj) { long i; + (void)obj; + if (!iconv_cd) return; @@ -139,14 +141,21 @@ void init_iconv_stop(void) iconv_converting = 0; } -void do_iconv_start(struct text_object *obj) +void print_iconv_start(struct text_object *obj, char *p, int p_max_size) { + (void)p; + (void)p_max_size; + iconv_converting = 1; iconv_selected = obj->data.i; } -void do_iconv_stop(void) +void print_iconv_stop(struct text_object *obj, char *p, int p_max_size) { + (void)obj; + (void)p; + (void)p_max_size; + iconv_converting = 0; iconv_selected = 0; } diff --git a/src/iconv_tools.h b/src/iconv_tools.h index 73a1467d..41154d75 100644 --- a/src/iconv_tools.h +++ b/src/iconv_tools.h @@ -31,11 +31,12 @@ #ifndef _ICONV_TOOLS_H #define _ICONV_TOOLS_H -void free_iconv(void); +void free_iconv(struct text_object *); void iconv_convert(size_t *, char *, char *, size_t); void init_iconv_start(struct text_object *, void *, const char *); void init_iconv_stop(void); -void do_iconv_start(struct text_object *); -void do_iconv_stop(void); + +void print_iconv_start(struct text_object *, char *, int); +void print_iconv_stop(struct text_object *, char *, int); #endif /* _ICONV_TOOLS_H */