X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Ffb-file.c;h=5394730b93fe3d4cadd559dee251b183baeea03c;hb=5de81f1debc4341fb3af4e756b0a18e196d5ba13;hp=cc5cf22cba1aa951290339c4205326d482589612;hpb=903e6530eaa344851bf0aa6a9f270c205aa97300;p=libucw.git diff --git a/ucw/fb-file.c b/ucw/fb-file.c index cc5cf22c..5394730b 100644 --- a/ucw/fb-file.c +++ b/ucw/fb-file.c @@ -8,9 +8,9 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/fastbuf.h" -#include "ucw/lfs.h" +#include +#include +#include #include #include @@ -25,7 +25,7 @@ struct fb_file { ucw_off_t wpos; /* Real file position */ uns wlen; /* Window size */ }; -#define FB_FILE(f) ((struct fb_file *)(f)->is_fastbuf) +#define FB_FILE(f) ((struct fb_file *)(f)) #define FB_BUFFER(f) (byte *)(FB_FILE(f) + 1) static int @@ -56,7 +56,7 @@ long_seek: int l = read(F->fd, f->buffer, MIN(skip, blen)); if (unlikely(l <= 0)) if (l < 0) - bthrow(f, "fb.read", "Error reading %s: %m", f->name); + bthrow(f, "read", "Error reading %s: %m", f->name); else { F->wpos -= skip; @@ -114,14 +114,14 @@ seek: /* Do lseek() */ F->wpos = f->pos + (f->buffer - f->bptr); if (ucw_seek(F->fd, F->wpos, SEEK_SET) < 0) - bthrow(f, "fb.read", "Error seeking %s: %m", f->name); + bthrow(f, "read", "Error seeking %s: %m", f->name); } /* Read (part of) buffer */ do { int l = read(F->fd, read_ptr, read_len); if (unlikely(l < 0)) - bthrow(f, "fb.read", "Error reading %s: %m", f->name); + bthrow(f, "read", "Error reading %s: %m", f->name); if (!l) if (unlikely(read_ptr < f->bptr)) goto eof; @@ -149,7 +149,7 @@ bfd_spout(struct fastbuf *f) { /* Do delayed lseek() if needed */ if (FB_FILE(f)->wpos != f->pos && ucw_seek(FB_FILE(f)->fd, f->pos, SEEK_SET) < 0) - bthrow(f, "fb.write", "Error seeking %s: %m", f->name); + bthrow(f, "write", "Error seeking %s: %m", f->name); int l = f->bptr - f->buffer; byte *c = f->buffer; @@ -161,7 +161,7 @@ bfd_spout(struct fastbuf *f) { int z = write(FB_FILE(f)->fd, c, l); if (z <= 0) - bthrow(f, "fb.write", "Error writing %s: %m", f->name); + bthrow(f, "write", "Error writing %s: %m", f->name); l -= z; c += z; } @@ -181,7 +181,7 @@ bfd_seek(struct fastbuf *f, ucw_off_t pos, int whence) case SEEK_END: ; ucw_off_t l = ucw_seek(FB_FILE(f)->fd, pos, SEEK_END); if (l < 0) - bthrow(f, "fb.seek", "Error seeking %s: %m", f->name); + bthrow(f, "seek", "Error seeking %s: %m", f->name); FB_FILE(f)->wpos = f->pos = l; FB_FILE(f)->wlen = 0; return 1; @@ -238,7 +238,7 @@ bfdopen_internal(int fd, const char *name, uns buflen) f->close = bfd_close; f->config = bfd_config; f->can_overwrite_buffer = 2; - return fb_tie(f); + return f; } void