Merging upstream version 1.4~rc1.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
ef8a63ecab
commit
be19348aea
29 changed files with 4714 additions and 5971 deletions
240
7zFile.c
240
7zFile.c
|
@ -1,240 +0,0 @@
|
||||||
/* 7zFile.c -- File IO
|
|
||||||
2009-11-24 : Igor Pavlov : Public domain */
|
|
||||||
|
|
||||||
#define _FILE_OFFSET_BITS 64
|
|
||||||
|
|
||||||
#include "7zFile.h"
|
|
||||||
|
|
||||||
#ifndef USE_WINDOWS_FILE
|
|
||||||
|
|
||||||
#ifndef UNDER_CE
|
|
||||||
#include <errno.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
/*
|
|
||||||
ReadFile and WriteFile functions in Windows have BUG:
|
|
||||||
If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1)
|
|
||||||
from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES
|
|
||||||
(Insufficient system resources exist to complete the requested service).
|
|
||||||
Probably in some version of Windows there are problems with other sizes:
|
|
||||||
for 32 MB (maybe also for 16 MB).
|
|
||||||
And message can be "Network connection was lost"
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define kChunkSizeMax (1 << 22)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void File_Construct(CSzFile *p)
|
|
||||||
{
|
|
||||||
#ifdef USE_WINDOWS_FILE
|
|
||||||
p->handle = INVALID_HANDLE_VALUE;
|
|
||||||
#else
|
|
||||||
p->file = NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE)
|
|
||||||
static WRes File_Open(CSzFile *p, const char *name, int writeMode)
|
|
||||||
{
|
|
||||||
#ifdef USE_WINDOWS_FILE
|
|
||||||
p->handle = CreateFileA(name,
|
|
||||||
writeMode ? GENERIC_WRITE : GENERIC_READ,
|
|
||||||
FILE_SHARE_READ, NULL,
|
|
||||||
writeMode ? CREATE_ALWAYS : OPEN_EXISTING,
|
|
||||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
|
||||||
return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError();
|
|
||||||
#else
|
|
||||||
if( !name[0] ) p->file = writeMode ? stdout : stdin;
|
|
||||||
else p->file = fopen(name, writeMode ? "wb+" : "rb");
|
|
||||||
return (p->file != 0) ? 0 :
|
|
||||||
#ifdef UNDER_CE
|
|
||||||
2; /* ENOENT */
|
|
||||||
#else
|
|
||||||
errno;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
WRes InFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 0); }
|
|
||||||
WRes OutFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 1); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_FILE
|
|
||||||
static WRes File_OpenW(CSzFile *p, const WCHAR *name, int writeMode)
|
|
||||||
{
|
|
||||||
p->handle = CreateFileW(name,
|
|
||||||
writeMode ? GENERIC_WRITE : GENERIC_READ,
|
|
||||||
FILE_SHARE_READ, NULL,
|
|
||||||
writeMode ? CREATE_ALWAYS : OPEN_EXISTING,
|
|
||||||
FILE_ATTRIBUTE_NORMAL, NULL);
|
|
||||||
return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError();
|
|
||||||
}
|
|
||||||
WRes InFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 0); }
|
|
||||||
WRes OutFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 1); }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
WRes File_Close(CSzFile *p)
|
|
||||||
{
|
|
||||||
#ifdef USE_WINDOWS_FILE
|
|
||||||
if (p->handle != INVALID_HANDLE_VALUE)
|
|
||||||
{
|
|
||||||
if (!CloseHandle(p->handle))
|
|
||||||
return GetLastError();
|
|
||||||
p->handle = INVALID_HANDLE_VALUE;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (p->file != NULL)
|
|
||||||
{
|
|
||||||
int res = fclose(p->file);
|
|
||||||
if (res != 0)
|
|
||||||
return res;
|
|
||||||
p->file = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
WRes File_Read(CSzFile *p, void *data, size_t *size)
|
|
||||||
{
|
|
||||||
size_t originalSize = *size;
|
|
||||||
if (originalSize == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_FILE
|
|
||||||
|
|
||||||
*size = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize;
|
|
||||||
DWORD processed = 0;
|
|
||||||
BOOL res = ReadFile(p->handle, data, curSize, &processed, NULL);
|
|
||||||
data = (void *)((Byte *)data + processed);
|
|
||||||
originalSize -= processed;
|
|
||||||
*size += processed;
|
|
||||||
if (!res)
|
|
||||||
return GetLastError();
|
|
||||||
if (processed == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
while (originalSize > 0);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
*size = fread(data, 1, originalSize, p->file);
|
|
||||||
if (*size == originalSize)
|
|
||||||
return 0;
|
|
||||||
return ferror(p->file);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
WRes File_Write(CSzFile *p, const void *data, size_t *size)
|
|
||||||
{
|
|
||||||
size_t originalSize = *size;
|
|
||||||
if (originalSize == 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_FILE
|
|
||||||
|
|
||||||
*size = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize;
|
|
||||||
DWORD processed = 0;
|
|
||||||
BOOL res = WriteFile(p->handle, data, curSize, &processed, NULL);
|
|
||||||
data = (void *)((Byte *)data + processed);
|
|
||||||
originalSize -= processed;
|
|
||||||
*size += processed;
|
|
||||||
if (!res)
|
|
||||||
return GetLastError();
|
|
||||||
if (processed == 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
while (originalSize > 0);
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
*size = fwrite(data, 1, originalSize, p->file);
|
|
||||||
if (*size == originalSize)
|
|
||||||
return 0;
|
|
||||||
return ferror(p->file);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin)
|
|
||||||
{
|
|
||||||
#ifdef USE_WINDOWS_FILE
|
|
||||||
|
|
||||||
LARGE_INTEGER value;
|
|
||||||
DWORD moveMethod;
|
|
||||||
value.LowPart = (DWORD)*pos;
|
|
||||||
value.HighPart = (LONG)((UInt64)*pos >> 16 >> 16); /* for case when UInt64 is 32-bit only */
|
|
||||||
switch (origin)
|
|
||||||
{
|
|
||||||
case SZ_SEEK_SET: moveMethod = FILE_BEGIN; break;
|
|
||||||
case SZ_SEEK_CUR: moveMethod = FILE_CURRENT; break;
|
|
||||||
case SZ_SEEK_END: moveMethod = FILE_END; break;
|
|
||||||
default: return ERROR_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
value.LowPart = SetFilePointer(p->handle, value.LowPart, &value.HighPart, moveMethod);
|
|
||||||
if (value.LowPart == 0xFFFFFFFF)
|
|
||||||
{
|
|
||||||
WRes res = GetLastError();
|
|
||||||
if (res != NO_ERROR)
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
*pos = ((Int64)value.HighPart << 32) | value.LowPart;
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
int moveMethod;
|
|
||||||
int res;
|
|
||||||
switch (origin)
|
|
||||||
{
|
|
||||||
case SZ_SEEK_SET: moveMethod = SEEK_SET; break;
|
|
||||||
case SZ_SEEK_CUR: moveMethod = SEEK_CUR; break;
|
|
||||||
case SZ_SEEK_END: moveMethod = SEEK_END; break;
|
|
||||||
default: return 1;
|
|
||||||
}
|
|
||||||
res = fseek(p->file, (long)*pos, moveMethod);
|
|
||||||
*pos = ftell(p->file);
|
|
||||||
return res;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------- FileSeqInStream ---------- */
|
|
||||||
|
|
||||||
static SRes FileSeqInStream_Read(void *pp, void *buf, size_t *size)
|
|
||||||
{
|
|
||||||
CFileSeqInStream *p = (CFileSeqInStream *)pp;
|
|
||||||
return File_Read(&p->file, buf, size) == 0 ? SZ_OK : SZ_ERROR_READ;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileSeqInStream_CreateVTable(CFileSeqInStream *p)
|
|
||||||
{
|
|
||||||
p->s.Read = FileSeqInStream_Read;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------- FileOutStream ---------- */
|
|
||||||
|
|
||||||
static size_t FileOutStream_Write(void *pp, const void *data, size_t size)
|
|
||||||
{
|
|
||||||
CFileOutStream *p = (CFileOutStream *)pp;
|
|
||||||
File_Write(&p->file, data, &size);
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileOutStream_CreateVTable(CFileOutStream *p)
|
|
||||||
{
|
|
||||||
p->s.Write = FileOutStream_Write;
|
|
||||||
}
|
|
80
7zFile.h
80
7zFile.h
|
@ -1,80 +0,0 @@
|
||||||
/* 7zFile.h -- File IO
|
|
||||||
2009-11-24 : Igor Pavlov : Public domain */
|
|
||||||
|
|
||||||
#ifndef __7Z_FILE_H
|
|
||||||
#define __7Z_FILE_H
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define USE_WINDOWS_FILE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef USE_WINDOWS_FILE
|
|
||||||
#include <windows.h>
|
|
||||||
#else
|
|
||||||
#include <stdio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
EXTERN_C_BEGIN
|
|
||||||
|
|
||||||
/* ---------- File ---------- */
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
#ifdef USE_WINDOWS_FILE
|
|
||||||
HANDLE handle;
|
|
||||||
#else
|
|
||||||
FILE *file;
|
|
||||||
#endif
|
|
||||||
} CSzFile;
|
|
||||||
|
|
||||||
void File_Construct(CSzFile *p);
|
|
||||||
#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE)
|
|
||||||
WRes InFile_Open(CSzFile *p, const char *name);
|
|
||||||
WRes OutFile_Open(CSzFile *p, const char *name);
|
|
||||||
#endif
|
|
||||||
#ifdef USE_WINDOWS_FILE
|
|
||||||
WRes InFile_OpenW(CSzFile *p, const WCHAR *name);
|
|
||||||
WRes OutFile_OpenW(CSzFile *p, const WCHAR *name);
|
|
||||||
#endif
|
|
||||||
WRes File_Close(CSzFile *p);
|
|
||||||
|
|
||||||
/* reads max(*size, remain file's size) bytes */
|
|
||||||
WRes File_Read(CSzFile *p, void *data, size_t *size);
|
|
||||||
|
|
||||||
/* writes *size bytes */
|
|
||||||
WRes File_Write(CSzFile *p, const void *data, size_t *size);
|
|
||||||
|
|
||||||
WRes File_Seek(CSzFile *p, Int64 *pos, ESzSeek origin);
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------- FileInStream ---------- */
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
ISeqInStream s;
|
|
||||||
CSzFile file;
|
|
||||||
} CFileSeqInStream;
|
|
||||||
|
|
||||||
void FileSeqInStream_CreateVTable(CFileSeqInStream *p);
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
ISeekInStream s;
|
|
||||||
CSzFile file;
|
|
||||||
} CFileInStream;
|
|
||||||
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
ISeqOutStream s;
|
|
||||||
CSzFile file;
|
|
||||||
} CFileOutStream;
|
|
||||||
|
|
||||||
void FileOutStream_CreateVTable(CFileOutStream *p);
|
|
||||||
|
|
||||||
EXTERN_C_END
|
|
||||||
|
|
||||||
#endif
|
|
164
7zStream.c
164
7zStream.c
|
@ -1,164 +0,0 @@
|
||||||
/* 7zStream.c -- 7z Stream functions
|
|
||||||
2008-11-23 : Igor Pavlov : Public domain */
|
|
||||||
|
|
||||||
#define _FILE_OFFSET_BITS 64
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType)
|
|
||||||
{
|
|
||||||
while (size != 0)
|
|
||||||
{
|
|
||||||
size_t processed = size;
|
|
||||||
RINOK(stream->Read(stream, buf, &processed));
|
|
||||||
if (processed == 0)
|
|
||||||
return errorType;
|
|
||||||
buf = (void *)((Byte *)buf + processed);
|
|
||||||
size -= processed;
|
|
||||||
}
|
|
||||||
return SZ_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size)
|
|
||||||
{
|
|
||||||
return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF);
|
|
||||||
}
|
|
||||||
|
|
||||||
SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset)
|
|
||||||
{
|
|
||||||
Int64 t = offset;
|
|
||||||
return stream->Seek(stream, &t, SZ_SEEK_SET);
|
|
||||||
}
|
|
||||||
|
|
||||||
SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size)
|
|
||||||
{
|
|
||||||
void *lookBuf;
|
|
||||||
if (*size == 0)
|
|
||||||
return SZ_OK;
|
|
||||||
RINOK(stream->Look(stream, &lookBuf, size));
|
|
||||||
memcpy(buf, lookBuf, *size);
|
|
||||||
return stream->Skip(stream, *size);
|
|
||||||
}
|
|
||||||
|
|
||||||
SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType)
|
|
||||||
{
|
|
||||||
while (size != 0)
|
|
||||||
{
|
|
||||||
size_t processed = size;
|
|
||||||
RINOK(stream->Read(stream, buf, &processed));
|
|
||||||
if (processed == 0)
|
|
||||||
return errorType;
|
|
||||||
buf = (void *)((Byte *)buf + processed);
|
|
||||||
size -= processed;
|
|
||||||
}
|
|
||||||
return SZ_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size)
|
|
||||||
{
|
|
||||||
return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF);
|
|
||||||
}
|
|
||||||
|
|
||||||
static SRes LookToRead_Look_Lookahead(void *pp, void **buf, size_t *size)
|
|
||||||
{
|
|
||||||
SRes res = SZ_OK;
|
|
||||||
CLookToRead *p = (CLookToRead *)pp;
|
|
||||||
size_t size2 = p->size - p->pos;
|
|
||||||
if (size2 == 0 && *size > 0)
|
|
||||||
{
|
|
||||||
p->pos = 0;
|
|
||||||
size2 = LookToRead_BUF_SIZE;
|
|
||||||
res = p->realStream->Read(p->realStream, p->buf, &size2);
|
|
||||||
p->size = size2;
|
|
||||||
}
|
|
||||||
if (size2 < *size)
|
|
||||||
*size = size2;
|
|
||||||
*buf = p->buf + p->pos;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SRes LookToRead_Look_Exact(void *pp, void **buf, size_t *size)
|
|
||||||
{
|
|
||||||
SRes res = SZ_OK;
|
|
||||||
CLookToRead *p = (CLookToRead *)pp;
|
|
||||||
size_t size2 = p->size - p->pos;
|
|
||||||
if (size2 == 0 && *size > 0)
|
|
||||||
{
|
|
||||||
p->pos = 0;
|
|
||||||
if (*size > LookToRead_BUF_SIZE)
|
|
||||||
*size = LookToRead_BUF_SIZE;
|
|
||||||
res = p->realStream->Read(p->realStream, p->buf, size);
|
|
||||||
size2 = p->size = *size;
|
|
||||||
}
|
|
||||||
if (size2 < *size)
|
|
||||||
*size = size2;
|
|
||||||
*buf = p->buf + p->pos;
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SRes LookToRead_Skip(void *pp, size_t offset)
|
|
||||||
{
|
|
||||||
CLookToRead *p = (CLookToRead *)pp;
|
|
||||||
p->pos += offset;
|
|
||||||
return SZ_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SRes LookToRead_Read(void *pp, void *buf, size_t *size)
|
|
||||||
{
|
|
||||||
CLookToRead *p = (CLookToRead *)pp;
|
|
||||||
size_t rem = p->size - p->pos;
|
|
||||||
if (rem == 0)
|
|
||||||
return p->realStream->Read(p->realStream, buf, size);
|
|
||||||
if (rem > *size)
|
|
||||||
rem = *size;
|
|
||||||
memcpy(buf, p->buf + p->pos, rem);
|
|
||||||
p->pos += rem;
|
|
||||||
*size = rem;
|
|
||||||
return SZ_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SRes LookToRead_Seek(void *pp, Int64 *pos, ESzSeek origin)
|
|
||||||
{
|
|
||||||
CLookToRead *p = (CLookToRead *)pp;
|
|
||||||
p->pos = p->size = 0;
|
|
||||||
return p->realStream->Seek(p->realStream, pos, origin);
|
|
||||||
}
|
|
||||||
|
|
||||||
void LookToRead_CreateVTable(CLookToRead *p, int lookahead)
|
|
||||||
{
|
|
||||||
p->s.Look = lookahead ?
|
|
||||||
LookToRead_Look_Lookahead :
|
|
||||||
LookToRead_Look_Exact;
|
|
||||||
p->s.Skip = LookToRead_Skip;
|
|
||||||
p->s.Read = LookToRead_Read;
|
|
||||||
p->s.Seek = LookToRead_Seek;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LookToRead_Init(CLookToRead *p)
|
|
||||||
{
|
|
||||||
p->pos = p->size = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SRes SecToLook_Read(void *pp, void *buf, size_t *size)
|
|
||||||
{
|
|
||||||
CSecToLook *p = (CSecToLook *)pp;
|
|
||||||
return LookInStream_LookRead(p->realStream, buf, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SecToLook_CreateVTable(CSecToLook *p)
|
|
||||||
{
|
|
||||||
p->s.Read = SecToLook_Read;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SRes SecToRead_Read(void *pp, void *buf, size_t *size)
|
|
||||||
{
|
|
||||||
CSecToRead *p = (CSecToRead *)pp;
|
|
||||||
return p->realStream->Read(p->realStream, buf, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SecToRead_CreateVTable(CSecToRead *p)
|
|
||||||
{
|
|
||||||
p->s.Read = SecToRead_Read;
|
|
||||||
}
|
|
127
Alloc.c
127
Alloc.c
|
@ -1,127 +0,0 @@
|
||||||
/* Alloc.c -- Memory allocation functions
|
|
||||||
2008-09-24 : Igor Pavlov : Public domain */
|
|
||||||
|
|
||||||
#define _FILE_OFFSET_BITS 64
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include "Alloc.h"
|
|
||||||
|
|
||||||
/* #define _SZ_ALLOC_DEBUG */
|
|
||||||
|
|
||||||
/* use _SZ_ALLOC_DEBUG to debug alloc/free operations */
|
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
|
||||||
#include <stdio.h>
|
|
||||||
int g_allocCount = 0;
|
|
||||||
int g_allocCountMid = 0;
|
|
||||||
int g_allocCountBig = 0;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void *MyAlloc(size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
return 0;
|
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
|
||||||
{
|
|
||||||
void *p = malloc(size);
|
|
||||||
fprintf(stderr, "\nAlloc %10d bytes, count = %10d, addr = %8X", size, g_allocCount++, (unsigned)p);
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
return malloc(size);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyFree(void *address)
|
|
||||||
{
|
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
|
||||||
if (address != 0)
|
|
||||||
fprintf(stderr, "\nFree; count = %10d, addr = %8X", --g_allocCount, (unsigned)address);
|
|
||||||
#endif
|
|
||||||
free(address);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
void *MidAlloc(size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
return 0;
|
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
|
||||||
fprintf(stderr, "\nAlloc_Mid %10d bytes; count = %10d", size, g_allocCountMid++);
|
|
||||||
#endif
|
|
||||||
return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MidFree(void *address)
|
|
||||||
{
|
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
|
||||||
if (address != 0)
|
|
||||||
fprintf(stderr, "\nFree_Mid; count = %10d", --g_allocCountMid);
|
|
||||||
#endif
|
|
||||||
if (address == 0)
|
|
||||||
return;
|
|
||||||
VirtualFree(address, 0, MEM_RELEASE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef MEM_LARGE_PAGES
|
|
||||||
#undef _7ZIP_LARGE_PAGES
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _7ZIP_LARGE_PAGES
|
|
||||||
SIZE_T g_LargePageSize = 0;
|
|
||||||
typedef SIZE_T (WINAPI *GetLargePageMinimumP)();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void SetLargePageSize()
|
|
||||||
{
|
|
||||||
#ifdef _7ZIP_LARGE_PAGES
|
|
||||||
SIZE_T size = 0;
|
|
||||||
GetLargePageMinimumP largePageMinimum = (GetLargePageMinimumP)
|
|
||||||
GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")), "GetLargePageMinimum");
|
|
||||||
if (largePageMinimum == 0)
|
|
||||||
return;
|
|
||||||
size = largePageMinimum();
|
|
||||||
if (size == 0 || (size & (size - 1)) != 0)
|
|
||||||
return;
|
|
||||||
g_LargePageSize = size;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void *BigAlloc(size_t size)
|
|
||||||
{
|
|
||||||
if (size == 0)
|
|
||||||
return 0;
|
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
|
||||||
fprintf(stderr, "\nAlloc_Big %10d bytes; count = %10d", size, g_allocCountBig++);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _7ZIP_LARGE_PAGES
|
|
||||||
if (g_LargePageSize != 0 && g_LargePageSize <= (1 << 30) && size >= (1 << 18))
|
|
||||||
{
|
|
||||||
void *res = VirtualAlloc(0, (size + g_LargePageSize - 1) & (~(g_LargePageSize - 1)),
|
|
||||||
MEM_COMMIT | MEM_LARGE_PAGES, PAGE_READWRITE);
|
|
||||||
if (res != 0)
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return VirtualAlloc(0, size, MEM_COMMIT, PAGE_READWRITE);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BigFree(void *address)
|
|
||||||
{
|
|
||||||
#ifdef _SZ_ALLOC_DEBUG
|
|
||||||
if (address != 0)
|
|
||||||
fprintf(stderr, "\nFree_Big; count = %10d", --g_allocCountBig);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (address == 0)
|
|
||||||
return;
|
|
||||||
VirtualFree(address, 0, MEM_RELEASE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
38
Alloc.h
38
Alloc.h
|
@ -1,38 +0,0 @@
|
||||||
/* Alloc.h -- Memory allocation functions
|
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
|
||||||
|
|
||||||
#ifndef __COMMON_ALLOC_H
|
|
||||||
#define __COMMON_ALLOC_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void *MyAlloc(size_t size);
|
|
||||||
void MyFree(void *address);
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
|
|
||||||
void SetLargePageSize();
|
|
||||||
|
|
||||||
void *MidAlloc(size_t size);
|
|
||||||
void MidFree(void *address);
|
|
||||||
void *BigAlloc(size_t size);
|
|
||||||
void BigFree(void *address);
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define MidAlloc(size) MyAlloc(size)
|
|
||||||
#define MidFree(address) MyFree(address)
|
|
||||||
#define BigAlloc(size) MyAlloc(size)
|
|
||||||
#define BigFree(address) MyFree(address)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,17 @@
|
||||||
|
2013-02-18 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
||||||
|
|
||||||
|
* Version 1.4-rc1 released.
|
||||||
|
* main.c: Added new option '-f, --force'.
|
||||||
|
* main.c: Added new option '-F, --recompress'.
|
||||||
|
* main.c: Added new option '-k, --keep'.
|
||||||
|
* main.c: Added new option '-o, --output'.
|
||||||
|
* main.c: Accept more than one file in command line.
|
||||||
|
* Decompression time has been reduced by 5%.
|
||||||
|
* main.c: '--test' no more needs '/dev/null'.
|
||||||
|
* configure: 'datadir' renamed to 'datarootdir'.
|
||||||
|
* Makefile.in: Added new target 'install-as-lzip'.
|
||||||
|
* Makefile.in: Added new target 'install-bin'.
|
||||||
|
|
||||||
2012-01-03 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
2012-01-03 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
||||||
|
|
||||||
* Version 1.3 released.
|
* Version 1.3 released.
|
||||||
|
@ -27,7 +41,7 @@
|
||||||
* Using LZMA SDK 9.10 (public domain) from Igor Pavlov.
|
* Using LZMA SDK 9.10 (public domain) from Igor Pavlov.
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2010, 2011, 2012 Antonio Diaz Diaz.
|
Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This file is a collection of facts, and thus it is not copyrightable,
|
This file is a collection of facts, and thus it is not copyrightable,
|
||||||
but just in case, you have unlimited permission to copy, distribute and
|
but just in case, you have unlimited permission to copy, distribute and
|
||||||
|
|
11
INSTALL
11
INSTALL
|
@ -1,7 +1,7 @@
|
||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
You will need a C compiler.
|
You will need a C compiler.
|
||||||
I use gcc 4.3.5 and 3.3.6, but the code should compile with any
|
I use gcc 4.7.2 and 3.3.6, but the code should compile with any
|
||||||
standards compliant compiler.
|
standards compliant compiler.
|
||||||
Gcc is available at http://gcc.gnu.org.
|
Gcc is available at http://gcc.gnu.org.
|
||||||
|
|
||||||
|
@ -32,6 +32,13 @@ the main archive.
|
||||||
5. Type 'make install' to install the program and any data files and
|
5. Type 'make install' to install the program and any data files and
|
||||||
documentation.
|
documentation.
|
||||||
|
|
||||||
|
You can install only the program, the info manual or the man page
|
||||||
|
typing 'make install-bin', 'make install-info' or 'make install-man'
|
||||||
|
respectively.
|
||||||
|
|
||||||
|
5a. Type 'make install-as-lzip' to install the program and any data
|
||||||
|
files and documentation, and link the program to the name 'lzip'.
|
||||||
|
|
||||||
|
|
||||||
Another way
|
Another way
|
||||||
-----------
|
-----------
|
||||||
|
@ -50,7 +57,7 @@ After running 'configure', you can run 'make' and 'make install' as
|
||||||
explained above.
|
explained above.
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2010, 2011, 2012 Antonio Diaz Diaz.
|
Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This file is free documentation: you have unlimited permission to copy,
|
This file is free documentation: you have unlimited permission to copy,
|
||||||
distribute and modify it.
|
distribute and modify it.
|
||||||
|
|
189
LzFind.h
189
LzFind.h
|
@ -1,115 +1,74 @@
|
||||||
/* LzFind.h -- Match finder for LZ algorithms
|
/* LzFind.h -- Match finder for LZ algorithms
|
||||||
2009-04-22 : Igor Pavlov : Public domain */
|
2009-04-22 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZ_FIND_H
|
typedef uint32_t CLzRef;
|
||||||
#define __LZ_FIND_H
|
|
||||||
|
typedef struct
|
||||||
#include "Types.h"
|
{
|
||||||
|
uint8_t *bufferBase;
|
||||||
#ifdef __cplusplus
|
uint8_t *buffer;
|
||||||
extern "C" {
|
CLzRef *hash;
|
||||||
#endif
|
CLzRef *son;
|
||||||
|
uint32_t pos;
|
||||||
typedef UInt32 CLzRef;
|
uint32_t posLimit;
|
||||||
|
uint32_t streamPos;
|
||||||
typedef struct _CMatchFinder
|
uint32_t lenLimit;
|
||||||
{
|
|
||||||
Byte *buffer;
|
uint32_t cyclicBufferPos;
|
||||||
UInt32 pos;
|
uint32_t cyclicBufferSize; /* it must be = (historySize + 1) */
|
||||||
UInt32 posLimit;
|
|
||||||
UInt32 streamPos;
|
uint32_t matchMaxLen;
|
||||||
UInt32 lenLimit;
|
uint32_t hashMask;
|
||||||
|
uint32_t cutValue;
|
||||||
UInt32 cyclicBufferPos;
|
|
||||||
UInt32 cyclicBufferSize; /* it must be = (historySize + 1) */
|
uint32_t blockSize;
|
||||||
|
uint32_t keepSizeBefore;
|
||||||
UInt32 matchMaxLen;
|
uint32_t keepSizeAfter;
|
||||||
CLzRef *hash;
|
|
||||||
CLzRef *son;
|
uint32_t numHashBytes;
|
||||||
UInt32 hashMask;
|
uint32_t historySize;
|
||||||
UInt32 cutValue;
|
uint32_t hashSizeSum;
|
||||||
|
uint32_t numSons;
|
||||||
Byte *bufferBase;
|
int infd;
|
||||||
ISeqInStream *stream;
|
int result;
|
||||||
int streamEndWasReached;
|
uint32_t crc;
|
||||||
|
bool btMode;
|
||||||
UInt32 blockSize;
|
bool streamEndWasReached;
|
||||||
UInt32 keepSizeBefore;
|
} CMatchFinder;
|
||||||
UInt32 keepSizeAfter;
|
|
||||||
|
|
||||||
UInt32 numHashBytes;
|
/* Conditions:
|
||||||
int directInput;
|
historySize <= 3 GB
|
||||||
size_t directInputRem;
|
keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
|
||||||
int btMode;
|
*/
|
||||||
int bigHash;
|
int Mf_Init(CMatchFinder *p, const int ifd, const int mc, uint32_t historySize,
|
||||||
UInt32 historySize;
|
uint32_t keepAddBufferBefore, uint32_t matchMaxLen, uint32_t keepAddBufferAfter);
|
||||||
UInt32 fixedHashSize;
|
|
||||||
UInt32 hashSizeSum;
|
void Mf_Free(CMatchFinder *p);
|
||||||
UInt32 numSons;
|
|
||||||
SRes result;
|
|
||||||
uint32_t crc;
|
/*
|
||||||
} CMatchFinder;
|
Conditions:
|
||||||
|
Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
|
||||||
#define Inline_MatchFinder_GetPointerToCurrentPos(p) ((p)->buffer)
|
Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
|
||||||
#define Inline_MatchFinder_GetIndexByte(p, index) ((p)->buffer[(Int32)(index)])
|
*/
|
||||||
|
|
||||||
#define Inline_MatchFinder_GetNumAvailableBytes(p) ((p)->streamPos - (p)->pos)
|
typedef uint32_t (*Mf_GetMatches_Func)(void *object, uint32_t *distances);
|
||||||
|
typedef void (*Mf_Skip_Func)(void *object, uint32_t);
|
||||||
int MatchFinder_NeedMove(CMatchFinder *p);
|
|
||||||
Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p);
|
typedef struct _IMatchFinder
|
||||||
void MatchFinder_MoveBlock(CMatchFinder *p);
|
{
|
||||||
void MatchFinder_ReadIfRequired(CMatchFinder *p);
|
Mf_GetMatches_Func GetMatches;
|
||||||
|
Mf_Skip_Func Skip;
|
||||||
void MatchFinder_Construct(CMatchFinder *p);
|
} IMatchFinder;
|
||||||
|
|
||||||
/* Conditions:
|
void Mf_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
|
||||||
historySize <= 3 GB
|
|
||||||
keepAddBufferBefore + matchMaxLen + keepAddBufferAfter < 511MB
|
static inline uint32_t Mf_GetNumAvailableBytes(CMatchFinder *p)
|
||||||
*/
|
{ return p->streamPos - p->pos; }
|
||||||
int MatchFinder_Create(CMatchFinder *p, UInt32 historySize,
|
|
||||||
UInt32 keepAddBufferBefore, UInt32 matchMaxLen, UInt32 keepAddBufferAfter,
|
static inline uint8_t Mf_GetIndexByte(CMatchFinder *p, int index)
|
||||||
ISzAlloc *alloc);
|
{ return p->buffer[index]; }
|
||||||
void MatchFinder_Free(CMatchFinder *p, ISzAlloc *alloc);
|
|
||||||
void MatchFinder_Normalize3(UInt32 subValue, CLzRef *items, UInt32 numItems);
|
static inline uint8_t * Mf_GetPointerToCurrentPos(CMatchFinder *p)
|
||||||
void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue);
|
{ return p->buffer; }
|
||||||
|
|
||||||
UInt32 * GetMatchesSpec1(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const Byte *buffer, CLzRef *son,
|
|
||||||
UInt32 _cyclicBufferPos, UInt32 _cyclicBufferSize, UInt32 _cutValue,
|
|
||||||
UInt32 *distances, UInt32 maxLen);
|
|
||||||
|
|
||||||
/*
|
|
||||||
Conditions:
|
|
||||||
Mf_GetNumAvailableBytes_Func must be called before each Mf_GetMatchLen_Func.
|
|
||||||
Mf_GetPointerToCurrentPos_Func's result must be used only before any other function
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef void (*Mf_Init_Func)(void *object);
|
|
||||||
typedef Byte (*Mf_GetIndexByte_Func)(void *object, Int32 index);
|
|
||||||
typedef UInt32 (*Mf_GetNumAvailableBytes_Func)(void *object);
|
|
||||||
typedef const Byte * (*Mf_GetPointerToCurrentPos_Func)(void *object);
|
|
||||||
typedef UInt32 (*Mf_GetMatches_Func)(void *object, UInt32 *distances);
|
|
||||||
typedef void (*Mf_Skip_Func)(void *object, UInt32);
|
|
||||||
|
|
||||||
typedef struct _IMatchFinder
|
|
||||||
{
|
|
||||||
Mf_Init_Func Init;
|
|
||||||
Mf_GetIndexByte_Func GetIndexByte;
|
|
||||||
Mf_GetNumAvailableBytes_Func GetNumAvailableBytes;
|
|
||||||
Mf_GetPointerToCurrentPos_Func GetPointerToCurrentPos;
|
|
||||||
Mf_GetMatches_Func GetMatches;
|
|
||||||
Mf_Skip_Func Skip;
|
|
||||||
} IMatchFinder;
|
|
||||||
|
|
||||||
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder *vTable);
|
|
||||||
|
|
||||||
void MatchFinder_Init(CMatchFinder *p);
|
|
||||||
UInt32 Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
|
||||||
UInt32 Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
|
|
||||||
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
|
||||||
void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
54
LzHash.h
54
LzHash.h
|
@ -1,54 +0,0 @@
|
||||||
/* LzHash.h -- HASH functions for LZ algorithms
|
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
|
||||||
|
|
||||||
#ifndef __LZ_HASH_H
|
|
||||||
#define __LZ_HASH_H
|
|
||||||
|
|
||||||
#define kHash2Size (1 << 10)
|
|
||||||
#define kHash3Size (1 << 16)
|
|
||||||
#define kHash4Size (1 << 20)
|
|
||||||
|
|
||||||
#define kFix3HashSize (kHash2Size)
|
|
||||||
#define kFix4HashSize (kHash2Size + kHash3Size)
|
|
||||||
#define kFix5HashSize (kHash2Size + kHash3Size + kHash4Size)
|
|
||||||
|
|
||||||
#define HASH2_CALC hashValue = cur[0] | ((UInt32)cur[1] << 8);
|
|
||||||
|
|
||||||
#define HASH3_CALC { \
|
|
||||||
UInt32 temp = crc32[cur[0]] ^ cur[1]; \
|
|
||||||
hash2Value = temp & (kHash2Size - 1); \
|
|
||||||
hashValue = (temp ^ ((UInt32)cur[2] << 8)) & p->hashMask; }
|
|
||||||
|
|
||||||
#define HASH4_CALC { \
|
|
||||||
UInt32 temp = crc32[cur[0]] ^ cur[1]; \
|
|
||||||
hash2Value = temp & (kHash2Size - 1); \
|
|
||||||
hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
|
|
||||||
hashValue = (temp ^ ((UInt32)cur[2] << 8) ^ (crc32[cur[3]] << 5)) & p->hashMask; }
|
|
||||||
|
|
||||||
#define HASH5_CALC { \
|
|
||||||
UInt32 temp = crc32[cur[0]] ^ cur[1]; \
|
|
||||||
hash2Value = temp & (kHash2Size - 1); \
|
|
||||||
hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
|
|
||||||
hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (crc32[cur[3]] << 5)); \
|
|
||||||
hashValue = (hash4Value ^ (crc32[cur[4]] << 3)) & p->hashMask; \
|
|
||||||
hash4Value &= (kHash4Size - 1); }
|
|
||||||
|
|
||||||
/* #define HASH_ZIP_CALC hashValue = ((cur[0] | ((UInt32)cur[1] << 8)) ^ crc32[cur[2]]) & 0xFFFF; */
|
|
||||||
#define HASH_ZIP_CALC hashValue = ((cur[2] | ((UInt32)cur[0] << 8)) ^ crc32[cur[1]]) & 0xFFFF;
|
|
||||||
|
|
||||||
|
|
||||||
#define MT_HASH2_CALC \
|
|
||||||
hash2Value = (crc32[cur[0]] ^ cur[1]) & (kHash2Size - 1);
|
|
||||||
|
|
||||||
#define MT_HASH3_CALC { \
|
|
||||||
UInt32 temp = crc32[cur[0]] ^ cur[1]; \
|
|
||||||
hash2Value = temp & (kHash2Size - 1); \
|
|
||||||
hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); }
|
|
||||||
|
|
||||||
#define MT_HASH4_CALC { \
|
|
||||||
UInt32 temp = crc32[cur[0]] ^ cur[1]; \
|
|
||||||
hash2Value = temp & (kHash2Size - 1); \
|
|
||||||
hash3Value = (temp ^ ((UInt32)cur[2] << 8)) & (kHash3Size - 1); \
|
|
||||||
hash4Value = (temp ^ ((UInt32)cur[2] << 8) ^ (crc32[cur[3]] << 5)) & (kHash4Size - 1); }
|
|
||||||
|
|
||||||
#endif
|
|
281
LzmaDec.h
281
LzmaDec.h
|
@ -1,191 +1,90 @@
|
||||||
/* LzmaDec.h -- LZMA Decoder
|
/* LzmaDec.h -- LZMA Decoder
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2009-02-07 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZMA_DEC_H
|
/* ---------- LZMA Properties ---------- */
|
||||||
#define __LZMA_DEC_H
|
|
||||||
|
#define LZMA_PROPS_SIZE 5
|
||||||
#include "Types.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
/* ---------- LZMA Decoder state ---------- */
|
||||||
extern "C" {
|
|
||||||
#endif
|
/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.
|
||||||
|
Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */
|
||||||
/* #define _LZMA_PROB32 */
|
|
||||||
/* _LZMA_PROB32 can increase the speed on some CPUs,
|
#define LZMA_REQUIRED_INPUT_MAX 20
|
||||||
but memory usage for CLzmaDec::probs will be doubled in that case */
|
|
||||||
|
typedef struct
|
||||||
#ifdef _LZMA_PROB32
|
{
|
||||||
#define CLzmaProb UInt32
|
int *probs;
|
||||||
#else
|
uint8_t *dic;
|
||||||
#define CLzmaProb UInt16
|
const uint8_t *buf;
|
||||||
#endif
|
uint32_t range, code;
|
||||||
|
uint32_t dicPos;
|
||||||
|
uint32_t dicBufSize;
|
||||||
/* ---------- LZMA Properties ---------- */
|
uint32_t processedPos;
|
||||||
|
uint32_t checkDicSize;
|
||||||
#define LZMA_PROPS_SIZE 5
|
unsigned lc, lp, pb;
|
||||||
|
State state;
|
||||||
typedef struct _CLzmaProps
|
uint32_t reps[4];
|
||||||
{
|
unsigned remainLen;
|
||||||
unsigned lc, lp, pb;
|
uint32_t numProbs;
|
||||||
UInt32 dicSize;
|
unsigned tempBufSize;
|
||||||
} CLzmaProps;
|
bool needFlush;
|
||||||
|
uint8_t tempBuf[LZMA_REQUIRED_INPUT_MAX];
|
||||||
/* LzmaProps_Decode - decodes properties
|
} CLzmaDec;
|
||||||
Returns:
|
|
||||||
SZ_OK
|
|
||||||
SZ_ERROR_UNSUPPORTED - Unsupported properties
|
/* There are two types of LZMA streams:
|
||||||
*/
|
0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
|
||||||
|
1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
|
||||||
SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size);
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
/* ---------- LZMA Decoder state ---------- */
|
LZMA_FINISH_ANY, /* finish at any point */
|
||||||
|
LZMA_FINISH_END /* block must be finished at the end */
|
||||||
/* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case.
|
} ELzmaFinishMode;
|
||||||
Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */
|
|
||||||
|
/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!
|
||||||
#define LZMA_REQUIRED_INPUT_MAX 20
|
|
||||||
|
You must use LZMA_FINISH_END, when you know that current output buffer
|
||||||
typedef struct
|
covers last bytes of block. In other cases you must use LZMA_FINISH_ANY.
|
||||||
{
|
|
||||||
CLzmaProps prop;
|
If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK,
|
||||||
CLzmaProb *probs;
|
and output value of destLen will be less than output buffer size limit.
|
||||||
Byte *dic;
|
You can check status result also.
|
||||||
const Byte *buf;
|
|
||||||
UInt32 range, code;
|
You can use multiple checks to test data integrity after full decompression:
|
||||||
SizeT dicPos;
|
1) Check Result and "status" variable.
|
||||||
SizeT dicBufSize;
|
2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.
|
||||||
UInt32 processedPos;
|
3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
|
||||||
UInt32 checkDicSize;
|
You must use correct finish mode in that case. */
|
||||||
unsigned state;
|
|
||||||
UInt32 reps[4];
|
typedef enum
|
||||||
unsigned remainLen;
|
{
|
||||||
int needFlush;
|
LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */
|
||||||
int needInitState;
|
LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
|
||||||
UInt32 numProbs;
|
LZMA_STATUS_NOT_FINISHED, /* stream was not finished */
|
||||||
unsigned tempBufSize;
|
LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */
|
||||||
Byte tempBuf[LZMA_REQUIRED_INPUT_MAX];
|
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */
|
||||||
} CLzmaDec;
|
} ELzmaStatus;
|
||||||
|
|
||||||
#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; }
|
/* ELzmaStatus is used only as output value for function call */
|
||||||
|
|
||||||
void LzmaDec_Init(CLzmaDec *p);
|
|
||||||
|
bool LzmaDec_Init(CLzmaDec *p, const uint8_t *raw_props);
|
||||||
/* There are two types of LZMA streams:
|
void LzmaDec_Free(CLzmaDec *p);
|
||||||
0) Stream with end mark. That end mark adds about 6 bytes to compressed size.
|
|
||||||
1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */
|
|
||||||
|
/* ---------- Buffer Interface ---------- */
|
||||||
typedef enum
|
|
||||||
{
|
/* It's zlib-like interface.
|
||||||
LZMA_FINISH_ANY, /* finish at any point */
|
|
||||||
LZMA_FINISH_END /* block must be finished at the end */
|
finishMode:
|
||||||
} ELzmaFinishMode;
|
It has meaning only if the decoding reaches output limit (*destLen).
|
||||||
|
LZMA_FINISH_ANY - Decode just destLen bytes.
|
||||||
/* ELzmaFinishMode has meaning only if the decoding reaches output limit !!!
|
LZMA_FINISH_END - Stream must be finished after (*destLen).
|
||||||
|
*/
|
||||||
You must use LZMA_FINISH_END, when you know that current output buffer
|
|
||||||
covers last bytes of block. In other cases you must use LZMA_FINISH_ANY.
|
bool LzmaDec_DecodeToBuf( CLzmaDec *p, uint8_t *dest, uint32_t *destLen,
|
||||||
|
const uint8_t *src, uint32_t *srcLen,
|
||||||
If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK,
|
ELzmaFinishMode finishMode, ELzmaStatus *status );
|
||||||
and output value of destLen will be less than output buffer size limit.
|
|
||||||
You can check status result also.
|
|
||||||
|
|
||||||
You can use multiple checks to test data integrity after full decompression:
|
|
||||||
1) Check Result and "status" variable.
|
|
||||||
2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize.
|
|
||||||
3) Check that output(srcLen) = compressedSize, if you know real compressedSize.
|
|
||||||
You must use correct finish mode in that case. */
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */
|
|
||||||
LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */
|
|
||||||
LZMA_STATUS_NOT_FINISHED, /* stream was not finished */
|
|
||||||
LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */
|
|
||||||
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */
|
|
||||||
} ELzmaStatus;
|
|
||||||
|
|
||||||
/* ELzmaStatus is used only as output value for function call */
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------- Interfaces ---------- */
|
|
||||||
|
|
||||||
/* There are 3 levels of interfaces:
|
|
||||||
1) Dictionary Interface
|
|
||||||
2) Buffer Interface
|
|
||||||
3) One Call Interface
|
|
||||||
You can select any of these interfaces, but don't mix functions from different
|
|
||||||
groups for same object. */
|
|
||||||
|
|
||||||
|
|
||||||
SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc);
|
|
||||||
void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc);
|
|
||||||
|
|
||||||
/* ---------- Dictionary Interface ---------- */
|
|
||||||
|
|
||||||
/* You can use it, if you want to eliminate the overhead for data copying from
|
|
||||||
dictionary to some other external buffer.
|
|
||||||
You must work with CLzmaDec variables directly in this interface.
|
|
||||||
|
|
||||||
STEPS:
|
|
||||||
LzmaDec_Constr()
|
|
||||||
LzmaDec_Allocate()
|
|
||||||
for (each new stream)
|
|
||||||
{
|
|
||||||
LzmaDec_Init()
|
|
||||||
while (it needs more decompression)
|
|
||||||
{
|
|
||||||
LzmaDec_DecodeToDic()
|
|
||||||
use data from CLzmaDec::dic and update CLzmaDec::dicPos
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LzmaDec_Free()
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* LzmaDec_DecodeToDic
|
|
||||||
|
|
||||||
The decoding to internal dictionary buffer (CLzmaDec::dic).
|
|
||||||
You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!!
|
|
||||||
|
|
||||||
finishMode:
|
|
||||||
It has meaning only if the decoding reaches output limit (dicLimit).
|
|
||||||
LZMA_FINISH_ANY - Decode just dicLimit bytes.
|
|
||||||
LZMA_FINISH_END - Stream must be finished after dicLimit.
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
SZ_OK
|
|
||||||
status:
|
|
||||||
LZMA_STATUS_FINISHED_WITH_MARK
|
|
||||||
LZMA_STATUS_NOT_FINISHED
|
|
||||||
LZMA_STATUS_NEEDS_MORE_INPUT
|
|
||||||
LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK
|
|
||||||
SZ_ERROR_DATA - Data error
|
|
||||||
*/
|
|
||||||
|
|
||||||
SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit,
|
|
||||||
const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------- Buffer Interface ---------- */
|
|
||||||
|
|
||||||
/* It's zlib-like interface.
|
|
||||||
See LzmaDec_DecodeToDic description for information about STEPS and return results,
|
|
||||||
but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need
|
|
||||||
to work with CLzmaDec variables manually.
|
|
||||||
|
|
||||||
finishMode:
|
|
||||||
It has meaning only if the decoding reaches output limit (*destLen).
|
|
||||||
LZMA_FINISH_ANY - Decode just destLen bytes.
|
|
||||||
LZMA_FINISH_END - Stream must be finished after (*destLen).
|
|
||||||
*/
|
|
||||||
|
|
||||||
SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen,
|
|
||||||
const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
77
LzmaEnc.h
77
LzmaEnc.h
|
@ -1,59 +1,18 @@
|
||||||
/* LzmaEnc.h -- LZMA Encoder
|
/* LzmaEnc.h -- LZMA Encoder
|
||||||
2009-02-07 : Igor Pavlov : Public domain */
|
2009-02-07 : Igor Pavlov : Public domain */
|
||||||
|
|
||||||
#ifndef __LZMA_ENC_H
|
|
||||||
#define __LZMA_ENC_H
|
/* ---------- CLzmaEncHandle Interface ---------- */
|
||||||
|
|
||||||
#include "Types.h"
|
/* LzmaEnc_* functions can return the following exit codes:
|
||||||
|
Returns:
|
||||||
#ifdef __cplusplus
|
SZ_OK - OK
|
||||||
extern "C" {
|
SZ_ERROR_WRITE - Write callback error.
|
||||||
#endif
|
*/
|
||||||
|
|
||||||
typedef struct _CLzmaEncProps
|
typedef void * CLzmaEncHandle;
|
||||||
{
|
|
||||||
int level; /* 0 <= level <= 9 */
|
CLzmaEncHandle LzmaEnc_Init( const int dict_size, const int match_len_limit,
|
||||||
UInt32 dictSize; /* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
|
const int infd, const int outfd );
|
||||||
(1 << 12) <= dictSize <= (1 << 30) for 64-bit version
|
void LzmaEnc_Free(CLzmaEncHandle p);
|
||||||
default = (1 << 24) */
|
int LzmaEnc_Encode(CLzmaEncHandle p);
|
||||||
int lc; /* 0 <= lc <= 8, default = 3 */
|
|
||||||
int lp; /* 0 <= lp <= 4, default = 0 */
|
|
||||||
int pb; /* 0 <= pb <= 4, default = 2 */
|
|
||||||
int algo; /* 0 - fast, 1 - normal, default = 1 */
|
|
||||||
int fb; /* 5 <= fb <= 273, default = 32 */
|
|
||||||
int btMode; /* 0 - hashChain Mode, 1 - binTree mode - normal, default = 1 */
|
|
||||||
int numHashBytes; /* 2, 3 or 4, default = 4 */
|
|
||||||
UInt32 mc; /* 1 <= mc <= (1 << 30), default = 32 */
|
|
||||||
int numThreads; /* 1 or 2, default = 2 */
|
|
||||||
} CLzmaEncProps;
|
|
||||||
|
|
||||||
void LzmaEncProps_Init(CLzmaEncProps *p);
|
|
||||||
void LzmaEncProps_Normalize(CLzmaEncProps *p);
|
|
||||||
UInt32 LzmaEncProps_GetDictSize(const CLzmaEncProps *props2);
|
|
||||||
|
|
||||||
|
|
||||||
/* ---------- CLzmaEncHandle Interface ---------- */
|
|
||||||
|
|
||||||
/* LzmaEnc_* functions can return the following exit codes:
|
|
||||||
Returns:
|
|
||||||
SZ_OK - OK
|
|
||||||
SZ_ERROR_MEM - Memory allocation error
|
|
||||||
SZ_ERROR_PARAM - Incorrect paramater in props
|
|
||||||
SZ_ERROR_WRITE - Write callback error.
|
|
||||||
SZ_ERROR_PROGRESS - some break from progress callback
|
|
||||||
SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef void * CLzmaEncHandle;
|
|
||||||
|
|
||||||
CLzmaEncHandle LzmaEnc_Create(ISzAlloc *alloc);
|
|
||||||
void LzmaEnc_Destroy(CLzmaEncHandle p, ISzAlloc *alloc, ISzAlloc *allocBig);
|
|
||||||
void LzmaEnc_SetProps(CLzmaEncHandle p, const CLzmaEncProps *props);
|
|
||||||
SRes LzmaEnc_Encode(CLzmaEncHandle p, ISeqOutStream *outStream, ISeqInStream *inStream,
|
|
||||||
ICompressProgress *progress, ISzAlloc *alloc, ISzAlloc *allocBig);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
44
Makefile.in
44
Makefile.in
|
@ -6,21 +6,20 @@ INSTALL_DATA = $(INSTALL) -p -m 644
|
||||||
INSTALL_DIR = $(INSTALL) -d -m 755
|
INSTALL_DIR = $(INSTALL) -d -m 755
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
||||||
objs = 7zFile.o 7zStream.o Alloc.o LzFind.o LzmaDec.o LzmaEnc.o \
|
objs = carg_parser.o LzFind.o LzmaEnc.o LzmaDec.o main.o
|
||||||
pdarg_parser.o main.o
|
|
||||||
|
|
||||||
|
|
||||||
.PHONY : all install install-info install-man install-strip \
|
.PHONY : all install install-bin install-info install-man install-strip \
|
||||||
uninstall uninstall-info uninstall-man \
|
install-as-lzip uninstall uninstall-bin uninstall-info uninstall-man \
|
||||||
doc info man check dist clean distclean
|
doc info man check dist clean distclean
|
||||||
|
|
||||||
all : $(progname)
|
all : $(progname)
|
||||||
|
|
||||||
$(progname) : $(objs)
|
$(progname) : $(objs)
|
||||||
$(CC) $(LDFLAGS) -o $@ $^
|
$(CC) $(LDFLAGS) -o $@ $(objs)
|
||||||
|
|
||||||
$(progname)_profiled : $(objs)
|
$(progname)_profiled : $(objs)
|
||||||
$(CC) $(LDFLAGS) -pg -o $@ $^
|
$(CC) $(LDFLAGS) -pg -o $@ $(objs)
|
||||||
|
|
||||||
main.o : main.c
|
main.o : main.c
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $<
|
$(CC) $(CPPFLAGS) $(CFLAGS) -DPROGVERSION=\"$(pkgversion)\" -c -o $@ $<
|
||||||
|
@ -28,15 +27,12 @@ main.o : main.c
|
||||||
%.o : %.c
|
%.o : %.c
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
$(objs) : Makefile
|
$(objs) : Makefile
|
||||||
7zFile.o : 7zFile.h Types.h
|
carg_parser.o : carg_parser.h
|
||||||
7zStream.o : Types.h
|
LzmaDec.o : clzip.h LzmaDec.h
|
||||||
Alloc.o : Alloc.h
|
LzFind.o : clzip.h LzFind.h
|
||||||
LzFind.o : LzFind.h LzHash.h Types.h pdlzip.h
|
LzmaEnc.o : clzip.h LzFind.h LzmaEnc.h
|
||||||
LzmaDec.o : LzmaDec.h Types.h
|
main.o : carg_parser.h clzip.h LzmaDec.h LzmaEnc.h
|
||||||
LzmaEnc.o : LzFind.h LzmaEnc.h Types.h pdlzip.h
|
|
||||||
pdarg_parser.o : pdarg_parser.h
|
|
||||||
main.o : 7zFile.h Alloc.h LzmaDec.h LzmaEnc.h pdarg_parser.h pdlzip.h
|
|
||||||
|
|
||||||
|
|
||||||
doc : man
|
doc : man
|
||||||
|
@ -58,14 +54,16 @@ Makefile : $(VPATH)/configure $(VPATH)/Makefile.in
|
||||||
check : all
|
check : all
|
||||||
@$(VPATH)/testsuite/check.sh $(VPATH)/testsuite $(pkgversion)
|
@$(VPATH)/testsuite/check.sh $(VPATH)/testsuite $(pkgversion)
|
||||||
|
|
||||||
install : all install-man
|
install : install-bin install-man
|
||||||
|
|
||||||
|
install-bin : all
|
||||||
if [ ! -d "$(DESTDIR)$(bindir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(bindir)" ; fi
|
if [ ! -d "$(DESTDIR)$(bindir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(bindir)" ; fi
|
||||||
$(INSTALL_PROGRAM) ./$(progname) "$(DESTDIR)$(bindir)/$(progname)"
|
$(INSTALL_PROGRAM) ./$(progname) "$(DESTDIR)$(bindir)/$(progname)"
|
||||||
|
|
||||||
install-info :
|
install-info :
|
||||||
if [ ! -d "$(DESTDIR)$(infodir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(infodir)" ; fi
|
if [ ! -d "$(DESTDIR)$(infodir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(infodir)" ; fi
|
||||||
$(INSTALL_DATA) $(VPATH)/doc/$(pkgname).info "$(DESTDIR)$(infodir)/$(pkgname).info"
|
$(INSTALL_DATA) $(VPATH)/doc/$(pkgname).info "$(DESTDIR)$(infodir)/$(pkgname).info"
|
||||||
-install-info --info-dir="$(DESTDIR)$(infodir)" $(DESTDIR)$(infodir)/$(pkgname).info
|
-install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$(pkgname).info"
|
||||||
|
|
||||||
install-man :
|
install-man :
|
||||||
if [ ! -d "$(DESTDIR)$(mandir)/man1" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1" ; fi
|
if [ ! -d "$(DESTDIR)$(mandir)/man1" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(mandir)/man1" ; fi
|
||||||
|
@ -74,7 +72,13 @@ install-man :
|
||||||
install-strip : all
|
install-strip : all
|
||||||
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
|
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' install
|
||||||
|
|
||||||
uninstall : uninstall-man
|
install-as-lzip : install
|
||||||
|
-rm -f "$(DESTDIR)$(bindir)/lzip"
|
||||||
|
cd "$(DESTDIR)$(bindir)" && ln -s $(progname) lzip
|
||||||
|
|
||||||
|
uninstall : uninstall-bin uninstall-man
|
||||||
|
|
||||||
|
uninstall-bin :
|
||||||
-rm -f "$(DESTDIR)$(bindir)/$(progname)"
|
-rm -f "$(DESTDIR)$(bindir)/$(progname)"
|
||||||
|
|
||||||
uninstall-info :
|
uninstall-info :
|
||||||
|
@ -97,8 +101,8 @@ dist : doc
|
||||||
$(DISTNAME)/doc/$(progname).1 \
|
$(DISTNAME)/doc/$(progname).1 \
|
||||||
$(DISTNAME)/testsuite/check.sh \
|
$(DISTNAME)/testsuite/check.sh \
|
||||||
$(DISTNAME)/testsuite/test.txt \
|
$(DISTNAME)/testsuite/test.txt \
|
||||||
$(DISTNAME)/testsuite/test.lz \
|
$(DISTNAME)/testsuite/test.txt.lz \
|
||||||
$(DISTNAME)/testsuite/test.lzma \
|
$(DISTNAME)/testsuite/test.txt.lzma \
|
||||||
$(DISTNAME)/*.h \
|
$(DISTNAME)/*.h \
|
||||||
$(DISTNAME)/*.c
|
$(DISTNAME)/*.c
|
||||||
rm -f $(DISTNAME)
|
rm -f $(DISTNAME)
|
||||||
|
|
20
NEWS
20
NEWS
|
@ -1,8 +1,18 @@
|
||||||
Changes in version 1.3:
|
Changes in version 1.4:
|
||||||
|
|
||||||
A small change has been made in the "--help" output and man page.
|
The options "-f, --force", "-F, --recompress", "-k, --keep", and
|
||||||
|
"-o, --output", have been ported from clzip.
|
||||||
|
|
||||||
Quote characters in messages have been changed as advised by GNU Coding
|
Pdlzip now accepts more than one file in the command line.
|
||||||
Standards.
|
|
||||||
|
|
||||||
Standard input and standard output are now set in binary mode on OS2.
|
Decompression time has been reduced by 5%.
|
||||||
|
|
||||||
|
The dependence of "--test" on the existence of "/dev/null" has been
|
||||||
|
removed.
|
||||||
|
|
||||||
|
Configure option "--datadir" has been renamed to "--datarootdir" to
|
||||||
|
follow GNU Standards.
|
||||||
|
|
||||||
|
The target "install-as-lzip" has been added to the Makefile.
|
||||||
|
|
||||||
|
The target "install-bin" has been added to the Makefile.
|
||||||
|
|
13
README
13
README
|
@ -6,17 +6,20 @@ gzip or bzip2. Pdlzip decompresses almost as fast as gzip and compresses
|
||||||
better than bzip2, which makes it well suited for software distribution
|
better than bzip2, which makes it well suited for software distribution
|
||||||
and data archiving.
|
and data archiving.
|
||||||
|
|
||||||
|
Pdlzip uses the lzip file format; the files produced by pdlzip are
|
||||||
|
(hope)fully compatible with lzip-1.4 or newer. Pdlzip is in fact a
|
||||||
|
"public domain" version of the lzip data compressor, intended for those
|
||||||
|
who can't distribute GPL licensed Free Software.
|
||||||
|
|
||||||
Pdlzip is also able to decompress legacy lzma-alone (.lzma) files.
|
Pdlzip is also able to decompress legacy lzma-alone (.lzma) files.
|
||||||
|
|
||||||
Pdlzip is a "public domain" version of the lzip data compressor,
|
|
||||||
intended for those who can't distribute GPL licensed Free Software.
|
|
||||||
Pdlzip is written in C.
|
Pdlzip is written in C.
|
||||||
|
|
||||||
Pdlzip uses public domain compression code from the LZMA SDK written by
|
Pdlzip includes public domain compression code from the LZMA SDK written
|
||||||
Igor Pavlov.
|
by Igor Pavlov.
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2010, 2011, 2012 Antonio Diaz Diaz.
|
Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This file is free documentation: you have unlimited permission to copy,
|
This file is free documentation: you have unlimited permission to copy,
|
||||||
distribute and modify it.
|
distribute and modify it.
|
||||||
|
|
225
Types.h
225
Types.h
|
@ -1,225 +0,0 @@
|
||||||
/* Types.h -- Basic types
|
|
||||||
2009-11-23 : Igor Pavlov : Public domain */
|
|
||||||
|
|
||||||
#ifndef __7Z_TYPES_H
|
|
||||||
#define __7Z_TYPES_H
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <windows.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EXTERN_C_BEGIN
|
|
||||||
#ifdef __cplusplus
|
|
||||||
#define EXTERN_C_BEGIN extern "C" {
|
|
||||||
#define EXTERN_C_END }
|
|
||||||
#else
|
|
||||||
#define EXTERN_C_BEGIN
|
|
||||||
#define EXTERN_C_END
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EXTERN_C_BEGIN
|
|
||||||
|
|
||||||
#define SZ_OK 0
|
|
||||||
|
|
||||||
#define SZ_ERROR_DATA 1
|
|
||||||
#define SZ_ERROR_MEM 2
|
|
||||||
#define SZ_ERROR_CRC 3
|
|
||||||
#define SZ_ERROR_UNSUPPORTED 4
|
|
||||||
#define SZ_ERROR_PARAM 5
|
|
||||||
#define SZ_ERROR_INPUT_EOF 6
|
|
||||||
#define SZ_ERROR_OUTPUT_EOF 7
|
|
||||||
#define SZ_ERROR_READ 8
|
|
||||||
#define SZ_ERROR_WRITE 9
|
|
||||||
#define SZ_ERROR_PROGRESS 10
|
|
||||||
#define SZ_ERROR_FAIL 11
|
|
||||||
#define SZ_ERROR_THREAD 12
|
|
||||||
|
|
||||||
#define SZ_ERROR_ARCHIVE 16
|
|
||||||
#define SZ_ERROR_NO_ARCHIVE 17
|
|
||||||
|
|
||||||
typedef int SRes;
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
typedef DWORD WRes;
|
|
||||||
#else
|
|
||||||
typedef int WRes;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef RINOK
|
|
||||||
#define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; }
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef unsigned char Byte;
|
|
||||||
typedef short Int16;
|
|
||||||
typedef unsigned short UInt16;
|
|
||||||
|
|
||||||
#ifdef _LZMA_UINT32_IS_ULONG
|
|
||||||
typedef long Int32;
|
|
||||||
typedef unsigned long UInt32;
|
|
||||||
#else
|
|
||||||
typedef int Int32;
|
|
||||||
typedef unsigned int UInt32;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _SZ_NO_INT_64
|
|
||||||
|
|
||||||
/* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers.
|
|
||||||
NOTES: Some code will work incorrectly in that case! */
|
|
||||||
|
|
||||||
typedef long Int64;
|
|
||||||
typedef unsigned long UInt64;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#if defined(_MSC_VER) || defined(__BORLANDC__)
|
|
||||||
typedef __int64 Int64;
|
|
||||||
typedef unsigned __int64 UInt64;
|
|
||||||
#else
|
|
||||||
typedef long long int Int64;
|
|
||||||
typedef unsigned long long int UInt64;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _LZMA_NO_SYSTEM_SIZE_T
|
|
||||||
typedef UInt32 SizeT;
|
|
||||||
#else
|
|
||||||
typedef size_t SizeT;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef int Bool;
|
|
||||||
#define True 1
|
|
||||||
#define False 0
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#define MY_STD_CALL __stdcall
|
|
||||||
#else
|
|
||||||
#define MY_STD_CALL
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
|
|
||||||
#if _MSC_VER >= 1300
|
|
||||||
#define MY_NO_INLINE __declspec(noinline)
|
|
||||||
#else
|
|
||||||
#define MY_NO_INLINE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define MY_CDECL __cdecl
|
|
||||||
#define MY_FAST_CALL __fastcall
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
#define MY_CDECL
|
|
||||||
#define MY_FAST_CALL
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* The following interfaces use first parameter as pointer to structure */
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
SRes (*Read)(void *p, void *buf, size_t *size);
|
|
||||||
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
|
|
||||||
(output(*size) < input(*size)) is allowed */
|
|
||||||
} ISeqInStream;
|
|
||||||
|
|
||||||
/* it can return SZ_ERROR_INPUT_EOF */
|
|
||||||
SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size);
|
|
||||||
SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType);
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
size_t (*Write)(void *p, const void *buf, size_t size);
|
|
||||||
/* Returns: result - the number of actually written bytes.
|
|
||||||
(result < size) means error */
|
|
||||||
} ISeqOutStream;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SZ_SEEK_SET = 0,
|
|
||||||
SZ_SEEK_CUR = 1,
|
|
||||||
SZ_SEEK_END = 2
|
|
||||||
} ESzSeek;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */
|
|
||||||
SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
|
|
||||||
} ISeekInStream;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
SRes (*Look)(void *p, void **buf, size_t *size);
|
|
||||||
/* if (input(*size) != 0 && output(*size) == 0) means end_of_stream.
|
|
||||||
(output(*size) > input(*size)) is not allowed
|
|
||||||
(output(*size) < input(*size)) is allowed */
|
|
||||||
SRes (*Skip)(void *p, size_t offset);
|
|
||||||
/* offset must be <= output(*size) of Look */
|
|
||||||
|
|
||||||
SRes (*Read)(void *p, void *buf, size_t *size);
|
|
||||||
/* reads directly (without buffer). It's same as ISeqInStream::Read */
|
|
||||||
SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin);
|
|
||||||
} ILookInStream;
|
|
||||||
|
|
||||||
SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size);
|
|
||||||
SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset);
|
|
||||||
|
|
||||||
/* reads via ILookInStream::Read */
|
|
||||||
SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType);
|
|
||||||
SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size);
|
|
||||||
|
|
||||||
#define LookToRead_BUF_SIZE (1 << 14)
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
ILookInStream s;
|
|
||||||
ISeekInStream *realStream;
|
|
||||||
size_t pos;
|
|
||||||
size_t size;
|
|
||||||
Byte buf[LookToRead_BUF_SIZE];
|
|
||||||
} CLookToRead;
|
|
||||||
|
|
||||||
void LookToRead_CreateVTable(CLookToRead *p, int lookahead);
|
|
||||||
void LookToRead_Init(CLookToRead *p);
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
ISeqInStream s;
|
|
||||||
ILookInStream *realStream;
|
|
||||||
} CSecToLook;
|
|
||||||
|
|
||||||
void SecToLook_CreateVTable(CSecToLook *p);
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
ISeqInStream s;
|
|
||||||
ILookInStream *realStream;
|
|
||||||
} CSecToRead;
|
|
||||||
|
|
||||||
void SecToRead_CreateVTable(CSecToRead *p);
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize);
|
|
||||||
/* Returns: result. (result != SZ_OK) means break.
|
|
||||||
Value (UInt64)(Int64)-1 for size means unknown value. */
|
|
||||||
} ICompressProgress;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
void *(*Alloc)(void *p, size_t size);
|
|
||||||
void (*Free)(void *p, void *address); /* address can be 0 */
|
|
||||||
} ISzAlloc;
|
|
||||||
|
|
||||||
#define IAlloc_Alloc(p, size) (p)->Alloc((p), size)
|
|
||||||
#define IAlloc_Free(p, a) (p)->Free((p), a)
|
|
||||||
|
|
||||||
EXTERN_C_END
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "pdarg_parser.h"
|
#include "carg_parser.h"
|
||||||
|
|
||||||
|
|
||||||
/* assure at least a minimum size for buffer 'buf' */
|
/* assure at least a minimum size for buffer 'buf' */
|
||||||
|
@ -71,7 +71,7 @@ static char parse_long_option( struct Arg_parser * const ap,
|
||||||
const struct ap_Option options[],
|
const struct ap_Option options[],
|
||||||
int * const argindp )
|
int * const argindp )
|
||||||
{
|
{
|
||||||
unsigned int len;
|
unsigned len;
|
||||||
int index = -1;
|
int index = -1;
|
||||||
int i;
|
int i;
|
||||||
char exact = 0, ambig = 0;
|
char exact = 0, ambig = 0;
|
|
@ -1,5 +1,5 @@
|
||||||
/* Pdlzip - Data compressor based on the LZMA algorithm
|
/* Pdlzip - Data compressor based on the LZMA algorithm
|
||||||
Copyright (C) 2010, 2011, 2012 Antonio Diaz Diaz.
|
Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This program is free software: you have unlimited permission
|
This program is free software: you have unlimited permission
|
||||||
to copy, distribute and modify it.
|
to copy, distribute and modify it.
|
||||||
|
@ -21,10 +21,12 @@ typedef enum Bool bool;
|
||||||
#define min(x,y) ((x) <= (y) ? (x) : (y))
|
#define min(x,y) ((x) <= (y) ? (x) : (y))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef int State;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
min_dictionary_bits = 12,
|
min_dictionary_bits = 12,
|
||||||
min_dictionary_size = 1 << min_dictionary_bits,
|
min_dictionary_size = 1 << min_dictionary_bits,
|
||||||
max_dictionary_bits = 26,
|
max_dictionary_bits = 29,
|
||||||
max_dictionary_size = 1 << max_dictionary_bits,
|
max_dictionary_size = 1 << max_dictionary_bits,
|
||||||
literal_context_bits = 3,
|
literal_context_bits = 3,
|
||||||
pos_state_bits = 2,
|
pos_state_bits = 2,
|
||||||
|
@ -41,16 +43,43 @@ enum {
|
||||||
max_match_len = min_match_len + max_len_symbols - 1, /* 273 */
|
max_match_len = min_match_len + max_len_symbols - 1, /* 273 */
|
||||||
min_match_len_limit = 5 };
|
min_match_len_limit = 5 };
|
||||||
|
|
||||||
|
|
||||||
|
struct Pretty_print
|
||||||
|
{
|
||||||
|
const char * name;
|
||||||
|
const char * stdin_name;
|
||||||
|
int longest_name;
|
||||||
|
int verbosity;
|
||||||
|
bool first_post;
|
||||||
|
};
|
||||||
|
|
||||||
|
void Pp_init( struct Pretty_print * const pp, const char * const filenames[],
|
||||||
|
const int num_filenames, const int v );
|
||||||
|
|
||||||
|
static inline void Pp_set_name( struct Pretty_print * const pp,
|
||||||
|
const char * const filename )
|
||||||
|
{
|
||||||
|
if( filename && filename[0] && strcmp( filename, "-" ) != 0 )
|
||||||
|
pp->name = filename;
|
||||||
|
else pp->name = pp->stdin_name;
|
||||||
|
pp->first_post = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void Pp_reset( struct Pretty_print * const pp )
|
||||||
|
{ if( pp->name && pp->name[0] ) pp->first_post = true; }
|
||||||
|
void Pp_show_msg( struct Pretty_print * const pp, const char * const msg );
|
||||||
|
|
||||||
|
|
||||||
typedef uint32_t CRC32[256]; /* Table of CRCs of all 8-bit messages. */
|
typedef uint32_t CRC32[256]; /* Table of CRCs of all 8-bit messages. */
|
||||||
|
|
||||||
extern CRC32 crc32;
|
extern CRC32 crc32;
|
||||||
|
|
||||||
static inline void CRC32_init()
|
static inline void CRC32_init( void )
|
||||||
{
|
{
|
||||||
unsigned int n;
|
unsigned n;
|
||||||
for( n = 0; n < 256; ++n )
|
for( n = 0; n < 256; ++n )
|
||||||
{
|
{
|
||||||
unsigned int c = n;
|
unsigned c = n;
|
||||||
int k;
|
int k;
|
||||||
for( k = 0; k < 8; ++k )
|
for( k = 0; k < 8; ++k )
|
||||||
{ if( c & 1 ) c = 0xEDB88320U ^ ( c >> 1 ); else c >>= 1; }
|
{ if( c & 1 ) c = 0xEDB88320U ^ ( c >> 1 ); else c >>= 1; }
|
||||||
|
@ -58,10 +87,11 @@ static inline void CRC32_init()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void CRC32_update_byte( uint32_t * crc, const uint8_t byte )
|
static inline void CRC32_update_byte( uint32_t * const crc, const uint8_t byte )
|
||||||
{ *crc = crc32[(*crc^byte)&0xFF] ^ ( *crc >> 8 ); }
|
{ *crc = crc32[(*crc^byte)&0xFF] ^ ( *crc >> 8 ); }
|
||||||
static inline void CRC32_update_buf( uint32_t * crc, const uint8_t * const buffer,
|
|
||||||
const int size )
|
static inline void CRC32_update_buf( uint32_t * const crc,
|
||||||
|
const uint8_t * const buffer, const int size )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for( i = 0; i < size; ++i )
|
for( i = 0; i < size; ++i )
|
||||||
|
@ -69,16 +99,15 @@ static inline void CRC32_update_buf( uint32_t * crc, const uint8_t * const buffe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline int real_bits( const int value )
|
static inline int real_bits( unsigned value )
|
||||||
{
|
{
|
||||||
int bits = 0, i, mask;
|
int bits = 0;
|
||||||
for( i = 1, mask = 1; mask > 0; ++i, mask <<= 1 )
|
while( value > 0 ) { value >>= 1; ++bits; }
|
||||||
if( value & mask ) bits = i;
|
|
||||||
return bits;
|
return bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t magic_string[4] = { 'L', 'Z', 'I', 'P' };
|
static const uint8_t magic_string[4] = { 0x4C, 0x5A, 0x49, 0x50 }; /* "LZIP" */
|
||||||
|
|
||||||
typedef uint8_t File_header[6]; /* 0-3 magic bytes */
|
typedef uint8_t File_header[6]; /* 0-3 magic bytes */
|
||||||
/* 4 version */
|
/* 4 version */
|
||||||
|
@ -86,15 +115,10 @@ typedef uint8_t File_header[6]; /* 0-3 magic bytes */
|
||||||
enum { Fh_size = 6 };
|
enum { Fh_size = 6 };
|
||||||
|
|
||||||
static inline void Fh_set_magic( File_header data )
|
static inline void Fh_set_magic( File_header data )
|
||||||
{
|
{ memcpy( data, magic_string, 4 ); data[4] = 1; }
|
||||||
memcpy( data, magic_string, 4 );
|
|
||||||
data[4] = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline bool Fh_verify_magic( const File_header data )
|
static inline bool Fh_verify_magic( const File_header data )
|
||||||
{
|
{ return ( memcmp( data, magic_string, 4 ) == 0 ); }
|
||||||
return ( memcmp( data, magic_string, 4 ) == 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint8_t Fh_version( const File_header data )
|
static inline uint8_t Fh_version( const File_header data )
|
||||||
{ return data[4]; }
|
{ return data[4]; }
|
||||||
|
@ -102,11 +126,11 @@ static inline uint8_t Fh_version( const File_header data )
|
||||||
static inline bool Fh_verify_version( const File_header data )
|
static inline bool Fh_verify_version( const File_header data )
|
||||||
{ return ( data[4] <= 1 ); }
|
{ return ( data[4] <= 1 ); }
|
||||||
|
|
||||||
static inline int Fh_get_dictionary_size( const File_header data )
|
static inline unsigned Fh_get_dictionary_size( const File_header data )
|
||||||
{
|
{
|
||||||
int sz = ( 1 << ( data[5] & 0x1F ) );
|
unsigned sz = ( 1 << ( data[5] & 0x1F ) );
|
||||||
if( sz > min_dictionary_size && sz <= max_dictionary_size )
|
if( sz > min_dictionary_size )
|
||||||
sz -= ( sz / 16 ) * ( ( data[5] >> 5 ) & 0x07 );
|
sz -= ( sz / 16 ) * ( ( data[5] >> 5 ) & 7 );
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,51 +164,60 @@ enum { Ft_size = 20 };
|
||||||
static inline int Ft_versioned_size( const int version )
|
static inline int Ft_versioned_size( const int version )
|
||||||
{ return ( ( version >= 1 ) ? 20 : 12 ); }
|
{ return ( ( version >= 1 ) ? 20 : 12 ); }
|
||||||
|
|
||||||
static inline uint32_t Ft_get_data_crc( const File_trailer data )
|
static inline unsigned Ft_get_data_crc( const File_trailer data )
|
||||||
{
|
{
|
||||||
uint32_t tmp = 0;
|
unsigned tmp = 0;
|
||||||
int i;
|
int i;
|
||||||
for( i = 3; i >= 0; --i ) { tmp <<= 8; tmp += data[i]; }
|
for( i = 3; i >= 0; --i ) { tmp <<= 8; tmp += data[i]; }
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Ft_set_data_crc( File_trailer data, uint32_t crc )
|
static inline void Ft_set_data_crc( File_trailer data, unsigned crc )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for( i = 0; i <= 3; ++i ) { data[i] = (uint8_t)crc; crc >>= 8; }
|
for( i = 0; i <= 3; ++i ) { data[i] = (uint8_t)crc; crc >>= 8; }
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline long long Ft_get_data_size( const File_trailer data )
|
static inline unsigned long long Ft_get_data_size( const File_trailer data )
|
||||||
{
|
{
|
||||||
long long tmp = 0;
|
unsigned long long tmp = 0;
|
||||||
int i;
|
int i;
|
||||||
for( i = 11; i >= 4; --i ) { tmp <<= 8; tmp += data[i]; }
|
for( i = 11; i >= 4; --i ) { tmp <<= 8; tmp += data[i]; }
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Ft_set_data_size( File_trailer data, long long sz )
|
static inline void Ft_set_data_size( File_trailer data, unsigned long long sz )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for( i = 4; i <= 11; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; }
|
for( i = 4; i <= 11; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; }
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline long long Ft_get_member_size( const File_trailer data )
|
static inline unsigned long long Ft_get_member_size( const File_trailer data )
|
||||||
{
|
{
|
||||||
long long tmp = 0;
|
unsigned long long tmp = 0;
|
||||||
int i;
|
int i;
|
||||||
for( i = 19; i >= 12; --i ) { tmp <<= 8; tmp += data[i]; }
|
for( i = 19; i >= 12; --i ) { tmp <<= 8; tmp += data[i]; }
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Ft_set_member_size( File_trailer data, long long sz )
|
static inline void Ft_set_member_size( File_trailer data, unsigned long long sz )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for( i = 12; i <= 19; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; }
|
for( i = 12; i <= 19; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* defined in LzmaDec.c */
|
||||||
|
int readblock( const int fd, uint8_t * const buf, const int size );
|
||||||
|
int writeblock( const int fd, const uint8_t * const buf, const int size );
|
||||||
|
|
||||||
/* defined in main.c */
|
/* defined in main.c */
|
||||||
extern int verbosity;
|
extern int verbosity;
|
||||||
|
|
||||||
void show_error( const char * const msg, const int errcode, const bool help );
|
void show_error( const char * const msg, const int errcode, const bool help );
|
||||||
void internal_error( const char * const msg );
|
void internal_error( const char * const msg );
|
||||||
|
|
||||||
|
#define SZ_OK 0
|
||||||
|
|
||||||
|
#define SZ_ERROR_READ 8
|
||||||
|
#define SZ_ERROR_WRITE 9
|
93
configure
vendored
93
configure
vendored
|
@ -1,6 +1,6 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# configure script for Pdlzip - Data compressor based on the LZMA algorithm
|
# configure script for Pdlzip - Data compressor based on the LZMA algorithm
|
||||||
# Copyright (C) 2010, 2011, 2012 Antonio Diaz Diaz.
|
# Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
#
|
#
|
||||||
# This configure script is free software: you have unlimited permission
|
# This configure script is free software: you have unlimited permission
|
||||||
# to copy, distribute and modify it.
|
# to copy, distribute and modify it.
|
||||||
|
@ -8,9 +8,9 @@
|
||||||
args=
|
args=
|
||||||
no_create=
|
no_create=
|
||||||
pkgname=pdlzip
|
pkgname=pdlzip
|
||||||
pkgversion=1.3
|
pkgversion=1.4-rc1
|
||||||
progname=pdlzip
|
progname=pdlzip
|
||||||
srctrigger=pdlzip.h
|
srctrigger=clzip.h
|
||||||
|
|
||||||
# clear some things potentially inherited from environment.
|
# clear some things potentially inherited from environment.
|
||||||
LC_ALL=C
|
LC_ALL=C
|
||||||
|
@ -19,15 +19,22 @@ srcdir=
|
||||||
prefix=/usr/local
|
prefix=/usr/local
|
||||||
exec_prefix='$(prefix)'
|
exec_prefix='$(prefix)'
|
||||||
bindir='$(exec_prefix)/bin'
|
bindir='$(exec_prefix)/bin'
|
||||||
datadir='$(prefix)/share'
|
datarootdir='$(prefix)/share'
|
||||||
infodir='$(datadir)/info'
|
infodir='$(datarootdir)/info'
|
||||||
mandir='$(datadir)/man'
|
mandir='$(datarootdir)/man'
|
||||||
sysconfdir='$(prefix)/etc'
|
CC=gcc
|
||||||
CC=
|
|
||||||
CPPFLAGS=
|
CPPFLAGS=
|
||||||
CFLAGS='-Wall -W -O2'
|
CFLAGS='-Wall -W -O2'
|
||||||
LDFLAGS=
|
LDFLAGS=
|
||||||
|
|
||||||
|
# checking whether we are using GNU C.
|
||||||
|
if [ ! -x /bin/gcc ] &&
|
||||||
|
[ ! -x /usr/bin/gcc ] &&
|
||||||
|
[ ! -x /usr/local/bin/gcc ] ; then
|
||||||
|
CC=cc
|
||||||
|
CFLAGS='-W -O2'
|
||||||
|
fi
|
||||||
|
|
||||||
# Loop over all args
|
# Loop over all args
|
||||||
while [ -n "$1" ] ; do
|
while [ -n "$1" ] ; do
|
||||||
|
|
||||||
|
@ -40,12 +47,12 @@ while [ -n "$1" ] ; do
|
||||||
|
|
||||||
# Split out the argument for options that take them
|
# Split out the argument for options that take them
|
||||||
case ${option} in
|
case ${option} in
|
||||||
*=*) optarg=`echo ${option} | sed -e 's,^[^=]*=,,'` ;;
|
*=*) optarg=`echo ${option} | sed -e 's,^[^=]*=,,;s,/$,,'` ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Process the options
|
# Process the options
|
||||||
case ${option} in
|
case ${option} in
|
||||||
--help | --he* | -h)
|
--help | -h)
|
||||||
echo "Usage: configure [options]"
|
echo "Usage: configure [options]"
|
||||||
echo
|
echo
|
||||||
echo "Options: [defaults in brackets]"
|
echo "Options: [defaults in brackets]"
|
||||||
|
@ -55,42 +62,31 @@ while [ -n "$1" ] ; do
|
||||||
echo " --prefix=DIR install into DIR [${prefix}]"
|
echo " --prefix=DIR install into DIR [${prefix}]"
|
||||||
echo " --exec-prefix=DIR base directory for arch-dependent files [${exec_prefix}]"
|
echo " --exec-prefix=DIR base directory for arch-dependent files [${exec_prefix}]"
|
||||||
echo " --bindir=DIR user executables directory [${bindir}]"
|
echo " --bindir=DIR user executables directory [${bindir}]"
|
||||||
echo " --datadir=DIR base directory for doc and data [${datadir}]"
|
echo " --datarootdir=DIR base directory for doc and data [${datarootdir}]"
|
||||||
echo " --infodir=DIR info files directory [${infodir}]"
|
echo " --infodir=DIR info files directory [${infodir}]"
|
||||||
echo " --mandir=DIR man pages directory [${mandir}]"
|
echo " --mandir=DIR man pages directory [${mandir}]"
|
||||||
echo " --sysconfdir=DIR read-only single-machine data directory [${sysconfdir}]"
|
|
||||||
echo " CC=COMPILER C compiler to use [gcc]"
|
echo " CC=COMPILER C compiler to use [gcc]"
|
||||||
echo " CPPFLAGS=OPTIONS command line options for the preprocessor [${CPPFLAGS}]"
|
echo " CPPFLAGS=OPTIONS command line options for the preprocessor [${CPPFLAGS}]"
|
||||||
echo " CFLAGS=OPTIONS command line options for the C compiler [${CFLAGS}]"
|
echo " CFLAGS=OPTIONS command line options for the C compiler [${CFLAGS}]"
|
||||||
echo " LDFLAGS=OPTIONS command line options for the linker [${LDFLAGS}]"
|
echo " LDFLAGS=OPTIONS command line options for the linker [${LDFLAGS}]"
|
||||||
echo
|
echo
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
--version | --ve* | -V)
|
--version | -V)
|
||||||
echo "Configure script for ${pkgname} version ${pkgversion}"
|
echo "Configure script for ${pkgname} version ${pkgversion}"
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
--srcdir* | --sr*)
|
--srcdir=*) srcdir=${optarg} ;;
|
||||||
srcdir=`echo ${optarg} | sed -e 's,/$,,'` ;;
|
--prefix=*) prefix=${optarg} ;;
|
||||||
--prefix* | --pr*)
|
--exec-prefix=*) exec_prefix=${optarg} ;;
|
||||||
prefix=`echo ${optarg} | sed -e 's,/$,,'` ;;
|
--bindir=*) bindir=${optarg} ;;
|
||||||
--exec-prefix* | --ex*)
|
--datarootdir=*) datarootdir=${optarg} ;;
|
||||||
exec_prefix=`echo ${optarg} | sed -e 's,/$,,'` ;;
|
--infodir=*) infodir=${optarg} ;;
|
||||||
--bindir* | --bi*)
|
--mandir=*) mandir=${optarg} ;;
|
||||||
bindir=`echo ${optarg} | sed -e 's,/$,,'` ;;
|
--no-create) no_create=yes ;;
|
||||||
--datadir* | --da*)
|
|
||||||
datadir=`echo ${optarg} | sed -e 's,/$,,'` ;;
|
|
||||||
--infodir* | --inf*)
|
|
||||||
infodir=`echo ${optarg} | sed -e 's,/$,,'` ;;
|
|
||||||
--mandir* | --ma*)
|
|
||||||
mandir=`echo ${optarg} | sed -e 's,/$,,'` ;;
|
|
||||||
--sysconfdir* | --sy*)
|
|
||||||
sysconfdir=`echo ${optarg} | sed -e 's,/$,,'` ;;
|
|
||||||
--no-create | --no-c*)
|
|
||||||
no_create=yes ;;
|
|
||||||
|
|
||||||
CC=*) CC=${optarg} ;;
|
CC=*) CC=${optarg} ;;
|
||||||
CPPFLAGS=*) CPPFLAGS=${optarg} ;;
|
CPPFLAGS=*) CPPFLAGS=${optarg} ;;
|
||||||
CFLAGS=*) CFLAGS=${optarg} ;;
|
CFLAGS=*) CFLAGS=${optarg} ;;
|
||||||
LDFLAGS=*) LDFLAGS=${optarg} ;;
|
LDFLAGS=*) LDFLAGS=${optarg} ;;
|
||||||
|
|
||||||
--* | *=* | *-*-*) ;;
|
--* | *=* | *-*-*) ;;
|
||||||
*)
|
*)
|
||||||
|
@ -103,14 +99,14 @@ done
|
||||||
srcdirtext=
|
srcdirtext=
|
||||||
if [ -z "${srcdir}" ] ; then
|
if [ -z "${srcdir}" ] ; then
|
||||||
srcdirtext="or . or .." ; srcdir=.
|
srcdirtext="or . or .." ; srcdir=.
|
||||||
if [ ! -r ${srcdir}/${srctrigger} ] ; then srcdir=.. ; fi
|
if [ ! -r "${srcdir}/${srctrigger}" ] ; then srcdir=.. ; fi
|
||||||
if [ ! -r ${srcdir}/${srctrigger} ] ; then
|
if [ ! -r "${srcdir}/${srctrigger}" ] ; then
|
||||||
## the sed command below emulates the dirname command
|
## the sed command below emulates the dirname command
|
||||||
srcdir=`echo $0 | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
srcdir=`echo $0 | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -r ${srcdir}/${srctrigger} ] ; then
|
if [ ! -r "${srcdir}/${srctrigger}" ] ; then
|
||||||
exec 1>&2
|
exec 1>&2
|
||||||
echo
|
echo
|
||||||
echo "configure: Can't find sources in ${srcdir} ${srcdirtext}"
|
echo "configure: Can't find sources in ${srcdir} ${srcdirtext}"
|
||||||
|
@ -119,18 +115,7 @@ if [ ! -r ${srcdir}/${srctrigger} ] ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set srcdir to . if that's what it is.
|
# Set srcdir to . if that's what it is.
|
||||||
if [ "`pwd`" = "`cd ${srcdir} ; pwd`" ] ; then srcdir=. ; fi
|
if [ "`pwd`" = "`cd "${srcdir}" ; pwd`" ] ; then srcdir=. ; fi
|
||||||
|
|
||||||
# checking whether we are using GNU C.
|
|
||||||
if [ -z "${CC}" ] ; then # Let the user override the test.
|
|
||||||
if [ -x /bin/gcc ] ||
|
|
||||||
[ -x /usr/bin/gcc ] ||
|
|
||||||
[ -x /usr/local/bin/gcc ] ; then
|
|
||||||
CC="gcc"
|
|
||||||
else
|
|
||||||
CC="cc"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
if [ -z "${no_create}" ] ; then
|
if [ -z "${no_create}" ] ; then
|
||||||
|
@ -154,10 +139,9 @@ echo "VPATH = ${srcdir}"
|
||||||
echo "prefix = ${prefix}"
|
echo "prefix = ${prefix}"
|
||||||
echo "exec_prefix = ${exec_prefix}"
|
echo "exec_prefix = ${exec_prefix}"
|
||||||
echo "bindir = ${bindir}"
|
echo "bindir = ${bindir}"
|
||||||
echo "datadir = ${datadir}"
|
echo "datarootdir = ${datarootdir}"
|
||||||
echo "infodir = ${infodir}"
|
echo "infodir = ${infodir}"
|
||||||
echo "mandir = ${mandir}"
|
echo "mandir = ${mandir}"
|
||||||
echo "sysconfdir = ${sysconfdir}"
|
|
||||||
echo "CC = ${CC}"
|
echo "CC = ${CC}"
|
||||||
echo "CPPFLAGS = ${CPPFLAGS}"
|
echo "CPPFLAGS = ${CPPFLAGS}"
|
||||||
echo "CFLAGS = ${CFLAGS}"
|
echo "CFLAGS = ${CFLAGS}"
|
||||||
|
@ -165,7 +149,7 @@ echo "LDFLAGS = ${LDFLAGS}"
|
||||||
rm -f Makefile
|
rm -f Makefile
|
||||||
cat > Makefile << EOF
|
cat > Makefile << EOF
|
||||||
# Makefile for Pdlzip - Data compressor based on the LZMA algorithm
|
# Makefile for Pdlzip - Data compressor based on the LZMA algorithm
|
||||||
# Copyright (C) 2010, 2011, 2012 Antonio Diaz Diaz.
|
# Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
# This file was generated automatically by configure. Do not edit.
|
# This file was generated automatically by configure. Do not edit.
|
||||||
#
|
#
|
||||||
# This Makefile is free software: you have unlimited permission
|
# This Makefile is free software: you have unlimited permission
|
||||||
|
@ -178,15 +162,14 @@ VPATH = ${srcdir}
|
||||||
prefix = ${prefix}
|
prefix = ${prefix}
|
||||||
exec_prefix = ${exec_prefix}
|
exec_prefix = ${exec_prefix}
|
||||||
bindir = ${bindir}
|
bindir = ${bindir}
|
||||||
datadir = ${datadir}
|
datarootdir = ${datarootdir}
|
||||||
infodir = ${infodir}
|
infodir = ${infodir}
|
||||||
mandir = ${mandir}
|
mandir = ${mandir}
|
||||||
sysconfdir = ${sysconfdir}
|
|
||||||
CC = ${CC}
|
CC = ${CC}
|
||||||
CPPFLAGS = ${CPPFLAGS}
|
CPPFLAGS = ${CPPFLAGS}
|
||||||
CFLAGS = ${CFLAGS}
|
CFLAGS = ${CFLAGS}
|
||||||
LDFLAGS = ${LDFLAGS}
|
LDFLAGS = ${LDFLAGS}
|
||||||
EOF
|
EOF
|
||||||
cat ${srcdir}/Makefile.in >> Makefile
|
cat "${srcdir}/Makefile.in" >> Makefile
|
||||||
|
|
||||||
echo "OK. Now you can run make."
|
echo "OK. Now you can run make."
|
||||||
|
|
20
doc/pdlzip.1
20
doc/pdlzip.1
|
@ -1,10 +1,10 @@
|
||||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.37.1.
|
||||||
.TH PDLZIP "1" "January 2012" "Pdlzip 1.3" "User Commands"
|
.TH PDLZIP "1" "February 2013" "Pdlzip 1.4-rc1" "User Commands"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
Pdlzip \- reduces the size of files
|
Pdlzip \- reduces the size of files
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B pdlzip
|
.B pdlzip
|
||||||
[\fIoptions\fR] [\fIfile\fR]
|
[\fIoptions\fR] [\fIfiles\fR]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Pdlzip \- A "public domain" version of the lzip data compressor
|
Pdlzip \- A "public domain" version of the lzip data compressor
|
||||||
also able to decompress legacy lzma\-alone (.lzma) files.
|
also able to decompress legacy lzma\-alone (.lzma) files.
|
||||||
|
@ -22,9 +22,21 @@ send output to standard output
|
||||||
\fB\-d\fR, \fB\-\-decompress\fR
|
\fB\-d\fR, \fB\-\-decompress\fR
|
||||||
decompress
|
decompress
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-f\fR, \fB\-\-force\fR
|
||||||
|
overwrite existing output files
|
||||||
|
.TP
|
||||||
|
\fB\-F\fR, \fB\-\-recompress\fR
|
||||||
|
force recompression of compressed files
|
||||||
|
.TP
|
||||||
|
\fB\-k\fR, \fB\-\-keep\fR
|
||||||
|
keep (don't delete) input files
|
||||||
|
.TP
|
||||||
\fB\-m\fR, \fB\-\-match\-length=\fR<bytes>
|
\fB\-m\fR, \fB\-\-match\-length=\fR<bytes>
|
||||||
set match length limit in bytes [36]
|
set match length limit in bytes [36]
|
||||||
.TP
|
.TP
|
||||||
|
\fB\-o\fR, \fB\-\-output=\fR<file>
|
||||||
|
if reading stdin, place the output into <file>
|
||||||
|
.TP
|
||||||
\fB\-q\fR, \fB\-\-quiet\fR
|
\fB\-q\fR, \fB\-\-quiet\fR
|
||||||
suppress all messages
|
suppress all messages
|
||||||
.TP
|
.TP
|
||||||
|
@ -46,7 +58,7 @@ alias for \fB\-1\fR
|
||||||
\fB\-\-best\fR
|
\fB\-\-best\fR
|
||||||
alias for \fB\-9\fR
|
alias for \fB\-9\fR
|
||||||
.PP
|
.PP
|
||||||
If no file name is given, pdlzip compresses or decompresses
|
If no file names are given, pdlzip compresses or decompresses
|
||||||
from standard input to standard output.
|
from standard input to standard output.
|
||||||
Numbers may be followed by a multiplier: k = kB = 10^3 = 1000,
|
Numbers may be followed by a multiplier: k = kB = 10^3 = 1000,
|
||||||
Ki = KiB = 2^10 = 1024, M = 10^6, Mi = 2^20, G = 10^9, Gi = 2^30, etc...
|
Ki = KiB = 2^10 = 1024, M = 10^6, Mi = 2^20, G = 10^9, Gi = 2^30, etc...
|
||||||
|
@ -59,7 +71,7 @@ Report bugs to lzip\-bug@nongnu.org
|
||||||
.br
|
.br
|
||||||
Pdlzip home page: http://www.nongnu.org/lzip/pdlzip.html
|
Pdlzip home page: http://www.nongnu.org/lzip/pdlzip.html
|
||||||
.SH COPYRIGHT
|
.SH COPYRIGHT
|
||||||
Copyright \(co 2012 Antonio Diaz Diaz.
|
Copyright \(co 2013 Antonio Diaz Diaz.
|
||||||
Public Domain 2009 Igor Pavlov.
|
Public Domain 2009 Igor Pavlov.
|
||||||
.br
|
.br
|
||||||
This is free software: you are free to change and redistribute it.
|
This is free software: you are free to change and redistribute it.
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# check script for Pdlzip - Data compressor based on the LZMA algorithm
|
# check script for Pdlzip - Data compressor based on the LZMA algorithm
|
||||||
# Copyright (C) 2010, 2011, 2012 Antonio Diaz Diaz.
|
# Copyright (C) 2010, 2011, 2012, 2013 Antonio Diaz Diaz.
|
||||||
#
|
#
|
||||||
# This script is free software: you have unlimited permission
|
# This script is free software: you have unlimited permission
|
||||||
# to copy, distribute and modify it.
|
# to copy, distribute and modify it.
|
||||||
|
@ -26,18 +26,32 @@ fail=0
|
||||||
|
|
||||||
printf "testing pdlzip-%s..." "$2"
|
printf "testing pdlzip-%s..." "$2"
|
||||||
|
|
||||||
"${LZIP}" -t "${testdir}"/test.lz || fail=1
|
"${LZIP}" -t "${testdir}"/test.txt.lz || fail=1
|
||||||
printf .
|
"${LZIP}" -cd "${testdir}"/test.txt.lz > copy || fail=1
|
||||||
"${LZIP}" -cd "${testdir}"/test.lz > copy || fail=1
|
|
||||||
cmp in copy || fail=1
|
cmp in copy || fail=1
|
||||||
printf .
|
printf .
|
||||||
|
|
||||||
"${LZIP}" -t "${testdir}"/test.lzma || fail=1
|
"${LZIP}" -cfq "${testdir}"/test.txt.lz > out
|
||||||
printf .
|
if [ $? != 1 ] ; then fail=1 ; printf - ; else printf . ; fi
|
||||||
"${LZIP}" -cd "${testdir}"/test.lzma > copy || fail=1
|
"${LZIP}" -cF "${testdir}"/test.txt.lz > out || fail=1
|
||||||
|
"${LZIP}" -cd out | "${LZIP}" -d > copy || fail=1
|
||||||
cmp in copy || fail=1
|
cmp in copy || fail=1
|
||||||
printf .
|
printf .
|
||||||
|
|
||||||
|
"${LZIP}" -t "${testdir}"/test.txt.lzma || fail=1
|
||||||
|
"${LZIP}" -cd "${testdir}"/test.txt.lzma > copy || fail=1
|
||||||
|
cmp in copy || fail=1
|
||||||
|
printf .
|
||||||
|
|
||||||
|
"${LZIP}" -cqs-1 in > out
|
||||||
|
if [ $? != 1 ] ; then fail=1 ; printf - ; else printf . ; fi
|
||||||
|
"${LZIP}" -cqs0 in > out
|
||||||
|
if [ $? != 1 ] ; then fail=1 ; printf - ; else printf . ; fi
|
||||||
|
"${LZIP}" -cqs4095 in > out
|
||||||
|
if [ $? != 1 ] ; then fail=1 ; printf - ; else printf . ; fi
|
||||||
|
"${LZIP}" -cqm274 in > out
|
||||||
|
if [ $? != 1 ] ; then fail=1 ; printf - ; else printf . ; fi
|
||||||
|
|
||||||
for i in s4Ki 0 1 2 3 4 5 6 7 8s16 9s16 ; do
|
for i in s4Ki 0 1 2 3 4 5 6 7 8s16 9s16 ; do
|
||||||
"${LZIP}" -k -$i in || fail=1
|
"${LZIP}" -k -$i in || fail=1
|
||||||
mv -f in.lz copy.lz || fail=1
|
mv -f in.lz copy.lz || fail=1
|
||||||
|
@ -62,11 +76,24 @@ for i in s4Ki 0 1 2 3 4 5 6 7 8s16 9s16 ; do
|
||||||
printf .
|
printf .
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for i in s4Ki 0 1 2 3 4 5 6 7 8s16 9s16 ; do
|
||||||
|
"${LZIP}" -f -$i -o out < in || fail=1
|
||||||
|
"${LZIP}" -df -o copy < out.lz || fail=1
|
||||||
|
cmp in copy || fail=1
|
||||||
|
printf .
|
||||||
|
done
|
||||||
|
|
||||||
"${LZIP}" < in > anyothername || fail=1
|
"${LZIP}" < in > anyothername || fail=1
|
||||||
"${LZIP}" -d anyothername || fail=1
|
"${LZIP}" -d anyothername || fail=1
|
||||||
cmp in anyothername.out || fail=1
|
cmp in anyothername.out || fail=1
|
||||||
printf .
|
printf .
|
||||||
|
|
||||||
|
cat in in > in2 || framework_failure
|
||||||
|
"${LZIP}" < in2 > out2 || fail=1
|
||||||
|
"${LZIP}" -d < out2 > copy2 || fail=1
|
||||||
|
cmp in2 copy2 || fail=1
|
||||||
|
printf .
|
||||||
|
|
||||||
echo
|
echo
|
||||||
if [ ${fail} = 0 ] ; then
|
if [ ${fail} = 0 ] ; then
|
||||||
echo "tests completed successfully."
|
echo "tests completed successfully."
|
||||||
|
|
Binary file not shown.
Binary file not shown.
BIN
testsuite/test.txt.lz
Normal file
BIN
testsuite/test.txt.lz
Normal file
Binary file not shown.
BIN
testsuite/test.txt.lzma
Normal file
BIN
testsuite/test.txt.lzma
Normal file
Binary file not shown.
Loading…
Add table
Reference in a new issue