Rename hed_blockoff_t -> hed_cursor_t
[hed.git] / libhed / private.h
blob203eebcfc506e012ccd6e8f7fe50c0cee8407ce8
1 #ifndef LIBHED__PRIVATE_H
2 #define LIBHED__PRIVATE_H
4 #include "file.h"
5 #include "access.h"
6 #include "tree.h"
8 #define file_block hed_file_block
9 #define file hed_file
10 #define blockoff_t hed_cursor_t
12 #define null_block(tree) (tree_entry(null_node(tree),struct file_block,t))
14 #define first_block(tree) (tree_entry(first_in_tree(tree),struct file_block,t))
15 #define prev_block(b) (tree_entry(prev_in_tree(&(b)->t),struct file_block,t))
16 #define next_block(b) (tree_entry(next_in_tree(&(b)->t),struct file_block,t))
17 #define last_block(tree) (tree_entry(last_in_tree(tree),struct file_block,t))
19 /* false if this is not a block - out of list bounds */
20 #define is_a_block(tree,b) (&(b)->t != null_node(tree))
22 #define block_offset(tree,b) tree_block_offset((tree), &(b)->t)
24 #define recalc_node_recursive(tree,b) recalc_node_recursive((tree),&(b)->t)
26 #define chain_block(tree,b) append_to_tree((tree), &(b)->t)
27 #define recalc_chain_block(tree,b) do { \
28 chain_block((tree), (b)); \
29 recalc_node_recursive((tree), (b)); \
30 } while (0)
32 #define chain_block_after(tree,p,b) insert_into_tree((tree), &(b)->t, &(p)->t)
34 #define recalc_chain_block_after(tree,p,b) do { \
35 chain_block_after((tree), (p), (b)); \
36 recalc_node_recursive((tree), (b)); \
37 } while (0)
39 #define unchain_block(tree,b) del_from_tree((tree), &(b)->t)
40 #define recalc_unchain_block(tree,b) recalc_del_from_tree((tree), &(b)->t)
42 #define init_block_list(tree) init_tree(tree)
43 #define init_block_link(b) init_node(&(b)->t)
45 #define foreach_block(b,tree) foreach_in_tree ((b),(tree),struct file_block,t)
46 #define foreachsafe_block(b,n,tree) foreachsafe_in_tree ((b),(n),(tree),struct file_block,t)
48 #define find_block(tree,o) tree_entry(find_in_tree((tree),(o)),struct file_block,t)
50 /* Number of blocks in cache */
51 #define CACHE_LENGTH 64
53 /* Blocks for readahead */
54 #define FILE_READAHEAD (CACHE_LENGTH/2)
56 #endif /* LIBHED__PRIVATE_H */