/alps/fastwriter

To get this branch, use:
bzr branch http://suren.me/webbzr/alps/fastwriter

« back to all changes in this revision

Viewing changes to fastwriter.h

  • Committer: Suren A. Chilingaryan
  • Date: 2011-12-13 13:57:51 UTC
  • Revision ID: csa@dside.dyndns.org-20111213135751-bpzkwwn7ujnkdekc
Initial release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _FASTWRITER_H
 
2
#define _FASTWRITER_H
 
3
 
 
4
typedef struct fastwrtier_s fastwriter_t;
 
5
 
 
6
typedef enum {
 
7
    FASTWRITER_FLAGS_DEFAULT = 0,
 
8
    FASTWRITER_FLAGS_BLOCK = 1,         /**< by default the error will be returned if there is no space in the buffer to accomodate the data */
 
9
    FASTWRITER_FLAGS_OVERWRITE = 2      /**< overwrite the data currently in the storage */
 
10
} fastwriter_flags_t;
 
11
 
 
12
typedef struct {
 
13
    size_t buffer_size;                 /**< buffer size in bytes */
 
14
    size_t buffer_used;                 /**< amount of data currently in the buffer */
 
15
    size_t buffer_max;                  /**< maximal amount of data in the buffer */
 
16
    size_t commited;                    /**< total commited data for current file */
 
17
    size_t written;                     /**< total written data for currrent file */
 
18
} fastwriter_stats_t;
 
19
 
 
20
#define FASTWRITER_BUFFER_DEFAULT       0
 
21
#define FASTWRITER_BUFFER_MAX           ((size_t)-1)
 
22
 
 
23
/*
 
24
 * @fs - defines which writter implementation will be actually used. One can
 
25
 * pass just a file name, then a type of partition will be autodetected.
 
26
 * Otherwise, it is possible to pass the name of storage device. In this 
 
27
 * case either RingFS will be used or data will be pushed to the RAW device.
 
28
 */
 
29
fastwriter_t *fastwriter_init(const char *fs, fastwriter_flags_t flags);
 
30
void fastwriter_destroy(fastwriter_t *ctx);
 
31
 
 
32
int fastwriter_set_buffer_size(fastwriter_t *ctx, size_t buffer_size);
 
33
int fastwriter_get_stats(fastwriter_t *ctx, fastwriter_stats_t *stats);
 
34
 
 
35
int fastwriter_open(fastwriter_t *ctx, const char *name, fastwriter_flags_t flags);
 
36
int fastwriter_close(fastwriter_t *ctx);
 
37
 
 
38
int fastwriter_push_chunk(fastwriter_t *ctx, size_t size, const void *buf);
 
39
int fastwriter_commit(fastwriter_t *ctx);
 
40
int fastwriter_cancel(fastwriter_t *ctx);
 
41
 
 
42
int fastwriter_push_data(fastwriter_t *ctx, size_t size, const void *buf);
 
43
 
 
44
#endif /* _FASTWRITER_H */