drop adt746x objects
[monky] / src / core.c
index 17fc126..ce75e90 100644 (file)
@@ -1,4 +1,5 @@
 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
+ * vim: ts=4 sw=4 noet ai cindent syntax=c
  *
  * Conky, a system monitor, based on torsmo
  *
@@ -25,8 +26,6 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
- * vim: ts=4 sw=4 noet ai cindent syntax=c
- *
  */
 
 /* local headers */
 #include "algebra.h"
 #include "build.h"
 #include "colours.h"
+#include "combine.h"
 #include "diskio.h"
+#include "entropy.h"
+#include "exec.h"
+#include "proc.h"
 #ifdef X11
 #include "fonts.h"
 #endif
 #include "fs.h"
+#ifdef HAVE_ICONV
+#include "iconv_tools.h"
+#endif
 #include "logging.h"
 #include "mixer.h"
 #include "mail.h"
 #include "mboxscan.h"
+#include "net_stat.h"
+#ifdef NVIDIA
+#include "nvidia.h"
+#endif
+#include "read_tcp.h"
+#include "scroll.h"
 #include "specials.h"
 #include "temphelper.h"
 #include "template.h"
 #include "tailhead.h"
+#include "timeinfo.h"
 #include "top.h"
 
+#ifdef NCURSES
+#include <ncurses.h>
+#endif
+
 /* check for OS and include appropriate headers */
 #if defined(__linux__)
 #include "linux.h"
 #include "openbsd.h"
 #endif
 
-/* OS specific prototypes to be implemented by linux.c & Co. */
-void update_entropy(void);
-
 #include <string.h>
 #include <ctype.h>
 
-#ifdef HAVE_ICONV
-#include <iconv.h>
-
-#ifdef NCURSES
-#include <ncurses.h>
-#endif
-
-#define ICONV_CODEPAGE_LENGTH 20
-
-int register_iconv(iconv_t *new_iconv);
-
-long iconv_selected;
-long iconv_count = 0;
-char iconv_converting;
-static iconv_t **iconv_cd = 0;
-
-char is_iconv_converting(void)
-{
-       return iconv_converting;
-}
-
-void set_iconv_converting(char i)
-{
-       iconv_converting = i;
-}
-
-long get_iconv_selected(void)
-{
-       return iconv_selected;
-}
-
-void set_iconv_selected(long i)
-{
-       iconv_selected = i;
-}
-
-int register_iconv(iconv_t *new_iconv)
-{
-       iconv_cd = realloc(iconv_cd, sizeof(iconv_t *) * (iconv_count + 1));
-       if (!iconv_cd) {
-               CRIT_ERR(NULL, NULL, "Out of memory");
-       }
-       iconv_cd[iconv_count] = malloc(sizeof(iconv_t));
-       if (!iconv_cd[iconv_count]) {
-               CRIT_ERR(NULL, NULL, "Out of memory");
-       }
-       memcpy(iconv_cd[iconv_count], new_iconv, sizeof(iconv_t));
-       iconv_count++;
-       return iconv_count;
-}
-
-void free_iconv(void)
-{
-       if (iconv_cd) {
-               long i;
-
-               for (i = 0; i < iconv_count; i++) {
-                       if (iconv_cd[i]) {
-                               iconv_close(*iconv_cd[i]);
-                               free(iconv_cd[i]);
-                       }
-               }
-               free(iconv_cd);
-       }
-       iconv_cd = 0;
-}
-
-void iconv_convert(size_t a, char *buff_in, char *p, size_t p_max_size)
-{
-       if (a > 0 && is_iconv_converting() && get_iconv_selected() > 0
-                       && (iconv_cd[iconv_selected - 1] != (iconv_t) (-1))) {
-               int bytes;
-               size_t dummy1, dummy2;
-#ifdef __FreeBSD__
-               const char *ptr = buff_in;
-#else
-               char *ptr = buff_in;
-#endif
-               char *outptr = p;
-
-               dummy1 = dummy2 = a;
-
-               strncpy(buff_in, p, p_max_size);
-
-               iconv(*iconv_cd[iconv_selected - 1], NULL, NULL, NULL, NULL);
-               while (dummy1 > 0) {
-                       bytes = iconv(*iconv_cd[iconv_selected - 1], &ptr, &dummy1,
-                                       &outptr, &dummy2);
-                       if (bytes == -1) {
-                               NORM_ERR("Iconv codeset conversion failed");
-                               break;
-                       }
-               }
-
-               /* It is nessecary when we are converting from multibyte to
-                * singlebyte codepage */
-               a = outptr - p;
-       }
-}
-#endif /* HAVE_ICONV */
-
 /* strip a leading /dev/ if any, following symlinks first
  *
  * BEWARE: this function returns a pointer to static content
  *         which gets overwritten in consecutive calls. I.e.:
  *         this function is NOT reentrant.
  */
-static const char *dev_name(const char *path)
+const char *dev_name(const char *path)
 {
        static char buf[255];   /* should be enough for pathnames */
        ssize_t buflen;
@@ -220,23 +133,19 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
 
        obj->line = line;
 
-#define CALLBACK(x) (-(long)x)
-
-#define OBJ(a, n) if (strcmp(s, #a) == 0) { \
-       obj->type = OBJ_##a; \
-       if (n > 0) { need_mask |= (1ULL << n); } \
-       else if (n < 0) { add_update_callback((void (*)(void))CALLBACK(n)); } {
-#define OBJ_IF(a, n) if (strcmp(s, #a) == 0) { \
-       obj->type = OBJ_##a; obj_be_ifblock_if(ifblock_opaque, obj); \
-       if (n > 0) { need_mask |= (1ULL << n); } \
-       else if (n < 0) { add_update_callback((void (*)(void))CALLBACK(n)); } {
+/* helper defines for internal use only */
+#define __OBJ_HEAD(a, n) if (!strcmp(s, #a)) { \
+       obj->type = OBJ_##a; add_update_callback(n);
+#define __OBJ_IF obj_be_ifblock_if(ifblock_opaque, obj)
+#define __OBJ_ARG(...) if (!arg) { CRIT_ERR(obj, free_at_crash, __VA_ARGS__); }
+
+/* defines to be used below */
+#define OBJ(a, n) __OBJ_HEAD(a, n) {
+#define OBJ_ARG(a, n, ...) __OBJ_HEAD(a, n) __OBJ_ARG(__VA_ARGS__) {
+#define OBJ_IF(a, n) __OBJ_HEAD(a, n) __OBJ_IF; {
+#define OBJ_IF_ARG(a, n, ...) __OBJ_HEAD(a, n) __OBJ_ARG(__VA_ARGS__) __OBJ_IF; {
 #define END } } else
 
-#define SIZE_DEFAULTS(arg) { \
-       obj->a = default_##arg##_width; \
-       obj->b = default_##arg##_height; \
-}
-
 #ifdef X11
        if (s[0] == '#') {
                obj->type = OBJ_color;
@@ -244,149 +153,73 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        } else
 #endif /* X11 */
 #ifdef __OpenBSD__
-       OBJ(freq, INFO_FREQ)
+       OBJ(freq, 0)
 #else
        OBJ(acpitemp, 0)
                obj->data.i = open_acpi_temperature(arg);
        END OBJ(acpiacadapter, 0)
-       END OBJ(freq, INFO_FREQ)
+       END OBJ(freq, 0)
 #endif /* !__OpenBSD__ */
                get_cpu_count();
                if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
-                               || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
-                       obj->data.cpu_index = 1;
+                               || atoi(&arg[0]) > info.cpu_count) {
+                       obj->data.i = 1;
                        /* NORM_ERR("freq: Invalid CPU number or you don't have that many CPUs! "
                                "Displaying the clock for CPU 1."); */
                } else {
-                       obj->data.cpu_index = atoi(&arg[0]);
+                       obj->data.i = atoi(&arg[0]);
                }
-               obj->a = 1;
-       END OBJ(freq_g, INFO_FREQ)
+       END OBJ(freq_g, 0)
                get_cpu_count();
                if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
-                               || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
-                       obj->data.cpu_index = 1;
+                               || atoi(&arg[0]) > info.cpu_count) {
+                       obj->data.i = 1;
                        /* NORM_ERR("freq_g: Invalid CPU number or you don't have that many "
                                "CPUs! Displaying the clock for CPU 1."); */
                } else {
-                       obj->data.cpu_index = atoi(&arg[0]);
-               }
-               obj->a = 1;
-       END OBJ(read_tcp, 0)
-               if (arg) {
-                       obj->data.read_tcp.host = malloc(text_buffer_size);
-                       sscanf(arg, "%s", obj->data.read_tcp.host);
-                       sscanf(arg+strlen(obj->data.read_tcp.host), "%u", &(obj->data.read_tcp.port));
-                       if(obj->data.read_tcp.port == 0) {
-                               obj->data.read_tcp.port = atoi(obj->data.read_tcp.host);
-                               strcpy(obj->data.read_tcp.host,"localhost");
-                       }
-                       obj->data.read_tcp.port = htons(obj->data.read_tcp.port);
-                       if(obj->data.read_tcp.port < 1 || obj->data.read_tcp.port > 65535) {
-                               CRIT_ERR(obj, free_at_crash, "read_tcp: Needs \"(host) port\" as argument(s)");
-                       }
-               }else{
-                       CRIT_ERR(obj, free_at_crash, "read_tcp: Needs \"(host) port\" as argument(s)");
+                       obj->data.i = atoi(&arg[0]);
                }
+       END OBJ_ARG(read_tcp, 0, "read_tcp: Needs \"(host) port\" as argument(s)")
+               parse_read_tcp_arg(obj, arg, free_at_crash);
 #if defined(__linux__)
        END OBJ(voltage_mv, 0)
                get_cpu_count();
                if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
-                               || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
-                       obj->data.cpu_index = 1;
+                               || atoi(&arg[0]) > info.cpu_count) {
+                       obj->data.i = 1;
                        /* NORM_ERR("voltage_mv: Invalid CPU number or you don't have that many "
                                "CPUs! Displaying voltage for CPU 1."); */
                } else {
-                       obj->data.cpu_index = atoi(&arg[0]);
+                       obj->data.i = atoi(&arg[0]);
                }
-               obj->a = 1;
        END OBJ(voltage_v, 0)
                get_cpu_count();
                if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
-                               || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
-                       obj->data.cpu_index = 1;
+                               || atoi(&arg[0]) > info.cpu_count) {
+                       obj->data.i = 1;
                        /* NORM_ERR("voltage_v: Invalid CPU number or you don't have that many "
                                "CPUs! Displaying voltage for CPU 1."); */
                } else {
-                       obj->data.cpu_index = atoi(&arg[0]);
+                       obj->data.i = atoi(&arg[0]);
                }
-               obj->a = 1;
 
 #ifdef HAVE_IWLIB
