summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2022-05-08 17:29:38 +0800
committerruki <[email protected]>2022-05-08 17:29:38 +0800
commit4045ac9d0c0e49c04794e2f8a253e81d6d29287c (patch)
tree44c41fbf94263e8faa63c7cb40f7c0002f19bbdc /core/src
parent27cc34ff877909993cc5de57b7ac7cff6a13b771 (diff)
add lz4 modules
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/engine.c19
-rw-r--r--core/src/xmake/lz4/block_compress.c42
-rw-r--r--core/src/xmake/lz4/block_decompress.c43
-rw-r--r--core/src/xmake/lz4/compress.c42
-rw-r--r--core/src/xmake/lz4/decompress.c43
-rw-r--r--core/src/xmake/lz4/prefix.h32
-rw-r--r--core/src/xmake/makefile9
7 files changed, 228 insertions, 2 deletions
diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c
index 1a74387d2..397fa1dcc 100644
--- a/core/src/xmake/engine.c
+++ b/core/src/xmake/engine.c
@@ -189,6 +189,12 @@ tb_int_t xm_hash_md5(lua_State* lua);
tb_int_t xm_base64_encode(lua_State* lua);
tb_int_t xm_base64_decode(lua_State* lua);
+// the lz4 functions
+tb_int_t xm_lz4_compress(lua_State* lua);
+tb_int_t xm_lz4_decompress(lua_State* lua);
+tb_int_t xm_lz4_block_compress(lua_State* lua);
+tb_int_t xm_lz4_block_decompress(lua_State* lua);
+
// the windows functions
#ifdef TB_CONFIG_OS_WINDOWS
tb_int_t xm_winos_cp_info(lua_State* lua);
@@ -403,6 +409,16 @@ static luaL_Reg const g_base64_functions[] =
, { tb_null, tb_null }
};
+// the lz4 functions
+static luaL_Reg const g_lz4_functions[] =
+{
+ { "compress", xm_lz4_compress }
+, { "decompress", xm_lz4_decompress }
+, { "block_compress", xm_lz4_block_compress }
+, { "block_decompress", xm_lz4_block_decompress }
+, { tb_null, tb_null }
+};
+
// the string functions
static luaL_Reg const g_string_functions[] =
{
@@ -948,6 +964,9 @@ xm_engine_ref_t xm_engine_init(tb_char_t const* name, xm_engine_lni_initalizer_c
// bind hash functions
xm_lua_register(engine->lua, "hash", g_hash_functions);
+ // bind lz4 functions
+ xm_lua_register(engine->lua, "lz4", g_lz4_functions);
+
// bind base64 functions
xm_lua_register(engine->lua, "base64", g_base64_functions);
diff --git a/core/src/xmake/lz4/block_compress.c b/core/src/xmake/lz4/block_compress.c
new file mode 100644
index 000000000..4f1e5d4c2
--- /dev/null
+++ b/core/src/xmake/lz4/block_compress.c
@@ -0,0 +1,42 @@
+/*!A cross-platform build utility based on Lua
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2015-present, TBOOX Open Source Group.
+ *
+ * @author ruki
+ * @file block_compress.c
+ *
+ */
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * trace
+ */
+#define TB_TRACE_MODULE_NAME "block_compress"
+#define TB_TRACE_MODULE_DEBUG (0)
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "prefix.h"
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * implementation
+ */
+tb_int_t xm_lz4_block_compress(lua_State* lua)
+{
+ // check
+ tb_assert_and_check_return_val(lua, 0);
+
+ return 0;
+}
diff --git a/core/src/xmake/lz4/block_decompress.c b/core/src/xmake/lz4/block_decompress.c
new file mode 100644
index 000000000..0bbad10ea
--- /dev/null
+++ b/core/src/xmake/lz4/block_decompress.c
@@ -0,0 +1,43 @@
+/*!A cross-platform build utility based on Lua
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2015-present, TBOOX Open Source Group.
+ *
+ * @author ruki
+ * @file block_decompress.c
+ *
+ */
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * trace
+ */
+#define TB_TRACE_MODULE_NAME "block_decompress"
+#define TB_TRACE_MODULE_DEBUG (0)
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "prefix.h"
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * implementation
+ */
+tb_int_t xm_lz4_block_decompress(lua_State* lua)
+{
+ // check
+ tb_assert_and_check_return_val(lua, 0);
+
+ return 0;
+}
+
diff --git a/core/src/xmake/lz4/compress.c b/core/src/xmake/lz4/compress.c
new file mode 100644
index 000000000..0d3f42e86
--- /dev/null
+++ b/core/src/xmake/lz4/compress.c
@@ -0,0 +1,42 @@
+/*!A cross-platform build utility based on Lua
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2015-present, TBOOX Open Source Group.
+ *
+ * @author ruki
+ * @file compress.c
+ *
+ */
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * trace
+ */
+#define TB_TRACE_MODULE_NAME "compress"
+#define TB_TRACE_MODULE_DEBUG (0)
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "prefix.h"
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * implementation
+ */
+tb_int_t xm_lz4_compress(lua_State* lua)
+{
+ // check
+ tb_assert_and_check_return_val(lua, 0);
+
+ return 0;
+}
diff --git a/core/src/xmake/lz4/decompress.c b/core/src/xmake/lz4/decompress.c
new file mode 100644
index 000000000..d18d02f7e
--- /dev/null
+++ b/core/src/xmake/lz4/decompress.c
@@ -0,0 +1,43 @@
+/*!A cross-platform build utility based on Lua
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2015-present, TBOOX Open Source Group.
+ *
+ * @author ruki
+ * @file decompress.c
+ *
+ */
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * trace
+ */
+#define TB_TRACE_MODULE_NAME "decompress"
+#define TB_TRACE_MODULE_DEBUG (0)
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "prefix.h"
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * implementation
+ */
+tb_int_t xm_lz4_decompress(lua_State* lua)
+{
+ // check
+ tb_assert_and_check_return_val(lua, 0);
+
+ return 0;
+}
+
diff --git a/core/src/xmake/lz4/prefix.h b/core/src/xmake/lz4/prefix.h
new file mode 100644
index 000000000..b0a8d06d0
--- /dev/null
+++ b/core/src/xmake/lz4/prefix.h
@@ -0,0 +1,32 @@
+/*!A cross-platform build utility based on Lua
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Copyright (C) 2015-present, TBOOX Open Source Group.
+ *
+ * @author ruki
+ * @file prefix.h
+ *
+ */
+#ifndef XM_LZ4_PREFIX_H
+#define XM_LZ4_PREFIX_H
+
+/* //////////////////////////////////////////////////////////////////////////////////////
+ * includes
+ */
+#include "../prefix.h"
+
+
+#endif
+
+
diff --git a/core/src/xmake/makefile b/core/src/xmake/makefile
index d9e8025fb..9de3fe01b 100644
--- a/core/src/xmake/makefile
+++ b/core/src/xmake/makefile
@@ -133,7 +133,11 @@ xmake_C_FILES += \
libc/byteof \
libc/setbyte \
libc/strndup \
- tty/term_mode
+ tty/term_mode \
+ lz4/compress \
+ lz4/decompress \
+ lz4/block_compress \
+ lz4/block_decompress
iswin =
ifeq ($(PLAT),windows)
@@ -168,7 +172,8 @@ xmake_CXFLAGS += $(if $(findstring curses,$(base_LIBNAMES)),-DXM_CONFIG
xmake_INC_DIRS += \
../tbox/tbox/src \
../tbox/inc/$(PLAT) \
- ../sv/sv/include
+ ../sv/sv/include \
+ ../lz4/lz4/lib
ifeq ($(RUNTIME),luajit)
xmake_INC_DIRS += ../luajit/luajit/src
xmake_CXFLAGS += -DUSE_LUAJIT