2025-02-23 20:52:59 +00:00
|
|
|
#ifndef CHUNK_TABLE_H_
|
|
|
|
|
#define CHUNK_TABLE_H_
|
|
|
|
|
|
2025-02-27 15:49:42 +00:00
|
|
|
#include "b-tree.h"
|
2025-02-23 20:52:59 +00:00
|
|
|
#include "bin.h"
|
|
|
|
|
|
|
|
|
|
#include <blue/core/btree.h>
|
|
|
|
|
#include <blue/core/hash.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2025-02-24 15:55:26 +00:00
|
|
|
struct ec3_tag_ioctx;
|
2025-02-23 20:52:59 +00:00
|
|
|
|
|
|
|
|
struct chunk_table {
|
2025-02-27 15:49:42 +00:00
|
|
|
struct b_tree tab_chunks;
|
2025-02-24 15:55:26 +00:00
|
|
|
enum ec3_cluster_size tab_cluster_size;
|
2025-02-23 20:52:59 +00:00
|
|
|
b_btree tab_cache;
|
|
|
|
|
|
2025-02-27 15:49:42 +00:00
|
|
|
unsigned char *tab_cluster_buf;
|
2025-03-01 19:27:54 +00:00
|
|
|
size_t tab_cluster_buf_pos;
|
2025-02-27 15:49:42 +00:00
|
|
|
|
|
|
|
|
size_t tab_next_cdat_cluster;
|
|
|
|
|
|
2025-02-24 15:55:26 +00:00
|
|
|
struct ec3_tag_ioctx *tab_ctab;
|
|
|
|
|
struct ec3_tag_ioctx *tab_cdat;
|
2025-03-01 19:27:54 +00:00
|
|
|
|
|
|
|
|
b_hash_ctx tab_hash;
|
|
|
|
|
size_t tab_first_chunk_cdat_cluster;
|
2025-02-23 20:52:59 +00:00
|
|
|
};
|
|
|
|
|
|
2025-02-24 15:55:26 +00:00
|
|
|
extern enum ec3_status chunk_table_init(
|
|
|
|
|
struct ec3_tag_ioctx *ctab,
|
|
|
|
|
struct ec3_tag_ioctx *cdat,
|
|
|
|
|
enum ec3_cluster_size cluster_size,
|
2025-02-23 20:52:59 +00:00
|
|
|
struct chunk_table *tab);
|
2025-02-27 15:49:42 +00:00
|
|
|
extern void chunk_table_init_empty_table(struct chunk_table *table);
|
2025-02-23 20:52:59 +00:00
|
|
|
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);
|
|
|
|
|
|
2025-03-01 19:27:54 +00:00
|
|
|
extern enum ec3_status chunk_table_begin_chunk(struct chunk_table *tab);
|
2025-02-23 20:52:59 +00:00
|
|
|
extern enum ec3_status chunk_table_put(
|
|
|
|
|
struct chunk_table *tab,
|
|
|
|
|
const void *data,
|
2025-03-01 19:27:54 +00:00
|
|
|
size_t len);
|
|
|
|
|
extern enum ec3_status chunk_table_end_chunk(
|
|
|
|
|
struct chunk_table *tab,
|
|
|
|
|
ec3_chunk_id out_chunk_id);
|
2025-02-23 20:52:59 +00:00
|
|
|
|
|
|
|
|
extern size_t chunk_table_bytes_per_chunk(struct chunk_table *tab);
|
|
|
|
|
|
2025-03-01 19:27:54 +00:00
|
|
|
extern void ec3_chunk_id_to_string(
|
|
|
|
|
const ec3_chunk_id id,
|
|
|
|
|
char *out,
|
|
|
|
|
size_t max);
|
|
|
|
|
|
2025-02-23 20:52:59 +00:00
|
|
|
#endif
|