-       END OBJ(wireless_essid, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
-       END OBJ(wireless_mode, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
-       END OBJ(wireless_bitrate, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
-       END OBJ(wireless_ap, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
-       END OBJ(wireless_link_qual, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
-       END OBJ(wireless_link_qual_max, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
-       END OBJ(wireless_link_qual_perc, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
-       END OBJ(wireless_link_bar, CALLBACK(&update_net_stats))
-               SIZE_DEFAULTS(bar);
-               if (arg) {
-                       arg = scan_bar(arg, &obj->a, &obj->b);
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
+       END OBJ(wireless_essid, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
+       END OBJ(wireless_mode, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
+       END OBJ(wireless_bitrate, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
+       END OBJ(wireless_ap, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
+       END OBJ(wireless_link_qual, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
+       END OBJ(wireless_link_qual_max, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
+       END OBJ(wireless_link_qual_perc, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
+       END OBJ(wireless_link_bar, &update_net_stats)
+               parse_net_stat_bar_arg(obj, arg, free_at_crash);
 #endif /* HAVE_IWLIB */
 
 #endif /* __linux__ */
@@ -431,10 +264,8 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
                obj->data.s = strndup(bat, text_buffer_size);
        END OBJ(battery_bar, 0)
                char bat[64];
-               SIZE_DEFAULTS(bar);
-               obj->b = 6;
                if (arg) {
-                       arg = scan_bar(arg, &obj->a, &obj->b);
+                       arg = scan_bar(obj, arg);
                        sscanf(arg, "%63s", bat);
                } else {
                        strcpy(bat, "BAT0");
@@ -443,184 +274,103 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
 #endif /* !__OpenBSD__ */
 
 #if defined(__linux__)
-       END OBJ(disk_protect, 0)
-               if (arg)
-                       obj->data.s = strndup(dev_name(arg), text_buffer_size);
-               else
-                       CRIT_ERR(obj, free_at_crash, "disk_protect needs an argument");
-       END OBJ(i8k_version, CALLBACK(&update_i8k))
-       END OBJ(i8k_bios, CALLBACK(&update_i8k))
-       END OBJ(i8k_serial, CALLBACK(&update_i8k))
-       END OBJ(i8k_cpu_temp, CALLBACK(&update_i8k))
-       END OBJ(i8k_left_fan_status, CALLBACK(&update_i8k))
-       END OBJ(i8k_right_fan_status, CALLBACK(&update_i8k))
-       END OBJ(i8k_left_fan_rpm, CALLBACK(&update_i8k))
-       END OBJ(i8k_right_fan_rpm, CALLBACK(&update_i8k))
-       END OBJ(i8k_ac_status, CALLBACK(&update_i8k))
-       END OBJ(i8k_buttons_status, CALLBACK(&update_i8k))
+       END OBJ_ARG(disk_protect, 0, "disk_protect needs an argument")
+               obj->data.s = strndup(dev_name(arg), text_buffer_size);
+       END OBJ(i8k_version, &update_i8k)
+       END OBJ(i8k_bios, &update_i8k)
+       END OBJ(i8k_serial, &update_i8k)
+       END OBJ(i8k_cpu_temp, &update_i8k)
+       END OBJ(i8k_left_fan_status, &update_i8k)
+       END OBJ(i8k_right_fan_status, &update_i8k)
+       END OBJ(i8k_left_fan_rpm, &update_i8k)
+       END OBJ(i8k_right_fan_rpm, &update_i8k)
+       END OBJ(i8k_ac_status, &update_i8k)
+       END OBJ(i8k_buttons_status, &update_i8k)
 #if defined(IBM)
        END OBJ(ibm_fan, 0)
-       END OBJ(ibm_temps, 0)
-               if (!arg) {
-                       CRIT_ERR(obj, free_at_crash, "ibm_temps: needs an argument");
-               }
-               if (!isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) >= 8) {
-                       obj->data.sensor = 0;
-                       NORM_ERR("Invalid temperature sensor! Sensor number must be 0 to 7. "
-                               "Using 0 (CPU temp sensor).");
-               }
-               obj->data.sensor = atoi(&arg[0]);
+       END OBJ_ARG(ibm_temps, &get_ibm_acpi_temps, "ibm_temps: needs an argument")
+               parse_ibm_temps_arg(obj, arg);
        END OBJ(ibm_volume, 0)
        END OBJ(ibm_brightness, 0)
 #endif
        /* information from sony_laptop kernel module
         * /sys/devices/platform/sony-laptop */
        END OBJ(sony_fanspeed, 0)
-       END OBJ_IF(if_gw, CALLBACK(&update_gateway_info))
-       END OBJ(ioscheduler, 0)
-               if (!arg) {
-                       CRIT_ERR(obj, free_at_crash, "get_ioscheduler needs an argument (e.g. hda)");
-                       obj->data.s = 0;
-               } else
-                       obj->data.s = strndup(dev_name(arg), text_buffer_size);
+       END OBJ_IF(if_gw, &update_gateway_info)
+       END OBJ_ARG(ioscheduler, 0, "get_ioscheduler needs an argument (e.g. hda)")
+               obj->data.s = strndup(dev_name(arg), text_buffer_size);
        END OBJ(laptop_mode, 0)
-       END OBJ(pb_battery, 0)
-               if (arg && strcmp(arg, "status") == EQUAL) {
+       END OBJ_ARG(pb_battery, 0, "pb_battery: needs one argument: status, percent or time")
+               if (strcmp(arg, "status") == EQUAL) {
                        obj->data.i = PB_BATT_STATUS;
-               } else if (arg && strcmp(arg, "percent") == EQUAL) {
+               } else if (strcmp(arg, "percent") == EQUAL) {
                        obj->data.i = PB_BATT_PERCENT;
-               } else if (arg && strcmp(arg, "time") == EQUAL) {
+               } else if (strcmp(arg, "time") == EQUAL) {
                        obj->data.i = PB_BATT_TIME;
                } else {
-                       NORM_ERR("pb_battery: needs one argument: status, percent or time");
-                       free(obj);
-                       return NULL;
+                       NORM_ERR("pb_battery: illegal argument '%s', defaulting to status", arg);
+                       obj->data.i = PB_BATT_STATUS;
                }
-
 #endif /* __linux__ */
 #if (defined(__FreeBSD__) || defined(__linux__))
-       END OBJ_IF(if_up, 0)
-               if (!arg) {
-                       NORM_ERR("if_up needs an argument");
-                       obj->data.ifblock.s = 0;
-               } else {
-                       obj->data.ifblock.s = strndup(arg, text_buffer_size);
-               }
+       END OBJ_IF_ARG(if_up, 0, "if_up needs an argument")
+               parse_if_up_arg(obj, arg);
 #endif
 #if defined(__OpenBSD__)
-       END OBJ(obsd_sensors_temp, 0)
-               if (!arg) {
-                       CRIT_ERR(obj, free_at_crash, "obsd_sensors_temp: needs an argument");
-               }
-               if (!isdigit(arg[0]) || atoi(&arg[0]) < 0
-                               || atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) {
-                       obj->data.sensor = 0;
-                       NORM_ERR("Invalid temperature sensor number!");
-               }
-               obj->data.sensor = atoi(&arg[0]);
-       END OBJ(obsd_sensors_fan, 0)
-               if (!arg) {
-                       CRIT_ERR(obj, free_at_crash, "obsd_sensors_fan: needs 2 arguments (device and sensor "
-                               "number)");
-               }
-               if (!isdigit(arg[0]) || atoi(&arg[0]) < 0
-                               || atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) {
-                       obj->data.sensor = 0;
-                       NORM_ERR("Invalid fan sensor number!");
-               }
-               obj->data.sensor = atoi(&arg[0]);
-       END OBJ(obsd_sensors_volt, 0)
-               if (!arg) {
-                       CRIT_ERR(obj, free_at_crash, "obsd_sensors_volt: needs 2 arguments (device and sensor "
-                               "number)");
-               }
-               if (!isdigit(arg[0]) || atoi(&arg[0]) < 0
-                               || atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) {
-                       obj->data.sensor = 0;
-                       NORM_ERR("Invalid voltage sensor number!");
-               }
-               obj->data.sensor = atoi(&arg[0]);
+       END OBJ_ARG(obsd_sensors_temp, 0, "obsd_sensors_temp: needs an argument")
+               parse_obsd_sensor(obj, arg);
+       END OBJ_ARG(obsd_sensors_fan, 0, "obsd_sensors_fan: needs 2 arguments (device and sensor number)")
+               parse_obsd_sensor(obj, arg);
+       END OBJ_ARG(obsd_sensors_volt, 0, "obsd_sensors_volt: needs 2 arguments (device and sensor number)")
+               parse_obsd_sensor(obj, arg);
        END OBJ(obsd_vendor, 0)
        END OBJ(obsd_product, 0)
 #endif /* __OpenBSD__ */
-       END OBJ(buffers, CALLBACK(&update_meminfo))
-       END OBJ(cached, CALLBACK(&update_meminfo))
+       END OBJ(buffers, &update_meminfo)
+       END OBJ(cached, &update_meminfo)
 #define SCAN_CPU(__arg, __var) { \
        int __offset = 0; \
-       if (__arg && sscanf(__arg, " cpu%u %n", &__var, &__offset) > 0) \
+       if (__arg && sscanf(__arg, " cpu%d %n", &__var, &__offset) > 0) \
                __arg += __offset; \
        else \
                __var = 0; \
 }
-       END OBJ(cpu, CALLBACK(&update_cpu_usage))
-               SCAN_CPU(arg, obj->data.cpu_index);
-               DBGP2("Adding $cpu for CPU %d", obj->data.cpu_index);
+       END OBJ(cpu, &update_cpu_usage)
+               SCAN_CPU(arg, obj->data.i);
+               DBGP2("Adding $cpu for CPU %d", obj->data.i);
 #ifdef X11
-       END OBJ(cpugauge, CALLBACK(&update_cpu_usage))
-               SIZE_DEFAULTS(gauge);
-               SCAN_CPU(arg, obj->data.cpu_index);
-               scan_gauge(arg, &obj->a, &obj->b);
-               DBGP2("Adding $cpugauge for CPU %d", obj->data.cpu_index);
+       END OBJ(cpugauge, &update_cpu_usage)
+               SCAN_CPU(arg, obj->data.i);
+               scan_gauge(obj, arg);
+               DBGP2("Adding $cpugauge for CPU %d", obj->data.i);
 #endif /* X11 */
-       END OBJ(cpubar, CALLBACK(&update_cpu_usage))
-               SIZE_DEFAULTS(bar);
-               SCAN_CPU(arg, obj->data.cpu_index);
-               scan_bar(arg, &obj->a, &obj->b);
-               DBGP2("Adding $cpubar for CPU %d", obj->data.cpu_index);
+       END OBJ(cpubar, &update_cpu_usage)
+               SCAN_CPU(arg, obj->data.i);
+               scan_bar(obj, arg);
+               DBGP2("Adding $cpubar for CPU %d", obj->data.i);
 #ifdef X11
-       END OBJ(cpugraph, CALLBACK(&update_cpu_usage))
+       END OBJ(cpugraph, &update_cpu_usage)
                char *buf = 0;
-               SIZE_DEFAULTS(graph);
-               SCAN_CPU(arg, obj->data.cpu_index);
-               buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
-                       &obj->e, &obj->char_a, &obj->char_b);
-               DBGP2("Adding $cpugraph for CPU %d", obj->data.cpu_index);
+               SCAN_CPU(arg, obj->data.i);
+               buf = scan_graph(obj, arg, 100);
+               DBGP2("Adding $cpugraph for CPU %d", obj->data.i);
                if (buf) free(buf);
-       END OBJ(loadgraph, CALLBACK(&update_load_average))
-               char *buf = 0;
-               SIZE_DEFAULTS(graph);
-               buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
-                               &obj->e, &obj->char_a, &obj->char_b);
-               if (buf) {
-                       int a = 1, r = 3;
-                       if (arg) {
-                               r = sscanf(arg, "%d", &a);
-                       }
-                       obj->data.loadavg[0] = (r >= 1) ? (unsigned char) a : 0;
-                       free(buf);
-               }
+       END OBJ(loadgraph, &update_load_average)
+               scan_loadgraph_arg(obj, arg);
 #endif /* X11 */
-       END OBJ(diskio, CALLBACK(&update_diskio))
-               obj->data.diskio = prepare_diskio_stat(dev_name(arg));
-       END OBJ(diskio_read, CALLBACK(&update_diskio))
-               obj->data.diskio = prepare_diskio_stat(dev_name(arg));
-       END OBJ(diskio_write, CALLBACK(&update_diskio))
-               obj->data.diskio = prepare_diskio_stat(dev_name(arg));
+       END OBJ(diskio, &update_diskio)
+               parse_diskio_arg(obj, arg);
+       END OBJ(diskio_read, &update_diskio)
+               parse_diskio_arg(obj, arg);
+       END OBJ(diskio_write, &update_diskio)
+               parse_diskio_arg(obj, arg);
 #ifdef X11
-       END OBJ(diskiograph, CALLBACK(&update_diskio))
-               char *buf = 0;
-               SIZE_DEFAULTS(graph);
-               buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
-                               &obj->e, &obj->char_a, &obj->char_b);
-
-               obj->data.diskio = prepare_diskio_stat(dev_name(buf));
-               if (buf) free(buf);
-       END OBJ(diskiograph_read, CALLBACK(&update_diskio))
-               char *buf = 0;
-               SIZE_DEFAULTS(graph);
-               buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
-                               &obj->e, &obj->char_a, &obj->char_b);
-
-               obj->data.diskio = prepare_diskio_stat(dev_name(buf));
-               if (buf) free(buf);
-       END OBJ(diskiograph_write, CALLBACK(&update_diskio))
-               char *buf = 0;
-               SIZE_DEFAULTS(graph);
-               buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
-                               &obj->e, &obj->char_a, &obj->char_b);
-
-               obj->data.diskio = prepare_diskio_stat(dev_name(buf));
-               if (buf) free(buf);
+       END OBJ(diskiograph, &update_diskio)
+               parse_diskiograph_arg(obj, arg);
+       END OBJ(diskiograph_read, &update_diskio)
+               parse_diskiograph_arg(obj, arg);
+       END OBJ(diskiograph_write, &update_diskio)
+               parse_diskiograph_arg(obj, arg);
 #endif /* X11 */
        END OBJ(color, 0)
 #ifdef X11
@@ -690,35 +440,13 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        END OBJ(conky_version, 0)
        END OBJ(conky_build_date, 0)
        END OBJ(conky_build_arch, 0)
-       END OBJ(downspeed, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
-       END OBJ(downspeedf, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
+       END OBJ(downspeed, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
+       END OBJ(downspeedf, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
 #ifdef X11
-       END OBJ(downspeedgraph, CALLBACK(&update_net_stats))
-               char *buf = 0;
-               SIZE_DEFAULTS(graph);
-               buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
-                               &obj->e, &obj->char_a, &obj->char_b);
-
-               // default to DEFAULTNETDEV
-               buf = strndup(buf ? buf : DEFAULTNETDEV, text_buffer_size);
-               obj->data.net = get_net_stat(buf, obj, free_at_crash);
-               free(buf);
+       END OBJ(downspeedgraph, &update_net_stats)
+               parse_net_stat_graph_arg(obj, arg, free_at_crash);
 #endif /* X11 */
        END OBJ(else, 0)
                obj_be_ifblock_else(ifblock_opaque, obj);
@@ -726,306 +454,76 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
                obj_be_ifblock_endif(ifblock_opaque, obj);
        END OBJ(eval, 0)
                obj->data.s = strndup(arg ? arg : "", text_buffer_size);
+#if defined(IMLIB2) && defined(X11)
        END OBJ(image, 0)
                obj->data.s = strndup(arg ? arg : "", text_buffer_size);
+#endif /* IMLIB2 */
        END OBJ(exec, 0)
-               obj->data.s = strndup(arg ? arg : "", text_buffer_size);
+               scan_exec_arg(obj, arg);
        END OBJ(execp, 0)
-               obj->data.s = strndup(arg ? arg : "", text_buffer_size);
+               scan_exec_arg(obj, arg);
        END OBJ(execbar, 0)
-               SIZE_DEFAULTS(bar);
-               obj->data.s = strndup(arg ? arg : "", text_buffer_size);
+               scan_exec_arg(obj, arg);
 #ifdef X11
        END OBJ(execgauge, 0)
-               SIZE_DEFAULTS(gauge);
-               obj->data.s = strndup(arg ? arg : "", text_buffer_size);
+               scan_exec_arg(obj, arg);
        END OBJ(execgraph, 0)
-               SIZE_DEFAULTS(graph);
-               obj->data.s = strndup(arg ? arg : "", text_buffer_size);
+               scan_execgraph_arg(obj, arg);
 #endif /* X11 */
-       END OBJ(execibar, 0)
-               int n;
-               SIZE_DEFAULTS(bar);
-
-               if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
-                       char buf[256];
-
-                       NORM_ERR("${execibar <interval> command}");
-                       obj->type = OBJ_text;
-                       snprintf(buf, 256, "${%s}", s);
-                       obj->data.s = strndup(buf, text_buffer_size);
-               } else {
-                       obj->data.execi.cmd = strndup(arg + n, text_buffer_size);
-               }
+       END OBJ_ARG(execibar, 0, "execibar needs arguments")
+               scan_execi_arg(obj, arg);
 #ifdef X11
-       END OBJ(execigraph, 0)
-               int n;
-               SIZE_DEFAULTS(graph);
-
-               if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
-                       char buf[256];
-
-                       NORM_ERR("${execigraph <interval> command}");
-                       obj->type = OBJ_text;
-                       snprintf(buf, 256, "${%s}", s);
-                       obj->data.s = strndup(buf, text_buffer_size);
-               } else {
-                       obj->data.execi.cmd = strndup(arg + n, text_buffer_size);
-               }
-       END OBJ(execigauge, 0)
-               int n;
-               SIZE_DEFAULTS(gauge);
-
-               if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
-                       char buf[256];
-
-                       NORM_ERR("${execigauge <interval> command}");
-                       obj->type = OBJ_text;
-                       snprintf(buf, 256, "${%s}", s);
-                       obj->data.s = strndup(buf, text_buffer_size);
-               } else {
-                       obj->data.execi.cmd = strndup(arg + n, text_buffer_size);
-               }
+       END OBJ_ARG(execigraph, 0, "execigraph needs arguments")
+               scan_execgraph_arg(obj, arg);
+       END OBJ_ARG(execigauge, 0, "execigauge needs arguments")
+               scan_execi_arg(obj, arg);
 #endif /* X11 */
-       END OBJ(execi, 0)
-               int n;
-
-               if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
-                       char buf[256];
-
-                       NORM_ERR("${execi <interval> command}");
-                       obj->type = OBJ_text;
-                       snprintf(buf, 256, "${%s}", s);
-                       obj->data.s = strndup(buf, text_buffer_size);
-               } else {
-                       obj->data.execi.cmd = strndup(arg + n, text_buffer_size);
-                       obj->data.execi.buffer = malloc(text_buffer_size);
-               }
-       END OBJ(execpi, 0)
-               int n;
-
-               if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) {
-                       char buf[256];
-
-                       NORM_ERR("${execi <interval> command}");
-                       obj->type = OBJ_text;
-                       snprintf(buf, 256, "${%s}", s);
-                       obj->data.s = strndup(buf, text_buffer_size);
-               } else {
-                       obj->data.execi.cmd = strndup(arg + n, text_buffer_size);
-                       obj->data.execi.buffer = malloc(text_buffer_size);
-               }
-       END OBJ(texeci, 0)
-                       int n;
-
-                       if (!arg || sscanf(arg, "%f %n", &obj->data.texeci.interval, &n) <= 0) {
-                               char buf[256];
-
-                               NORM_ERR("${texeci <interval> command}");
-                               obj->type = OBJ_text;
-                               snprintf(buf, 256, "${%s}", s);
-                               obj->data.s = strndup(buf, text_buffer_size);
-                       } else {
-                               obj->data.texeci.cmd = strndup(arg + n, text_buffer_size);
-                               obj->data.texeci.buffer = malloc(text_buffer_size);
-                       }
-                       obj->data.texeci.p_timed_thread = NULL;
+       END OBJ_ARG(execi, 0, "execi needs arguments")
+               scan_execi_arg(obj, arg);
+       END OBJ_ARG(execpi, 0, "execpi needs arguments")
+               scan_execi_arg(obj, arg);
+       END OBJ_ARG(texeci, 0, "texeci needs arguments")
+               scan_execi_arg(obj, arg);
        END OBJ(pre_exec, 0)
-               obj->type = OBJ_text;
-               if (arg) {
-                       char buf[2048];
-
-                       do_read_exec(arg, buf, sizeof(buf));
-                       obj->data.s = strndup(buf, text_buffer_size);
-               } else {
-                       obj->data.s = strndup("", text_buffer_size);
-               }
-       END OBJ(fs_bar, CALLBACK(&update_fs_stats))
-               SIZE_DEFAULTS(bar);
-               arg = scan_bar(arg, &obj->data.fsbar.w, &obj->data.fsbar.h);
-               if (arg) {
-                       while (isspace(*arg)) {
-                               arg++;
-                       }
-                       if (*arg == '\0') {
-                               arg = "/";
-                       }
-               } else {
-                       arg = "/";
-               }
-               obj->data.fsbar.fs = prepare_fs_stat(arg);
-       END OBJ(fs_bar_free, CALLBACK(&update_fs_stats))
-               SIZE_DEFAULTS(bar);
-               arg = scan_bar(arg, &obj->data.fsbar.w, &obj->data.fsbar.h);
-               if (arg) {
-                       while (isspace(*arg)) {
-                               arg++;
-                       }
-                       if (*arg == '\0') {
-                               arg = "/";
-                       }
-               } else {
-                       arg = "/";
-               }
-
-               obj->data.fsbar.fs = prepare_fs_stat(arg);
-       END OBJ(fs_free, CALLBACK(&update_fs_stats))
-               if (!arg) {
-                       arg = "/";
-               }
-               obj->data.fs = prepare_fs_stat(arg);
-       END OBJ(fs_used_perc, CALLBACK(&update_fs_stats))
-               if (!arg) {
-                       arg = "/";
-               }
-               obj->data.fs = prepare_fs_stat(arg);
-       END OBJ(fs_free_perc, CALLBACK(&update_fs_stats))
-               if (!arg) {
-                       arg = "/";
-               }
-               obj->data.fs = prepare_fs_stat(arg);
-       END OBJ(fs_size, CALLBACK(&update_fs_stats))
-               if (!arg) {
-                       arg = "/";
-               }
-               obj->data.fs = prepare_fs_stat(arg);
-       END OBJ(fs_type, CALLBACK(&update_fs_stats))
-               if (!arg) {
-                       arg = "/";
-               }
-               obj->data.fs = prepare_fs_stat(arg);
-       END OBJ(fs_used, CALLBACK(&update_fs_stats))
-               if (!arg) {
-                       arg = "/";
-               }
-               obj->data.fs = prepare_fs_stat(arg);
+               scan_pre_exec_arg(obj, arg);
+       END OBJ(fs_bar, &update_fs_stats)
+               init_fs_bar(obj, arg);
+       END OBJ(fs_bar_free, &update_fs_stats)
+               init_fs_bar(obj, arg);
+       END OBJ(fs_free, &update_fs_stats)
+               init_fs(obj, arg);
+       END OBJ(fs_used_perc, &update_fs_stats)
+               init_fs(obj, arg);
+       END OBJ(fs_free_perc, &update_fs_stats)
+               init_fs(obj, arg);
+       END OBJ(fs_size, &update_fs_stats)
+               init_fs(obj, arg);
+       END OBJ(fs_type, &update_fs_stats)
+               init_fs(obj, arg);
+       END OBJ(fs_used, &update_fs_stats)
+               init_fs(obj, arg);
        END OBJ(hr, 0)
                obj->data.i = arg ? atoi(arg) : 1;
-       END OBJ(nameserver, CALLBACK(&update_dns_data))
-               obj->data.i = arg ? atoi(arg) : 0;
+       END OBJ(nameserver, &update_dns_data)
+               parse_nameserver_arg(obj, arg);
        END OBJ(offset, 0)
                obj->data.i = arg ? atoi(arg) : 1;
        END OBJ(voffset, 0)
                obj->data.i = arg ? atoi(arg) : 1;
-       END OBJ(goto, 0)
-
-               if (!arg) {
-                       NORM_ERR("goto needs arguments");
-                       obj->type = OBJ_text;
-                       obj->data.s = strndup("${goto}", text_buffer_size);
-                       return NULL;
-               }
-
+       END OBJ_ARG(goto, 0, "goto needs arguments")
                obj->data.i = atoi(arg);
-
+#ifdef X11
        END OBJ(tab, 0)
-               int a = 10, b = 0;
-
-               if (arg) {
-                       if (sscanf(arg, "%d %d", &a, &b) != 2) {
-                               sscanf(arg, "%d", &b);
-                       }
-               }
-               if (a <= 0) {
-                       a = 1;
-               }
-               obj->data.pair.a = a;
-               obj->data.pair.b = b;
-
+               scan_tab(obj, arg);
+#endif /* X11 */
 #ifdef __linux__
-       END OBJ(i2c, INFO_SYSFS)
-               char buf1[64], buf2[64];
-               float factor, offset;
-               int n, found = 0;
-
-               if (!arg) {
-                       NORM_ERR("i2c needs arguments");
-                       obj->type = OBJ_text;
-                       // obj->data.s = strndup("${i2c}", text_buffer_size);
-                       return NULL;
-               }
-
-#define HWMON_RESET() {\
-               buf1[0] = 0; \
-               factor = 1.0; \
-               offset = 0.0; }
-
-               if (sscanf(arg, "%63s %d %f %f", buf2, &n, &factor, &offset) == 4) found = 1; else HWMON_RESET();
-               if (!found && sscanf(arg, "%63s %63s %d %f %f", buf1, buf2, &n, &factor, &offset) == 5) found = 1; else if (!found) HWMON_RESET();
-               if (!found && sscanf(arg, "%63s %63s %d", buf1, buf2, &n) == 3) found = 1; else if (!found) HWMON_RESET();
-               if (!found && sscanf(arg, "%63s %d", buf2, &n) == 2) found = 1; else if (!found) HWMON_RESET();
-
-               if (!found) {
-                       NORM_ERR("i2c failed to parse arguments");
-                       obj->type = OBJ_text;
-                       return NULL;
-               }
-               DBGP("parsed i2c args: '%s' '%s' %d %f %f\n", buf1, buf2, n, factor, offset);
-               obj->data.sysfs.fd = open_i2c_sensor((*buf1) ? buf1 : 0, buf2, n,
-                               &obj->data.sysfs.arg, obj->data.sysfs.devtype);
-               strncpy(obj->data.sysfs.type, buf2, 63);
-               obj->data.sysfs.factor = factor;
-               obj->data.sysfs.offset = offset;
-
-       END OBJ(platform, INFO_SYSFS)
-               char buf1[64], buf2[64];
-               float factor, offset;
-               int n, found = 0;
-
-               if (!arg) {
-                       NORM_ERR("platform needs arguments");
-                       obj->type = OBJ_text;
-                       return NULL;
-               }
-
-               if (sscanf(arg, "%63s %d %f %f", buf2, &n, &factor, &offset) == 4) found = 1; else HWMON_RESET();
-               if (!found && sscanf(arg, "%63s %63s %d %f %f", buf1, buf2, &n, &factor, &offset) == 5) found = 1; else if (!found) HWMON_RESET();
-               if (!found && sscanf(arg, "%63s %63s %d", buf1, buf2, &n) == 3) found = 1; else if (!found) HWMON_RESET();
-               if (!found && sscanf(arg, "%63s %d", buf2, &n) == 2) found = 1; else if (!found) HWMON_RESET();
-
-               if (!found) {
-                       NORM_ERR("platform failed to parse arguments");
-                       obj->type = OBJ_text;
-                       return NULL;
-               }
-               DBGP("parsed platform args: '%s' '%s' %d %f %f", buf1, buf2, n, factor, offset);
-               obj->data.sysfs.fd = open_platform_sensor((*buf1) ? buf1 : 0, buf2, n,
-                               &obj->data.sysfs.arg, obj->data.sysfs.devtype);
-               strncpy(obj->data.sysfs.type, buf2, 63);
-               obj->data.sysfs.factor = factor;
-               obj->data.sysfs.offset = offset;
-
-       END OBJ(hwmon, INFO_SYSFS)
-               char buf1[64], buf2[64];
-               float factor, offset;
-               int n, found = 0;
-
-               if (!arg) {
-                       NORM_ERR("hwmon needs argumanets");
-                       obj->type = OBJ_text;
-                       return NULL;
-               }
-
-               if (sscanf(arg, "%63s %d %f %f", buf2, &n, &factor, &offset) == 4) found = 1; else HWMON_RESET();
-               if (!found && sscanf(arg, "%63s %63s %d %f %f", buf1, buf2, &n, &factor, &offset) == 5) found = 1; else if (!found) HWMON_RESET();
-               if (!found && sscanf(arg, "%63s %63s %d", buf1, buf2, &n) == 3) found = 1; else if (!found) HWMON_RESET();
-               if (!found && sscanf(arg, "%63s %d", buf2, &n) == 2) found = 1; else if (!found) HWMON_RESET();
-
-#undef HWMON_RESET
-
-               if (!found) {
-                       NORM_ERR("hwmon failed to parse arguments");
-                       obj->type = OBJ_text;
-                       return NULL;
-               }
-               DBGP("parsed hwmon args: '%s' '%s' %d %f %f\n", buf1, buf2, n, factor, offset);
-               obj->data.sysfs.fd = open_hwmon_sensor((*buf1) ? buf1 : 0, buf2, n,
-                               &obj->data.sysfs.arg, obj->data.sysfs.devtype);
-               strncpy(obj->data.sysfs.type, buf2, 63);
-               obj->data.sysfs.factor = factor;
-               obj->data.sysfs.offset = offset;
-
-#endif /* !__OpenBSD__ */
+       END OBJ_ARG(i2c, 0, "i2c needs arguments")
+               parse_i2c_sensor(obj, arg);
+       END OBJ_ARG(platform, 0, "platform needs arguments")
+               parse_platform_sensor(obj, arg);
+       END OBJ_ARG(hwmon, 0, "hwmon needs argumanets")
+               parse_hwmon_sensor(obj, arg);
+#endif /* __linux__ */
 
        END
        /* we have four different types of top (top, top_mem, top_time and top_io). To
@@ -1033,396 +531,138 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
         * handler. */
        if (strncmp(s, "top", 3) == EQUAL) {
                add_update_callback(&update_meminfo);
+               add_update_callback(&update_top);
                if (!parse_top_args(s, arg, obj)) {
                        return NULL;
                }
-       } else OBJ(addr, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
+       } else OBJ(addr, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
 #if defined(__linux__)
-       END OBJ(addrs, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
+       END OBJ(addrs, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
 #endif /* __linux__ */
-       END OBJ(tail, 0)
+       END OBJ_ARG(tail, 0, "tail needs arguments")
                init_tailhead("tail", arg, obj, free_at_crash);
-       END OBJ(head, 0)
+       END OBJ_ARG(head, 0, "head needs arguments")
                init_tailhead("head", arg, obj, free_at_crash);
-       END OBJ(lines, 0)
-               if (arg) {
-                       obj->data.s = strndup(arg, text_buffer_size);
-               }else{
-                       CRIT_ERR(obj, free_at_crash, "lines needs a argument");
-               }
-       END OBJ(words, 0)
-               if (arg) {
-                       obj->data.s = strndup(arg, text_buffer_size);
-               }else{
-                       CRIT_ERR(obj, free_at_crash, "words needs a argument");
-               }
-       END OBJ(loadavg, CALLBACK(&update_load_average))
-               int a = 1, b = 2, c = 3, r = 3;
-
-               if (arg) {
-                       r = sscanf(arg, "%d %d %d", &a, &b, &c);
-                       if (r >= 3 && (c < 1 || c > 3)) {
-                               r--;
-                       }
-                       if (r >= 2 && (b < 1 || b > 3)) {
-                               r--, b = c;
-                       }
-                       if (r >= 1 && (a < 1 || a > 3)) {
-                               r--, a = b, b = c;
-                       }
-               }
-               obj->data.loadavg[0] = (r >= 1) ? (unsigned char) a : 0;
-               obj->data.loadavg[1] = (r >= 2) ? (unsigned char) b : 0;
-               obj->data.loadavg[2] = (r >= 3) ? (unsigned char) c : 0;
-       END OBJ_IF(if_empty, 0)
-               if (!arg) {
-                       NORM_ERR("if_empty needs an argument");
-                       obj->data.ifblock.s = 0;
-               } else {
-                       obj->data.ifblock.s = strndup(arg, text_buffer_size);
-                       obj->sub = malloc(sizeof(struct text_object));
-                       extract_variable_text_internal(obj->sub,
-                                                      obj->data.ifblock.s);
-               }
-       END OBJ_IF(if_match, 0)
-               if (!arg) {
-                       NORM_ERR("if_match needs arguments");
-                       obj->data.ifblock.s = 0;
-               } else {
-                       obj->data.ifblock.s = strndup(arg, text_buffer_size);
-                       obj->sub = malloc(sizeof(struct text_object));
-                       extract_variable_text_internal(obj->sub,
-                                                      obj->data.ifblock.s);
-               }
-       END OBJ_IF(if_existing, 0)
-               if (!arg) {
-                       NORM_ERR("if_existing needs an argument or two");
-                       obj->data.ifblock.s = NULL;
-                       obj->data.ifblock.str = NULL;
-               } else {
-                       char buf1[256], buf2[256];
-                       int r = sscanf(arg, "%255s %255[^\n]", buf1, buf2);
-
-                       if (r == 1) {
-                               obj->data.ifblock.s = strndup(buf1, text_buffer_size);
-                               obj->data.ifblock.str = NULL;
-                       } else {
-                               obj->data.ifblock.s = strndup(buf1, text_buffer_size);
-                               obj->data.ifblock.str = strndup(buf2, text_buffer_size);
-                       }
-               }
-               DBGP("if_existing: '%s' '%s'", obj->data.ifblock.s, obj->data.ifblock.str);
-       END OBJ_IF(if_mounted, 0)
-               if (!arg) {
-                       NORM_ERR("if_mounted needs an argument");
-                       obj->data.ifblock.s = 0;
-               } else {
-                       obj->data.ifblock.s = strndup(arg, text_buffer_size);
-               }
+       END OBJ_ARG(lines, 0, "lines needs an argument")
+               obj->data.s = strndup(arg, text_buffer_size);
+       END OBJ_ARG(words, 0, "words needs a argument")
+               obj->data.s = strndup(arg, text_buffer_size);
+       END OBJ(loadavg, &update_load_average)
+               scan_loadavg_arg(obj, arg);
+       END OBJ_IF_ARG(if_empty, 0, "if_empty needs an argument")
+               obj->sub = malloc(sizeof(struct text_object));
+               extract_variable_text_internal(obj->sub, arg);
+       END OBJ_IF_ARG(if_match, 0, "if_match needs arguments")
+               obj->sub = malloc(sizeof(struct text_object));
+               extract_variable_text_internal(obj->sub, arg);
+       END OBJ_IF_ARG(if_existing, 0, "if_existing needs an argument or two")
+               obj->data.s = strndup(arg, text_buffer_size);
+       END OBJ_IF_ARG(if_mounted, 0, "if_mounted needs an argument")
+               obj->data.s = strndup(arg, text_buffer_size);
 #ifdef __linux__
-       END OBJ_IF(if_running, CALLBACK(&update_top))
-               if (arg) {
-                       top_running = 1;
-                       obj->data.ifblock.s = strndup(arg, text_buffer_size);
+       END OBJ_IF_ARG(if_running, &update_top, "if_running needs an argument")
+               top_running = 1;
+               obj->data.s = strndup(arg, text_buffer_size);
 #else
-       END OBJ_IF(if_running, 0)
-               if (arg) {
-                       char buf[256];
+       END OBJ_IF_ARG(if_running, 0, "if_running needs an argument")
+               char buf[256];
 
-                       snprintf(buf, 256, "pidof %s >/dev/null", arg);
-                       obj->data.ifblock.s = strndup(buf, text_buffer_size);
+               snprintf(buf, 256, "pidof %s >/dev/null", arg);
+               obj->data.s = strndup(buf, text_buffer_size);
 #endif
-               } else {
-                       NORM_ERR("if_running needs an argument");
-                       obj->data.ifblock.s = 0;
-               }
        END OBJ(kernel, 0)
        END OBJ(machine, 0)
        END OBJ(mails, 0)
-               float n1;
-               char mbox[256], dst[256];
-
-               if (!arg) {
-                       n1 = 9.5;
-                       /* Kapil: Changed from MAIL_FILE to
-                          current_mail_spool since the latter
-                          is a copy of the former if undefined
-                          but the latter should take precedence
-                          if defined */
-                       strncpy(mbox, current_mail_spool, sizeof(mbox));
-               } else {
-                       if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
-                               n1 = 9.5;
-                               strncpy(mbox, arg, sizeof(mbox));
-                       }
-               }
-
-               variable_substitute(mbox, dst, sizeof(dst));
-               obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
-               obj->data.local_mail.interval = n1;
+               parse_local_mail_args(obj, arg);
        END OBJ(new_mails, 0)
-               float n1;
-               char mbox[256], dst[256];
-
-               if (!arg) {
-                       n1 = 9.5;
-                       strncpy(mbox, current_mail_spool, sizeof(mbox));
-               } else {
-                       if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
-                               n1 = 9.5;
-                               strncpy(mbox, arg, sizeof(mbox));
-                       }
-               }
-
-               variable_substitute(mbox, dst, sizeof(dst));
-               obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
-               obj->data.local_mail.interval = n1;
-       END OBJ(seen_mails, 0)
-               float n1;
-               char mbox[256], dst[256];
-
-               if (!arg) {
-                       n1 = 9.5;
-                       strncpy(mbox, current_mail_spool, sizeof(mbox));
-               } else {
-                       if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
-                               n1 = 9.5;
-                               strncpy(mbox, arg, sizeof(mbox));
-                       }
-               }
-
-               variable_substitute(mbox, dst, sizeof(dst));
-               obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
-               obj->data.local_mail.interval = n1;
-       END OBJ(unseen_mails, 0)
-               float n1;
-               char mbox[256], dst[256];
-
-               if (!arg) {
-                       n1 = 9.5;
-                       strncpy(mbox, current_mail_spool, sizeof(mbox));
-               } else {
-                       if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
-                               n1 = 9.5;
-                               strncpy(mbox, arg, sizeof(mbox));
-                       }
-               }
-
-               variable_substitute(mbox, dst, sizeof(dst));
-               obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
-               obj->data.local_mail.interval = n1;
+               parse_local_mail_args(obj, arg);
+       END OBJ(seen_mails, 0)
+               parse_local_mail_args(obj, arg);
+       END OBJ(unseen_mails, 0)
+               parse_local_mail_args(obj, arg);
        END OBJ(flagged_mails, 0)
-               float n1;
-               char mbox[256], dst[256];
-
-               if (!arg) {
-                       n1 = 9.5;
-                       strncpy(mbox, current_mail_spool, sizeof(mbox));
-               } else {
-                       if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
-                               n1 = 9.5;
-                               strncpy(mbox, arg, sizeof(mbox));
-                       }
-               }
-
-               variable_substitute(mbox, dst, sizeof(dst));
-               obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
-               obj->data.local_mail.interval = n1;
+               parse_local_mail_args(obj, arg);
        END OBJ(unflagged_mails, 0)
-               float n1;
-               char mbox[256], dst[256];
-
-               if (!arg) {
-                       n1 = 9.5;
-                       strncpy(mbox, current_mail_spool, sizeof(mbox));
-               } else {
-                       if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
-                               n1 = 9.5;
-                               strncpy(mbox, arg, sizeof(mbox));
-                       }
-               }
-
-               variable_substitute(mbox, dst, sizeof(dst));
-               obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
-               obj->data.local_mail.interval = n1;
+               parse_local_mail_args(obj, arg);
        END OBJ(forwarded_mails, 0)
-               float n1;
-               char mbox[256], dst[256];
-
-               if (!arg) {
-                       n1 = 9.5;
-                       strncpy(mbox, current_mail_spool, sizeof(mbox));
-               } else {
-                       if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
-                               n1 = 9.5;
-                               strncpy(mbox, arg, sizeof(mbox));
-                       }
-               }
-
-               variable_substitute(mbox, dst, sizeof(dst));
-               obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
-               obj->data.local_mail.interval = n1;
+               parse_local_mail_args(obj, arg);
        END OBJ(unforwarded_mails, 0)
-               float n1;
-               char mbox[256], dst[256];
-
-               if (!arg) {
-                       n1 = 9.5;
-                       strncpy(mbox, current_mail_spool, sizeof(mbox));
-               } else {
-                       if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
-                               n1 = 9.5;
-                               strncpy(mbox, arg, sizeof(mbox));
-                       }
-               }
-
-               variable_substitute(mbox, dst, sizeof(dst));
-               obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
-               obj->data.local_mail.interval = n1;
+               parse_local_mail_args(obj, arg);
        END OBJ(replied_mails, 0)
-               float n1;
-               char mbox[256], dst[256];
-
-               if (!arg) {
-                       n1 = 9.5;
-                       strncpy(mbox, current_mail_spool, sizeof(mbox));
-               } else {
-                       if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
-                               n1 = 9.5;
-                               strncpy(mbox, arg, sizeof(mbox));
-                       }
-               }
-
-               variable_substitute(mbox, dst, sizeof(dst));
-               obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
-               obj->data.local_mail.interval = n1;
+               parse_local_mail_args(obj, arg);
        END OBJ(unreplied_mails, 0)
-               float n1;
-               char mbox[256], dst[256];
-
-               if (!arg) {
-                       n1 = 9.5;
-                       strncpy(mbox, current_mail_spool, sizeof(mbox));
-               } else {
-                       if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
-                               n1 = 9.5;
-                               strncpy(mbox, arg, sizeof(mbox));
-                       }
-               }
-
-               variable_substitute(mbox, dst, sizeof(dst));
-               obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
-               obj->data.local_mail.interval = n1;
+               parse_local_mail_args(obj, arg);
        END OBJ(draft_mails, 0)
-               float n1;
-               char mbox[256], dst[256];
-
-               if (!arg) {
-                       n1 = 9.5;
-                       strncpy(mbox, current_mail_spool, sizeof(mbox));
-               } else {
-                       if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
-                               n1 = 9.5;
-                               strncpy(mbox, arg, sizeof(mbox));
-                       }
-               }
-
-               variable_substitute(mbox, dst, sizeof(dst));
-               obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
-               obj->data.local_mail.interval = n1;
+               parse_local_mail_args(obj, arg);
        END OBJ(trashed_mails, 0)
