X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=audioc.c;h=dabc2f77eb18d8b705241acc0753fd2fbbe34736;hp=79051a98bb03b542dbb7d53a76c0d4a426a484bc;hb=f5cf47f2bc4bb76d0d21e2467c5846cade38558f;hpb=6eab6671f857009b6d6a2de2c2ec8187f869f705 diff --git a/audioc.c b/audioc.c index 79051a98..dabc2f77 100644 --- a/audioc.c +++ b/audioc.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2013 Andre Noll + * Copyright (C) 2005 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -13,10 +13,11 @@ #include #include #include -#include #include #include "audioc.cmdline.h" +#include "audiod_cmd.lsg.h" + #include "para.h" #include "error.h" #include "net.h" @@ -25,7 +26,8 @@ #include "ggo.h" #include "version.h" -INIT_AUDIOC_ERRLISTS; +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; /** The gengetopt structure containing command line args. */ static struct audioc_args_info conf; @@ -72,14 +74,13 @@ fail: #include "sched.h" #include "buffer_tree.h" #include "interactive.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[]; @@ -97,11 +98,20 @@ 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[] = {LSG_AUDIOD_CMD_VERSION_OPTS, 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) { char *sia[] = {STATUS_ITEM_ARRAY NULL}; - char *opts[] = {"-p", NULL}; + char *opts[] = {LSG_AUDIOD_CMD_STAT_OPTS, NULL}; if (ci->word_num <= 2 && ci->word && ci->word[0] == '-') i9e_complete_option(opts, ci, cr); @@ -112,18 +122,22 @@ static void stat_completer(struct i9e_completion_info *ci, static void grab_completer(struct i9e_completion_info *ci, struct i9e_completion_result *cr) { - char *opts[] = {"-ms", "-ms", "-ma", "-p=", "-n=", "-o", NULL}; + char *opts[] = {LSG_AUDIOD_CMD_GRAB_OPTS, NULL}; i9e_complete_option(opts, ci, cr); } +I9E_DUMMY_COMPLETER(SUPERCOMMAND_UNAVAILABLE); static struct i9e_completer audiod_completers[] = { - AUDIOD_COMPLETERS +#define LSG_AUDIOD_CMD_CMD(_name) {.name = #_name, \ + .completer = _name ## _completer} + LSG_AUDIOD_CMD_SUBCOMMANDS +#undef LSG_AUDIOD_CMD_CMD {.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) @@ -131,10 +145,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) @@ -159,13 +173,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) { @@ -193,8 +201,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: @@ -239,6 +251,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: