diff options
author | Alex Auvolat <alex@adnab.me> | 2017-04-21 14:57:53 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2017-04-21 14:57:53 +0200 |
commit | ec08d0410730a16836eb40f5e46082b3bbaf45f6 (patch) | |
tree | 1191271926f1fe42049b974f4bd9bdf56a2945bb /src/syslua | |
parent | 59ecab36f634a00cc6e2c4194bf2d5ebc4ec70eb (diff) | |
download | kogata-ec08d0410730a16836eb40f5e46082b3bbaf45f6.tar.gz kogata-ec08d0410730a16836eb40f5e46082b3bbaf45f6.zip |
include lua_cmsgpack and implement select binding
Diffstat (limited to 'src/syslua')
-rw-r--r-- | src/syslua/lx/lxinit.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/syslua/lx/lxinit.lua b/src/syslua/lx/lxinit.lua index 1c8d116..055ffc9 100644 --- a/src/syslua/lx/lxinit.lua +++ b/src/syslua/lx/lxinit.lua @@ -38,3 +38,27 @@ function string.split(str, sep) str:gsub(pattern, function(c) fields[#fields+1] = c end) return fields end + +function hexdump(str) + for i = 1, #str, 16 do + local b = {string.byte(str, i, math.min(i+15, #str))} + local s = "" + for j = 1, 16 do + if b[j] then + s = s .. string.format("%02x ", b[j]) + else + s = s .. ' ' + end + end + s = s .. '| ' + for j = 1, #b do + ss = string.char(b[j]) + if b[j] >= 32 and b[j] < 128 then + s = s .. string.char(b[j]) + else + s = s .. '.' + end + end + print(s) + end +end |