aboutsummaryrefslogtreecommitdiff
path: root/lib/mpack
diff options
context:
space:
mode:
Diffstat (limited to 'lib/mpack')
-rw-r--r--lib/mpack/CMakeLists.txt28
-rw-r--r--lib/mpack/makefile4
-rw-r--r--lib/mpack/mpack.h19
-rw-r--r--lib/mpack/read-remaining.c10
m---------lib/mpack/src (renamed from lib/mpack)0
5 files changed, 61 insertions, 0 deletions
diff --git a/lib/mpack/CMakeLists.txt b/lib/mpack/CMakeLists.txt
new file mode 100644
index 0000000..0e4359d
--- /dev/null
+++ b/lib/mpack/CMakeLists.txt
@@ -0,0 +1,28 @@
+if(TARGET mpack)
+ return()
+endif()
+
+cmake_minimum_required(VERSION 3.29)
+
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
+
+project(mpack C)
+
+add_library(mpack STATIC
+ src/src/mpack/mpack-common.c
+ src/src/mpack/mpack-expect.c
+ src/src/mpack/mpack-node.c
+ src/src/mpack/mpack-platform.c
+ src/src/mpack/mpack-reader.c
+ src/src/mpack/mpack-writer.c
+ read-remaining.c
+ )
+target_include_directories(mpack SYSTEM INTERFACE
+ .
+ src/src/mpack
+ )
+
+# causes some wild crashes, please leave off
+add_compile_definitions(MPACK_READ_TRACKING=0)
+
diff --git a/lib/mpack/makefile b/lib/mpack/makefile
new file mode 100644
index 0000000..e96794a
--- /dev/null
+++ b/lib/mpack/makefile
@@ -0,0 +1,4 @@
+TARGET = $(BUILD_DIR)/libmpack.a
+
+include ../../lazy.mk
+
diff --git a/lib/mpack/mpack.h b/lib/mpack/mpack.h
new file mode 100644
index 0000000..7c0c089
--- /dev/null
+++ b/lib/mpack/mpack.h
@@ -0,0 +1,19 @@
+#pragma once
+
+#include "src/src/mpack/mpack.h"
+
+/**
+ * \brief read remaining bytes in reader without opening a tag first
+ *
+ * \param reader pointer to mpack reader object
+ * \param p pointer to write data to
+ * \param count maximum number of bytes to read
+ *
+ * This function reads *up to* the amount of bytes specified in \p count, or
+ * less if there is less remaining data in the buffer. If \p count is equal to
+ * 0, all remaining data in the buffer is read.
+ *
+ * \return amount of bytes read
+ */
+size_t mpack_read_remaining_bytes(mpack_reader_t * reader, char * p, size_t count);
+
diff --git a/lib/mpack/read-remaining.c b/lib/mpack/read-remaining.c
new file mode 100644
index 0000000..ebc9b56
--- /dev/null
+++ b/lib/mpack/read-remaining.c
@@ -0,0 +1,10 @@
+#include "mpack.h"
+
+size_t mpack_read_remaining_bytes(mpack_reader_t * reader, char * p, size_t count) {
+ size_t limit =mpack_reader_remaining(reader, NULL);
+ if (0 < count && count < limit)
+ limit = count;
+ memcpy(p, reader->data, limit);
+ return limit;
+}
+
diff --git a/lib/mpack b/lib/mpack/src
-Subproject 79d3fcd3e04338b06e82d01a62f4aa98c7bad5f
+Subproject 79d3fcd3e04338b06e82d01a62f4aa98c7bad5f