libclod
C library for interacting with NBTs, region files, LOD data and other things.
Loading...
Searching...
No Matches
format.h
1#ifndef LIBCLOD_FORMAT_H
2#define LIBCLOD_FORMAT_H
3
5#include <../../include/clod/data_structures/table.h>
6#include "bitarray.h"
7#include <stdint.h>
8
9#define LIBCLOD_MAGIC \
10 "\n\n"\
11 "libclod extended region file format version 1.\n"\
12 "See github.com/stewi1014/clod for format details.\n"\
13 "\n\n"
14
15constexpr size_t MAGIC_LEN = sizeof(LIBCLOD_MAGIC);
16constexpr size_t HEADER_SIZE = 20480u;
17
18struct clod_rfmt {
19 struct clod_rfmt_opts opts;
20
21 uint8_t *data;
22 size_t data_size;
23
24#ifndef NDEBUG
25 bool file_locked;
26 bitarray(1024) held_locks;
27 bitarray(1024) observing_locks;
28#endif
29};
30
31enum clod_rfmt_result chunk_lock_acquire(struct clod_rfmt *rfmt, unsigned chunk_index);
32enum clod_rfmt_result chunk_lock_refresh(struct clod_rfmt *rfmt, unsigned chunk_index);
33enum clod_rfmt_result chunk_lock_release(struct clod_rfmt *rfmt, unsigned chunk_index);
34
35enum clod_rfmt_result global_lock_acquire(struct clod_rfmt *rfmt);
36enum clod_rfmt_result global_lock_refresh(struct clod_rfmt *rfmt);
37enum clod_rfmt_result global_lock_release(struct clod_rfmt *rfmt);
38
39enum clod_rfmt_result resize_lock_acquire(struct clod_rfmt *rfmt, size_t *old_size, size_t grow_size);
40enum clod_rfmt_result resize_lock_release(struct clod_rfmt *rfmt);
41
42#endif
clod_rfmt_result