X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Ffastbuf.h;h=af6787aeaf5cc29a2f3e28856c0aa0cf18d85fab;hb=b6a5054473b03660664647866d41601431e83b07;hp=800794c7ae5669790d5d98eb94468196a38c3892;hpb=cad27e97e6370f96903d42aaf345c099af0a03bd;p=libucw.git diff --git a/lib/fastbuf.h b/lib/fastbuf.h index 800794c7..af6787ae 100644 --- a/lib/fastbuf.h +++ b/lib/fastbuf.h @@ -81,6 +81,7 @@ struct fastbuf { /* FastIO on standard files (specify buffer size 0 to enable mmaping) */ struct fastbuf *bopen(byte *name, uns mode, uns buflen); +struct fastbuf *bopen_try(byte *name, uns mode, uns buflen); struct fastbuf *bopen_tmp(uns buflen); struct fastbuf *bfdopen(int fd, uns buflen); struct fastbuf *bfdopen_shared(int fd, uns buflen); @@ -109,6 +110,12 @@ fbbuf_count_written(struct fastbuf *f) return f->bptr - f->bstop; } +/* FastIO on recyclable growing buffers */ + +struct fastbuf *fbgrow_create(unsigned basic_size); +void fbgrow_reset(struct fastbuf *b); /* Reset stream and prepare for writing */ +void fbgrow_rewind(struct fastbuf *b); /* Prepare for reading */ + /* Configuring stream parameters */ int bconfig(struct fastbuf *f, uns type, int data); @@ -373,7 +380,10 @@ static inline uns bdirect_read_prepare(struct fastbuf *f, byte **buf) { if (f->bptr == f->bstop && !f->refill(f)) - return 0; + { + *buf = NULL; // This is not needed, but it helps to get rid of spurious warnings + return 0; + } *buf = f->bptr; return bavailr(f); } @@ -408,7 +418,7 @@ bdirect_write_commit(struct fastbuf *f, byte *pos) /* Formatted output */ -int bprintf(struct fastbuf *b, byte *msg, ...); -int vbprintf(struct fastbuf *b, byte *msg, va_list args); +int bprintf(struct fastbuf *b, char *msg, ...) FORMAT_CHECK(printf,2,3); +int vbprintf(struct fastbuf *b, char *msg, va_list args); #endif