X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Ffastbuf.h;h=f1f0239ae8dac3177855a5919502d287e823353f;hb=7e769f8c4092b9538a497f0846a9165759b1fee2;hp=c62ed4cd470cf2af754ce50b46ee398cfbffb2a3;hpb=82434b9e8d257be287b88a4f0d4e6f4a993106e2;p=libucw.git diff --git a/lib/fastbuf.h b/lib/fastbuf.h index c62ed4cd..f1f0239a 100644 --- a/lib/fastbuf.h +++ b/lib/fastbuf.h @@ -4,6 +4,9 @@ * (c) 1997--2000 Martin Mares */ +#ifndef _SHERLOCK_FASTBUF_H +#define _SHERLOCK_FASTBUF_H + #ifndef EOF #include #endif @@ -264,16 +267,17 @@ static inline void bput5(struct fastbuf *f, u64 l) bput5_slow(f, l); } -void bread_slow(struct fastbuf *f, void *b, uns l); -static inline void bread(struct fastbuf *f, void *b, uns l) +uns bread_slow(struct fastbuf *f, void *b, uns l); +static inline uns bread(struct fastbuf *f, void *b, uns l) { if (f->bptr + l <= f->bstop) { memcpy(b, f->bptr, l); f->bptr += l; + return l; } else - bread_slow(f, b, l); + return bread_slow(f, b, l); } void bwrite_slow(struct fastbuf *f, void *b, uns l); @@ -303,6 +307,12 @@ bputsn(struct fastbuf *f, byte *b) bputc(f, '\n'); } +/* Direct I/O on buffers */ + +int bdirect_read(struct fastbuf *f, byte **buf); +int bdirect_write_prepare(struct fastbuf *f, byte **buf); +void bdirect_write_commit(struct fastbuf *f, byte *pos); + /* Depending on compile-time configuration, we select the right function for reading/writing of file offsets */ #ifdef SHERLOCK_CONFIG_LARGE_DB @@ -316,3 +326,5 @@ bputsn(struct fastbuf *f, byte *b) #define bgetp(f) bgetl(f) #define bputp(f,l) bputl(f,l) #endif + +#endif