From: Miek Gieben Date: Thu, 28 Jul 2005 12:50:38 +0000 (+0000) Subject: emergency checkin; working code! X-Git-Tag: release-0.70~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=647bd03334836e80499654554a173cfa9ecfa043;p=thirdparty%2Fldns.git emergency checkin; working code! --- diff --git a/tests/lua-rns.c b/tests/lua-rns.c index baecbdd8..7cebd5e0 100644 --- a/tests/lua-rns.c +++ b/tests/lua-rns.c @@ -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(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 diff --git a/tests/rns.lua b/tests/rns.lua index 1f9276e8..763c5dcb 100644 --- a/tests/rns.lua +++ b/tests/rns.lua @@ -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)