X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Ffb-limfd.c;h=351f0032daa15f710b0d0a45a02ab3ce4a15dbab;hb=3d60a4fe8e95194666956fe7e861101f40571630;hp=c1b6cb2c9bf66b6b96372cadead1b5b210d75584;hpb=30e8b23e52a9ee5b5735d0179dd572656feeaa6b;p=libucw.git diff --git a/lib/fb-limfd.c b/lib/fb-limfd.c index c1b6cb2c..351f0032 100644 --- a/lib/fb-limfd.c +++ b/lib/fb-limfd.c @@ -1,7 +1,7 @@ /* * Sherlock Library -- Fast Buffered Input on Limited File Descriptors * - * (c) 2003 Martin Mares + * (c) 2003--2004 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. @@ -19,15 +19,16 @@ struct fb_limfd { int limit; }; #define FB_LIMFD(f) ((struct fb_limfd *)(f)->is_fastbuf) +#define FB_BUFFER(f) (byte *)(FB_LIMFD(f) + 1) static int bfl_refill(struct fastbuf *f) { + f->bptr = f->buffer = FB_BUFFER(f); int max = MIN(FB_LIMFD(f)->limit - f->pos, f->bufend - f->buffer); int l = read(FB_LIMFD(f)->fd, f->buffer, max); if (l < 0) die("Error reading %s: %m", f->name); - f->bptr = f->buffer; f->bstop = f->buffer + l; f->pos += l; return l; @@ -54,6 +55,7 @@ bopen_limited_fd(int fd, uns buflen, uns limit) F->limit = limit; f->refill = bfl_refill; f->close = bfl_close; + f->can_overwrite_buffer = 2; return f; }