summaryrefslogtreecommitdiff
path: root/src/tag.h
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2023-12-14 18:08:16 -0500
committerFreya Murphy <freya@freyacat.org>2023-12-14 18:08:16 -0500
commit00c88659104ce423959151ff6f3f96f6537a6d68 (patch)
treec2745a95c2b7f15f69f8bfcaa85e0b12626f6142 /src/tag.h
downloadnbtvis-00c88659104ce423959151ff6f3f96f6537a6d68.tar.gz
nbtvis-00c88659104ce423959151ff6f3f96f6537a6d68.tar.bz2
nbtvis-00c88659104ce423959151ff6f3f96f6537a6d68.zip
testing
Diffstat (limited to 'src/tag.h')
-rw-r--r--src/tag.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/tag.h b/src/tag.h
new file mode 100644
index 0000000..7fd0b4e
--- /dev/null
+++ b/src/tag.h
@@ -0,0 +1,73 @@
+#pragma once
+
+#include "stream.h"
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <arpa/inet.h>
+#include <string.h>
+#include <unistd.h>
+
+typedef enum: int8_t {
+ TAG_END = 0,
+ TAG_BYTE = 1,
+ TAG_SHORT = 2,
+ TAG_INT = 3,
+ TAG_LONG = 4,
+ TAG_FLOAT = 5,
+ TAG_DOUBLE = 6,
+ TAG_BYTE_ARRAY = 7,
+ TAG_STRING = 8,
+ TAG_LIST = 9,
+ TAG_COMPOUND = 10,
+ TAG_INT_ARRAY = 11,
+ TAG_LONG_ARRAY = 12
+} tagtype_t ;
+
+struct tag_t;
+
+typedef union {
+ int8_t b;
+ int16_t s;
+ int32_t i;
+ int64_t l;
+ float f;
+ double d;
+ struct {
+ int32_t size;
+ int8_t *data;
+ } b_arr;
+ struct {
+ uint16_t size;
+ char *data;
+ } string;
+ struct {
+ tagtype_t type;
+ int32_t size;
+ struct tag_t *tags;
+ } list;
+ struct {
+ int32_t size;
+ struct tag_t *tags;
+ } compound;
+ struct {
+ int32_t size;
+ int32_t *data;
+ } i_arr;
+ struct {
+ int32_t size;
+ int64_t *data;
+ } l_arr;
+} tagdata_t;
+
+typedef struct tag_t {
+ tagtype_t type;
+ tagdata_t data;
+ uint16_t name_len;
+ char *name;
+} tag_t;
+
+bool tag_read_header(tag_t *tag, stream_t *stream, bool named);
+bool tag_read_data(tag_t *tag, stream_t *stream);
+bool tag_read(tag_t *tag, stream_t *stream, bool named);
+