mirror of
https://github.com/kiwix/kiwix-tools.git
synced 2025-09-24 21:06:42 -04:00
updated zimAccessor lib and JS module
This commit is contained in:
parent
0308b2aea8
commit
eba1b0ce84
@ -52,6 +52,52 @@ int ZimAccessor_LoadFile( HZIMCLASS h, char* zimPath) {
|
||||
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);
|
||||
@ -63,6 +109,18 @@ const char* ZimAccessor_GetMainPageUrl( HZIMCLASS h ) {
|
||||
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);
|
||||
@ -76,3 +134,45 @@ const char* ZimAccessor_GetContent(HZIMCLASS h, char* url) {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,17 @@ 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
|
||||
};
|
||||
|
@ -46,7 +46,7 @@ int main(int argc, char* argv[])
|
||||
|
||||
char * url = "A/Lugha.html";
|
||||
const char* content;
|
||||
content = ZimAccessor_GetContent( zimA, url );
|
||||
content = ZimAccessor_GetContent( zimA, hp );
|
||||
|
||||
printf("%s", content);
|
||||
|
||||
|
@ -70,7 +70,7 @@ int main(int argc, char* argv[])
|
||||
unsigned int contentLength;
|
||||
string contentType;
|
||||
string req = "A/Lugha.html";
|
||||
zima->GetContent(req, content, contentLength, contentType);
|
||||
zima->GetContent(homepage, content, contentLength, contentType);
|
||||
cout << content << endl;
|
||||
cout << contentType << endl;
|
||||
cout << contentLength << endl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user