drop adt746x objects
[monky] / src / core.c
index 495cfb5..ce75e90 100644 (file)
@@ -36,7 +36,9 @@
 #include "colours.h"
 #include "combine.h"
 #include "diskio.h"
+#include "entropy.h"
 #include "exec.h"
+#include "proc.h"
 #ifdef X11
 #include "fonts.h"
 #endif
@@ -74,9 +76,6 @@
 #include "openbsd.h"
 #endif
 
-/* OS specific prototypes to be implemented by linux.c & Co. */
-void update_entropy(void);
-
 #include <string.h>
 #include <ctype.h>
 
@@ -163,50 +162,46 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
 #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, 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->data.i = atoi(&arg[0]);
                }
-               obj->a = 1;
        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, &update_net_stats)
@@ -269,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");
@@ -295,7 +288,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        END OBJ(i8k_buttons_status, &update_i8k)
 #if defined(IBM)
        END OBJ(ibm_fan, 0)
-       END OBJ(ibm_temps, &get_ibm_acpi_temps, "ibm_temps: needs an argument")
+       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)
@@ -321,30 +314,15 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
 #endif /* __linux__ */
 #if (defined(__FreeBSD__) || defined(__linux__))
        END OBJ_IF_ARG(if_up, 0, "if_up needs an argument")
-               obj->data.ifblock.s = strndup(arg, text_buffer_size);
+               parse_if_up_arg(obj, arg);
 #endif
 #if defined(__OpenBSD__)
        END OBJ_ARG(obsd_sensors_temp, 0, "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!");
-               } else
-                       obj->data.sensor = atoi(&arg[0]);
+               parse_obsd_sensor(obj, arg);
        END OBJ_ARG(obsd_sensors_fan, 0, "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!");
-               } else
-                       obj->data.sensor = atoi(&arg[0]);
+               parse_obsd_sensor(obj, arg);
        END OBJ_ARG(obsd_sensors_volt, 0, "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!");
-               } else
-                       obj->data.sensor = atoi(&arg[0]);
+               parse_obsd_sensor(obj, arg);
        END OBJ(obsd_vendor, 0)
        END OBJ(obsd_product, 0)
 #endif /* __OpenBSD__ */
@@ -352,80 +330,47 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        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, &update_cpu_usage)
-               SCAN_CPU(arg, obj->data.cpu_index);
-               DBGP2("Adding $cpu for CPU %d", obj->data.cpu_index);
+               SCAN_CPU(arg, obj->data.i);
+               DBGP2("Adding $cpu for CPU %d", obj->data.i);
 #ifdef X11
        END OBJ(cpugauge, &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);
+               SCAN_CPU(arg, obj->data.i);
+               scan_gauge(obj, arg);
+               DBGP2("Adding $cpugauge for CPU %d", obj->data.i);
 #endif /* X11 */
        END OBJ(cpubar, &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);
+               SCAN_CPU(arg, obj->data.i);
+               scan_bar(obj, arg);
+               DBGP2("Adding $cpubar for CPU %d", obj->data.i);
 #ifdef X11
        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, &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);
-               }
+               scan_loadgraph_arg(obj, arg);
 #endif /* X11 */
        END OBJ(diskio, &update_diskio)
-               obj->data.diskio = prepare_diskio_stat(dev_name(arg));
+               parse_diskio_arg(obj, arg);
        END OBJ(diskio_read, &update_diskio)
-               obj->data.diskio = prepare_diskio_stat(dev_name(arg));
+               parse_diskio_arg(obj, arg);
        END OBJ(diskio_write, &update_diskio)
-               obj->data.diskio = prepare_diskio_stat(dev_name(arg));
+               parse_diskio_arg(obj, arg);
 #ifdef X11
        END OBJ(diskiograph, &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);
+               parse_diskiograph_arg(obj, arg);
        END OBJ(diskiograph_read, &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);
