]> granicus.if.org Git - pdns/commitdiff
interim commit lua52 work
authorbert hubert <bert.hubert@netherlabs.nl>
Thu, 23 May 2013 13:55:16 +0000 (15:55 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Thu, 23 May 2013 13:55:16 +0000 (15:55 +0200)
configure.ac
pdns/Makefile.am
pdns/lua-auth.cc
pdns/lua-pdns.cc
pdns/lua-pdns.hh

index 31025f88156460e559ddc3224633673c177893ce..0869506270ee72b48356c8ac587e14f689fb03c7 100644 (file)
@@ -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)
index 12c1b930c290cca5ef64075d3dc8b18d977654ff..4eef10695c750b24d8fff303cb7b8059010dcc7c 100644 (file)
@@ -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 \
index f9109322c66373f0c9adec08434ca5bce8906f91..a11e2199e859c892d3364221211fb5fc43afcb31 100644 (file)
@@ -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);
index 26c7630f2a555681c23a8a0ff0801d87f713f5fd..613f382eac30aec60fb4ca128f9eab02cefcdad9 100644 (file)
@@ -111,6 +111,17 @@ void pushResourceRecordsTable(lua_State* lua, const vector<DNSResourceRecord>& 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<DNSResourceRecord>& ret)
 {
   /* get the result */
@@ -120,11 +131,8 @@ void popResourceRecordsTable(lua_State *lua, const string &query, vector<DNSReso
   rr.ttl = 3600;
 
 //  cerr<<"Lua stacksize "<<lua_gettop(lua)<<endl;
-#ifndef LUA_VERSION_NUM
-  int tableLen = luaL_getn(lua, 2);
-#else
-  int tableLen = lua_objlen(lua, 2);
-#endif
+
+  int tableLen = getLuaTableLength(lua, 2);
 //  cerr<<"Got back "<<tableLen<< " answers from Lua"<<endl;
 
   for(int n=1; n < tableLen + 1; ++n) {
@@ -217,7 +225,7 @@ int logLua(lua_State *lua)
 
 PowerDNSLua::PowerDNSLua(const std::string& fname)
 {
-  d_lua = lua_open();
+  d_lua = luaL_newstate();
 
 #ifndef LUA_VERSION_NUM
   luaopen_base(d_lua);
index ddecdffdf105230ccb66d29e7c9462fce274d8ec..51ac65c54167315bdfc7acc2b4c1bc63ec24e3b6 100644 (file)
@@ -33,5 +33,5 @@ protected: // FIXME?
 
 void pushResourceRecordsTable(lua_State* lua, const vector<DNSResourceRecord>& records);
 void popResourceRecordsTable(lua_State *lua, const string &query, vector<DNSResourceRecord>& ret);
-
+int getLuaTableLength(lua_State* lua, int depth);
 #endif