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
);
67 * the client program to connect to para_server
69 * \param argc usual argument count
70 * \param argv usual argument vector
72 * It registers two tasks: The client task that communicates with para_server
73 * and the standard out task that writes any output produced by the client task
76 * \return EXIT_SUCCESS or EXIT_FAILURE
78 * \sa client_open(), stdout.c, stdout.h, para_client(1), para_server(1)
80 int main(int argc
, char *argv
[])
86 s
.default_timeout
.tv_sec
= 1;
87 s
.default_timeout
.tv_usec
= 0;
88 ret
= client_open(argc
, argv
, &pcd
);
89 if (ret
< 0) /* can not use PARA_LOG here */
91 pcd
->task
.event_handler
= client_event_handler
;
94 PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret
));
96 return ret
>= 0? EXIT_SUCCESS
: EXIT_FAILURE
;