forked from goldendict/goldendict
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Aard dictionaries (aar-html)
- Loading branch information
Showing
9 changed files
with
1,034 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* This file is (c) 2008-2012 Konstantin Isakov <[email protected]> | ||
* Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ | ||
|
||
#ifndef __AARD_HH_INCLUDED__ | ||
#define __AARD_HH_INCLUDED__ | ||
|
||
#include "dictionary.hh" | ||
|
||
/// Support for the aard dictionaries. | ||
namespace Aard { | ||
|
||
using std::vector; | ||
using std::string; | ||
|
||
vector< sptr< Dictionary::Class > > makeDictionaries( | ||
vector< string > const & fileNames, | ||
string const & indicesDir, | ||
Dictionary::Initializing & ) | ||
throw( std::exception ); | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include <stdlib.h> | ||
|
||
#include "decompress.hh" | ||
#include "zlib.h" | ||
#include "bzlib.h" | ||
|
||
string decompressZlib( char * bufptr, unsigned length ) | ||
{ | ||
z_stream zs; | ||
char buf[2048]; | ||
string str; | ||
int res; | ||
memset( &zs, 0, sizeof(zs) ); | ||
zs.next_in = (Bytef *)bufptr; | ||
zs.avail_in = length; | ||
while( 1 ) | ||
{ | ||
res = inflateInit( &zs ); | ||
if( res != Z_OK ) | ||
break; | ||
while( res != Z_STREAM_END ) | ||
{ | ||
memset( buf, 0, sizeof(buf) ); | ||
zs.next_out = (Bytef *)buf; | ||
zs.avail_out = 2047; | ||
res = inflate( &zs, Z_SYNC_FLUSH ); | ||
str += buf; | ||
if( res != Z_OK && res != Z_STREAM_END ) | ||
break; | ||
} | ||
break; | ||
} | ||
inflateEnd( &zs ); | ||
if( res != Z_STREAM_END ) | ||
str.clear(); | ||
return str; | ||
} | ||
|
||
string decompressBzip2( char * bufptr, unsigned length ) | ||
{ | ||
bz_stream zs; | ||
char buf[2048]; | ||
string str; | ||
int res; | ||
memset( &zs, 0, sizeof(zs) ); | ||
zs.next_in = bufptr; | ||
zs.avail_in = length; | ||
zs.total_in_lo32 = length; | ||
while( 1 ) | ||
{ | ||
res = BZ2_bzDecompressInit( &zs, 0, 0 ); | ||
if( res != BZ_OK ) | ||
break; | ||
while( res != BZ_STREAM_END ) | ||
{ | ||
memset( buf, 0, sizeof(buf) ); | ||
zs.next_out = buf; | ||
zs.avail_out = 2047; | ||
zs.total_out_lo32 = length; | ||
res = BZ2_bzDecompress( &zs ); | ||
str += buf; | ||
if( res != BZ_OK && res != BZ_STREAM_END ) | ||
break; | ||
} | ||
break; | ||
} | ||
BZ2_bzDecompressEnd( &zs ); | ||
if( res != BZ_STREAM_END ) | ||
str.clear(); | ||
return str; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef __DECOMPRESS_HH_INCLUDED__ | ||
#define __DECOMPRESS_HH_INCLUDED__ | ||
|
||
#include <string> | ||
|
||
using std::string; | ||
|
||
string decompressZlib( char * bufptr, unsigned length ); | ||
|
||
string decompressBzip2( char * bufptr, unsigned length ); | ||
|
||
#endif // DECOMPRESS_HH |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters