2006-10-28 19:45:02 +00:00
|
|
|
/*
|
|
|
|
* clzma.h
|
|
|
|
*
|
|
|
|
* This file is a part of NSIS.
|
|
|
|
*
|
2009-02-01 14:44:30 +00:00
|
|
|
* Copyright (C) 1999-2009 Nullsoft and Contributors
|
2006-10-28 19:45:02 +00:00
|
|
|
*
|
|
|
|
* Licensed under the zlib/libpng license (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
*
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* This software is provided 'as-is', without any express or implied
|
|
|
|
* warranty.
|
2010-03-24 17:22:56 +00:00
|
|
|
*
|
|
|
|
* Unicode support by Jim Park -- 08/24/2007
|
2006-10-28 19:45:02 +00:00
|
|
|
*/
|
|
|
|
|
2003-11-24 00:08:58 +00:00
|
|
|
#ifndef __CLZMA_H__
|
|
|
|
#define __CLZMA_H__
|
|
|
|
|
2004-10-10 20:58:33 +00:00
|
|
|
#include "Platform.h"
|
|
|
|
|
2004-10-01 11:18:07 +00:00
|
|
|
#ifndef _WIN32
|
|
|
|
# include <pthread.h>
|
|
|
|
#endif
|
|
|
|
|
2003-11-24 00:08:58 +00:00
|
|
|
#include "compressor.h"
|
|
|
|
#include "7zip/7zip/IStream.h"
|
|
|
|
#include "7zip/7zip/Compress/LZMA/LZMAEncoder.h"
|
|
|
|
#include "7zip/Common/MyCom.h"
|
2004-05-08 17:40:29 +00:00
|
|
|
#include "7zip/Common/Defs.h"
|
2003-11-24 00:08:58 +00:00
|
|
|
|
2004-05-08 17:40:29 +00:00
|
|
|
#define LZMA_BAD_CALL -1
|
|
|
|
#define LZMA_INIT_ERROR -2
|
|
|
|
#define LZMA_THREAD_ERROR -3
|
|
|
|
#define LZMA_IO_ERROR -4
|
|
|
|
#define LZMA_MEM_ERROR -5
|
|
|
|
|
2003-11-26 20:27:36 +00:00
|
|
|
class CLZMA:
|
|
|
|
public ICompressor,
|
2003-11-24 00:08:58 +00:00
|
|
|
public ISequentialInStream,
|
|
|
|
public ISequentialOutStream,
|
2003-11-26 20:27:36 +00:00
|
|
|
public CMyUnknownImp
|
2003-11-24 00:08:58 +00:00
|
|
|
{
|
2003-11-26 20:27:36 +00:00
|
|
|
private:
|
|
|
|
NCompress::NLZMA::CEncoder *_encoder;
|
2003-11-24 00:08:58 +00:00
|
|
|
|
2004-03-29 20:21:00 +00:00
|
|
|
#ifdef _WIN32
|
2003-11-26 20:27:36 +00:00
|
|
|
HANDLE hCompressionThread;
|
2004-03-29 20:21:00 +00:00
|
|
|
#else
|
|
|
|
pthread_t hCompressionThread;
|
|
|
|
#endif
|
2004-05-01 19:44:06 +00:00
|
|
|
HANDLE hNeedIOEvent;
|
|
|
|
HANDLE hIOReadyEvent;
|
2003-11-26 20:27:36 +00:00
|
|
|
|
|
|
|
BYTE *next_in; /* next input byte */
|
|
|
|
UINT avail_in; /* number of bytes available at next_in */
|
|
|
|
|
|
|
|
BYTE *next_out; /* next output byte should be put there */
|
|
|
|
UINT avail_out; /* remaining free space at next_out */
|
|
|
|
|
|
|
|
int res;
|
|
|
|
|
|
|
|
BOOL finish;
|
|
|
|
BOOL compressor_finished;
|
2003-11-24 00:08:58 +00:00
|
|
|
|
2004-10-10 20:58:33 +00:00
|
|
|
int ConvertError(HRESULT result);
|
2004-03-29 20:21:00 +00:00
|
|
|
|
2004-10-10 20:58:33 +00:00
|
|
|
void GetMoreIO();
|
|
|
|
int CompressReal();
|
2004-03-29 20:21:00 +00:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
2004-10-10 20:58:33 +00:00
|
|
|
static DWORD WINAPI lzmaCompressThread(LPVOID lpParameter);
|
2004-03-29 20:21:00 +00:00
|
|
|
#else
|
2004-10-10 20:58:33 +00:00
|
|
|
static void* lzmaCompressThread(void *lpParameter);
|
2004-03-29 20:21:00 +00:00
|
|
|
#endif
|
2003-11-26 20:27:36 +00:00
|
|
|
|
2004-10-10 20:58:33 +00:00
|
|
|
public:
|
|
|
|
MY_UNKNOWN_IMP
|
2003-11-26 20:27:36 +00:00
|
|
|
|
2004-10-10 20:58:33 +00:00
|
|
|
CLZMA();
|
|
|
|
virtual ~CLZMA();
|
2003-11-26 20:27:36 +00:00
|
|
|
|
2004-10-11 14:26:13 +00:00
|
|
|
virtual int Init(int level, unsigned int dicSize);
|
2004-10-10 20:58:33 +00:00
|
|
|
virtual int End();
|
|
|
|
virtual int Compress(bool flush);
|
2003-11-26 20:27:36 +00:00
|
|
|
|
2004-10-10 20:58:33 +00:00
|
|
|
STDMETHOD(Read)(void *data, UINT32 size, UINT32 *processedSize);
|
|
|
|
STDMETHOD(ReadPart)(void *data, UINT32 size, UINT32 *processedSize);
|
|
|
|
STDMETHOD(Write)(const void *data, UINT32 size, UINT32 *processedSize);
|
|
|
|
STDMETHOD(WritePart)(const void *data, UINT32 size, UINT32 *processedSize);
|
2003-11-26 20:27:36 +00:00
|
|
|
|
2004-10-10 20:58:33 +00:00
|
|
|
virtual void SetNextIn(char *in, unsigned int size);
|
|
|
|
virtual void SetNextOut(char *out, unsigned int size);
|
2003-11-26 20:27:36 +00:00
|
|
|
|
2004-10-10 20:58:33 +00:00
|
|
|
virtual char *GetNextOut();
|
|
|
|
virtual unsigned int GetAvailIn();
|
|
|
|
virtual unsigned int GetAvailOut();
|
2010-03-24 17:22:56 +00:00
|
|
|
virtual const TCHAR *GetName();
|
2004-05-08 17:40:29 +00:00
|
|
|
|
2010-03-24 17:22:56 +00:00
|
|
|
virtual const TCHAR* GetErrStr(int err);
|
2003-11-24 00:08:58 +00:00
|
|
|
};
|
|
|
|
|
2004-03-12 20:43:54 +00:00
|
|
|
#endif
|