my hg working dir managed to break itself somehow... my attempt to fix that, and add some cache code :)
#ifndef CACHE_H
#define CACHE_H
#include <sys/types.h>
/*
* Configuration
*/
#define CACHE_NEST_COUNT 16
#define CACHE_KEY_SIZE 8
struct cache {
struct cache_index {
int fd;
struct cache_index_file *data;
off_t size;
} index;
struct cache_nest {
int fd;
struct cache_nest_header *nest;
off_t size;
struct cache_op *w_op;
} nests[CACHE_NEST_COUNT];
struct cache_op *wop_queue;
struct cache_op *rop_list;
};
// system page size, initialized by cache_open
static long sys_pagesize;
// cache.c
void cache_close (struct cache *ctx);
int cache_open (struct cache *ctx, const char *cache_path);
// cache_index.c
int _cache_index_init (struct cache_index *ctx);
int _cache_index_find (struct cache_index *ctx, const u_int8_t key[CACHE_KEY_SIZE], u_int8_t *nest, u_int32_t *offset, u_int16_t *length);
int _cache_index_insert (struct cache_index *ctx, const u_int8_t key[CACHE_KEY_SIZE], const u_int8_t nest, const u_int32_t offset, const u_int16_t length);
#endif /* CACHE_H */