X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=gui.c;h=fc2cd9a145d25ac5ff0197fa132a87f5492661f7;hp=616890299047629dcaad4541a239efae19f2b76c;hb=b2e6a24448a9e49e0766ab4f32163580eeff469e;hpb=40de1dd2fdbb054444d585aa70e2d50166a66e07 diff --git a/gui.c b/gui.c index 61689029..fc2cd9a1 100644 --- a/gui.c +++ b/gui.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1998-2008 Andre Noll + * Copyright (C) 1998-2009 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -489,17 +489,19 @@ static int add_output_line(char *line, __a_unused void *data) return 1; } +static int loglevel; + __printf_2_3 void para_log(int ll, const char *fmt,...) { int color; char *msg; - if (ll < conf.loglevel_arg || !curses_active) + if (ll < loglevel || !curses_active) return; switch (ll) { - case DEBUG: - case INFO: - case NOTICE: + case LL_DEBUG: + case LL_INFO: + case LL_NOTICE: color = COLOR_MSG; break; default: @@ -519,13 +521,12 @@ static void setup_signal_handling(void) para_install_sighandler(SIGCHLD); para_install_sighandler(SIGWINCH); para_install_sighandler(SIGUSR1); -// signal(SIGPIPE, SIG_IGN); - signal(SIGHUP, SIG_IGN); + para_sigaction(SIGHUP, SIG_IGN); } __noreturn static void do_exit(int ret) { - signal(SIGTERM, SIG_IGN); + para_sigaction(SIGTERM, SIG_IGN); kill(0, SIGTERM); exit(ret); } @@ -562,8 +563,7 @@ __noreturn __printf_2_3 static void msg_n_exit(int ret, const char* fmt, ...) static void print_welcome(void) { - int ll = conf.loglevel_arg; - if (ll > NOTICE) + if (loglevel > LL_NOTICE) return; outputf(COLOR_WELCOME, "Welcome to para_gui " PACKAGE_VERSION " \"" CODENAME "\". Theme: %s", theme.name); @@ -895,7 +895,7 @@ static int open_audiod_pipe(void) * when any key is pressed. * * EXTERNAL_MODE: Check only signal pipe. Used when an external command - * is running. During that thime curses is disabled. Returns when + * is running. During that time curses is disabled. Returns when * cmd_pid == 0. */ static int do_select(int mode) @@ -1091,13 +1091,14 @@ static void com_page_up(void) { unsigned lines; int fvr = first_visible_rbe(&lines); + if (fvr < 0 || fvr + 1 >= ringbuffer_filled(bot_win_rb)) { print_in_bar(COLOR_ERRMSG, "top of buffer is shown\n"); return; } scroll_position = fvr + 1; for (; scroll_position > 0; scroll_position--) { - fvr = first_visible_rbe(&lines); + first_visible_rbe(&lines); if (lines == bot.lines) break; } @@ -1168,24 +1169,24 @@ err_out: static void com_ll_decr(void) { - if (conf.loglevel_arg <= DEBUG) { + if (loglevel <= LL_DEBUG) { print_in_bar(COLOR_ERRMSG, "loglevel already at maximal verbosity\n"); return; } - conf.loglevel_arg--; - print_in_bar(COLOR_MSG, "loglevel set to %d\n", conf.loglevel_arg); + loglevel--; + print_in_bar(COLOR_MSG, "loglevel set to %d\n", loglevel); } static void com_ll_incr(void) { - if (conf.loglevel_arg >= EMERG) { + if (loglevel >= LL_EMERG) { print_in_bar(COLOR_ERRMSG, - "loglevel already at miminal verbosity\n"); + "loglevel already at minimal verbosity\n"); return; } - conf.loglevel_arg++; - print_in_bar(COLOR_MSG, "loglevel set to %d\n", conf.loglevel_arg); + loglevel++; + print_in_bar(COLOR_MSG, "loglevel set to %d\n", loglevel); } /* @@ -1391,6 +1392,7 @@ int main(int argc, char *argv[]) }; gui_cmdline_parser_config_file(cf, &conf, ¶ms); } + loglevel = get_loglevel_by_name(conf.loglevel_arg); if (check_key_map_args() < 0) { fprintf(stderr, "invalid key map in config file\n"); exit(EXIT_FAILURE);