summaryrefslogtreecommitdiff
path: root/robot/bin.h
diff options
context:
space:
mode:
Diffstat (limited to 'robot/bin.h')
-rw-r--r--robot/bin.h39
1 files changed, 33 insertions, 6 deletions
diff --git a/robot/bin.h b/robot/bin.h
index ccde132..1c9b951 100644
--- a/robot/bin.h
+++ b/robot/bin.h
@@ -1,19 +1,46 @@
#pragma once
+/**
+ * helper file for binary data
+ *
+ * - fix endianness with functions inspired by UNIX arpa/inet.h
+ * - convert uint16_t and uint32_t to w2_s_bin
+ */
#include <stdint.h>
+extern uint8_t g_w2_endianness;
+
+#define W2_T_UINT8_T (0)
+#define W2_T_UINT16_T (1)
+#define W2_T_UINT32_T (2)
+
+enum w2_e_struct_types {
+ W2_ST_UINT8_T,
+ W2_ST_UINT16_T,
+ W2_ST_UINT32_T,
+};
+
+extern const uint8_t W2_STRUCT_T_SIZES[];
+
typedef struct {
uint16_t bytes;
uint8_t data[];
} w2_s_bin;
-extern uint8_t g_w2_endianness;
+typedef struct {
+ enum w2_e_struct_types type;
+ uint16_t length;
+ const uint8_t *data;
+} w2_s_struct_property;
-/**
- * helper file for binary data
- *
- * - fix endianness with functions inspired by UNIX arpa/inet.h
- */
+typedef struct {
+ uint16_t length;
+ w2_s_struct_property *properties[];
+} w2_s_property_list;
+
+w2_s_bin *w2_bin_from_uint8_t(uint8_t data);
+w2_s_bin *w2_bin_from_uint16_t(uint16_t data);
+w2_s_bin *w2_bin_from_uint32_t(uint32_t data);
/** convert 32-bit value from host endian to network (big-endian) */
uint32_t w2_bin_hton32(uint32_t h32);