+               parse_diskiograph_arg(obj, arg);
        END OBJ(diskiograph_write, &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);
+               parse_diskiograph_arg(obj, arg);
 #endif /* X11 */
        END OBJ(color, 0)
 #ifdef X11
@@ -518,25 +463,19 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        END OBJ(execp, 0)
                scan_exec_arg(obj, arg);
        END OBJ(execbar, 0)
-               SIZE_DEFAULTS(bar);
                scan_exec_arg(obj, arg);
 #ifdef X11
        END OBJ(execgauge, 0)
-               SIZE_DEFAULTS(gauge);
                scan_exec_arg(obj, arg);
        END OBJ(execgraph, 0)
-               SIZE_DEFAULTS(graph);
-               scan_exec_arg(obj, arg);
+               scan_execgraph_arg(obj, arg);
 #endif /* X11 */
        END OBJ_ARG(execibar, 0, "execibar needs arguments")
-               SIZE_DEFAULTS(bar);
                scan_execi_arg(obj, arg);
 #ifdef X11
        END OBJ_ARG(execigraph, 0, "execigraph needs arguments")
-               SIZE_DEFAULTS(graph);
-               scan_execi_arg(obj, arg);
+               scan_execgraph_arg(obj, arg);
        END OBJ_ARG(execigauge, 0, "execigauge needs arguments")
-               SIZE_DEFAULTS(gauge);
                scan_execi_arg(obj, arg);
 #endif /* X11 */
        END OBJ_ARG(execi, 0, "execi needs arguments")
@@ -573,20 +512,10 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
                obj->data.i = arg ? atoi(arg) : 1;
        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_ARG(i2c, 0, "i2c needs arguments")
                parse_i2c_sensor(obj, arg);
@@ -621,55 +550,27 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        END OBJ_ARG(words, 0, "words needs a argument")
                obj->data.s = strndup(arg, text_buffer_size);
        END OBJ(loadavg, &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;
+               scan_loadavg_arg(obj, arg);
        END OBJ_IF_ARG(if_empty, 0, "if_empty needs an argument")
-               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);
+               extract_variable_text_internal(obj->sub, arg);
        END OBJ_IF_ARG(if_match, 0, "if_match needs arguments")
-               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);
+               extract_variable_text_internal(obj->sub, arg);
        END OBJ_IF_ARG(if_existing, 0, "if_existing needs an argument or two")
-               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);
+               obj->data.s = strndup(arg, text_buffer_size);
        END OBJ_IF_ARG(if_mounted, 0, "if_mounted needs an argument")
-               obj->data.ifblock.s = strndup(arg, text_buffer_size);
+               obj->data.s = strndup(arg, text_buffer_size);
 #ifdef __linux__
        END OBJ_IF_ARG(if_running, &update_top, "if_running needs an argument")
                top_running = 1;
-               obj->data.ifblock.s = strndup(arg, text_buffer_size);
+               obj->data.s = strndup(arg, text_buffer_size);
 #else
        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);
+               obj->data.s = strndup(buf, text_buffer_size);
 #endif
        END OBJ(kernel, 0)
        END OBJ(machine, 0)
@@ -698,11 +599,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        END OBJ(trashed_mails, 0)
                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);
+               parse_mboxscan_arg(obj, arg);
        END OBJ(mem, &update_meminfo)
        END OBJ(memeasyfree, &update_meminfo)
        END OBJ(memfree, &update_meminfo)
@@ -710,43 +607,33 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        END OBJ(memperc, &update_meminfo)
 #ifdef X11
        END OBJ(memgauge, &update_meminfo)
-               SIZE_DEFAULTS(gauge);
-               scan_gauge(arg, &obj->data.pair.a, &obj->data.pair.b);
+               scan_gauge(obj, arg);
 #endif /* X11*/
        END OBJ(membar, &update_meminfo)
-               SIZE_DEFAULTS(bar);
-               scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+               scan_bar(obj, arg);
 #ifdef X11
        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, 0)
