lua 5.1/5.2/5.3/5.4 supports
This commit is contained in:
parent
dc64c27abd
commit
4b7172766c
|
|
@ -1,4 +1,4 @@
|
||||||
LuaVersion = 5.4
|
LuaVersion ?= 5.4
|
||||||
LIB_DIR = /usr/local/share/lua/$(LuaVersion)
|
LIB_DIR = /usr/local/share/lua/$(LuaVersion)
|
||||||
|
|
||||||
all: ../c/xdb_api.h ../c/xdb_util.c ../c/xdb_searcher.c xdb_searcher.c
|
all: ../c/xdb_api.h ../c/xdb_util.c ../c/xdb_searcher.c xdb_searcher.c
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,26 @@
|
||||||
# ip2region xdb lua c 扩展查询客户端实现
|
# ip2region xdb lua c 扩展查询客户端实现
|
||||||
|
|
||||||
|
# 版本兼容
|
||||||
|
该实现兼容 lua `5.1`,`5.2`,`5.3`, `5.4`
|
||||||
|
|
||||||
# 编译安装
|
# 编译安装
|
||||||
|
|
||||||
通过如下方式来编译安装该扩展:
|
### 默认编译
|
||||||
|
通过如下方式来编译安装默认的 `Lua5.4` 版本的扩展:
|
||||||
```bash
|
```bash
|
||||||
# cd 到 lua_c binding 的根目录
|
# cd 到 lua_c binding 的根目录
|
||||||
make
|
make
|
||||||
sudo make install
|
sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
备注:Makefile 里面的 `LuaVersion` 变量代表你本地环境的 lua 的版本,默认为 5.4,如果你的版本不是 5.4,记得先修改为和你本地 lua 版本一致的版本号。
|
### 指定 Lua 版本
|
||||||
|
通过如下的 `LuaVersion` 参数指定 Lua 版本编译,例如:`5.1` / `5.2` / `5.3` / `5.4`
|
||||||
|
```bash
|
||||||
|
# cd 到 lua_c binding 的根目录
|
||||||
|
# 例如,编译 5.1 版本兼容的扩展
|
||||||
|
make LuaVersion=5.1
|
||||||
|
sudo make install
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
# 使用方式
|
# 使用方式
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
-- @Date 2022/06/30
|
-- @Date 2022/06/30
|
||||||
|
|
||||||
-- set the package to load the current xdb_searcher.so
|
-- set the package to load the current xdb_searcher.so
|
||||||
package.path = "./?.lua" .. package.path
|
package.path = "./?.lua;" .. package.path
|
||||||
package.cpath = "./?.so" .. package.cpath
|
package.cpath = "./?.so;" .. package.cpath
|
||||||
local xdb = require("xdb_searcher")
|
local xdb = require("xdb_searcher")
|
||||||
|
|
||||||
function printHelp()
|
function printHelp()
|
||||||
|
|
@ -29,31 +29,26 @@ local dbFile, srcFile = "", ""
|
||||||
local cachePolicy = "vectorIndex"
|
local cachePolicy = "vectorIndex"
|
||||||
for _, r in ipairs(arg) do
|
for _, r in ipairs(arg) do
|
||||||
if string.len(r) < 5 then
|
if string.len(r) < 5 then
|
||||||
goto continue
|
-- continue and do nothing here
|
||||||
end
|
elseif string.sub(r, 1, 2) ~= "--" then
|
||||||
|
-- continue and do nothing here
|
||||||
|
else
|
||||||
|
for k, v in string.gmatch(string.sub(r, 3), "([^=]+)=([^%s]+)") do
|
||||||
|
if k == "db" then
|
||||||
|
dbFile = v
|
||||||
|
elseif k == "src" then
|
||||||
|
srcFile = v
|
||||||
|
elseif k == "cache-policy" then
|
||||||
|
cachePolicy = v
|
||||||
|
else
|
||||||
|
print(string.format("undefined option `%s`", r))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if string.sub(r, 1, 2) ~= "--" then
|
-- break the match iterate
|
||||||
goto continue
|
break
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in string.gmatch(string.sub(r, 3), "([^=]+)=([^%s]+)") do
|
|
||||||
if k == "db" then
|
|
||||||
dbFile = v
|
|
||||||
elseif k == "src" then
|
|
||||||
srcFile = v
|
|
||||||
elseif k == "cache-policy" then
|
|
||||||
cachePolicy = v
|
|
||||||
else
|
|
||||||
print(string.format("undefined option `%s`", r))
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- break the match iterate
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- continue this loop
|
|
||||||
::continue::
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- print(string.format("dbFile=%s, srcFile=%s, cachePolicy=%s", dbFile, srcFile, cachePolicy))
|
-- print(string.format("dbFile=%s, srcFile=%s, cachePolicy=%s", dbFile, srcFile, cachePolicy))
|
||||||
|
|
@ -126,59 +121,58 @@ if handle == nil then
|
||||||
end
|
end
|
||||||
|
|
||||||
local lines = handle:lines()
|
local lines = handle:lines()
|
||||||
local sip_str, eip_str, s_region, region = "", "", "", ""
|
local sip_str, eip_str, s_region, region, err = "", "", "", "", 0
|
||||||
local sip, mip, eip, err = 0, 0, 0, 0
|
|
||||||
local count, t_time, c_time = 0, 0, 0
|
local count, t_time, c_time = 0, 0, 0
|
||||||
local s_time = xdb.now()
|
local s_time = xdb.now()
|
||||||
for l in lines do
|
for l in lines do
|
||||||
if string.len(l) < 1 then
|
if string.len(l) < 1 then
|
||||||
goto continue
|
-- continue and do nothing here
|
||||||
end
|
else
|
||||||
|
for v1, v2, v3 in string.gmatch(l, "([^|]+)|([^|]+)|([^\n]+)") do
|
||||||
|
-- print(sip_str, eip_str, region)
|
||||||
|
sip_str = v1
|
||||||
|
eip_str = v2
|
||||||
|
s_region = v3
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
for v1, v2, v3 in string.gmatch(l, "([^|]+)|([^|]+)|([^\n]+)") do
|
|
||||||
-- print(sip_str, eip_str, region)
|
|
||||||
sip_str = v1
|
|
||||||
eip_str = v2
|
|
||||||
s_region = v3
|
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
sip_bytes, err = xdb.parse_ip(sip_str)
|
|
||||||
if err ~= nil then
|
|
||||||
print(string.format("invalid start ip `%s`", sip_str))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
eip_bytes, err = xdb.parse_ip(eip_str)
|
|
||||||
if err ~= nil then
|
|
||||||
print(string.format("invalid end ip `%s`", sip_str))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
if xdb.ip_compare(sip_bytes, eip_bytes) > 0 then
|
|
||||||
print(string.format("start ip(%s) should not be greater than end ip(%s)\n", sip_str, eip_str))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
for _, ip_bytes in ipairs({sip_bytes, eip_bytes}) do
|
|
||||||
t_time = xdb.now()
|
t_time = xdb.now()
|
||||||
region, err = searcher:search(ip_bytes)
|
sip_bytes, err = xdb.parse_ip(sip_str)
|
||||||
c_time = c_time + xdb.now() - t_time
|
|
||||||
if err ~= nil then
|
if err ~= nil then
|
||||||
print(string.format("failed to search ip `%s`", xdb.ip_to_string(ip_bytes)))
|
print(string.format("invalid start ip `%s`", sip_str))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check the region
|
eip_bytes, err = xdb.parse_ip(eip_str)
|
||||||
if region ~= s_region then
|
if err ~= nil then
|
||||||
print(string.format("failed search(%s) with (%s != %s)\n", xdb.ip_to_string(ip_bytes), region, s_region))
|
print(string.format("invalid end ip `%s`", sip_str))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
count = count + 1
|
if xdb.ip_compare(sip_bytes, eip_bytes) > 0 then
|
||||||
|
print(string.format("start ip(%s) should not be greater than end ip(%s)\n", sip_str, eip_str))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, ip_bytes in ipairs({sip_bytes, eip_bytes}) do
|
||||||
|
region, err = searcher:search(ip_bytes)
|
||||||
|
if err ~= nil then
|
||||||
|
print(string.format("failed to search ip `%s`", xdb.ip_to_string(ip_bytes)))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
-- check the region
|
||||||
|
if region ~= s_region then
|
||||||
|
print(string.format("failed search(%s) with (%s != %s)\n", xdb.ip_to_string(ip_bytes), region, s_region))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
count = count + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
-- increase the time costs
|
||||||
|
c_time = c_time + xdb.now() - t_time
|
||||||
end
|
end
|
||||||
|
|
||||||
::continue::
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- resource cleanup
|
-- resource cleanup
|
||||||
|
|
@ -190,7 +184,7 @@ if content ~= nil then
|
||||||
content:close()
|
content:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
xdb.cleanup();
|
xdb.cleanup()
|
||||||
|
|
||||||
-- print the stats
|
-- print the stats
|
||||||
local avg_costs = 0
|
local avg_costs = 0
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
-- @Date 2022/06/30
|
-- @Date 2022/06/30
|
||||||
|
|
||||||
-- set the package to load the current xdb_searcher.so
|
-- set the package to load the current xdb_searcher.so
|
||||||
package.path = "./?.lua" .. package.path
|
package.path = "./?.lua;" .. package.path
|
||||||
package.cpath = "./?.so" .. package.cpath
|
package.cpath = "./?.so;" .. package.cpath
|
||||||
local xdb = require("xdb_searcher")
|
local xdb = require("xdb_searcher")
|
||||||
|
|
||||||
function printHelp()
|
function printHelp()
|
||||||
|
|
@ -28,29 +28,24 @@ local dbFile = ""
|
||||||
local cachePolicy = "vectorIndex"
|
local cachePolicy = "vectorIndex"
|
||||||
for _, r in ipairs(arg) do
|
for _, r in ipairs(arg) do
|
||||||
if string.len(r) < 5 then
|
if string.len(r) < 5 then
|
||||||
goto continue
|
-- continue and do nothing here
|
||||||
end
|
elseif string.sub(r, 1, 2) ~= "--" then
|
||||||
|
-- continue and do nothing here
|
||||||
|
else
|
||||||
|
for k, v in string.gmatch(string.sub(r, 3), "([^=]+)=([^%s]+)") do
|
||||||
|
if k == "db" then
|
||||||
|
dbFile = v
|
||||||
|
elseif k == "cache-policy" then
|
||||||
|
cachePolicy = v
|
||||||
|
else
|
||||||
|
print(string.format("undefined option `%s`", r))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
if string.sub(r, 1, 2) ~= "--" then
|
-- break the match iterate
|
||||||
goto continue
|
break
|
||||||
end
|
|
||||||
|
|
||||||
for k, v in string.gmatch(string.sub(r, 3), "([^=]+)=([^%s]+)") do
|
|
||||||
if k == "db" then
|
|
||||||
dbFile = v
|
|
||||||
elseif k == "cache-policy" then
|
|
||||||
cachePolicy = v
|
|
||||||
else
|
|
||||||
print(string.format("undefined option `%s`", r))
|
|
||||||
return
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- break the match iterate
|
|
||||||
break
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- continue this loop
|
|
||||||
::continue::
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- print(string.format("dbFile=%s, cachePolicy=%s", dbFile, cachePolicy))
|
-- print(string.format("dbFile=%s, cachePolicy=%s", dbFile, cachePolicy))
|
||||||
|
|
@ -121,7 +116,7 @@ ip2region xdb searcher test program
|
||||||
source xdb: %s (%s, %s)
|
source xdb: %s (%s, %s)
|
||||||
type 'quit' to exit]], dbFile, xdb.version_info(version).name, cachePolicy))
|
type 'quit' to exit]], dbFile, xdb.version_info(version).name, cachePolicy))
|
||||||
local region, err = "", nil
|
local region, err = "", nil
|
||||||
local ip_int, s_time, c_time = 0, 0, 0
|
local s_time, c_time = 0, 0
|
||||||
while ( true ) do
|
while ( true ) do
|
||||||
io.write("ip2region>> ");
|
io.write("ip2region>> ");
|
||||||
io.input(io.stdin);
|
io.input(io.stdin);
|
||||||
|
|
@ -137,27 +132,24 @@ while ( true ) do
|
||||||
-- empty string ignore
|
-- empty string ignore
|
||||||
line = line:gsub("^%s*(.-)%s*$", "%1")
|
line = line:gsub("^%s*(.-)%s*$", "%1")
|
||||||
if string.len(line) < 1 then
|
if string.len(line) < 1 then
|
||||||
goto continue
|
-- continue and do nothing here
|
||||||
end
|
|
||||||
|
|
||||||
ip_bytes, err = xdb.parse_ip(line)
|
|
||||||
-- print(string.format("parse(%s): %s, err: %s", line, xdb.ip_to_string(ip_bytes), err))
|
|
||||||
if err ~= nil then
|
|
||||||
print(string.format("invalid ip address `%s`", line))
|
|
||||||
goto continue
|
|
||||||
end
|
|
||||||
|
|
||||||
-- do the search
|
|
||||||
s_time = xdb.now()
|
|
||||||
region, err = searcher:search(ip_bytes)
|
|
||||||
c_time = xdb.now() - s_time
|
|
||||||
if err ~= nil then
|
|
||||||
print(string.format("{err: %s, io_count: %d}", err, searcher:get_io_count()))
|
|
||||||
else
|
else
|
||||||
print(string.format("{region: %s, io_count: %d, took: %dμs}", region, searcher:get_io_count(), c_time))
|
s_time = xdb.now()
|
||||||
|
ip_bytes, err = xdb.parse_ip(line)
|
||||||
|
-- print(string.format("parse(%s): %s, err: %s", line, xdb.ip_to_string(ip_bytes), err))
|
||||||
|
if err ~= nil then
|
||||||
|
print(string.format("invalid ip address `%s`", line))
|
||||||
|
else
|
||||||
|
-- do the search
|
||||||
|
region, err = searcher:search(ip_bytes)
|
||||||
|
c_time = xdb.now() - s_time
|
||||||
|
if err ~= nil then
|
||||||
|
print(string.format("{err: %s, io_count: %d}", err, searcher:get_io_count()))
|
||||||
|
else
|
||||||
|
print(string.format("{region: %s, io_count: %d, took: %dμs}", region, searcher:get_io_count(), c_time))
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
::continue::
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- resource cleanup
|
-- resource cleanup
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@
|
||||||
-- @Date 2022/06/30
|
-- @Date 2022/06/30
|
||||||
|
|
||||||
-- set the package to load the current xdb_searcher.so
|
-- set the package to load the current xdb_searcher.so
|
||||||
package.path = "./?.lua" .. package.path
|
package.path = "./?.lua;" .. package.path
|
||||||
package.cpath = "./?.so" .. package.cpath
|
package.cpath = "./?.so;" .. package.cpath
|
||||||
local xdb = require("xdb_searcher")
|
local xdb = require("xdb_searcher")
|
||||||
|
|
||||||
---- ip checking testing
|
---- ip checking testing
|
||||||
|
|
@ -25,7 +25,7 @@ function test_parse_ip()
|
||||||
print(string.format("invalid ip address `%s`: %s", ip_src, err))
|
print(string.format("invalid ip address `%s`: %s", ip_src, err))
|
||||||
else
|
else
|
||||||
local ip_string = xdb.ip_to_string(ip_bytes);
|
local ip_string = xdb.ip_to_string(ip_bytes);
|
||||||
print(string.format("parse_ip(%s)->%s ? %s", ip_src, ip_string, ip_src==ip_string))
|
print(string.format("parse_ip(%s)->%s ? %s", ip_src, ip_string, tostring(ip_src==ip_string)))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -44,7 +44,7 @@ function test_load_header()
|
||||||
if err ~= nil then
|
if err ~= nil then
|
||||||
print("failed to load header: ", err)
|
print("failed to load header: ", err)
|
||||||
else
|
else
|
||||||
print(string.format("xdb header buffer `%s` loaded", header))
|
print(string.format("xdb header buffer `%s` loaded", tostring(header)))
|
||||||
|
|
||||||
local tpl = [[
|
local tpl = [[
|
||||||
header: {
|
header: {
|
||||||
|
|
@ -79,7 +79,7 @@ function test_load_vector_index()
|
||||||
print("failed to load vector index: ", err)
|
print("failed to load vector index: ", err)
|
||||||
else
|
else
|
||||||
print(string.format("xdb vector index buffer `%s` loaded, info={name=%s, type=%d, length=%d}",
|
print(string.format("xdb vector index buffer `%s` loaded, info={name=%s, type=%d, length=%d}",
|
||||||
v_index, v_index:name(), v_index:type(), v_index:length()))
|
tostring(v_index), v_index:name(), v_index:type(), v_index:length()))
|
||||||
v_index:close()
|
v_index:close()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -91,7 +91,7 @@ function test_load_content()
|
||||||
print("failed to load content: ", err)
|
print("failed to load content: ", err)
|
||||||
else
|
else
|
||||||
print(string.format("xdb content buffer `%s` loaded, info={name=%s, type=%d, length=%d}",
|
print(string.format("xdb content buffer `%s` loaded, info={name=%s, type=%d, length=%d}",
|
||||||
c_buffer, c_buffer:name(), c_buffer:type(), c_buffer:length()))
|
tostring(c_buffer), c_buffer:name(), c_buffer:type(), c_buffer:length()))
|
||||||
c_buffer:close();
|
c_buffer:close();
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -101,23 +101,23 @@ function test_search()
|
||||||
-- ipv4
|
-- ipv4
|
||||||
local ip_str = "1.2.3.4"
|
local ip_str = "1.2.3.4"
|
||||||
searcher, err = xdb.new_with_file_only(xdb.IPv4, "../../data/ip2region_v4.xdb")
|
searcher, err = xdb.new_with_file_only(xdb.IPv4, "../../data/ip2region_v4.xdb")
|
||||||
print(string.format("searcher.tostring=%s", searcher))
|
print(string.format("searcher.tostring=%s", tostring(searcher)))
|
||||||
local t_start = xdb.now()
|
local t_start = xdb.now()
|
||||||
region, err = searcher:search(ip_str)
|
region, err = searcher:search(ip_str)
|
||||||
local c_time = xdb.now() - t_start
|
local c_time = xdb.now() - t_start
|
||||||
print(string.format("search(%s): {region=%s, io_count: %d, took: %dμs, err=%s}",
|
print(string.format("search(%s): {region=%s, io_count: %d, took: %dμs, err=%s}",
|
||||||
ip_str, region, searcher:get_io_count(), c_time, err))
|
ip_str, region, searcher:get_io_count(), c_time, tostring(err)))
|
||||||
searcher:close()
|
searcher:close()
|
||||||
|
|
||||||
-- IPv6
|
-- IPv6
|
||||||
ip_str = "240e:3b7:3276:33b0:958f:f34c:d04f:f6a"
|
ip_str = "240e:3b7:3276:33b0:958f:f34c:d04f:f6a"
|
||||||
searcher, err = xdb.new_with_file_only(xdb.IPv6, "../../data/ip2region_v6.xdb")
|
searcher, err = xdb.new_with_file_only(xdb.IPv6, "../../data/ip2region_v6.xdb")
|
||||||
print(string.format("searcher.tostring=%s", searcher))
|
print(string.format("searcher.tostring=%s", tostring(searcher)))
|
||||||
t_start = xdb.now()
|
t_start = xdb.now()
|
||||||
region, err = searcher:search(ip_str)
|
region, err = searcher:search(ip_str)
|
||||||
c_time = xdb.now() - t_start
|
c_time = xdb.now() - t_start
|
||||||
print(string.format("search(%s): {region=%s, io_count: %d, took: %dμs, err=%s}",
|
print(string.format("search(%s): {region=%s, io_count: %d, took: %dμs, err=%s}",
|
||||||
ip_str, region, searcher:get_io_count(), c_time, err))
|
ip_str, region, searcher:get_io_count(), c_time, tostring(err)))
|
||||||
searcher:close()
|
searcher:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -134,7 +134,7 @@ end
|
||||||
|
|
||||||
local s_time = xdb.now();
|
local s_time = xdb.now();
|
||||||
print(string.format("+---calling test function %s ...", func_name))
|
print(string.format("+---calling test function %s ...", func_name))
|
||||||
_G[func_name]();
|
_G[func_name]()
|
||||||
local cost_time = xdb.now() - s_time
|
local cost_time = xdb.now() - s_time
|
||||||
xdb.cleanup();
|
xdb.cleanup();
|
||||||
print(string.format("|---done, took: %.3fμs", cost_time))
|
print(string.format("|---done, took: %.3fμs", cost_time))
|
||||||
|
|
@ -735,14 +735,27 @@ int luaopen_xdb_searcher(lua_State *L)
|
||||||
luaL_newmetatable(L, XDB_BUFFER_METATABLE_NAME);
|
luaL_newmetatable(L, XDB_BUFFER_METATABLE_NAME);
|
||||||
lua_pushvalue(L, -1);
|
lua_pushvalue(L, -1);
|
||||||
lua_setfield(L, -2, "__index");
|
lua_setfield(L, -2, "__index");
|
||||||
|
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
|
||||||
|
// lua 5.1
|
||||||
|
luaL_register(L, NULL, xdb_buffer_methods);
|
||||||
|
#elif defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 502
|
||||||
|
// lua version 5.2, 5.3, 5.4 ...
|
||||||
luaL_setfuncs(L, xdb_buffer_methods, 0);
|
luaL_setfuncs(L, xdb_buffer_methods, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
// create a metatable for xdb searcher object
|
// create a metatable for xdb searcher object
|
||||||
luaL_newmetatable(L, XDB_METATABLE_NAME);
|
luaL_newmetatable(L, XDB_METATABLE_NAME);
|
||||||
lua_pushvalue(L, -1);
|
lua_pushvalue(L, -1);
|
||||||
lua_setfield(L, -2, "__index");
|
lua_setfield(L, -2, "__index");
|
||||||
|
#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM == 501
|
||||||
|
// lua 5.1
|
||||||
|
luaL_register(L, NULL, xdb_searcher_methods);
|
||||||
|
luaL_register(L, NULL, xdb_searcher_functions);
|
||||||
|
#elif defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 502
|
||||||
|
// lua version 5.2, 5.3, 5.4 ...
|
||||||
luaL_setfuncs(L, xdb_searcher_methods, 0);
|
luaL_setfuncs(L, xdb_searcher_methods, 0);
|
||||||
luaL_setfuncs(L, xdb_searcher_functions, 0);
|
luaL_setfuncs(L, xdb_searcher_functions, 0);
|
||||||
|
#endif
|
||||||
|
|
||||||
// register the constants attributes
|
// register the constants attributes
|
||||||
lua_pushinteger(L, xdb_ipv4_id);
|
lua_pushinteger(L, xdb_ipv4_id);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue