diff options
| author | ruki <[email protected]> | 2025-11-10 06:35:04 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-10 06:35:04 +0800 |
| commit | 2b01e46fcf619aaecb8435b0fac975e3aff0587f (patch) | |
| tree | 8f005a8dfc3272e9f027560e5e1b5881a7a8bc70 /core/src/xmake/base64 | |
| parent | a1b0ec856e2c22aac84022feb05b6687912e3d6e (diff) | |
| parent | 2c387895657ae13cd717d7f42f5baed5eb028a8e (diff) | |
Merge pull request #7008 from xmake-io/format
format code
Diffstat (limited to 'core/src/xmake/base64')
| -rw-r--r-- | core/src/xmake/base64/decode.c | 20 | ||||
| -rw-r--r-- | core/src/xmake/base64/encode.c | 27 | ||||
| -rw-r--r-- | core/src/xmake/base64/prefix.h | 3 |
3 files changed, 21 insertions, 29 deletions
diff --git a/core/src/xmake/base64/decode.c b/core/src/xmake/base64/decode.c index abb9abcbd..cb1b7eb82 100644 --- a/core/src/xmake/base64/decode.c +++ b/core/src/xmake/base64/decode.c @@ -22,8 +22,8 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "base64" -#define TB_TRACE_MODULE_DEBUG (0) +#define TB_TRACE_MODULE_NAME "base64" +#define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -33,24 +33,20 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t xm_base64_decode(lua_State* lua) -{ - // check +tb_int_t xm_base64_decode(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); // get the string - size_t size = 0; - tb_char_t const* cstr = luaL_checklstring(lua, 1, &size); + size_t size = 0; + tb_char_t const *cstr = luaL_checklstring(lua, 1, &size); tb_check_return_val(cstr && size, 0); // decode it tb_byte_t buff[8192]; - if (size < sizeof(buff)) - { + if (size < sizeof(buff)) { tb_size_t real = tb_base64_decode(cstr, size, buff, sizeof(buff)); - if (real > 0) - { - lua_pushlstring(lua, (tb_char_t const*)buff, (tb_int_t)real); + if (real > 0) { + lua_pushlstring(lua, (tb_char_t const *)buff, (tb_int_t)real); return 1; } } diff --git a/core/src/xmake/base64/encode.c b/core/src/xmake/base64/encode.c index b99ee3922..d5ce56306 100644 --- a/core/src/xmake/base64/encode.c +++ b/core/src/xmake/base64/encode.c @@ -22,8 +22,8 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "base64" -#define TB_TRACE_MODULE_DEBUG (0) +#define TB_TRACE_MODULE_NAME "base64" +#define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -33,18 +33,19 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t xm_base64_encode(lua_State* lua) -{ - // check +tb_int_t xm_base64_encode(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); // get data and size tb_size_t size = 0; - tb_byte_t const* data = tb_null; - if (xm_lua_isinteger(lua, 1)) data = (tb_byte_t const*)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1); - if (xm_lua_isinteger(lua, 2)) size = (tb_size_t)lua_tointeger(lua, 2); - if (!data || !size) - { + tb_byte_t const *data = tb_null; + if (xm_lua_isinteger(lua, 1)) { + data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1); + } + if (xm_lua_isinteger(lua, 2)) { + size = (tb_size_t)lua_tointeger(lua, 2); + } + if (!data || !size) { lua_pushnil(lua); lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size); return 2; @@ -53,11 +54,9 @@ tb_int_t xm_base64_encode(lua_State* lua) // encode it tb_char_t buff[8192]; - if (size * 3 / 2 < sizeof(buff)) - { + if (size * 3 / 2 < sizeof(buff)) { tb_size_t real = tb_base64_encode(data, size, buff, sizeof(buff)); - if (real > 0) - { + if (real > 0) { lua_pushlstring(lua, buff, (tb_int_t)real); return 1; } diff --git a/core/src/xmake/base64/prefix.h b/core/src/xmake/base64/prefix.h index a22be8e7c..4e7ba2bf3 100644 --- a/core/src/xmake/base64/prefix.h +++ b/core/src/xmake/base64/prefix.h @@ -26,7 +26,4 @@ */ #include "../prefix.h" - #endif - - |
