*
* (c) 1997--2011 Martin Mares <mj@ucw.cz>
* (c) 2004 Robert Spalek <robert@ucw.cz>
+ * (c) 2014 Pavel Charvat <pchar@ucw.cz>
*
* This software may be freely distributed and used according to the terms
* of the GNU Lesser General Public License.
#define fbmulti_append ucw_fbmulti_append
#define fbmulti_create ucw_fbmulti_create
#define fbmulti_remove ucw_fbmulti_remove
+#define fbnull_open ucw_fbnull_open
+#define fbnull_start ucw_fbnull_start
+#define fbnull_test ucw_fbnull_test
#define fbpar_cf ucw_fbpar_cf
#define fbpar_def ucw_fbpar_def
#define fbpool_end ucw_fbpool_end
* ^ ^ ^ ^
* buffer <= bstop (BE pos) <= bptr (FE pos) <= bufend
*
- * * This schema describes a fastbuf after its initialization or bflush().
+ * * This schema describes a fastbuf after its initialization or @bflush().
* * There is no cached data and we are ready for any read or write operation
* (well, only if the back-end supports it).
* * The interval `[bptr, bufend]` can be used by front-ends
* Raises `ucw.fb.open` if the file does not exist.
**/
struct fastbuf *bopen_file(const char *name, int mode, struct fb_params *params);
-struct fastbuf *bopen_file_try(const char *name, int mode, struct fb_params *params); /** Like bopen_file(), but returns NULL on failure. **/
+struct fastbuf *bopen_file_try(const char *name, int mode, struct fb_params *params); /** Like @bopen_file(), but returns NULL on failure. **/
/**
* Opens a temporary file.
/**
* Initialize a new `fbpool`. The structure is allocated by the caller,
- * so bclose() should not be called and no resource tying takes place.
+ * so @bclose() should not be called and no resource tying takes place.
**/
void fbpool_init(struct fbpool *fb); /** Initialize a new mempool fastbuf. **/
/**
fbatomic_internal_write(b);
}
+/*** === Null fastbufs ***/
+
+/**
+ * Creates a new "/dev/null"-like fastbuf.
+ * Any read attempt returns an EOF, any write attempt is silently ignored.
+ **/
+struct fastbuf *fbnull_open(uns bufsize);
+
+/**
+ * Can be used by any back-end to switch it to the null mode.
+ * You need to provide at least one byte long buffer for writing.
+ **/
+void fbnull_start(struct fastbuf *b, byte *buf, uns bufsize);
+
+/**
+ * Checks whether a fastbuf has been switched to the null mode.
+ **/
+bool fbnull_test(struct fastbuf *b);
+
/***
* === Fastbufs atop other fastbufs [[fbmulti]]
*