-               float n1;
-               char mbox[256], dst[256];
-
-               if (!arg) {
-                       n1 = 9.5;
-                       strncpy(mbox, current_mail_spool, sizeof(mbox));
-               } else {
-                       if (sscanf(arg, "%s %f", mbox, &n1) != 2) {
-                               n1 = 9.5;
-                               strncpy(mbox, arg, sizeof(mbox));
-                       }
-               }
-
-               variable_substitute(mbox, dst, sizeof(dst));
-               obj->data.local_mail.mbox = strndup(dst, text_buffer_size);
-               obj->data.local_mail.interval = n1;
+               parse_local_mail_args(obj, arg);
        END OBJ(mboxscan, 0)
-               obj->data.mboxscan.args = (char *) malloc(text_buffer_size);
-               obj->data.mboxscan.output = (char *) malloc(text_buffer_size);
-               /* if '1' (in mboxscan.c) then there was SIGUSR1, hmm */
-               obj->data.mboxscan.output[0] = 1;
-               strncpy(obj->data.mboxscan.args, arg, text_buffer_size);
-       END OBJ(mem, CALLBACK(&update_meminfo))
-       END OBJ(memeasyfree, CALLBACK(&update_meminfo))
-       END OBJ(memfree, CALLBACK(&update_meminfo))
-       END OBJ(memmax, CALLBACK(&update_meminfo))
-       END OBJ(memperc, CALLBACK(&update_meminfo))
+               parse_mboxscan_arg(obj, arg);
+       END OBJ(mem, &update_meminfo)
+       END OBJ(memeasyfree, &update_meminfo)
+       END OBJ(memfree, &update_meminfo)
+       END OBJ(memmax, &update_meminfo)
+       END OBJ(memperc, &update_meminfo)
 #ifdef X11
