/*
- * Copyright (C) 1997-2011 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1997-2012 Andre Noll <maan@systemlinux.org>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
-/** \file client.c the client program used to connect to para_server */
+/** \file client.c The client program used to connect to para_server. */
#include <regex.h>
-#include <stdbool.h>
#include <signal.h>
#include "para.h"
goto out;
schedule(&command_sched);
*result = exec_task.result_buf;
- btr_remove_node(exec_task.btrn);
+ btr_remove_node(&exec_task.btrn);
client_disconnect(ct);
ret = 1;
out:
- btr_free_node(exec_task.btrn);
+ btr_remove_node(&exec_task.btrn);
if (ret < 0)
free(exec_task.result_buf);
return ret;
free(orig);
}
sl[2 * num_atts] = NULL;
- ret = i9e_extract_completions(ci->word, sl, &cr->matches);
+ i9e_extract_completions(ci->word, sl, &cr->matches);
out:
free(buf);
free_argv(sl);
return 1;
}
-static void client_sighandler(int s)
-{
- i9e_signal_dispatch(s);
-}
-
static struct i9e_completer completers[] = {
SERVER_COMPLETERS
AFS_COMPLETERS
}
ici.history_file = history_file;
- act.sa_handler = client_sighandler;
+ act.sa_handler = i9e_signal_dispatch;
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
sigaction(SIGINT, &act, NULL);
*/
sit.btrn = btr_new_node(&(struct btr_node_description)
EMBRACE(.name = "stdin"));
- ret = client_open(argc, argv, &ct, &client_loglevel, sit.btrn, NULL, &sched);
+ ret = client_connect(ct, &sched, sit.btrn, NULL);
if (ret < 0)
goto out;
sot.btrn = btr_new_node(&(struct btr_node_description)
EMBRACE(.name = "stdout", .parent = ct->btrn));
register_task(&sched, &svt);
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;
+ }
+ }
out:
+ if (ret < 0)
+ PARA_ERROR_LOG("%s\n", para_strerror(-ret));
client_close(ct);
- btr_free_node(sit.btrn);
- btr_free_node(sot.btrn);
- if (ret < 0) {
- /* can not use PARA_LOG here because ct is NULL */
- fprintf(stderr, "%s\n", para_strerror(-ret));
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
+ btr_remove_node(&sit.btrn);
+ btr_remove_node(&sot.btrn);
+ return ret < 0? EXIT_FAILURE : EXIT_SUCCESS;
}