Debian Codegraph @

Source/clzma.h

raw
1 /*
2 * clzma.h
3 *
4 * This file is a part of NSIS.
5 *
6 * Copyright (C) 1999-2026 Nullsoft and Contributors
7 *
8 * Licensed under the zlib/libpng license (the "License");
9 * you may not use this file except in compliance with the License.
10 *
11 * Licence details can be found in the file COPYING.
12 *
13 * This software is provided 'as-is', without any express or implied
14 * warranty.
15 *
16 * Unicode support by Jim Park -- 08/24/2007
17 */
18
19 #ifndef __CLZMA_H__
20 #define __CLZMA_H__
21
22 #include "Platform.h"
23
24 #ifndef _WIN32
25 # include <pthread.h>
26 #endif
27
28 #include "compressor.h"
29 #include "7zip/7zip/IStream.h"
30 #include "7zip/7zip/Compress/LZMA/LZMAEncoder.h"
31 #include "7zip/Common/MyCom.h"
32 #include "7zip/Common/Defs.h"
33
34 #define LZMA_BAD_CALL -1
35 #define LZMA_INIT_ERROR -2
36 #define LZMA_THREAD_ERROR -3
37 #define LZMA_IO_ERROR -4
38 #define LZMA_MEM_ERROR -5
39
40 class CLZMA:
41 public ICompressor,
42 public ISequentialInStream,
43 public ISequentialOutStream,
44 public CMyUnknownImp
45 {
46 private:
47 NCompress::NLZMA::CEncoder *_encoder;
48
49 #ifdef _WIN32
50 HANDLE hCompressionThread;
51 #else
52 pthread_t hCompressionThread;
53 #endif
54 HANDLE hNeedIOEvent;
55 HANDLE hIOReadyEvent;
56
57 BYTE *next_in; /* next input byte */
58 UINT avail_in; /* number of bytes available at next_in */
59
60 BYTE *next_out; /* next output byte should be put there */
61 UINT avail_out; /* remaining free space at next_out */
62
63 int res;
64
65 BOOL finish;
66 BOOL compressor_finished;
67
68 int ConvertError(HRESULT result);
69
70 void GetMoreIO();
71 int CompressReal();
72
73 #ifdef _WIN32
74 static DWORD WINAPI lzmaCompressThread(LPVOID lpParameter);
75 #else
76 static void* lzmaCompressThread(void *lpParameter);
77 #endif
78
79 public:
80 MY_UNKNOWN_IMP
81
82 CLZMA();
83 virtual ~CLZMA();
84
85 virtual int Init(int level, unsigned int dicSize);
86 virtual int End();
87 virtual int Compress(bool flush);
88
89 STDMETHOD(Read)(void *data, UINT32 size, UINT32 *processedSize);
90 STDMETHOD(ReadPart)(void *data, UINT32 size, UINT32 *processedSize);
91 STDMETHOD(Write)(const void *data, UINT32 size, UINT32 *processedSize);
92 STDMETHOD(WritePart)(const void *data, UINT32 size, UINT32 *processedSize);
93
94 virtual void SetNextIn(char *in, unsigned int size);
95 virtual void SetNextOut(char *out, unsigned int size);
96
97 virtual char *GetNextOut();
98 virtual unsigned int GetAvailIn();
99 virtual unsigned int GetAvailOut();
100 virtual const TCHAR *GetName();
101
102 virtual const TCHAR* GetErrStr(int err);
103 };
104
105 #endif