-       END OBJ(memgauge, CALLBACK(&update_meminfo))
-               SIZE_DEFAULTS(gauge);
-               scan_gauge(arg, &obj->data.pair.a, &obj->data.pair.b);
+       END OBJ(memgauge, &update_meminfo)
+               scan_gauge(obj, arg);
 #endif /* X11*/
-       END OBJ(membar, CALLBACK(&update_meminfo))
-               SIZE_DEFAULTS(bar);
-               scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+       END OBJ(membar, &update_meminfo)
+               scan_bar(obj, arg);
 #ifdef X11
-       END OBJ(memgraph, CALLBACK(&update_meminfo))
+       END OBJ(memgraph, &update_meminfo)
                char *buf = 0;
-               SIZE_DEFAULTS(graph);
-               buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
-                               &obj->e, &obj->char_a, &obj->char_b);
+               buf = scan_graph(obj, arg, 100);
 
                if (buf) free(buf);
 #endif /* X11*/
-       END OBJ(mixer, INFO_MIXER)
-               obj->data.l = mixer_init(arg);
-       END OBJ(mixerl, INFO_MIXER)
-               obj->data.l = mixer_init(arg);
-       END OBJ(mixerr, INFO_MIXER)
-               obj->data.l = mixer_init(arg);
+       END OBJ(mixer, 0)
+               parse_mixer_arg(obj, arg);
+       END OBJ(mixerl, 0)
+               parse_mixer_arg(obj, arg);
+       END OBJ(mixerr, 0)
+               parse_mixer_arg(obj, arg);
 #ifdef X11
