2 * Copyright (C) 1997-2008 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 client_task
*ct
;
22 static struct stdin_task sit
;
23 static struct stdout_task sot
;
25 static void supervisor_post_select(__a_unused
struct sched
*s
, struct task
*t
)
27 if (ct
->task
.error
< 0) {
28 t
->error
= ct
->task
.error
;
31 if (ct
->status
== CL_SENDING
) {
32 stdin_set_defaults(&sit
);
33 sit
.buf
= para_malloc(sit
.bufsize
),
34 register_task(&sit
.task
);
36 ct
->in_loaded
= &sit
.loaded
;
37 ct
->in_error
= &sit
.task
.error
;
38 t
->error
= -E_TASK_STARTED
;
41 if (ct
->status
== CL_RECEIVING
) {
42 stdout_set_defaults(&sot
);
44 sot
.loaded
= &ct
->loaded
;
45 sot
.input_error
= &ct
->task
.error
;
46 register_task(&sot
.task
);
47 t
->error
= -E_TASK_STARTED
;
52 static struct task svt
= {
53 .post_select
= supervisor_post_select
,
54 .status
= "supervisor task"
57 INIT_STDERR_LOGGING(ct
->conf
.loglevel_arg
);
61 * The client program to connect to para_server.
63 * \param argc Usual argument count.
64 * \param argv Usual argument vector.
66 * It registers two tasks: The client task that communicates with para_server
67 * and the standard out task that writes any output produced by the client task
70 * \return EXIT_SUCCESS or EXIT_FAILURE
72 * \sa client_open(), stdout.c, stdout.h, para_client(1), para_server(1)
74 int main(int argc
, char *argv
[])
78 static struct sched s
;
80 s
.default_timeout
.tv_sec
= 1;
81 s
.default_timeout
.tv_usec
= 0;
82 ret
= client_open(argc
, argv
, &ct
);
83 if (ret
< 0) /* can not use PARA_LOG here */
88 PARA_ERROR_LOG("%s\n", para_strerror(-ret
));
90 return ret
>= 0? EXIT_SUCCESS
: EXIT_FAILURE
;