]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
emergency checkin; working code!
authorMiek Gieben <miekg@NLnetLabs.nl>
Thu, 28 Jul 2005 12:50:38 +0000 (12:50 +0000)
committerMiek Gieben <miekg@NLnetLabs.nl>
Thu, 28 Jul 2005 12:50:38 +0000 (12:50 +0000)
tests/lua-rns.c
tests/rns.lua

index baecbdd8bebdfd03143dad5e2a4a978cf5b814be..7cebd5e0d93c40558d6017a5557d5a2531df3f78 100644 (file)
@@ -61,13 +61,35 @@ l_rr_new_frm_str(lua_State *L)
        /* pop string from stack, make new rr, push rr to
         * stack and return 1 - to signal the new pointer
         */
-       char *str = (char*)luaL_checkstring(L, 1);
+       char *str = strdup((char*)luaL_checkstring(L, 1));
+
+       printf("string retrieved from stack %s\n", str);
+
        ldns_rr *new_rr = ldns_rr_new_frm_str(str);
 
+       if (new_rr) {
+               printf("yeah it worked\n");
+       } else {
+               printf("uh oh\n");
+       }
+
        lua_pushlightuserdata(L, new_rr);
        return 1;
 }
 
+static int
+l_rr_print(lua_State *L)
+{
+       /* we always print to stdout */
+/*
+ luaL_checktype(lua,1,LUA_TLIGHTUSERDATA);
+ QCanvasLine *line = static_cast<QCanvasLine*>(lua_touserdata(lua,1));
+*/
+       ldns_rr *toprint = (ldns_rr*)lua_touserdata(L, 1); /* pop from the stack */
+
+       ldns_rr_print(stdout, toprint);
+       return 0;
+}
 
 /* Test function which doesn't call ldns stuff yet */
 static int 
@@ -104,13 +126,9 @@ void
 register_ldns_functions(void)
 {
         /* register our functions */
-
-       /* need to encap. all used functions in a
-        * still lua can understand
-        */
         lua_register(L, "l_average", l_average);
-
        lua_register(L, "l_rr_new_frm_str", l_rr_new_frm_str);
+       lua_register(L, "l_rr_print", l_rr_print);
 }
 
 int
index 1f9276e8271ed989b1ff37e85e39622415c4ee05..763c5dcba8206723df9846f1224baf0fcbd49a26 100644 (file)
@@ -7,4 +7,6 @@ print("The sum is ", sum)
 
 -- Now the scary ldns_* stuff
 
-my_rr = l_rr_new_frm_str("miek.nl")
+my_rr = l_rr_new_frm_str("www.miek.nl  IN A 192.168.1.2")
+
+l_rr_print(my_rr)