-       END OBJ(mixerbar, INFO_MIXER)
-               SIZE_DEFAULTS(bar);
-               scan_mixer_bar(arg, &obj->data.mixerbar.l, &obj->data.mixerbar.w,
-                       &obj->data.mixerbar.h);
-       END OBJ(mixerlbar, INFO_MIXER)
-               SIZE_DEFAULTS(bar);
-               scan_mixer_bar(arg, &obj->data.mixerbar.l, &obj->data.mixerbar.w,
-                       &obj->data.mixerbar.h);
-       END OBJ(mixerrbar, INFO_MIXER)
-               SIZE_DEFAULTS(bar);
-               scan_mixer_bar(arg, &obj->data.mixerbar.l, &obj->data.mixerbar.w,
-                       &obj->data.mixerbar.h);
+       END OBJ(mixerbar, 0)
+               scan_mixer_bar(obj, arg);
+       END OBJ(mixerlbar, 0)
+               scan_mixer_bar(obj, arg);
+       END OBJ(mixerrbar, 0)
+               scan_mixer_bar(obj, arg);
 #endif
-       END OBJ_IF(if_mixer_mute, INFO_MIXER)
-               obj->data.ifblock.i = mixer_init(arg);
+       END OBJ_IF(if_mixer_mute, 0)
+               parse_mixer_arg(obj, arg);
 #ifdef X11
-       END OBJ(monitor, CALLBACK(&update_x11info))
-       END OBJ(monitor_number, CALLBACK(&update_x11info))
-       END OBJ(desktop, CALLBACK(&update_x11info))
-       END OBJ(desktop_number, CALLBACK(&update_x11info))
-       END OBJ(desktop_name, CALLBACK(&update_x11info))
+       END OBJ(monitor, &update_x11info)
+       END OBJ(monitor_number, &update_x11info)
+       END OBJ(desktop, &update_x11info)
+       END OBJ(desktop_number, &update_x11info)
+       END OBJ(desktop_name, &update_x11info)
 #endif
        END OBJ(nodename, 0)
-       END OBJ(processes, CALLBACK(&update_total_processes))
-       END OBJ(running_processes, CALLBACK(&update_running_processes))
+       END OBJ_ARG(pid_cmdline, 0, "pid_cmdline needs a pid as argument")
+               scan_pid_cmdline_arg(obj, arg, free_at_crash);
+       END OBJ_ARG(pid_cwd, 0, "pid_cwd needs a pid as argument")
+               scan_pid_cwd_arg(obj, arg, free_at_crash);
+       END OBJ_ARG(pid_environ, 0, "pid_environ needs arguments")
+               scan_pid_environ_arg(obj, arg, free_at_crash);
+       END OBJ_ARG(pid_environ_list, 0, "pid_environ_list needs a pid as argument")
+               scan_pid_environ_list_arg(obj, arg, free_at_crash);
+       END OBJ_ARG(pid_exe, 0, "pid_exe needs a pid as argument")
+               scan_pid_exe_arg(obj, arg, free_at_crash);
+       END OBJ_ARG(pid_openfiles, 0, "pid_openfiles needs a pid as argument")
+               scan_pid_openfiles_arg(obj, arg, free_at_crash);
+       END OBJ_ARG(pid_stderr, 0, "pid_stderr needs a pid as argument")
+               scan_pid_stderr_arg(obj, arg, free_at_crash);
+       END OBJ_ARG(pid_stdin, 0, "pid_stdin needs a pid as argument")
+               scan_pid_stdin_arg(obj, arg, free_at_crash);
+       END OBJ_ARG(pid_stdout, 0, "pid_stdout needs a pid as argument")
+               scan_pid_stdout_arg(obj, arg, free_at_crash);
+       END OBJ(processes, &update_total_processes)
+       END OBJ(running_processes, &update_running_processes)
+       END OBJ(threads, &update_threads)
        END OBJ(shadecolor, 0)
 #ifdef X11
                obj->data.l = arg ? get_x11_color(arg) : default_bg_color;
@@ -1433,151 +673,58 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
 #endif /* X11 */
        END OBJ(stippled_hr, 0)
 #ifdef X11
-               int a = get_stippled_borders(), b = 1;
-
-               if (arg) {
-                       if (sscanf(arg, "%d %d", &a, &b) != 2) {
-                               sscanf(arg, "%d", &b);
-                       }
-               }
-               if (a <= 0) {
-                       a = 1;
-               }
-               obj->data.pair.a = a;
-               obj->data.pair.b = b;
+               scan_stippled_hr(obj, arg);
 #endif /* X11 */
-       END OBJ(swap, CALLBACK(&update_meminfo))
-       END OBJ(swapfree, CALLBACK(&update_meminfo))
-       END OBJ(swapmax, CALLBACK(&update_meminfo))
-       END OBJ(swapperc, CALLBACK(&update_meminfo))
-       END OBJ(swapbar, CALLBACK(&update_meminfo))
-               SIZE_DEFAULTS(bar);
-               scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+       END OBJ(swap, &update_meminfo)
+       END OBJ(swapfree, &update_meminfo)
+       END OBJ(swapmax, &update_meminfo)
+       END OBJ(swapperc, &update_meminfo)
+       END OBJ(swapbar, &update_meminfo)
+               scan_bar(obj, arg);
        END OBJ(sysname, 0)
        END OBJ(time, 0)
-               obj->data.s = strndup(arg ? arg : "%F %T", text_buffer_size);
+               scan_time(obj, arg);
        END OBJ(utime, 0)
-               obj->data.s = strndup(arg ? arg : "%F %T", text_buffer_size);
+               scan_time(obj, arg);
        END OBJ(tztime, 0)
-               char buf1[256], buf2[256], *fmt, *tz;
-
-               fmt = tz = NULL;
-               if (arg) {
-                       int nArgs = sscanf(arg, "%255s %255[^\n]", buf1, buf2);
-
-                       switch (nArgs) {
-                               case 2:
-                                       tz = buf1;
-                               case 1:
-                                       fmt = buf2;
-                       }
-               }
-
-               obj->data.tztime.fmt = strndup(fmt ? fmt : "%F %T", text_buffer_size);
-               obj->data.tztime.tz = tz ? strndup(tz, text_buffer_size) : NULL;
+               scan_tztime(obj, arg);
 #ifdef HAVE_ICONV
-       END OBJ(iconv_start, 0)
-               if (is_iconv_converting()) {
-                       CRIT_ERR(obj, free_at_crash, "You must stop your last iconv conversion before "
-                               "starting another");
-               }
-               if (arg) {
-                       char iconv_from[ICONV_CODEPAGE_LENGTH];
-                       char iconv_to[ICONV_CODEPAGE_LENGTH];
-
-                       if (sscanf(arg, "%s %s", iconv_from, iconv_to) != 2) {
-                               CRIT_ERR(obj, free_at_crash, "Invalid arguments for iconv_start");
-                       } else {
-                               iconv_t new_iconv;
-
-                               new_iconv = iconv_open(iconv_to, iconv_from);
-                               if (new_iconv == (iconv_t) (-1)) {
-                                       NORM_ERR("Can't convert from %s to %s.", iconv_from, iconv_to);
-                               } else {
-                                       obj->a = register_iconv(&new_iconv);
-                                       set_iconv_converting(1);
-                               }
-                       }
-               } else {
-                       CRIT_ERR(obj, free_at_crash, "Iconv requires arguments");
-               }
+       END OBJ_ARG(iconv_start, 0, "Iconv requires arguments")
+               init_iconv_start(obj, free_at_crash, arg);
        END OBJ(iconv_stop, 0)
-               set_iconv_converting(0);
-
+               init_iconv_stop();
 #endif
