Fix using blind-from-name without command - blind - suckless command-line video editing utility
 (HTM) git clone git://git.suckless.org/blind
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 86beb51a66bf680a212584e72d70eff74fe559b9
 (DIR) parent f70ffc7f6e6331a56be4a52882c432133e40bd01
 (HTM) Author: Mattias Andrée <maandree@kth.se>
       Date:   Sat, 22 Jul 2017 17:47:08 +0200
       
       Fix using blind-from-name without command
       
       Signed-off-by: Mattias Andrée <maandree@kth.se>
       
       Diffstat:
         M TODO                                |       2 --
         M src/blind-from-named.c              |      45 +++++--------------------------
       
       2 files changed, 7 insertions(+), 40 deletions(-)
       ---
 (DIR) diff --git a/TODO b/TODO
       @@ -1,5 +1,3 @@
       -Fix blind-from-named without command
       -
        blind-transform                affine transformation by matrix multiplication, -[xy] for tiling, -s for
                                        improve quality on downscaling (pixels' neighbours must not change)
        blind-primary-key        replace a primary with transparency, -g for greyscaled images
 (DIR) diff --git a/src/blind-from-named.c b/src/blind-from-named.c
       @@ -39,42 +39,16 @@ erecv_fd(int sock)
                return fd;
        }
        
       -#if !defined(HAVE_SENDFILE)
       -static ssize_t
       -sendfile(int outfd, int infd, off_t *offset, size_t count)
       -{
       -        char buf[PIPE_BUF];
       -        ssize_t r, w, p, ret = 0;
       -
       -        (void) offset;
       -        (void) count;
       -
       -        for (;;) {
       -                r = read(infd, buf, sizeof(buf));
       -                if (r < 0)
       -                        eprintf("read <received file>:");
       -                if (!r)
       -                        break;
       -                ret += r;
       -                for (p = 0; p < r; p += w) {
       -                        w = write(outfd, buf + p, (size_t)(r - p));
       -                        if (w < 0)
       -                                eprintf("write <stdout>:");
       -                }
       -        }
       -
       -        return ret;
       -}
       -#endif
       -
        int
        main(int argc, char *argv[])
        {
       +        char buf[BUFSIZ];
                struct sockaddr_un addr;
                int abstract = 0;
                int filedes = -1;
                int tries = 11;
                int sockfd, fd;
       +        ssize_t n;
        
                ARGBEGIN {
                case 'a':
       @@ -133,14 +107,9 @@ retry:
                        eprintf("execvp %s:", argv[0]);
                }
        
       -        for (;;) {
       -                switch (sendfile(STDOUT_FILENO, fd, NULL, SIZE_MAX)) {
       -                case 0:
       -                        return 0;
       -                case -1:
       -                        eprintf("sendfile <stdout> <received file>:");
       -                default:
       -                        break;
       -                }
       -        }
       +        while ((n = read(fd, buf, sizeof(buf))) > 0)
       +                ewriteall(STDOUT_FILENO, buf, (size_t)n, "<stdout>");
       +        if (n < 0)
       +                eprintf("read <received file>:");
       +        return 0;
        }