1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-04 10:19:33 +02:00

new icon set

native unzip
new build script



git-svn-id: https://only.mawhrin.net/repos/FBReaderJ/trunk@990 6a642e6f-84f6-412e-ac94-c4a38d5a04b0
This commit is contained in:
Nikolay Pultsin 2009-06-30 08:11:39 +00:00
parent dfece0b383
commit b6970e1dc9
82 changed files with 735 additions and 369 deletions

View file

@ -0,0 +1,71 @@
#include <jni.h>
#include <string.h>
#include <zlib.h>
#include <new>
#define SIZE 10
static jobject keys[SIZE] = { 0 };
static z_stream* values[SIZE] = { 0 };
extern "C"
jboolean Java_org_amse_ys_zip_NativeDeflatingDecompressor_startInflating(JNIEnv *env, jobject thiz) {
int i;
for (i = 0; i < SIZE; ++i) {
if (keys[i] == 0) {
keys[i] = thiz;
values[i] = new z_stream;
memset(values[i], 0, sizeof(z_stream));
inflateInit2(values[i], -MAX_WBITS);
return 1;
}
}
return 0;
}
extern "C"
void Java_org_amse_ys_zip_NativeDeflatingDecompressor_endInflating(JNIEnv *env, jobject thiz) {
int i;
for (i = 0; i < SIZE; ++i) {
if (keys[i] == thiz) {
keys[i] = 0;
inflateEnd(values[i]);
delete values[i];
values[i] = 0;
break;
}
}
}
// returns ((used inLength) << 16) + utLength
extern "C"
jint Java_org_amse_ys_zip_NativeDeflatingDecompressor_inflate(JNIEnv *env, jobject thiz, jbyteArray in, jint inOffset, jint inLength, jbyteArray out) {
int i;
z_stream *stream = 0;
for (i = 0; i < SIZE; ++i) {
if (keys[i] == thiz) {
stream = values[i];
break;
}
}
if (stream == 0) {
return 0;
}
jbyte* inStart = env->GetByteArrayElements(in, 0);
jbyte* outStart = env->GetByteArrayElements(out, 0);
stream->next_in = (Bytef*)inStart + inOffset;
stream->avail_in = inLength;
stream->next_out = (Bytef*)outStart;
const int outLength = env->GetArrayLength(out);
stream->avail_out = outLength;
int code = inflate(stream, Z_SYNC_FLUSH);
env->ReleaseByteArrayElements(in, inStart, 0);
env->ReleaseByteArrayElements(out, outStart, 0);
if ((code == Z_OK) || (code == Z_STREAM_END)) {
return ((inLength - stream->avail_in) << 16) + outLength - stream->avail_out;
}
return 0;
}