From 156a482d3ba71f361a5a092390b3c3c36f58ac7e Mon Sep 17 00:00:00 2001 From: kelson42 Date: Sat, 9 Apr 2011 11:10:07 +0000 Subject: [PATCH] + small fix in kiwix-serve after the template engine integration --- src/server/kiwix-serve.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index d905ae7..8353076 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -232,8 +232,6 @@ static int accessHandlerCallback(void *cls, unsigned int startNumber = 0; unsigned int endNumber = 25; - cout << "---" << start << endl; - if (start != NULL) startNumber = atoi(start); @@ -353,8 +351,8 @@ static int accessHandlerCallback(void *cls, int main(int argc, char **argv) { struct MHD_Daemon *daemon; string zimPath = ""; - string indexPath = ""; + char rootPath[PATH_MAX]; int serverPort = 80; int daemonFlag = false; @@ -408,10 +406,6 @@ int main(int argc, char **argv) { void *page; - /* Chnage the current dir to binary dir */ - const char* currentDirectory = dirname(argv[0]); - chdir(currentDirectory); - /* Instanciate the ZIM file handler */ try { reader = new kiwix::Reader(zimPath); @@ -431,10 +425,14 @@ int main(int argc, char **argv) { cerr << "Unable to open the search index '" << zimPath << "' with the XapianSearcher." << endl; } + /* Change the current dir to binary dir */ + /* Non portable linux solution */ + readlink("/proc/self/exe", rootPath, PATH_MAX); + chdir(dirname(rootPath)); + /* Try to load the result template */ try { fstream templateStream; - char rootPath[PATH_MAX]; templateStream.open("../share/kiwix/static/results.tmpl", ifstream::in); if (templateStream.fail()) {