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 parse_obsd_sensor(obj, arg);
329 END OBJ_ARG(obsd_sensors_fan, 0, "obsd_sensors_fan: needs 2 arguments (device and sensor number)")
330 parse_obsd_sensor(obj, arg);
331 END OBJ_ARG(obsd_sensors_volt, 0, "obsd_sensors_volt: needs 2 arguments (device and sensor number)")
332 parse_obsd_sensor(obj, arg);
333 END OBJ(obsd_vendor, 0)
334 END OBJ(obsd_product, 0)
335 #endif /* __OpenBSD__ */
336 END OBJ(buffers, &update_meminfo)
337 END OBJ(cached, &update_meminfo)
338 #define SCAN_CPU(__arg, __var) { \
340 if (__arg && sscanf(__arg, " cpu%u %n", &__var, &__offset) > 0) \
345 END OBJ(cpu, &update_cpu_usage)
346 SCAN_CPU(arg, obj->data.cpu_index);
347 DBGP2("Adding $cpu for CPU %d", obj->data.cpu_index);
349 END OBJ(cpugauge, &update_cpu_usage)
350 SIZE_DEFAULTS(gauge);
351 SCAN_CPU(arg, obj->data.cpu_index);
352 scan_gauge(arg, &obj->a, &obj->b);
353 DBGP2("Adding $cpugauge for CPU %d", obj->data.cpu_index);
355 END OBJ(cpubar, &update_cpu_usage)
357 SCAN_CPU(arg, obj->data.cpu_index);
358 scan_bar(arg, &obj->a, &obj->b);
359 DBGP2("Adding $cpubar for CPU %d", obj->data.cpu_index);
361 END OBJ(cpugraph, &update_cpu_usage)
363 SIZE_DEFAULTS(graph);
364 SCAN_CPU(arg, obj->data.cpu_index);
365 buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
366 &obj->e, &obj->char_a, &obj->char_b);
367 DBGP2("Adding $cpugraph for CPU %d", obj->data.cpu_index);
369 END OBJ(loadgraph, &update_load_average)
371 SIZE_DEFAULTS(graph);
372 buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
373 &obj->e, &obj->char_a, &obj->char_b);
377 r = sscanf(arg, "%d", &a);
379 obj->data.loadavg[0] = (r >= 1) ? (unsigned char) a : 0;
383 END OBJ(diskio, &update_diskio)
384 parse_diskio_arg(obj, arg);
385 END OBJ(diskio_read, &update_diskio)
386 parse_diskio_arg(obj, arg);
387 END OBJ(diskio_write, &update_diskio)
388 parse_diskio_arg(obj, arg);
390 END OBJ(diskiograph, &update_diskio)
391 parse_diskiograph_arg(obj, arg);
392 END OBJ(diskiograph_read, &update_diskio)
393 parse_diskiograph_arg(obj, arg);
394 END OBJ(diskiograph_write, &update_diskio)
395 parse_diskiograph_arg(obj, arg);
399 if (output_methods & TO_X) {
400 obj->data.l = arg ? get_x11_color(arg) : default_fg_color;
401 set_current_text_color(obj->data.l);
405 if (output_methods & TO_NCURSES) {
406 obj->data.l = COLOR_WHITE;
408 if(strcasecmp(arg, "red") == 0) {
409 obj->data.l = COLOR_RED;
410 }else if(strcasecmp(arg, "green") == 0) {
411 obj->data.l = COLOR_GREEN;
412 }else if(strcasecmp(arg, "yellow") == 0) {
413 obj->data.l = COLOR_YELLOW;
414 }else if(strcasecmp(arg, "blue") == 0) {
415 obj->data.l = COLOR_BLUE;
416 }else if(strcasecmp(arg, "magenta") == 0) {
417 obj->data.l = COLOR_MAGENTA;
418 }else if(strcasecmp(arg, "cyan") == 0) {
419 obj->data.l = COLOR_CYAN;
420 }else if(strcasecmp(arg, "black") == 0) {
421 obj->data.l = COLOR_BLACK;
424 set_current_text_color(obj->data.l);
425 init_pair(obj->data.l, obj->data.l, COLOR_BLACK);
429 obj->data.l = color0;
430 set_current_text_color(obj->data.l);
432 obj->data.l = color1;
433 set_current_text_color(obj->data.l);
435 obj->data.l = color2;
436 set_current_text_color(obj->data.l);
438 obj->data.l = color3;
439 set_current_text_color(obj->data.l);
441 obj->data.l = color4;
442 set_current_text_color(obj->data.l);
444 obj->data.l = color5;
445 set_current_text_color(obj->data.l);
447 obj->data.l = color6;
448 set_current_text_color(obj->data.l);
450 obj->data.l = color7;
451 set_current_text_color(obj->data.l);
453 obj->data.l = color8;
454 set_current_text_color(obj->data.l);
456 obj->data.l = color9;
457 set_current_text_color(obj->data.l);
460 obj->data.s = scan_font(arg);
462 END OBJ(conky_version, 0)
463 END OBJ(conky_build_date, 0)
464 END OBJ(conky_build_arch, 0)
465 END OBJ(downspeed, &update_net_stats)
466 parse_net_stat_arg(obj, arg, free_at_crash);
467 END OBJ(downspeedf, &update_net_stats)
468 parse_net_stat_arg(obj, arg, free_at_crash);
470 END OBJ(downspeedgraph, &update_net_stats)
471 parse_net_stat_graph_arg(obj, arg, free_at_crash);
474 obj_be_ifblock_else(ifblock_opaque, obj);
476 obj_be_ifblock_endif(ifblock_opaque, obj);
478 obj->data.s = strndup(arg ? arg : "", text_buffer_size);
479 #if defined(IMLIB2) && defined(X11)
481 obj->data.s = strndup(arg ? arg : "", text_buffer_size);
484 scan_exec_arg(obj, arg);
486 scan_exec_arg(obj, arg);
489 scan_exec_arg(obj, arg);
491 END OBJ(execgauge, 0)
492 SIZE_DEFAULTS(gauge);
493 scan_exec_arg(obj, arg);
494 END OBJ(execgraph, 0)
495 SIZE_DEFAULTS(graph);
496 scan_exec_arg(obj, arg);
498 END OBJ_ARG(execibar, 0, "execibar needs arguments")
500 scan_execi_arg(obj, arg);
502 END OBJ_ARG(execigraph, 0, "execigraph needs arguments")
503 SIZE_DEFAULTS(graph);
504 scan_execi_arg(obj, arg);
505 END OBJ_ARG(execigauge, 0, "execigauge needs arguments")
506 SIZE_DEFAULTS(gauge);
507 scan_execi_arg(obj, arg);
509 END OBJ_ARG(execi, 0, "execi needs arguments")
510 scan_execi_arg(obj, arg);
511 END OBJ_ARG(execpi, 0, "execpi needs arguments")
512 scan_execi_arg(obj, arg);
513 END OBJ_ARG(texeci, 0, "texeci needs arguments")
514 scan_execi_arg(obj, arg);
516 scan_pre_exec_arg(obj, arg);
517 END OBJ(fs_bar, &update_fs_stats)
518 init_fs_bar(obj, arg);
519 END OBJ(fs_bar_free, &update_fs_stats)
520 init_fs_bar(obj, arg);
521 END OBJ(fs_free, &update_fs_stats)
523 END OBJ(fs_used_perc, &update_fs_stats)
525 END OBJ(fs_free_perc, &update_fs_stats)
527 END OBJ(fs_size, &update_fs_stats)
529 END OBJ(fs_type, &update_fs_stats)
531 END OBJ(fs_used, &update_fs_stats)
534 obj->data.i = arg ? atoi(arg) : 1;
535 END OBJ(nameserver, &update_dns_data)
536 parse_nameserver_arg(obj, arg);
538 obj->data.i = arg ? atoi(arg) : 1;
540 obj->data.i = arg ? atoi(arg) : 1;
541 END OBJ_ARG(goto, 0, "goto needs arguments")
542 obj->data.i = atoi(arg);
547 if (sscanf(arg, "%d %d", &a, &b) != 2) {
548 sscanf(arg, "%d", &b);
554 obj->data.pair.a = a;
555 obj->data.pair.b = b;
558 END OBJ_ARG(i2c, 0, "i2c needs arguments")
559 parse_i2c_sensor(obj, arg);
560 END OBJ_ARG(platform, 0, "platform needs arguments")
561 parse_platform_sensor(obj, arg);
562 END OBJ_ARG(hwmon, 0, "hwmon needs argumanets")
563 parse_hwmon_sensor(obj, arg);
564 #endif /* __linux__ */
567 /* we have four different types of top (top, top_mem, top_time and top_io). To
568 * avoid having almost-same code four times, we have this special
570 if (strncmp(s, "top", 3) == EQUAL) {
571 add_update_callback(&update_meminfo);
572 add_update_callback(&update_top);
573 if (!parse_top_args(s, arg, obj)) {
576 } else OBJ(addr, &update_net_stats)
577 parse_net_stat_arg(obj, arg, free_at_crash);
578 #if defined(__linux__)
579 END OBJ(addrs, &update_net_stats)
580 parse_net_stat_arg(obj, arg, free_at_crash);
581 #endif /* __linux__ */
582 END OBJ_ARG(tail, 0, "tail needs arguments")
583 init_tailhead("tail", arg, obj, free_at_crash);
584 END OBJ_ARG(head, 0, "head needs arguments")
585 init_tailhead("head", arg, obj, free_at_crash);
586 END OBJ_ARG(lines, 0, "lines needs an argument")
587 obj->data.s = strndup(arg, text_buffer_size);
588 END OBJ_ARG(words, 0, "words needs a argument")
589 obj->data.s = strndup(arg, text_buffer_size);
590 END OBJ(loadavg, &update_load_average)
591 int a = 1, b = 2, c = 3, r = 3;
594 r = sscanf(arg, "%d %d %d", &a, &b, &c);
595 if (r >= 3 && (c < 1 || c > 3)) {
598 if (r >= 2 && (b < 1 || b > 3)) {
601 if (r >= 1 && (a < 1 || a > 3)) {
605 obj->data.loadavg[0] = (r >= 1) ? (unsigned char) a : 0;
606 obj->data.loadavg[1] = (r >= 2) ? (unsigned char) b : 0;
607 obj->data.loadavg[2] = (r >= 3) ? (unsigned char) c : 0;
608 END OBJ_IF_ARG(if_empty, 0, "if_empty needs an argument")
609 obj->data.ifblock.s = strndup(arg, text_buffer_size);
610 obj->sub = malloc(sizeof(struct text_object));
611 extract_variable_text_internal(obj->sub, obj->data.ifblock.s);
612 END OBJ_IF_ARG(if_match, 0, "if_match needs arguments")
613 obj->data.ifblock.s = strndup(arg, text_buffer_size);
614 obj->sub = malloc(sizeof(struct text_object));
615 extract_variable_text_internal(obj->sub, obj->data.ifblock.s);
616 END OBJ_IF_ARG(if_existing, 0, "if_existing needs an argument or two")
617 char buf1[256], buf2[256];
618 int r = sscanf(arg, "%255s %255[^\n]", buf1, buf2);
621 obj->data.ifblock.s = strndup(buf1, text_buffer_size);
622 obj->data.ifblock.str = NULL;
624 obj->data.ifblock.s = strndup(buf1, text_buffer_size);
625 obj->data.ifblock.str = strndup(buf2, text_buffer_size);
627 DBGP("if_existing: '%s' '%s'", obj->data.ifblock.s, obj->data.ifblock.str);
628 END OBJ_IF_ARG(if_mounted, 0, "if_mounted needs an argument")
629 obj->data.ifblock.s = strndup(arg, text_buffer_size);
631 END OBJ_IF_ARG(if_running, &update_top, "if_running needs an argument")
633 obj->data.ifblock.s = strndup(arg, text_buffer_size);
635 END OBJ_IF_ARG(if_running, 0, "if_running needs an argument")
638 snprintf(buf, 256, "pidof %s >/dev/null", arg);
639 obj->data.ifblock.s = strndup(buf, text_buffer_size);
644 parse_local_mail_args(obj, arg);
645 END OBJ(new_mails, 0)
646 parse_local_mail_args(obj, arg);
647 END OBJ(seen_mails, 0)
648 parse_local_mail_args(obj, arg);
649 END OBJ(unseen_mails, 0)
650 parse_local_mail_args(obj, arg);
651 END OBJ(flagged_mails, 0)
652 parse_local_mail_args(obj, arg);
653 END OBJ(unflagged_mails, 0)
654 parse_local_mail_args(obj, arg);
655 END OBJ(forwarded_mails, 0)
656 parse_local_mail_args(obj, arg);
657 END OBJ(unforwarded_mails, 0)
658 parse_local_mail_args(obj, arg);
659 END OBJ(replied_mails, 0)
660 parse_local_mail_args(obj, arg);
661 END OBJ(unreplied_mails, 0)
662 parse_local_mail_args(obj, arg);
663 END OBJ(draft_mails, 0)
664 parse_local_mail_args(obj, arg);
665 END OBJ(trashed_mails, 0)
666 parse_local_mail_args(obj, arg);
668 parse_mboxscan_arg(obj, arg);
669 END OBJ(mem, &update_meminfo)
670 END OBJ(memeasyfree, &update_meminfo)
671 END OBJ(memfree, &update_meminfo)
672 END OBJ(memmax, &update_meminfo)
673 END OBJ(memperc, &update_meminfo)
675 END OBJ(memgauge, &update_meminfo)
676 SIZE_DEFAULTS(gauge);
677 scan_gauge(arg, &obj->data.pair.a, &obj->data.pair.b);
679 END OBJ(membar, &update_meminfo)
681 scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
683 END OBJ(memgraph, &update_meminfo)
685 SIZE_DEFAULTS(graph);
686 buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
687 &obj->e, &obj->char_a, &obj->char_b);
692 parse_mixer_arg(obj, arg);
694 parse_mixer_arg(obj, arg);
696 parse_mixer_arg(obj, arg);
699 scan_mixer_bar(obj, arg);
700 END OBJ(mixerlbar, 0)
701 scan_mixer_bar(obj, arg);
702 END OBJ(mixerrbar, 0)
703 scan_mixer_bar(obj, arg);
705 END OBJ_IF(if_mixer_mute, 0)
706 parse_mixer_arg(obj, arg);
708 END OBJ(monitor, &update_x11info)
709 END OBJ(monitor_number, &update_x11info)
710 END OBJ(desktop, &update_x11info)
711 END OBJ(desktop_number, &update_x11info)
712 END OBJ(desktop_name, &update_x11info)
715 END OBJ(processes, &update_total_processes)
716 END OBJ(running_processes, &update_running_processes)
717 END OBJ(shadecolor, 0)
719 obj->data.l = arg ? get_x11_color(arg) : default_bg_color;
721 END OBJ(outlinecolor, 0)
723 obj->data.l = arg ? get_x11_color(arg) : default_out_color;
725 END OBJ(stippled_hr, 0)
727 int a = get_stippled_borders(), b = 1;
730 if (sscanf(arg, "%d %d", &a, &b) != 2) {
731 sscanf(arg, "%d", &b);
737 obj->data.pair.a = a;
738 obj->data.pair.b = b;
740 END OBJ(swap, &update_meminfo)
741 END OBJ(swapfree, &update_meminfo)
742 END OBJ(swapmax, &update_meminfo)
743 END OBJ(swapperc, &update_meminfo)
744 END OBJ(swapbar, &update_meminfo)
746 scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
753 scan_tztime(obj, arg);
755 END OBJ_ARG(iconv_start, 0, "Iconv requires arguments")
756 init_iconv_start(obj, free_at_crash, arg);
757 END OBJ(iconv_stop, 0)
760 END OBJ(totaldown, &update_net_stats)
761 parse_net_stat_arg(obj, arg, free_at_crash);
762 END OBJ(totalup, &update_net_stats)
763 parse_net_stat_arg(obj, arg, free_at_crash);
765 END OBJ_IF(if_updatenr, 0)
766 obj->data.ifblock.i = arg ? atoi(arg) : 0;
767 if(obj->data.ifblock.i == 0) CRIT_ERR(obj, free_at_crash, "if_updatenr needs a number above 0 as argument");
768 set_updatereset(obj->data.ifblock.i > get_updatereset() ? obj->data.ifblock.i : get_updatereset());
770 obj->data.i = arg ? atoi(arg) : 0;
772 obj->data.i = arg ? atoi(arg) : 0;
773 END OBJ(upspeed, &update_net_stats)
774 parse_net_stat_arg(obj, arg, free_at_crash);
775 END OBJ(upspeedf, &update_net_stats)
776 parse_net_stat_arg(obj, arg, free_at_crash);
778 END OBJ(upspeedgraph, &update_net_stats)
779 parse_net_stat_graph_arg(obj, arg, free_at_crash);
781 END OBJ(uptime_short, &update_uptime)
782 END OBJ(uptime, &update_uptime)
783 END OBJ(user_names, &update_users)
784 END OBJ(user_times, &update_users)
785 END OBJ(user_terms, &update_users)
786 END OBJ(user_number, &update_users)
787 #if defined(__linux__)
788 END OBJ(gw_iface, &update_gateway_info)
789 END OBJ(gw_ip, &update_gateway_info)
790 #endif /* !__linux__ */
792 END OBJ(adt746xcpu, 0)
793 END OBJ(adt746xfan, 0)
794 #endif /* !__OpenBSD__ */
795 #if (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
796 || defined(__OpenBSD__)) && (defined(i386) || defined(__i386__))
797 END OBJ(apm_adapter, 0)
798 END OBJ(apm_battery_life, 0)
799 END OBJ(apm_battery_time, 0)
800 #endif /* __FreeBSD__ */
801 END OBJ(imap_unseen, 0)
802 parse_imap_mail_args(obj, arg);
803 END OBJ(imap_messages, 0)
804 parse_imap_mail_args(obj, arg);
805 END OBJ(pop3_unseen, 0)
806 parse_pop3_mail_args(obj, arg);
807 END OBJ(pop3_used, 0)
808 parse_pop3_mail_args(obj, arg);
810 END OBJ_ARG(smapi, 0, "smapi needs an argument")
811 obj->data.s = strndup(arg, text_buffer_size);
812 END OBJ_IF_ARG(if_smapi_bat_installed, 0, "if_smapi_bat_installed needs an argument")
813 obj->data.ifblock.s = strndup(arg, text_buffer_size);
814 END OBJ_ARG(smapi_bat_perc, 0, "smapi_bat_perc needs an argument")
815 obj->data.s = strndup(arg, text_buffer_size);
816 END OBJ_ARG(smapi_bat_temp, 0, "smapi_bat_temp needs an argument")
817 obj->data.s = strndup(arg, text_buffer_size);
818 END OBJ_ARG(smapi_bat_power, 0, "smapi_bat_power needs an argument")
819 obj->data.s = strndup(arg, text_buffer_size);
821 END OBJ_ARG(smapi_bat_bar, 0, "smapi_bat_bar needs an argument")
824 if(sscanf(arg, "%i %n", &obj->data.i, &cnt) <= 0) {
825 NORM_ERR("first argument to smapi_bat_bar must be an integer value");
829 arg = scan_bar(arg + cnt, &obj->a, &obj->b);
834 #define mpd_set_maxlen(name) \
837 sscanf(arg, "%d", &i); \
839 obj->data.i = i + 1; \
841 NORM_ERR(#name ": invalid length argument"); \
843 END OBJ(mpd_artist, &update_mpd)
844 mpd_set_maxlen(mpd_artist);
846 END OBJ(mpd_title, &update_mpd)
847 mpd_set_maxlen(mpd_title);
849 END OBJ(mpd_random, &update_mpd) init_mpd();
850 END OBJ(mpd_repeat, &update_mpd) init_mpd();
851 END OBJ(mpd_elapsed, &update_mpd) init_mpd();
852 END OBJ(mpd_length, &update_mpd) init_mpd();
853 END OBJ(mpd_track, &update_mpd)
854 mpd_set_maxlen(mpd_track);
856 END OBJ(mpd_name, &update_mpd)
857 mpd_set_maxlen(mpd_name);
859 END OBJ(mpd_file, &update_mpd)
860 mpd_set_maxlen(mpd_file);
862 END OBJ(mpd_percent, &update_mpd) init_mpd();
863 END OBJ(mpd_album, &update_mpd)
864 mpd_set_maxlen(mpd_album);
866 END OBJ(mpd_vol, &update_mpd) init_mpd();
867 END OBJ(mpd_bitrate, &update_mpd) init_mpd();
868 END OBJ(mpd_status, &update_mpd) init_mpd();
869 END OBJ(mpd_bar, &update_mpd)
871 scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
873 END OBJ(mpd_smart, &update_mpd)
874 mpd_set_maxlen(mpd_smart);
876 END OBJ_IF(if_mpd_playing, &update_mpd)
878 #undef mpd_set_maxlen
881 END OBJ(moc_state, &update_moc)
882 END OBJ(moc_file, &update_moc)
883 END OBJ(moc_title, &update_moc)
884 END OBJ(moc_artist, &update_moc)
885 END OBJ(moc_song, &update_moc)
886 END OBJ(moc_album, &update_moc)
887 END OBJ(moc_totaltime, &update_moc)
888 END OBJ(moc_timeleft, &update_moc)
889 END OBJ(moc_curtime, &update_moc)
890 END OBJ(moc_bitrate, &update_moc)
891 END OBJ(moc_rate, &update_moc)
894 END OBJ(xmms2_artist, &update_xmms2)
895 END OBJ(xmms2_album, &update_xmms2)
896 END OBJ(xmms2_title, &update_xmms2)
897 END OBJ(xmms2_genre, &update_xmms2)
898 END OBJ(xmms2_comment, &update_xmms2)
899 END OBJ(xmms2_url, &update_xmms2)
900 END OBJ(xmms2_tracknr, &update_xmms2)
901 END OBJ(xmms2_bitrate, &update_xmms2)
902 END OBJ(xmms2_date, &update_xmms2)
903 END OBJ(xmms2_id, &update_xmms2)
904 END OBJ(xmms2_duration, &update_xmms2)
905 END OBJ(xmms2_elapsed, &update_xmms2)
906 END OBJ(xmms2_size, &update_xmms2)
907 END OBJ(xmms2_status, &update_xmms2)
908 END OBJ(xmms2_percent, &update_xmms2)
910 END OBJ(xmms2_bar, &update_xmms2)
912 scan_bar(arg, &obj->data.pair.a, &obj->data.pair.b);
914 END OBJ(xmms2_smart, &update_xmms2)
915 END OBJ(xmms2_playlist, &update_xmms2)
916 END OBJ(xmms2_timesplayed, &update_xmms2)
917 END OBJ_IF(if_xmms2_connected, &update_xmms2)
920 END OBJ(audacious_status, &update_audacious)
921 END OBJ_ARG(audacious_title, &update_audacious, "audacious_title needs an argument")
922 sscanf(arg, "%d", &info.audacious.max_title_len);
923 if (info.audacious.max_title_len > 0) {
924 info.audacious.max_title_len++;
926 CRIT_ERR(obj, free_at_crash, "audacious_title: invalid length argument");
928 END OBJ(audacious_length, &update_audacious)
929 END OBJ(audacious_length_seconds, &update_audacious)
930 END OBJ(audacious_position, &update_audacious)
931 END OBJ(audacious_position_seconds, &update_audacious)
932 END OBJ(audacious_bitrate, &update_audacious)
933 END OBJ(audacious_frequency, &update_audacious)
934 END OBJ(audacious_channels, &update_audacious)
935 END OBJ(audacious_filename, &update_audacious)
936 END OBJ(audacious_playlist_length, &update_audacious)
937 END OBJ(audacious_playlist_position, &update_audacious)
938 END OBJ(audacious_main_volume, &update_audacious)
940 END OBJ(audacious_bar, &update_audacious)
942 scan_bar(arg, &obj->a, &obj->b);
946 END OBJ(bmpx_title, &update_bmpx)
947 memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
948 END OBJ(bmpx_artist, &update_bmpx)
949 memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
950 END OBJ(bmpx_album, &update_bmpx)
951 memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
952 END OBJ(bmpx_track, &update_bmpx)
953 memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
954 END OBJ(bmpx_uri, &update_bmpx)
955 memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
956 END OBJ(bmpx_bitrate, &update_bmpx)
957 memset(&(info.bmpx), 0, sizeof(struct bmpx_s));
960 END OBJ_ARG(eve, 0, "eve needs arguments: <userid> <apikey> <characterid>")
964 END OBJ_ARG(curl, 0, "curl needs arguments: <uri> <interval in minutes>")
965 curl_parse_arg(obj, arg);
968 END OBJ_ARG(rss, 0, "rss needs arguments: <uri> <interval in minutes> <action> [act_par] [spaces in front]")
969 rss_scan_arg(obj, arg);
972 END OBJ_ARG(weather, 0, "weather needs arguments: <uri> <locID> <data_type> [interval in minutes]")
973 scan_weather_arg(obj, arg, free_at_crash);
976 END OBJ_ARG(weather_forecast, 0, "weather_forecast needs arguments: <uri> <locID> <day> <data_type> [interval in minutes]")
977 scan_weather_forecast_arg(obj, arg, free_at_crash);
980 END OBJ_ARG(lua, 0, "lua needs arguments: <function name> [function parameters]")
981 obj->data.s = strndup(arg, text_buffer_size);
982 END OBJ_ARG(lua_parse, 0, "lua_parse needs arguments: <function name> [function parameters]")
983 obj->data.s = strndup(arg, text_buffer_size);
984 END OBJ_ARG(lua_bar, 0, "lua_bar needs arguments: <height>,<width> <function name> [function parameters]")
986 arg = scan_bar(arg, &obj->a, &obj->b);
988 obj->data.s = strndup(arg, text_buffer_size);
990 CRIT_ERR(obj, free_at_crash, "lua_bar needs arguments: <height>,<width> <function name> [function parameters]");
993 END OBJ_ARG(lua_graph, 0, "lua_graph needs arguments: <function name> [height],[width] [gradient colour 1] [gradient colour 2] [scale] [-t] [-l]")
995 SIZE_DEFAULTS(graph);
996 buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
997 &obj->e, &obj->char_a, &obj->char_b);
1001 CRIT_ERR(obj, free_at_crash, "lua_graph needs arguments: <function name> [height],[width] [gradient colour 1] [gradient colour 2] [scale] [-t] [-l]");
1003 END OBJ_ARG(lua_gauge, 0, "lua_gauge needs arguments: <height>,<width> <function name> [function parameters]")
1004 SIZE_DEFAULTS(gauge);
1005 arg = scan_gauge(arg, &obj->a, &obj->b);
1007 obj->data.s = strndup(arg, text_buffer_size);
1009 CRIT_ERR(obj, free_at_crash, "lua_gauge needs arguments: <height>,<width> <function name> [function parameters]");
1012 #endif /* HAVE_LUA */
1014 END OBJ(hddtemp, &update_hddtemp)
1016 obj->data.s = strndup(arg, text_buffer_size);
1017 #endif /* HDDTEMP */
1018 #ifdef TCP_PORT_MONITOR
1019 END OBJ_ARG(tcp_portmon, &tcp_portmon_update, "tcp_portmon: needs arguments")
1020 tcp_portmon_init(obj, arg);
1021 #endif /* TCP_PORT_MONITOR */
1022 END OBJ(entropy_avail, &update_entropy)
1023 END OBJ(entropy_perc, &update_entropy)
1024 END OBJ(entropy_poolsize, &update_entropy)
1025 END OBJ(entropy_bar, &update_entropy)
1027 scan_bar(arg, &obj->a, &obj->b);
1028 END OBJ_ARG(include, 0, "include needs a argument")
1029 struct conftree *leaf = conftree_add(currentconffile, arg);
1031 if (load_config_file(arg) == TRUE) {
1032 obj->sub = malloc(sizeof(struct text_object));
1033 currentconffile = leaf;
1034 extract_variable_text_internal(obj->sub, get_global_text());
1035 currentconffile = leaf->back;
1037 NORM_ERR("Can't load configfile '%s'.", arg);
1040 NORM_ERR("You are trying to load '%s' recursively, I'm only going to load it once to prevent an infinite loop.", arg);
1042 END OBJ_ARG(blink, 0, "blink needs a argument")
1043 obj->sub = malloc(sizeof(struct text_object));
1044 extract_variable_text_internal(obj->sub, arg);
1045 END OBJ_ARG(to_bytes, 0, "to_bytes needs a argument")
1046 obj->sub = malloc(sizeof(struct text_object));
1047 extract_variable_text_internal(obj->sub, arg);
1049 parse_scroll_arg(obj, arg, free_at_crash);
1050 END OBJ_ARG(combine, 0, "combine needs arguments: <text1> <text2>")
1051 parse_combine_arg(obj, arg, free_at_crash);
1053 END OBJ_ARG(nvidia, 0, "nvidia needs an argument")
1054 if (set_nvidia_type(obj, arg)) {
1055 CRIT_ERR(obj, free_at_crash, "nvidia: invalid argument"
1056 " specified: '%s'\n", arg);
1060 END OBJ_ARG(apcupsd, &update_apcupsd, "apcupsd needs arguments: <host> <port>")
1063 if (sscanf(arg, "%63s %d", host, &port) != 2) {
1064 CRIT_ERR(obj, free_at_crash, "apcupsd needs arguments: <host> <port>");
1066 info.apcupsd.port = htons(port);
1067 strncpy(info.apcupsd.host, host, sizeof(info.apcupsd.host));
1069 END OBJ(apcupsd_name, &update_apcupsd)
1070 END OBJ(apcupsd_model, &update_apcupsd)
1071 END OBJ(apcupsd_upsmode, &update_apcupsd)
1072 END OBJ(apcupsd_cable, &update_apcupsd)
1073 END OBJ(apcupsd_status, &update_apcupsd)
1074 END OBJ(apcupsd_linev, &update_apcupsd)
1075 END OBJ(apcupsd_load, &update_apcupsd)
1076 END OBJ(apcupsd_loadbar, &update_apcupsd)
1078 scan_bar(arg, &obj->a, &obj->b);
1080 END OBJ(apcupsd_loadgraph, &update_apcupsd)
1082 SIZE_DEFAULTS(graph);
1083 buf = scan_graph(arg, &obj->a, &obj->b, &obj->c, &obj->d,
1084 &obj->e, &obj->char_a, &obj->char_b);
1086 END OBJ(apcupsd_loadgauge, &update_apcupsd)
1087 SIZE_DEFAULTS(gauge);
1088 scan_gauge(arg, &obj->a, &obj->b);
1090 END OBJ(apcupsd_charge, &update_apcupsd)
1091 END OBJ(apcupsd_timeleft, &update_apcupsd)
1092 END OBJ(apcupsd_temp, &update_apcupsd)
1093 END OBJ(apcupsd_lastxfer, &update_apcupsd)
1094 #endif /* APCUPSD */
1098 NORM_ERR("unknown variable %s", s);
1099 obj->type = OBJ_text;
1100 snprintf(buf, 256, "${%s}", s);
1101 obj->data.s = strndup(buf, text_buffer_size);
1111 #undef SIZE_DEFAULTS
1117 * - assumes that *string is '#'
1118 * - removes the part from '#' to the end of line ('\n' or '\0')
1119 * - it removes the '\n'
1120 * - copies the last char into 'char *last' argument, which should be a pointer
1121 * to a char rather than a string.
1123 static size_t remove_comment(char *string, char *last)
1126 while (*end != '\0' && *end != '\n') {
1129 if (last) *last = *end;
1130 if (*end == '\n') end++;
1131 strfold(string, end - string);
1132 return end - string;
1135 size_t remove_comments(char *string)
1139 for (curplace = string; *curplace != 0; curplace++) {
1140 if (*curplace == '\\' && *(curplace + 1) == '#') {
1141 // strcpy can't be used for overlapping strings
1142 strfold(curplace, 1);
1144 } else if (*curplace == '#') {
1145 folded += remove_comment(curplace, 0);
1151 int extract_variable_text_internal(struct text_object *retval, const char *const_p)
1153 struct text_object *obj;
1154 char *p, *s, *orig_p;
1156 void *ifblock_opaque = NULL;
1161 p = strndup(const_p, max_user_text - 1);
1162 while (text_contains_templates(p)) {
1164 tmp = find_and_replace_templates(p);
1170 if (strcmp(p, const_p)) {
1171 DBGP("replaced all templates in text: input is\n'%s'\noutput is\n'%s'", const_p, p);
1173 DBGP("no templates to replace");
1176 memset(retval, 0, sizeof(struct text_object));
1178 line = global_text_lines;
1186 obj = create_plain_text(s);
1188 append_object(retval, obj);
1198 /* variable is either $foo or ${foo} */
1200 unsigned int brl = 1, brr = 0;
1204 while (*p && brl != brr) {
1219 while (*p && (isalnum((int) *p) || *p == '_')) {
1224 /* copy variable to buffer */
1225 len = (p - s > 255) ? 255 : (p - s);
1226 strncpy(buf, s, len);
1234 /* search for variable in environment */
1238 obj = create_plain_text(var);
1240 append_object(retval, obj);
1245 /* if variable wasn't found in environment, use some special */
1250 if (strchr(buf, ' ')) {
1251 arg = strchr(buf, ' ');
1254 while (isspace((int) *arg)) {
1262 /* lowercase variable name */
1265 *tmp_p = tolower(*tmp_p);
1269 obj = construct_text_object(buf, arg,
1270 line, &ifblock_opaque, orig_p);
1272 append_object(retval, obj);
1276 obj = create_plain_text("$");
1279 append_object(retval, obj);
1282 } else if (*p == '\\' && *(p+1) == '#') {
1284 } else if (*p == '#') {
1286 if (remove_comment(p, &c) && p > orig_p && c == '\n') {
1287 /* if remove_comment removed a newline, we need to 'back up' with p */
1293 obj = create_plain_text(s);
1295 append_object(retval, obj);
1298 if (!ifblock_stack_empty(&ifblock_opaque)) {
1299 NORM_ERR("one or more $endif's are missing");
1307 * Frees the list of text objects root points to. When internal = 1, it won't
1308 * free global objects.
1310 void free_text_objects(struct text_object *root, int internal)
1312 struct text_object *obj;
1318 #define data obj->data
1319 for (obj = root->prev; obj; obj = root->prev) {
1320 root->prev = obj->prev;
1321 switch (obj->type) {
1326 #endif /* !__OpenBSD__ */
1331 free_sysfs_sensor(obj);
1333 #endif /* __linux__ */
1349 case OBJ_seen_mails:
1350 case OBJ_unseen_mails:
1351 case OBJ_flagged_mails:
1352 case OBJ_unflagged_mails:
1353 case OBJ_forwarded_mails:
1354 case OBJ_unforwarded_mails:
1355 case OBJ_replied_mails:
1356 case OBJ_unreplied_mails:
1357 case OBJ_draft_mails:
1358 case OBJ_trashed_mails:
1359 free(data.local_mail.mbox);
1361 case OBJ_imap_unseen:
1362 case OBJ_imap_messages:
1363 case OBJ_pop3_unseen:
1369 free_text_objects(obj->sub, 1);
1372 case OBJ_if_existing:
1373 case OBJ_if_mounted:
1374 case OBJ_if_running:
1375 free(data.ifblock.s);
1376 free(data.ifblock.str);
1396 case OBJ_iconv_start:
1401 case OBJ_disk_protect:
1405 free(data.ifblock.s);
1406 free(data.ifblock.str);
1409 free_gateway_info();
1411 case OBJ_ioscheduler:
1416 #if (defined(__FreeBSD__) || defined(__linux__))
1418 free(data.ifblock.s);
1419 free(data.ifblock.str);
1423 case OBJ_xmms2_artist:
1424 if (info.xmms2.artist) {
1425 free(info.xmms2.artist);
1426 info.xmms2.artist = 0;
1429 case OBJ_xmms2_album:
1430 if (info.xmms2.album) {
1431 free(info.xmms2.album);
1432 info.xmms2.album = 0;
1435 case OBJ_xmms2_title:
1436 if (info.xmms2.title) {
1437 free(info.xmms2.title);
1438 info.xmms2.title = 0;
1441 case OBJ_xmms2_genre:
1442 if (info.xmms2.genre) {
1443 free(info.xmms2.genre);
1444 info.xmms2.genre = 0;
1447 case OBJ_xmms2_comment:
1448 if (info.xmms2.comment) {
1449 free(info.xmms2.comment);
1450 info.xmms2.comment = 0;
1454 if (info.xmms2.url) {
1455 free(info.xmms2.url);
1459 case OBJ_xmms2_date:
1460 if (info.xmms2.date) {
1461 free(info.xmms2.date);
1462 info.xmms2.date = 0;
1465 case OBJ_xmms2_status:
1466 if (info.xmms2.status) {
1467 free(info.xmms2.status);
1468 info.xmms2.status = 0;
1471 case OBJ_xmms2_playlist:
1472 if (info.xmms2.playlist) {
1473 free(info.xmms2.playlist);
1474 info.xmms2.playlist = 0;
1477 case OBJ_xmms2_smart:
1478 if (info.xmms2.artist) {
1479 free(info.xmms2.artist);
1480 info.xmms2.artist = 0;
1482 if (info.xmms2.title) {
1483 free(info.xmms2.title);
1484 info.xmms2.title = 0;
1486 if (info.xmms2.url) {
1487 free(info.xmms2.url);
1493 case OBJ_bmpx_title:
1494 case OBJ_bmpx_artist:
1495 case OBJ_bmpx_album:
1496 case OBJ_bmpx_track:
1498 case OBJ_bmpx_bitrate:
1513 rss_free_obj_info(obj);
1522 case OBJ_weather_forecast:
1536 #endif /* HAVE_LUA */
1543 case OBJ_battery_short:
1546 case OBJ_battery_time:
1549 #endif /* !__OpenBSD__ */
1555 case OBJ_execigraph:
1556 case OBJ_execigauge:
1560 case OBJ_nameserver:
1569 free_top(obj, internal);
1579 #endif /* HDDTEMP */
1580 case OBJ_entropy_avail:
1581 case OBJ_entropy_perc:
1582 case OBJ_entropy_poolsize:
1583 case OBJ_entropy_bar:
1585 case OBJ_user_names:
1586 if (info.users.names) {
1587 free(info.users.names);
1588 info.users.names = 0;
1591 case OBJ_user_terms:
1592 if (info.users.terms) {
1593 free(info.users.terms);
1594 info.users.terms = 0;
1597 case OBJ_user_times:
1598 if (info.users.times) {
1599 free(info.users.times);
1600 info.users.times = 0;
1605 case OBJ_smapi_bat_perc:
1606 case OBJ_smapi_bat_temp:
1607 case OBJ_smapi_bat_power:
1610 case OBJ_if_smapi_bat_installed:
1611 free(data.ifblock.s);
1612 free(data.ifblock.str);
1622 case OBJ_mpd_artist:
1624 case OBJ_mpd_random:
1625 case OBJ_mpd_repeat:
1627 case OBJ_mpd_bitrate:
1628 case OBJ_mpd_status:
1630 case OBJ_mpd_elapsed:
1631 case OBJ_mpd_length:
1635 case OBJ_mpd_percent:
1637 case OBJ_if_mpd_playing:
1645 case OBJ_moc_artist:
1648 case OBJ_moc_totaltime:
1649 case OBJ_moc_timeleft:
1650 case OBJ_moc_curtime:
1651 case OBJ_moc_bitrate:
1660 free_text_objects(obj->sub, 1);
1672 case OBJ_apcupsd_name:
1673 case OBJ_apcupsd_model:
1674 case OBJ_apcupsd_upsmode:
1675 case OBJ_apcupsd_cable:
1676 case OBJ_apcupsd_status:
1677 case OBJ_apcupsd_linev:
1678 case OBJ_apcupsd_load:
1679 case OBJ_apcupsd_loadbar:
1681 case OBJ_apcupsd_loadgraph:
1682 case OBJ_apcupsd_loadgauge:
1684 case OBJ_apcupsd_charge:
1685 case OBJ_apcupsd_timeleft:
1686 case OBJ_apcupsd_temp:
1687 case OBJ_apcupsd_lastxfer:
1689 #endif /* APCUPSD */
1690 #ifdef TCP_PORT_MONITOR
1691 case OBJ_tcp_portmon:
1692 tcp_portmon_free(obj);
1694 #endif /* TCP_PORT_MONITOR */
1697 case OBJ_desktop_number:
1698 case OBJ_desktop_name:
1699 if(info.x11.desktop.name && !internal) {
1700 free(info.x11.desktop.name);
1701 info.x11.desktop.name = NULL;
1703 if(info.x11.desktop.all_names && !internal) {
1704 free(info.x11.desktop.all_names);
1705 info.x11.desktop.all_names = NULL;