1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-28 04:55:08 +00:00

convert iconv objects to callbacks

This commit is contained in:
Phil Sutter 2009-11-29 14:24:14 +01:00
parent b8e600b9a4
commit 938af98ff3
4 changed files with 19 additions and 20 deletions

View File

@ -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

View File

@ -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:

View File

@ -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;
}

View File

@ -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 */