-               obj->data.l = mixer_init(arg);
+               parse_mixer_arg(obj, arg);
        END OBJ(mixerl, 0)
-               obj->data.l = mixer_init(arg);
+               parse_mixer_arg(obj, arg);
        END OBJ(mixerr, 0)
-               obj->data.l = mixer_init(arg);
+               parse_mixer_arg(obj, arg);
 #ifdef X11
        END OBJ(mixerbar, 0)
-               SIZE_DEFAULTS(bar);
-               scan_mixer_bar(arg, &obj->data.mixerbar.l, &obj->data.mixerbar.w,
-                       &obj->data.mixerbar.h);
+               scan_mixer_bar(obj, arg);
        END OBJ(mixerlbar, 0)
-               SIZE_DEFAULTS(bar);
-               scan_mixer_bar(arg, &obj->data.mixerbar.l, &obj->data.mixerbar.w,
-                       &obj->data.mixerbar.h);
+               scan_mixer_bar(obj, arg);
        END OBJ(mixerrbar, 0)
-               SIZE_DEFAULTS(bar);
-               scan_mixer_bar(arg, &obj->data.mixerbar.l, &obj->data.mixerbar.w,
-                       &obj->data.mixerbar.h);
+               scan_mixer_bar(obj, arg);
 #endif
        END OBJ_IF(if_mixer_mute, 0)
-               obj->data.ifblock.i = mixer_init(arg);
+               parse_mixer_arg(obj, arg);
 #ifdef X11
        END OBJ(monitor, &update_x11info)
        END OBJ(monitor_number, &update_x11info)
@@ -755,8 +642,27 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        END OBJ(desktop_name, &update_x11info)
 #endif
        END OBJ(nodename, 0)
+       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;
@@ -767,26 +673,14 @@ 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, &update_meminfo)
        END OBJ(swapfree, &update_meminfo)
        END OBJ(swapmax, &update_meminfo)
        END OBJ(swapperc, &update_meminfo)
        END OBJ(swapbar, &update_meminfo)
-               SIZE_DEFAULTS(bar);
-               scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+               scan_bar(obj, arg);
        END OBJ(sysname, 0)
        END OBJ(time, 0)
                scan_time(obj, arg);
@@ -806,9 +700,9 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
                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)
@@ -831,10 +725,6 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        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)
@@ -853,7 +743,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        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.ifblock.s = strndup(arg, text_buffer_size);
+               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")
@@ -863,14 +753,11 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
 #ifdef X11
        END OBJ_ARG(smapi_bat_bar, 0, "smapi_bat_bar needs an argument")
                int cnt;
-               SIZE_DEFAULTS(bar);
                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);
-               }
+               } else
+                       arg = scan_bar(obj, arg + cnt);
 #endif /* X11 */
 #endif /* IBM */
 #ifdef MPD
@@ -910,8 +797,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        END OBJ(mpd_bitrate, &update_mpd) init_mpd();
        END OBJ(mpd_status, &update_mpd) init_mpd();
        END OBJ(mpd_bar, &update_mpd)
-               SIZE_DEFAULTS(bar);
-               scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+               scan_bar(obj, arg);
                init_mpd();
        END OBJ(mpd_smart, &update_mpd)
                mpd_set_maxlen(mpd_smart);
@@ -951,8 +837,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        END OBJ(xmms2_percent, &update_xmms2)
 #ifdef X11
        END OBJ(xmms2_bar, &update_xmms2)
-               SIZE_DEFAULTS(bar);
-               scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
+               scan_bar(obj, arg);
 #endif /* X11 */
        END OBJ(xmms2_smart, &update_xmms2)
        END OBJ(xmms2_playlist, &update_xmms2)
@@ -981,8 +866,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        END OBJ(audacious_main_volume, &update_audacious)
 #ifdef X11
        END OBJ(audacious_bar, &update_audacious)
