2 * Copyright (C) 1997-2007 Andre Noll <maan@systemlinux.org>
4 * Licensed under the GPL v2. For licencing details see COPYING.
7 /** \file client.c the client program used to connect to para_server */
12 #include "client.cmdline.h"
21 static struct private_client_data *pcd;
22 static struct stdin_task sit;
23 static struct stdout_task sot;
26 INIT_STDERR_LOGGING(pcd->conf.loglevel_arg);
28 static void client_event_handler(struct task *t)
30 struct private_client_data *p = t->private_data;
32 PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret));
33 if (t->ret != -E_HANDSHAKE_COMPLETE) {
38 if (p->status == CL_SENDING) {
39 stdin_set_defaults(&sit);
40 sit.buf = para_malloc(sit.bufsize),
41 register_task(&sit.task);
43 p->in_loaded = &sit.loaded;
47 stdout_set_defaults(&sot);
49 sot.loaded = &p->loaded;
50 sot.input_eof = &p->eof;
51 register_task(&sot.task);
55 * the client program to connect to para_server
57 * \param argc usual argument count
58 * \param argv usual argument vector
60 * It registers two tasks: The client task that communicates with para_server
61 * and the standard out task that writes any output produced by the client task
64 * \return EXIT_SUCCESS or EXIT_FAILURE
66 * \sa client_open(), stdout.c, stdout.h, para_client(1), para_server(1)
68 int main(int argc, char *argv[])
74 s.default_timeout.tv_sec = 1;
75 s.default_timeout.tv_usec = 0;
76 ret = client_open(argc, argv, &pcd);
77 if (ret < 0) /* can not use PARA_LOG here */
79 pcd->task.event_handler = client_event_handler;
82 PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
84 return ret >= 0? EXIT_SUCCESS: EXIT_FAILURE;