|
libclod
C library for interacting with NBTs, region files, LOD data and other things.
|
Classes | |
| struct | clod_region_opts |
Enumerations | |
| enum | clod_region_result { CLOD_REGION_OK = 0 , CLOD_REGION_INVALID_USAGE = 1 , CLOD_REGION_MALFORMED = 2 , CLOD_REGION_NOT_FOUND = 3 } |
Functions | |
| struct clod_region * | clod_region_open (const char *path, const struct clod_region_opts *opts) |
| enum clod_region_result | clod_region_read (struct clod_region *region, const int64_t *pos, uint8_t *buff, size_t buff_size, size_t *size) |
| enum clod_region_result | clod_region_write (struct clod_region *region, const int64_t *pos, const uint8_t *buff, size_t buff_size) |
| enum clod_region_result | clod_region_mtime (struct clod_region *region, const int64_t *pos, time_t *mtime) |
| struct clod_region_iter * | clod_region_iter_start (struct clod_region *region) |
| bool | clod_region_iter_next (struct clod_region_iter *iter, int64_t *pos) |
| void | clod_region_iter_end (struct clod_region_iter *iter) |
| enum clod_region_result | clod_region_close (struct clod_region *region) |
Open modes | |
| #define | CLOD_REGION_MODE_RDONLY 1 |
| #define | CLOD_REGION_MODE_RDWR 2 |
Limits | |
| #define | CLOD_REGION_PREFIX_MAX 30 |
| #define | CLOD_REGION_EXTENSION_MAX 10 |
| #define | CLOD_REGION_DIMENSIONS_MAX 10 |
region.h defines the public interface libclod exposes for interacting with a gentrified and extended version of the minecraft region file format that retains compatibility with minecraft.
https://minecraft.wiki/w/Region_file_format
Thanks to ishland for his insights while brainstorming approaches to this.
| enum clod_region_result |
Result of a call to a libregion library method. It's designed to allow programs to respond to error states and does not intend to represent debug information. The library currently uses stderr for debug information and user-relevant messages (i.e. permission denied). I do realise that might not be ideal for some cases, so I've tried to leave space to add support for a custom logger if such a thing becomes wanted.
| struct clod_region * clod_region_open | ( | const char * | path, |
| const struct clod_region_opts * | opts ) |
Open a directory for region storage.
| path | Path to the directory. |
| opts | Configuration options. |
Definition at line 8 of file region_open.c.
| enum clod_region_result clod_region_read | ( | struct clod_region * | region, |
| const int64_t * | pos, | ||
| uint8_t * | buff, | ||
| size_t | buff_size, | ||
| size_t * | size ) |
Read chunk data.
| [in] | Region Storage | Region handle. |
| [in] | pos | Chunk position. |
| [in] | buff | The buffer where data is written to. |
| [in] | buff_size | Size of dst. |
| [out] | size | Actual size of the chunk data. |
| CLOD_REGION_OK | On success. |
| CLOD_REGION_INVALID_USAGE | On invalid usage. |
| CLOD_REGION_MALFORMED | Chunk data is corrupted. |
| CLOD_REGION_NOT_FOUND | Chunk does not exist. |
Definition at line 6 of file region_read.c.
| enum clod_region_result clod_region_write | ( | struct clod_region * | region, |
| const int64_t * | pos, | ||
| const uint8_t * | buff, | ||
| size_t | buff_size ) |
Write chunk data or delete a chunk. Delete a chunk by passing a null buffer.
| [in] | Region Storage | Region handle. |
| [in] | pos | Chunk position. |
| [in] | buff | Buffer containing chunk data to write. |
| [in] | buff_size | Size of the chunk data to write. |
| CLOD_REGION_OK | On success. |
| CLOD_REGION_INVALID_USAGE | On invalid usage. |
| CLOD_REGION_MALFORMED | Chunk data is corrupted. |
| enum clod_region_result clod_region_mtime | ( | struct clod_region * | region, |
| const int64_t * | pos, | ||
| time_t * | mtime ) |
Get the last modification time of the chunk.
| [in] | Region Storage | Region handle. |
| [in] | pos | Chunk position. |
| [out] | mtime | Last modification time. |
| CLOD_REGION_OK | On success. |
| CLOD_REGION_INVALID_USAGE | On invalid usage. |
| CLOD_REGION_MALFORMED | Chunk data is corrupted. |
| CLOD_REGION_NOT_FOUND | Chunk does not exist. |
| struct clod_region_iter * clod_region_iter_start | ( | struct clod_region * | region | ) |
Start iterating over chunks.
| [in] | Region Storage | Region handle. |
| bool clod_region_iter_next | ( | struct clod_region_iter * | iter, |
| int64_t * | pos ) |
Get the next position when iterating over chunks. This method is thread-safe and always returns a unique position.
| [in] | iter | Iterator. |
| [out] | pos | Next chunk position. |
| void clod_region_iter_end | ( | struct clod_region_iter * | iter | ) |
Release resources associated with an iterator. This method is not thread safe.
| [in] | iter | The iterator to free. |
| enum clod_region_result clod_region_close | ( | struct clod_region * | region | ) |
Release resources associated with the region handle.
| [in] | Region Storage | The handle to free. |
Definition at line 31 of file region_open.c.