nbt.h
1.01 KB
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
#ifndef _NBT_H
#define _NBT_H
#include <stdint.h>
#include <byteswap.h>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#include <zlib.h>
#ifndef REALLOC_SIZE
#define REALLOC_SIZE 10
#endif
#ifndef GZIP_BUFFER
#define GZIP_BUFFER 4096
#endif
#define GZIP_MAGIC 0x8B1F
typedef struct Tag {
uint8_t type;
char* name;
unsigned int nameLength;
unsigned int payloadLength;
void* payload;
} Tag;
typedef struct TagList {
uint8_t type;
uint32_t size;
Tag* list;
} TagList;
typedef struct TagCompound {
unsigned int numTags;
Tag* list;
} TagCompound;
enum TAG {
TAG_END = 0,
TAG_BYTE,
TAG_SHORT,
TAG_INT,
TAG_LONG,
TAG_FLOAT,
TAG_DOUBLE,
TAG_BYTEARRAY,
TAG_STRING,
TAG_LIST,
TAG_COMPOUND,
TAG_INTARRAY
};
ssize_t loadDB(const char* filename, void** data);
void destroyTag(Tag* t);
unsigned int parseTag(void* addr, Tag* t);
#endif