]> git.ipfire.org Git - people/ms/libloc.git/commitdiff
lua: Actually return a network after lookup()
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 22 Feb 2024 14:01:08 +0000 (14:01 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 22 Feb 2024 14:01:08 +0000 (14:01 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/lua/database.c
src/lua/network.c
src/lua/network.h

index 2912f4c94f204d25fe0fb36f68f3595d5cce3106..69ff32c4b3adf2fd819927c6694879f30c4f88e5 100644 (file)
@@ -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[] = {
index 0706fe2a2350246448bd09e972a893de19b323c4..5a6c68ada06a635029f0e6ca5c38cbdeffb5e52b 100644 (file)
@@ -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));
 
index 54be76d863f5516c8d54a6b6a48fabe02e603480..130aa2fd8b120ad40f86d6bdbf17e68fea54a815 100644 (file)
 #include <lua.h>
 #include <lauxlib.h>
 
+#include <libloc/network.h>
+
 int register_network(lua_State* L);
 
+int create_network(lua_State* L, struct loc_network* network);
+
 #endif /* LUA_LOCATION_NETWORK_H */