63 lines
1.2 KiB
C
63 lines
1.2 KiB
C
|
|
#ifndef CHUNK_TABLE_H_
|
||
|
|
#define CHUNK_TABLE_H_
|
||
|
|
|
||
|
|
#include "bin.h"
|
||
|
|
|
||
|
|
#include <blue/core/btree.h>
|
||
|
|
#include <blue/core/hash.h>
|
||
|
|
#include <stdio.h>
|
||
|
|
|
||
|
|
struct ec3_tag_reader;
|
||
|
|
struct ec3_tag_writer;
|
||
|
|
|
||
|
|
enum chunk_table_mode {
|
||
|
|
CHUNK_TABLE_READ,
|
||
|
|
CHUNK_TABLE_WRITE,
|
||
|
|
};
|
||
|
|
|
||
|
|
struct chunk_table {
|
||
|
|
enum chunk_table_mode tab_mode;
|
||
|
|
unsigned int tab_cluster_size;
|
||
|
|
b_btree tab_cache;
|
||
|
|
|
||
|
|
union {
|
||
|
|
struct {
|
||
|
|
struct ec3_tag_reader *ctab;
|
||
|
|
struct ec3_tag_reader *cdat;
|
||
|
|
} tab_read;
|
||
|
|
|
||
|
|
struct {
|
||
|
|
struct ec3_tag_writer *ctab;
|
||
|
|
struct ec3_tag_writer *cdat;
|
||
|
|
} tab_write;
|
||
|
|
};
|
||
|
|
};
|
||
|
|
|
||
|
|
extern enum ec3_status chunk_table_init_read(
|
||
|
|
struct ec3_tag_reader *ctab,
|
||
|
|
struct ec3_tag_reader *cdat,
|
||
|
|
size_t cluster_size,
|
||
|
|
struct chunk_table *tab);
|
||
|
|
extern enum ec3_status chunk_table_init_write(
|
||
|
|
struct ec3_tag_writer *ctab,
|
||
|
|
struct ec3_tag_writer *cdat,
|
||
|
|
size_t cluster_size,
|
||
|
|
struct chunk_table *tab);
|
||
|
|
extern void chunk_table_finish(struct chunk_table *tab);
|
||
|
|
|
||
|
|
extern enum ec3_status chunk_table_get(
|
||
|
|
struct chunk_table *tab,
|
||
|
|
ec3_chunk_id id,
|
||
|
|
void *out_data,
|
||
|
|
size_t *out_len);
|
||
|
|
|
||
|
|
extern enum ec3_status chunk_table_put(
|
||
|
|
struct chunk_table *tab,
|
||
|
|
const void *data,
|
||
|
|
size_t len,
|
||
|
|
ec3_chunk_id out_id);
|
||
|
|
|
||
|
|
extern size_t chunk_table_bytes_per_chunk(struct chunk_table *tab);
|
||
|
|
|
||
|
|
#endif
|