2 * Copyright (C) 1997-2006 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
;
40 void para_log(int ll
, const char* fmt
,...)
44 /* ignore log message if loglevel is not high enough */
45 if (pcd
&& ll
< pcd
->conf
.loglevel_arg
)
48 vfprintf(stderr
, fmt
, argp
);
52 static void client_event_handler(struct task
*t
)
54 struct private_client_data
*p
= t
->private_data
;
56 PARA_NOTICE_LOG("%s\n", PARA_STRERROR(-t
->ret
));
57 if (t
->ret
!= -E_HANDSHAKE_COMPLETE
) {
62 if (p
->status
== CL_SENDING
) {
63 stdin_set_defaults(&sit
);
64 sit
.buf
= para_malloc(sit
.bufsize
),
65 register_task(&sit
.task
);
67 p
->in_loaded
= &sit
.loaded
;
71 stdout_set_defaults(&sot
);
73 sot
.loaded
= &p
->loaded
;
74 sot
.input_eof
= &p
->eof
;
75 register_task(&sot
.task
);
81 int main(int argc
, char *argv
[])
87 s
.default_timeout
.tv_sec
= 1;
88 s
.default_timeout
.tv_usec
= 0;
89 ret
= client_parse_config(argc
, argv
, &pcd
);
92 pcd
->task
.event_handler
= client_event_handler
;
93 ret
= client_open(pcd
);
100 PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret
));
101 return ret
>= 0? EXIT_SUCCESS
: EXIT_FAILURE
;