mirror of
https://github.com/thepigeongenerator/mcaselector-lite.git
synced 2025-12-17 06:05:44 +01:00
add nbt_proctag to nbt.h
also changed the `out` parameter from `u8` to `void`, to be more acurrate that it may point to whatever.
This commit is contained in:
@@ -131,12 +131,12 @@ MALLOC static void *nbt_procarr(const u8 *restrict buf, i32 nmem, uint size) {
|
|||||||
|
|
||||||
// TODO: not actually doing anything
|
// TODO: not actually doing anything
|
||||||
/* readies the output data for export, returns the new buffer position, or `NULL` upon an error (may be out of bounds) */
|
/* readies the output data for export, returns the new buffer position, or `NULL` upon an error (may be out of bounds) */
|
||||||
static const u8 *nbt_proctag(const u8 *restrict buf, u8 *restrict out, u16 slen) {
|
const u8 *nbt_proctag(const u8 *restrict buf, u16 slen, void *restrict out) {
|
||||||
const u8 *ptr = buf + 3 + slen;
|
const u8 *ptr = buf + 3 + slen;
|
||||||
|
|
||||||
switch (*buf) {
|
switch (*buf) {
|
||||||
// integral types
|
// integral types
|
||||||
case NBT_I8: *out = *ptr; return ptr + 1;
|
case NBT_I8: *(u8 *)out = *ptr; return ptr + 1;
|
||||||
case NBT_I16: *(u16 *)out = be16toh(*(u16 *)ptr); return ptr + 2;
|
case NBT_I16: *(u16 *)out = be16toh(*(u16 *)ptr); return ptr + 2;
|
||||||
case NBT_I32: // fall through
|
case NBT_I32: // fall through
|
||||||
case NBT_F32: *(u32 *)out = be16toh(*(u32 *)ptr); return ptr + 4;
|
case NBT_F32: *(u32 *)out = be16toh(*(u32 *)ptr); return ptr + 4;
|
||||||
|
|||||||
@@ -54,5 +54,8 @@ struct nbt_procdat {
|
|||||||
* `NULL` is returned upon failure, the otherwise returned pointer is not guaranteed to be valid. */
|
* `NULL` is returned upon failure, the otherwise returned pointer is not guaranteed to be valid. */
|
||||||
const u8 *nbt_nexttag(const u8 *restrict buf) NONNULL((1)) PURE;
|
const u8 *nbt_nexttag(const u8 *restrict buf) NONNULL((1)) PURE;
|
||||||
|
|
||||||
|
/* Processes the tag entered in `buf`, `buf` is assumed */
|
||||||
|
const u8 *nbt_proctag(const u8 *restrict buf, u16 slen, void *restrict out) NONNULL((1, 3));
|
||||||
|
|
||||||
/* initialises a data structure used whilst processing the tags */
|
/* initialises a data structure used whilst processing the tags */
|
||||||
struct nbt_procdat nbt_initproc(struct nbt_path const *restrict pats, uint npats) NONNULL((1)) PURE;
|
struct nbt_procdat nbt_initproc(struct nbt_path const *restrict pats, uint npats) NONNULL((1)) PURE;
|
||||||
|
|||||||
Reference in New Issue
Block a user