Merge branch 'refs/heads/t/com_tasks'
[paraslash.git] / command.c
index 551fe05a66eb4eab694f62f6ac1578ad0992d742..a9f5aa697be2e3f7ab51819898b14afb7d0535c6 100644 (file)
--- a/command.c
+++ b/command.c
@@ -718,7 +718,7 @@ static int com_ff(struct command_context *cc)
                promille += 1000 * i / mmd->afd.afhi.seconds_total;
        if (promille < 0)
                promille = 0;
-       if (promille >  1000) {
+       if (promille > 1000) {
                mmd->new_vss_status_flags |= VSS_NEXT;
                goto out;
        }
@@ -749,8 +749,8 @@ static int com_jmp(struct command_context *cc)
        if (i > 100)
                i = 100;
        PARA_INFO_LOG("jumping to %lu%%\n", i);
-       mmd->repos_request = (mmd->afd.afhi.chunks_total * i + 50)/ 100;
-       PARA_INFO_LOG("sent: %lu,  offset before jmp: %lu\n",
+       mmd->repos_request = (mmd->afd.afhi.chunks_total * i + 50) / 100;
+       PARA_INFO_LOG("sent: %lu, offset before jmp: %lu\n",
                mmd->chunks_sent, mmd->offset);
        mmd->new_vss_status_flags |= VSS_REPOS;
        mmd->new_vss_status_flags &= ~VSS_NEXT;
@@ -761,6 +761,16 @@ out:
        return ret;
 }
 
+static int com_tasks(struct command_context *cc)
+{
+       char *tl = server_get_tasks();
+       int ret = 1;
+
+       if (tl)
+               ret = send_sb(&cc->scc, tl, strlen(tl), SBD_OUTPUT, false);
+       return ret;
+}
+
 /*
  * check if perms are sufficient to exec a command having perms cmd_perms.
  * Returns 0 if perms are sufficient, -E_PERM otherwise.
@@ -865,24 +875,22 @@ out:
  * \param fd The file descriptor to send output to.
  * \param peername Identifies the connecting peer.
  *
- * Whenever para_server accepts an incoming tcp connection on
- * the port it listens on, it forks and the resulting child
- * calls this function.
+ * Whenever para_server accepts an incoming tcp connection on the port it
+ * listens on, it forks and the resulting child calls this function.
  *
- * An RSA-based challenge/response is used to authenticate
- * the peer. It that authentication succeeds, a random
- * session key is generated and sent back to the peer,
- * encrypted with its RSA public key.  From this point on,
- * all transfers are crypted with this session key.
+ * An RSA-based challenge/response is used to authenticate the peer. It that
+ * authentication succeeds, a random session key is generated and sent back to
+ * the peer, encrypted with its RSA public key. From this point on, all
+ * transfers are crypted with this session key.
  *
- * Next it is checked if the peer supplied  a valid server command or a command
- * for the audio file selector.  If yes, and if the user has sufficient
+ * Next it is checked if the peer supplied a valid server command or a command
+ * for the audio file selector. If yes, and if the user has sufficient
  * permissions to execute that command, the function calls the corresponding
  * command handler which does argument checking and further processing.
  *
- * In order to cope with a DOS attacks, a timeout is set up
- * which terminates the function if the connection was not
- * authenticated when the timeout expires.
+ * In order to cope with a DOS attacks, a timeout is set up which terminates
+ * the function if the connection was not authenticated when the timeout
+ * expires.
  *
  * \sa alarm(2), crypt.c, crypt.h
  */
@@ -905,7 +913,7 @@ __noreturn void handle_connect(int fd, const char *peername)
                goto net_err;
        /* send Welcome message */
        ret = write_va_buffer(fd, "This is para_server, version "
-               PACKAGE_VERSION  ".\n"
+               PACKAGE_VERSION ".\n"
                "Features: sideband,aes_ctr128\n"
        );
        if (ret < 0)