summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2023-08-08 11:30:11 +0800
committerliuxueli <[email protected]>2023-08-08 11:30:11 +0800
commit2548c8c857d8859f341f955229f2e97ef6f495f9 (patch)
treefa140800c4ac5ef2a21432d31c3273ca923838ee
parent50514b92dde68badbb21066f9fcdd104f53a7a3b (diff)
define utable.h interface
-rw-r--r--sdk/include/utable.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/sdk/include/utable.h b/sdk/include/utable.h
new file mode 100644
index 0000000..38975f7
--- /dev/null
+++ b/sdk/include/utable.h
@@ -0,0 +1,45 @@
+#pragma once
+
+#include <stddef.h>
+
+struct file_chunk
+{
+ uuid_t uuid;
+ size_t offset;
+ const char *chunk;
+ size_t chunk_len;
+};
+
+struct utable;
+struct utable *utable_new(void);
+void utable_free(struct utable *table);
+
+void utable_add_cstring(struct utable *table, const char *key, const char *value);
+void utable_add_blob(struct utable *table, const char *key, const char *blob, size_t blob_sz);
+void utable_add_integer_array(struct utable *table, const char *key, long long value_array[], size_t n_value);
+void utable_delete_item(struct utable *table, const char *key);
+
+enum utable_value_type
+{
+ utable_value_type_undefined=0,
+ utable_value_type_cstring,
+ utable_value_type_blob,
+ utable_value_type_integer_array
+};
+
+void utable_reset_iter(struct utable *table);
+const char *utable_next_key(struct utable *table);
+enum utable_value_type utable_get_value_type(struct utable *table, const char *key);
+int utable_get0_blob_value(struct utable *table, const char *key, char **value, size_t *value_len);
+int utable_get0_cstring_value(struct utable *table, const char *key, char **value, size_t *value_len);
+int utable_get0_integer_value_array(struct utable *table, const char *key, long long **value_array, size_t *n_value);
+
+struct utable *utable_duplicate(struct utable *table);
+int utable_merge(struct utable *dst, struct utable *src);
+
+void utable_serialize(struct utable *table, char **blob, size_t *blob_len);
+struct utable *utable_deserialize(char *bolb, size_t blob_len);
+
+int utable_ipfix_exporter(struct utable *table, char **blob, size_t *blob_len);
+int utable_json_export(struct utable *table, char **blob, size_t *blob_len);
+int utable_msgpack_export(struct utable *table, char **blob, size_t *blob_len); \ No newline at end of file