-               SIZE_DEFAULTS(bar);
-               scan_bar(arg, &obj->a, &obj->b);
+               scan_bar(obj, arg);
 #endif /* X11 */
 #endif
 #ifdef BMPX
@@ -1025,8 +909,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        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]")
-               SIZE_DEFAULTS(bar);
-               arg = scan_bar(arg, &obj->a, &obj->b);
+               arg = scan_bar(obj, arg);
                if(arg) {
                        obj->data.s = strndup(arg, text_buffer_size);
                } else {
@@ -1035,17 +918,14 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
 #ifdef X11
        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;
-               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, 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_ARG(lua_gauge, 0, "lua_gauge needs arguments: <height>,<width> <function name> [function parameters]")
-               SIZE_DEFAULTS(gauge);
-               arg = scan_gauge(arg, &obj->a, &obj->b);
+               arg = scan_gauge(obj, arg);
                if (arg) {
                        obj->data.s = strndup(arg, text_buffer_size);
                } else {
@@ -1066,8 +946,7 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        END OBJ(entropy_perc, &update_entropy)
        END OBJ(entropy_poolsize, &update_entropy)
        END OBJ(entropy_bar, &update_entropy)
-               SIZE_DEFAULTS(bar);
-               scan_bar(arg, &obj->a, &obj->b);
+               scan_bar(obj, arg);
        END OBJ_ARG(include, 0, "include needs a argument")
                struct conftree *leaf = conftree_add(currentconffile, arg);
                if(leaf) {
@@ -1117,18 +996,14 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
        END OBJ(apcupsd_linev, &update_apcupsd)
        END OBJ(apcupsd_load, &update_apcupsd)
        END OBJ(apcupsd_loadbar, &update_apcupsd)
-               SIZE_DEFAULTS(bar);
-               scan_bar(arg, &obj->a, &obj->b);
+               scan_bar(obj, arg);
 #ifdef X11
        END OBJ(apcupsd_loadgraph, &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);
+               buf = scan_graph(obj, arg, 0);
                if (buf) free(buf);
        END OBJ(apcupsd_loadgauge, &update_apcupsd)
-               SIZE_DEFAULTS(gauge);
-               scan_gauge(arg, &obj->a, &obj->b);
+               scan_gauge(obj, arg);
 #endif /* X11 */
        END OBJ(apcupsd_charge, &update_apcupsd)
        END OBJ(apcupsd_timeleft, &update_apcupsd)
@@ -1151,7 +1026,6 @@ struct text_object *construct_text_object(const char *s, const char *arg, long
 #undef __OBJ_IF
 #undef __OBJ_ARG
 #undef END
-#undef SIZE_DEFAULTS
 
        return obj;
 }
@@ -1374,6 +1248,33 @@ void free_text_objects(struct text_object *root, int internal)
                                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_read_tcp(obj);
                                break;
@@ -1385,8 +1286,7 @@ void free_text_objects(struct text_object *root, int internal)
                                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:
@@ -1400,7 +1300,7 @@ 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:
                        case OBJ_imap_messages:
@@ -1412,12 +1312,11 @@ void free_text_objects(struct text_object *root, int internal)
                        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:
@@ -1427,6 +1326,8 @@ void free_text_objects(struct text_object *root, int internal)
                        case OBJ_font:
                        case OBJ_image:
                        case OBJ_eval:
+                               free(data.s);
+                               break;
                        case OBJ_exec:
                        case OBJ_execbar:
 #ifdef X11
@@ -1446,8 +1347,6 @@ 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:
                                free_gateway_info();
@@ -1459,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
@@ -1544,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
@@ -1612,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:
@@ -1658,8 +1550,7 @@ 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
@@ -1757,6 +1648,7 @@ void free_text_objects(struct text_object *root, int internal)
                                break;
 #endif /* X11 */
                }
+               if(obj->special_data) free(obj->special_data);
                free(obj);
        }
 #undef data