diff options
Diffstat (limited to 'addon/doxysearch')
-rw-r--r-- | addon/doxysearch/CMakeLists.txt | 11 | ||||
-rw-r--r-- | addon/doxysearch/doxyindexer.cpp | 13 | ||||
-rw-r--r-- | addon/doxysearch/doxysearch.cpp | 44 |
3 files changed, 52 insertions, 16 deletions
diff --git a/addon/doxysearch/CMakeLists.txt b/addon/doxysearch/CMakeLists.txt index 459d17a..d0c8724 100644 --- a/addon/doxysearch/CMakeLists.txt +++ b/addon/doxysearch/CMakeLists.txt @@ -6,8 +6,9 @@ if (WIN32) endif() include_directories( - ${PROJECT_SOURCE_DIR}/qtools - ${XAPIAN_INCLUDE_DIR} + ${PROJECT_SOURCE_DIR}/libversion + ${PROJECT_SOURCE_DIR}/qtools + ${XAPIAN_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS} ) add_executable(doxyindexer @@ -16,8 +17,9 @@ add_executable(doxyindexer target_link_libraries(doxyindexer ${XAPIAN_LIBRARIES} ${ZLIB_LIBRARIES} - ${WIN_EXTRA_LIBS} + ${WIN_EXTRA_LIBS} ${COVERAGE_LINKER_FLAGS} + doxygen_version qtools ) @@ -25,9 +27,10 @@ add_executable(doxysearch.cgi doxysearch.cpp ) target_link_libraries(doxysearch.cgi + doxygen_version ${XAPIAN_LIBRARIES} ${ZLIB_LIBRARIES} - ${WIN_EXTRA_LIBS} + ${WIN_EXTRA_LIBS} ) install(TARGETS doxyindexer doxysearch.cgi DESTINATION bin) diff --git a/addon/doxysearch/doxyindexer.cpp b/addon/doxysearch/doxyindexer.cpp index cd31b3d..ae4e046 100644 --- a/addon/doxysearch/doxyindexer.cpp +++ b/addon/doxysearch/doxyindexer.cpp @@ -30,6 +30,8 @@ // Xapian include #include <xapian.h> +#include "version.h" + #define MAX_TERM_LENGTH 245 #if defined(_WIN32) && !defined(__CYGWIN__) @@ -303,10 +305,10 @@ class XMLErrorHandler : public QXmlErrorHandler QString errorMsg; }; -static void usage(const char *name) +static void usage(const char *name, int exitVal = 1) { std::cerr << "Usage: " << name << " [-o output_dir] searchdata.xml [searchdata2.xml ...]" << std::endl; - exit(1); + exit(exitVal); } /** main function to index data */ @@ -340,7 +342,12 @@ int main(int argc,const char **argv) } else if (std::string(argv[i])=="-h" || std::string(argv[i])=="--help") { - usage(argv[0]); + usage(argv[0],0); + } + else if (std::string(argv[i])=="-v" || std::string(argv[i])=="--version") + { + std::cerr << argv[0] << " version: " << getFullVersion() << std::endl; + exit(0); } } diff --git a/addon/doxysearch/doxysearch.cpp b/addon/doxysearch/doxysearch.cpp index 4c4dc72..26517bd 100644 --- a/addon/doxysearch/doxysearch.cpp +++ b/addon/doxysearch/doxysearch.cpp @@ -27,6 +27,8 @@ // Xapian includes #include <xapian.h> +#include "version.h" + #ifdef _WIN32 #include <windows.h> #else @@ -306,31 +308,55 @@ static void showError(const std::string &callback,const std::string &error) exit(0); } +static void usage(const char *name, int exitVal = 1) +{ + std::cerr << "Usage: " << name << "[query_string]" << std::endl; + std::cerr << " " << "alternatively the query string can be given by the environment variable QUERY_STRING" << std::endl; + exit(exitVal); +} + /** Main routine */ int main(int argc,char **argv) { // process inputs that were passed to us via QUERY_STRING - std::cout << "Content-Type:application/javascript;charset=utf-8\r\n\n"; std::string callback; try { - // get input parameters - const char *queryEnv = getenv("QUERY_STRING"); std::string queryString; - if (queryEnv) + if (argc == 1) { - queryString = queryEnv; + const char *queryEnv = getenv("QUERY_STRING"); + if (queryEnv) + { + queryString = queryEnv; + } + else + { + usage(argv[0]); + } } - else if (argc>=2) + else if (argc == 2) { - queryString = argv[1]; + if (std::string(argv[1])=="-h" || std::string(argv[1])=="--help") + { + usage(argv[0],0); + } + else if (std::string(argv[1])=="-v" || std::string(argv[1])=="--version") + { + std::cerr << argv[0] << " version: " << getFullVersion() << std::endl; + exit(0); + } + else + { + queryString = argv[1]; + } } else { - std::cout << "No input!\n"; - exit(1); + usage(argv[0]); } + std::cout << "Content-Type:application/javascript;charset=utf-8\r\n\n"; // parse query string std::vector<std::string> parts = split(queryString,'&'); std::string searchFor,callback; |