bzr branch
http://darksoft.org/webbzr/alps/fastwriter
1
by Suren A. Chilingaryan
Initial release |
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 |
||
2
by Suren A. Chilingaryan
Just push instead push_chunk |
38 |
int fastwriter_push(fastwriter_t *ctx, size_t size, const void *buf); |
1
by Suren A. Chilingaryan
Initial release |
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 */ |