From 264fc8e0d4243b36f9af8ddc635360a4dae71b59 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Mon, 18 Jan 2010 14:49:14 +0000 Subject: [PATCH] + divers improv. --- src/server/kiwix-serve.cpp | 41 +++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/src/server/kiwix-serve.cpp b/src/server/kiwix-serve.cpp index da354f8..02c0645 100644 --- a/src/server/kiwix-serve.cpp +++ b/src/server/kiwix-serve.cpp @@ -16,7 +16,7 @@ using namespace std; -zim::File* zimFileHandler; +static zim::File* zimFileHandler; static int accessHandlerCallback(void *cls, struct MHD_Connection * connection, @@ -41,12 +41,10 @@ static int accessHandlerCallback(void *cls, /* Prepare the variable */ zim::Article article; struct MHD_Response * response; - //const char *page = (char*)cls; - const char *content; + string content; + string mimeType; unsigned int contentLength = 0; - const char *mimeType; - string mimeTypeModified = ""; - + /* Prepare the url */ unsigned int urlLength = strlen(url); unsigned int offset = 0; @@ -78,12 +76,13 @@ static int accessHandlerCallback(void *cls, title[titleOffset] = 0; /* Load the article from the ZIM file */ - cout << "Loading '" << title << "' in namespace '" << ns << "'" << endl; + cout << "Loading '" << title << "' in namespace '" << ns << "'... " << endl; try { std::pair resultPair = zimFileHandler->findx(ns[0], title); /* Test if the article was found */ if (resultPair.first == true) { + cout << ns << "/" << title << " found." << endl; /* Get the article */ zim::Article article = zimFileHandler->getArticle(resultPair.second.getIndex()); @@ -95,24 +94,27 @@ static int accessHandlerCallback(void *cls, } /* Get the content */ - content = article.getData().data(); contentLength = article.getArticleSize(); - + content = string(article.getData().data(), article.getArticleSize()); + cout << "content size: " << contentLength << endl; + /* Get the content mime-type */ - mimeType = article.getMimeType().data(); - unsigned int mimeTypeLength = strlen(mimeType); - for (int i=0; i