(wrong string) ée

From: <git_AT_suckless.org>
Date: Sat, 22 Jul 2017 17:48:18 +0200 (CEST)

commit 86beb51a66bf680a212584e72d70eff74fe559b9
Author: Mattias Andrée <maandree_AT_kth.se>
AuthorDate: Sat Jul 22 17:47:08 2017 +0200
Commit: Mattias Andrée <maandree_AT_kth.se>
CommitDate: Sat Jul 22 17:47:08 2017 +0200

    Fix using blind-from-name without command
    
    Signed-off-by: Mattias Andrée <maandree_AT_kth.se>

diff --git a/TODO b/TODO
index d5cbb56..4d35da5 100644
--- a/TODO
+++ b/TODO
_AT_@ -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
diff --git a/src/blind-from-named.c b/src/blind-from-named.c
index b1fc3b8..8290bc5 100644
--- a/src/blind-from-named.c
+++ b/src/blind-from-named.c
_AT_@ -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':
_AT_@ -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;
 }
Received on Sat Jul 22 2017 - 17:48:18 CEST

This archive was generated by hypermail 2.3.0 : Sat Jul 22 2017 - 17:48:53 CEST