]> mj.ucw.cz Git - libucw.git/blobdiff - lib/fastbuf.h
WT_LINK added into WORD_TYPES_META
[libucw.git] / lib / fastbuf.h
index 5ee23d48c88c556e0e25bb7ab1c20d9a1880b48d..a370c45be8995155190b5eb61079812a685178e4 100644 (file)
@@ -15,6 +15,7 @@
 #endif
 
 #include <string.h>
+#include <stdarg.h>
 
 #include "lib/unaligned.h"
 
@@ -65,7 +66,7 @@ struct fastbuf {
   int (*config)(struct fastbuf *, uns, int);   /* Configure the stream */
 };
 
-/* FastIO on standard files */
+/* FastIO on standard files (specify buffer size 0 to enable mmaping) */
 
 struct fastbuf *bopen(byte *name, uns mode, uns buffer);
 struct fastbuf *bopen_tmp(uns buffer);
@@ -315,11 +316,11 @@ bbcopy(struct fastbuf *f, struct fastbuf *t, uns l)
 
 /* Direct I/O on buffers */
 
-static inline int
+static inline uns
 bdirect_read_prepare(struct fastbuf *f, byte **buf)
 {
   if (f->bptr == f->bstop && !f->refill(f))
-    return EOF;
+    return 0;
   *buf = f->bptr;
   return f->bstop - f->bptr;
 }
@@ -330,7 +331,7 @@ bdirect_read_commit(struct fastbuf *f, byte *pos)
   f->bptr = pos;
 }
 
-static inline int
+static inline uns
 bdirect_write_prepare(struct fastbuf *f, byte **buf)
 {
   if (f->bptr == f->bufend)
@@ -345,4 +346,9 @@ bdirect_write_commit(struct fastbuf *f, byte *pos)
   f->bptr = pos;
 }
 
+/* Formatted output */
+
+int bprintf(struct fastbuf *b, byte *msg, ...);
+int vbprintf(struct fastbuf *b, byte *msg, va_list args);
+
 #endif