From: Michael Tremer Date: Thu, 22 Feb 2024 14:01:08 +0000 (+0000) Subject: lua: Actually return a network after lookup() X-Git-Tag: 0.9.18~163 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fac2ef2df5d7d66d6c69bcae1a111ad840dd806;p=location%2Flibloc.git lua: Actually return a network after lookup() Signed-off-by: Michael Tremer --- diff --git a/src/lua/database.c b/src/lua/database.c index 2912f4c..69ff32c 100644 --- a/src/lua/database.c +++ b/src/lua/database.c @@ -24,6 +24,7 @@ #include "location.h" #include "database.h" +#include "network.h" typedef struct database { struct loc_database* db; @@ -94,11 +95,11 @@ static int Database_lookup(lua_State* L) { if (r) return luaL_error(L, "Could not lookup address %s: %s\n", address, strerror(errno)); - // XXX Return the network - + // Create a network object + r = create_network(L, network); loc_network_unref(network); - return 0; + return r; } static const struct luaL_Reg database_functions[] = { diff --git a/src/lua/network.c b/src/lua/network.c index 0706fe2..5a6c68a 100644 --- a/src/lua/network.c +++ b/src/lua/network.c @@ -39,7 +39,7 @@ static Network* luaL_checknetwork(lua_State* L, int i) { return (Network*)userdata; } -static int create_network(lua_State* L, struct loc_network* network) { +int create_network(lua_State* L, struct loc_network* network) { // Allocate a new object Network* self = (Network*)lua_newuserdata(L, sizeof(*self)); diff --git a/src/lua/network.h b/src/lua/network.h index 54be76d..130aa2f 100644 --- a/src/lua/network.h +++ b/src/lua/network.h @@ -20,6 +20,10 @@ #include #include +#include + int register_network(lua_State* L); +int create_network(lua_State* L, struct loc_network* network); + #endif /* LUA_LOCATION_NETWORK_H */