X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=client.c;h=31cfff09798b2089e2b815a544fd207464f0e76c;hp=d951692caa22f11340dcae3e29962aec2e5aa0ec;hb=b2e4347baf722d13e4936cf2138750f05c43c3da;hpb=f3f25455d91c6d8fa7789abce1f7c536436beead diff --git a/client.c b/client.c index d951692c..31cfff09 100644 --- a/client.c +++ b/client.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1997-2014 Andre Noll + * Copyright (C) 1997 Andre Noll * * Licensed under the GPL v2. For licencing details see COPYING. */ @@ -35,8 +35,8 @@ __printf_2_3 void (*para_log)(int, const char*, ...) = stderr_log; #ifdef HAVE_READLINE #include "interactive.h" -#include "server_completion.h" -#include "afs_completion.h" +#include "server.completion.h" +#include "afs.completion.h" struct exec_task { struct task *task; @@ -45,18 +45,18 @@ struct exec_task { size_t result_size; }; -static void exec_pre_select(struct sched *s, struct task *t) +static void exec_pre_select(struct sched *s, void *context) { - struct exec_task *et = task_context(t); + struct exec_task *et = context; int ret = btr_node_status(et->btrn, 0, BTR_NT_LEAF); if (ret != 0) sched_min_delay(s); } -static int exec_post_select(__a_unused struct sched *s, struct task *t) +static int exec_post_select(__a_unused struct sched *s, void *context) { - struct exec_task *et = task_context(t); + struct exec_task *et = context; struct btr_node *btrn = et->btrn; char *buf; size_t sz; @@ -204,10 +204,10 @@ I9E_DUMMY_COMPLETER(pause); I9E_DUMMY_COMPLETER(play); I9E_DUMMY_COMPLETER(si); I9E_DUMMY_COMPLETER(term); -I9E_DUMMY_COMPLETER(version); I9E_DUMMY_COMPLETER(stop); I9E_DUMMY_COMPLETER(addatt); I9E_DUMMY_COMPLETER(init); +I9E_DUMMY_COMPLETER(tasks); static struct i9e_completer completers[]; @@ -217,6 +217,13 @@ static void help_completer(struct i9e_completion_info *ci, result->matches = i9e_complete_commands(ci->word, completers); } +static void version_completer(struct i9e_completion_info *ci, + struct i9e_completion_result *cr) +{ + char *opts[] = {"-v", NULL}; + i9e_complete_option(opts, ci, cr); +} + static void stat_completer(struct i9e_completion_info *ci, struct i9e_completion_result *cr) { @@ -269,9 +276,9 @@ static void ls_completer(struct i9e_completion_info *ci, struct i9e_completion_result *cr) { char *opts[] = { - "--", "-l", "-ls", "-ll", "-lv", "-lp", "-lm", "-lc", "-p", - "-a", "-r", "-d", "-sp", "-sl", "-ss", "-sn", "-sf", "-sc", - "-si", "-sy", "-sb", "-sd", "-sa", NULL + "--", "-l", "-l=s", "-l=l", "-l=v", "-l=p", "-l=m", "-l=c", + "-p", "-a", "-r", "-d", "-s=p", "-s=l", "-s=s", "-s=n", "-s=f", + "-s=c", "-s=i", "-s=y", "-s=b", "-s=d", "-s=a", NULL }; if (ci->word[0] == '-') i9e_complete_option(opts, ci, cr); @@ -316,11 +323,7 @@ static void lsatt_completer(struct i9e_completion_info *ci, struct i9e_completion_result *cr) { char *opts[] = {"-i", "-l", "-r", NULL}; - - if (ci->word[0] == '-') - i9e_complete_option(opts, ci, cr); - else - complete_attributes(ci->word, &cr->matches); + i9e_complete_option(opts, ci, cr); } static void mvatt_completer(struct i9e_completion_info *ci, @@ -530,16 +533,16 @@ __noreturn static void print_completions(void) struct supervisor_task { bool stdout_task_started; - struct task task; + struct task *task; }; -static int supervisor_post_select(struct sched *s, struct task *t) +static int supervisor_post_select(struct sched *s, void *context) { - struct supervisor_task *svt = container_of(t, struct supervisor_task, - task); + struct supervisor_task *svt = context; + int ret = task_status(ct->task); - if (ct->task.error < 0) - return ct->task.error; + if (ret < 0) + return ret; if (!svt->stdout_task_started && ct->status == CL_EXECUTING) { stdout_task_register(&sot, s); svt->stdout_task_started = true; @@ -552,12 +555,7 @@ static int supervisor_post_select(struct sched *s, struct task *t) return 0; } -static struct supervisor_task supervisor_task = { - .task = { - .post_select = supervisor_post_select, - .status = "supervisor task" - } -}; +static struct supervisor_task supervisor_task; /** * The client program to connect to para_server. @@ -605,18 +603,26 @@ int main(int argc, char *argv[]) goto out; sot.btrn = btr_new_node(&(struct btr_node_description) EMBRACE(.name = "stdout", .parent = ct->btrn[0])); - register_task(&sched, &supervisor_task.task); + supervisor_task.task = task_register(&(struct task_info) { + .name = "supervisor", + .post_select = supervisor_post_select, + .context = &supervisor_task, + }, &sched); + ret = schedule(&sched); - if (ret >= 0 && ct->task.error < 0) { - switch(ct->task.error) { - /* these are not errors */ - case -E_SERVER_CMD_SUCCESS: - case -E_EOF: - case -E_SERVER_EOF: - case -E_BTR_EOF: - ret = 0; - break; - default: ret = -E_SERVER_CMD_FAILURE; + if (ret >= 0) { + ret = task_status(ct->task); + if (ret < 0) { + switch (ret) { + /* these are not errors */ + case -E_SERVER_CMD_SUCCESS: + case -E_EOF: + case -E_SERVER_EOF: + case -E_BTR_EOF: + ret = 0; + break; + default: ret = -E_SERVER_CMD_FAILURE; + } } } sched_shutdown(&sched);