diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2014-10-14 13:08:41 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2014-10-14 13:08:41 +0200 |
commit | c757efa3ee6f395e3ada3088065c73eb953f6834 (patch) | |
tree | 8660ca4d2ec0024177541cd4ca123e04e6541252 | |
parent | 0fdd066c566564a786e9070fbfb82a0b70bd1790 (diff) | |
download | crawler-c757efa3ee6f395e3ada3088065c73eb953f6834.tar.gz crawler-c757efa3ee6f395e3ada3088065c73eb953f6834.tar.bz2 |
added initialize_libcrawler instead of silly tolua trick in the main program
-rw-r--r-- | include/crawler/libcrawler.hpp | 6 | ||||
-rwxr-xr-x | src/crawl/GNUmakefile | 4 | ||||
-rwxr-xr-x | src/crawl/crawl.cpp | 14 | ||||
-rwxr-xr-x | src/libcrawler/GNUmakefile | 10 | ||||
-rwxr-xr-x | src/libcrawler/Makefile.W32 | 6 | ||||
-rw-r--r-- | src/libcrawler/URL.cpp | 2 | ||||
-rw-r--r-- | src/libcrawler/libcrawler.cpp | 18 |
7 files changed, 39 insertions, 21 deletions
diff --git a/include/crawler/libcrawler.hpp b/include/crawler/libcrawler.hpp new file mode 100644 index 0000000..a615bc9 --- /dev/null +++ b/include/crawler/libcrawler.hpp @@ -0,0 +1,6 @@ +#ifndef __LIBCRAWLER_H +#define __LIBCRAWLER_H + +void initialize_libcrawler( void *user_data ); + +#endif diff --git a/src/crawl/GNUmakefile b/src/crawl/GNUmakefile index 5a9051a..cea25f5 100755 --- a/src/crawl/GNUmakefile +++ b/src/crawl/GNUmakefile @@ -36,10 +36,6 @@ endif ifeq ($(WITH_LUA),1) INCLUDE_CXXFLAGS += \ -DWITH_LUA - -INCLUDE_DIRS += \ - -I$(TOPDIR)/src/libcrawler \ - $(TOLUA_INCLUDES) endif CPP_OBJS = \ diff --git a/src/crawl/crawl.cpp b/src/crawl/crawl.cpp index 4abd37c..648060c 100755 --- a/src/crawl/crawl.cpp +++ b/src/crawl/crawl.cpp @@ -6,6 +6,7 @@ #include "URLNormalizer.hpp" #include "URLFilter.hpp" #include "TypeDetect.hpp" +#include "libcrawler.hpp" #include "ModuleLoader.hpp" @@ -55,18 +56,14 @@ BOOL WINAPI termHandler( DWORD ctrlType ) #endif -#ifdef WITH_LUA -// TODO: should be in the laoding function of libcrawl -#include "tolua.h" -#include "URLLua.hpp" -#endif - static int counter = 0; int main( int /* argc */, char *argv[] ) { try { LuaVM luaVm; + + initialize_libcrawler( (void *)&luaVm ); //Logger::instance( ).openConsoleLog( logDEBUG ); @@ -107,11 +104,6 @@ int main( int /* argc */, char *argv[] ) #endif ModuleLoader<URLNormalizer> urlNormalizers( normalizerModules, CLOSE_DEFERRED, (void *)&luaVm ); -#ifdef WITH_LUA - // TODO: should be in the laoding function of libcrawl - tolua_URL_open( luaVm.handle( ) ); -#endif - // initialize crawler function luaVm.executeFunction( "init" ); diff --git a/src/libcrawler/GNUmakefile b/src/libcrawler/GNUmakefile index d546058..e337c4f 100755 --- a/src/libcrawler/GNUmakefile +++ b/src/libcrawler/GNUmakefile @@ -4,7 +4,12 @@ SUBDIRS = -include $(TOPDIR)/makefiles/gmake/platform.mk -INCLUDE_CPPFLAGS = \ +INCLUDE_CXXFLAGS = \ + +ifeq ($(WITH_LUA),1) +INCLUDE_CXXFLAGS += \ + -DWITH_LUA +endif INCLUDE_LDFLAGS = \ @@ -43,7 +48,8 @@ DYNAMIC_LIB_PATCH = 0 CPP_OBJS = \ URL.o \ MIMEType.o \ - SpoolRewindInputStream.o + SpoolRewindInputStream.o \ + libcrawler.o ifeq ($(WITH_LUA),1) CPP_OBJS += \ diff --git a/src/libcrawler/Makefile.W32 b/src/libcrawler/Makefile.W32 index d3cd06c..716fef0 100755 --- a/src/libcrawler/Makefile.W32 +++ b/src/libcrawler/Makefile.W32 @@ -45,7 +45,8 @@ INCLUDE_LIBS = $(INCLUDE_LIBS) \ CPP_OBJS = \ URL.obj \ MIMEType.obj \ - SpoolRewindInputStream.obj + SpoolRewindInputStream.obj \ + libcrawler.obj !IFDEF WITH_LUA CPP_OBJS = $(CPP_OBJS) \ @@ -55,7 +56,8 @@ CPP_OBJS = $(CPP_OBJS) \ DYNAMIC_CPP_OBJS = \ URL.dllobj \ MIMEType.dllobj \ - SpoolRewindInputStream.dllobj + SpoolRewindInputStream.dllobj \ + libcrawler.dllobj !IFDEF WITH_LUA DYNAMIC_CPP_OBJS = $(DYNAMIC_CPP_OBJS) \ diff --git a/src/libcrawler/URL.cpp b/src/libcrawler/URL.cpp index f208500..6128edc 100644 --- a/src/libcrawler/URL.cpp +++ b/src/libcrawler/URL.cpp @@ -1,5 +1,3 @@ #include "URL.hpp" URL URL::Null; - - diff --git a/src/libcrawler/libcrawler.cpp b/src/libcrawler/libcrawler.cpp new file mode 100644 index 0000000..0c549a4 --- /dev/null +++ b/src/libcrawler/libcrawler.cpp @@ -0,0 +1,18 @@ +#include "libcrawler.hpp" + +#include <iostream> + +#ifdef WITH_LUA +#include "tolua.h" +#include "URLLua.hpp" +#include "LuaVM.hpp" +#endif + +void initialize_libcrawler( void *user_data ) +{ +#ifdef WITH_LUA + LuaVM *vm = (LuaVM *)user_data; + tolua_URL_open( vm->handle( ) ); +#endif +} + |