blob: 88f636bc6c7c8f57ac4585432853cbc07caf1323 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#ifndef LIBWORLD_NBT_INTERNAL_H_INCLUDED
#define LIBWORLD_NBT_INTERNAL_H_INCLUDED
#include "nbt.h"
#include "nbt/nbtht.internal.h"
typedef struct {
size_t len;
nbt_byte_t *data;
} nbt__byte_array_t;
typedef struct {
size_t len;
nbt_int_t *data;
} nbt__int_array_t;
typedef struct {
size_t len;
nbt_long_t *data;
} nbt__long_array_t;
typedef struct {
size_t len;
char *data;
} nbt__string_t;
typedef struct nbt__compound_tag {
nbt__ht_t *hash;
} nbt__compound_t;
typedef struct nbt__list_tag {
size_t cap, len;
nbt_tag_t **ptags;
} nbt__list_t;
typedef union {
nbt_byte_t nbt_byte;
nbt_short_t nbt_short;
nbt_int_t nbt_int;
nbt_long_t nbt_long;
nbt_float_t nbt_float;
nbt_double_t nbt_double;
nbt__byte_array_t nbt_byte_array;
nbt__string_t nbt_string;
nbt__list_t nbt_list;
nbt__compound_t nbt_compound;
nbt__int_array_t nbt_int_array;
nbt__long_array_t nbt_long_array;
} nbt__any_t;
struct nbt__tag_tag {
size_t ref;
nbt_type_t type;
nbt__any_t value;
};
/* a named tag */
typedef struct {
nbt_tag_t tag;
size_t name_length;
char *name; /* nullable if there is no name (will be written as if the name is empty) */
} nbt__ntag_t;
#define NBT__CHECK_TYPE(_tag, _t, _r, ...) do { \
if (!(_tag) || (_tag)->type != _t) { _r(__VA_ARGS__); } \
} while (0)
/* functions */
void nbt__tag_free(nbt_tag_t *tag);
#endif /* include guard */
|