]> mj.ucw.cz Git - libucw.git/blobdiff - lib/fastbuf.c
written parsing config files and command line parameters, untested yet
[libucw.git] / lib / fastbuf.c
index 1a5544fb59b4ed918bd3ce72d1ada4827e83f49a..1a1457844a1f9b46fb8b037972ee6b27c52a24d6 100644 (file)
@@ -4,17 +4,17 @@
  *     (c) 1997--2000 Martin Mares <mj@ucw.cz>
  */
 
+#include "lib/lib.h"
+#include "lib/fastbuf.h"
+
 #include <stdio.h>
 #include <stdlib.h>
 
-#include "lib.h"
-#include "fastbuf.h"
-
 void bclose(struct fastbuf *f)
 {
   bflush(f);
   f->close(f);
-  free(f);
+  xfree(f);
 }
 
 void bflush(struct fastbuf *f)
@@ -184,8 +184,9 @@ void bput5_slow(struct fastbuf *f, u64 o)
 #endif
 }
 
-void bread_slow(struct fastbuf *f, void *b, uns l)
+uns bread_slow(struct fastbuf *f, void *b, uns l)
 {
+  uns total = 0;
   while (l)
     {
       uns k = f->bstop - f->bptr;
@@ -195,7 +196,7 @@ void bread_slow(struct fastbuf *f, void *b, uns l)
          f->refill(f);
          k = f->bstop - f->bptr;
          if (!k)
-           die("bread on %s: file exhausted", f->name);
+           break;
        }
       if (k > l)
        k = l;
@@ -203,7 +204,9 @@ void bread_slow(struct fastbuf *f, void *b, uns l)
       f->bptr += k;
       b = (byte *)b + k;
       l -= k;
+      total += k;
     }
+  return total;
 }
 
 void bwrite_slow(struct fastbuf *f, void *b, uns l)