Blame view

nbt.h 1.04 KB
Imanol-Mikel Barba Sabariego authored
1
2
3
4
5
6
7
8
9
#ifndef _NBT_H
#define _NBT_H

#include <stdint.h>
#include <byteswap.h>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include <string.h>
10
11
12
13
14
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <errno.h>
#include <zlib.h>
Imanol-Mikel Barba Sabariego authored
15
16
17
18
19

#ifndef REALLOC_SIZE
#define REALLOC_SIZE 10
#endif
20
21
22
23
24
25
#ifndef GZIP_BUFFER
#define GZIP_BUFFER 4096
#endif

#define GZIP_MAGIC 0x8B1F
Imanol-Mikel Barba Sabariego authored
26
27
28
typedef struct Tag {
    uint8_t type;
    char* name;
29
    uint16_t nameLength;
Imanol-Mikel Barba Sabariego authored
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
    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
};
60
ssize_t loadDB(const char* filename, void** data);
Imanol-Mikel Barba Sabariego authored
61
62
void destroyTag(Tag* t);
unsigned int parseTag(void* addr, Tag* t);
63
size_t composeTag(Tag t, void** data);
Imanol-Mikel Barba Sabariego authored
64
65

#endif