From 28324c16515de11bbc668ab6699eb651eb32bd27 Mon Sep 17 00:00:00 2001 From: kelson42 Date: Fri, 5 Apr 2013 23:47:31 +0200 Subject: [PATCH] + Was a unused jsctype prototype --- src/zimAccessor/Makefile | 9 - src/zimAccessor/ZimAccessorWrapper.cpp | 178 -------------------- src/zimAccessor/ZimAccessorWrapper.h | 31 ---- src/zimAccessor/zimAccessor.cpp | 220 ------------------------- src/zimAccessor/zimAccessor.h | 27 --- 5 files changed, 465 deletions(-) delete mode 100644 src/zimAccessor/Makefile delete mode 100644 src/zimAccessor/ZimAccessorWrapper.cpp delete mode 100644 src/zimAccessor/ZimAccessorWrapper.h delete mode 100644 src/zimAccessor/zimAccessor.cpp delete mode 100644 src/zimAccessor/zimAccessor.h diff --git a/src/zimAccessor/Makefile b/src/zimAccessor/Makefile deleted file mode 100644 index 37b14b3..0000000 --- a/src/zimAccessor/Makefile +++ /dev/null @@ -1,9 +0,0 @@ - -all: wrapperlib - -wrapperlib: - g++ -shared -o libZimCAccessor.so ZimAccessorWrapper.cpp zimAccessor.cpp ../common/kiwix/reader.cpp -I . -I ../zimAccessor/ -I ../common/ -I ../zimlib/include/ -L ../zimlib/src/.libs/ -lzim ../dependences/xz/src/liblzma/.libs/liblzma.a -I /usr/include/ - -clean: - find . -name 'libZimCAccessor.so' -delete - find . -name '*.o' -delete diff --git a/src/zimAccessor/ZimAccessorWrapper.cpp b/src/zimAccessor/ZimAccessorWrapper.cpp deleted file mode 100644 index 470f398..0000000 --- a/src/zimAccessor/ZimAccessorWrapper.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright 2011 Renaud Gaudin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ - -#include -#include -#include -#include "ZimAccessorWrapper.h" -#include "zimAccessor.h" - -/* creates instance of ZimAccessor */ -HZIMCLASS ZimAccessor_Create( void ) { - ZimAccessor * zimAccessor = new ZimAccessor(0); - - // Return its pointer (opaque) - return (HZIMCLASS)zimAccessor; -} - -/* Delete instance of ZimAccessor */ -void ZimAccessor_Destroy( HZIMCLASS h ) { - assert(h != NULL); - - // Convert from handle to ZimAccessor pointer - ZimAccessor * zimAccessor = (ZimAccessor *)h; - - delete zimAccessor; -} - -int ZimAccessor_LoadFile( HZIMCLASS h, char* zimPath) { - assert(h != NULL); - - ZimAccessor * zimAccessor = (ZimAccessor *)h; - - if (zimAccessor->LoadFile( zimPath )) - return true; - else - return false; -} - -/* Reset the cursor for GetNextArticle() */ -int ZimAccessor_Reset( HZIMCLASS h) { - assert(h != NULL); - - ZimAccessor * zimAccessor = (ZimAccessor *)h; - - if (zimAccessor->Reset()) - return true; - else - return false; -} - -/* Get the count of articles which can be indexed/displayed */ -unsigned int ZimAccessor_GetArticleCount( HZIMCLASS h) { - assert(h != NULL); - - ZimAccessor * zimAccessor = (ZimAccessor *)h; - - unsigned int count = 0; - zimAccessor->GetArticleCount(count); - return count; -} - -/* Return the UID of the ZIM file */ -const char* ZimAccessor_GetId( HZIMCLASS h) { - assert(h != NULL); - - ZimAccessor * zimAccessor = (ZimAccessor *)h; - - string id = ""; - zimAccessor->GetId(id); - return id.c_str(); -} - -/* Return a page url fronm title */ -const char* ZimAccessor_GetPageUrlFromTitle( HZIMCLASS h, char* title) { - assert(h != NULL); - - ZimAccessor * zimAccessor = (ZimAccessor *)h; - - string cptitle = string(title); - string url = ""; - zimAccessor->GetPageUrlFromTitle(cptitle, url); - return url.c_str(); -} - -/* Return the welcome page URL */ -const char* ZimAccessor_GetMainPageUrl( HZIMCLASS h ) { - assert(h != NULL); - - ZimAccessor * zimAccessor = (ZimAccessor *)h; - - string hp = ""; - zimAccessor->GetMainPageUrl( hp ); - return hp.c_str(); -} - -/* Get a metatag value */ -const char* ZimAccessor_GetMetatag( HZIMCLASS h, char* name) { - assert(h != NULL); - - ZimAccessor * zimAccessor = (ZimAccessor *)h; - - string cpname = string(name); - string value = ""; - zimAccessor->GetMetatag(cpname, value); - return value.c_str(); -} - -/* Get a content from a zim file */ -const char* ZimAccessor_GetContent(HZIMCLASS h, char* url) { - assert(h != NULL); - - ZimAccessor * zimAccessor = (ZimAccessor *)h; - - string cpurl = string(url); - string content = ""; - unsigned int contentLength = 0; - string contentType = ""; - zimAccessor->GetContent( cpurl, content, contentLength, contentType ); - return content.c_str(); -} - -/* Search titles by prefix*/ -unsigned int ZimAccessor_SearchSuggestions( HZIMCLASS h, char* prefix) { - assert(h != NULL); - - ZimAccessor * zimAccessor = (ZimAccessor *)h; - - string cpprefix = string(prefix); - unsigned int suggestionsCount; - zimAccessor->SearchSuggestions(cpprefix, suggestionsCount); - return suggestionsCount; -} - -/* Get next suggestion */ -const char* ZimAccessor_GetNextSuggestion( HZIMCLASS h ) { - assert(h != NULL); - - ZimAccessor * zimAccessor = (ZimAccessor *)h; - - string title = ""; - zimAccessor->GetNextSuggestion( title ); - return title.c_str(); -} - -/* Can I check the integrity - for old ZIM file without checksum */ -int ZimAccessor_CanCheckIntegrity( HZIMCLASS h ) { - assert(h != NULL); - - ZimAccessor * zimAccessor = (ZimAccessor *)h; - - return zimAccessor->CanCheckIntegrity(); -} - -/* Return true if corrupted, false otherwise */ -int ZimAccessor_IsCorrupted( HZIMCLASS h ) { - assert(h != NULL); - - ZimAccessor * zimAccessor = (ZimAccessor *)h; - - return zimAccessor->IsCorrupted(); -} - diff --git a/src/zimAccessor/ZimAccessorWrapper.h b/src/zimAccessor/ZimAccessorWrapper.h deleted file mode 100644 index a1a614f..0000000 --- a/src/zimAccessor/ZimAccessorWrapper.h +++ /dev/null @@ -1,31 +0,0 @@ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -typedef void * HZIMCLASS; - -HZIMCLASS ZimAccessor_Create( void ); - -void ZimAccessor_Destroy( HZIMCLASS h ); - -int ZimAccessor_LoadFile( HZIMCLASS h, char* zimPath ); -int ZimAccessor_Reset( HZIMCLASS h ); -unsigned int ZimAccessor_GetArticleCount( HZIMCLASS h ); -const char* ZimAccessor_GetId( HZIMCLASS h ); -const char* ZimAccessor_GetPageUrlFromTitle( HZIMCLASS h, char* url); -const char* ZimAccessor_GetMainPageUrl( HZIMCLASS h ); -const char* ZimAccessor_GetMetatag( HZIMCLASS h, char* name); -const char* ZimAccessor_GetContent( HZIMCLASS h, char* url); -unsigned int ZimAccessor_SearchSuggestions( HZIMCLASS h, char* prefix); -const char* ZimAccessor_GetNextSuggestion( HZIMCLASS h ); -int ZimAccessor_CanCheckIntegrity( HZIMCLASS h ); -int ZimAccessor_IsCorrupted( HZIMCLASS h ); - -#ifdef __cplusplus -}; -#endif diff --git a/src/zimAccessor/zimAccessor.cpp b/src/zimAccessor/zimAccessor.cpp deleted file mode 100644 index 4f79dc2..0000000 --- a/src/zimAccessor/zimAccessor.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright 2011 Renaud Gaudin - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301, USA. - */ - -#include -#include -#include -#include -#include "zimAccessor.h" - -ZimAccessor::ZimAccessor(int x) : reader(NULL) {} - -bool ZimAccessor::LoadFile(string path) { - try { - this->reader = new kiwix::Reader(path); - } catch (exception &e) { - cerr << e.what() << endl; - return false; - } - return true; -} - -/* Reset the cursor for GetNextArticle() */ -bool ZimAccessor::Reset() { - try { - this->reader->reset(); - } catch (exception &e) { - cerr << e.what() << endl; - return false; - } - return true; -} - -/* Get the count of articles which can be indexed/displayed */ -bool ZimAccessor::GetArticleCount(unsigned int &count) { - try { - if (this->reader != NULL) { - count = this->reader->getArticleCount(); - return true; - } - } catch (exception &e) { - cerr << e.what() << endl; - return false; - } - return false; -} - -/* Return the UID of the ZIM file */ -bool ZimAccessor::GetId(string &id) { - try { - if (this->reader != NULL) { - id = this->reader->getId().c_str(); - return true; - } - } catch (exception &e) { - cerr << e.what() << endl; - } - - return false; -} - -/* Return a page url fronm title */ -bool ZimAccessor::GetPageUrlFromTitle(const string &title, string &url) { - string urlstr; - - try { - if (this->reader != NULL) { - if (this->reader->getPageUrlFromTitle(title.c_str(), urlstr)) { - url = urlstr.c_str(); - return true; - } - } - } catch (exception &e) { - cerr << e.what() << endl; - return false; - } - return false; -} - -/* Return the welcome page URL */ -bool ZimAccessor::GetMainPageUrl(string &url) { - try { - if (this->reader != NULL) { - string urlstr = this->reader->getMainPageUrl(); - - url = urlstr.c_str(); - return true; - } - } catch (exception &e) { - cerr << e.what() << endl; - return false; - } - - return false; -} - -/* Get a metatag value */ -bool ZimAccessor::GetMetatag(const string &name, string &value) { - string valueStr; - - try { - if (this->reader != NULL) { - if (this->reader->getMetatag(name.c_str(), valueStr)) { - value = valueStr.data(); - return true; - } - } - } catch (exception &e) { - cerr << e.what() << endl; - return false; - } - - return false; -} - -/* Get a content from a zim file */ -bool ZimAccessor::GetContent(string url, string &content, unsigned int &contentLength, string &contentType) { - - /* strings */ - string contentStr; - string contentTypeStr; - unsigned int contentLengthInt; - - /* default value */ - content = ""; - contentLength = 0; - - try { - if (this->reader != NULL) { - if (this->reader->getContentByUrl(url, contentStr, contentLength, contentTypeStr)) { - contentType = contentTypeStr.data(); - content = contentStr.data(); - return true; - } - } - } catch (exception &e) { - cerr << e.what() << endl; - return false; - } - - return true; -} - -/* Search titles by prefix*/ -bool ZimAccessor::SearchSuggestions(const string &prefix, unsigned int suggestionsCount) { - try { - if (this->reader != NULL) { - if (this->reader->searchSuggestions(prefix.c_str(), suggestionsCount)) { - return true; - } - } - } catch (exception &e) { - cerr << e.what() << endl; - return false; - } - - return false; -} - -/* Get next suggestion */ -bool ZimAccessor::GetNextSuggestion(string &title) { - string titleStr; - - try { - if (this->reader != NULL) { - if (this->reader->getNextSuggestion(titleStr)) { - title = titleStr.c_str(); - return true; - } - } - } catch (exception &e) { - cerr << e.what() << endl; - return false; - } - - return false; -} - -/* Can I check the integrity - for old ZIM file without checksum */ -bool ZimAccessor::CanCheckIntegrity() { - try { - if (this->reader != NULL) { - return this->reader->canCheckIntegrity(); - } - } catch (exception &e) { - cerr << e.what() << endl; - return false; - } - - return false; -} - -/* Return true if corrupted, false otherwise */ -bool ZimAccessor::IsCorrupted() { - try { - if (this->reader != NULL) { - return this->reader->isCorrupted(); - } - } catch (exception &e) { - cerr << e.what() << endl; - return true; - } - - return true; -} diff --git a/src/zimAccessor/zimAccessor.h b/src/zimAccessor/zimAccessor.h deleted file mode 100644 index aea211a..0000000 --- a/src/zimAccessor/zimAccessor.h +++ /dev/null @@ -1,27 +0,0 @@ - -#include -#include -#include -#include - -class ZimAccessor -{ - public: - ZimAccessor(int); - bool LoadFile(string); - bool GetArticleCount(unsigned int&); - bool Reset(); - bool GetId(string&); - bool GetPageUrlFromTitle(const string &, string &); - bool GetMainPageUrl(string &); - bool GetMetatag(const string &, string &); - // WARNING: previous API expected an nsIURI instead of string - bool GetContent(string, string &, unsigned int &, string &); - bool SearchSuggestions(const string &, unsigned int); - bool GetNextSuggestion(string &); - bool CanCheckIntegrity(); - bool IsCorrupted(); - - public: - kiwix::Reader *reader; -};