2 * Copyright (C) 1997-2007 Andre Noll <maan@systemlinux.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
19 /** \file client.c the client program used to connect to para_server */
24 #include "client.cmdline.h"
33 static struct private_client_data *pcd;
34 static struct stdin_task sit;
35 static struct stdout_task sot;
38 INIT_STDERR_LOGGING(pcd->conf.loglevel_arg);
40 static void client_event_handler(struct task *t)
42 struct private_client_data *p = t->private_data;
44 PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t->ret));
45 if (t->ret != -E_HANDSHAKE_COMPLETE) {
50 if (p->status == CL_SENDING) {
51 stdin_set_defaults(&sit);
52 sit.buf = para_malloc(sit.bufsize),
53 register_task(&sit.task);
55 p->in_loaded = &sit.loaded;
59 stdout_set_defaults(&sot);
61 sot.loaded = &p->loaded;
62 sot.input_eof = &p->eof;
63 register_task(&sot.task);
69 int main(int argc, char *argv[])
75 s.default_timeout.tv_sec = 1;
76 s.default_timeout.tv_usec = 0;
77 ret = client_parse_config(argc, argv, &pcd);
80 pcd->task.event_handler = client_event_handler;
81 ret = client_open(pcd);
88 PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
89 return ret >= 0? EXIT_SUCCESS: EXIT_FAILURE;