-
Notifications
You must be signed in to change notification settings - Fork 1
/
GuNBT.c
86 lines (72 loc) · 1.88 KB
/
GuNBT.c
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
79
80
81
82
83
84
85
86
#include "GuNBT.h"
#include <errno.h>
char * gnbt_read_name(unsigned char * stream)
{
int length = *stream;
char *name;
return name;
}
gnbt_node * gnbt_read_node(unsigned char * stream)
{
gnbt_node * node = malloc(sizeof(gnbt_node));
node->type = *++stream;
node->name = (node->type != gnbt_type_end) ? gnbt_readname(stream) : "END";
switch (node->type)
{
case gnbt_type_end:
return node;
case gnbt_type_byte:
node->data->tag_byte = *++stream;
break;
case gnbt_type_short:
node->data->tag_short = *stream;
stream += 2;
break;
case gnbt_type_int:
node->data->tag_int = *stream;
stream += 4;
break;
case gnbt_type_long:
node->data->tag_long = *stream;
stream += 8;
break;
case gnbt_type_float:
node->data->tag_float = *stream;
stream += 4;
break;
case gnbt_type_double:
node->data->tag_double = *stream;
stream += 8;
break;
case gnbt_type_byte_array:
stream += gnbt_read_byte_array(node, stream);
break;
case gnbt_type_string:
stream += gnbt_read_string(node, stream);
break;
case gnbt_type_list:
stream += gnbt_read_list(node, stream);
break;
case gnbt_type_short:
stream += gnbt_read_int_array(node, stream);
break;
}
return node;
}
void gnbt_parse_file(FILE * fp)
{
unsigned char * stream = 0;
gnbt_node * tree = gnbt_readnode(stream);
}
void gnbt_save_tree(nbt_node * tree, const char * path)
{
}
void gnbt_free(nbt_node)
{
}
gnbt_node * nbt_find_by_name(nbt_node * tree, const char * name)
{
}
gnbt_node * nbt_add_to_compound(nbt_node * tree, nbt_node * node)
{
}