Introduce btr_node_description.
[paraslash.git] / buffer_tree.h
1
2 struct btr_node;
3 struct btr_pool;
4
5 typedef int (*btr_command_handler)(struct btr_node *btrn,
6 const char *command, char **result);
7
8 enum btr_node_type {
9 BTR_NT_ROOT,
10 BTR_NT_INTERNAL,
11 BTR_NT_LEAF,
12 };
13
14 struct btr_node_description {
15 const char *name;
16 struct btr_node *parent;
17 btr_command_handler handler;
18 void *context;
19 };
20
21 size_t btr_pool_size(struct btr_pool *btrp);
22 struct btr_pool *btr_pool_new(const char *name, size_t area_size);
23 void btr_pool_free(struct btr_pool *btrp);
24 size_t btr_pool_get_buffer(struct btr_pool *btrp, char **result);
25 void btr_pool_allocate(struct btr_pool *btrp, size_t size);
26 void btr_add_output_pool(struct btr_pool *btrp, size_t size,
27 struct btr_node *btrn);
28 size_t btr_pool_unused(struct btr_pool *btrp);
29 void btr_copy(const void *src, size_t n, struct btr_pool *btrp,
30 struct btr_node *btrn);
31
32 struct btr_node *btr_new_node(struct btr_node_description *bnd);
33 void btr_remove_node(struct btr_node *btrn);
34 void btr_free_node(struct btr_node *btrn);
35 void btr_add_output(char *buf, size_t size, struct btr_node *btrn);
36 bool btr_no_children(struct btr_node *btrn);
37 size_t btr_bytes_pending(struct btr_node *btrn);
38 size_t btr_get_input_queue_size(struct btr_node *btrn);
39 bool btr_no_parent(struct btr_node *btrn);
40 size_t btr_next_buffer(struct btr_node *btrn, char **bufp);
41 void btr_consume(struct btr_node *btrn, size_t numbytes);
42 int btr_exec(struct btr_node *btrn, const char *command, char **value_result);
43 int btr_exec_up(struct btr_node *btrn, const char *command, char **value_result);
44 void btr_splice_out_node(struct btr_node *btrn);
45 void btr_pushdown(struct btr_node *btrn);
46 void *btr_context(struct btr_node *btrn);
47 void btr_merge(struct btr_node *btrn, size_t dest_size);
48 bool btr_eof(struct btr_node *btrn);
49 void btr_log_tree(struct btr_node *btrn, int loglevel);
50 int btr_pushdown_one(struct btr_node *btrn);
51 bool btr_inplace_ok(struct btr_node *btrn);
52 int btr_node_status(struct btr_node *btrn, size_t min_iqs,
53 enum btr_node_type type);
54 void btr_get_node_start(struct btr_node *btrn, struct timeval *tv);
55 struct btr_node *btr_search_node(const char *name, struct btr_node *root);