-/**
- * The post select hook for client commands.
- *
- * \param s Pointer to the scheduler.
- * \param t Pointer to the task struct for this command.
- *
- * Depending on the current state of the connection and the status of the read
- * and write fd sets of \a s, this function performs the necessary steps to
- * authenticate the connection, to send the command given by \a t->private_data
- * and to receive para_server's output, if any.
+static int send_sb_command(struct client_task *ct)
+{
+ int i;
+ char *command, *p;
+ size_t len = 0;
+ unsigned num_inputs = lls_num_inputs(ct->lpr);
+
+ if (ct->sbc[1])
+ return send_sb(ct, 0, NULL, 0, 0, false);
+
+ for (i = 0; i < num_inputs; i++)
+ len += strlen(lls_input(i, ct->lpr)) + 1;
+ p = command = para_malloc(len);
+ for (i = 0; i < num_inputs; i++) {
+ const char *str = lls_input(i, ct->lpr);
+ strcpy(p, str);
+ p += strlen(str) + 1;
+ }
+ PARA_DEBUG_LOG("--> %s\n", command);
+ return send_sb(ct, 0, command, len, SBD_COMMAND, false);
+}
+
+/*
+ * This function reads or writes to the socket file descriptor which
+ * corresponds to an established connection between the client and the server.
+ * It depends on the current state of the connection and on the readiness of
+ * the socket file descriptor which type of I/O is going to be performed.
+ * Besides the initial handshake and authentication, the function sends the
+ * server command and receives the output from the server, if any.