1 /* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*-
2 * vim: ts=4 sw=4 noet ai cindent syntax=c
4 * Conky, a system monitor, based on torsmo
6 * Any original torsmo code is licensed under the BSD license
8 * All code written since the fork of torsmo is licensed under the GPL
10 * Please see COPYING for details
12 * Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
13 * Copyright (c) 2005-2009 Brenden Matthews, Philip Kovacs, et. al.
15 * All rights reserved.
17 * This program is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program. If not, see <http://www.gnu.org/licenses/>.
33 #include "text_object.h"
45 #include "iconv_tools.h"
58 #include "temphelper.h"
68 /* check for OS and include appropriate headers */
69 #if defined(__linux__)
71 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
73 #elif defined(__OpenBSD__)
77 /* OS specific prototypes to be implemented by linux.c & Co. */
78 void update_entropy(void);
83 /* strip a leading /dev/ if any, following symlinks first
85 * BEWARE: this function returns a pointer to static content
86 * which gets overwritten in consecutive calls. I.e.:
87 * this function is NOT reentrant.
89 const char *dev_name(const char *path)
91 static char buf[255]; /* should be enough for pathnames */
98 x != NULL && strlen(x) > 5 && strncmp(x, "/dev/", 5) == 0 ? x + 5 : x
99 if ((buflen = readlink(path, buf, 254)) == -1)
100 return DEV_NAME(path);
102 return DEV_NAME(buf);
106 static struct text_object *new_text_object_internal(void)
108 struct text_object *obj = malloc(sizeof(struct text_object));
109 memset(obj, 0, sizeof(struct text_object));
113 static struct text_object *create_plain_text(const char *s)
115 struct text_object *obj;
117 if (s == NULL || *s == '\0') {
121 obj = new_text_object_internal();
123 obj->type = OBJ_text;
124 obj->data.s = strndup(s, text_buffer_size);
128 /* construct_text_object() creates a new text_object */
129 struct text_object *construct_text_object(const char *s, const char *arg, long
130 line, void **ifblock_opaque, void *free_at_crash)
132 // struct text_object *obj = new_text_object();
133 struct text_object *obj = new_text_object_internal();
137 /* helper defines for internal use only */
138 #define __OBJ_HEAD(a, n) if (!strcmp(s, #a)) { \
139 obj->type = OBJ_##a; add_update_callback(n);
140 #define __OBJ_IF obj_be_ifblock_if(ifblock_opaque, obj)
141 #define __OBJ_ARG(...) if (!arg) { CRIT_ERR(obj, free_at_crash, __VA_ARGS__); }
143 /* defines to be used below */
144 #define OBJ(a, n) __OBJ_HEAD(a, n) {
145 #define OBJ_ARG(a, n, ...) __OBJ_HEAD(a, n) __OBJ_ARG(__VA_ARGS__) {
146 #define OBJ_IF(a, n) __OBJ_HEAD(a, n) __OBJ_IF; {
147 #define OBJ_IF_ARG(a, n, ...) __OBJ_HEAD(a, n) __OBJ_ARG(__VA_ARGS__) __OBJ_IF; {
152 obj->type = OBJ_color;
153 obj->data.l = get_x11_color(s);
160 obj->data.i = open_acpi_temperature(arg);
161 END OBJ(acpiacadapter, 0)
163 #endif /* !__OpenBSD__ */
165 if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
166 || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
167 obj->data.cpu_index = 1;
168 /* NORM_ERR("freq: Invalid CPU number or you don't have that many CPUs! "
169 "Displaying the clock for CPU 1."); */
171 obj->data.cpu_index = atoi(&arg[0]);
176 if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
177 || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
178 obj->data.cpu_index = 1;
179 /* NORM_ERR("freq_g: Invalid CPU number or you don't have that many "
180 "CPUs! Displaying the clock for CPU 1."); */
182 obj->data.cpu_index = atoi(&arg[0]);
185 END OBJ_ARG(read_tcp, 0, "read_tcp: Needs \"(host) port\" as argument(s)")
186 parse_read_tcp_arg(obj, arg, free_at_crash);
187 #if defined(__linux__)
188 END OBJ(voltage_mv, 0)
190 if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
191 || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
192 obj->data.cpu_index = 1;
193 /* NORM_ERR("voltage_mv: Invalid CPU number or you don't have that many "
194 "CPUs! Displaying voltage for CPU 1."); */
196 obj->data.cpu_index = atoi(&arg[0]);
199 END OBJ(voltage_v, 0)
201 if (!arg || !isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) == 0
202 || (unsigned int) atoi(&arg[0]) > info.cpu_count) {
203 obj->data.cpu_index = 1;
204 /* NORM_ERR("voltage_v: Invalid CPU number or you don't have that many "
205 "CPUs! Displaying voltage for CPU 1."); */
207 obj->data.cpu_index = atoi(&arg[0]);
212 END OBJ(wireless_essid, &update_net_stats)
213 parse_net_stat_arg(obj, arg, free_at_crash);
214 END OBJ(wireless_mode, &update_net_stats)
215 parse_net_stat_arg(obj, arg, free_at_crash);
216 END OBJ(wireless_bitrate, &update_net_stats)
217 parse_net_stat_arg(obj, arg, free_at_crash);
218 END OBJ(wireless_ap, &update_net_stats)
219 parse_net_stat_arg(obj, arg, free_at_crash);
220 END OBJ(wireless_link_qual, &update_net_stats)
221 parse_net_stat_arg(obj, arg, free_at_crash);
222 END OBJ(wireless_link_qual_max, &update_net_stats)
223 parse_net_stat_arg(obj, arg, free_at_crash);
224 END OBJ(wireless_link_qual_perc, &update_net_stats)
225 parse_net_stat_arg(obj, arg, free_at_crash);
226 END OBJ(wireless_link_bar, &update_net_stats)
227 parse_net_stat_bar_arg(obj, arg, free_at_crash);
228 #endif /* HAVE_IWLIB */
230 #endif /* __linux__ */
238 sscanf(arg, "%63s", bat);
242 obj->data.s = strndup(bat, text_buffer_size);
243 END OBJ(battery_short, 0)
247 sscanf(arg, "%63s", bat);
251 obj->data.s = strndup(bat, text_buffer_size);
252 END OBJ(battery_time, 0)
256 sscanf(arg, "%63s", bat);
260 obj->data.s = strndup(bat, text_buffer_size);
261 END OBJ(battery_percent, 0)
265 sscanf(arg, "%63s", bat);
269 obj->data.s = strndup(bat, text_buffer_size);
270 END OBJ(battery_bar, 0)
275 arg = scan_bar(arg, &obj->a, &obj->b);
276 sscanf(arg, "%63s", bat);
280 obj->data.s = strndup(bat, text_buffer_size);
281 #endif /* !__OpenBSD__ */
283 #if defined(__linux__)
284 END OBJ_ARG(disk_protect, 0, "disk_protect needs an argument")
285 obj->data.s = strndup(dev_name(arg), text_buffer_size);
286 END OBJ(i8k_version, &update_i8k)
287 END OBJ(i8k_bios, &update_i8k)
288 END OBJ(i8k_serial, &update_i8k)
289 END OBJ(i8k_cpu_temp, &update_i8k)
290 END OBJ(i8k_left_fan_status, &update_i8k)
291 END OBJ(i8k_right_fan_status, &update_i8k)
292 END OBJ(i8k_left_fan_rpm, &update_i8k)
293 END OBJ(i8k_right_fan_rpm, &update_i8k)
294 END OBJ(i8k_ac_status, &update_i8k)
295 END OBJ(i8k_buttons_status, &update_i8k)
298 END OBJ(ibm_temps, &get_ibm_acpi_temps, "ibm_temps: needs an argument")
299 parse_ibm_temps_arg(obj, arg);
300 END OBJ(ibm_volume, 0)
301 END OBJ(ibm_brightness, 0)
303 /* information from sony_laptop kernel module
304 * /sys/devices/platform/sony-laptop */
305 END OBJ(sony_fanspeed, 0)
306 END OBJ_IF(if_gw, &update_gateway_info)
307 END OBJ_ARG(ioscheduler, 0, "get_ioscheduler needs an argument (e.g. hda)")
308 obj->data.s = strndup(dev_name(arg), text_buffer_size);
309 END OBJ(laptop_mode, 0)
310 END OBJ_ARG(pb_battery, 0, "pb_battery: needs one argument: status, percent or time")
311 if (strcmp(arg, "status") == EQUAL) {
312 obj->data.i = PB_BATT_STATUS;
313 } else if (strcmp(arg, "percent") == EQUAL) {
314 obj->data.i = PB_BATT_PERCENT;
315 } else if (strcmp(arg, "time") == EQUAL) {
316 obj->data.i = PB_BATT_TIME;
318 NORM_ERR("pb_battery: illegal argument '%s', defaulting to status", arg);
319 obj->data.i = PB_BATT_STATUS;
321 #endif /* __linux__ */
322 #if (defined(__FreeBSD__) || defined(__linux__))
323 END OBJ_IF_ARG(if_up, 0, "if_up needs an argument")
324 obj->data.ifblock.s = strndup(arg, text_buffer_size);
326 #if defined(__OpenBSD__)
327 END OBJ_ARG(obsd_sensors_temp, 0, "obsd_sensors_temp: needs an argument")
328 if (!isdigit(arg[0]) || atoi(&arg[0]) < 0
329 || atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) {
330 obj->data.sensor = 0;
331 NORM_ERR("Invalid temperature sensor number!");
333 obj->data.sensor = atoi(&arg[0]);
334 END OBJ_ARG(obsd_sensors_fan, 0, "obsd_sensors_fan: needs 2 arguments (device and sensor number)")
335 if (!isdigit(arg[0]) || atoi(&arg[0]) < 0
336 || atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) {
337 obj->data.sensor = 0;
338 NORM_ERR("Invalid fan sensor number!");
340 obj->data.sensor = atoi(&arg[0]);
341 END OBJ_ARG(obsd_sensors_volt, 0, "obsd_sensors_volt: needs 2 arguments (device and sensor number)")
342 if (!isdigit(arg[0]) || atoi(&arg[0]) < 0
343 || atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) {
344 obj->data.sensor = 0;
345 NORM_ERR("Invalid voltage sensor number!");
347 obj->data.sensor = atoi(&arg[0]);
348 END OBJ(obsd_vendor, 0)
349 END OBJ(obsd_product, 0)
350 #endif /* __OpenBSD__ */
351 END OBJ(buffers, &update_meminfo)
352 END OBJ(cached, &update_meminfo)
353 #define SCAN_CPU(__arg, __var) { \
355 if (__arg && sscanf(__arg, " cpu%u %n", &__var, &__offset) > 0) \
360 END OBJ(cpu, &update_cpu_usage)
361 SCAN_CPU(arg, obj->data.cpu_index);
362 DBGP2("Adding $cpu for CPU %d", obj->data.cpu_index);
364 END OBJ(cpugauge, &update_cpu_usage)
365 SIZE_DEFAULTS(gauge);
366 SCAN_CPU(arg, obj->data.cpu_index);
367 scan_gauge(arg, &obj->a, &obj->b);
368 DBGP2("Adding $cpugauge for CPU %d", obj->data.cpu_index);
370 END OBJ(cpubar, &update_cpu_usage)
372 SCAN_CPU(arg, obj->data.cpu_index);
373 scan_bar(arg, &obj->a, &obj->b);
374 DBGP2("Adding $cpubar for CPU %d", obj->data.cpu_index);
376 END OBJ(cpugraph, &update_cpu_usage)
378 SIZE_DEFAULTS(graph);
379 SCAN_CPU(arg, obj->data.cpu_index);
380 buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
381 &obj->e, &obj->char_a, &obj->char_b);
382 DBGP2("Adding $cpugraph for CPU %d", obj->data.cpu_index);
384 END OBJ(loadgraph, &update_load_average)
386 SIZE_DEFAULTS(graph);
387 buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
388 &obj->e, &obj->char_a, &obj->char_b);
392 r = sscanf(arg, "%d", &a);
394 obj->data.loadavg[0] = (r >= 1) ? (unsigned char) a : 0;
398 END OBJ(diskio, &update_diskio)
399 parse_diskio_arg(obj, arg);
400 END OBJ(diskio_read, &update_diskio)
401 parse_diskio_arg(obj, arg);
402 END OBJ(diskio_write, &update_diskio)
403 parse_diskio_arg(obj, arg);
405 END OBJ(diskiograph, &update_diskio)
406 parse_diskiograph_arg(obj, arg);
407 END OBJ(diskiograph_read, &update_diskio)
408 parse_diskiograph_arg(obj, arg);
409 END OBJ(diskiograph_write, &update_diskio)
410 parse_diskiograph_arg(obj, arg);
414 if (output_methods & TO_X) {
415 obj->data.l = arg ? get_x11_color(arg) : default_fg_color;
416 set_current_text_color(obj->data.l);
420 if (output_methods & TO_NCURSES) {
421 obj->data.l = COLOR_WHITE;
423 if(strcasecmp(arg, "red") == 0) {
424 obj->data.l = COLOR_RED;
425 }else if(strcasecmp(arg, "green") == 0) {
426 obj->data.l = COLOR_GREEN;
427 }else if(strcasecmp(arg, "yellow") == 0) {
428 obj->data.l = COLOR_YELLOW;
429 }else if(strcasecmp(arg, "blue") == 0) {
430 obj->data.l = COLOR_BLUE;
431 }else if(strcasecmp(arg, "magenta") == 0) {
432 obj->data.l = COLOR_MAGENTA;
433 }else if(strcasecmp(arg, "cyan") == 0) {
434 obj->data.l = COLOR_CYAN;
435 }else if(strcasecmp(arg, "black") == 0) {
436 obj->data.l = COLOR_BLACK;
439 set_current_text_color(obj->data.l);
440 init_pair(obj->data.l, obj->data.l, COLOR_BLACK);
444 obj->data.l = color0;
445 set_current_text_color(obj->data.l);
447 obj->data.l = color1;
448 set_current_text_color(obj->data.l);
450 obj->data.l = color2;
451 set_current_text_color(obj->data.l);
453 obj->data.l = color3;
454 set_current_text_color(obj->data.l);
456 obj->data.l = color4;
457 set_current_text_color(obj->data.l);
459 obj->data.l = color5;
460 set_current_text_color(obj->data.l);
462 obj->data.l = color6;
463 set_current_text_color(obj->data.l);
465 obj->data.l = color7;
466 set_current_text_color(obj->data.l);
468 obj->data.l = color8;
469 set_current_text_color(obj->data.l);
471 obj->data.l = color9;
472 set_current_text_color(obj->data.l);
475 obj->data.s = scan_font(arg);
477 END OBJ(conky_version, 0)
478 END OBJ(conky_build_date, 0)
479 END OBJ(conky_build_arch, 0)
480 END OBJ(downspeed, &update_net_stats)
481 parse_net_stat_arg(obj, arg, free_at_crash);
482 END OBJ(downspeedf, &update_net_stats)
483 parse_net_stat_arg(obj, arg, free_at_crash);
485 END OBJ(downspeedgraph, &update_net_stats)
486 parse_net_stat_graph_arg(obj, arg, free_at_crash);
489 obj_be_ifblock_else(ifblock_opaque, obj);
491 obj_be_ifblock_endif(ifblock_opaque, obj);
493 obj->data.s = strndup(arg ? arg : "", text_buffer_size);
494 #if defined(IMLIB2) && defined(X11)
496 obj->data.s = strndup(arg ? arg : "", text_buffer_size);
499 scan_exec_arg(obj, arg);
501 scan_exec_arg(obj, arg);
504 scan_exec_arg(obj, arg);
506 END OBJ(execgauge, 0)
507 SIZE_DEFAULTS(gauge);
508 scan_exec_arg(obj, arg);
509 END OBJ(execgraph, 0)
510 SIZE_DEFAULTS(graph);
511 scan_exec_arg(obj, arg);
513 END OBJ_ARG(execibar, 0, "execibar needs arguments")
515 scan_execi_arg(obj, arg);
517 END OBJ_ARG(execigraph, 0, "execigraph needs arguments")
518 SIZE_DEFAULTS(graph);
519 scan_execi_arg(obj, arg);
520 END OBJ_ARG(execigauge, 0, "execigauge needs arguments")
521 SIZE_DEFAULTS(gauge);
522 scan_execi_arg(obj, arg);
524 END OBJ_ARG(execi, 0, "execi needs arguments")
525 scan_execi_arg(obj, arg);
526 END OBJ_ARG(execpi, 0, "execpi needs arguments")
527 scan_execi_arg(obj, arg);
528 END OBJ_ARG(texeci, 0, "texeci needs arguments")
529 scan_execi_arg(obj, arg);
531 scan_pre_exec_arg(obj, arg);
532 END OBJ(fs_bar, &update_fs_stats)
533 init_fs_bar(obj, arg);
534 END OBJ(fs_bar_free, &update_fs_stats)
535 init_fs_bar(obj, arg);
536 END OBJ(fs_free, &update_fs_stats)
538 END OBJ(fs_used_perc, &update_fs_stats)
540 END OBJ(fs_free_perc, &update_fs_stats)
542 END OBJ(fs_size, &update_fs_stats)
544 END OBJ(fs_type, &update_fs_stats)
546 END OBJ(fs_used, &update_fs_stats)
549 obj->data.i = arg ? atoi(arg) : 1;
550 END OBJ(nameserver, &update_dns_data)
551 parse_nameserver_arg(obj, arg);
553 obj->data.i = arg ? atoi(arg) : 1;
555 obj->data.i = arg ? atoi(arg) : 1;
556 END OBJ_ARG(goto, 0, "goto needs arguments")
557 obj->data.i = atoi(arg);
562 if (sscanf(arg, "%d %d", &a, &b) != 2) {
563 sscanf(arg, "%d", &b);
569 obj->data.pair.a = a;
570 obj->data.pair.b = b;
573 END OBJ_ARG(i2c, 0, "i2c needs arguments")
574 parse_i2c_sensor(obj, arg);
575 END OBJ_ARG(platform, 0, "platform needs arguments")
576 parse_platform_sensor(obj, arg);
577 END OBJ_ARG(hwmon, 0, "hwmon needs argumanets")
578 parse_hwmon_sensor(obj, arg);
579 #endif /* __linux__ */
582 /* we have four different types of top (top, top_mem, top_time and top_io). To
583 * avoid having almost-same code four times, we have this special
585 if (strncmp(s, "top", 3) == EQUAL) {
586 add_update_callback(&update_meminfo);
587 add_update_callback(&update_top);
588 if (!parse_top_args(s, arg, obj)) {
591 } else OBJ(addr, &update_net_stats)
592 parse_net_stat_arg(obj, arg, free_at_crash);
593 #if defined(__linux__)
594 END OBJ(addrs, &update_net_stats)
595 parse_net_stat_arg(obj, arg, free_at_crash);
596 #endif /* __linux__ */
597 END OBJ_ARG(tail, 0, "tail needs arguments")
598 init_tailhead("tail", arg, obj, free_at_crash);
599 END OBJ_ARG(head, 0, "head needs arguments")
600 init_tailhead("head", arg, obj, free_at_crash);
601 END OBJ_ARG(lines, 0, "lines needs an argument")
602 obj->data.s = strndup(arg, text_buffer_size);
603 END OBJ_ARG(words, 0, "words needs a argument")
604 obj->data.s = strndup(arg, text_buffer_size);
605 END OBJ(loadavg, &update_load_average)
606 int a = 1, b = 2, c = 3, r = 3;
609 r = sscanf(arg, "%d %d %d", &a, &b, &c);
610 if (r >= 3 && (c < 1 || c > 3)) {
613 if (r >= 2 && (b < 1 || b > 3)) {
616 if (r >= 1 && (a < 1 || a > 3)) {
620 obj->data.loadavg[0] = (r >= 1) ? (unsigned char) a : 0;
621 obj->data.loadavg[1] = (r >= 2) ? (unsigned char) b : 0;
622 obj->data.loadavg[2] = (r >= 3) ? (unsigned char) c : 0;
623 END OBJ_IF_ARG(if_empty, 0, "if_empty needs an argument")
624 obj->data.ifblock.s = strndup(arg, text_buffer_size);
625 obj->sub = malloc(sizeof(struct text_object));
626 extract_variable_text_internal(obj->sub, obj->data.ifblock.s);
627 END OBJ_IF_ARG(if_match, 0, "if_match needs arguments")
628 obj->data.ifblock.s = strndup(arg, text_buffer_size);
629 obj->sub = malloc(sizeof(struct text_object));
630 extract_variable_text_internal(obj->sub, obj->data.ifblock.s);
631 END OBJ_IF_ARG(if_existing, 0, "if_existing needs an argument or two")
632 char buf1[256], buf2[256];
633 int r = sscanf(arg, "%255s %255[^\n]", buf1, buf2);
636 obj->data.ifblock.s = strndup(buf1, text_buffer_size);
637 obj->data.ifblock.str = NULL;
639 obj->data.ifblock.s = strndup(buf1, text_buffer_size);
640 obj->data.ifblock.str = strndup(buf2, text_buffer_size);
642 DBGP("if_existing: '%s' '%s'", obj->data.ifblock.s, obj->data.ifblock.str);
643 END OBJ_IF_ARG(if_mounted, 0, "if_mounted needs an argument")
644 obj->data.ifblock.s = strndup(arg, text_buffer_size);
646 END OBJ_IF_ARG(if_running, &update_top, "if_running needs an argument")
648 obj->data.ifblock.s = strndup(arg, text_buffer_size);
650 END OBJ_IF_ARG(if_running, 0, "if_running needs an argument")
653 snprintf(buf, 256, "pidof %s >/dev/null", arg);
654 obj->data.ifblock.s = strndup(buf, text_buffer_size);
659 parse_local_mail_args(obj, arg);
660 END OBJ(new_mails, 0)
661 parse_local_mail_args(obj, arg);
662 END OBJ(seen_mails, 0)
663 parse_local_mail_args(obj, arg);
664 END OBJ(unseen_mails, 0)
665 parse_local_mail_args(obj, arg);
666 END OBJ(flagged_mails, 0)
667 parse_local_mail_args(obj, arg);
668 END OBJ(unflagged_mails, 0)
669 parse_local_mail_args(obj, arg);
670 END OBJ(forwarded_mails, 0)
671 parse_local_mail_args(obj, arg);
672 END OBJ(unforwarded_mails, 0)
673 parse_local_mail_args(obj, arg);
674 END OBJ(replied_mails, 0)
675 parse_local_mail_args(obj, arg);
676 END OBJ(unreplied_mails, 0)
677 parse_local_mail_args(obj, arg);
678 END OBJ(draft_mails, 0)
679 parse_local_mail_args(obj, arg);
680 END OBJ(trashed_mails, 0)
681 parse_local_mail_args(obj, arg);
683 parse_mboxscan_arg(obj, arg);
684 END OBJ(mem, &update_meminfo)
685 END OBJ(memeasyfree, &update_meminfo)
686 END OBJ(memfree, &update_meminfo)
687 END OBJ(memmax, &update_meminfo)
688 END OBJ(memperc, &update_meminfo)
690 END OBJ(memgauge, &update_meminfo)
691 SIZE_DEFAULTS(gauge);
692 scan_gauge(arg, &obj->data.pair.a, &obj->data.pair.b);
694 END OBJ(membar, &update_meminfo)
696 scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
698 END OBJ(memgraph, &update_meminfo)
700 SIZE_DEFAULTS(graph);
701 buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
702 &obj->e, &obj->char_a, &obj->char_b);
707 parse_mixer_arg(obj, arg);
709 parse_mixer_arg(obj, arg);
711 parse_mixer_arg(obj, arg);
714 scan_mixer_bar(obj, arg);
715 END OBJ(mixerlbar, 0)
716 scan_mixer_bar(obj, arg);
717 END OBJ(mixerrbar, 0)
718 scan_mixer_bar(obj, arg);
720 END OBJ_IF(if_mixer_mute, 0)
721 parse_mixer_arg(obj, arg);
723 END OBJ(monitor, &update_x11info)
724 END OBJ(monitor_number, &update_x11info)
725 END OBJ(desktop, &update_x11info)
726 END OBJ(desktop_number, &update_x11info)
727 END OBJ(desktop_name, &update_x11info)
730 END OBJ(processes, &update_total_processes)
731 END OBJ(running_processes, &update_running_processes)
732 END OBJ(shadecolor, 0)
734 obj->data.l = arg ? get_x11_color(arg) : default_bg_color;
736 END OBJ(outlinecolor, 0)
738 obj->data.l = arg ? get_x11_color(arg) : default_out_color;
740 END OBJ(stippled_hr, 0)
742 int a = get_stippled_borders(), b = 1;
745 if (sscanf(arg, "%d %d", &a, &b) != 2) {
746 sscanf(arg, "%d", &b);
752 obj->data.pair.a = a;
753 obj->data.pair.b = b;
755 END OBJ(swap, &update_meminfo)
756 END OBJ(swapfree, &update_meminfo)
757 END OBJ(swapmax, &update_meminfo)
758 END OBJ(swapperc, &update_meminfo)
759 END OBJ(swapbar, &update_meminfo)
761 scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
768 scan_tztime(obj, arg);
770 END OBJ_ARG(iconv_start, 0, "Iconv requires arguments")
771 init_iconv_start(obj, free_at_crash, arg);
772 END OBJ(iconv_stop, 0)
775 END OBJ(totaldown, &update_net_stats)
776 parse_net_stat_arg(obj, arg, free_at_crash);
777 END OBJ(totalup, &update_net_stats)
778 parse_net_stat_arg(obj, arg, free_at_crash);
780 END OBJ_IF(if_updatenr, 0)
781 obj->data.ifblock.i = arg ? atoi(arg) : 0;
782 if(obj->data.ifblock.i == 0) CRIT_ERR(obj, free_at_crash, "if_updatenr needs a number above 0 as argument");
783 set_updatereset(obj->data.ifblock.i > get_updatereset() ? obj->data.ifblock.i : get_updatereset());
785 obj->data.i = arg ? atoi(arg) : 0;
787 obj->data.i = arg ? atoi(arg) : 0;
788 END OBJ(upspeed, &update_net_stats)
789 parse_net_stat_arg(obj, arg, free_at_crash);
790 END OBJ(upspeedf, &update_net_stats)
791 parse_net_stat_arg(obj, arg, free_at_crash);
793 END OBJ(upspeedgraph, &update_net_stats)
794 parse_net_stat_graph_arg(obj, arg, free_at_crash);
796 END OBJ(uptime_short, &update_uptime)
797 END OBJ(uptime, &update_uptime)
798 END OBJ(user_names, &update_users)
799 END OBJ(user_times, &update_users)
800 END OBJ(user_terms, &update_users)
801 END OBJ(user_number, &update_users)
802 #if defined(__linux__)
803 END OBJ(gw_iface, &update_gateway_info)
804 END OBJ(gw_ip, &update_gateway_info)
805 #endif /* !__linux__ */
807 END OBJ(adt746xcpu, 0)
808 END OBJ(adt746xfan, 0)
809 #endif /* !__OpenBSD__ */
810 #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
811 || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
812 END OBJ(apm_adapter, 0)
813 END OBJ(apm_battery_life, 0)
814 END OBJ(apm_battery_time, 0)
815 #endif /* __FreeBSD__ */
816 END OBJ(imap_unseen, 0)
817 parse_imap_mail_args(obj, arg);
818 END OBJ(imap_messages, 0)
819 parse_imap_mail_args(obj, arg);
820 END OBJ(pop3_unseen, 0)
821 parse_pop3_mail_args(obj, arg);
822 END OBJ(pop3_used, 0)
823 parse_pop3_mail_args(obj, arg);
825 END OBJ_ARG(smapi, 0, "smapi needs an argument")
826 obj->data.s = strndup(arg, text_buffer_size);
827 END OBJ_IF_ARG(if_smapi_bat_installed, 0, "if_smapi_bat_installed needs an argument")
828 obj->data.ifblock.s = strndup(arg, text_buffer_size);
829 END OBJ_ARG(smapi_bat_perc, 0, "smapi_bat_perc needs an argument")
830 obj->data.s = strndup(arg, text_buffer_size);
831 END OBJ_ARG(smapi_bat_temp, 0, "smapi_bat_temp needs an argument")
832 obj->data.s = strndup(arg, text_buffer_size);
833 END OBJ_ARG(smapi_bat_power, 0, "smapi_bat_power needs an argument")
834 obj->data.s = strndup(arg, text_buffer_size);
836 END OBJ_ARG(smapi_bat_bar, 0, "smapi_bat_bar needs an argument")
839 if(sscanf(arg, "%i %n", &obj->data.i, &cnt) <= 0) {
840 NORM_ERR("first argument to smapi_bat_bar must be an integer value");
844 arg = scan_bar(arg + cnt, &obj->a, &obj->b);
849 #define mpd_set_maxlen(name) \
852 sscanf(arg, "%d", &i); \
854 obj->data.i = i + 1; \
856 NORM_ERR(#name ": invalid length argument"); \
858 END OBJ(mpd_artist, &update_mpd)
859 mpd_set_maxlen(mpd_artist);
861 END OBJ(mpd_title, &update_mpd)
862 mpd_set_maxlen(mpd_title);
864 END OBJ(mpd_random, &update_mpd) init_mpd();
865 END OBJ(mpd_repeat, &update_mpd) init_mpd();
866 END OBJ(mpd_elapsed, &update_mpd) init_mpd();
867 END OBJ(mpd_length, &update_mpd) init_mpd();
868 END OBJ(mpd_track, &update_mpd)
869 mpd_set_maxlen(mpd_track);
871 END OBJ(mpd_name, &update_mpd)
872 mpd_set_maxlen(mpd_name);
874 END OBJ(mpd_file, &update_mpd)
875 mpd_set_maxlen(mpd_file);
877 END OBJ(mpd_percent, &update_mpd) init_mpd();
878 END OBJ(mpd_album, &update_mpd)
879 mpd_set_maxlen(mpd_album);
881 END OBJ(mpd_vol, &update_mpd) init_mpd();
882 END OBJ(mpd_bitrate, &update_mpd) init_mpd();
883 END OBJ(mpd_status, &update_mpd) init_mpd();
884 END OBJ(mpd_bar, &update_mpd)
886 scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
888 END OBJ(mpd_smart, &update_mpd)
889 mpd_set_maxlen(mpd_smart);
891 END OBJ_IF(if_mpd_playing, &update_mpd)
893 #undef mpd_set_maxlen
896 END OBJ(moc_state, &update_moc)
897 END OBJ(moc_file, &update_moc)
898 END OBJ(moc_title, &update_moc)
899 END OBJ(moc_artist, &update_moc)
900 END OBJ(moc_song, &update_moc)
901 END OBJ(moc_album, &update_moc)
902 END OBJ(moc_totaltime, &update_moc)
903 END OBJ(moc_timeleft, &update_moc)
904 END OBJ(moc_curtime, &update_moc)
905 END OBJ(moc_bitrate, &update_moc)
906 END OBJ(moc_rate, &update_moc)
909 END OBJ(xmms2_artist, &update_xmms2)
910 END OBJ(xmms2_album, &update_xmms2)
911 END OBJ(xmms2_title, &update_xmms2)
912 END OBJ(xmms2_genre, &update_xmms2)
913 END OBJ(xmms2_comment, &update_xmms2)
914 END OBJ(xmms2_url, &update_xmms2)
915 END OBJ(xmms2_tracknr, &update_xmms2)
916 END OBJ(xmms2_bitrate, &update_xmms2)
917 END OBJ(xmms2_date, &update_xmms2)
918 END OBJ(xmms2_id, &update_xmms2)
919 END OBJ(xmms2_duration, &update_xmms2)
920 END OBJ(xmms2_elapsed, &update_xmms2)
921 END OBJ(xmms2_size, &update_xmms2)
922 END OBJ(xmms2_status, &update_xmms2)
923 END OBJ(xmms2_percent, &update_xmms2)
925 END OBJ(xmms2_bar, &update_xmms2)
927 scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
929 END OBJ(xmms2_smart, &update_xmms2)
930 END OBJ(xmms2_playlist, &update_xmms2)
931 END OBJ(xmms2_timesplayed, &update_xmms2)
932 END OBJ_IF(if_xmms2_connected, &update_xmms2)
935 END OBJ(audacious_status, &update_audacious)
936 END OBJ_ARG(audacious_title, &update_audacious, "audacious_title needs an argument")
937 sscanf(arg, "%d", &info.audacious.max_title_len);
938 if (info.audacious.max_title_len > 0) {
939 info.audacious.max_title_len++;
941 CRIT_ERR(obj, free_at_crash, "audacious_title: invalid length argument");
943 END OBJ(audacious_length, &update_audacious)
944 END OBJ(audacious_length_seconds, &update_audacious)
945 END OBJ(audacious_position, &update_audacious)
946 END OBJ(audacious_position_seconds, &update_audacious)
947 END OBJ(audacious_bitrate, &update_audacious)
948 END OBJ(audacious_frequency, &update_audacious)
949 END OBJ(audacious_channels, &update_audacious)
950 END OBJ(audacious_filename, &update_audacious)
951 END OBJ(audacious_playlist_length, &update_audacious)
952 END OBJ(audacious_playlist_position, &update_audacious)
953 END OBJ(audacious_main_volume, &update_audacious)
955 END OBJ(audacious_bar, &update_audacious)
957 scan_bar(arg, &obj->a, &obj->b);
961 END OBJ(bmpx_title, &update_bmpx)
962 memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
963 END OBJ(bmpx_artist, &update_bmpx)
964 memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
965 END OBJ(bmpx_album, &update_bmpx)
966 memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
967 END OBJ(bmpx_track, &update_bmpx)
968 memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
969 END OBJ(bmpx_uri, &update_bmpx)
970 memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
971 END OBJ(bmpx_bitrate, &update_bmpx)
972 memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
975 END OBJ_ARG(eve, 0, "eve needs arguments: <userid> <apikey> <characterid>")
979 END OBJ_ARG(curl, 0, "curl needs arguments: <uri> <interval in minutes>")
980 curl_parse_arg(obj, arg);
983 END OBJ_ARG(rss, 0, "rss needs arguments: <uri> <interval in minutes> <action> [act_par] [spaces in front]")
984 rss_scan_arg(obj, arg);
987 END OBJ_ARG(weather, 0, "weather needs arguments: <uri> <locID> <data_type> [interval in minutes]")
988 scan_weather_arg(obj, arg, free_at_crash);
991 END OBJ_ARG(weather_forecast, 0, "weather_forecast needs arguments: <uri> <locID> <day> <data_type> [interval in minutes]")
992 scan_weather_forecast_arg(obj, arg, free_at_crash);
995 END OBJ_ARG(lua, 0, "lua needs arguments: <function name> [function parameters]")
996 obj->data.s = strndup(arg, text_buffer_size);
997 END OBJ_ARG(lua_parse, 0, "lua_parse needs arguments: <function name> [function parameters]")
998 obj->data.s = strndup(arg, text_buffer_size);
999 END OBJ_ARG(lua_bar, 0, "lua_bar needs arguments: <height>,<width> <function name> [function parameters]")
1001 arg = scan_bar(arg, &obj->a, &obj->b);
1003 obj->data.s = strndup(arg, text_buffer_size);
1005 CRIT_ERR(obj, free_at_crash, "lua_bar needs arguments: <height>,<width> <function name> [function parameters]");
1008 END OBJ_ARG(lua_graph, 0, "lua_graph needs arguments: <function name> [height],[width] [gradient colour 1] [gradient colour 2] [scale] [-t] [-l]")
1010 SIZE_DEFAULTS(graph);
1011 buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
1012 &obj->e, &obj->char_a, &obj->char_b);
1016 CRIT_ERR(obj, free_at_crash, "lua_graph needs arguments: <function name> [height],[width] [gradient colour 1] [gradient colour 2] [scale] [-t] [-l]");
1018 END OBJ_ARG(lua_gauge, 0, "lua_gauge needs arguments: <height>,<width> <function name> [function parameters]")
1019 SIZE_DEFAULTS(gauge);
1020 arg = scan_gauge(arg, &obj->a, &obj->b);
1022 obj->data.s = strndup(arg, text_buffer_size);
1024 CRIT_ERR(obj, free_at_crash, "lua_gauge needs arguments: <height>,<width> <function name> [function parameters]");
1027 #endif /* HAVE_LUA */
1029 END OBJ(hddtemp, &update_hddtemp)
1031 obj->data.s = strndup(arg, text_buffer_size);
1032 #endif /* HDDTEMP */
1033 #ifdef TCP_PORT_MONITOR
1034 END OBJ_ARG(tcp_portmon, &tcp_portmon_update, "tcp_portmon: needs arguments")
1035 tcp_portmon_init(obj, arg);
1036 #endif /* TCP_PORT_MONITOR */
1037 END OBJ(entropy_avail, &update_entropy)
1038 END OBJ(entropy_perc, &update_entropy)
1039 END OBJ(entropy_poolsize, &update_entropy)
1040 END OBJ(entropy_bar, &update_entropy)
1042 scan_bar(arg, &obj->a, &obj->b);
1043 END OBJ_ARG(include, 0, "include needs a argument")
1044 struct conftree *leaf = conftree_add(currentconffile, arg);
1046 if (load_config_file(arg) == TRUE) {
1047 obj->sub = malloc(sizeof(struct text_object));
1048 currentconffile = leaf;
1049 extract_variable_text_internal(obj->sub, get_global_text());
1050 currentconffile = leaf->back;
1052 NORM_ERR("Can't load configfile '%s'.", arg);
1055 NORM_ERR("You are trying to load '%s' recursively, I'm only going to load it once to prevent an infinite loop.", arg);
1057 END OBJ_ARG(blink, 0, "blink needs a argument")
1058 obj->sub = malloc(sizeof(struct text_object));
1059 extract_variable_text_internal(obj->sub, arg);
1060 END OBJ_ARG(to_bytes, 0, "to_bytes needs a argument")
1061 obj->sub = malloc(sizeof(struct text_object));
1062 extract_variable_text_internal(obj->sub, arg);
1064 parse_scroll_arg(obj, arg, free_at_crash);
1065 END OBJ_ARG(combine, 0, "combine needs arguments: <text1> <text2>")
1066 parse_combine_arg(obj, arg, free_at_crash);
1068 END OBJ_ARG(nvidia, 0, "nvidia needs an argument")
1069 if (set_nvidia_type(obj, arg)) {
1070 CRIT_ERR(obj, free_at_crash, "nvidia: invalid argument"
1071 " specified: '%s'\n", arg);
1075 END OBJ_ARG(apcupsd, &update_apcupsd, "apcupsd needs arguments: <host> <port>")
1078 if (sscanf(arg, "%63s %d", host, &port) != 2) {
1079 CRIT_ERR(obj, free_at_crash, "apcupsd needs arguments: <host> <port>");
1081 info.apcupsd.port = htons(port);
1082 strncpy(info.apcupsd.host, host, sizeof(info.apcupsd.host));
1084 END OBJ(apcupsd_name, &update_apcupsd)
1085 END OBJ(apcupsd_model, &update_apcupsd)
1086 END OBJ(apcupsd_upsmode, &update_apcupsd)
1087 END OBJ(apcupsd_cable, &update_apcupsd)
1088 END OBJ(apcupsd_status, &update_apcupsd)
1089 END OBJ(apcupsd_linev, &update_apcupsd)
1090 END OBJ(apcupsd_load, &update_apcupsd)
1091 END OBJ(apcupsd_loadbar, &update_apcupsd)
1093 scan_bar(arg, &obj->a, &obj->b);
1095 END OBJ(apcupsd_loadgraph, &update_apcupsd)
1097 SIZE_DEFAULTS(graph);
1098 buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
1099 &obj->e, &obj->char_a, &obj->char_b);
1101 END OBJ(apcupsd_loadgauge, &update_apcupsd)
1102 SIZE_DEFAULTS(gauge);
1103 scan_gauge(arg, &obj->a, &obj->b);
1105 END OBJ(apcupsd_charge, &update_apcupsd)
1106 END OBJ(apcupsd_timeleft, &update_apcupsd)
1107 END OBJ(apcupsd_temp, &update_apcupsd)
1108 END OBJ(apcupsd_lastxfer, &update_apcupsd)
1109 #endif /* APCUPSD */
1113 NORM_ERR("unknown variable %s", s);
1114 obj->type = OBJ_text;
1115 snprintf(buf, 256, "${%s}", s);
1116 obj->data.s = strndup(buf, text_buffer_size);
1126 #undef SIZE_DEFAULTS
1132 * - assumes that *string is '#'
1133 * - removes the part from '#' to the end of line ('\n' or '\0')
1134 * - it removes the '\n'
1135 * - copies the last char into 'char *last' argument, which should be a pointer
1136 * to a char rather than a string.
1138 static size_t remove_comment(char *string, char *last)
1141 while (*end != '\0' && *end != '\n') {
1144 if (last) *last = *end;
1145 if (*end == '\n') end++;
1146 strfold(string, end - string);
1147 return end - string;
1150 size_t remove_comments(char *string)
1154 for (curplace = string; *curplace != 0; curplace++) {
1155 if (*curplace == '\\' && *(curplace + 1) == '#') {
1156 // strcpy can't be used for overlapping strings
1157 strfold(curplace, 1);
1159 } else if (*curplace == '#') {
1160 folded += remove_comment(curplace, 0);
1166 int extract_variable_text_internal(struct text_object *retval, const char *const_p)
1168 struct text_object *obj;
1169 char *p, *s, *orig_p;
1171 void *ifblock_opaque = NULL;
1176 p = strndup(const_p, max_user_text - 1);
1177 while (text_contains_templates(p)) {
1179 tmp = find_and_replace_templates(p);
1185 if (strcmp(p, const_p)) {
1186 DBGP("replaced all templates in text: input is\n'%s'\noutput is\n'%s'", const_p, p);
1188 DBGP("no templates to replace");
1191 memset(retval, 0, sizeof(struct text_object));
1193 line = global_text_lines;
1201 obj = create_plain_text(s);
1203 append_object(retval, obj);
1213 /* variable is either $foo or ${foo} */
1215 unsigned int brl = 1, brr = 0;
1219 while (*p && brl != brr) {
1234 while (*p && (isalnum((int) *p) || *p == '_')) {
1239 /* copy variable to buffer */
1240 len = (p - s > 255) ? 255 : (p - s);
1241 strncpy(buf, s, len);
1249 /* search for variable in environment */
1253 obj = create_plain_text(var);
1255 append_object(retval, obj);
1260 /* if variable wasn't found in environment, use some special */
1265 if (strchr(buf, ' ')) {
1266 arg = strchr(buf, ' ');
1269 while (isspace((int) *arg)) {
1277 /* lowercase variable name */
1280 *tmp_p = tolower(*tmp_p);
1284 obj = construct_text_object(buf, arg,
1285 line, &ifblock_opaque, orig_p);
1287 append_object(retval, obj);
1291 obj = create_plain_text("$");
1294 append_object(retval, obj);
1297 } else if (*p == '\\' && *(p+1) == '#') {
1299 } else if (*p == '#') {
1301 if (remove_comment(p, &c) && p > orig_p && c == '\n') {
1302 /* if remove_comment removed a newline, we need to 'back up' with p */
1308 obj = create_plain_text(s);
1310 append_object(retval, obj);
1313 if (!ifblock_stack_empty(&ifblock_opaque)) {
1314 NORM_ERR("one or more $endif's are missing");
1322 * Frees the list of text objects root points to. When internal = 1, it won't
1323 * free global objects.
1325 void free_text_objects(struct text_object *root, int internal)
1327 struct text_object *obj;
1333 #define data obj->data
1334 for (obj = root->prev; obj; obj = root->prev) {
1335 root->prev = obj->prev;
1336 switch (obj->type) {
1341 #endif /* !__OpenBSD__ */
1346 free_sysfs_sensor(obj);
1348 #endif /* __linux__ */
1364 case OBJ_seen_mails:
1365 case OBJ_unseen_mails:
1366 case OBJ_flagged_mails:
1367 case OBJ_unflagged_mails:
1368 case OBJ_forwarded_mails:
1369 case OBJ_unforwarded_mails:
1370 case OBJ_replied_mails:
1371 case OBJ_unreplied_mails:
1372 case OBJ_draft_mails:
1373 case OBJ_trashed_mails:
1374 free(data.local_mail.mbox);
1376 case OBJ_imap_unseen:
1377 case OBJ_imap_messages:
1378 case OBJ_pop3_unseen:
1384 free_text_objects(obj->sub, 1);
1387 case OBJ_if_existing:
1388 case OBJ_if_mounted:
1389 case OBJ_if_running:
1390 free(data.ifblock.s);
1391 free(data.ifblock.str);
1411 case OBJ_iconv_start:
1416 case OBJ_disk_protect:
1420 free(data.ifblock.s);
1421 free(data.ifblock.str);
1424 free_gateway_info();
1426 case OBJ_ioscheduler:
1431 #if (defined(__FreeBSD__) || defined(__linux__))
1433 free(data.ifblock.s);
1434 free(data.ifblock.str);
1438 case OBJ_xmms2_artist:
1439 if (info.xmms2.artist) {
1440 free(info.xmms2.artist);
1441 info.xmms2.artist = 0;
1444 case OBJ_xmms2_album:
1445 if (info.xmms2.album) {
1446 free(info.xmms2.album);
1447 info.xmms2.album = 0;
1450 case OBJ_xmms2_title:
1451 if (info.xmms2.title) {
1452 free(info.xmms2.title);
1453 info.xmms2.title = 0;
1456 case OBJ_xmms2_genre:
1457 if (info.xmms2.genre) {
1458 free(info.xmms2.genre);
1459 info.xmms2.genre = 0;
1462 case OBJ_xmms2_comment:
1463 if (info.xmms2.comment) {
1464 free(info.xmms2.comment);
1465 info.xmms2.comment = 0;
1469 if (info.xmms2.url) {
1470 free(info.xmms2.url);
1474 case OBJ_xmms2_date:
1475 if (info.xmms2.date) {
1476 free(info.xmms2.date);
1477 info.xmms2.date = 0;
1480 case OBJ_xmms2_status:
1481 if (info.xmms2.status) {
1482 free(info.xmms2.status);
1483 info.xmms2.status = 0;
1486 case OBJ_xmms2_playlist:
1487 if (info.xmms2.playlist) {
1488 free(info.xmms2.playlist);
1489 info.xmms2.playlist = 0;
1492 case OBJ_xmms2_smart:
1493 if (info.xmms2.artist) {
1494 free(info.xmms2.artist);
1495 info.xmms2.artist = 0;
1497 if (info.xmms2.title) {
1498 free(info.xmms2.title);
1499 info.xmms2.title = 0;
1501 if (info.xmms2.url) {
1502 free(info.xmms2.url);
1508 case OBJ_bmpx_title:
1509 case OBJ_bmpx_artist:
1510 case OBJ_bmpx_album:
1511 case OBJ_bmpx_track:
1513 case OBJ_bmpx_bitrate:
1528 rss_free_obj_info(obj);
1537 case OBJ_weather_forecast:
1551 #endif /* HAVE_LUA */
1558 case OBJ_battery_short:
1561 case OBJ_battery_time:
1564 #endif /* !__OpenBSD__ */
1570 case OBJ_execigraph:
1571 case OBJ_execigauge:
1575 case OBJ_nameserver:
1584 free_top(obj, internal);
1594 #endif /* HDDTEMP */
1595 case OBJ_entropy_avail:
1596 case OBJ_entropy_perc:
1597 case OBJ_entropy_poolsize:
1598 case OBJ_entropy_bar:
1600 case OBJ_user_names:
1601 if (info.users.names) {
1602 free(info.users.names);
1603 info.users.names = 0;
1606 case OBJ_user_terms:
1607 if (info.users.terms) {
1608 free(info.users.terms);
1609 info.users.terms = 0;
1612 case OBJ_user_times:
1613 if (info.users.times) {
1614 free(info.users.times);
1615 info.users.times = 0;
1620 case OBJ_smapi_bat_perc:
1621 case OBJ_smapi_bat_temp:
1622 case OBJ_smapi_bat_power:
1625 case OBJ_if_smapi_bat_installed:
1626 free(data.ifblock.s);
1627 free(data.ifblock.str);
1637 case OBJ_mpd_artist:
1639 case OBJ_mpd_random:
1640 case OBJ_mpd_repeat:
1642 case OBJ_mpd_bitrate:
1643 case OBJ_mpd_status:
1645 case OBJ_mpd_elapsed:
1646 case OBJ_mpd_length:
1650 case OBJ_mpd_percent:
1652 case OBJ_if_mpd_playing:
1660 case OBJ_moc_artist:
1663 case OBJ_moc_totaltime:
1664 case OBJ_moc_timeleft:
1665 case OBJ_moc_curtime:
1666 case OBJ_moc_bitrate:
1675 free_text_objects(obj->sub, 1);
1687 case OBJ_apcupsd_name:
1688 case OBJ_apcupsd_model:
1689 case OBJ_apcupsd_upsmode:
1690 case OBJ_apcupsd_cable:
1691 case OBJ_apcupsd_status:
1692 case OBJ_apcupsd_linev:
1693 case OBJ_apcupsd_load:
1694 case OBJ_apcupsd_loadbar:
1696 case OBJ_apcupsd_loadgraph:
1697 case OBJ_apcupsd_loadgauge:
1699 case OBJ_apcupsd_charge:
1700 case OBJ_apcupsd_timeleft:
1701 case OBJ_apcupsd_temp:
1702 case OBJ_apcupsd_lastxfer:
1704 #endif /* APCUPSD */
1705 #ifdef TCP_PORT_MONITOR
1706 case OBJ_tcp_portmon:
1707 tcp_portmon_free(obj);
1709 #endif /* TCP_PORT_MONITOR */
1712 case OBJ_desktop_number:
1713 case OBJ_desktop_name:
1714 if(info.x11.desktop.name && !internal) {
1715 free(info.x11.desktop.name);
1716 info.x11.desktop.name = NULL;
1718 if(info.x11.desktop.all_names && !internal) {
1719 free(info.x11.desktop.all_names);
1720 info.x11.desktop.all_names = NULL;