para_play -> para_write documentation update
[paraslash.git] / gui_common.c
1 #include "para.h"
2
3 extern const char *status_item_list[NUM_STAT_ITEMS];
4
5
6 int para_open_audiod_pipe(char *cmd)
7 {
8 int fds[3] = {0, 1, 0};
9 pid_t pid;
10 return para_exec_cmdline_pid(&pid, cmd, fds) > 0?
11 fds[1] : -1;
12 }
13
14 int read_audiod_pipe(int fd, void (*line_handler)(char *) )
15 {
16 static char buf[STRINGSIZE];
17 const ssize_t bufsize = sizeof(buf) - 1;
18 static ssize_t loaded;
19 ssize_t ret;
20
21 if (loaded >= bufsize)
22 loaded = 0;
23 ret = read(fd, buf + loaded, bufsize - loaded);
24 if (ret > 0) {
25 loaded += ret;
26 buf[loaded] = '\0';
27 loaded = for_each_line(buf, loaded, line_handler);
28 }
29 return ret;
30 }