X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=audioc.c;h=337c8062e2b4257f47e7412d3d1ca631edd503a1;hp=0edab366efe6ef6fa50f99c22b9ffa3492494640;hb=a8786a08cf7cd65db89ee9ffa495e5282720082a;hpb=79d6515d49cdb0a91ff7c4a599f2d63cb5678032 diff --git a/audioc.c b/audioc.c index 0edab366..337c8062 100644 --- a/audioc.c +++ b/audioc.c @@ -1,14 +1,18 @@ /* - * Copyright (C) 2005-2013 Andre Noll + * Copyright (C) 2005 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ /** \file audioc.c The client program used to connect to para_audiod. */ +#include +#include #include #include -#include +#include +#include +#include #include #include "audioc.cmdline.h" @@ -67,14 +71,14 @@ fail: #include "sched.h" #include "buffer_tree.h" #include "interactive.h" -#include "audiod_completion.h" +#include "audiod.completion.h" static struct sched sched; struct audioc_task { int fd; struct btr_node *btrn; - struct task task; + struct task *task; }; static struct i9e_completer audiod_completers[]; @@ -92,6 +96,15 @@ static void help_completer(struct i9e_completion_info *ci, result->matches = i9e_complete_commands(ci->word, audiod_completers); } +static void version_completer(struct i9e_completion_info *ci, + struct i9e_completion_result *cr) +{ + char *opts[] = {"-v", NULL}; + + if (ci->word_num <= 2 && ci->word && ci->word[0] == '-') + i9e_complete_option(opts, ci, cr); +} + static void stat_completer(struct i9e_completion_info *ci, struct i9e_completion_result *cr) { @@ -116,9 +129,9 @@ static struct i9e_completer audiod_completers[] = { {.name = NULL} }; -static void audioc_pre_select(struct sched *s, struct task *t) +static void audioc_pre_select(struct sched *s, void *context) { - struct audioc_task *at = container_of(t, struct audioc_task, task); + struct audioc_task *at = context; int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT); if (ret < 0) @@ -126,10 +139,10 @@ static void audioc_pre_select(struct sched *s, struct task *t) para_fd_set(at->fd, &s->rfds, &s->max_fileno); } -static int audioc_post_select(struct sched *s, struct task *t) +static int audioc_post_select(struct sched *s, void *context) { char *buf = NULL; - struct audioc_task *at = container_of(t, struct audioc_task, task); + struct audioc_task *at = context; int ret = btr_node_status(at->btrn, 0, BTR_NT_ROOT); if (ret < 0) @@ -154,13 +167,7 @@ out: return ret; } -static struct audioc_task audioc_task = { - .task = { - .pre_select = audioc_pre_select, - .post_select = audioc_post_select, - .status = "audioc task" - }, -}, *at = &audioc_task; +static struct audioc_task audioc_task, *at = &audioc_task; static int audioc_i9e_line_handler(char *line) { @@ -188,8 +195,12 @@ static int audioc_i9e_line_handler(char *line) args = NULL; at->btrn = btr_new_node(&(struct btr_node_description) EMBRACE(.name = "audioc line handler")); - at->task.error = 0; - register_task(&sched, &at->task); + at->task = task_register(&(struct task_info) { + .name = "audioc", + .pre_select = audioc_pre_select, + .post_select = audioc_post_select, + .context = at, + }, &sched); i9e_attach_to_stdout(at->btrn); return 1; close: @@ -234,6 +245,7 @@ __noreturn static void interactive_session(void) goto out; para_log = i9e_log; ret = schedule(&sched); + sched_shutdown(&sched); i9e_close(); para_log = stderr_log; out: