]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - client_common.c
Pass command via sideband.
[paraslash.git] / client_common.c
index 53f7b5a96e524214798e549d755141a5bb48c3ed..ff351e8902e42fba250345878d60d7d55df1db62 100644 (file)
@@ -245,6 +245,26 @@ static bool has_feature(const char *feature, struct client_task *ct)
        return find_arg(feature, ct->features) >= 0? true : false;
 }
 
+static int send_sb_command(struct client_task *ct)
+{
+       int i;
+       char *command, *p;
+       size_t len = 0;
+
+       if (ct->sbc)
+               return send_sb(ct, NULL, 0, 0, false);
+
+       for (i = 0; i < ct->conf.inputs_num; i++)
+               len += strlen(ct->conf.inputs[i]) + 1;
+       p = command = para_malloc(len);
+       for (i = 0; i < ct->conf.inputs_num; i++) {
+               strcpy(p, ct->conf.inputs[i]);
+               p += strlen(ct->conf.inputs[i]) + 1;
+       }
+       PARA_DEBUG_LOG("--> %s\n", command);
+       return send_sb(ct, command, len, SBD_COMMAND, false);
+}
+
 /**
  * The post select hook for client commands.
  *
@@ -385,6 +405,13 @@ static void client_post_select(struct sched *s, struct task *t)
                char *command = NULL;
                if (!FD_ISSET(ct->scc.fd, &s->wfds))
                        return;
+               if (ct->use_sideband) {
+                       ret = send_sb_command(ct);
+                       if (ret <= 0)
+                               goto out;
+                       ct->status = CL_SENT_COMMAND;
+                       return;
+               }
                for (i = 0; i < ct->conf.inputs_num; i++) {
                        char *tmp = command;
                        command = make_message("%s\n%s", command?