summaryrefslogtreecommitdiffstats
path: root/fastwriter.h
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@dside.dyndns.org>2011-12-13 14:57:51 +0100
committerSuren A. Chilingaryan <csa@dside.dyndns.org>2011-12-13 14:57:51 +0100
commita77e7147c1814b4ed19d6abce417c8d8c627cc32 (patch)
tree0827dabe5bea4a5bb26199675e3a4fa52c2905fd /fastwriter.h
downloadfastwriter-a77e7147c1814b4ed19d6abce417c8d8c627cc32.tar.gz
fastwriter-a77e7147c1814b4ed19d6abce417c8d8c627cc32.tar.bz2
fastwriter-a77e7147c1814b4ed19d6abce417c8d8c627cc32.tar.xz
fastwriter-a77e7147c1814b4ed19d6abce417c8d8c627cc32.zip
Initial release
Diffstat (limited to 'fastwriter.h')
-rw-r--r--fastwriter.h44
1 files changed, 44 insertions, 0 deletions
diff --git a/fastwriter.h b/fastwriter.h
new file mode 100644
index 0000000..389b0a9
--- /dev/null
+++ b/fastwriter.h
@@ -0,0 +1,44 @@
+#ifndef _FASTWRITER_H
+#define _FASTWRITER_H
+
+typedef struct fastwrtier_s fastwriter_t;
+
+typedef enum {
+ FASTWRITER_FLAGS_DEFAULT = 0,
+ FASTWRITER_FLAGS_BLOCK = 1, /**< by default the error will be returned if there is no space in the buffer to accomodate the data */
+ FASTWRITER_FLAGS_OVERWRITE = 2 /**< overwrite the data currently in the storage */
+} fastwriter_flags_t;
+
+typedef struct {
+ size_t buffer_size; /**< buffer size in bytes */
+ size_t buffer_used; /**< amount of data currently in the buffer */
+ size_t buffer_max; /**< maximal amount of data in the buffer */
+ size_t commited; /**< total commited data for current file */
+ size_t written; /**< total written data for currrent file */
+} fastwriter_stats_t;
+
+#define FASTWRITER_BUFFER_DEFAULT 0
+#define FASTWRITER_BUFFER_MAX ((size_t)-1)
+
+/*
+ * @fs - defines which writter implementation will be actually used. One can
+ * pass just a file name, then a type of partition will be autodetected.
+ * Otherwise, it is possible to pass the name of storage device. In this
+ * case either RingFS will be used or data will be pushed to the RAW device.
+ */
+fastwriter_t *fastwriter_init(const char *fs, fastwriter_flags_t flags);
+void fastwriter_destroy(fastwriter_t *ctx);
+
+int fastwriter_set_buffer_size(fastwriter_t *ctx, size_t buffer_size);
+int fastwriter_get_stats(fastwriter_t *ctx, fastwriter_stats_t *stats);
+
+int fastwriter_open(fastwriter_t *ctx, const char *name, fastwriter_flags_t flags);
+int fastwriter_close(fastwriter_t *ctx);
+
+int fastwriter_push_chunk(fastwriter_t *ctx, size_t size, const void *buf);
+int fastwriter_commit(fastwriter_t *ctx);
+int fastwriter_cancel(fastwriter_t *ctx);
+
+int fastwriter_push_data(fastwriter_t *ctx, size_t size, const void *buf);
+
+#endif /* _FASTWRITER_H */