-       END OBJ(totaldown, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
-       END OBJ(totalup, CALLBACK(&update_net_stats))
-               obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
+       END OBJ(totaldown, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
+       END OBJ(totalup, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
        END OBJ(updates, 0)
        END OBJ_IF(if_updatenr, 0)
-               obj->data.ifblock.i = arg ? atoi(arg) : 0;
-               if(obj->data.ifblock.i == 0) CRIT_ERR(obj, free_at_crash, "if_updatenr needs a number above 0 as argument");
-               set_updatereset(obj->data.ifblock.i > get_updatereset() ? obj->data.ifblock.i : get_updatereset());
+               obj->data.i = arg ? atoi(arg) : 0;
+               if(obj->data.i == 0) CRIT_ERR(obj, free_at_crash, "if_updatenr needs a number above 0 as argument");
+               set_updatereset(obj->data.i > get_updatereset() ? obj->data.i : get_updatereset());
        END OBJ(alignr, 0)
                obj->data.i = arg ? atoi(arg) : 0;
        END OBJ(alignc, 0)
                obj->data.i = arg ? atoi(arg) : 0;
-       END OBJ(upspeed, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
-       END OBJ(upspeedf, CALLBACK(&update_net_stats))
-               if (arg) {
-                       obj->data.net = get_net_stat(arg, obj, free_at_crash);
-               } else {
-                       // default to DEFAULTNETDEV
-                       char *buf = strndup(DEFAULTNETDEV, text_buffer_size);
-                       obj->data.net = get_net_stat(buf, obj, free_at_crash);
-                       free(buf);
-               }
-
+       END OBJ(upspeed, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
+       END OBJ(upspeedf, &update_net_stats)
+               parse_net_stat_arg(obj, arg, free_at_crash);
 #ifdef X11
-       END OBJ(upspeedgraph, CALLBACK(&update_net_stats))
-               char *buf = 0;
-               SIZE_DEFAULTS(graph);
-               buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
-                               &obj->e, &obj->char_a, &obj->char_b);
-
-               // default to DEFAULTNETDEV
-               buf = strndup(buf ? buf : DEFAULTNETDEV, text_buffer_size);
-               obj->data.net = get_net_stat(buf, obj, free_at_crash);
-               free(buf);
+       END OBJ(upspeedgraph, &update_net_stats)
+               parse_net_stat_graph_arg(obj, arg, free_at_crash);
 #endif
-       END OBJ(uptime_short, CALLBACK(&update_uptime))
-       END OBJ(uptime, CALLBACK(&update_uptime))
-       END OBJ(user_names, CALLBACK(&update_users))
-       END OBJ(user_times, CALLBACK(&update_users))
-       END OBJ(user_terms, CALLBACK(&update_users))
-       END OBJ(user_number, CALLBACK(&update_users))
+       END OBJ(uptime_short, &update_uptime)
+       END OBJ(uptime, &update_uptime)
+       END OBJ(user_names, &update_users)
+       END OBJ(user_times, &update_users)
+       END OBJ(user_terms, &update_users)
+       END OBJ(user_number, &update_users)
 #if defined(__linux__)
-       END OBJ(gw_iface, CALLBACK(&update_gateway_info))
-       END OBJ(gw_ip, CALLBACK(&update_gateway_info))
+       END OBJ(gw_iface, &update_gateway_info)
+       END OBJ(gw_ip, &update_gateway_info)
 #endif /* !__linux__ */
-#ifndef __OpenBSD__
-       END OBJ(adt746xcpu, 0)
-       END OBJ(adt746xfan, 0)
-#endif /* !__OpenBSD__ */
 #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
                || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
        END OBJ(apm_adapter, 0)
@@ -1585,78 +732,32 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        END OBJ(apm_battery_time, 0)
 #endif /* __FreeBSD__ */
        END OBJ(imap_unseen, 0)
-               if (arg) {
-                       // proccss
-                       obj->data.mail = parse_mail_args(IMAP_TYPE, arg);
-                       obj->char_b = 0;
-               } else {
-                       obj->char_b = 1;
-               }
+               parse_imap_mail_args(obj, arg);
        END OBJ(imap_messages, 0)
-               if (arg) {
-                       // proccss
-                       obj->data.mail = parse_mail_args(IMAP_TYPE, arg);
-                       obj->char_b = 0;
-               } else {
-                       obj->char_b = 1;
-               }
+               parse_imap_mail_args(obj, arg);
        END OBJ(pop3_unseen, 0)
-               if (arg) {
-                       // proccss
-                       obj->data.mail = parse_mail_args(POP3_TYPE, arg);
-                       obj->char_b = 0;
-               } else {
-                       obj->char_b = 1;
-               }
+               parse_pop3_mail_args(obj, arg);
        END OBJ(pop3_used, 0)
-               if (arg) {
-                       // proccss
-                       obj->data.mail = parse_mail_args(POP3_TYPE, arg);
-                       obj->char_b = 0;
-               } else {
-                       obj->char_b = 1;
-               }
+               parse_pop3_mail_args(obj, arg);
 #ifdef IBM
-       END OBJ(smapi, 0)
-               if (arg)
-                       obj->data.s = strndup(arg, text_buffer_size);
-               else
-                       NORM_ERR("smapi needs an argument");
-       END OBJ_IF(if_smapi_bat_installed, 0)
-               if (!arg) {
-                       NORM_ERR("if_smapi_bat_installed needs an argument");
-                       obj->data.ifblock.s = 0;
-               } else
-                       obj->data.ifblock.s = strndup(arg, text_buffer_size);
-       END OBJ(smapi_bat_perc, 0)
-               if (arg)
-                       obj->data.s = strndup(arg, text_buffer_size);
-               else
-                       NORM_ERR("smapi_bat_perc needs an argument");
-       END OBJ(smapi_bat_temp, 0)
-               if (arg)
-                       obj->data.s = strndup(arg, text_buffer_size);
-               else
-                       NORM_ERR("smapi_bat_temp needs an argument");
-       END OBJ(smapi_bat_power, 0)
-               if (arg)
-                       obj->data.s = strndup(arg, text_buffer_size);
-               else
-                       NORM_ERR("smapi_bat_power needs an argument");
+       END OBJ_ARG(smapi, 0, "smapi needs an argument")
+               obj->data.s = strndup(arg, text_buffer_size);
+       END OBJ_IF_ARG(if_smapi_bat_installed, 0, "if_smapi_bat_installed needs an argument")
+               obj->data.s = strndup(arg, text_buffer_size);
+       END OBJ_ARG(smapi_bat_perc, 0, "smapi_bat_perc needs an argument")
+               obj->data.s = strndup(arg, text_buffer_size);
+       END OBJ_ARG(smapi_bat_temp, 0, "smapi_bat_temp needs an argument")
+               obj->data.s = strndup(arg, text_buffer_size);
+       END OBJ_ARG(smapi_bat_power, 0, "smapi_bat_power needs an argument")
+               obj->data.s = strndup(arg, text_buffer_size);
 #ifdef X11
-       END OBJ(smapi_bat_bar, 0)
-               SIZE_DEFAULTS(bar);
-               if(arg) {
-                       int cnt;
-                       if(sscanf(arg, "%i %n", &obj->data.i, &cnt) <= 0) {
-                               NORM_ERR("first argument to smapi_bat_bar must be an integer value");
-                               obj->data.i = -1;
-                       } else {
-                               obj->b = 4;
-                               arg = scan_bar(arg + cnt, &obj->a, &obj->b);
-                       }
+       END OBJ_ARG(smapi_bat_bar, 0, "smapi_bat_bar needs an argument")
+               int cnt;
+               if(sscanf(arg, "%i %n", &obj->data.i, &cnt) <= 0) {
+                       NORM_ERR("first argument to smapi_bat_bar must be an integer value");
+                       obj->data.i = -1;
                } else
-                       NORM_ERR("smapi_bat_bar needs an argument");
+                       arg = scan_bar(obj, arg + cnt);
 #endif /* X11 */
 #endif /* IBM */
 #ifdef MPD
@@ -1669,504 +770,245 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
                        else \
                                NORM_ERR(#name ": invalid length argument"); \
                }
-       END OBJ(mpd_artist, CALLBACK(&update_mpd))
+       END OBJ(mpd_artist, &update_mpd)
                mpd_set_maxlen(mpd_artist);
                init_mpd();
-       END OBJ(mpd_title, CALLBACK(&update_mpd))
+       END OBJ(mpd_title, &update_mpd)
                mpd_set_maxlen(mpd_title);
                init_mpd();
-       END OBJ(mpd_random, CALLBACK(&update_mpd)) init_mpd();
-       END OBJ(mpd_repeat, CALLBACK(&update_mpd)) init_mpd();
-       END OBJ(mpd_elapsed, CALLBACK(&update_mpd)) init_mpd();
-       END OBJ(mpd_length, CALLBACK(&update_mpd)) init_mpd();
-       END OBJ(mpd_track, CALLBACK(&update_mpd))
+       END OBJ(mpd_random, &update_mpd) init_mpd();
+       END OBJ(mpd_repeat, &update_mpd) init_mpd();
+       END OBJ(mpd_elapsed, &update_mpd) init_mpd();
+       END OBJ(mpd_length, &update_mpd) init_mpd();
+       END OBJ(mpd_track, &update_mpd)
                mpd_set_maxlen(mpd_track);
                init_mpd();
-       END OBJ(mpd_name, CALLBACK(&update_mpd))
+       END OBJ(mpd_name, &update_mpd)
                mpd_set_maxlen(mpd_name);
                init_mpd();
-       END OBJ(mpd_file, CALLBACK(&update_mpd))
+       END OBJ(mpd_file, &update_mpd)
                mpd_set_maxlen(mpd_file);
                init_mpd();
-       END OBJ(mpd_percent, CALLBACK(&update_mpd)) init_mpd();
-       END OBJ(mpd_album, CALLBACK(&update_mpd))
+       END OBJ(mpd_percent, &update_mpd) init_mpd();
+       END OBJ(mpd_album, &update_mpd)
                mpd_set_maxlen(mpd_album);
                init_mpd();
-       END OBJ(mpd_vol, CALLBACK(&update_mpd)) init_mpd();
-       END OBJ(mpd_bitrate, CALLBACK(&update_mpd)) init_mpd();
-       END OBJ(mpd_status, CALLBACK(&update_mpd)) init_mpd();
-       END OBJ(mpd_bar, CALLBACK(&update_mpd))
-               SIZE_DEFAULTS(bar);
-               scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+       END OBJ(mpd_vol, &update_mpd) init_mpd();
+       END OBJ(mpd_bitrate, &update_mpd) init_mpd();
+       END OBJ(mpd_status, &update_mpd) init_mpd();
+       END OBJ(mpd_bar, &update_mpd)
+               scan_bar(obj, arg);
                init_mpd();
-       END OBJ(mpd_smart, CALLBACK(&update_mpd))
+       END OBJ(mpd_smart, &update_mpd)
                mpd_set_maxlen(mpd_smart);
                init_mpd();
-       END OBJ_IF(if_mpd_playing, CALLBACK(&update_mpd))
+       END OBJ_IF(if_mpd_playing, &update_mpd)
                init_mpd();
 #undef mpd_set_maxlen
 #endif /* MPD */
 #ifdef MOC
-       END OBJ(moc_state, CALLBACK(&update_moc))
-       END OBJ(moc_file, CALLBACK(&update_moc))
-       END OBJ(moc_title, CALLBACK(&update_moc))
-       END OBJ(moc_artist, CALLBACK(&update_moc))
-       END OBJ(moc_song, CALLBACK(&update_moc))
-       END OBJ(moc_album, CALLBACK(&update_moc))
-       END OBJ(moc_totaltime, CALLBACK(&update_moc))
-       END OBJ(moc_timeleft, CALLBACK(&update_moc))
-       END OBJ(moc_curtime, CALLBACK(&update_moc))
-       END OBJ(moc_bitrate, CALLBACK(&update_moc))
-       END OBJ(moc_rate, CALLBACK(&update_moc))
+       END OBJ(moc_state, &update_moc)
+       END OBJ(moc_file, &update_moc)
+       END OBJ(moc_title, &update_moc)
+       END OBJ(moc_artist, &update_moc)
+       END OBJ(moc_song, &update_moc)
+       END OBJ(moc_album, &update_moc)
+       END OBJ(moc_totaltime, &update_moc)
+       END OBJ(moc_timeleft, &update_moc)
+       END OBJ(moc_curtime, &update_moc)
+       END OBJ(moc_bitrate, &update_moc)
+       END OBJ(moc_rate, &update_moc)
 #endif /* MOC */
 #ifdef XMMS2
-       END OBJ(xmms2_artist, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_album, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_title, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_genre, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_comment, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_url, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_tracknr, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_bitrate, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_date, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_id, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_duration, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_elapsed, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_size, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_status, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_percent, CALLBACK(&update_xmms2))
+       END OBJ(xmms2_artist, &update_xmms2)
+       END OBJ(xmms2_album, &update_xmms2)
+       END OBJ(xmms2_title, &update_xmms2)
+       END OBJ(xmms2_genre, &update_xmms2)
+       END OBJ(xmms2_comment, &update_xmms2)
+       END OBJ(xmms2_url, &update_xmms2)
+       END OBJ(xmms2_tracknr, &update_xmms2)
+       END OBJ(xmms2_bitrate, &update_xmms2)
+       END OBJ(xmms2_date, &update_xmms2)
+       END OBJ(xmms2_id, &update_xmms2)
+       END OBJ(xmms2_duration, &update_xmms2)
+       END OBJ(xmms2_elapsed, &update_xmms2)
+       END OBJ(xmms2_size, &update_xmms2)
+       END OBJ(xmms2_status, &update_xmms2)
+       END OBJ(xmms2_percent, &update_xmms2)
 #ifdef X11
-       END OBJ(xmms2_bar, CALLBACK(&update_xmms2))
-               SIZE_DEFAULTS(bar);
-               scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+       END OBJ(xmms2_bar, &update_xmms2)
+               scan_bar(obj, arg);
 #endif /* X11 */
-       END OBJ(xmms2_smart, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_playlist, CALLBACK(&update_xmms2))
-       END OBJ(xmms2_timesplayed, CALLBACK(&update_xmms2))
-       END OBJ_IF(if_xmms2_connected, CALLBACK(&update_xmms2))
+       END OBJ(xmms2_smart, &update_xmms2)
+       END OBJ(xmms2_playlist, &update_xmms2)
+       END OBJ(xmms2_timesplayed, &update_xmms2)
+       END OBJ_IF(if_xmms2_connected, &update_xmms2)
 #endif
 #ifdef AUDACIOUS
-       END OBJ(audacious_status, CALLBACK(&update_audacious))
-       END OBJ(audacious_title, CALLBACK(&update_audacious))
-               if (arg) {
-                       sscanf(arg, "%d", &info.audacious.max_title_len);
-                       if (info.audacious.max_title_len > 0) {
-                               info.audacious.max_title_len++;
-                       } else {
-                               CRIT_ERR(obj, free_at_crash, "audacious_title: invalid length argument");
-                       }
-               }
-       END OBJ(audacious_length, CALLBACK(&update_audacious))
-       END OBJ(audacious_length_seconds, CALLBACK(&update_audacious))
-       END OBJ(audacious_position, CALLBACK(&update_audacious))
-       END OBJ(audacious_position_seconds, CALLBACK(&update_audacious))
-       END OBJ(audacious_bitrate, CALLBACK(&update_audacious))
-       END OBJ(audacious_frequency, CALLBACK(&update_audacious))
-       END OBJ(audacious_channels, CALLBACK(&update_audacious))
-       END OBJ(audacious_filename, CALLBACK(&update_audacious))
-       END OBJ(audacious_playlist_length, CALLBACK(&update_audacious))
-       END OBJ(audacious_playlist_position, CALLBACK(&update_audacious))
-       END OBJ(audacious_main_volume, CALLBACK(&update_audacious))
+       END OBJ(audacious_status, &update_audacious)
+       END OBJ_ARG(audacious_title, &update_audacious, "audacious_title needs an argument")
+               sscanf(arg, "%d", &info.audacious.max_title_len);
+               if (info.audacious.max_title_len > 0) {
+                       info.audacious.max_title_len++;
+               } else {
+                       CRIT_ERR(obj, free_at_crash, "audacious_title: invalid length argument");
+               }
+       END OBJ(audacious_length, &update_audacious)
+       END OBJ(audacious_length_seconds, &update_audacious)
+       END OBJ(audacious_position, &update_audacious)
+       END OBJ(audacious_position_seconds, &update_audacious)
+       END OBJ(audacious_bitrate, &update_audacious)
+       END OBJ(audacious_frequency, &update_audacious)
+       END OBJ(audacious_channels, &update_audacious)
+       END OBJ(audacious_filename, &update_audacious)
+       END OBJ(audacious_playlist_length, &update_audacious)
+       END OBJ(audacious_playlist_position, &update_audacious)
+       END OBJ(audacious_main_volume, &update_audacious)
 #ifdef X11
-       END OBJ(audacious_bar, CALLBACK(&update_audacious))
-               SIZE_DEFAULTS(bar);
-               scan_bar(arg, &obj->a, &obj->b);
+       END OBJ(audacious_bar, &update_audacious)
+               scan_bar(obj, arg);
 #endif /* X11 */
 #endif
 #ifdef BMPX
-       END OBJ(bmpx_title, CALLBACK(&update_bmpx))
+       END OBJ(bmpx_title, &update_bmpx)
                memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
-       END OBJ(bmpx_artist, CALLBACK(&update_bmpx))
+       END OBJ(bmpx_artist, &update_bmpx)
                memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
-       END OBJ(bmpx_album, CALLBACK(&update_bmpx))
+       END OBJ(bmpx_album, &update_bmpx)
                memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
-       END OBJ(bmpx_track, CALLBACK(&update_bmpx))
+       END OBJ(bmpx_track, &update_bmpx)
                memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
-       END OBJ(bmpx_uri, CALLBACK(&update_bmpx))
+       END OBJ(bmpx_uri, &update_bmpx)
                memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
-       END OBJ(bmpx_bitrate, CALLBACK(&update_bmpx))
+       END OBJ(bmpx_bitrate, &update_bmpx)
                memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
 #endif
 #ifdef EVE
-       END OBJ(eve, 0)
-               if(arg) {
-                       int argc;
-                       char *userid = (char *) malloc(20 * sizeof(char));
-                       char *apikey = (char *) malloc(64 * sizeof(char));
-                       char *charid = (char *) malloc(20 * sizeof(char));
-
-                       argc = sscanf(arg, "%20s %64s %20s", userid, apikey, charid);
-                       obj->data.eve.charid = charid;
-                       obj->data.eve.userid = userid;
-                       obj->data.eve.apikey = apikey;
-
-                       init_eve();
-               } else {
-                       CRIT_ERR(obj, free_at_crash, "eve needs arguments: <userid> <apikey> <characterid>");
-               }
+       END OBJ_ARG(eve, 0, "eve needs arguments: <userid> <apikey> <characterid>")
+               scan_eve(obj, arg);
 #endif
 #ifdef HAVE_CURL
-       END OBJ(curl, 0)
-               if (arg) {
-                       int argc;
-                       float interval = 0;
-                       char *uri = (char *) malloc(128 * sizeof(char));
-
-                       argc = sscanf(arg, "%127s %f", uri, &interval);
-                       if (argc == 2) {
-                               obj->data.curl.uri = uri;
-                               obj->data.curl.interval = interval > 0 ? interval * 60 : 15*60;
-                       } else {
-                               NORM_ERR("wrong number of arguments for $curl");
-                       }
-               } else {
-                       CRIT_ERR(obj, free_at_crash, "curl needs arguments: <uri> <interval in minutes>");
-               }
+       END OBJ_ARG(curl, 0, "curl needs arguments: <uri> <interval in minutes>")
+               curl_parse_arg(obj, arg);
 #endif
 #ifdef RSS
-       END OBJ(rss, 0)
-               if (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) {
-                               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");
-                       }
-               } else {
-                       CRIT_ERR(obj, free_at_crash, "rss needs arguments: <uri> <interval in minutes> <action> "
-                                       "[act_par] [spaces in front]");
-               }
+       END OBJ_ARG(rss, 0, "rss needs arguments: <uri> <interval in minutes> <action> [act_par] [spaces in front]")
+               rss_scan_arg(obj, arg);
 #endif
 #ifdef WEATHER
-       END OBJ(weather, 0)
-               if (arg) {
-                       int argc;
-                       float interval = 0;
-                       char *locID = (char *) malloc(9 * sizeof(char));
-                       char *uri = (char *) malloc(128 * sizeof(char));
-                       char *data_type = (char *) malloc(32 * sizeof(char));
-
-                       argc = sscanf(arg, "%119s %8s %31s %f", uri, locID, data_type, &interval);
-
-                       if (argc >= 3) {
-                               if (process_weather_uri(uri, locID, 0)) {
-                                       free(data_type);
-                                       free(uri);
-                                       free(locID);
-                                       CRIT_ERR(obj, free_at_crash, \
-                                                       "could not recognize the weather uri");
-                               }
-
-                               obj->data.weather.uri = uri;
-                               obj->data.weather.data_type = data_type;
-
-                               /* Limit the data retrieval interval to half hour min */
-                               if (interval < 30) {
-                                       interval = 30;
-                               }
-
-                               /* Convert to seconds */
-                               obj->data.weather.interval = interval * 60;
-                               free(locID);
-
-                               DBGP("weather: fetching %s from %s every %d seconds", \
-                                               data_type, uri, obj->data.weather.interval);
-                       } else {
-                               free(data_type);
-                               free(uri);
-                               free(locID);
-                               CRIT_ERR(obj, free_at_crash, "wrong number of arguments for $weather");
-                       }
-               } else {
-                       CRIT_ERR(obj, free_at_crash, "weather needs arguments: <uri> <locID> <data_type> [interval in minutes]");
-               }
+       END OBJ_ARG(weather, 0, "weather needs arguments: <uri> <locID> <data_type> [interval in minutes]")
+               scan_weather_arg(obj, arg, free_at_crash);
 #endif
 #ifdef XOAP
-       END OBJ(weather_forecast, 0)
-               if (arg) {
-                       int argc;
-                       unsigned int day;
-                       float interval = 0;
-                       char *locID = (char *) malloc(9 * sizeof(char));
-                       char *uri = (char *) malloc(128 * sizeof(char));
-                       char *data_type = (char *) malloc(32 * sizeof(char));
-
-                       argc = sscanf(arg, "%119s %8s %1u %31s %f", uri, locID, &day, data_type, &interval);
-
-                       if (argc >= 4) {
-                               if (process_weather_uri(uri, locID, 1)) {
-                                       free(data_type);
-                                       free(uri);
-                                       free(locID);
-                                       CRIT_ERR(obj, free_at_crash, \
-                                                       "could not recognize the weather forecast uri");
-                               }
-
-                               obj->data.weather_forecast.uri = uri;
-                               obj->data.weather_forecast.data_type = data_type;
-
-                               /* Limit the day between 0 (today) and FORECAST_DAYS */
-                               if (day >= FORECAST_DAYS) {
-                                       day = FORECAST_DAYS-1;
-                               }
-                               obj->data.weather_forecast.day = day;
-
-                               /* Limit the data retrieval interval to 3 hours and an half */
-                               if (interval < 210) {
-                                       interval = 210;
-                               }
-
-                               /* Convert to seconds */
-                               obj->data.weather_forecast.interval = interval * 60;
-                               free(locID);
-
-                               DBGP("weather_forecast: fetching %s for day %d from %s every %d seconds", \
-                                        data_type, day, uri, obj->data.weather_forecast.interval);
-                       } else {
-                               free(data_type);
-                               free(uri);
-                               free(locID);
-                               CRIT_ERR(obj, free_at_crash, "wrong number of arguments for $weather_forecast");
-                       }
-               } else {
-                       CRIT_ERR(obj, free_at_crash, "weather_forecast needs arguments: <uri> <locID> <day> <data_type> [interval in minutes]");
-               }
+       END OBJ_ARG(weather_forecast, 0, "weather_forecast needs arguments: <uri> <locID> <day> <data_type> [interval in minutes]")
+               scan_weather_forecast_arg(obj, arg, free_at_crash);
 #endif
 #ifdef HAVE_LUA
-       END OBJ(lua, 0)
-               if (arg) {
-                       obj->data.s = strndup(arg, text_buffer_size);
-               } else {
-                       CRIT_ERR(obj, free_at_crash, "lua needs arguments: <function name> [function parameters]");
-               }
-       END OBJ(lua_parse, 0)
-               if (arg) {
+       END OBJ_ARG(lua, 0, "lua needs arguments: <function name> [function parameters]")
+               obj->data.s = strndup(arg, text_buffer_size);
+       END OBJ_ARG(lua_parse, 0, "lua_parse needs arguments: <function name> [function parameters]")
+               obj->data.s = strndup(arg, text_buffer_size);
+       END OBJ_ARG(lua_bar, 0, "lua_bar needs arguments: <height>,<width> <function name> [function parameters]")
+               arg = scan_bar(obj, arg);
+               if(arg) {
                        obj->data.s = strndup(arg, text_buffer_size);
                } else {
-                       CRIT_ERR(obj, free_at_crash, "lua_parse needs arguments: <function name> [function parameters]");
-               }
-       END OBJ(lua_bar, 0)
-               SIZE_DEFAULTS(bar);
-               if (arg) {
-                       arg = scan_bar(arg, &obj->a, &obj->b);
-                       if(arg) {
-                               obj->data.s = strndup(arg, text_buffer_size);
-                       } else {
-                               CRIT_ERR(obj, free_at_crash, "lua_bar needs arguments: <height>,<width> <function name> [function parameters]");
-                       }
-               } else {
                        CRIT_ERR(obj, free_at_crash, "lua_bar needs arguments: <height>,<width> <function name> [function parameters]");
                }
 #ifdef X11
-       END OBJ(lua_graph, 0)
-               SIZE_DEFAULTS(graph);
-               if (arg) {
-                       char *buf = 0;
-                       buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
-                                       &obj->e, &obj->char_a, &obj->char_b);
-                       if (buf) {
-                               obj->data.s = buf;
-                       } else {
-                               CRIT_ERR(obj, free_at_crash, "lua_graph needs arguments: <function name> [height],[width] [gradient colour 1] [gradient colour 2] [scale] [-t] [-l]");
-                       }
+       END OBJ_ARG(lua_graph, 0, "lua_graph needs arguments: <function name> [height],[width] [gradient colour 1] [gradient colour 2] [scale] [-t] [-l]")
+               char *buf = 0;
+               buf = scan_graph(obj, arg, 0);
+               if (buf) {
+                       obj->data.s = buf;
                } else {
                        CRIT_ERR(obj, free_at_crash, "lua_graph needs arguments: <function name> [height],[width] [gradient colour 1] [gradient colour 2] [scale] [-t] [-l]");
-       }
-       END OBJ(lua_gauge, 0)
-               SIZE_DEFAULTS(gauge);
+               }
+       END OBJ_ARG(lua_gauge, 0, "lua_gauge needs arguments: <height>,<width> <function name> [function parameters]")
+               arg = scan_gauge(obj, arg);
                if (arg) {
-                       arg = scan_gauge(arg, &obj->a, &obj->b);
-                       if (arg) {
-                               obj->data.s = strndup(arg, text_buffer_size);
-                       } else {
-                               CRIT_ERR(obj, free_at_crash, "lua_gauge needs arguments: <height>,<width> <function name> [function parameters]");
-                       }
+                       obj->data.s = strndup(arg, text_buffer_size);
                } else {
                        CRIT_ERR(obj, free_at_crash, "lua_gauge needs arguments: <height>,<width> <function name> [function parameters]");
                }
 #endif /* X11 */
 #endif /* HAVE_LUA */
 #ifdef HDDTEMP
-       END OBJ(hddtemp, CALLBACK(&update_hddtemp))
+       END OBJ(hddtemp, &update_hddtemp)
                if (arg)
                        obj->data.s = strndup(arg, text_buffer_size);
 #endif /* HDDTEMP */
 #ifdef TCP_PORT_MONITOR
-       END OBJ(tcp_portmon, CALLBACK(&tcp_portmon_update))
-               tcp_portmon_init(arg, &obj->data.tcp_port_monitor);
+       END OBJ_ARG(tcp_portmon, &tcp_portmon_update, "tcp_portmon: needs arguments")
+               tcp_portmon_init(obj, arg);
 #endif /* TCP_PORT_MONITOR */
-       END OBJ(entropy_avail, CALLBACK(&update_entropy))
-       END OBJ(entropy_perc, CALLBACK(&update_entropy))
-       END OBJ(entropy_poolsize, CALLBACK(&update_entropy))
-       END OBJ(entropy_bar, CALLBACK(&update_entropy))
-               SIZE_DEFAULTS(bar);
-               scan_bar(arg, &obj->a, &obj->b);
-       END OBJ(include, 0)
-               if(arg) {
-                       struct conftree *leaf = conftree_add(currentconffile, arg);
-                       if(leaf) {
-                               if (load_config_file(arg) == TRUE) {
-                                       obj->sub = malloc(sizeof(struct text_object));
-                                       currentconffile = leaf;
-                                       extract_variable_text_internal(obj->sub, get_global_text());
-                                       currentconffile = leaf->back;
-                               } else {
-                                       NORM_ERR("Can't load configfile '%s'.", arg);
-                               }
-                       } else {
-                               NORM_ERR("You are trying to load '%s' recursively, I'm only going to load it once to prevent an infinite loop.", arg);
-                       }
-               } else {
-                       CRIT_ERR(obj, free_at_crash, "include needs a argument");
-               }
-       END OBJ(blink, 0)
-               if(arg) {
-                       obj->sub = malloc(sizeof(struct text_object));
-                       extract_variable_text_internal(obj->sub, arg);
-               }else{
-                       CRIT_ERR(obj, free_at_crash, "blink needs a argument");
-               }
-       END OBJ(to_bytes, 0)
-               if(arg) {
-                       obj->sub = malloc(sizeof(struct text_object));
-                       extract_variable_text_internal(obj->sub, arg);
-               }else{
-                       CRIT_ERR(obj, free_at_crash, "to_bytes needs a argument");
-               }
-       END OBJ(scroll, 0)
-               int n1 = 0, n2 = 0;
-
-               obj->data.scroll.resetcolor = get_current_text_color();
-               obj->data.scroll.step = 1;
-               if (arg && sscanf(arg, "%u %n", &obj->data.scroll.show, &n1) > 0) {
-                       sscanf(arg + n1, "%u %n", &obj->data.scroll.step, &n2);
-                       if (*(arg + n1 + n2)) {
-                               n1 += n2;
-                       } else {
-                               obj->data.scroll.step = 1;
-                       }
-                       obj->data.scroll.text = malloc(strlen(arg + n1) + obj->data.scroll.show + 1);
-                       for(n2 = 0; (unsigned int) n2 < obj->data.scroll.show; n2++) {
-                               obj->data.scroll.text[n2] = ' ';
-                       }
-                       obj->data.scroll.text[n2] = 0;
-                       strcat(obj->data.scroll.text, arg + n1);
-                       obj->data.scroll.start = 0;
-                       obj->sub = malloc(sizeof(struct text_object));
-                       extract_variable_text_internal(obj->sub,
-                                       obj->data.scroll.text);
-               } else {
-                       CRIT_ERR(obj, free_at_crash, "scroll needs arguments: <length> [<step>] <text>");
-               }
-       END OBJ(combine, 0)
-               if(arg) {
-                       unsigned int i,j;
-                       unsigned int indenting = 0;     //vars can be used as args for other vars
-                       int startvar[2];
-                       int endvar[2];
-                       startvar[0] = endvar[0] = startvar[1] = endvar[1] = -1;
-                       j=0;
-                       for (i=0; arg[i] != 0 && j < 2; i++) {
-                               if(startvar[j] == -1) {
-                                       if(arg[i] == '$') {
-                                               startvar[j] = i;
-                                       }
-                               }else if(endvar[j] == -1) {
-                                       if(arg[i] == '{') {
-                                               indenting++;
-                                       }else if(arg[i] == '}') {
-                                               indenting--;
-                                       }
-                                       if (indenting == 0 && arg[i+1] < 48) {  //<48 has 0, $, and the most used chars not used in varnames but not { or }
-                                               endvar[j]=i+1;
-                                               j++;
-                                       }
-                               }
-                       }
-                       if(startvar[0] >= 0 && endvar[0] >= 0 && startvar[1] >= 0 && endvar[1] >= 0) {
-                               obj->data.combine.left = malloc(endvar[0]-startvar[0] + 1);
-                               obj->data.combine.seperation = malloc(startvar[1] - endvar[0] + 1);
-                               obj->data.combine.right= malloc(endvar[1]-startvar[1] + 1);
-
-                               strncpy(obj->data.combine.left, arg + startvar[0], endvar[0] - startvar[0]);
-                               obj->data.combine.left[endvar[0] - startvar[0]] = 0;
-
-                               strncpy(obj->data.combine.seperation, arg + endvar[0], startvar[1] - endvar[0]);
-                               obj->data.combine.seperation[startvar[1] - endvar[0]] = 0;
-
-                               strncpy(obj->data.combine.right, arg + startvar[1], endvar[1] - startvar[1]);
-                               obj->data.combine.right[endvar[1] - startvar[1]] = 0;
-
+       END OBJ(entropy_avail, &update_entropy)
+       END OBJ(entropy_perc, &update_entropy)
+       END OBJ(entropy_poolsize, &update_entropy)
+       END OBJ(entropy_bar, &update_entropy)
+               scan_bar(obj, arg);
+       END OBJ_ARG(include, 0, "include needs a argument")
+               struct conftree *leaf = conftree_add(currentconffile, arg);
+               if(leaf) {
+                       if (load_config_file(arg) == TRUE) {
                                obj->sub = malloc(sizeof(struct text_object));
-                               extract_variable_text_internal(obj->sub, obj->data.combine.left);
-                               obj->sub->sub = malloc(sizeof(struct text_object));
-                               extract_variable_text_internal(obj->sub->sub, obj->data.combine.right);
+                               currentconffile = leaf;
+                               extract_variable_text_internal(obj->sub, get_global_text());
+                               currentconffile = leaf->back;
                        } else {
-                               CRIT_ERR(obj, free_at_crash, "combine needs arguments: <text1> <text2>");
+                               NORM_ERR("Can't load configfile '%s'.", arg);
                        }
                } else {
-                       CRIT_ERR(obj, free_at_crash, "combine needs arguments: <text1> <text2>");
+                       NORM_ERR("You are trying to load '%s' recursively, I'm only going to load it once to prevent an infinite loop.", arg);
                }
+       END OBJ_ARG(blink, 0, "blink needs a argument")
+               obj->sub = malloc(sizeof(struct text_object));
+               extract_variable_text_internal(obj->sub, arg);
+       END OBJ_ARG(to_bytes, 0, "to_bytes needs a argument")
+               obj->sub = malloc(sizeof(struct text_object));
+               extract_variable_text_internal(obj->sub, arg);
+       END OBJ(scroll, 0)
+               parse_scroll_arg(obj, arg, free_at_crash);
+       END OBJ_ARG(combine, 0, "combine needs arguments: <text1> <text2>")
+               parse_combine_arg(obj, arg, free_at_crash);
 #ifdef NVIDIA
-       END OBJ(nvidia, 0)
-               if (!arg) {
-                       CRIT_ERR(obj, free_at_crash, "nvidia needs an argument\n");
-               } else if (set_nvidia_type(&obj->data.nvidia, arg)) {
+       END OBJ_ARG(nvidia, 0, "nvidia needs an argument")
+               if (set_nvidia_type(obj, arg)) {
                        CRIT_ERR(obj, free_at_crash, "nvidia: invalid argument"
                                 " specified: '%s'\n", arg);
                }
 #endif /* NVIDIA */
 #ifdef APCUPSD
-               init_apcupsd();
-               END OBJ(apcupsd, CALLBACK(&update_apcupsd))
-                       if (arg) {
-                               char host[64];
-                               int port;
-                               if (sscanf(arg, "%63s %d", host, &port) != 2) {
-                                       CRIT_ERR(obj, free_at_crash, "apcupsd needs arguments: <host> <port>");
-                               } else {
-                                       info.apcupsd.port = htons(port);
-                                       strncpy(info.apcupsd.host, host, sizeof(info.apcupsd.host));
-                               }
-                       } else {
-                               CRIT_ERR(obj, free_at_crash, "apcupsd needs arguments: <host> <port>");
-                       }
-                       END OBJ(apcupsd_name, CALLBACK(&update_apcupsd))
-                       END OBJ(apcupsd_model, CALLBACK(&update_apcupsd))
-                       END OBJ(apcupsd_upsmode, CALLBACK(&update_apcupsd))
-                       END OBJ(apcupsd_cable, CALLBACK(&update_apcupsd))
-                       END OBJ(apcupsd_status, CALLBACK(&update_apcupsd))
-                       END OBJ(apcupsd_linev, CALLBACK(&update_apcupsd))
-                       END OBJ(apcupsd_load, CALLBACK(&update_apcupsd))
-                       END OBJ(apcupsd_loadbar, CALLBACK(&update_apcupsd))
-                               SIZE_DEFAULTS(bar);
-                               scan_bar(arg, &obj->a, &obj->b);
+       END OBJ_ARG(apcupsd, &update_apcupsd, "apcupsd needs arguments: <host> <port>")
+               char host[64];
+               int port;
+               if (sscanf(arg, "%63s %d", host, &port) != 2) {
+                       CRIT_ERR(obj, free_at_crash, "apcupsd needs arguments: <host> <port>");
+               } else {
+                       info.apcupsd.port = htons(port);
+                       strncpy(info.apcupsd.host, host, sizeof(info.apcupsd.host));
+               }
+       END OBJ(apcupsd_name, &update_apcupsd)
+       END OBJ(apcupsd_model, &update_apcupsd)
+       END OBJ(apcupsd_upsmode, &update_apcupsd)
+       END OBJ(apcupsd_cable, &update_apcupsd)
+       END OBJ(apcupsd_status, &update_apcupsd)
+       END OBJ(apcupsd_linev, &update_apcupsd)
+       END OBJ(apcupsd_load, &update_apcupsd)
+       END OBJ(apcupsd_loadbar, &update_apcupsd)
+               scan_bar(obj, arg);
 #ifdef X11
-                       END OBJ(apcupsd_loadgraph, CALLBACK(&update_apcupsd))
-                               char* buf = 0;
-                               SIZE_DEFAULTS(graph);
-                               buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
-                                               &obj->e, &obj->char_a, &obj->char_b);
-                               if (buf) free(buf);
-                       END OBJ(apcupsd_loadgauge, CALLBACK(&update_apcupsd))
-                               SIZE_DEFAULTS(gauge);
-                               scan_gauge(arg, &obj->a, &obj->b);
+       END OBJ(apcupsd_loadgraph, &update_apcupsd)
+               char* buf = 0;
+               buf = scan_graph(obj, arg, 0);
+               if (buf) free(buf);
+       END OBJ(apcupsd_loadgauge, &update_apcupsd)
+               scan_gauge(obj, arg);
 #endif /* X11 */
-                       END OBJ(apcupsd_charge, CALLBACK(&update_apcupsd))
-                       END OBJ(apcupsd_timeleft, CALLBACK(&update_apcupsd))
-                       END OBJ(apcupsd_temp, CALLBACK(&update_apcupsd))
-                       END OBJ(apcupsd_lastxfer, CALLBACK(&update_apcupsd))
+       END OBJ(apcupsd_charge, &update_apcupsd)
+       END OBJ(apcupsd_timeleft, &update_apcupsd)
+       END OBJ(apcupsd_temp, &update_apcupsd)
+       END OBJ(apcupsd_lastxfer, &update_apcupsd)
 #endif /* APCUPSD */
        END {
                char buf[256];
@@ -2177,6 +1019,13 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
                obj->data.s = strndup(buf, text_buffer_size);
        }
 #undef OBJ
+#undef OBJ_IF
+#undef OBJ_ARG
+#undef OBJ_IF_ARG
+#undef __OBJ_HEAD
+#undef __OBJ_IF
+#undef __OBJ_ARG
+#undef END
 
        return obj;
 }
@@ -2396,23 +1245,48 @@ void free_text_objects(struct text_object *root, int internal)
                        case OBJ_i2c:
                        case OBJ_platform:
                        case OBJ_hwmon:
-                               close(data.sysfs.fd);
+                               free_sysfs_sensor(obj);
                                break;
 #endif /* __linux__ */
+                       case OBJ_pid_cmdline:
+                               free(data.s);
+                               break;
+                       case OBJ_pid_cwd:
+                               free(data.s);
+                               break;
+                       case OBJ_pid_environ:
+                               free_pid_environ(obj);
+                               break;
+                       case OBJ_pid_environ_list:
+                               free(data.s);
+                               break;
+                       case OBJ_pid_exe:
+                               free(data.s);
+                               break;
+                       case OBJ_pid_openfiles:
+                               free(data.s);
+                               break;
+                       case OBJ_pid_stderr:
+                               free(data.s);
+                               break;
+                       case OBJ_pid_stdin:
+                               free(data.s);
+                               break;
+                       case OBJ_pid_stdout:
+                               free(data.s);
+                               break;
                        case OBJ_read_tcp:
-                               free(data.read_tcp.host);
+                               free_read_tcp(obj);
                                break;
                        case OBJ_time:
                        case OBJ_utime:
-                               free(data.s);
+                               free_time(obj);
                                break;
                        case OBJ_tztime:
-                               free(data.tztime.tz);
-                               free(data.tztime.fmt);
+                               free_tztime(obj);
                                break;
                        case OBJ_mboxscan:
-                               free(data.mboxscan.args);
-                               free(data.mboxscan.output);
+                               free_mboxscan(obj);
                                break;
                        case OBJ_mails:
                        case OBJ_new_mails:
@@ -2426,50 +1300,34 @@ void free_text_objects(struct text_object *root, int internal)
                        case OBJ_unreplied_mails:
                        case OBJ_draft_mails:
                        case OBJ_trashed_mails:
-                               free(data.local_mail.mbox);
+                               free_local_mails(obj);
                                break;
                        case OBJ_imap_unseen:
-                               if (!obj->char_b) {
-                                       free(data.mail);
-                               }
-                               break;
                        case OBJ_imap_messages:
-                               if (!obj->char_b) {
-                                       free(data.mail);
-                               }
-                               break;
                        case OBJ_pop3_unseen:
-                               if (!obj->char_b) {
-                                       free(data.mail);
-                               }
-                               break;
                        case OBJ_pop3_used:
-                               if (!obj->char_b) {
-                                       free(data.mail);
-                               }
+                               free_mail_obj(obj);
                                break;
                        case OBJ_if_empty:
                        case OBJ_if_match:
                                free_text_objects(obj->sub, 1);
                                free(obj->sub);
-                               /* fall through */
+                               break;
                        case OBJ_if_existing:
                        case OBJ_if_mounted:
                        case OBJ_if_running:
-                               free(data.ifblock.s);
-                               free(data.ifblock.str);
+                               free(data.s);
                                break;
                        case OBJ_head:
                        case OBJ_tail:
-                               free(data.headtail.logfile);
-                               if(data.headtail.buffer) {
-                                       free(data.headtail.buffer);
-                               }
+                               free_tailhead(obj);
                                break;
                        case OBJ_text:
                        case OBJ_font:
                        case OBJ_image:
                        case OBJ_eval:
+                               free(data.s);
+                               break;
                        case OBJ_exec:
                        case OBJ_execbar:
 #ifdef X11
@@ -2477,7 +1335,7 @@ void free_text_objects(struct text_object *root, int internal)
                        case OBJ_execgraph:
 #endif
                        case OBJ_execp:
-                               free(data.s);
+                               free_exec(obj);
                                break;
 #ifdef HAVE_ICONV
                        case OBJ_iconv_start:
@@ -2489,18 +1347,9 @@ void free_text_objects(struct text_object *root, int internal)
                                free(data.s);
                                break;
                        case OBJ_if_gw:
-                               free(data.ifblock.s);
-                               free(data.ifblock.str);
                        case OBJ_gw_iface:
                        case OBJ_gw_ip:
-                               if (info.gw_info.iface) {
-                                       free(info.gw_info.iface);
-                                       info.gw_info.iface = 0;
-                               }
-                               if (info.gw_info.ip) {
-                                       free(info.gw_info.ip);
-                                       info.gw_info.ip = 0;
-                               }
+                               free_gateway_info();
                                break;
                        case OBJ_ioscheduler:
                                if(data.s)
@@ -2509,8 +1358,7 @@ void free_text_objects(struct text_object *root, int internal)
 #endif
 #if (defined(__FreeBSD__) || defined(__linux__))
                        case OBJ_if_up:
-                               free(data.ifblock.s);
-                               free(data.ifblock.str);
+                               free_if_up(obj);
                                break;
 #endif
 #ifdef XMMS2
@@ -2594,29 +1442,27 @@ void free_text_objects(struct text_object *root, int internal)
 #endif
 #ifdef EVE
                        case OBJ_eve:
+                               free_eve(obj);
                                break;
 #endif
 #ifdef HAVE_CURL
                        case OBJ_curl:
-                               free(data.curl.uri);
+                               curl_obj_free(obj);
                                break;
 #endif
 #ifdef RSS
                        case OBJ_rss:
-                               free(data.rss.uri);
-                               free(data.rss.action);
+                               rss_free_obj_info(obj);
                                break;
 #endif
 #ifdef WEATHER
                        case OBJ_weather:
-                               free(data.weather.uri);
-                               free(data.weather.data_type);
+                               free_weather(obj);
                                break;
 #endif
 #ifdef XOAP
                        case OBJ_weather_forecast:
-                               free(data.weather_forecast.uri);
-                               free(data.weather_forecast.data_type);
+                               free_weather(obj);
                                break;
 #endif
 #ifdef HAVE_LUA
@@ -2646,17 +1492,12 @@ void free_text_objects(struct text_object *root, int internal)
                        case OBJ_execpi:
                        case OBJ_execi:
                        case OBJ_execibar:
+                       case OBJ_texeci:
 #ifdef X11
                        case OBJ_execigraph:
                        case OBJ_execigauge:
 #endif /* X11 */
-                               free(data.execi.cmd);
-                               free(data.execi.buffer);
-                               break;
-                       case OBJ_texeci:
-                               if (data.texeci.p_timed_thread) timed_thread_destroy(data.texeci.p_timed_thread, &data.texeci.p_timed_thread);
-                               free(data.texeci.cmd);
-                               free(data.texeci.buffer);
+                               free_execi(obj);
                                break;
                        case OBJ_nameserver:
                                free_dns_data();
@@ -2667,11 +1508,7 @@ void free_text_objects(struct text_object *root, int internal)
 #ifdef IOSTATS
                        case OBJ_top_io:
 #endif
-                               if (info.first_process && !internal) {
-                                       free_all_processes();
-                                       info.first_process = NULL;
-                               }
-                               if (data.top.s) free(data.top.s);
+                               free_top(obj, internal);
                                break;
 #ifdef HDDTEMP
                        case OBJ_hddtemp:
@@ -2713,12 +1550,12 @@ void free_text_objects(struct text_object *root, int internal)
                                free(data.s);
                                break;
                        case OBJ_if_smapi_bat_installed:
-                               free(data.ifblock.s);
-                               free(data.ifblock.str);
+                               free(data.s);
                                break;
 #endif /* IBM */
 #ifdef NVIDIA
                        case OBJ_nvidia:
+                               free_nvidia(obj);
                                break;
 #endif /* NVIDIA */
 #ifdef MPD
@@ -2766,16 +1603,10 @@ void free_text_objects(struct text_object *root, int internal)
                                }
                                break;
                        case OBJ_scroll:
-                               free(data.scroll.text);
-                               free_text_objects(obj->sub, 1);
-                               free(obj->sub);
+                               free_scroll(obj);
                                break;
                        case OBJ_combine:
-                               free(data.combine.left);
-                               free(data.combine.seperation);
-                               free(data.combine.right);
-                               free_text_objects(obj->sub, 1);
-                               free(obj->sub);
+                               free_combine(obj);
                                break;
 #ifdef APCUPSD
                        case OBJ_apcupsd:
@@ -2797,21 +1628,27 @@ void free_text_objects(struct text_object *root, int internal)
                        case OBJ_apcupsd_lastxfer:
                                break;
 #endif /* APCUPSD */
+#ifdef TCP_PORT_MONITOR
+                       case OBJ_tcp_portmon:
+                               tcp_portmon_free(obj);
+                               break;
+#endif /* TCP_PORT_MONITOR */
 #ifdef X11
                        case OBJ_desktop:
                        case OBJ_desktop_number:
                        case OBJ_desktop_name:
-                               if(info.x11.desktop.name) {
+                               if(info.x11.desktop.name && !internal) {
                                  free(info.x11.desktop.name);
                                  info.x11.desktop.name = NULL;
                                }
-                               if(info.x11.desktop.all_names) {
+                               if(info.x11.desktop.all_names && !internal) {
                                  free(info.x11.desktop.all_names);
                                  info.x11.desktop.all_names = NULL;
                                }
                                break;
 #endif /* X11 */
                }
+               if(obj->special_data) free(obj->special_data);
                free(obj);
        }
 #undef data