]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
use luaL_reg to get lua-like syntax for DNS pkt manipulation
authorMiek Gieben <miekg@NLnetLabs.nl>
Tue, 23 Aug 2005 10:49:33 +0000 (10:49 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Tue, 23 Aug 2005 10:49:33 +0000 (10:49 +0000)
lua/lua-rns.c
lua/test.lua
lua/test2.lua [new file with mode: 0644]

index 7d272964648822447f28728003c637e8781d5ca0..c37282a34defb5c003c4f09bb2a89c410ea74265 100644 (file)
@@ -548,6 +548,12 @@ register_ldns_functions(void)
        lua_register(L, "l_pkt_nscount", l_pkt_nscount);
        lua_register(L, "l_pkt_id", l_pkt_id);
 
+       static const struct luaL_reg l_pkt_lib [] = {
+               {"new", l_pkt_new},
+               {NULL, NULL}
+       };
+       luaL_openlib(L, "pkt", l_pkt_lib, 0);
+
 #if 0
        lua_register(L, "l_pkt_set_qdcount", l_pkt_set_qdcount);
        lua_register(L, "l_pkt_set_ancount", l_pkt_set_ancount);
index f08fef2833fa84a709442ade41bbaeb35b337c82..6f7cbf453f4ffd758249c6a3ae44928193ad00ec 100644 (file)
@@ -10,7 +10,8 @@ l_rr_print(my_rr)
 l_rr_print(my_rr2)
 l_rr_print(my_rr4)
 
-my_pkt = l_pkt_new()
+--my_pkt = l_pkt_new()
+my_pkt = pkt.new();
 
 my_pkt = l_pkt_push_rr(my_pkt, LDNS_SECTION_ANSWER, my_rr)
 
diff --git a/lua/test2.lua b/lua/test2.lua
new file mode 100644 (file)
index 0000000..c2ca5ad
--- /dev/null
@@ -0,0 +1,4 @@
+-- source the lib file with the function
+dofile("rns-lib.lua")
+
+my_pkt = pkt.new();