1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2025-01-12 19:06:36 +00:00

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.
This commit is contained in:
Nikolas Garofil 2009-08-01 20:45:43 +02:00
parent 763ae568a7
commit 44b82311b9
33 changed files with 348 additions and 285 deletions

View File

@ -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

View File

@ -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

View File

@ -488,6 +488,17 @@
<listitem>Print text to stdout.
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>
<option>out_to_ncurses</option>
</command>
</term>
<listitem>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)
<para /></listitem>
</varlistentry>
<varlistentry>
<term>
<command>

View File

@ -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)\>"

View File

@ -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

View File

@ -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;
}

View File

@ -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 */

View File

@ -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, &current_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;
}

View File

@ -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");
}
}

View File

@ -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");
}

View File

@ -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;
}

File diff suppressed because it is too large Load Diff

View File

@ -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,

View File

@ -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;
}

View File

@ -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");
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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: '<path to image> (-p x,y) (-s WxH) (-n) (-f interval)' (got '%s')", args);
NORM_ERR("Invalid args for $image. Format is: '<path to image> (-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;
}

View File

@ -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);

View File

@ -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 */

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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();

View File

@ -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 */

View File

@ -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");
}
}

View File

@ -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,<int>,<str>'");
NORM_ERR("smapi: wrong arguments, should be 'bat,<int>,<str>'");
return NULL;
}

View File

@ -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));
}
}

View File

@ -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");
}
}

View File

@ -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;