tClear up the enums and fix implicit condition-bug - ratox - FIFO based tox client
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit c6ed048ce09050da0c66de0c4b22e05e97774b6d
 (DIR) parent 7171cb2591c5df14b362c45a0ebc6cb166518953
 (HTM) Author: FRIGN <dev@frign.de>
       Date:   Fri, 19 Sep 2014 13:39:51 +0200
       
       Clear up the enums and fix implicit condition-bug
       
       The OUT_F-type was not clear. Make it easier to see the out-file
       has no state (=NONE) and is defined for each slot individually.
       
       Moreover, in the initial creation, the err-file fell through
       just because STATIC = 0 and .outfile wasn't defined for it.
       
       It was only coincidence this worked and now we have a much
       more bulletproof implementation.
       
       Diffstat:
         M ratox.c                             |      17 ++++++++++++-----
       
       1 file changed, 12 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/ratox.c b/ratox.c
       t@@ -60,8 +60,8 @@ enum {
        };
        
        enum {
       +        NONE,
                FIFO,
       -        OUT_F,
                STATIC,
                FOLDER
        };
       t@@ -77,9 +77,9 @@ static struct slot gslots[] = {
        };
        
        static struct file gfiles[] = {
       -        { .type = FIFO,  .name = "in",  .flags = O_RDONLY | O_NONBLOCK,       },
       -        { .type = OUT_F, .name = "out", .flags = O_WRONLY | O_TRUNC | O_CREAT },
       -        { .type = OUT_F, .name = "err", .flags = O_WRONLY | O_TRUNC | O_CREAT },
       +        { .type = FIFO,   .name = "in",  .flags = O_RDONLY | O_NONBLOCK,       },
       +        { .type = NONE,   .name = "out", .flags = O_WRONLY | O_TRUNC | O_CREAT },
       +        { .type = STATIC, .name = "err", .flags = O_WRONLY | O_TRUNC | O_CREAT },
        };
        
        enum {
       t@@ -634,7 +634,14 @@ localinit(void)
                                                exit(EXIT_FAILURE);
                                        }
                                        gslots[i].fd[m] = r;
       -                        } else if (gfiles[m].type == OUT_F) {
       +                        } else if (gfiles[m].type == STATIC) {
       +                                r = openat(gslots[i].dirfd, gfiles[m].name, gfiles[m].flags, 0644);
       +                                if (r < 0) {
       +                                        perror("open");
       +                                        exit(EXIT_FAILURE);
       +                                }
       +                                gslots[i].fd[m] = r;
       +                        } else if (gfiles[m].type == NONE) {
                                        if (gslots[i].outtype == STATIC) {
                                                r = openat(gslots[i].dirfd, gfiles[m].name, gfiles[m].flags, 0644);
                                                if (r < 0) {