summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2014-10-15 16:44:27 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2014-10-15 16:44:27 +0200
commit7c1364816bce2ecfad1ecc118225b1fa6f28faed (patch)
tree0a0232e53ed9ea50e0de07abb519455c07e24a14
parentb37950fecfb3afb53942fba28e4e36d0b8753351 (diff)
downloadcrawler-7c1364816bce2ecfad1ecc118225b1fa6f28faed.tar.gz
crawler-7c1364816bce2ecfad1ecc118225b1fa6f28faed.tar.bz2
added getstringarray to luavm layer
-rwxr-xr-xinclude/luaglue/LuaVM.hpp2
-rwxr-xr-xsrc/crawl/GNUmakefile1
-rwxr-xr-xsrc/crawl/crawl.cpp16
-rw-r--r--src/libluaglue/LuaVM.cpp28
4 files changed, 46 insertions, 1 deletions
diff --git a/include/luaglue/LuaVM.hpp b/include/luaglue/LuaVM.hpp
index 488c810..81261f3 100755
--- a/include/luaglue/LuaVM.hpp
+++ b/include/luaglue/LuaVM.hpp
@@ -5,6 +5,7 @@
#include "lua.hpp"
+#include <vector>
#include <string>
class LuaVM
@@ -25,6 +26,7 @@ class LuaVM
LUAGLUE_DLL_VISIBLE void fullGarbageCollect( );
LUAGLUE_DLL_VISIBLE std::string getString( const std::string &key );
+ LUAGLUE_DLL_VISIBLE std::vector<std::string> getStringArray( const std::string &key );
LUAGLUE_DLL_VISIBLE bool getBoolean( const std::string &key );
LUAGLUE_DLL_VISIBLE lua_State *handle( );
diff --git a/src/crawl/GNUmakefile b/src/crawl/GNUmakefile
index cea25f5..778a72a 100755
--- a/src/crawl/GNUmakefile
+++ b/src/crawl/GNUmakefile
@@ -8,6 +8,7 @@ INCLUDE_CPPFLAGS = \
INCLUDE_DIRS = \
-I. \
+ -I$(TOPDIR)/include \
-I$(TOPDIR)/include/logger \
-I$(TOPDIR)/include/util \
-I$(TOPDIR)/include/module \
diff --git a/src/crawl/crawl.cpp b/src/crawl/crawl.cpp
index 648060c..88f6aa3 100755
--- a/src/crawl/crawl.cpp
+++ b/src/crawl/crawl.cpp
@@ -14,6 +14,8 @@
#include "LuaVM.hpp"
+#include "FileUtils.hpp"
+
#include <set>
#include <vector>
#include <list>
@@ -93,7 +95,19 @@ int main( int /* argc */, char *argv[] )
bool modulesSearchRecursive = luaVm.getBoolean( "crawler.modules_search_recursive" );
LOG( logNOTICE ) << "Loading modules from path '" << modulePath << "' "
<< ( modulesSearchRecursive ? "(recursive)" : "" );
-
+
+ vector<string> entries = directory_entries( modulePath, true, modulesSearchRecursive );
+ vector<string>::const_iterator it, end = entries.end( );
+ for( it = entries.begin( ); it != end; it++ ) {
+ cout << (*it) << endl;
+ }
+
+ vector<string> modules = luaVm.getStringArray( "modules.urlnormalizers" );
+ end = modules.end( );
+ for( it = modules.begin( ); it != end; it++ ) {
+ cout << (*it) << endl;
+ }
+
vector<string> normalizerModules;
#ifndef _WIN32
normalizerModules.push_back( "./modules/urlnormalizer/simpleurl/mod_urlnormalizer_simple.so" );
diff --git a/src/libluaglue/LuaVM.cpp b/src/libluaglue/LuaVM.cpp
index 637f668..04027af 100644
--- a/src/libluaglue/LuaVM.cpp
+++ b/src/libluaglue/LuaVM.cpp
@@ -273,3 +273,31 @@ bool LuaVM::getBoolean( const string &key )
return res;
}
+
+vector<string> LuaVM::getStringArray( const string &key )
+{
+ vector<string> res;
+
+ int n = findValue( key );
+
+ if( !lua_istable( m_lua, -1 ) ) {
+ lua_pop( m_lua, n );
+ ostringstream ss;
+ ss << "key '" << key << "' refers not to a table";
+ throw runtime_error( ss.str( ) );
+ }
+
+ //dumpStack( );
+
+ lua_pushvalue( m_lua, -1 );
+ lua_pushnil( m_lua );
+ while( lua_next( m_lua, -2 ) ) {
+ res.push_back( lua_tostring( m_lua, -1 ) );
+ lua_pop( m_lua, 1 );
+ }
+ lua_pop( m_lua, 1 );
+
+ lua_pop( m_lua, n );
+
+ return res;
+}