From: bert hubert Date: Thu, 23 May 2013 13:55:16 +0000 (+0200) Subject: interim commit lua52 work X-Git-Tag: auth-3.3-rc1~16 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3bb90c674a2ad40a2dfa030696c9ff2fd4484983;p=pdns interim commit lua52 work --- diff --git a/configure.ac b/configure.ac index 31025f881..086950627 100644 --- a/configure.ac +++ b/configure.ac @@ -44,31 +44,28 @@ dnl Check for lua AC_MSG_CHECKING(if with lua) AC_ARG_WITH(lua, AC_HELP_STRING([--with-lua],[use Lua]), [WITH_LUA=$withval],[WITH_LUA=yes]) -AC_MSG_RESULT($WITH_LUA) -if test "$WITH_LUA" != "no"; then - # try pkgconfig - if test "$WITH_LUA" = "yes"; then - LUAPC=lua - else - LUAPC=$WITH_LUA - fi - PKG_CHECK_MODULES(LUA, $LUAPC >= 5.1, [ - AC_DEFINE([HAVE_LUA], [1], [liblua]) - AC_DEFINE([HAVE_LUA_H], [1], [lua.h]) - ],[ - PKG_CHECK_MODULES(LUA, lua5.1 >= 5.1, [ - AC_DEFINE([HAVE_LUA], [1], [liblua]) - AC_DEFINE([HAVE_LUA_H], [1], [lua.h]) - ],[ - PKG_CHECK_MODULES(LUA, lua-5.1 >= 5.1, [ - AC_DEFINE([HAVE_LUA], [1], [liblua]) - AC_DEFINE([HAVE_LUA_H], [1], [lua.h]) - ]) - ]) - ]) - AC_SUBST(LUA_CFLAGS) - AC_SUBST(LUA_LIBS) -fi +AX_PROG_LUA(5.0,,,) + +AX_LUA_LIBS( + [ + AC_DEFINE([HAVE_LUA], [1], [liblua]) + ], + [ + AC_MSG_RESULT(Not found) + ] + ) + +AX_LUA_HEADERS( + [ + AC_DEFINE([HAVE_LUA_H], [1], [lua.h]) + ], + [ + AC_MSG_RESULT(Not found) + ] + ) + +AC_SUBST(LUA_LIB) +AC_SUBST(LUA_INCLUDE) dnl Allow user to require SQLite3 AC_MSG_CHECKING(whether user requires sqlite3) diff --git a/pdns/Makefile.am b/pdns/Makefile.am index 12c1b930c..4eef10695 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -1,7 +1,7 @@ if HAVE_LIBPOLARSSL -AM_CXXFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" -DLIBDIR=\"@libdir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind @THREADFLAGS@ $(LUA_CFLAGS) $(SQLITE3_CFLAGS) -I ext/rapidjson/include +AM_CXXFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" -DLIBDIR=\"@libdir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind @THREADFLAGS@ $(LUA_INCLUDE) $(SQLITE3_CFLAGS) -I ext/rapidjson/include else -AM_CXXFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" -DLIBDIR=\"@libdir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind @THREADFLAGS@ $(LUA_CFLAGS) $(SQLITE3_CFLAGS) -Iext/polarssl-1.1.2/include -Iext/rapidjson/include +AM_CXXFLAGS=-DSYSCONFDIR=\"@sysconfdir@\" -DLIBDIR=\"@libdir@\" -DLOCALSTATEDIR=\"@socketdir@\" -Ibackends/bind @THREADFLAGS@ $(LUA_INCLUDE) $(SQLITE3_CFLAGS) -Iext/polarssl-1.1.2/include -Iext/rapidjson/include endif AM_CPPFLAGS=-Ibackends/bind $(BOOST_CPPFLAGS) @THREADFLAGS@ $(LIBCURL_CFLAGS) @@ -71,7 +71,7 @@ version.hh version.cc # pdns_server_LDFLAGS=@moduleobjects@ @modulelibs@ @DYNLINKFLAGS@ @LIBDL@ @THREADFLAGS@ $(BOOST_SERIALIZATION_LDFLAGS) -rdynamic -pdns_server_LDADD= ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_SERIALIZATION_LIBS) $(LUA_LIBS) $(SQLITE3_LIBS) $(LIBCURL_LIBS) $(MYSQL_lib) +pdns_server_LDADD= ext/polarssl-1.1.2/library/libpolarssl.a $(BOOST_SERIALIZATION_LIBS) $(LUA_LIB) $(SQLITE3_LIBS) $(LIBCURL_LIBS) $(MYSQL_lib) if BOTAN110 pdns_server_SOURCES += botan110signers.cc botansigners.cc @@ -266,7 +266,7 @@ lua-pdns.cc lua-pdns.hh lua-recursor.cc lua-recursor.hh randomhelper.cc \ recpacketcache.cc recpacketcache.hh dns.cc nsecrecords.cc base32.cc cachecleaner.hh json_ws.cc json_ws.hh \ json.cc json.hh version.hh version.cc -pdns_recursor_LDFLAGS= $(LUA_LIBS) +pdns_recursor_LDFLAGS= $(LUA_LIB) pdns_recursor_LDADD= pdns_control_SOURCES=dynloader.cc dynmessenger.cc arguments.cc logger.cc statbag.cc \ diff --git a/pdns/lua-auth.cc b/pdns/lua-auth.cc index f9109322c..a11e2199e 100644 --- a/pdns/lua-auth.cc +++ b/pdns/lua-auth.cc @@ -86,12 +86,7 @@ bool AuthLua::axfrfilter(const ComboAddress& remote, const string& zone, const D /* 1 2 3 4 */ /* stack: boolean table key row */ -#ifndef LUA_VERSION_NUM - int tableLen = luaL_getn(d_lua, 2); -#else - int tableLen = lua_objlen(d_lua, 2); -#endif - + int tableLen = getLuaTableLength(d_lua, 2); for(int n=1; n < tableLen + 1; ++n) { lua_pushnumber(d_lua, n); lua_gettable(d_lua, 2); diff --git a/pdns/lua-pdns.cc b/pdns/lua-pdns.cc index 26c7630f2..613f382ea 100644 --- a/pdns/lua-pdns.cc +++ b/pdns/lua-pdns.cc @@ -111,6 +111,17 @@ void pushResourceRecordsTable(lua_State* lua, const vector& r } } +int getLuaTableLength(lua_State* lua, int depth) +{ +#ifndef LUA_VERSION_NUM + return luaL_getn(lua, 2); +#elif LUA_VERSION_NUM < 502 + return lua_objlen(lua, 2); +#else + return lua_rawlen(lua, 2); +#endif +} + void popResourceRecordsTable(lua_State *lua, const string &query, vector& ret) { /* get the result */ @@ -120,11 +131,8 @@ void popResourceRecordsTable(lua_State *lua, const string &query, vector& records); void popResourceRecordsTable(lua_State *lua, const string &query, vector& ret); - +int getLuaTableLength(lua_State* lua, int depth); #endif