2 * Copyright (C) 1997-2009 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 */
10 #include <openssl/rc4.h>
16 #include "client.cmdline.h"
25 static struct client_task *ct;
26 static struct stdin_task sit;
27 static struct stdout_task sot;
29 static void supervisor_post_select(__a_unused struct sched *s, struct task *t)
31 if (ct->task.error < 0) {
32 t->error = ct->task.error;
35 if (ct->status == CL_SENDING) {
36 stdin_set_defaults(&sit);
37 sit.buf = para_malloc(sit.bufsize),
38 register_task(&sit.task);
40 ct->in_loaded = &sit.loaded;
41 ct->in_error = &sit.task.error;
42 t->error = -E_TASK_STARTED;
45 if (ct->status == CL_RECEIVING) {
46 stdout_set_defaults(&sot);
48 sot.loaded = &ct->loaded;
49 sot.input_error = &ct->task.error;
50 register_task(&sot.task);
51 t->error = -E_TASK_STARTED;
56 static struct task svt = {
57 .post_select = supervisor_post_select,
58 .status = "supervisor task"
61 static int client_loglevel; /* loglevel */
62 INIT_STDERR_LOGGING(client_loglevel);
66 * The client program to connect to para_server.
68 * \param argc Usual argument count.
69 * \param argv Usual argument vector.
71 * It registers two tasks: The client task that communicates with para_server
72 * and the standard out task that writes any output produced by the client task
75 * \return EXIT_SUCCESS or EXIT_FAILURE
77 * \sa client_open(), stdout.c, stdout.h, para_client(1), para_server(1)
79 int main(int argc, char *argv[])
83 static struct sched s;
85 init_random_seed_or_die();
86 s.default_timeout.tv_sec = 1;
87 s.default_timeout.tv_usec = 0;
88 ret = client_open(argc, argv, &ct, &client_loglevel);
89 if (ret < 0) /* can not use PARA_LOG here because ct is NULL */
94 PARA_ERROR_LOG("%s\n", para_strerror(-ret));
96 return ret >= 0? EXIT_SUCCESS: EXIT_FAILURE;