+#define HANDSHAKE_BUFSIZE 4096
+
+static int parse_sb_command(struct command_context *cc, struct iovec *iov)
+{
+ int ret, i;
+ char *p, *end;
+
+ ret = -E_BAD_CMD;
+ if (iov->iov_base == NULL || iov->iov_len == 0)
+ goto out;
+ p = iov->iov_base;
+ p[iov->iov_len - 1] = '\0'; /* just to be sure */
+ cc->cmd = get_cmd_ptr(p, NULL);
+ if (!cc->cmd)
+ goto out;
+ ret = check_perms(cc->u->perms, cc->cmd);
+ if (ret < 0)
+ goto out;
+ end = iov->iov_base + iov->iov_len;
+ for (i = 0, p = iov->iov_base; p < end; i++)
+ p += strlen(p) + 1;
+ cc->argc = i;
+ cc->argv = para_malloc((cc->argc + 1) * sizeof(char *));
+ for (i = 0, p = iov->iov_base; p < end; i++) {
+ cc->argv[i] = para_strdup(p);
+ p += strlen(p) + 1;
+ }
+ cc->argv[cc->argc] = NULL;
+ ret = cc->argc;
+out:
+ free(iov->iov_base);
+ return ret;
+}
+