From 474294f88806259e54fafe6cfd10287909868c99 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sat, 9 Feb 2008 14:39:00 +0100 Subject: [PATCH] Remove gui_common.[ch]. As the only gui in paraslash-0.3.x is the curses-based para_gui there is no point in having common gui functions. --- configure.ac | 2 +- gui.c | 38 ++++++++++++++++++++++++++++++++++---- gui_common.c | 47 ----------------------------------------------- gui_common.h | 4 ---- 4 files changed, 35 insertions(+), 56 deletions(-) delete mode 100644 gui_common.c delete mode 100644 gui_common.h diff --git a/configure.ac b/configure.ac index c612a542..ff27cb41 100644 --- a/configure.ac +++ b/configure.ac @@ -136,7 +136,7 @@ fsck_errlist_objs="osl rbtree fsck string sha1 fd" gui_cmdline_objs="gui.cmdline" gui_errlist_objs="exec close_on_fork signal string stat ringbuffer fd" -gui_other_objs="gui gui_common gui_theme" +gui_other_objs="gui gui_theme" gui_objs="$gui_cmdline_objs $gui_errlist_objs $gui_other_objs" ########################################################################### ssl diff --git a/gui.c b/gui.c index c335250f..933729a2 100644 --- a/gui.c +++ b/gui.c @@ -4,7 +4,7 @@ * Licensed under the GPL v2. For licencing details see COPYING. */ -/** \file gui.c ncurses-based interface for paraslash */ +/** \file gui.c Curses-based interface for paraslash. */ #include #include @@ -12,9 +12,9 @@ #include "gui.cmdline.h" #include "para.h" #include "gui.h" +#include "string.h" #include #include "ringbuffer.h" -#include "gui_common.h" #include "fd.h" #include "error.h" #include "list.h" @@ -29,8 +29,6 @@ static char *stat_content[NUM_STAT_ITEMS]; static int signal_pipe; -static void finish(int sig); - static struct win_data { WINDOW *win; NCURSES_SIZE_T begx; @@ -191,6 +189,38 @@ struct gui_command command_list[] = { } }; +static int para_open_audiod_pipe(char *cmd) +{ + int fds[3] = {0, 1, 0}; + pid_t pid; + int ret = para_exec_cmdline_pid(&pid, cmd, fds); + if (ret < 0) + return ret; + ret = mark_fd_nonblocking(fds[1]); + if (ret > 0) + return fds[1]; + close(fds[1]); + return ret; +} + +static int read_audiod_pipe(int fd, line_handler_t *line_handler) +{ + static char buf[4096]; + const ssize_t bufsize = sizeof(buf) - 1; + static ssize_t loaded; + ssize_t ret; + + if (loaded >= bufsize) + loaded = 0; + ret = read(fd, buf + loaded, bufsize - loaded); + if (ret > 0) { + loaded += ret; + buf[loaded] = '\0'; + loaded = for_each_line(buf, loaded, line_handler, NULL); + } + return ret; +} + static int find_cmd_byname(char *name) { int i; diff --git a/gui_common.c b/gui_common.c deleted file mode 100644 index b517d715..00000000 --- a/gui_common.c +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (C) 2006-2008 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ - -/** \file gui_common.c Functions used by the guis of paraslash. */ - - -#include -#include - -#include "para.h" -#include "string.h" -#include "fd.h" - -int para_open_audiod_pipe(char *cmd) -{ - int fds[3] = {0, 1, 0}; - pid_t pid; - int ret = para_exec_cmdline_pid(&pid, cmd, fds); - if (ret < 0) - return ret; - ret = mark_fd_nonblocking(fds[1]); - if (ret > 0) - return fds[1]; - close(fds[1]); - return ret; -} - -int read_audiod_pipe(int fd, line_handler_t *line_handler) -{ - static char buf[4096]; - const ssize_t bufsize = sizeof(buf) - 1; - static ssize_t loaded; - ssize_t ret; - - if (loaded >= bufsize) - loaded = 0; - ret = read(fd, buf + loaded, bufsize - loaded); - if (ret > 0) { - loaded += ret; - buf[loaded] = '\0'; - loaded = for_each_line(buf, loaded, line_handler, NULL); - } - return ret; -} diff --git a/gui_common.h b/gui_common.h deleted file mode 100644 index 0e8671f5..00000000 --- a/gui_common.h +++ /dev/null @@ -1,4 +0,0 @@ -#include "string.h" -int para_open_audiod_pipe(char *); -int read_audiod_pipe(int fd, line_handler_t *line_handler); - -- 2.39.5