diff --git a/src/conky.c b/src/conky.c index c8198263..acca372e 100644 --- a/src/conky.c +++ b/src/conky.c @@ -1842,11 +1842,7 @@ static void generate_text_internal(char *p, int p_max_size, #endif #ifdef RSS OBJ(rss) { - if (obj->data.rss.uri != NULL) { - rss_process_info(p, p_max_size, obj->data.rss.uri, obj->data.rss.action, obj->data.rss.act_par, obj->data.rss.interval, obj->data.rss.nrspaces); - } else { - NORM_ERR("error processing RSS data"); - } + rss_print_info(obj, p, p_max_size); } #endif #ifdef WEATHER diff --git a/src/core.c b/src/core.c index cf5396f6..e1281b93 100644 --- a/src/core.c +++ b/src/core.c @@ -1463,23 +1463,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long #endif #ifdef RSS END OBJ_ARG(rss, 0, "rss needs arguments: [act_par] [spaces in front]") - float interval = 0; - int argc, act_par = 0; - unsigned int nrspaces = 0; - char *uri = (char *) malloc(128 * sizeof(char)); - char *action = (char *) malloc(64 * sizeof(char)); - - argc = sscanf(arg, "%127s %f %63s %d %u", uri, &interval, action, - &act_par, &nrspaces); - if (argc >= 3) { - obj->data.rss.uri = uri; - obj->data.rss.interval = interval > 0 ? interval * 60 : 15*60; - obj->data.rss.action = action; - obj->data.rss.act_par = act_par; - obj->data.rss.nrspaces = nrspaces; - } else { - NORM_ERR("wrong number of arguments for $rss"); - } + rss_scan_arg(obj, arg); #endif #ifdef WEATHER END OBJ_ARG(weather, 0, "weather needs arguments: [interval in minutes]") diff --git a/src/rss.c b/src/rss.c index 36408dfc..129823bd 100644 --- a/src/rss.c +++ b/src/rss.c @@ -27,6 +27,7 @@ #include "conky.h" #include "logging.h" #include "prss.h" +#include "text_object.h" #include "ccurl_thread.h" #include #include @@ -44,7 +45,7 @@ void rss_free_info(void) ccurl_free_locations(&locations_head); } -void rss_process_info(char *p, int p_max_size, char *uri, char *action, int +static void rss_process_info(char *p, int p_max_size, char *uri, char *action, int act_par, int interval, unsigned int nrspaces) { PRSS *data; @@ -147,3 +148,33 @@ void rss_process_info(char *p, int p_max_size, char *uri, char *action, int timed_thread_unlock(curloc->p_timed_thread); } +void rss_scan_arg(struct text_object *obj, const char *arg) +{ + float interval = 0; + int argc, act_par = 0; + unsigned int nrspaces = 0; + char *uri = (char *) malloc(128 * sizeof(char)); + char *action = (char *) malloc(64 * sizeof(char)); + + argc = sscanf(arg, "%127s %f %63s %d %u", uri, &interval, action, + &act_par, &nrspaces); + if (argc < 3) { + NORM_ERR("wrong number of arguments for $rss"); + return; + } + obj->data.rss.uri = uri; + obj->data.rss.interval = interval > 0 ? interval * 60 : 15*60; + obj->data.rss.action = action; + obj->data.rss.act_par = act_par; + obj->data.rss.nrspaces = nrspaces; +} + +void rss_print_info(struct text_object *obj, char *p, int p_max_size) +{ + if (!obj->data.rss.uri) { + NORM_ERR("error processing RSS data"); + return; + } + rss_process_info(p, p_max_size, obj->data.rss.uri, obj->data.rss.action, + obj->data.rss.act_par, obj->data.rss.interval, obj->data.rss.nrspaces); +} diff --git a/src/rss.h b/src/rss.h index 3e10d810..279246f8 100644 --- a/src/rss.h +++ b/src/rss.h @@ -5,8 +5,8 @@ #include "prss.h" +void rss_scan_arg(struct text_object *, const char *); +void rss_print_info(struct text_object *, char *, int); void rss_free_info(void); -void rss_process_info(char *p, int p_max_size, char *uri, char *action, int - act_par, int interval, unsigned int nrspaces); #endif /*RSS_H_*/