tRemember to ftruncate() before dprintf() - ratox - FIFO based tox client
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 07a2a6732b43465144ee35255e9590b98d377286
 (DIR) parent 92e3bc3c3beee18adae630557ab5d9bc6fe20555
 (HTM) Author: sin <sin@2f30.org>
       Date:   Wed, 17 Sep 2014 17:04:44 +0100
       
       Remember to ftruncate() before dprintf()
       
       Diffstat:
         M ratatox.c                           |       6 ++++++
       
       1 file changed, 6 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/ratatox.c b/ratatox.c
       t@@ -633,6 +633,7 @@ localinit(void)
                if (r > sizeof(name) - 1)
                        r = sizeof(name) - 1;
                name[r] = '\0';
       +        ftruncate(gslots[NAME].fd[OUT], 0);
                dprintf(gslots[NAME].fd[OUT], "%s\n", name);
        
                /* Dump status message */
       t@@ -641,6 +642,7 @@ localinit(void)
                if (r > sizeof(statusmsg) - 1)
                        r = sizeof(statusmsg) - 1;
                statusmsg[r] = '\0';
       +        ftruncate(gslots[STATUS].fd[OUT], 0);
                dprintf(gslots[STATUS].fd[OUT], "%s\n", name);
        
                /* Dump ID */
       t@@ -927,6 +929,7 @@ again:
                tox_set_name(tox, name, r);
                datasave();
                printout("Changed name to %s\n", name);
       +        ftruncate(gslots[NAME].fd[OUT], 0);
                dprintf(gslots[NAME].fd[OUT], "%s\n", name);
        }
        
       t@@ -952,6 +955,7 @@ again:
                tox_set_status_message(tox, statusmsg, r);
                datasave();
                printout("Changed status message to %s\n", statusmsg);
       +        ftruncate(gslots[STATUS].fd[OUT], 0);
                dprintf(gslots[STATUS].fd[OUT], "%s\n", statusmsg);
        }
        
       t@@ -989,6 +993,8 @@ again:
                str2id(buf, id);
        
                r = tox_add_friend(tox, id, buf, strlen(buf));
       +        if (r < 0)
       +                ftruncate(gslots[REQUEST].fd[ERR], 0);
                switch (r) {
                case TOX_FAERR_TOOLONG:
                        dprintf(gslots[REQUEST].fd[ERR], "Message is too long\n");