]> granicus.if.org Git - pdns/commitdiff
fix up so we at least compile against lua5.2 for our internal testing functions,...
authorbert hubert <bert.hubert@netherlabs.nl>
Fri, 24 May 2013 09:20:13 +0000 (11:20 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Fri, 24 May 2013 09:20:13 +0000 (11:20 +0200)
pdns/lua-auth.cc

index a11e2199e859c892d3364221211fb5fc43afcb31..effcdf06211356380b2aa0463c45b55da9e7d6df 100644 (file)
@@ -160,6 +160,8 @@ static int ldp_getRemote(lua_State *L) {
   return 1;
 }
 
+// these functions are used for PowerDNS recursor regresseion testing against auth. The Lua 5.2 implementation is most likely broken.
+#if LUA_VERSION_NUM < 502
 static const struct luaL_reg ldp_methods [] = {
       {"setRcode", ldp_setRcode},
       {"getQuestion", ldp_getQuestion},
@@ -180,6 +182,28 @@ void AuthLua::registerLuaDNSPacket(void) {
 
   lua_pop(d_lua, 1);
 }
+#else
+static const struct luaL_Reg ldp_methods [] = {
+      {"setRcode", ldp_setRcode},
+      {"getQuestion", ldp_getQuestion},
+      {"addRecords", ldp_addRecords},
+      {"getRemote", ldp_getRemote},
+      {NULL, NULL}
+    };
+
+void AuthLua::registerLuaDNSPacket(void) {
+
+  luaL_newmetatable(d_lua, "LuaDNSPacket");
+
+  lua_pushstring(d_lua, "__index");
+  lua_pushvalue(d_lua, -2);  /* pushes the metatable */
+  lua_settable(d_lua, -3);  /* metatable.__index = metatable */
+
+  luaL_newlib(d_lua, ldp_methods);
+
+  lua_pop(d_lua, 1);
+}
+#endif
 
 DNSPacket* AuthLua::prequery(DNSPacket *p)
 {