174c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes/* 257995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson * Licensed to the Apache Software Foundation (ASF) under one or more 357995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson * contributor license agreements. See the NOTICE file distributed with 457995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson * this work for additional information regarding copyright ownership. 557995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson * The ASF licenses this file to You under the Apache License, Version 2.0 657995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson * (the "License"); you may not use this file except in compliance with 757995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson * the License. You may obtain a copy of the License at 874c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes * 957995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson * http://www.apache.org/licenses/LICENSE-2.0 1074c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes * 1157995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson * Unless required by applicable law or agreed to in writing, software 1257995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson * distributed under the License is distributed on an "AS IS" BASIS, 1357995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1457995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson * See the License for the specific language governing permissions and 1557995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson * limitations under the License. 1657995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson */ 1757995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson 183aac4ddc4d17c07fa8b4908069d23d5401a77993Elliott Hughes#ifndef ZIP_UTILITIES_H_included 193aac4ddc4d17c07fa8b4908069d23d5401a77993Elliott Hughes#define ZIP_UTILITIES_H_included 2057995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson 215ccb2b3621f633708eb3ae1fd0f27f88bdb32a9dNarayan Kamath#include <cstdint> 22b3aacde3d8af759ee4a7b395c636ea360547d92dIan Rogers#include <memory> 2374c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes#include "jni.h" 2474c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes#include "zlib.h" 2557995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson 2674c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughesclass NativeZipStream { 2774c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughespublic: 28b3aacde3d8af759ee4a7b395c636ea360547d92dIan Rogers std::unique_ptr<jbyte[]> input; 2974c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes int inCap; 3074c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes z_stream stream; 315ccb2b3621f633708eb3ae1fd0f27f88bdb32a9dNarayan Kamath uint64_t totalIn; 325ccb2b3621f633708eb3ae1fd0f27f88bdb32a9dNarayan Kamath uint64_t totalOut; 3357995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson 342e6a64542c52490d89476bfd1b10b1938a8a0e99Kenny Root NativeZipStream(); 352e6a64542c52490d89476bfd1b10b1938a8a0e99Kenny Root ~NativeZipStream(); 362e6a64542c52490d89476bfd1b10b1938a8a0e99Kenny Root void setDictionary(JNIEnv* env, jbyteArray javaDictionary, int off, int len, bool inflate); 372e6a64542c52490d89476bfd1b10b1938a8a0e99Kenny Root void setInput(JNIEnv* env, jbyteArray buf, jint off, jint len); 3874c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes 3974c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughesprivate: 40b3aacde3d8af759ee4a7b395c636ea360547d92dIan Rogers std::unique_ptr<jbyte[]> mDict; 4174c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes 4274c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes // Disallow copy and assignment. 4374c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes NativeZipStream(const NativeZipStream&); 4474c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes void operator=(const NativeZipStream&); 4574c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes}; 4674c05e2a892f236c8648af7f4cfb2bcb483f267bElliott Hughes 472e6a64542c52490d89476bfd1b10b1938a8a0e99Kenny RootNativeZipStream* toNativeZipStream(jlong address); 482e6a64542c52490d89476bfd1b10b1938a8a0e99Kenny Root 492e6a64542c52490d89476bfd1b10b1938a8a0e99Kenny Rootvoid throwExceptionForZlibError(JNIEnv* env, const char* exceptionClassName, int error, 502e6a64542c52490d89476bfd1b10b1938a8a0e99Kenny Root NativeZipStream* stream); 5157995e8186b54515d5a03bf2ab104c3dc247f1b6Jesse Wilson 523aac4ddc4d17c07fa8b4908069d23d5401a77993Elliott Hughes#endif // ZIP_UTILITIES_H_included 53