/*
* Sherlock Library -- Fast Buffered I/O
*
- * (c) 1997--2002 Martin Mares <mj@ucw.cz>
+ * (c) 1997--2004 Martin Mares <mj@ucw.cz>
*
* This software may be freely distributed and used according to the terms
* of the GNU Lesser General Public License.
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);
struct fastbuf *bopen_mm(byte *name, uns mode);
+/* FastI on file descriptors with limit */
+
+struct fastbuf *bopen_limited_fd(int fd, uns bufsize, uns limit);
+
+/* FastIO on static buffers */
+
+void fbbuf_init_read(struct fastbuf *f, byte *buffer, uns size);
+void fbbuf_init_write(struct fastbuf *f, byte *buffer, uns size);
+static inline uns
+fbbuf_count_written(struct fastbuf *f)
+{
+ return f->bptr - f->bstop;
+}
+
/* Configuring stream parameters */
int bconfig(struct fastbuf *f, uns type, int data);
void bflush(struct fastbuf *f);
void bseek(struct fastbuf *f, sh_off_t pos, int whence);
void bsetpos(struct fastbuf *f, sh_off_t pos);
+void brewind(struct fastbuf *f);
static inline sh_off_t btell(struct fastbuf *f)
{
}
byte *bgets(struct fastbuf *f, byte *b, uns l); /* Non-std */
+int bgets_nodie(struct fastbuf *f, byte *b, uns l);
byte *bgets0(struct fastbuf *f, byte *b, uns l);
static inline void
/* 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;
}
f->bptr = pos;
}
-static inline int
+static inline uns
bdirect_write_prepare(struct fastbuf *f, byte **buf)
{
if (f->bptr == f->bufend)
f->bptr = pos;
}
+/* Formatted output */
+
+int bprintf(struct fastbuf *b, byte *msg, ...);
+int vbprintf(struct fastbuf *b, byte *msg, va_list args);
+
#endif