From 44b82311b9a16e4134242cd5f8d4acbeb881b08a Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Sat, 1 Aug 2009 20:45:43 +0200 Subject: [PATCH] Added support for out_to_ncurses All ERR()'s are renamed to NORM_ERR() and box to mbox so that they don't clash with things in ncurses.h . Ncurses is enabled by default when building conky but can be disabled with --disable-ncurses . At the moment configure doesn't check if ncurses is actually available. I'm adding support for ncurses so that we can make as much things as possible that are only available in X11 also available in console in the future. --- ChangeLog | 3 + configure.ac.in | 14 ++ doc/config_settings.xml | 11 ++ extras/nano/conky.nanorc | 2 +- extras/vim/syntax/conkyrc.vim | 2 +- src/algebra.c | 8 +- src/apcupsd.c | 2 +- src/bmpx.c | 8 +- src/ccurl_thread.c | 8 +- src/colours.c | 2 +- src/common.c | 6 +- src/conky.c | 396 ++++++++++++++++++++++------------------- src/conky.h | 3 + src/diskio.c | 2 +- src/fonts.c | 6 +- src/fs.c | 8 +- src/hddtemp.c | 6 +- src/imlib2.c | 8 +- src/linux.c | 16 +- src/llua.c | 14 +- src/logging.h | 4 +- src/mail.c | 48 ++--- src/mail.h | 2 +- src/mboxscan.c | 2 +- src/mixer.c | 4 +- src/moc.c | 4 +- src/mpd.c | 8 +- src/openbsd.c | 18 +- src/rss.c | 2 +- src/smapi.c | 2 +- src/solaris.c | 2 +- src/weather.c | 6 +- src/x11.c | 6 +- 33 files changed, 348 insertions(+), 285 deletions(-) diff --git a/ChangeLog b/ChangeLog index 554e219..6190b74 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2009-08-01 + * Added support for out_to_ncurses + 2009-07-31 * Removed alias config option due to brokenness * Added support for $include diff --git a/configure.ac.in b/configure.ac.in index b8e2d90..6c7892a 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -123,6 +123,20 @@ if test $dah != "no"; then AC_DEFINE(OWN_WINDOW, 1, [Define if you want support for window creating]) fi +dnl +dnl NCURSES option +dnl + +AC_ARG_ENABLE([ncurses], + AC_HELP_STRING([--disable-ncurses], [disable if you do not want ncurses support in conky @<:@default=yes@:>@]), + [want_ncurses="$enableval"], [want_ncurses=yes]) + +AM_CONDITIONAL(BUILD_NCURSES, test x$want_ncurses = xyes) +if test x$want_ncurses = xyes; then + conky_LIBS="$conky_LIBS -lncurses" + AC_DEFINE(NCURSES, 1, [Define for ncurses support]) +fi + dnl dnl Audacious Media Player diff --git a/doc/config_settings.xml b/doc/config_settings.xml index bae2d83..2b8bcb9 100644 --- a/doc/config_settings.xml +++ b/doc/config_settings.xml @@ -491,6 +491,17 @@ + + + + Print text in the console, but use ncurses so that + conky can print the text of a new update over the old text. + (In the future this will provide more useful things) + + + + + diff --git a/extras/nano/conky.nanorc b/extras/nano/conky.nanorc index e3d2d2a..9bb4274 100644 --- a/extras/nano/conky.nanorc +++ b/extras/nano/conky.nanorc @@ -5,7 +5,7 @@ syntax "conky" "(\.*conkyrc.*$|conky.conf)" ## Configuration items -color green "\<(alignment|append_file|background|border_inner_margin|border_outer_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_size|default_color|default_gauge_size|default_graph_size|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|extra_newline|font|format_human_readable|gap_x|gap_y|if_up_strictness|imap|imlib_cache_flush_interval|imlib_cache_size|lua_draw_hook_post|lua_draw_hook_pre|lua_load|mail_spool|max_port_monitor_connections|max_specials|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|net_avg_samples|no_buffers|out_to_console|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|top_cpu_separate|top_name_width|total_run_times|update_interval|update_interval_on_battery|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>" +color green "\<(alignment|append_file|background|border_inner_margin|border_outer_margin|border_width|color0|color1|color2|color3|color4|color5|color6|color7|color8|color9|colorN|cpu_avg_samples|default_bar_size|default_color|default_gauge_size|default_graph_size|default_outline_color|default_shade_color|diskio_avg_samples|display|double_buffer|draw_borders|draw_graph_borders|draw_outline|draw_shades|extra_newline|font|format_human_readable|gap_x|gap_y|if_up_strictness|imap|imlib_cache_flush_interval|imlib_cache_size|lua_draw_hook_post|lua_draw_hook_pre|lua_load|mail_spool|max_port_monitor_connections|max_specials|max_user_text|maximum_width|minimum_size|mpd_host|mpd_password|mpd_port|music_player_interval|net_avg_samples|no_buffers|out_to_console|out_to_ncurses|out_to_stderr|out_to_x|override_utf8_locale|overwrite_file|own_window|own_window_class|own_window_colour|own_window_hints|own_window_title|own_window_transparent|own_window_type|pad_percents|pop3|sensor_device|short_units|show_graph_range|show_graph_scale|stippled_borders|temperature_unit|template|template0|template1|template2|template3|template4|template5|template6|template7|template8|template9|text|text_buffer_size|top_cpu_separate|top_name_width|total_run_times|update_interval|update_interval_on_battery|uppercase|use_spacer|use_xft|xftalpha|xftfont)\>" ## Configuration item constants color yellow "\<(above|below|bottom_left|bottom_right|bottom_middle|desktop|dock|no|none|normal|override|skip_pager|skip_taskbar|sticky|top_left|top_right|top_middle|middle_left|middle_right|undecorated|yes)\>" diff --git a/extras/vim/syntax/conkyrc.vim b/extras/vim/syntax/conkyrc.vim index e0ba646..4a1d773 100644 --- a/extras/vim/syntax/conkyrc.vim +++ b/extras/vim/syntax/conkyrc.vim @@ -12,7 +12,7 @@ endif syn region ConkyrcComment start=/^\s*#/ end=/$/ -syn keyword ConkyrcSetting alignment append_file background border_inner_margin border_outer_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_size default_color default_gauge_size default_graph_size default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades extra_newline font format_human_readable gap_x gap_y if_up_strictness imap imlib_cache_flush_interval imlib_cache_size lua_draw_hook_post lua_draw_hook_pre lua_load mail_spool max_port_monitor_connections max_specials max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval net_avg_samples no_buffers out_to_console out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size top_cpu_separate top_name_width total_run_times update_interval update_interval_on_battery uppercase use_spacer use_xft xftalpha xftfont +syn keyword ConkyrcSetting alignment append_file background border_inner_margin border_outer_margin border_width color0 color1 color2 color3 color4 color5 color6 color7 color8 color9 colorN cpu_avg_samples default_bar_size default_color default_gauge_size default_graph_size default_outline_color default_shade_color diskio_avg_samples display double_buffer draw_borders draw_graph_borders draw_outline draw_shades extra_newline font format_human_readable gap_x gap_y if_up_strictness imap imlib_cache_flush_interval imlib_cache_size lua_draw_hook_post lua_draw_hook_pre lua_load mail_spool max_port_monitor_connections max_specials max_user_text maximum_width minimum_size mpd_host mpd_password mpd_port music_player_interval net_avg_samples no_buffers out_to_console out_to_ncurses out_to_stderr out_to_x override_utf8_locale overwrite_file own_window own_window_class own_window_colour own_window_hints own_window_title own_window_transparent own_window_type pad_percents pop3 sensor_device short_units show_graph_range show_graph_scale stippled_borders temperature_unit template template0 template1 template2 template3 template4 template5 template6 template7 template8 template9 text text_buffer_size top_cpu_separate top_name_width total_run_times update_interval update_interval_on_battery uppercase use_spacer use_xft xftalpha xftfont syn keyword ConkyrcConstant \ above diff --git a/src/algebra.c b/src/algebra.c index bc0f1fd..a224e4c 100644 --- a/src/algebra.c +++ b/src/algebra.c @@ -179,7 +179,7 @@ double arg_to_double(const char *arg) { double d; if (sscanf(arg, "%lf", &d) != 1) { - ERR("converting '%s' to double failed", arg); + NORM_ERR("converting '%s' to double failed", arg); return 0.0; } return d; @@ -188,7 +188,7 @@ long arg_to_long(const char *arg) { long l; if (sscanf(arg, "%ld", &l) != 1) { - ERR("converting '%s' to long failed", arg); + NORM_ERR("converting '%s' to long failed", arg); return 0; } return l; @@ -203,7 +203,7 @@ int compare(const char *expr) mtype = get_match_type(expr); if (!idx || mtype == -1) { - ERR("failed to parse compare string '%s'", expr); + NORM_ERR("failed to parse compare string '%s'", expr); return -2; } @@ -219,7 +219,7 @@ int compare(const char *expr) if (type1 == ARG_DOUBLE && type2 == ARG_LONG) type2 = ARG_DOUBLE; if (type1 != type2) { - ERR("trying to compare args '%s' and '%s' of different type", + NORM_ERR("trying to compare args '%s' and '%s' of different type", expr_dup, (expr_dup + idx + 1)); return -2; } diff --git a/src/apcupsd.c b/src/apcupsd.c index baf5f73..3bc843a 100644 --- a/src/apcupsd.c +++ b/src/apcupsd.c @@ -183,7 +183,7 @@ void update_apcupsd(void) { } #ifdef HAVE_GETHOSTBYNAME_R if (gethostbyname_r(info.apcupsd.host, &he_mem, hostbuff, sizeof(hostbuff), &he, &he_errno)) { - ERR("APCUPSD gethostbyname_r: %s", hstrerror(h_errno)); + NORM_ERR("APCUPSD gethostbyname_r: %s", hstrerror(h_errno)); break; } #else /* HAVE_GETHOSTBYNAME_R */ diff --git a/src/bmpx.c b/src/bmpx.c index 3ca9cf2..b54c5b1 100644 --- a/src/bmpx.c +++ b/src/bmpx.c @@ -58,7 +58,7 @@ void update_bmpx() bus = dbus_g_bus_get(DBUS_BUS_SESSION, &error); if (bus == NULL) { - ERR("BMPx error 1: %s\n", error->message); + NORM_ERR("BMPx error 1: %s\n", error->message); fail(error); return; } @@ -66,7 +66,7 @@ void update_bmpx() remote_object = dbus_g_proxy_new_for_name(bus, BMP_DBUS_SERVICE, BMP_DBUS_PATH, BMP_DBUS_INTERFACE); if (!remote_object) { - ERR("BMPx error 2: %s\n", error->message); + NORM_ERR("BMPx error 2: %s\n", error->message); fail(error); return; } @@ -78,7 +78,7 @@ void update_bmpx() if (dbus_g_proxy_call(remote_object, "GetCurrentTrack", &error, G_TYPE_INVALID, G_TYPE_INT, ¤t_track, G_TYPE_INVALID)) { } else { - ERR("BMPx error 3: %s\n", error->message); + NORM_ERR("BMPx error 3: %s\n", error->message); fail(error); return; } @@ -112,7 +112,7 @@ void update_bmpx() current_info->bmpx.uri = g_value_get_string(g_hash_table_lookup(metadata, "location")); } else { - ERR("BMPx error 4: %s\n", error->message); + NORM_ERR("BMPx error 4: %s\n", error->message); fail(error); return; } diff --git a/src/ccurl_thread.c b/src/ccurl_thread.c index 31a3d78..9e2a003 100644 --- a/src/ccurl_thread.c +++ b/src/ccurl_thread.c @@ -138,7 +138,7 @@ void ccurl_fetch_data(ccurl_location_t *curloc) timed_thread_unlock(curloc->p_timed_thread); free(chunk.memory); } else { - ERR("curl: no data from server"); + NORM_ERR("curl: no data from server"); } curl_easy_cleanup(curl); @@ -157,12 +157,12 @@ void ccurl_init_thread(ccurl_location_t *curloc, int interval) (void *)curloc, interval * 1000000); if (!curloc->p_timed_thread) { - ERR("curl thread: error creating timed thread"); + NORM_ERR("curl thread: error creating timed thread"); } timed_thread_register(curloc->p_timed_thread, &curloc->p_timed_thread); if (timed_thread_run(curloc->p_timed_thread)) { - ERR("curl thread: error running timed thread"); + NORM_ERR("curl thread: error running timed thread"); } } @@ -209,7 +209,7 @@ void ccurl_process_info(char *p, int p_max_size, char *uri, int interval) curloc->process_function = &ccurl_parse_data; ccurl_init_thread(curloc, interval); if (!curloc->p_timed_thread) { - ERR("error setting up curl thread"); + NORM_ERR("error setting up curl thread"); } } diff --git a/src/colours.c b/src/colours.c index 3b899f8..c32eda1 100644 --- a/src/colours.c +++ b/src/colours.c @@ -53,7 +53,7 @@ static void set_up_gradient(void) colour_depth = 16; } if (colour_depth != 24 && colour_depth != 16) { - ERR("using non-standard colour depth, gradients may look like a " + NORM_ERR("using non-standard colour depth, gradients may look like a " "lolly-pop"); } diff --git a/src/common.c b/src/common.c index 1948e54..1d14215 100644 --- a/src/common.c +++ b/src/common.c @@ -108,7 +108,7 @@ void to_real_path(char *dest, const char *source) if (homedir) { snprintf(dest, DEFAULT_TEXT_BUFFER_SIZE, "%s/%s", homedir, tmp); } else { - ERR("$HOME environment variable doesn't exist"); + NORM_ERR("$HOME environment variable doesn't exist"); strncpy(dest, source, DEFAULT_TEXT_BUFFER_SIZE); } } else if (dest != source) { //see changelog 2009-06-29 if you doubt that this check is necessary @@ -126,7 +126,7 @@ int open_fifo(const char *file, int *reported) if (fd == -1) { if (!reported || *reported == 0) { - ERR("can't open %s: %s", file, strerror(errno)); + NORM_ERR("can't open %s: %s", file, strerror(errno)); if (reported) { *reported = 1; } @@ -147,7 +147,7 @@ FILE *open_file(const char *file, int *reported) if (!fp) { if (!reported || *reported == 0) { - ERR("can't open %s: %s", file, strerror(errno)); + NORM_ERR("can't open %s: %s", file, strerror(errno)); if (reported) { *reported = 1; } diff --git a/src/conky.c b/src/conky.c index c056fee..ad348ce 100644 --- a/src/conky.c +++ b/src/conky.c @@ -65,6 +65,9 @@ #include #include #include +#ifdef NCURSES +#include +#endif /* local headers */ #include "algebra.h" @@ -453,7 +456,7 @@ int check_contains(char *f, char *s) } fclose(where); } else { - ERR("Could not open the file"); + NORM_ERR("Could not open the file"); } return ret; } @@ -802,7 +805,7 @@ static 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.box); + free(data.local_mail.mbox); break; case OBJ_imap_unseen: if (!obj->char_b) { @@ -1257,15 +1260,15 @@ static int parse_top_args(const char *s, const char *arg, struct text_object *ob #endif } else { #ifdef IOSTATS - ERR("Must be top, top_mem, top_time or top_io"); + NORM_ERR("Must be top, top_mem, top_time or top_io"); #else - ERR("Must be top, top_mem or top_time"); + NORM_ERR("Must be top, top_mem or top_time"); #endif return 0; } if (!arg) { - ERR("top needs arguments"); + NORM_ERR("top needs arguments"); return 0; } @@ -1293,23 +1296,23 @@ static int parse_top_args(const char *s, const char *arg, struct text_object *ob obj->data.top.type = TOP_IO_PERC; #endif } else { - ERR("invalid type arg for top"); + NORM_ERR("invalid type arg for top"); #ifdef IOSTATS - ERR("must be one of: name, cpu, pid, mem, time, mem_res, mem_vsize, " + NORM_ERR("must be one of: name, cpu, pid, mem, time, mem_res, mem_vsize, " "io_read, io_write, io_perc"); #else - ERR("must be one of: name, cpu, pid, mem, time, mem_res, mem_vsize"); + NORM_ERR("must be one of: name, cpu, pid, mem, time, mem_res, mem_vsize"); #endif return 0; } if (n < 1 || n > 10) { - ERR("invalid num arg for top. Must be between 1 and 10."); + NORM_ERR("invalid num arg for top. Must be between 1 and 10."); return 0; } else { obj->data.top.num = n - 1; } } else { - ERR("invalid argument count for top"); + NORM_ERR("invalid argument count for top"); return 0; } return 1; @@ -1403,7 +1406,7 @@ static struct text_object *construct_text_object(const char *s, 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; - /* ERR("freq: Invalid CPU number or you don't have that many CPUs! " + /* 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]); @@ -1414,7 +1417,7 @@ static struct text_object *construct_text_object(const char *s, 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; - /* ERR("freq_g: Invalid CPU number or you don't have that many " + /* 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]); @@ -1442,7 +1445,7 @@ static struct text_object *construct_text_object(const char *s, 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; - /* ERR("voltage_mv: Invalid CPU number or you don't have that many " + /* 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]); @@ -1453,7 +1456,7 @@ static struct text_object *construct_text_object(const char *s, 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; - /* ERR("voltage_v: Invalid CPU number or you don't have that many " + /* 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]); @@ -1614,7 +1617,7 @@ static struct text_object *construct_text_object(const char *s, } if (!isdigit(arg[0]) || strlen(arg) >= 2 || atoi(&arg[0]) >= 8) { obj->data.sensor = 0; - ERR("Invalid temperature sensor! Sensor number must be 0 to 7. " + NORM_ERR("Invalid temperature sensor! Sensor number must be 0 to 7. " "Using 0 (CPU temp sensor)."); } obj->data.sensor = atoi(&arg[0]); @@ -1640,7 +1643,7 @@ static struct text_object *construct_text_object(const char *s, } else if (arg && strcmp(arg, "time") == EQUAL) { obj->data.i = PB_BATT_TIME; } else { - ERR("pb_battery: needs one argument: status, percent or time"); + NORM_ERR("pb_battery: needs one argument: status, percent or time"); free(obj); return NULL; } @@ -1649,7 +1652,7 @@ static struct text_object *construct_text_object(const char *s, #if (defined(__FreeBSD__) || defined(__linux__)) END OBJ_IF(if_up, 0) if (!arg) { - ERR("if_up needs an argument"); + NORM_ERR("if_up needs an argument"); obj->data.ifblock.s = 0; } else { obj->data.ifblock.s = strndup(arg, text_buffer_size); @@ -1663,7 +1666,7 @@ static struct text_object *construct_text_object(const char *s, if (!isdigit(arg[0]) || atoi(&arg[0]) < 0 || atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) { obj->data.sensor = 0; - ERR("Invalid temperature sensor number!"); + NORM_ERR("Invalid temperature sensor number!"); } obj->data.sensor = atoi(&arg[0]); END OBJ(obsd_sensors_fan, 0) @@ -1674,7 +1677,7 @@ static struct text_object *construct_text_object(const char *s, if (!isdigit(arg[0]) || atoi(&arg[0]) < 0 || atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) { obj->data.sensor = 0; - ERR("Invalid fan sensor number!"); + NORM_ERR("Invalid fan sensor number!"); } obj->data.sensor = atoi(&arg[0]); END OBJ(obsd_sensors_volt, 0) @@ -1685,7 +1688,7 @@ static struct text_object *construct_text_object(const char *s, if (!isdigit(arg[0]) || atoi(&arg[0]) < 0 || atoi(&arg[0]) > OBSD_MAX_SENSORS - 1) { obj->data.sensor = 0; - ERR("Invalid voltage sensor number!"); + NORM_ERR("Invalid voltage sensor number!"); } obj->data.sensor = atoi(&arg[0]); END OBJ(obsd_vendor, 0) @@ -1874,7 +1877,7 @@ static struct text_object *construct_text_object(const char *s, if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) { char buf[256]; - ERR("${execibar command}"); + NORM_ERR("${execibar command}"); obj->type = OBJ_text; snprintf(buf, 256, "${%s}", s); obj->data.s = strndup(buf, text_buffer_size); @@ -1889,7 +1892,7 @@ static struct text_object *construct_text_object(const char *s, if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) { char buf[256]; - ERR("${execigraph command}"); + NORM_ERR("${execigraph command}"); obj->type = OBJ_text; snprintf(buf, 256, "${%s}", s); obj->data.s = strndup(buf, text_buffer_size); @@ -1903,7 +1906,7 @@ static struct text_object *construct_text_object(const char *s, if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) { char buf[256]; - ERR("${execigauge command}"); + NORM_ERR("${execigauge command}"); obj->type = OBJ_text; snprintf(buf, 256, "${%s}", s); obj->data.s = strndup(buf, text_buffer_size); @@ -1917,7 +1920,7 @@ static struct text_object *construct_text_object(const char *s, if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) { char buf[256]; - ERR("${execi command}"); + NORM_ERR("${execi command}"); obj->type = OBJ_text; snprintf(buf, 256, "${%s}", s); obj->data.s = strndup(buf, text_buffer_size); @@ -1931,7 +1934,7 @@ static struct text_object *construct_text_object(const char *s, if (!arg || sscanf(arg, "%f %n", &obj->data.execi.interval, &n) <= 0) { char buf[256]; - ERR("${execi command}"); + NORM_ERR("${execi command}"); obj->type = OBJ_text; snprintf(buf, 256, "${%s}", s); obj->data.s = strndup(buf, text_buffer_size); @@ -1945,7 +1948,7 @@ static struct text_object *construct_text_object(const char *s, if (!arg || sscanf(arg, "%f %n", &obj->data.texeci.interval, &n) <= 0) { char buf[256]; - ERR("${texeci command}"); + NORM_ERR("${texeci command}"); obj->type = OBJ_text; snprintf(buf, 256, "${%s}", s); obj->data.s = strndup(buf, text_buffer_size); @@ -2034,7 +2037,7 @@ static struct text_object *construct_text_object(const char *s, END OBJ(goto, 0) if (!arg) { - ERR("goto needs arguments"); + NORM_ERR("goto needs arguments"); obj->type = OBJ_text; obj->data.s = strndup("${goto}", text_buffer_size); return NULL; @@ -2063,7 +2066,7 @@ static struct text_object *construct_text_object(const char *s, int n, found = 0; if (!arg) { - ERR("i2c needs arguments"); + NORM_ERR("i2c needs arguments"); obj->type = OBJ_text; // obj->data.s = strndup("${i2c}", text_buffer_size); return NULL; @@ -2080,7 +2083,7 @@ static struct text_object *construct_text_object(const char *s, if (!found && sscanf(arg, "%63s %d", buf2, &n) == 2) found = 1; else if (!found) HWMON_RESET(); if (!found) { - ERR("i2c failed to parse arguments"); + NORM_ERR("i2c failed to parse arguments"); obj->type = OBJ_text; return NULL; } @@ -2097,7 +2100,7 @@ static struct text_object *construct_text_object(const char *s, int n, found = 0; if (!arg) { - ERR("platform needs arguments"); + NORM_ERR("platform needs arguments"); obj->type = OBJ_text; return NULL; } @@ -2108,7 +2111,7 @@ static struct text_object *construct_text_object(const char *s, if (!found && sscanf(arg, "%63s %d", buf2, &n) == 2) found = 1; else if (!found) HWMON_RESET(); if (!found) { - ERR("platform failed to parse arguments"); + NORM_ERR("platform failed to parse arguments"); obj->type = OBJ_text; return NULL; } @@ -2125,7 +2128,7 @@ static struct text_object *construct_text_object(const char *s, int n, found = 0; if (!arg) { - ERR("hwmon needs argumanets"); + NORM_ERR("hwmon needs argumanets"); obj->type = OBJ_text; return NULL; } @@ -2138,7 +2141,7 @@ static struct text_object *construct_text_object(const char *s, #undef HWMON_RESET if (!found) { - ERR("hwmon failed to parse arguments"); + NORM_ERR("hwmon failed to parse arguments"); obj->type = OBJ_text; return NULL; } @@ -2215,7 +2218,7 @@ static struct text_object *construct_text_object(const char *s, obj->data.loadavg[2] = (r >= 3) ? (unsigned char) c : 0; END OBJ_IF(if_empty, 0) if (!arg) { - ERR("if_empty needs an argument"); + NORM_ERR("if_empty needs an argument"); obj->data.ifblock.s = 0; } else { obj->data.ifblock.s = strndup(arg, text_buffer_size); @@ -2225,7 +2228,7 @@ static struct text_object *construct_text_object(const char *s, } END OBJ_IF(if_match, 0) if (!arg) { - ERR("if_match needs arguments"); + NORM_ERR("if_match needs arguments"); obj->data.ifblock.s = 0; } else { obj->data.ifblock.s = strndup(arg, text_buffer_size); @@ -2235,7 +2238,7 @@ static struct text_object *construct_text_object(const char *s, } END OBJ_IF(if_existing, 0) if (!arg) { - ERR("if_existing needs an argument or two"); + NORM_ERR("if_existing needs an argument or two"); obj->data.ifblock.s = NULL; obj->data.ifblock.str = NULL; } else { @@ -2253,7 +2256,7 @@ static struct text_object *construct_text_object(const char *s, DBGP("if_existing: '%s' '%s'", obj->data.ifblock.s, obj->data.ifblock.str); END OBJ_IF(if_mounted, 0) if (!arg) { - ERR("if_mounted needs an argument"); + NORM_ERR("if_mounted needs an argument"); obj->data.ifblock.s = 0; } else { obj->data.ifblock.s = strndup(arg, text_buffer_size); @@ -2271,14 +2274,14 @@ static struct text_object *construct_text_object(const char *s, obj->data.ifblock.s = strndup(buf, text_buffer_size); #endif } else { - ERR("if_running needs an argument"); + NORM_ERR("if_running needs an argument"); obj->data.ifblock.s = 0; } END OBJ(kernel, 0) END OBJ(machine, 0) END OBJ(mails, 0) float n1; - char box[256], dst[256]; + char mbox[256], dst[256]; if (!arg) { n1 = 9.5; @@ -2287,203 +2290,203 @@ static struct text_object *construct_text_object(const char *s, is a copy of the former if undefined but the latter should take precedence if defined */ - strncpy(box, current_mail_spool, sizeof(box)); + strncpy(mbox, current_mail_spool, sizeof(mbox)); } else { - if (sscanf(arg, "%s %f", box, &n1) != 2) { + if (sscanf(arg, "%s %f", mbox, &n1) != 2) { n1 = 9.5; - strncpy(box, arg, sizeof(box)); + strncpy(mbox, arg, sizeof(mbox)); } } - variable_substitute(box, dst, sizeof(dst)); - obj->data.local_mail.box = strndup(dst, text_buffer_size); + variable_substitute(mbox, dst, sizeof(dst)); + obj->data.local_mail.mbox = strndup(dst, text_buffer_size); obj->data.local_mail.interval = n1; END OBJ(new_mails, 0) float n1; - char box[256], dst[256]; + char mbox[256], dst[256]; if (!arg) { n1 = 9.5; - strncpy(box, current_mail_spool, sizeof(box)); + strncpy(mbox, current_mail_spool, sizeof(mbox)); } else { - if (sscanf(arg, "%s %f", box, &n1) != 2) { + if (sscanf(arg, "%s %f", mbox, &n1) != 2) { n1 = 9.5; - strncpy(box, arg, sizeof(box)); + strncpy(mbox, arg, sizeof(mbox)); } } - variable_substitute(box, dst, sizeof(dst)); - obj->data.local_mail.box = strndup(dst, text_buffer_size); + variable_substitute(mbox, dst, sizeof(dst)); + obj->data.local_mail.mbox = strndup(dst, text_buffer_size); obj->data.local_mail.interval = n1; END OBJ(seen_mails, 0) float n1; - char box[256], dst[256]; + char mbox[256], dst[256]; if (!arg) { n1 = 9.5; - strncpy(box, current_mail_spool, sizeof(box)); + strncpy(mbox, current_mail_spool, sizeof(mbox)); } else { - if (sscanf(arg, "%s %f", box, &n1) != 2) { + if (sscanf(arg, "%s %f", mbox, &n1) != 2) { n1 = 9.5; - strncpy(box, arg, sizeof(box)); + strncpy(mbox, arg, sizeof(mbox)); } } - variable_substitute(box, dst, sizeof(dst)); - obj->data.local_mail.box = strndup(dst, text_buffer_size); + variable_substitute(mbox, dst, sizeof(dst)); + obj->data.local_mail.mbox = strndup(dst, text_buffer_size); obj->data.local_mail.interval = n1; END OBJ(unseen_mails, 0) float n1; - char box[256], dst[256]; + char mbox[256], dst[256]; if (!arg) { n1 = 9.5; - strncpy(box, current_mail_spool, sizeof(box)); + strncpy(mbox, current_mail_spool, sizeof(mbox)); } else { - if (sscanf(arg, "%s %f", box, &n1) != 2) { + if (sscanf(arg, "%s %f", mbox, &n1) != 2) { n1 = 9.5; - strncpy(box, arg, sizeof(box)); + strncpy(mbox, arg, sizeof(mbox)); } } - variable_substitute(box, dst, sizeof(dst)); - obj->data.local_mail.box = strndup(dst, text_buffer_size); + variable_substitute(mbox, dst, sizeof(dst)); + obj->data.local_mail.mbox = strndup(dst, text_buffer_size); obj->data.local_mail.interval = n1; END OBJ(flagged_mails, 0) float n1; - char box[256], dst[256]; + char mbox[256], dst[256]; if (!arg) { n1 = 9.5; - strncpy(box, current_mail_spool, sizeof(box)); + strncpy(mbox, current_mail_spool, sizeof(mbox)); } else { - if (sscanf(arg, "%s %f", box, &n1) != 2) { + if (sscanf(arg, "%s %f", mbox, &n1) != 2) { n1 = 9.5; - strncpy(box, arg, sizeof(box)); + strncpy(mbox, arg, sizeof(mbox)); } } - variable_substitute(box, dst, sizeof(dst)); - obj->data.local_mail.box = strndup(dst, text_buffer_size); + variable_substitute(mbox, dst, sizeof(dst)); + obj->data.local_mail.mbox = strndup(dst, text_buffer_size); obj->data.local_mail.interval = n1; END OBJ(unflagged_mails, 0) float n1; - char box[256], dst[256]; + char mbox[256], dst[256]; if (!arg) { n1 = 9.5; - strncpy(box, current_mail_spool, sizeof(box)); + strncpy(mbox, current_mail_spool, sizeof(mbox)); } else { - if (sscanf(arg, "%s %f", box, &n1) != 2) { + if (sscanf(arg, "%s %f", mbox, &n1) != 2) { n1 = 9.5; - strncpy(box, arg, sizeof(box)); + strncpy(mbox, arg, sizeof(mbox)); } } - variable_substitute(box, dst, sizeof(dst)); - obj->data.local_mail.box = strndup(dst, text_buffer_size); + variable_substitute(mbox, dst, sizeof(dst)); + obj->data.local_mail.mbox = strndup(dst, text_buffer_size); obj->data.local_mail.interval = n1; END OBJ(forwarded_mails, 0) float n1; - char box[256], dst[256]; + char mbox[256], dst[256]; if (!arg) { n1 = 9.5; - strncpy(box, current_mail_spool, sizeof(box)); + strncpy(mbox, current_mail_spool, sizeof(mbox)); } else { - if (sscanf(arg, "%s %f", box, &n1) != 2) { + if (sscanf(arg, "%s %f", mbox, &n1) != 2) { n1 = 9.5; - strncpy(box, arg, sizeof(box)); + strncpy(mbox, arg, sizeof(mbox)); } } - variable_substitute(box, dst, sizeof(dst)); - obj->data.local_mail.box = strndup(dst, text_buffer_size); + variable_substitute(mbox, dst, sizeof(dst)); + obj->data.local_mail.mbox = strndup(dst, text_buffer_size); obj->data.local_mail.interval = n1; END OBJ(unforwarded_mails, 0) float n1; - char box[256], dst[256]; + char mbox[256], dst[256]; if (!arg) { n1 = 9.5; - strncpy(box, current_mail_spool, sizeof(box)); + strncpy(mbox, current_mail_spool, sizeof(mbox)); } else { - if (sscanf(arg, "%s %f", box, &n1) != 2) { + if (sscanf(arg, "%s %f", mbox, &n1) != 2) { n1 = 9.5; - strncpy(box, arg, sizeof(box)); + strncpy(mbox, arg, sizeof(mbox)); } } - variable_substitute(box, dst, sizeof(dst)); - obj->data.local_mail.box = strndup(dst, text_buffer_size); + variable_substitute(mbox, dst, sizeof(dst)); + obj->data.local_mail.mbox = strndup(dst, text_buffer_size); obj->data.local_mail.interval = n1; END OBJ(replied_mails, 0) float n1; - char box[256], dst[256]; + char mbox[256], dst[256]; if (!arg) { n1 = 9.5; - strncpy(box, current_mail_spool, sizeof(box)); + strncpy(mbox, current_mail_spool, sizeof(mbox)); } else { - if (sscanf(arg, "%s %f", box, &n1) != 2) { + if (sscanf(arg, "%s %f", mbox, &n1) != 2) { n1 = 9.5; - strncpy(box, arg, sizeof(box)); + strncpy(mbox, arg, sizeof(mbox)); } } - variable_substitute(box, dst, sizeof(dst)); - obj->data.local_mail.box = strndup(dst, text_buffer_size); + variable_substitute(mbox, dst, sizeof(dst)); + obj->data.local_mail.mbox = strndup(dst, text_buffer_size); obj->data.local_mail.interval = n1; END OBJ(unreplied_mails, 0) float n1; - char box[256], dst[256]; + char mbox[256], dst[256]; if (!arg) { n1 = 9.5; - strncpy(box, current_mail_spool, sizeof(box)); + strncpy(mbox, current_mail_spool, sizeof(mbox)); } else { - if (sscanf(arg, "%s %f", box, &n1) != 2) { + if (sscanf(arg, "%s %f", mbox, &n1) != 2) { n1 = 9.5; - strncpy(box, arg, sizeof(box)); + strncpy(mbox, arg, sizeof(mbox)); } } - variable_substitute(box, dst, sizeof(dst)); - obj->data.local_mail.box = strndup(dst, text_buffer_size); + variable_substitute(mbox, dst, sizeof(dst)); + obj->data.local_mail.mbox = strndup(dst, text_buffer_size); obj->data.local_mail.interval = n1; END OBJ(draft_mails, 0) float n1; - char box[256], dst[256]; + char mbox[256], dst[256]; if (!arg) { n1 = 9.5; - strncpy(box, current_mail_spool, sizeof(box)); + strncpy(mbox, current_mail_spool, sizeof(mbox)); } else { - if (sscanf(arg, "%s %f", box, &n1) != 2) { + if (sscanf(arg, "%s %f", mbox, &n1) != 2) { n1 = 9.5; - strncpy(box, arg, sizeof(box)); + strncpy(mbox, arg, sizeof(mbox)); } } - variable_substitute(box, dst, sizeof(dst)); - obj->data.local_mail.box = strndup(dst, text_buffer_size); + variable_substitute(mbox, dst, sizeof(dst)); + obj->data.local_mail.mbox = strndup(dst, text_buffer_size); obj->data.local_mail.interval = n1; END OBJ(trashed_mails, 0) float n1; - char box[256], dst[256]; + char mbox[256], dst[256]; if (!arg) { n1 = 9.5; - strncpy(box, current_mail_spool, sizeof(box)); + strncpy(mbox, current_mail_spool, sizeof(mbox)); } else { - if (sscanf(arg, "%s %f", box, &n1) != 2) { + if (sscanf(arg, "%s %f", mbox, &n1) != 2) { n1 = 9.5; - strncpy(box, arg, sizeof(box)); + strncpy(mbox, arg, sizeof(mbox)); } } - variable_substitute(box, dst, sizeof(dst)); - obj->data.local_mail.box = strndup(dst, text_buffer_size); + variable_substitute(mbox, dst, sizeof(dst)); + obj->data.local_mail.mbox = strndup(dst, text_buffer_size); obj->data.local_mail.interval = n1; END OBJ(mboxscan, 0) obj->data.mboxscan.args = (char *) malloc(text_buffer_size); @@ -2614,7 +2617,7 @@ static struct text_object *construct_text_object(const char *s, new_iconv = iconv_open(iconv_to, iconv_from); if (new_iconv == (iconv_t) (-1)) { - ERR("Can't convert from %s to %s.", iconv_from, iconv_to); + NORM_ERR("Can't convert from %s to %s.", iconv_from, iconv_to); } else { obj->a = register_iconv(&new_iconv); iconv_converting = 1; @@ -2743,10 +2746,10 @@ static struct text_object *construct_text_object(const char *s, if (arg) obj->data.s = strndup(arg, text_buffer_size); else - ERR("smapi needs an argument"); + NORM_ERR("smapi needs an argument"); END OBJ_IF(if_smapi_bat_installed, 0) if (!arg) { - ERR("if_smapi_bat_installed needs an argument"); + NORM_ERR("if_smapi_bat_installed needs an argument"); obj->data.ifblock.s = 0; } else obj->data.ifblock.s = strndup(arg, text_buffer_size); @@ -2754,31 +2757,31 @@ static struct text_object *construct_text_object(const char *s, if (arg) obj->data.s = strndup(arg, text_buffer_size); else - ERR("smapi_bat_perc needs an argument"); + NORM_ERR("smapi_bat_perc needs an argument"); END OBJ(smapi_bat_temp, 0) if (arg) obj->data.s = strndup(arg, text_buffer_size); else - ERR("smapi_bat_temp needs an argument"); + NORM_ERR("smapi_bat_temp needs an argument"); END OBJ(smapi_bat_power, 0) if (arg) obj->data.s = strndup(arg, text_buffer_size); else - ERR("smapi_bat_power needs an argument"); + NORM_ERR("smapi_bat_power needs an argument"); #ifdef X11 END OBJ(smapi_bat_bar, 0) SIZE_DEFAULTS(bar); if(arg) { int cnt; if(sscanf(arg, "%i %n", &obj->data.i, &cnt) <= 0) { - ERR("first argument to smapi_bat_bar must be an integer value"); + 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 - ERR("smapi_bat_bar needs an argument"); + NORM_ERR("smapi_bat_bar needs an argument"); #endif /* X11 */ #endif /* IBM */ #ifdef MPD @@ -2789,7 +2792,7 @@ static struct text_object *construct_text_object(const char *s, if (i > 0) \ obj->data.i = i + 1; \ else \ - ERR(#name ": invalid length argument"); \ + NORM_ERR(#name ": invalid length argument"); \ } END OBJ(mpd_artist, INFO_MPD) mpd_set_maxlen(mpd_artist); @@ -2939,7 +2942,7 @@ static struct text_object *construct_text_object(const char *s, obj->data.curl.uri = uri; obj->data.curl.interval = interval > 0 ? interval * 60 : 15*60; } else { - ERR("wrong number of arguments for $curl"); + NORM_ERR("wrong number of arguments for $curl"); } } else { CRIT_ERR(obj, free_at_crash, "curl needs arguments: "); @@ -2963,7 +2966,7 @@ static struct text_object *construct_text_object(const char *s, obj->data.rss.act_par = act_par; obj->data.rss.nrspaces = nrspaces; } else { - ERR("wrong number of arguments for $rss"); + NORM_ERR("wrong number of arguments for $rss"); } } else { CRIT_ERR(obj, free_at_crash, "rss needs arguments: " @@ -3072,7 +3075,7 @@ static struct text_object *construct_text_object(const char *s, END OBJ(hddtemp, 0) if (scan_hddtemp(arg, &obj->data.hddtemp.dev, &obj->data.hddtemp.addr, &obj->data.hddtemp.port)) { - ERR("hddtemp needs arguments"); + NORM_ERR("hddtemp needs arguments"); obj->type = OBJ_text; obj->data.s = strndup("${hddtemp}", text_buffer_size); obj->data.hddtemp.update_time = 0; @@ -3099,10 +3102,10 @@ static struct text_object *construct_text_object(const char *s, extract_variable_text_internal(obj->sub, global_text); currentconffile = leaf->back; } else { - ERR("Can't load configfile '%s'.", arg); + NORM_ERR("Can't load configfile '%s'.", arg); } } else { - ERR("You are trying to load '%s' recursively, I'm only going to load it once to prevent an infinite loop.", arg); + NORM_ERR("You are trying to load '%s' recursively, I'm only going to load it once to prevent an infinite loop.", arg); } } else { CRIT_ERR(obj, free_at_crash, "include needs a argument"); @@ -3248,7 +3251,7 @@ static struct text_object *construct_text_object(const char *s, END { char buf[256]; - ERR("unknown variable %s", s); + NORM_ERR("unknown variable %s", s); obj->type = OBJ_text; snprintf(buf, 256, "${%s}", s); obj->data.s = strndup(buf, text_buffer_size); @@ -3446,7 +3449,7 @@ static char *find_and_replace_templates(const char *inbuf) free(tmpl_out); o = outbuf + strlen(outbuf); } else { - ERR("failed to handle template '%s' with args '%s'", templ, args); + NORM_ERR("failed to handle template '%s' with args '%s'", templ, args); } } *o = '\0'; @@ -3647,7 +3650,7 @@ static int extract_variable_text_internal(struct text_object *retval, const char } if (!ifblock_stack_empty(&ifblock_opaque)) { - ERR("one or more $endif's are missing"); + NORM_ERR("one or more $endif's are missing"); } free(orig_p); @@ -3689,12 +3692,12 @@ static inline struct mail_s *ensure_mail_thread(struct text_object *obj, timed_thread_create(thread, (void *) info.mail, info.mail->interval * 1000000); if (!info.mail->p_timed_thread) { - ERR("Error creating %s timed thread", text); + NORM_ERR("Error creating %s timed thread", text); } timed_thread_register(info.mail->p_timed_thread, &info.mail->p_timed_thread); if (timed_thread_run(info.mail->p_timed_thread)) { - ERR("Error running %s timed thread", text); + NORM_ERR("Error running %s timed thread", text); } } return info.mail; @@ -3706,18 +3709,18 @@ static inline struct mail_s *ensure_mail_thread(struct text_object *obj, (void *) obj->data.mail, obj->data.mail->interval * 1000000); if (!obj->data.mail->p_timed_thread) { - ERR("Error creating %s timed thread", text); + NORM_ERR("Error creating %s timed thread", text); } timed_thread_register(obj->data.mail->p_timed_thread, &obj->data.mail->p_timed_thread); if (timed_thread_run(obj->data.mail->p_timed_thread)) { - ERR("Error running %s timed thread", text); + NORM_ERR("Error running %s timed thread", text); } } return obj->data.mail; } else if (!obj->a) { // something is wrong, warn once then stop - ERR("There's a problem with your mail settings. " + NORM_ERR("There's a problem with your mail settings. " "Check that the global mail settings are properly defined" " (line %li).", obj->line); obj->a++; @@ -3816,12 +3819,12 @@ static inline double get_barnum(char *buf) } if (sscanf(buf, "%lf", &barnum) == 0) { - ERR("reading exec value failed (perhaps it's not the " + NORM_ERR("reading exec value failed (perhaps it's not the " "correct format?)"); return -1; } if (barnum > 100.0 || barnum < 0.0) { - ERR("your exec value is not between 0 and 100, " + NORM_ERR("your exec value is not between 0 and 100, " "therefore it will be ignored"); return -1; } @@ -3894,7 +3897,7 @@ static void generate_text_internal(char *p, int p_max_size, switch (obj->type) { default: - ERR("not implemented obj type %d", obj->type); + NORM_ERR("not implemented obj type %d", obj->type); OBJ(read_tcp) { int sock, received; struct sockaddr_in addr; @@ -3919,13 +3922,13 @@ static void generate_text_internal(char *p, int p_max_size, } close(sock); } else { - ERR("read_tcp: Couldn't create a connection"); + NORM_ERR("read_tcp: Couldn't create a connection"); } }else{ - ERR("read_tcp: Couldn't create a socket"); + NORM_ERR("read_tcp: Couldn't create a socket"); } }else{ - ERR("read_tcp: Problem with resolving the hostname"); + NORM_ERR("read_tcp: Problem with resolving the hostname"); } } #ifndef __OpenBSD__ @@ -4060,7 +4063,7 @@ static void generate_text_internal(char *p, int p_max_size, } OBJ(cpu) { if (obj->data.cpu_index > info.cpu_count) { - ERR("obj->data.cpu_index %i info.cpu_count %i", + NORM_ERR("obj->data.cpu_index %i info.cpu_count %i", obj->data.cpu_index, info.cpu_count); CRIT_ERR(NULL, NULL, "attempting to use more CPUs than you have!"); } @@ -4562,14 +4565,14 @@ static void generate_text_internal(char *p, int p_max_size, timed_thread_create(&threaded_exec, (void *) obj, obj->data.texeci.interval * 1000000); if (!obj->data.texeci.p_timed_thread) { - ERR("Error creating texeci timed thread"); + NORM_ERR("Error creating texeci timed thread"); } /* * note that we don't register this thread with the * timed_thread list, because we destroy it manually */ if (timed_thread_run(obj->data.texeci.p_timed_thread)) { - ERR("Error running texeci timed thread"); + NORM_ERR("Error running texeci timed thread"); } } else { timed_thread_lock(obj->data.texeci.p_timed_thread); @@ -4762,7 +4765,7 @@ static void generate_text_internal(char *p, int p_max_size, if (obj->data.curl.uri != NULL) { ccurl_process_info(p, p_max_size, obj->data.curl.uri, obj->data.curl.interval); } else { - ERR("error processing Curl data"); + NORM_ERR("error processing Curl data"); } } #endif @@ -4771,7 +4774,7 @@ static void generate_text_internal(char *p, int p_max_size, if (obj->data.rss.uri != NULL) { rss_process_info(p, p_max_size, obj->data.rss.uri, obj->data.rss.action, obj->data.rss.act_par, obj->data.rss.interval, obj->data.rss.nrspaces); } else { - ERR("error processing RSS data"); + NORM_ERR("error processing RSS data"); } } #endif @@ -4780,7 +4783,7 @@ static void generate_text_internal(char *p, int p_max_size, if (obj->data.weather.uri != NULL) { weather_process_info(p, p_max_size, obj->data.weather.uri, obj->data.weather.data_type, obj->data.weather.interval); } else { - ERR("error processing weather data, check that you have a valid XOAP key if using XOAP."); + NORM_ERR("error processing weather data, check that you have a valid XOAP key if using XOAP."); } } #endif @@ -4946,7 +4949,7 @@ static void generate_text_internal(char *p, int p_max_size, val = compare(expression); if (val == -2) { - ERR("compare failed for expression '%s'", + NORM_ERR("compare failed for expression '%s'", expression); } else if (!val) { DO_JUMP; @@ -5799,7 +5802,7 @@ static void generate_text_internal(char *p, int p_max_size, DO_JUMP; } } else - ERR("argument to if_smapi_bat_installed must be an integer"); + NORM_ERR("argument to if_smapi_bat_installed must be an integer"); } OBJ(smapi_bat_perc) { int idx, val; @@ -5808,7 +5811,7 @@ static void generate_text_internal(char *p, int p_max_size, smapi_get_bat_int(idx, "remaining_percent") : 0; percent_print(p, p_max_size, val); } else - ERR("argument to smapi_bat_perc must be an integer"); + NORM_ERR("argument to smapi_bat_perc must be an integer"); } OBJ(smapi_bat_temp) { int idx, val; @@ -5818,7 +5821,7 @@ static void generate_text_internal(char *p, int p_max_size, /* temperature is in milli degree celsius */ temp_print(p, p_max_size, val / 1000, TEMP_CELSIUS); } else - ERR("argument to smapi_bat_temp must be an integer"); + NORM_ERR("argument to smapi_bat_temp must be an integer"); } OBJ(smapi_bat_power) { int idx, val; @@ -5828,7 +5831,7 @@ static void generate_text_internal(char *p, int p_max_size, /* power_now is in mW, set to W with one digit precision */ snprintf(p, p_max_size, "%.1f", ((double)val / 1000)); } else - ERR("argument to smapi_bat_power must be an integer"); + NORM_ERR("argument to smapi_bat_power must be an integer"); } #ifdef X11 OBJ(smapi_bat_bar) { @@ -6135,7 +6138,7 @@ static void generate_text_internal(char *p, int p_max_size, bytes = iconv(*iconv_cd[iconv_selected - 1], &ptr, &dummy1, &outptr, &dummy2); if (bytes == -1) { - ERR("Iconv codeset conversion failed"); + NORM_ERR("Iconv codeset conversion failed"); break; } } @@ -6514,6 +6517,11 @@ static void draw_string(const char *s) if ((output_methods & APPEND_FILE) && draw_mode == FG && append_fpointer) { fprintf(append_fpointer, "%s\n", s_with_newlines); } +#ifdef NCURSES + if ((output_methods & TO_NCURSES) && draw_mode == FG) { + printw("%s\n", s_with_newlines); + } +#endif free(s_with_newlines); memset(tmpstring1, 0, text_buffer_size); memset(tmpstring2, 0, text_buffer_size); @@ -7091,12 +7099,12 @@ static void draw_stuff(void) if (overwrite_file) { overwrite_fpointer = fopen(overwrite_file, "w"); if(!overwrite_fpointer) - ERR("Can't overwrite '%s' anymore", overwrite_file); + NORM_ERR("Can't overwrite '%s' anymore", overwrite_file); } if (append_file) { append_fpointer = fopen(append_file, "a"); if(!append_fpointer) - ERR("Can't append '%s' anymore", append_file); + NORM_ERR("Can't append '%s' anymore", append_file); } #ifdef X11 if (output_methods & TO_X) { @@ -7272,7 +7280,7 @@ static void main_loop(void) s = select(ConnectionNumber(display) + 1, &fdsr, 0, 0, &tv); if (s == -1) { if (errno != EINTR) { - ERR("can't select(): %s", strerror(errno)); + NORM_ERR("can't select(): %s", strerror(errno)); } } else { /* timeout */ @@ -7543,6 +7551,12 @@ static void main_loop(void) if(t > 0) usleep((useconds_t)t); update_text(); draw_stuff(); +#ifdef NCURSES + if(output_methods & TO_NCURSES) { + refresh(); + clear(); + } +#endif #ifdef X11 } #endif /* X11 */ @@ -7557,12 +7571,12 @@ static void main_loop(void) switch (g_signal_pending) { case SIGHUP: case SIGUSR1: - ERR("received SIGHUP or SIGUSR1. reloading the config file."); + NORM_ERR("received SIGHUP or SIGUSR1. reloading the config file."); reload_config(); break; case SIGINT: case SIGTERM: - ERR("received SIGINT or SIGTERM to terminate. bye!"); + NORM_ERR("received SIGINT or SIGTERM to terminate. bye!"); terminate = 1; #ifdef X11 if (output_methods & TO_X) { @@ -7594,7 +7608,7 @@ static void main_loop(void) * If you don't want to handle a signal, don't set a handler on * it in the first place. */ if (g_signal_pending) { - ERR("ignoring signal (%d)", g_signal_pending); + NORM_ERR("ignoring signal (%d)", g_signal_pending); } break; } @@ -7622,7 +7636,7 @@ static void main_loop(void) struct inotify_event *ev = (struct inotify_event *) &inotify_buff[idx]; if (ev->wd == inotify_config_wd && (ev->mask & IN_MODIFY || ev->mask & IN_IGNORED)) { /* current_config should be reloaded */ - ERR("'%s' modified, reloading...", current_config); + NORM_ERR("'%s' modified, reloading...", current_config); reload_config(); if (ev->mask & IN_IGNORED) { /* for some reason we get IN_IGNORED here @@ -7676,6 +7690,13 @@ static void reload_config(void) void clean_up(void *memtofree1, void* memtofree2) { int i; + +#ifdef NCURSES + if(output_methods & TO_NCURSES) { + delwin(stdscr); + endwin(); + } +#endif conftree_empty(currentconffile); currentconffile = NULL; if(memtofree1) { @@ -8020,7 +8041,7 @@ int x11_error_handler(Display *d, XErrorEvent *err) __attribute__((noreturn)); int x11_error_handler(Display *d, XErrorEvent *err) { - ERR("X Error: type %i Display %lx XID %li serial %lu error_code %i request_code %i minor_code %i other Display: %lx\n", + NORM_ERR("X Error: type %i Display %lx XID %li serial %lu error_code %i request_code %i minor_code %i other Display: %lx\n", err->type, (long unsigned)err->display, (long)err->resourceid, @@ -8037,7 +8058,7 @@ int x11_ioerror_handler(Display *d) __attribute__((noreturn)); int x11_ioerror_handler(Display *d) { - ERR("X Error: Display %lx\n", + NORM_ERR("X Error: Display %lx\n", (long unsigned)d ); abort(); @@ -8095,7 +8116,7 @@ static void X11_create_window(void) x11_stuff.region = XCreateRegion(); #ifdef HAVE_XDAMAGE if (!XDamageQueryExtension(display, &x11_stuff.event_base, &x11_stuff.error_base)) { - ERR("Xdamage extension unavailable"); + NORM_ERR("Xdamage extension unavailable"); } x11_stuff.damage = XDamageCreate(display, window.window, XDamageReportNonEmpty); x11_stuff.region2 = XFixesCreateRegionFromWindow(display, window.window, 0); @@ -8112,8 +8133,8 @@ static void X11_create_window(void) } #endif /* X11 */ -#define CONF_ERR ERR("%s: %d: config file error", f, line) -#define CONF_ERR2(a) ERR("%s: %d: config file error: %s", f, line, a) +#define CONF_ERR NORM_ERR("%s: %d: config file error", f, line) +#define CONF_ERR2(a) NORM_ERR("%s: %d: config file error: %s", f, line, a) #define CONF2(a) if (strcasecmp(name, a) == 0) #define CONF(a) else CONF2(a) #define CONF3(a, b) else if (strcasecmp(name, a) == 0 \ @@ -8453,8 +8474,11 @@ char load_config_file(const char *f) } #endif /* X11 */ CONF("out_to_console") { - if(string_to_bool(value)) + if(string_to_bool(value)) { output_methods |= TO_STDOUT; + } else { + output_methods &= ~TO_STDOUT; + } } CONF("extra_newline") { extra_newline = string_to_bool(value); @@ -8463,6 +8487,14 @@ char load_config_file(const char *f) if(string_to_bool(value)) output_methods |= TO_STDERR; } +#ifdef NCURSES + CONF("out_to_ncurses") { + if(string_to_bool(value)) { + initscr(); + output_methods |= TO_NCURSES; + } + } +#endif CONF("overwrite_file") { if(overwrite_file) { free(overwrite_file); @@ -8472,7 +8504,7 @@ char load_config_file(const char *f) overwrite_file = strdup(value); output_methods |= OVERWRITE_FILE; } else - ERR("overwrite_file won't be able to create/overwrite '%s'", value); + NORM_ERR("overwrite_file won't be able to create/overwrite '%s'", value); } CONF("append_file") { if(append_file) { @@ -8483,7 +8515,7 @@ char load_config_file(const char *f) append_file = strdup(value); output_methods |= APPEND_FILE; } else - ERR("append_file won't be able to create/append '%s'", value); + NORM_ERR("append_file won't be able to create/append '%s'", value); } CONF("use_spacer") { if (value) { @@ -8495,7 +8527,7 @@ char load_config_file(const char *f) use_spacer = NO_SPACER; } else { use_spacer = string_to_bool(value); - ERR("use_spacer should have an argument of left, right, or" + NORM_ERR("use_spacer should have an argument of left, right, or" " none. '%s' seems to be some form of '%s', so" " defaulting to %s.", value, use_spacer ? "true" : "false", @@ -8507,7 +8539,7 @@ char load_config_file(const char *f) } } } else { - ERR("use_spacer should have an argument. Defaulting to right."); + NORM_ERR("use_spacer should have an argument. Defaulting to right."); use_spacer = RIGHT_SPACER; } } @@ -8531,7 +8563,7 @@ char load_config_file(const char *f) #else CONF("use_xft") { if (string_to_bool(value)) { - ERR("Xft not enabled at compile time"); + NORM_ERR("Xft not enabled at compile time"); } } CONF("xftfont") { @@ -8774,7 +8806,7 @@ char load_config_file(const char *f) if (value) { text_buffer_size = atoi(value); if (text_buffer_size < DEFAULT_TEXT_BUFFER_SIZE) { - ERR("text_buffer_size must be >=%i bytes", DEFAULT_TEXT_BUFFER_SIZE); + NORM_ERR("text_buffer_size must be >=%i bytes", DEFAULT_TEXT_BUFFER_SIZE); text_buffer_size = DEFAULT_TEXT_BUFFER_SIZE; } } else { @@ -8850,7 +8882,7 @@ char load_config_file(const char *f) #endif CONF("if_up_strictness") { if (!value) { - ERR("incorrect if_up_strictness value, defaulting to 'up'"); + NORM_ERR("incorrect if_up_strictness value, defaulting to 'up'"); ifup_strictness = IFUP_UP; } else if (strcasecmp(value, "up") == EQUAL) { ifup_strictness = IFUP_UP; @@ -8859,16 +8891,16 @@ char load_config_file(const char *f) } else if (strcasecmp(value, "address") == EQUAL) { ifup_strictness = IFUP_ADDR; } else { - ERR("incorrect if_up_strictness value, defaulting to 'up'"); + NORM_ERR("incorrect if_up_strictness value, defaulting to 'up'"); ifup_strictness = IFUP_UP; } } CONF("temperature_unit") { if (!value) { - ERR("config option 'temperature_unit' needs an argument, either 'celsius' or 'fahrenheit'"); + NORM_ERR("config option 'temperature_unit' needs an argument, either 'celsius' or 'fahrenheit'"); } else if (set_temp_output_unit(value)) { - ERR("temperature_unit: incorrect argument"); + NORM_ERR("temperature_unit: incorrect argument"); } } @@ -8918,7 +8950,7 @@ char load_config_file(const char *f) CONF("own_window_colour") {} else { - ERR("%s: %d: no such configuration: '%s'", f, line, name); + NORM_ERR("%s: %d: no such configuration: '%s'", f, line, name); } } @@ -9092,7 +9124,7 @@ static void load_config_file_x11(const char *f) if (value) { background_colour = get_x11_color(value); } else { - ERR("Invalid colour for own_window_colour (try omitting the " + NORM_ERR("Invalid colour for own_window_colour (try omitting the " "'#' for hex colours"); } } @@ -9206,7 +9238,7 @@ void initialisation(int argc, char **argv) { /* init specials array */ if ((specials = calloc(sizeof(struct special_t), max_specials)) == 0) { - ERR("failed to create specials array"); + NORM_ERR("failed to create specials array"); } #ifdef MAIL_FILE @@ -9326,7 +9358,7 @@ void initialisation(int argc, char **argv) { switch (pid) { case -1: - ERR(PACKAGE_NAME": couldn't fork() to background: %s", + NORM_ERR(PACKAGE_NAME": couldn't fork() to background: %s", strerror(errno)); break; @@ -9375,7 +9407,7 @@ void initialisation(int argc, char **argv) { || sigaction(SIGUSR1, &act, &oact) < 0 || sigaction(SIGHUP, &act, &oact) < 0 || sigaction(SIGTERM, &act, &oact) < 0) { - ERR("error setting signal handler: %s", strerror(errno)); + NORM_ERR("error setting signal handler: %s", strerror(errno)); } } @@ -9407,7 +9439,7 @@ int main(int argc, char **argv) || ((s = getenv("LANG")) && *s)) { temp = (char *) malloc((strlen(s) + 1) * sizeof(char)); if (temp == NULL) { - ERR("malloc failed"); + NORM_ERR("malloc failed"); } for (x = 0; x < strlen(s); x++) { temp[x] = tolower(s[x]); @@ -9420,7 +9452,7 @@ int main(int argc, char **argv) free(temp); } if (!setlocale(LC_CTYPE, "")) { - ERR("Can't set the specified locale!\nCheck LANG, LC_CTYPE, LC_ALL."); + NORM_ERR("Can't set the specified locale!\nCheck LANG, LC_CTYPE, LC_ALL."); } #endif /* X11 */ while (1) { @@ -9472,7 +9504,7 @@ int main(int argc, char **argv) struct stat sb; if (stat(current_config, &sb) || (!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode))) { - ERR("invalid configuration file '%s'\n", current_config); + NORM_ERR("invalid configuration file '%s'\n", current_config); free(current_config); current_config = 0; } @@ -9502,7 +9534,7 @@ int main(int argc, char **argv) if (!current_config) { #ifdef CONFIG_OUTPUT current_config = strdup("==builtin=="); - ERR("no readable personal or system-wide config file found," + NORM_ERR("no readable personal or system-wide config file found," " using builtin default"); #else CRIT_ERR(NULL, NULL, "no readable personal or system-wide config file found"); diff --git a/src/conky.h b/src/conky.h index c341a53..d34d234 100644 --- a/src/conky.h +++ b/src/conky.h @@ -368,6 +368,9 @@ extern char *current_config; #define TO_STDERR 4 #define OVERWRITE_FILE 8 #define APPEND_FILE 16 +#ifdef NCURSES +#define TO_NCURSES 32 +#endif enum x_initialiser_state { NO = 0, YES = 1, diff --git a/src/diskio.c b/src/diskio.c index b6c4c20..8b407b3 100644 --- a/src/diskio.c +++ b/src/diskio.c @@ -85,7 +85,7 @@ struct diskio_stat *prepare_diskio_stat(const char *s) snprintf(stat_name, text_buffer_size, "/dev/%s", device_name); if (stat(stat_name, &sb)) { - ERR("diskio device '%s' does not exist", s); + NORM_ERR("diskio device '%s' does not exist", s); return 0; } diff --git a/src/fonts.c b/src/fonts.c index 4c08c65..a31e563 100644 --- a/src/fonts.c +++ b/src/fonts.c @@ -175,13 +175,13 @@ void load_fonts(void) continue; } - ERR("can't load Xft font '%s'", fonts[i].name); + NORM_ERR("can't load Xft font '%s'", fonts[i].name); if ((fonts[i].xftfont = XftFontOpenName(display, screen, "courier-12")) != NULL) { continue; } - ERR("can't load Xft font '%s'", "courier-12"); + NORM_ERR("can't load Xft font '%s'", "courier-12"); if ((fonts[i].font = XLoadQueryFont(display, "fixed")) == NULL) { CRIT_ERR(NULL, NULL, "can't load font '%s'", "fixed"); @@ -193,7 +193,7 @@ void load_fonts(void) #endif /* load normal font */ if (!fonts[i].font && (fonts[i].font = XLoadQueryFont(display, fonts[i].name)) == NULL) { - ERR("can't load font '%s'", fonts[i].name); + NORM_ERR("can't load font '%s'", fonts[i].name); if ((fonts[i].font = XLoadQueryFont(display, "fixed")) == NULL) { CRIT_ERR(NULL, NULL, "can't load font '%s'", "fixed"); } diff --git a/src/fs.c b/src/fs.c index 28f6a68..044317a 100644 --- a/src/fs.c +++ b/src/fs.c @@ -99,7 +99,7 @@ struct fs_stat *prepare_fs_stat(const char *s) } /* new path */ if (!new) { - ERR("too many fs stats"); + NORM_ERR("too many fs stats"); return 0; } strncpy(new->path, s, DEFAULT_TEXT_BUFFER_SIZE); @@ -123,7 +123,7 @@ static void update_fs_stat(struct fs_stat *fs) fs->avail = 0; fs->free = 0; strncpy(fs->type, "unknown", DEFAULT_TEXT_BUFFER_SIZE); - ERR("statfs '%s': %s", fs->path, strerror(errno)); + NORM_ERR("statfs '%s': %s", fs->path, strerror(errno)); } } @@ -136,7 +136,7 @@ void get_fs_type(const char *path, char *result) if (statfs(path, &s) == 0) { strncpy(result, s.f_fstypename, DEFAULT_TEXT_BUFFER_SIZE); } else { - ERR("statfs '%s': %s", path, strerror(errno)); + NORM_ERR("statfs '%s': %s", path, strerror(errno)); } return; @@ -149,7 +149,7 @@ void get_fs_type(const char *path, char *result) char *slash; if (mtab == NULL) { - ERR("setmntent /etc/mtab: %s", strerror(errno)); + NORM_ERR("setmntent /etc/mtab: %s", strerror(errno)); strncpy(result, "unknown", DEFAULT_TEXT_BUFFER_SIZE); return; } diff --git a/src/hddtemp.c b/src/hddtemp.c index b90fba4..d053305 100644 --- a/src/hddtemp.c +++ b/src/hddtemp.c @@ -137,7 +137,7 @@ char *get_hddtemp_info(char *dev, char *hostaddr, int port) #ifdef HAVE_GETHOSTBYNAME_R if (gethostbyname_r(hostaddr, &he, hostbuff, sizeof(hostbuff), &he_res, &he_errno)) { - ERR("hddtemp gethostbyname_r: %s", hstrerror(h_errno)); + NORM_ERR("hddtemp gethostbyname_r: %s", hstrerror(h_errno)); #else /* HAVE_GETHOSTBYNAME_R */ if (!(he_res = gethostbyname(hostaddr))) { perror("gethostbyname()"); @@ -175,7 +175,7 @@ char *get_hddtemp_info(char *dev, char *hostaddr, int port) perror("select"); } } else if (i == 0) { /* select() timeouted */ - ERR("hddtemp had nothing for us"); + NORM_ERR("hddtemp had nothing for us"); goto GET_OUT; } @@ -192,7 +192,7 @@ char *get_hddtemp_info(char *dev, char *hostaddr, int port) } while (i > 0 && p < buf + BUFLEN - 1); if (len < 2) { - ERR("hddtemp returned nada"); + NORM_ERR("hddtemp returned nada"); goto GET_OUT; } diff --git a/src/imlib2.c b/src/imlib2.c index a9f7391..394da1f 100644 --- a/src/imlib2.c +++ b/src/imlib2.c @@ -71,7 +71,7 @@ void cimlib_set_cache_flush_interval(long interval) if (interval >= 0) { cimlib_cache_flush_interval = interval; } else { - ERR("Imlib2: flush interval should be >= 0"); + NORM_ERR("Imlib2: flush interval should be >= 0"); } } @@ -110,7 +110,7 @@ void cimlib_add_image(const char *args) memset(cur, 0, sizeof(struct image_list_s)); if (!sscanf(args, "%1023s", cur->name)) { - ERR("Invalid args for $image. Format is: ' (-p x,y) (-s WxH) (-n) (-f interval)' (got '%s')", args); + NORM_ERR("Invalid args for $image. Format is: ' (-p x,y) (-s WxH) (-n) (-f interval)' (got '%s')", args); free(cur); return; } @@ -142,7 +142,7 @@ void cimlib_add_image(const char *args) } } if (cur->flush_interval < 0) { - ERR("Imlib2: flush interval should be >= 0"); + NORM_ERR("Imlib2: flush interval should be >= 0"); cur->flush_interval = 0; } @@ -163,7 +163,7 @@ cimlib_draw_image(struct image_list_s *cur, int *clip_x, image = imlib_load_image(cur->name); if (!image) { - ERR("Unable to load image '%s'", cur->name); + NORM_ERR("Unable to load image '%s'", cur->name); return; } diff --git a/src/linux.c b/src/linux.c index e253885..bb78380 100644 --- a/src/linux.c +++ b/src/linux.c @@ -136,7 +136,7 @@ int check_mount(char *s) } fclose(mtab); } else { - ERR("Could not open mtab"); + NORM_ERR("Could not open mtab"); } return ret; } @@ -775,7 +775,7 @@ void update_i8k(void) memset(&i8k_procbuf[0], 0, 128); if (fread(&i8k_procbuf[0], sizeof(char), 128, fp) == 0) { - ERR("something wrong with /proc/i8k..."); + NORM_ERR("something wrong with /proc/i8k..."); } fclose(fp); @@ -812,7 +812,7 @@ static int get_first_file_in_a_directory(const char *dir, char *s, int *rep) n = scandir(dir, &namelist, no_dots, alphasort); if (n < 0) { if (!rep || !*rep) { - ERR("scandir for %s: %s", dir, strerror(errno)); + NORM_ERR("scandir for %s: %s", dir, strerror(errno)); if (rep) { *rep = 1; } @@ -924,7 +924,7 @@ int open_sysfs_sensor(const char *dir, const char *dev, const char *type, int n, /* should read until n == 0 but I doubt that kernel will give these * in multiple pieces. :) */ if (divn < 0) { - ERR("open_sysfs_sensor(): can't read from sysfs"); + NORM_ERR("open_sysfs_sensor(): can't read from sysfs"); } else { divbuf[divn] = '\0'; *divisor = atoi(divbuf); @@ -954,7 +954,7 @@ double get_sysfs_info(int *fd, int divisor, char *devtype, char *type) /* should read until n == 0 but I doubt that kernel will give these * in multiple pieces. :) */ if (n < 0) { - ERR("get_sysfs_info(): read from %s failed\n", devtype); + NORM_ERR("get_sysfs_info(): read from %s failed\n", devtype); } else { buf[n] = '\0'; val = atoi(buf); @@ -965,7 +965,7 @@ double get_sysfs_info(int *fd, int divisor, char *devtype, char *type) /* open file */ *fd = open(devtype, O_RDONLY); if (*fd < 0) { - ERR("can't open '%s': %s", devtype, strerror(errno)); + NORM_ERR("can't open '%s': %s", devtype, strerror(errno)); } /* My dirty hack for computing CPU value @@ -1357,7 +1357,7 @@ int open_acpi_temperature(const char *name) fd = open(path, O_RDONLY); if (fd < 0) { - ERR("can't open '%s': %s", path, strerror(errno)); + NORM_ERR("can't open '%s': %s", path, strerror(errno)); } return fd; @@ -1388,7 +1388,7 @@ double get_acpi_temperature(int fd) n = read(fd, buf, 255); if (n < 0) { - ERR("can't read fd %d: %s", fd, strerror(errno)); + NORM_ERR("can't read fd %d: %s", fd, strerror(errno)); } else { buf[n] = '\0'; sscanf(buf, "temperature: %lf", &last_acpi_temp); diff --git a/src/llua.c b/src/llua.c index 47dc120..7c3e227 100644 --- a/src/llua.c +++ b/src/llua.c @@ -143,7 +143,7 @@ void llua_load(const char *script) to_real_path(path, script); error = luaL_dofile(lua_L, path); if (error) { - ERR("llua_load: %s", lua_tostring(lua_L, -1)); + NORM_ERR("llua_load: %s", lua_tostring(lua_L, -1)); lua_pop(lua_L, 1); #ifdef HAVE_SYS_INOTIFY_H } else if (!llua_block_notify && inotify_fd != -1) { @@ -192,7 +192,7 @@ char *llua_do_call(const char *string, int retc) free(tmp); if(lua_pcall(lua_L, argc, retc, 0) != 0) { - ERR("llua_do_call: function %s execution failed: %s", func, lua_tostring(lua_L, -1)); + NORM_ERR("llua_do_call: function %s execution failed: %s", func, lua_tostring(lua_L, -1)); lua_pop(lua_L, -1); return NULL; } @@ -215,7 +215,7 @@ char *llua_do_read_call(const char *function, const char *arg, int retc) lua_pushstring(lua_L, arg); if (lua_pcall(lua_L, 1, retc, 0) != 0) { - ERR("llua_do_call: function %s execution failed: %s", func, lua_tostring(lua_L, -1)); + NORM_ERR("llua_do_call: function %s execution failed: %s", func, lua_tostring(lua_L, -1)); lua_pop(lua_L, -1); return NULL; } @@ -233,7 +233,7 @@ char *llua_getstring(const char *args) func = llua_do_call(args, 1); if (func) { if (!lua_isstring(lua_L, -1)) { - ERR("llua_getstring: function %s didn't return a string, result discarded", func); + NORM_ERR("llua_getstring: function %s didn't return a string, result discarded", func); } else { ret = strdup(lua_tostring(lua_L, -1)); lua_pop(lua_L, 1); @@ -253,7 +253,7 @@ char *llua_getstring_read(const char *function, const char *arg) func = llua_do_read_call(function, arg, 1); if (func) { if(!lua_isstring(lua_L, -1)) { - ERR("llua_getstring_read: function %s didn't return a string, result discarded", func); + NORM_ERR("llua_getstring_read: function %s didn't return a string, result discarded", func); } else { ret = strdup(lua_tostring(lua_L, -1)); lua_pop(lua_L, 1); @@ -272,7 +272,7 @@ int llua_getnumber(const char *args, double *ret) func = llua_do_call(args, 1); if(func) { if(!lua_isnumber(lua_L, -1)) { - ERR("llua_getnumber: function %s didn't return a number, result discarded", func); + NORM_ERR("llua_getnumber: function %s didn't return a number, result discarded", func); } else { *ret = lua_tonumber(lua_L, -1); lua_pop(lua_L, 1); @@ -366,7 +366,7 @@ void llua_inotify_query(int wd, int mask) llua_block_notify = 1; llua_load(head->name); llua_block_notify = 0; - ERR("Lua script '%s' reloaded", head->name); + NORM_ERR("Lua script '%s' reloaded", head->name); if (mask & IN_IGNORED) { /* for some reason we get IN_IGNORED here * sometimes, so we need to re-add the watch */ diff --git a/src/logging.h b/src/logging.h index ec849d6..8916ff9 100644 --- a/src/logging.h +++ b/src/logging.h @@ -32,7 +32,7 @@ void clean_up(void *memtofree1, void* memtofree2); #ifndef _LOGGING_H #define _LOGGING_H -#define ERR(...) { \ +#define NORM_ERR(...) { \ fprintf(stderr, PACKAGE_NAME": "); \ fprintf(stderr, __VA_ARGS__); \ fprintf(stderr, "\n"); \ @@ -40,7 +40,7 @@ void clean_up(void *memtofree1, void* memtofree2); /* critical error */ #define CRIT_ERR(memtofree1, memtofree2, ...) \ - { ERR(__VA_ARGS__); clean_up(memtofree1, memtofree2); exit(EXIT_FAILURE); } + { NORM_ERR(__VA_ARGS__); clean_up(memtofree1, memtofree2); exit(EXIT_FAILURE); } /* debugging output */ extern int global_debug_level; diff --git a/src/mail.c b/src/mail.c index 7a068a3..5db57b6 100644 --- a/src/mail.c +++ b/src/mail.c @@ -77,11 +77,11 @@ void update_mail_count(struct local_mail_s *mail) mail->last_update = current_update_time; } - if (stat(mail->box, &st)) { + if (stat(mail->mbox, &st)) { static int rep = 0; if (!rep) { - ERR("can't stat %s: %s", mail->box, strerror(errno)); + NORM_ERR("can't stat %s: %s", mail->mbox, strerror(errno)); rep = 1; } return; @@ -100,19 +100,19 @@ void update_mail_count(struct local_mail_s *mail) mail->forwarded_mail_count = mail->unforwarded_mail_count = 0; mail->replied_mail_count = mail->unreplied_mail_count = 0; mail->draft_mail_count = mail->trashed_mail_count = 0; - dirname = (char *) malloc(sizeof(char) * (strlen(mail->box) + 5)); + dirname = (char *) malloc(sizeof(char) * (strlen(mail->mbox) + 5)); if (!dirname) { - ERR("malloc"); + NORM_ERR("malloc"); return; } - strcpy(dirname, mail->box); + strcpy(dirname, mail->mbox); strcat(dirname, "/"); /* checking the cur subdirectory */ strcat(dirname, "cur"); dir = opendir(dirname); if (!dir) { - ERR("cannot open directory"); + NORM_ERR("cannot open directory"); free(dirname); return; } @@ -123,7 +123,7 @@ void update_mail_count(struct local_mail_s *mail) mail->mail_count++; mailflags = (char *) malloc(sizeof(char) * strlen(strrchr(dirent->d_name, ','))); if (!mailflags) { - ERR("malloc"); + NORM_ERR("malloc"); free(dirname); return; } @@ -166,7 +166,7 @@ void update_mail_count(struct local_mail_s *mail) dir = opendir(dirname); if (!dir) { - ERR("cannot open directory"); + NORM_ERR("cannot open directory"); free(dirname); return; } @@ -205,7 +205,7 @@ void update_mail_count(struct local_mail_s *mail) mail->replied_mail_count = mail->unreplied_mail_count = -1; mail->draft_mail_count = mail->trashed_mail_count = -1; - fp = open_file(mail->box, &rep); + fp = open_file(mail->mbox, &rep); if (!fp) { return; } @@ -307,9 +307,9 @@ struct mail_s *parse_mail_args(char type, const char *arg) if (sscanf(arg, "%128s %128s %128s", mail->host, mail->user, mail->pass) != 3) { if (type == POP3_TYPE) { - ERR("Scanning POP3 args failed"); + NORM_ERR("Scanning POP3 args failed"); } else if (type == IMAP_TYPE) { - ERR("Scanning IMAP args failed"); + NORM_ERR("Scanning IMAP args failed"); } return 0; } @@ -420,7 +420,7 @@ int imap_check_status(char *recvbuf, struct mail_s *mail) reply += 2; *strchr(reply, ')') = '\0'; if (reply == NULL) { - ERR("Error parsing IMAP response: %s", recvbuf); + NORM_ERR("Error parsing IMAP response: %s", recvbuf); return -1; } else { timed_thread_lock(mail->p_timed_thread); @@ -461,7 +461,7 @@ void *imap_thread(void *arg) #ifdef HAVE_GETHOSTBYNAME_R if (gethostbyname_r(mail->host, &he, hostbuff, sizeof(hostbuff), &he_res, &he_errno)) { // get the host info - ERR("IMAP gethostbyname_r: %s", hstrerror(h_errno)); + NORM_ERR("IMAP gethostbyname_r: %s", hstrerror(h_errno)); exit(EXIT_FAILURE); } #else /* HAVE_GETHOSTBYNAME_R */ @@ -476,7 +476,7 @@ void *imap_thread(void *arg) fd_set fdset; if (fail > 0) { - ERR("Trying IMAP connection again for %s@%s (try %u/%u)", + NORM_ERR("Trying IMAP connection again for %s@%s (try %u/%u)", mail->user, mail->host, fail + 1, mail->retries); } do { @@ -513,14 +513,14 @@ void *imap_thread(void *arg) break; } } else { - ERR("IMAP connection failed: timeout"); + NORM_ERR("IMAP connection failed: timeout"); fail++; break; } recvbuf[numbytes] = '\0'; DBGP2("imap_thread() received: %s", recvbuf); if (strstr(recvbuf, "* OK") != recvbuf) { - ERR("IMAP connection failed, probably not an IMAP server"); + NORM_ERR("IMAP connection failed, probably not an IMAP server"); fail++; break; } @@ -706,7 +706,7 @@ void *imap_thread(void *arg) recvbuf[numbytes] = '\0'; DBGP2("imap_thread() received: %s", recvbuf); if (strstr(recvbuf, "a3 OK") == NULL) { - ERR("IMAP logout failed: %s", recvbuf); + NORM_ERR("IMAP logout failed: %s", recvbuf); fail++; break; } @@ -770,7 +770,7 @@ void *pop3_thread(void *arg) #ifdef HAVE_GETHOSTBYNAME_R if (gethostbyname_r(mail->host, &he, hostbuff, sizeof(hostbuff), &he_res, &he_errno)) { // get the host info - ERR("POP3 gethostbyname_r: %s", hstrerror(h_errno)); + NORM_ERR("POP3 gethostbyname_r: %s", hstrerror(h_errno)); exit(EXIT_FAILURE); } #else /* HAVE_GETHOSTBYNAME_R */ @@ -785,7 +785,7 @@ void *pop3_thread(void *arg) fd_set fdset; if (fail > 0) { - ERR("Trying POP3 connection again for %s@%s (try %u/%u)", + NORM_ERR("Trying POP3 connection again for %s@%s (try %u/%u)", mail->user, mail->host, fail + 1, mail->retries); } do { @@ -822,14 +822,14 @@ void *pop3_thread(void *arg) break; } } else { - ERR("POP3 connection failed: timeout\n"); + NORM_ERR("POP3 connection failed: timeout\n"); fail++; break; } DBGP2("pop3_thread received: %s", recvbuf); recvbuf[numbytes] = '\0'; if (strstr(recvbuf, "+OK ") != recvbuf) { - ERR("POP3 connection failed, probably not a POP3 server"); + NORM_ERR("POP3 connection failed, probably not a POP3 server"); fail++; break; } @@ -845,7 +845,7 @@ void *pop3_thread(void *arg) strncat(sendbuf, mail->pass, MAXDATASIZE - strlen(sendbuf) - 1); strncat(sendbuf, "\r\n", MAXDATASIZE - strlen(sendbuf) - 1); if (pop3_command(sockfd, sendbuf, recvbuf, "+OK ")) { - ERR("POP3 server login failed: %s", recvbuf); + NORM_ERR("POP3 server login failed: %s", recvbuf); fail++; break; } @@ -860,7 +860,7 @@ void *pop3_thread(void *arg) // now we get the data reply = recvbuf + 4; if (reply == NULL) { - ERR("Error parsing POP3 response: %s", recvbuf); + NORM_ERR("Error parsing POP3 response: %s", recvbuf); fail++; break; } else { @@ -871,7 +871,7 @@ void *pop3_thread(void *arg) strncpy(sendbuf, "QUIT\r\n", MAXDATASIZE); if (pop3_command(sockfd, sendbuf, recvbuf, "+OK")) { - ERR("POP3 logout failed: %s", recvbuf); + NORM_ERR("POP3 logout failed: %s", recvbuf); fail++; break; } diff --git a/src/mail.h b/src/mail.h index a807b39..21664d8 100644 --- a/src/mail.h +++ b/src/mail.h @@ -27,7 +27,7 @@ struct mail_s { // for imap and pop3 }; struct local_mail_s { - char *box; + char *mbox; int mail_count; int new_mail_count; int seen_mail_count; diff --git a/src/mboxscan.c b/src/mboxscan.c index c911b4f..d3cd404 100644 --- a/src/mboxscan.c +++ b/src/mboxscan.c @@ -166,7 +166,7 @@ void mbox_scan(char *args, char *output, size_t max_len) /* mbox still exists? and get stat-infos */ if (stat(mbox_mail_spool, &statbuf)) { - ERR("can't stat %s: %s", mbox_mail_spool, strerror(errno)); + NORM_ERR("can't stat %s: %s", mbox_mail_spool, strerror(errno)); output[0] = '\0'; /* delete any output */ return; } diff --git a/src/mixer.c b/src/mixer.c index 7c381aa..ccda5aa 100644 --- a/src/mixer.c +++ b/src/mixer.c @@ -223,7 +223,7 @@ int mixer_init(const char *name) if (mixer_fd <= 0) { mixer_fd = open(MIXER_DEV, O_RDONLY); if (mixer_fd == -1) { - ERR("can't open %s: %s", MIXER_DEV, strerror(errno)); + NORM_ERR("can't open %s: %s", MIXER_DEV, strerror(errno)); return -1; } } @@ -244,7 +244,7 @@ static int mixer_get(int i) if (ioctl(mixer_fd, MIXER_READ(i), &val) == -1) { if (!rep) { - ERR("mixer ioctl: %s", strerror(errno)); + NORM_ERR("mixer ioctl: %s", strerror(errno)); } rep = 1; return 0; diff --git a/src/moc.c b/src/moc.c index 98a4dc3..652d421 100644 --- a/src/moc.c +++ b/src/moc.c @@ -123,12 +123,12 @@ int run_moc_thread(double interval) moc_thread = timed_thread_create(&update_moc, NULL, interval); if (!moc_thread) { - ERR("Failed to create MOC timed thread"); + NORM_ERR("Failed to create MOC timed thread"); return 1; } timed_thread_register(moc_thread, &moc_thread); if (timed_thread_run(moc_thread)) { - ERR("Failed to run MOC timed thread"); + NORM_ERR("Failed to run MOC timed thread"); return 2; } return 0; diff --git a/src/mpd.c b/src/mpd.c index 44d0abe..ca59287 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -126,12 +126,12 @@ void update_mpd(void) interval = info.music_player_interval * 1000000; thread = timed_thread_create(&update_mpd_thread, &thread, interval); if (!thread) { - ERR("Failed to create MPD timed thread"); + NORM_ERR("Failed to create MPD timed thread"); return; } timed_thread_register(thread, &thread); if (timed_thread_run(thread)) - ERR("Failed to run MPD timed thread"); + NORM_ERR("Failed to run MPD timed thread"); } /* stringMAXdup dups at most text_buffer_size bytes */ @@ -157,7 +157,7 @@ static void *update_mpd_thread(void *arg) timed_thread_lock(me); if (conn->error || conn == NULL) { - ERR("MPD error: %s\n", conn->errorStr); + NORM_ERR("MPD error: %s\n", conn->errorStr); mpd_closeConnection(conn); conn = 0; clear_mpd(); @@ -172,7 +172,7 @@ static void *update_mpd_thread(void *arg) mpd_sendStatusCommand(conn); if ((status = mpd_getStatus(conn)) == NULL) { - ERR("MPD error: %s\n", conn->errorStr); + NORM_ERR("MPD error: %s\n", conn->errorStr); mpd_closeConnection(conn); conn = 0; clear_mpd(); diff --git a/src/openbsd.c b/src/openbsd.c index ff67066..4ab676b 100644 --- a/src/openbsd.c +++ b/src/openbsd.c @@ -89,7 +89,7 @@ static int kvm_init() kd = kvm_open(NULL, NULL, NULL, KVM_NO_FILES, NULL); if (kd == NULL) { - ERR("error opening kvm"); + NORM_ERR("error opening kvm"); } else { init_kvm = 1; } @@ -152,7 +152,7 @@ void update_uptime() time(&now); info.uptime = now - boottime.tv_sec; } else { - ERR("Could not get uptime"); + NORM_ERR("Could not get uptime"); info.uptime = 0; } } @@ -324,7 +324,7 @@ void get_cpu_count() size_t len = sizeof(cpu_count); if (sysctl(mib, 2, &cpu_count, &len, NULL, 0) != 0) { - ERR("error getting cpu count, defaulting to 1"); + NORM_ERR("error getting cpu count, defaulting to 1"); } #endif info.cpu_count = cpu_count; @@ -363,7 +363,7 @@ void update_cpu_usage() #ifdef OLDCPU if (sysctl(mib, 2, &cp_time, &len, NULL, 0) < 0) { - ERR("Cannot get kern.cp_time"); + NORM_ERR("Cannot get kern.cp_time"); } fresh.load[0] = cp_time[CP_USER]; @@ -391,7 +391,7 @@ void update_cpu_usage() int cp_time_mib[] = { CTL_KERN, KERN_CPTIME2, i }; if (sysctl(cp_time_mib, 3, &(fresh[i * CPUSTATES]), &size, NULL, 0) < 0) { - ERR("sysctl kern.cp_time2 failed"); + NORM_ERR("sysctl kern.cp_time2 failed"); } } } else { @@ -400,7 +400,7 @@ void update_cpu_usage() size = sizeof(cp_time_tmp); if (sysctl(cp_time_mib, 2, cp_time_tmp, &size, NULL, 0) < 0) { - ERR("sysctl kern.cp_time failed"); + NORM_ERR("sysctl kern.cp_time failed"); } for (i = 0; i < CPUSTATES; i++) { @@ -514,7 +514,7 @@ void get_obsd_vendor(char *buf, size_t client_buffer_size) size_t size = sizeof(vendor); if (sysctl(mib, 2, vendor, &size, NULL, 0) == -1) { - ERR("error reading vendor"); + NORM_ERR("error reading vendor"); snprintf(buf, client_buffer_size, "unknown"); } else { snprintf(buf, client_buffer_size, "%s", vendor); @@ -532,7 +532,7 @@ void get_obsd_product(char *buf, size_t client_buffer_size) size_t size = sizeof(product); if (sysctl(mib, 2, product, &size, NULL, 0) == -1) { - ERR("error reading product"); + NORM_ERR("error reading product"); snprintf(buf, client_buffer_size, "unknown"); } else { snprintf(buf, client_buffer_size, "%s", product); @@ -724,7 +724,7 @@ inline void proc_find_top(struct process **cpu, struct process **mem) size_t size = sizeof(usermem); if (sysctl(mib, 2, &usermem, &size, NULL, 0) == -1) { - ERR("error reading usermem"); + NORM_ERR("error reading usermem"); } /* translate bytes into page count */ diff --git a/src/rss.c b/src/rss.c index 1832f5b..5fa2b9d 100644 --- a/src/rss.c +++ b/src/rss.c @@ -58,7 +58,7 @@ void rss_process_info(char *p, int p_max_size, char *uri, char *action, int curloc->process_function = &prss_parse_data; ccurl_init_thread(curloc, interval); if (!curloc->p_timed_thread) { - ERR("error setting up RSS thread"); + NORM_ERR("error setting up RSS thread"); } } diff --git a/src/smapi.c b/src/smapi.c index cb6758f..2189b3e 100644 --- a/src/smapi.c +++ b/src/smapi.c @@ -103,7 +103,7 @@ char *smapi_get_bat_val(const char *args) if(sscanf(args, "%i %n", &idx, &cnt) <= 0 || snprintf(fname, 127, "%s", (args + cnt)) < 0) { - ERR("smapi: wrong arguments, should be 'bat,,'"); + NORM_ERR("smapi: wrong arguments, should be 'bat,,'"); return NULL; } diff --git a/src/solaris.c b/src/solaris.c index b68a10f..22b4529 100644 --- a/src/solaris.c +++ b/src/solaris.c @@ -41,7 +41,7 @@ static void update_kstat() if (kstat == NULL) { kstat = kstat_open(); if (kstat == NULL) { - ERR("can't open kstat: %s", strerror(errno)); + NORM_ERR("can't open kstat: %s", strerror(errno)); } } diff --git a/src/weather.c b/src/weather.c index 6a144cd..a2141d8 100644 --- a/src/weather.c +++ b/src/weather.c @@ -145,13 +145,13 @@ static void parse_weather_xml(PWEATHER *res, const char *data) xmlXPathContextPtr xpathCtx; if (!(doc = xmlReadMemory(data, strlen(data), "", NULL, 0))) { - ERR("weather: can't read xml data"); + NORM_ERR("weather: can't read xml data"); return; } xpathCtx = xmlXPathNewContext(doc); if(xpathCtx == NULL) { - ERR("weather: unable to create new XPath context"); + NORM_ERR("weather: unable to create new XPath context"); xmlFreeDoc(doc); return; } @@ -514,7 +514,7 @@ void weather_process_info(char *p, int p_max_size, char *uri, char *data_type, i curloc->process_function = &parse_weather; ccurl_init_thread(curloc, interval); if (!curloc->p_timed_thread) { - ERR("error setting up weather thread"); + NORM_ERR("error setting up weather thread"); } } diff --git a/src/x11.c b/src/x11.c index 5d325cd..a5af282 100644 --- a/src/x11.c +++ b/src/x11.c @@ -462,7 +462,7 @@ void init_window(int own_window, int w, int h, int set_trans, int back_colour, } } if (!use_xdbe) { - ERR("failed to set up double buffer"); + NORM_ERR("failed to set up double buffer"); } } if (!use_xdbe) { @@ -545,12 +545,12 @@ long get_x11_color(const char *name) /* now lets try again */ if (!XParseColor(display, DefaultColormap(display, screen), &newname[0], &color)) { - ERR("can't parse X color '%s'", name); + NORM_ERR("can't parse X color '%s'", name); return 0xFF00FF; } } if (!XAllocColor(display, DefaultColormap(display, screen), &color)) { - ERR("can't allocate X color '%s'", name); + NORM_ERR("can't allocate X color '%s'", name); } return (long) color.pixel; -- 1.7.9.5