]> git.ipfire.org Git - people/ms/libloc.git/blobdiff - src/lua/location.c
lua: Export network flags
[people/ms/libloc.git] / src / lua / location.c
index ee9bce512a24a14f4346b8fec85031fabad19d25..6f2157cfc0bd9ef32f8d8fc89ad528501775ef8e 100644 (file)
 #include <lualib.h>
 
 #include <libloc/libloc.h>
+#include <libloc/network.h>
 
 #include "location.h"
+#include "as.h"
+#include "country.h"
 #include "database.h"
+#include "network.h"
 
 struct loc_ctx* ctx = NULL;
 
@@ -50,10 +54,42 @@ int luaopen_location(lua_State* L) {
        // Register functions
        luaL_newlib(L, location_functions);
 
+       // Register AS type
+       register_as(L);
+
+       lua_setfield(L, -2, "AS");
+
+       // Register Country type
+       register_country(L);
+
+       lua_setfield(L, -2, "Country");
+
        // Register Database type
        register_database(L);
 
        lua_setfield(L, -2, "Database");
 
+       // Register Network type
+       register_network(L);
+
+       lua_setfield(L, -2, "Network");
+
+       // Set DATABASE_PATH
+       lua_pushstring(L, LIBLOC_DEFAULT_DATABASE_PATH);
+       lua_setfield(L, -2, "DATABASE_PATH");
+
+       // Add flags
+       lua_pushnumber(L, LOC_NETWORK_FLAG_ANONYMOUS_PROXY);
+       lua_setfield(L, -2, "NETWORK_FLAG_ANONYMOUS_PROXY");
+
+       lua_pushnumber(L, LOC_NETWORK_FLAG_SATELLITE_PROVIDER);
+       lua_setfield(L, -2, "NETWORK_FLAG_SATELLITE_PROVIDER");
+
+       lua_pushnumber(L, LOC_NETWORK_FLAG_ANYCAST);
+       lua_setfield(L, -2, "NETWORK_FLAG_ANYCAST");
+
+       lua_pushnumber(L, LOC_NETWORK_FLAG_DROP);
+       lua_setfield(L, -2, "NETWORK_FLAG_DROP");
+
        return 1;
 }