Compare commits
No commits in common. "b64391bed2828414ca6f14bf24687151140941c0" and "f87096b5ddf7f76698c152199f594abf29f94942" have entirely different histories.
b64391bed2
...
f87096b5dd
30 changed files with 970 additions and 1626 deletions
4
AUTHORS
4
AUTHORS
|
@ -1,4 +1,4 @@
|
||||||
Pdlzip was written by Antonio Diaz Diaz.
|
Pdlzip was written by Antonio Diaz Diaz.
|
||||||
|
|
||||||
Pdlzip includes public domain compression/decompression code from the LZMA
|
Pdlzip includes public domain (de)compression code from the LZMA SDK
|
||||||
SDK (Software Development Kit) written by Igor Pavlov.
|
(Software Development Kit) written by Igor Pavlov.
|
||||||
|
|
19
COPYING
19
COPYING
|
@ -1,19 +0,0 @@
|
||||||
Pdlzip - LZMA lossless data compressor
|
|
||||||
Copyright (C) Antonio Diaz Diaz.
|
|
||||||
Pdlzip includes public domain (de)compression code from the LZMA SDK
|
|
||||||
(Software Development Kit) written by Igor Pavlov.
|
|
||||||
|
|
||||||
This program is free software. Redistribution and use in source and
|
|
||||||
binary forms, with or without modification, are permitted provided
|
|
||||||
that the following conditions are met:
|
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
|
||||||
notice, this list of conditions, and the following disclaimer.
|
|
||||||
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
notice, this list of conditions, and the following disclaimer in the
|
|
||||||
documentation and/or other materials provided with the distribution.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
109
ChangeLog
109
ChangeLog
|
@ -1,107 +1,39 @@
|
||||||
2025-01-07 Antonio Diaz Diaz <antonio@gnu.org>
|
|
||||||
|
|
||||||
* Version 1.14 released.
|
|
||||||
* main.c (decompress): Return 2 if empty member in multimember file.
|
|
||||||
(Pp_free): New function.
|
|
||||||
* check.sh: Use 'cp' instead of 'cat'.
|
|
||||||
|
|
||||||
2024-01-21 Antonio Diaz Diaz <antonio@gnu.org>
|
|
||||||
|
|
||||||
* Version 1.13 released.
|
|
||||||
* main.c: Reformat file diagnostics as 'PROGRAM: FILE: MESSAGE'.
|
|
||||||
(show_option_error): New function showing argument and option name.
|
|
||||||
(main): Make -o preserve date/mode/owner if 1 input file.
|
|
||||||
* lzip.h: Rename verify_* to check_*.
|
|
||||||
* configure, Makefile.in: New variable 'MAKEINFO'.
|
|
||||||
* INSTALL: Document use of CFLAGS+='--std=c99 -D_XOPEN_SOURCE=500'.
|
|
||||||
|
|
||||||
2022-01-21 Antonio Diaz Diaz <antonio@gnu.org>
|
|
||||||
|
|
||||||
* Version 1.12 released.
|
|
||||||
* main.c (getnum): Show option name and valid range if error.
|
|
||||||
|
|
||||||
2021-01-01 Antonio Diaz Diaz <antonio@gnu.org>
|
|
||||||
|
|
||||||
* Version 1.11 released.
|
|
||||||
* main.c (main): Report an error if a file name is empty.
|
|
||||||
Make '-o' behave like '-c', but writing to file instead of stdout.
|
|
||||||
Make '-c' and '-o' check whether the output is a terminal only once.
|
|
||||||
Do not open output if input is a terminal.
|
|
||||||
* Don't allow mixing different operations (-d and -t).
|
|
||||||
* Replace 'decompressed', 'compressed' with 'out', 'in' in output.
|
|
||||||
* Document extraction from tar.lz in '--help' output and man page.
|
|
||||||
* main.c: Set a valid invocation_name even if argc == 0.
|
|
||||||
* testsuite: Add 9 new test files.
|
|
||||||
|
|
||||||
2019-01-01 Antonio Diaz Diaz <antonio@gnu.org>
|
|
||||||
|
|
||||||
* Version 1.10 released.
|
|
||||||
* Rename File_* to Lzip_*.
|
|
||||||
* main.c: Document option -0 and make it use a 64 KiB dict size.
|
|
||||||
* main.c (main): Check return value of close( infd ).
|
|
||||||
* main.c: Compile on DOS with DJGPP.
|
|
||||||
* configure: Accept appending to CFLAGS; 'CFLAGS+=OPTIONS'.
|
|
||||||
* INSTALL: Document use of CFLAGS+='-D __USE_MINGW_ANSI_STDIO'.
|
|
||||||
|
|
||||||
2018-02-04 Antonio Diaz Diaz <antonio@gnu.org>
|
|
||||||
|
|
||||||
* Version 1.9 released.
|
|
||||||
* New option '--loose-trailing'.
|
|
||||||
* Replace 'bits/byte' with inverse compression ratio in output.
|
|
||||||
* main.c (decompress): Improve corrupt header detection to HD=3.
|
|
||||||
(main): Show final diagnostic when testing multiple files.
|
|
||||||
(set_c_outname): Do not add a second '.lz' to the arg of '-o'.
|
|
||||||
(lzip_decode): Show stored sizes also in hex.
|
|
||||||
Show dictionary size at verbosity level 4 (-vvvv).
|
|
||||||
|
|
||||||
2017-04-12 Antonio Diaz Diaz <antonio@gnu.org>
|
|
||||||
|
|
||||||
* Version 1.8 released.
|
|
||||||
* main.c: Continue testing if any input file is a terminal.
|
|
||||||
* main.c (decompress): Improve detection of trailing data.
|
|
||||||
|
|
||||||
2016-05-16 Antonio Diaz Diaz <antonio@gnu.org>
|
|
||||||
|
|
||||||
* Version 1.7 released.
|
|
||||||
* main.c: New option '-a, --trailing-error'.
|
|
||||||
* main.c (main): Delete '--output' file if infd is a terminal.
|
|
||||||
(main): Don't use stdin more than once.
|
|
||||||
* configure: Avoid warning on some shells when testing for gcc.
|
|
||||||
* check.sh: Require a POSIX shell. Don't check error messages.
|
|
||||||
|
|
||||||
2015-05-26 Antonio Diaz Diaz <antonio@gnu.org>
|
2015-05-26 Antonio Diaz Diaz <antonio@gnu.org>
|
||||||
|
|
||||||
* Version 1.6 released.
|
* Version 1.6 released.
|
||||||
* main.c (close_and_set_permissions): Behave like 'cp -p'.
|
* main.c (close_and_set_permissions): Behave like 'cp -p'.
|
||||||
* Makefile.in: New targets 'install*-compress'.
|
* Makefile.in: Added new targets 'install*-compress'.
|
||||||
|
|
||||||
2013-09-14 Antonio Diaz Diaz <antonio@gnu.org>
|
2013-09-14 Antonio Diaz Diaz <antonio@gnu.org>
|
||||||
|
|
||||||
* Version 1.5 released.
|
* Version 1.5 released.
|
||||||
* main.c (show_header): Don't show header version in lzip mode.
|
* main.c (show_header): Do not show header version in lzip mode.
|
||||||
* Minor fixes.
|
* Minor fixes.
|
||||||
|
|
||||||
2013-05-27 Antonio Diaz Diaz <antonio@gnu.org>
|
2013-05-27 Antonio Diaz Diaz <antonio@gnu.org>
|
||||||
|
|
||||||
* Version 1.4 released.
|
* Version 1.4 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%.
|
* Decompression time has been reduced by 5%.
|
||||||
* main.c: New options '-f, --force', '-F, --recompress',
|
* main.c: '--test' no longer needs '/dev/null'.
|
||||||
'-k, --keep', and '-o, --output'.
|
* Fixed return value of '-d' and '-t' in case of data error.
|
||||||
Accept more than one file in command line.
|
* main.c: Changed info shown at verbosity levels 2 and 3.
|
||||||
(main): '--test' no longer needs '/dev/null'.
|
* Ignore option '-n, --threads' for compatibility with plzip.
|
||||||
(main): Fix return value of '-d' and '-t' in case of data error.
|
|
||||||
Change info shown at verbosity levels 2 and 3.
|
|
||||||
(main): Ignore option '-n, --threads' for compatibility with plzip.
|
|
||||||
* configure: Options now accept a separate argument.
|
* configure: Options now accept a separate argument.
|
||||||
Rename 'datadir' to 'datarootdir'.
|
* configure: 'datadir' renamed to 'datarootdir'.
|
||||||
* Makefile.in: New targets 'install-as-lzip' and 'install-bin'.
|
* 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.
|
||||||
* Small change in '--help' output and man page.
|
* Small change in '--help' output and man page.
|
||||||
* Change quote characters in messages as advised by GNU Standards.
|
* Changed quote characters in messages as advised by GNU Standards.
|
||||||
* main.c (main): Set stdin/stdout in binary mode on OS2.
|
* main.c: Set stdin/stdout in binary mode on OS2.
|
||||||
|
|
||||||
2011-01-05 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
2011-01-05 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
||||||
|
|
||||||
|
@ -111,7 +43,7 @@
|
||||||
2010-08-19 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
2010-08-19 Antonio Diaz Diaz <ant_diaz@teleline.es>
|
||||||
|
|
||||||
* Version 1.1 released.
|
* Version 1.1 released.
|
||||||
* main.c: Add support for decompression of lzma-alone files.
|
* main.c: Added support for decompression of lzma-alone files.
|
||||||
* main.c: Match length limit set by options -1 to -8 has been
|
* main.c: Match length limit set by options -1 to -8 has been
|
||||||
reduced to extend range of use towards gzip. Lower numbers now
|
reduced to extend range of use towards gzip. Lower numbers now
|
||||||
compress less but faster. (-1 now takes 43% less time for only
|
compress less but faster. (-1 now takes 43% less time for only
|
||||||
|
@ -125,7 +57,8 @@
|
||||||
* Using LZMA SDK 9.10 (public domain) from Igor Pavlov.
|
* Using LZMA SDK 9.10 (public domain) from Igor Pavlov.
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
Copyright (C) 2010-2015 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This file is a collection of facts, and thus it is not copyrightable, but just
|
This file is a collection of facts, and thus it is not copyrightable,
|
||||||
in case, you have unlimited permission to copy, distribute, and modify it.
|
but just in case, you have unlimited permission to copy, distribute and
|
||||||
|
modify it.
|
||||||
|
|
50
INSTALL
50
INSTALL
|
@ -1,14 +1,9 @@
|
||||||
Requirements
|
Requirements
|
||||||
------------
|
------------
|
||||||
You will need a C99 compiler. (gcc 3.3.6 or newer is recommended).
|
You will need a C compiler.
|
||||||
I use gcc 6.1.0 and 3.3.6, but the code should compile with any standards
|
I use gcc 4.9.1 and 4.1.2, but the code should compile with any
|
||||||
compliant compiler.
|
standards compliant compiler.
|
||||||
Gcc is available at http://gcc.gnu.org
|
Gcc is available at http://gcc.gnu.org.
|
||||||
Lzip is available at http://www.nongnu.org/lzip/lzip.html
|
|
||||||
|
|
||||||
The operating system must allow signal handlers read access to objects with
|
|
||||||
static storage duration so that the cleanup handler for Control-C can delete
|
|
||||||
the partial output file.
|
|
||||||
|
|
||||||
|
|
||||||
Procedure
|
Procedure
|
||||||
|
@ -19,8 +14,8 @@ Procedure
|
||||||
or
|
or
|
||||||
lzip -cd pdlzip[version].tar.lz | tar -xf -
|
lzip -cd pdlzip[version].tar.lz | tar -xf -
|
||||||
|
|
||||||
This creates the directory ./pdlzip[version] containing the source code
|
This creates the directory ./pdlzip[version] containing the source from
|
||||||
extracted from the archive.
|
the main archive.
|
||||||
|
|
||||||
2. Change to pdlzip directory and run configure.
|
2. Change to pdlzip directory and run configure.
|
||||||
(Try 'configure --help' for usage instructions).
|
(Try 'configure --help' for usage instructions).
|
||||||
|
@ -28,14 +23,6 @@ extracted from the archive.
|
||||||
cd pdlzip[version]
|
cd pdlzip[version]
|
||||||
./configure
|
./configure
|
||||||
|
|
||||||
If you choose a C standard, enable the POSIX features explicitly:
|
|
||||||
|
|
||||||
./configure CFLAGS+='--std=c99 -D_XOPEN_SOURCE=500'
|
|
||||||
|
|
||||||
If you are compiling on MinGW, use:
|
|
||||||
|
|
||||||
./configure CFLAGS+='-D __USE_MINGW_ANSI_STDIO'
|
|
||||||
|
|
||||||
3. Run make.
|
3. Run make.
|
||||||
|
|
||||||
make
|
make
|
||||||
|
@ -43,15 +30,14 @@ extracted from the archive.
|
||||||
4. Optionally, type 'make check' to run the tests that come with pdlzip.
|
4. Optionally, type 'make check' to run the tests that come with pdlzip.
|
||||||
|
|
||||||
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. You need root privileges to install into a prefix owned
|
documentation.
|
||||||
by root.
|
|
||||||
|
|
||||||
Or type 'make install-compress', which additionally compresses the
|
Or type 'make install-compress', which additionally compresses the
|
||||||
man page after installation.
|
man page after installation. (Installing compressed docs may become
|
||||||
(Installing compressed docs may become the default in the future).
|
the default in the future).
|
||||||
|
|
||||||
You can install only the program or the man page by typing
|
You can install only the program or the man page by typing 'make
|
||||||
'make install-bin' or 'make install-man' respectively.
|
install-bin' or 'make install-man' respectively.
|
||||||
|
|
||||||
Instead of 'make install', you can type 'make install-as-lzip' to
|
Instead of 'make install', you can type 'make install-as-lzip' to
|
||||||
install the program and any data files and documentation, and link
|
install the program and any data files and documentation, and link
|
||||||
|
@ -61,21 +47,21 @@ extracted from the archive.
|
||||||
Another way
|
Another way
|
||||||
-----------
|
-----------
|
||||||
You can also compile pdlzip into a separate directory.
|
You can also compile pdlzip into a separate directory.
|
||||||
To do this, you must use a version of 'make' that supports the variable
|
To do this, you must use a version of 'make' that supports the 'VPATH'
|
||||||
'VPATH', such as GNU 'make'. 'cd' to the directory where you want the
|
variable, such as GNU 'make'. 'cd' to the directory where you want the
|
||||||
object files and executables to go and run the 'configure' script.
|
object files and executables to go and run the 'configure' script.
|
||||||
'configure' automatically checks for the source code in '.', in '..', and
|
'configure' automatically checks for the source code in '.', in '..' and
|
||||||
in the directory that 'configure' is in.
|
in the directory that 'configure' is in.
|
||||||
|
|
||||||
'configure' recognizes the option '--srcdir=DIR' to control where to look
|
'configure' recognizes the option '--srcdir=DIR' to control where to
|
||||||
for the source code. Usually 'configure' can determine that directory
|
look for the sources. Usually 'configure' can determine that directory
|
||||||
automatically.
|
automatically.
|
||||||
|
|
||||||
After running 'configure', you can run 'make' and 'make install' as
|
After running 'configure', you can run 'make' and 'make install' as
|
||||||
explained above.
|
explained above.
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
Copyright (C) 2010-2015 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.
|
||||||
|
|
1
LzFind.c
1
LzFind.c
|
@ -4,7 +4,6 @@
|
||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -716,8 +715,8 @@ static bool LzmaDec_DecodeToDic(CLzmaDec *p, uint32_t dicLimit,
|
||||||
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
|
*status = LZMA_STATUS_NEEDS_MORE_INPUT;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/* check first byte of the LZMA stream */
|
if (p->tempBuf[0] != 0)
|
||||||
if (p->tempBuf[0] != 0) return false;
|
return false;
|
||||||
|
|
||||||
LzmaDec_InitRc(p, p->tempBuf);
|
LzmaDec_InitRc(p, p->tempBuf);
|
||||||
p->tempBufSize = 0;
|
p->tempBufSize = 0;
|
||||||
|
|
25
LzmaEnc.c
25
LzmaEnc.c
|
@ -3,7 +3,6 @@
|
||||||
|
|
||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -1352,7 +1351,7 @@ static uint32_t GetOptimumFast(CLzmaEnc *p, uint32_t *backRes)
|
||||||
static void LZe_full_flush(CLzmaEnc *p, uint32_t posState)
|
static void LZe_full_flush(CLzmaEnc *p, uint32_t posState)
|
||||||
{
|
{
|
||||||
const uint32_t len = LZMA_MATCH_LEN_MIN;
|
const uint32_t len = LZMA_MATCH_LEN_MIN;
|
||||||
Lzip_trailer trailer;
|
File_trailer trailer;
|
||||||
RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);
|
RangeEnc_EncodeBit(&p->rc, &p->isMatch[p->state][posState], 1);
|
||||||
RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
|
RangeEnc_EncodeBit(&p->rc, &p->isRep[p->state], 0);
|
||||||
p->state = kMatchNextStates[p->state];
|
p->state = kMatchNextStates[p->state];
|
||||||
|
@ -1362,23 +1361,23 @@ static void LZe_full_flush(CLzmaEnc *p, uint32_t posState)
|
||||||
RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask);
|
RcTree_ReverseEncode(&p->rc, p->posAlignEncoder, kNumAlignBits, kAlignMask);
|
||||||
RangeEnc_FlushData(&p->rc);
|
RangeEnc_FlushData(&p->rc);
|
||||||
RangeEnc_FlushStream(&p->rc);
|
RangeEnc_FlushStream(&p->rc);
|
||||||
Lt_set_data_crc( trailer, p->matchFinderBase.crc ^ 0xFFFFFFFFU );
|
Ft_set_data_crc( trailer, p->matchFinderBase.crc ^ 0xFFFFFFFFU );
|
||||||
Lt_set_data_size( trailer, p->nowPos64 );
|
Ft_set_data_size( trailer, p->nowPos64 );
|
||||||
Lt_set_member_size( trailer, p->rc.processed + Lh_size + Lt_size );
|
Ft_set_member_size( trailer, p->rc.processed + Fh_size + Ft_size );
|
||||||
if( writeblock( p->rc.outfd, trailer, Lt_size ) != Lt_size )
|
if( writeblock( p->rc.outfd, trailer, Ft_size ) != Ft_size )
|
||||||
p->rc.res = SZ_ERROR_WRITE;
|
p->rc.res = SZ_ERROR_WRITE;
|
||||||
if( verbosity >= 1 )
|
if( verbosity >= 1 )
|
||||||
{
|
{
|
||||||
unsigned long long in_size = p->nowPos64;
|
unsigned long long in_size = p->nowPos64;
|
||||||
unsigned long long out_size = p->rc.processed + Lh_size + Lt_size;
|
unsigned long long out_size = p->rc.processed + Fh_size + Ft_size;
|
||||||
if( in_size == 0 || out_size == 0 )
|
if( in_size <= 0 || out_size <= 0 )
|
||||||
fputs( " no data compressed.\n", stderr );
|
fprintf( stderr, " no data compressed.\n" );
|
||||||
else
|
else
|
||||||
fprintf( stderr, "%6.3f:1, %5.2f%% ratio, %5.2f%% saved, "
|
fprintf( stderr, "%6.3f:1, %6.3f bits/byte, "
|
||||||
"%llu in, %llu out.\n",
|
"%5.2f%% saved, %llu in, %llu out.\n",
|
||||||
(double)in_size / out_size,
|
(double)in_size / out_size,
|
||||||
( 100.0 * out_size ) / in_size,
|
( 8.0 * out_size ) / in_size,
|
||||||
100.0 - ( ( 100.0 * out_size ) / in_size ),
|
100.0 * ( 1.0 - ( (double)out_size / in_size ) ),
|
||||||
in_size, out_size );
|
in_size, out_size );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
/* ---------- CLzmaEncHandle Interface ---------- */
|
/* ---------- CLzmaEncHandle Interface ---------- */
|
||||||
|
|
||||||
/* LzmaEnc_* functions can return the following exit codes:
|
/* LzmaEnc_* functions can return the following exit codes:
|
||||||
|
Returns:
|
||||||
SZ_OK - OK
|
SZ_OK - OK
|
||||||
SZ_ERROR_WRITE - Write callback error.
|
SZ_ERROR_WRITE - Write callback error.
|
||||||
*/
|
*/
|
||||||
|
|
33
Makefile.in
33
Makefile.in
|
@ -2,10 +2,9 @@
|
||||||
DISTNAME = $(pkgname)-$(pkgversion)
|
DISTNAME = $(pkgname)-$(pkgversion)
|
||||||
INSTALL = install
|
INSTALL = install
|
||||||
INSTALL_PROGRAM = $(INSTALL) -m 755
|
INSTALL_PROGRAM = $(INSTALL) -m 755
|
||||||
INSTALL_DIR = $(INSTALL) -d -m 755
|
|
||||||
INSTALL_DATA = $(INSTALL) -m 644
|
INSTALL_DATA = $(INSTALL) -m 644
|
||||||
|
INSTALL_DIR = $(INSTALL) -d -m 755
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
CAN_RUN_INSTALLINFO = $(SHELL) -c "install-info --version" > /dev/null 2>&1
|
|
||||||
|
|
||||||
objs = carg_parser.o LzFind.o LzmaEnc.o LzmaDec.o main.o
|
objs = carg_parser.o LzFind.o LzmaEnc.o LzmaDec.o main.o
|
||||||
|
|
||||||
|
@ -13,14 +12,13 @@ objs = carg_parser.o LzFind.o LzmaEnc.o LzmaDec.o main.o
|
||||||
.PHONY : all install install-bin install-info install-man \
|
.PHONY : all install install-bin install-info install-man \
|
||||||
install-strip install-compress install-strip-compress \
|
install-strip install-compress install-strip-compress \
|
||||||
install-bin-strip install-info-compress install-man-compress \
|
install-bin-strip install-info-compress install-man-compress \
|
||||||
install-as-lzip \
|
install-as-lzip uninstall uninstall-bin uninstall-info uninstall-man \
|
||||||
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) $(CFLAGS) $(LDFLAGS) -o $@ $(objs)
|
$(CC) $(LDFLAGS) $(CFLAGS) -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,11 +26,6 @@ main.o : main.c
|
||||||
%.o : %.c
|
%.o : %.c
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
# prevent 'make' from trying to remake source files
|
|
||||||
$(VPATH)/configure $(VPATH)/Makefile.in $(VPATH)/doc/$(pkgname).texi : ;
|
|
||||||
MAKEFLAGS += -r
|
|
||||||
.SUFFIXES :
|
|
||||||
|
|
||||||
$(objs) : Makefile
|
$(objs) : Makefile
|
||||||
carg_parser.o : carg_parser.h
|
carg_parser.o : carg_parser.h
|
||||||
LzmaDec.o : lzip.h LzmaDec.h
|
LzmaDec.o : lzip.h LzmaDec.h
|
||||||
|
@ -40,12 +33,13 @@ LzFind.o : lzip.h LzFind.h
|
||||||
LzmaEnc.o : lzip.h LzFind.h LzmaEnc.h
|
LzmaEnc.o : lzip.h LzFind.h LzmaEnc.h
|
||||||
main.o : carg_parser.h lzip.h LzmaDec.h LzmaEnc.h
|
main.o : carg_parser.h lzip.h LzmaDec.h LzmaEnc.h
|
||||||
|
|
||||||
|
|
||||||
doc : man
|
doc : man
|
||||||
|
|
||||||
info : $(VPATH)/doc/$(pkgname).info
|
info : $(VPATH)/doc/$(pkgname).info
|
||||||
|
|
||||||
$(VPATH)/doc/$(pkgname).info : $(VPATH)/doc/$(pkgname).texi
|
$(VPATH)/doc/$(pkgname).info : $(VPATH)/doc/$(pkgname).texi
|
||||||
cd $(VPATH)/doc && $(MAKEINFO) $(pkgname).texi
|
cd $(VPATH)/doc && makeinfo $(pkgname).texi
|
||||||
|
|
||||||
man : $(VPATH)/doc/$(progname).1
|
man : $(VPATH)/doc/$(progname).1
|
||||||
|
|
||||||
|
@ -74,9 +68,7 @@ install-info :
|
||||||
if [ ! -d "$(DESTDIR)$(infodir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(infodir)" ; fi
|
if [ ! -d "$(DESTDIR)$(infodir)" ] ; then $(INSTALL_DIR) "$(DESTDIR)$(infodir)" ; fi
|
||||||
-rm -f "$(DESTDIR)$(infodir)/$(pkgname).info"*
|
-rm -f "$(DESTDIR)$(infodir)/$(pkgname).info"*
|
||||||
$(INSTALL_DATA) $(VPATH)/doc/$(pkgname).info "$(DESTDIR)$(infodir)/$(pkgname).info"
|
$(INSTALL_DATA) $(VPATH)/doc/$(pkgname).info "$(DESTDIR)$(infodir)/$(pkgname).info"
|
||||||
-if $(CAN_RUN_INSTALLINFO) ; then \
|
-install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$(pkgname).info"
|
||||||
install-info --info-dir="$(DESTDIR)$(infodir)" "$(DESTDIR)$(infodir)/$(pkgname).info" ; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
install-info-compress : install-info
|
install-info-compress : install-info
|
||||||
lzip -v -9 "$(DESTDIR)$(infodir)/$(pkgname).info"
|
lzip -v -9 "$(DESTDIR)$(infodir)/$(pkgname).info"
|
||||||
|
@ -99,9 +91,7 @@ uninstall-bin :
|
||||||
-rm -f "$(DESTDIR)$(bindir)/$(progname)"
|
-rm -f "$(DESTDIR)$(bindir)/$(progname)"
|
||||||
|
|
||||||
uninstall-info :
|
uninstall-info :
|
||||||
-if $(CAN_RUN_INSTALLINFO) ; then \
|
-install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$(pkgname).info"
|
||||||
install-info --info-dir="$(DESTDIR)$(infodir)" --remove "$(DESTDIR)$(infodir)/$(pkgname).info" ; \
|
|
||||||
fi
|
|
||||||
-rm -f "$(DESTDIR)$(infodir)/$(pkgname).info"*
|
-rm -f "$(DESTDIR)$(infodir)/$(pkgname).info"*
|
||||||
|
|
||||||
uninstall-man :
|
uninstall-man :
|
||||||
|
@ -111,7 +101,6 @@ dist : doc
|
||||||
ln -sf $(VPATH) $(DISTNAME)
|
ln -sf $(VPATH) $(DISTNAME)
|
||||||
tar -Hustar --owner=root --group=root -cvf $(DISTNAME).tar \
|
tar -Hustar --owner=root --group=root -cvf $(DISTNAME).tar \
|
||||||
$(DISTNAME)/AUTHORS \
|
$(DISTNAME)/AUTHORS \
|
||||||
$(DISTNAME)/COPYING \
|
|
||||||
$(DISTNAME)/ChangeLog \
|
$(DISTNAME)/ChangeLog \
|
||||||
$(DISTNAME)/INSTALL \
|
$(DISTNAME)/INSTALL \
|
||||||
$(DISTNAME)/Makefile.in \
|
$(DISTNAME)/Makefile.in \
|
||||||
|
@ -119,14 +108,12 @@ dist : doc
|
||||||
$(DISTNAME)/README \
|
$(DISTNAME)/README \
|
||||||
$(DISTNAME)/configure \
|
$(DISTNAME)/configure \
|
||||||
$(DISTNAME)/doc/$(progname).1 \
|
$(DISTNAME)/doc/$(progname).1 \
|
||||||
$(DISTNAME)/*.h \
|
|
||||||
$(DISTNAME)/*.c \
|
|
||||||
$(DISTNAME)/testsuite/check.sh \
|
$(DISTNAME)/testsuite/check.sh \
|
||||||
$(DISTNAME)/testsuite/test.txt \
|
$(DISTNAME)/testsuite/test.txt \
|
||||||
$(DISTNAME)/testsuite/fox.lz \
|
|
||||||
$(DISTNAME)/testsuite/fox_*.lz \
|
|
||||||
$(DISTNAME)/testsuite/test.txt.lz \
|
$(DISTNAME)/testsuite/test.txt.lz \
|
||||||
$(DISTNAME)/testsuite/test.txt.lzma
|
$(DISTNAME)/testsuite/test.txt.lzma \
|
||||||
|
$(DISTNAME)/*.h \
|
||||||
|
$(DISTNAME)/*.c
|
||||||
rm -f $(DISTNAME)
|
rm -f $(DISTNAME)
|
||||||
lzip -v -9 $(DISTNAME).tar
|
lzip -v -9 $(DISTNAME).tar
|
||||||
|
|
||||||
|
|
10
NEWS
10
NEWS
|
@ -1,4 +1,8 @@
|
||||||
Changes in version 1.14:
|
Changes in version 1.6:
|
||||||
|
|
||||||
pdlzip now exits with error status 2 if any empty member is found in a
|
Copying of file dates, permissions, and ownership now behaves like "cp -p".
|
||||||
multimember file.
|
(If the user ID or the group ID can't be duplicated, the file permission
|
||||||
|
bits S_ISUID and S_ISGID are cleared).
|
||||||
|
|
||||||
|
The targets "install-compress", "install-strip-compress" and
|
||||||
|
"install-man-compress" have been added to the Makefile.
|
||||||
|
|
85
README
85
README
|
@ -1,64 +1,59 @@
|
||||||
See the file INSTALL for compilation and installation instructions.
|
|
||||||
|
|
||||||
Description
|
Description
|
||||||
|
|
||||||
Pdlzip is a permissively licensed implementation of the lzip data
|
Pdlzip is a lossless data compressor with a user interface similar to
|
||||||
compressor, intended for those who can't distribute (or even use) GPL
|
the one of lzip, bzip2 or gzip.
|
||||||
licensed Free Software. The name of pdlzip comes from 'public domain lzip'.
|
|
||||||
Pdlzip is written in C.
|
|
||||||
|
|
||||||
Lzip is a lossless data compressor with a user interface similar to the one
|
Pdlzip uses the lzip file format; the files produced by pdlzip are
|
||||||
of gzip or bzip2. Lzip uses a simplified form of LZMA (Lempel-Ziv-Markov
|
(hope)fully compatible with lzip-1.4 or newer. Pdlzip is in fact a
|
||||||
chain-Algorithm) designed to achieve complete interoperability between
|
"public domain" version of the lzip data compressor, intended for those
|
||||||
implementations. The maximum dictionary size is 512 MiB so that any lzip
|
who can't distribute (or even use) GPL licensed Free Software.
|
||||||
file can be decompressed on 32-bit machines. Lzip provides accurate and
|
|
||||||
robust 3-factor integrity checking. 'lzip -0' compresses about as fast as
|
|
||||||
gzip, while 'lzip -9' compresses most files more than bzip2. Decompression
|
|
||||||
speed is intermediate between gzip and bzip2. Lzip provides better data
|
|
||||||
recovery capabilities than gzip and bzip2. Lzip has been designed, written,
|
|
||||||
and tested with great care to replace gzip and bzip2 as general-purpose
|
|
||||||
compressed format for Unix-like systems.
|
|
||||||
|
|
||||||
The lzip file format is designed for data sharing and long-term archiving,
|
The lzip file format is designed for data sharing and long-term
|
||||||
taking into account both data integrity and decoder availability:
|
archiving, taking into account both data integrity and decoder
|
||||||
|
availability:
|
||||||
|
|
||||||
* The program lziprecover can repair bit flip errors (one of the most
|
* The lzip format provides very safe integrity checking and some data
|
||||||
common forms of data corruption) in lzip files, and provides data
|
recovery means. The lziprecover program can repair bit-flip errors
|
||||||
recovery capabilities, including error-checked merging of damaged
|
(one of the most common forms of data corruption) in lzip files,
|
||||||
copies of a file.
|
and provides data recovery capabilities, including error-checked
|
||||||
|
merging of damaged copies of a file.
|
||||||
|
|
||||||
* The lzip format is as simple as possible (but not simpler). The lzip
|
* The lzip format is as simple as possible (but not simpler). The
|
||||||
manual provides the source code of a simple decompressor along with a
|
lzip manual provides the code of a simple decompressor along with a
|
||||||
detailed explanation of how it works, so that with the only help of the
|
detailed explanation of how it works, so that with the only help of
|
||||||
lzip manual it would be possible for a digital archaeologist to extract
|
the lzip manual it would be possible for a digital archaeologist to
|
||||||
the data from a lzip file long after quantum computers eventually
|
extract the data from a lzip file long after quantum computers
|
||||||
render LZMA obsolete.
|
eventually render LZMA obsolete.
|
||||||
|
|
||||||
* Additionally the lzip reference implementation is copylefted, which
|
* Additionally the lzip reference implementation is copylefted, which
|
||||||
guarantees that it will remain free forever.
|
guarantees that it will remain free forever.
|
||||||
|
|
||||||
A nice feature of the lzip format is that a corrupt byte is easier to repair
|
A nice feature of the lzip format is that a corrupt byte is easier to
|
||||||
the nearer it is from the beginning of the file. Therefore, with the help of
|
repair the nearer it is from the beginning of the file. Therefore, with
|
||||||
lziprecover, losing an entire archive just because of a corrupt byte near
|
the help of lziprecover, losing an entire archive just because of a
|
||||||
the beginning is a thing of the past.
|
corrupt byte near the beginning is a thing of the past.
|
||||||
|
|
||||||
Pdlzip is also able to decompress legacy lzma-alone (.lzma) files.
|
Pdlzip is also able to decompress legacy lzma-alone (.lzma) files.
|
||||||
Lzma-alone is a very bad format; it is essentially a raw LZMA stream.
|
Lzma-alone is a very bad format. If you keep any lzma-alone files, it is
|
||||||
If you keep any lzma-alone files, it is advisable to recompress them to
|
advisable to recompress them to lzip format.
|
||||||
lzip format. Lziprecover can convert some lzma-alone files to lzip format
|
|
||||||
without recompressing.
|
|
||||||
|
|
||||||
Pdlzip includes public domain compression/decompression code from the LZMA
|
Pdlzip is written in C.
|
||||||
SDK (Software Development Kit) written by Igor Pavlov.
|
|
||||||
|
|
||||||
Pdlzip uses Arg_parser for command-line argument parsing:
|
Pdlzip includes public domain (de)compression code from the LZMA SDK
|
||||||
http://www.nongnu.org/arg-parser/arg_parser.html
|
(Software Development Kit) written by Igor Pavlov.
|
||||||
|
|
||||||
|
I would not write non-copylefted software unless it is too simple to be
|
||||||
|
worth copylefting it, but one of the uses of the lzip format is the
|
||||||
|
interchange of information, and it is therefore desirable that even the
|
||||||
|
users of the most non-free platforms can share lzip files with everybody
|
||||||
|
else.
|
||||||
|
|
||||||
|
|
||||||
Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
Copyright (C) 2010-2015 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.
|
||||||
|
|
||||||
The file Makefile.in is a data file used by configure to produce the Makefile.
|
The file Makefile.in is a data file used by configure to produce the
|
||||||
It has the same copyright owner and permissions that configure itself.
|
Makefile. It has the same copyright owner and permissions that configure
|
||||||
|
itself.
|
||||||
|
|
171
carg_parser.c
171
carg_parser.c
|
@ -1,15 +1,15 @@
|
||||||
/* Arg_parser - POSIX/GNU command-line argument parser. (C version)
|
/* Arg_parser - POSIX/GNU command line argument parser. (C version)
|
||||||
Copyright (C) 2006-2025 Antonio Diaz Diaz.
|
Copyright (C) 2006-2015 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This library is free software. Redistribution and use in source and
|
This library is free software. Redistribution and use in source and
|
||||||
binary forms, with or without modification, are permitted provided
|
binary forms, with or without modification, are permitted provided
|
||||||
that the following conditions are met:
|
that the following conditions are met:
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions, and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions, and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
This library is distributed in the hope that it will be useful,
|
||||||
|
@ -32,46 +32,28 @@ static void * ap_resize_buffer( void * buf, const int min_size )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char push_back_record( Arg_parser * const ap, const int code,
|
static char push_back_record( struct Arg_parser * const ap,
|
||||||
const char * const long_name,
|
const int code, const char * const argument )
|
||||||
const char * const argument )
|
|
||||||
{
|
|
||||||
ap_Record * p;
|
|
||||||
void * tmp = ap_resize_buffer( ap->data,
|
|
||||||
( ap->data_size + 1 ) * sizeof (ap_Record) );
|
|
||||||
if( !tmp ) return 0;
|
|
||||||
ap->data = (ap_Record *)tmp;
|
|
||||||
p = &(ap->data[ap->data_size]);
|
|
||||||
p->code = code;
|
|
||||||
if( long_name )
|
|
||||||
{
|
|
||||||
const int len = strlen( long_name );
|
|
||||||
p->parsed_name = (char *)malloc( len + 2 + 1 );
|
|
||||||
if( !p->parsed_name ) return 0;
|
|
||||||
p->parsed_name[0] = p->parsed_name[1] = '-';
|
|
||||||
strncpy( p->parsed_name + 2, long_name, len + 1 );
|
|
||||||
}
|
|
||||||
else if( code > 0 && code < 256 )
|
|
||||||
{
|
|
||||||
p->parsed_name = (char *)malloc( 2 + 1 );
|
|
||||||
if( !p->parsed_name ) return 0;
|
|
||||||
p->parsed_name[0] = '-'; p->parsed_name[1] = code; p->parsed_name[2] = 0;
|
|
||||||
}
|
|
||||||
else p->parsed_name = 0;
|
|
||||||
if( argument )
|
|
||||||
{
|
{
|
||||||
const int len = strlen( argument );
|
const int len = strlen( argument );
|
||||||
p->argument = (char *)malloc( len + 1 );
|
struct ap_Record * p;
|
||||||
if( !p->argument ) { free( p->parsed_name ); return 0; }
|
void * tmp = ap_resize_buffer( ap->data,
|
||||||
|
( ap->data_size + 1 ) * sizeof (struct ap_Record) );
|
||||||
|
if( !tmp ) return 0;
|
||||||
|
ap->data = (struct ap_Record *)tmp;
|
||||||
|
p = &(ap->data[ap->data_size]);
|
||||||
|
p->code = code;
|
||||||
|
p->argument = 0;
|
||||||
|
tmp = ap_resize_buffer( p->argument, len + 1 );
|
||||||
|
if( !tmp ) return 0;
|
||||||
|
p->argument = (char *)tmp;
|
||||||
strncpy( p->argument, argument, len + 1 );
|
strncpy( p->argument, argument, len + 1 );
|
||||||
}
|
|
||||||
else p->argument = 0;
|
|
||||||
++ap->data_size;
|
++ap->data_size;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static char add_error( Arg_parser * const ap, const char * const msg )
|
static char add_error( struct Arg_parser * const ap, const char * const msg )
|
||||||
{
|
{
|
||||||
const int len = strlen( msg );
|
const int len = strlen( msg );
|
||||||
void * tmp = ap_resize_buffer( ap->error, ap->error_size + len + 1 );
|
void * tmp = ap_resize_buffer( ap->error, ap->error_size + len + 1 );
|
||||||
|
@ -83,20 +65,19 @@ static char add_error( Arg_parser * const ap, const char * const msg )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void free_data( Arg_parser * const ap )
|
static void free_data( struct Arg_parser * const ap )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
for( i = 0; i < ap->data_size; ++i )
|
for( i = 0; i < ap->data_size; ++i ) free( ap->data[i].argument );
|
||||||
{ free( ap->data[i].argument ); free( ap->data[i].parsed_name ); }
|
|
||||||
if( ap->data ) { free( ap->data ); ap->data = 0; }
|
if( ap->data ) { free( ap->data ); ap->data = 0; }
|
||||||
ap->data_size = 0;
|
ap->data_size = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Return 0 only if out of memory. */
|
static char parse_long_option( struct Arg_parser * const ap,
|
||||||
static char parse_long_option( Arg_parser * const ap,
|
|
||||||
const char * const opt, const char * const arg,
|
const char * const opt, const char * const arg,
|
||||||
const ap_Option options[], int * const argindp )
|
const struct ap_Option options[],
|
||||||
|
int * const argindp )
|
||||||
{
|
{
|
||||||
unsigned len;
|
unsigned len;
|
||||||
int index = -1, i;
|
int index = -1, i;
|
||||||
|
@ -106,10 +87,9 @@ static char parse_long_option( Arg_parser * const ap,
|
||||||
|
|
||||||
/* Test all long options for either exact match or abbreviated matches. */
|
/* Test all long options for either exact match or abbreviated matches. */
|
||||||
for( i = 0; options[i].code != 0; ++i )
|
for( i = 0; options[i].code != 0; ++i )
|
||||||
if( options[i].long_name &&
|
if( options[i].name && strncmp( options[i].name, &opt[2], len ) == 0 )
|
||||||
strncmp( options[i].long_name, &opt[2], len ) == 0 )
|
|
||||||
{
|
{
|
||||||
if( strlen( options[i].long_name ) == len ) /* Exact match found */
|
if( strlen( options[i].name ) == len ) /* Exact match found */
|
||||||
{ index = i; exact = 1; break; }
|
{ index = i; exact = 1; break; }
|
||||||
else if( index < 0 ) index = i; /* First nonexact match found */
|
else if( index < 0 ) index = i; /* First nonexact match found */
|
||||||
else if( options[index].code != options[i].code ||
|
else if( options[index].code != options[i].code ||
|
||||||
|
@ -137,55 +117,52 @@ static char parse_long_option( Arg_parser * const ap,
|
||||||
{
|
{
|
||||||
if( options[index].has_arg == ap_no )
|
if( options[index].has_arg == ap_no )
|
||||||
{
|
{
|
||||||
add_error( ap, "option '--" ); add_error( ap, options[index].long_name );
|
add_error( ap, "option '--" ); add_error( ap, options[index].name );
|
||||||
add_error( ap, "' doesn't allow an argument" );
|
add_error( ap, "' doesn't allow an argument" );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if( options[index].has_arg == ap_yes && !opt[len+3] )
|
if( options[index].has_arg == ap_yes && !opt[len+3] )
|
||||||
{
|
{
|
||||||
add_error( ap, "option '--" ); add_error( ap, options[index].long_name );
|
add_error( ap, "option '--" ); add_error( ap, options[index].name );
|
||||||
add_error( ap, "' requires an argument" );
|
add_error( ap, "' requires an argument" );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return push_back_record( ap, options[index].code, options[index].long_name,
|
return push_back_record( ap, options[index].code, &opt[len+3] );
|
||||||
&opt[len+3] ); /* argument may be empty */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( options[index].has_arg == ap_yes || options[index].has_arg == ap_yme )
|
if( options[index].has_arg == ap_yes )
|
||||||
{
|
{
|
||||||
if( !arg || ( options[index].has_arg == ap_yes && !arg[0] ) )
|
if( !arg || !arg[0] )
|
||||||
{
|
{
|
||||||
add_error( ap, "option '--" ); add_error( ap, options[index].long_name );
|
add_error( ap, "option '--" ); add_error( ap, options[index].name );
|
||||||
add_error( ap, "' requires an argument" );
|
add_error( ap, "' requires an argument" );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
++*argindp;
|
++*argindp;
|
||||||
return push_back_record( ap, options[index].code, options[index].long_name,
|
return push_back_record( ap, options[index].code, arg );
|
||||||
arg ); /* argument may be empty */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return push_back_record( ap, options[index].code,
|
return push_back_record( ap, options[index].code, "" );
|
||||||
options[index].long_name, 0 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Return 0 only if out of memory. */
|
static char parse_short_option( struct Arg_parser * const ap,
|
||||||
static char parse_short_option( Arg_parser * const ap,
|
|
||||||
const char * const opt, const char * const arg,
|
const char * const opt, const char * const arg,
|
||||||
const ap_Option options[], int * const argindp )
|
const struct ap_Option options[],
|
||||||
|
int * const argindp )
|
||||||
{
|
{
|
||||||
int cind = 1; /* character index in opt */
|
int cind = 1; /* character index in opt */
|
||||||
|
|
||||||
while( cind > 0 )
|
while( cind > 0 )
|
||||||
{
|
{
|
||||||
int index = -1, i;
|
int index = -1, i;
|
||||||
const unsigned char c = opt[cind];
|
const unsigned char code = opt[cind];
|
||||||
char code_str[2];
|
char code_str[2];
|
||||||
code_str[0] = c; code_str[1] = 0;
|
code_str[0] = code; code_str[1] = 0;
|
||||||
|
|
||||||
if( c != 0 )
|
if( code != 0 )
|
||||||
for( i = 0; options[i].code; ++i )
|
for( i = 0; options[i].code; ++i )
|
||||||
if( c == options[i].code )
|
if( code == options[i].code )
|
||||||
{ index = i; break; }
|
{ index = i; break; }
|
||||||
|
|
||||||
if( index < 0 )
|
if( index < 0 )
|
||||||
|
@ -199,34 +176,34 @@ static char parse_short_option( Arg_parser * const ap,
|
||||||
|
|
||||||
if( options[index].has_arg != ap_no && cind > 0 && opt[cind] )
|
if( options[index].has_arg != ap_no && cind > 0 && opt[cind] )
|
||||||
{
|
{
|
||||||
if( !push_back_record( ap, c, 0, &opt[cind] ) ) return 0;
|
if( !push_back_record( ap, code, &opt[cind] ) ) return 0;
|
||||||
++*argindp; cind = 0;
|
++*argindp; cind = 0;
|
||||||
}
|
}
|
||||||
else if( options[index].has_arg == ap_yes || options[index].has_arg == ap_yme )
|
else if( options[index].has_arg == ap_yes )
|
||||||
{
|
{
|
||||||
if( !arg || ( options[index].has_arg == ap_yes && !arg[0] ) )
|
if( !arg || !arg[0] )
|
||||||
{
|
{
|
||||||
add_error( ap, "option requires an argument -- '" );
|
add_error( ap, "option requires an argument -- '" );
|
||||||
add_error( ap, code_str ); add_error( ap, "'" );
|
add_error( ap, code_str ); add_error( ap, "'" );
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
++*argindp; cind = 0; /* argument may be empty */
|
++*argindp; cind = 0;
|
||||||
if( !push_back_record( ap, c, 0, arg ) ) return 0;
|
if( !push_back_record( ap, code, arg ) ) return 0;
|
||||||
}
|
}
|
||||||
else if( !push_back_record( ap, c, 0, 0 ) ) return 0;
|
else if( !push_back_record( ap, code, "" ) ) return 0;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char ap_init( Arg_parser * const ap,
|
char ap_init( struct Arg_parser * const ap,
|
||||||
const int argc, const char * const argv[],
|
const int argc, const char * const argv[],
|
||||||
const ap_Option options[], const char in_order )
|
const struct ap_Option options[], const char in_order )
|
||||||
{
|
{
|
||||||
const char ** non_options = 0; /* skipped non-options */
|
const char ** non_options = 0; /* skipped non-options */
|
||||||
int non_options_size = 0; /* number of skipped non-options */
|
int non_options_size = 0; /* number of skipped non-options */
|
||||||
int argind = 1; /* index in argv */
|
int argind = 1; /* index in argv */
|
||||||
char done = 0; /* false until success */
|
int i;
|
||||||
|
|
||||||
ap->data = 0;
|
ap->data = 0;
|
||||||
ap->error = 0;
|
ap->error = 0;
|
||||||
|
@ -246,41 +223,38 @@ char ap_init( Arg_parser * const ap,
|
||||||
if( ch2 == '-' )
|
if( ch2 == '-' )
|
||||||
{
|
{
|
||||||
if( !argv[argind][2] ) { ++argind; break; } /* we found "--" */
|
if( !argv[argind][2] ) { ++argind; break; } /* we found "--" */
|
||||||
else if( !parse_long_option( ap, opt, arg, options, &argind ) ) goto out;
|
else if( !parse_long_option( ap, opt, arg, options, &argind ) ) return 0;
|
||||||
}
|
}
|
||||||
else if( !parse_short_option( ap, opt, arg, options, &argind ) ) goto out;
|
else if( !parse_short_option( ap, opt, arg, options, &argind ) ) return 0;
|
||||||
if( ap->error ) break;
|
if( ap->error ) break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( in_order )
|
if( !in_order )
|
||||||
{ if( !push_back_record( ap, 0, 0, argv[argind++] ) ) goto out; }
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
void * tmp = ap_resize_buffer( non_options,
|
void * tmp = ap_resize_buffer( non_options,
|
||||||
( non_options_size + 1 ) * sizeof *non_options );
|
( non_options_size + 1 ) * sizeof *non_options );
|
||||||
if( !tmp ) goto out;
|
if( !tmp ) return 0;
|
||||||
non_options = (const char **)tmp;
|
non_options = (const char **)tmp;
|
||||||
non_options[non_options_size++] = argv[argind++];
|
non_options[non_options_size++] = argv[argind++];
|
||||||
}
|
}
|
||||||
|
else if( !push_back_record( ap, 0, argv[argind++] ) ) return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( ap->error ) free_data( ap );
|
if( ap->error ) free_data( ap );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
for( i = 0; i < non_options_size; ++i )
|
for( i = 0; i < non_options_size; ++i )
|
||||||
if( !push_back_record( ap, 0, 0, non_options[i] ) ) goto out;
|
if( !push_back_record( ap, 0, non_options[i] ) ) return 0;
|
||||||
while( argind < argc )
|
while( argind < argc )
|
||||||
if( !push_back_record( ap, 0, 0, argv[argind++] ) ) goto out;
|
if( !push_back_record( ap, 0, argv[argind++] ) ) return 0;
|
||||||
}
|
}
|
||||||
done = 1;
|
if( non_options ) free( non_options );
|
||||||
out: if( non_options ) free( non_options );
|
return 1;
|
||||||
return done;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ap_free( Arg_parser * const ap )
|
void ap_free( struct Arg_parser * const ap )
|
||||||
{
|
{
|
||||||
free_data( ap );
|
free_data( ap );
|
||||||
if( ap->error ) { free( ap->error ); ap->error = 0; }
|
if( ap->error ) { free( ap->error ); ap->error = 0; }
|
||||||
|
@ -288,26 +262,23 @@ void ap_free( Arg_parser * const ap )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * ap_error( const Arg_parser * const ap ) { return ap->error; }
|
const char * ap_error( const struct Arg_parser * const ap )
|
||||||
|
{ return ap->error; }
|
||||||
|
|
||||||
int ap_arguments( const Arg_parser * const ap ) { return ap->data_size; }
|
|
||||||
|
|
||||||
int ap_code( const Arg_parser * const ap, const int i )
|
int ap_arguments( const struct Arg_parser * const ap )
|
||||||
|
{ return ap->data_size; }
|
||||||
|
|
||||||
|
|
||||||
|
int ap_code( const struct Arg_parser * const ap, const int i )
|
||||||
{
|
{
|
||||||
if( i < 0 || i >= ap_arguments( ap ) ) return 0;
|
if( i >= 0 && i < ap_arguments( ap ) ) return ap->data[i].code;
|
||||||
return ap->data[i].code;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * ap_parsed_name( const Arg_parser * const ap, const int i )
|
const char * ap_argument( const struct Arg_parser * const ap, const int i )
|
||||||
{
|
{
|
||||||
if( i < 0 || i >= ap_arguments( ap ) || !ap->data[i].parsed_name ) return "";
|
if( i >= 0 && i < ap_arguments( ap ) ) return ap->data[i].argument;
|
||||||
return ap->data[i].parsed_name;
|
else return "";
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const char * ap_argument( const Arg_parser * const ap, const int i )
|
|
||||||
{
|
|
||||||
if( i < 0 || i >= ap_arguments( ap ) || !ap->data[i].argument ) return "";
|
|
||||||
return ap->data[i].argument;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
/* Arg_parser - POSIX/GNU command-line argument parser. (C version)
|
/* Arg_parser - POSIX/GNU command line argument parser. (C version)
|
||||||
Copyright (C) 2006-2025 Antonio Diaz Diaz.
|
Copyright (C) 2006-2015 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This library is free software. Redistribution and use in source and
|
This library is free software. Redistribution and use in source and
|
||||||
binary forms, with or without modification, are permitted provided
|
binary forms, with or without modification, are permitted provided
|
||||||
that the following conditions are met:
|
that the following conditions are met:
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions, and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions, and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
This library is distributed in the hope that it will be useful,
|
This library is distributed in the hope that it will be useful,
|
||||||
|
@ -18,15 +18,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Arg_parser reads the arguments in 'argv' and creates a number of
|
/* Arg_parser reads the arguments in 'argv' and creates a number of
|
||||||
option codes, option arguments, and non-option arguments.
|
option codes, option arguments and non-option arguments.
|
||||||
|
|
||||||
In case of error, 'ap_error' returns a non-null pointer to an error
|
In case of error, 'ap_error' returns a non-null pointer to an error
|
||||||
message.
|
message.
|
||||||
|
|
||||||
'options' is an array of 'struct ap_Option' terminated by an element
|
'options' is an array of 'struct ap_Option' terminated by an element
|
||||||
containing a code which is zero. A null long_name means a short-only
|
containing a code which is zero. A null name means a short-only
|
||||||
option. A code value outside the unsigned char range means a long-only
|
option. A code value outside the unsigned char range means a
|
||||||
option.
|
long-only option.
|
||||||
|
|
||||||
Arg_parser normally makes it appear as if all the option arguments
|
Arg_parser normally makes it appear as if all the option arguments
|
||||||
were specified before all the non-option arguments for the purposes
|
were specified before all the non-option arguments for the purposes
|
||||||
|
@ -37,65 +37,56 @@
|
||||||
The argument '--' terminates all options; any following arguments are
|
The argument '--' terminates all options; any following arguments are
|
||||||
treated as non-option arguments, even if they begin with a hyphen.
|
treated as non-option arguments, even if they begin with a hyphen.
|
||||||
|
|
||||||
The syntax of options with an optional argument is
|
The syntax for optional option arguments is '-<short_option><argument>'
|
||||||
'-<short_option><argument>' (without whitespace), or
|
(without whitespace), or '--<long_option>=<argument>'.
|
||||||
'--<long_option>=<argument>'.
|
|
||||||
|
|
||||||
The syntax of options with an empty argument is '-<short_option> ""',
|
|
||||||
'--<long_option> ""', or '--<long_option>=""'.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ap_yme = yes but maybe empty */
|
enum ap_Has_arg { ap_no, ap_yes, ap_maybe };
|
||||||
typedef enum ap_Has_arg { ap_no, ap_yes, ap_maybe, ap_yme } ap_Has_arg;
|
|
||||||
|
|
||||||
typedef struct ap_Option
|
struct ap_Option
|
||||||
{
|
{
|
||||||
int code; /* Short option letter or code ( code != 0 ) */
|
int code; /* Short option letter or code ( code != 0 ) */
|
||||||
const char * long_name; /* Long option name (maybe null) */
|
const char * name; /* Long option name (maybe null) */
|
||||||
ap_Has_arg has_arg;
|
enum ap_Has_arg has_arg;
|
||||||
} ap_Option;
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct ap_Record
|
struct ap_Record
|
||||||
{
|
{
|
||||||
int code;
|
int code;
|
||||||
char * parsed_name;
|
|
||||||
char * argument;
|
char * argument;
|
||||||
} ap_Record;
|
};
|
||||||
|
|
||||||
|
|
||||||
typedef struct Arg_parser
|
struct Arg_parser
|
||||||
{
|
{
|
||||||
ap_Record * data;
|
struct ap_Record * data;
|
||||||
char * error;
|
char * error;
|
||||||
int data_size;
|
int data_size;
|
||||||
int error_size;
|
int error_size;
|
||||||
} Arg_parser;
|
};
|
||||||
|
|
||||||
|
|
||||||
char ap_init( Arg_parser * const ap,
|
char ap_init( struct Arg_parser * const ap,
|
||||||
const int argc, const char * const argv[],
|
const int argc, const char * const argv[],
|
||||||
const ap_Option options[], const char in_order );
|
const struct ap_Option options[], const char in_order );
|
||||||
|
|
||||||
void ap_free( Arg_parser * const ap );
|
void ap_free( struct Arg_parser * const ap );
|
||||||
|
|
||||||
const char * ap_error( const Arg_parser * const ap );
|
const char * ap_error( const struct Arg_parser * const ap );
|
||||||
|
|
||||||
/* The number of arguments parsed. May be different from argc. */
|
/* The number of arguments parsed (may be different from argc) */
|
||||||
int ap_arguments( const Arg_parser * const ap );
|
int ap_arguments( const struct Arg_parser * const ap );
|
||||||
|
|
||||||
/* If ap_code( i ) is 0, ap_argument( i ) is a non-option.
|
/* If ap_code( i ) is 0, ap_argument( i ) is a non-option.
|
||||||
Else ap_argument( i ) is the option's argument (or empty). */
|
Else ap_argument( i ) is the option's argument (or empty). */
|
||||||
int ap_code( const Arg_parser * const ap, const int i );
|
int ap_code( const struct Arg_parser * const ap, const int i );
|
||||||
|
|
||||||
/* Full name of the option parsed (short or long). */
|
const char * ap_argument( const struct Arg_parser * const ap, const int i );
|
||||||
const char * ap_parsed_name( const Arg_parser * const ap, const int i );
|
|
||||||
|
|
||||||
const char * ap_argument( const Arg_parser * const ap, const int i );
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
59
configure
vendored
59
configure
vendored
|
@ -1,12 +1,12 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# configure script for Pdlzip - LZMA lossless data compressor
|
# configure script for Pdlzip - LZMA lossless data compressor
|
||||||
# Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
# Copyright (C) 2010-2015 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.
|
||||||
|
|
||||||
pkgname=pdlzip
|
pkgname=pdlzip
|
||||||
pkgversion=1.14
|
pkgversion=1.6
|
||||||
progname=pdlzip
|
progname=pdlzip
|
||||||
srctrigger=doc/${progname}.1
|
srctrigger=doc/${progname}.1
|
||||||
|
|
||||||
|
@ -24,10 +24,13 @@ CC=gcc
|
||||||
CPPFLAGS=
|
CPPFLAGS=
|
||||||
CFLAGS='-Wall -W -O2'
|
CFLAGS='-Wall -W -O2'
|
||||||
LDFLAGS=
|
LDFLAGS=
|
||||||
MAKEINFO=makeinfo
|
|
||||||
|
|
||||||
# checking whether we are using GNU C.
|
# checking whether we are using GNU C.
|
||||||
/bin/sh -c "${CC} --version" > /dev/null 2>&1 || { CC=cc ; CFLAGS=-O2 ; }
|
${CC} --version > /dev/null 2>&1
|
||||||
|
if [ $? != 0 ] ; then
|
||||||
|
CC=cc
|
||||||
|
CFLAGS='-W -O2'
|
||||||
|
fi
|
||||||
|
|
||||||
# Loop over all args
|
# Loop over all args
|
||||||
args=
|
args=
|
||||||
|
@ -39,26 +42,22 @@ while [ $# != 0 ] ; do
|
||||||
shift
|
shift
|
||||||
|
|
||||||
# Add the argument quoted to args
|
# Add the argument quoted to args
|
||||||
if [ -z "${args}" ] ; then args="\"${option}\""
|
args="${args} \"${option}\""
|
||||||
else args="${args} \"${option}\"" ; fi
|
|
||||||
|
|
||||||
# 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,^[^=]*=,,;s,/$,,'` ;;
|
*=*) optarg=`echo ${option} | sed -e 's,^[^=]*=,,;s,/$,,'` ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Process the options
|
# Process the options
|
||||||
case ${option} in
|
case ${option} in
|
||||||
--help | -h)
|
--help | -h)
|
||||||
echo "Usage: $0 [OPTION]... [VAR=VALUE]..."
|
echo "Usage: configure [options]"
|
||||||
echo
|
echo
|
||||||
echo "To assign makefile variables (e.g., CC, CFLAGS...), specify them as"
|
echo "Options: [defaults in brackets]"
|
||||||
echo "arguments to configure in the form VAR=VALUE."
|
|
||||||
echo
|
|
||||||
echo "Options and variables: [defaults in brackets]"
|
|
||||||
echo " -h, --help display this help and exit"
|
echo " -h, --help display this help and exit"
|
||||||
echo " -V, --version output version information and exit"
|
echo " -V, --version output version information and exit"
|
||||||
echo " --srcdir=DIR find the source code in DIR [. or ..]"
|
echo " --srcdir=DIR find the sources in DIR [. or ..]"
|
||||||
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}]"
|
||||||
|
@ -66,11 +65,9 @@ while [ $# != 0 ] ; do
|
||||||
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 " CC=COMPILER C compiler to use [${CC}]"
|
echo " CC=COMPILER C compiler to use [${CC}]"
|
||||||
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 " CFLAGS+=OPTIONS append options to the current value of CFLAGS"
|
echo " LDFLAGS=OPTIONS command line options for the linker [${LDFLAGS}]"
|
||||||
echo " LDFLAGS=OPTIONS command-line options for the linker [${LDFLAGS}]"
|
|
||||||
echo " MAKEINFO=NAME makeinfo program to use [${MAKEINFO}]"
|
|
||||||
echo
|
echo
|
||||||
exit 0 ;;
|
exit 0 ;;
|
||||||
--version | -V)
|
--version | -V)
|
||||||
|
@ -96,9 +93,7 @@ while [ $# != 0 ] ; do
|
||||||
CC=*) CC=${optarg} ;;
|
CC=*) CC=${optarg} ;;
|
||||||
CPPFLAGS=*) CPPFLAGS=${optarg} ;;
|
CPPFLAGS=*) CPPFLAGS=${optarg} ;;
|
||||||
CFLAGS=*) CFLAGS=${optarg} ;;
|
CFLAGS=*) CFLAGS=${optarg} ;;
|
||||||
CFLAGS+=*) CFLAGS="${CFLAGS} ${optarg}" ;;
|
|
||||||
LDFLAGS=*) LDFLAGS=${optarg} ;;
|
LDFLAGS=*) LDFLAGS=${optarg} ;;
|
||||||
MAKEINFO=*) MAKEINFO=${optarg} ;;
|
|
||||||
|
|
||||||
--*)
|
--*)
|
||||||
echo "configure: WARNING: unrecognized option: '${option}'" 1>&2 ;;
|
echo "configure: WARNING: unrecognized option: '${option}'" 1>&2 ;;
|
||||||
|
@ -109,7 +104,7 @@ while [ $# != 0 ] ; do
|
||||||
exit 1 ;;
|
exit 1 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Check whether the option took a separate argument
|
# Check if the option took a separate argument
|
||||||
if [ "${arg2}" = yes ] ; then
|
if [ "${arg2}" = yes ] ; then
|
||||||
if [ $# != 0 ] ; then args="${args} \"$1\"" ; shift
|
if [ $# != 0 ] ; then args="${args} \"$1\"" ; shift
|
||||||
else echo "configure: Missing argument to '${option}'" 1>&2
|
else echo "configure: Missing argument to '${option}'" 1>&2
|
||||||
|
@ -118,19 +113,19 @@ while [ $# != 0 ] ; do
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Find the source code, if location was not specified.
|
# Find the source files, if location was not specified.
|
||||||
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
|
||||||
echo "configure: Can't find source code in ${srcdir} ${srcdirtext}" 1>&2
|
echo "configure: Can't find sources in ${srcdir} ${srcdirtext}" 1>&2
|
||||||
echo "configure: (At least ${srctrigger} is missing)." 1>&2
|
echo "configure: (At least ${srctrigger} is missing)." 1>&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -144,13 +139,13 @@ if [ -z "${no_create}" ] ; then
|
||||||
rm -f config.status
|
rm -f config.status
|
||||||
cat > config.status << EOF
|
cat > config.status << EOF
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# This file was generated automatically by configure. Don't edit.
|
# This file was generated automatically by configure. Do not edit.
|
||||||
# Run this file to recreate the current configuration.
|
# Run this file to recreate the current configuration.
|
||||||
#
|
#
|
||||||
# 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.
|
||||||
|
|
||||||
exec /bin/sh "$0" ${args} --no-create
|
exec /bin/sh $0 ${args} --no-create
|
||||||
EOF
|
EOF
|
||||||
chmod +x config.status
|
chmod +x config.status
|
||||||
fi
|
fi
|
||||||
|
@ -167,15 +162,14 @@ echo "CC = ${CC}"
|
||||||
echo "CPPFLAGS = ${CPPFLAGS}"
|
echo "CPPFLAGS = ${CPPFLAGS}"
|
||||||
echo "CFLAGS = ${CFLAGS}"
|
echo "CFLAGS = ${CFLAGS}"
|
||||||
echo "LDFLAGS = ${LDFLAGS}"
|
echo "LDFLAGS = ${LDFLAGS}"
|
||||||
echo "MAKEINFO = ${MAKEINFO}"
|
|
||||||
rm -f Makefile
|
rm -f Makefile
|
||||||
cat > Makefile << EOF
|
cat > Makefile << EOF
|
||||||
# Makefile for Pdlzip - LZMA lossless data compressor
|
# Makefile for Pdlzip - LZMA lossless data compressor
|
||||||
# Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
# Copyright (C) 2010-2015 Antonio Diaz Diaz.
|
||||||
# This file was generated automatically by configure. Don't 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
|
||||||
# to copy, distribute, and modify it.
|
# to copy, distribute and modify it.
|
||||||
|
|
||||||
pkgname = ${pkgname}
|
pkgname = ${pkgname}
|
||||||
pkgversion = ${pkgversion}
|
pkgversion = ${pkgversion}
|
||||||
|
@ -191,7 +185,6 @@ CC = ${CC}
|
||||||
CPPFLAGS = ${CPPFLAGS}
|
CPPFLAGS = ${CPPFLAGS}
|
||||||
CFLAGS = ${CFLAGS}
|
CFLAGS = ${CFLAGS}
|
||||||
LDFLAGS = ${LDFLAGS}
|
LDFLAGS = ${LDFLAGS}
|
||||||
MAKEINFO = ${MAKEINFO}
|
|
||||||
EOF
|
EOF
|
||||||
cat "${srcdir}/Makefile.in" >> Makefile
|
cat "${srcdir}/Makefile.in" >> Makefile
|
||||||
|
|
||||||
|
|
79
doc/pdlzip.1
79
doc/pdlzip.1
|
@ -1,33 +1,15 @@
|
||||||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2.
|
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.46.1.
|
||||||
.TH PDLZIP "1" "January 2025" "pdlzip 1.14" "User Commands"
|
.TH PDLZIP "1" "May 2015" "pdlzip 1.6" "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
|
||||||
[\fI\,options\/\fR] [\fI\,files\/\fR]
|
[\fI\,options\/\fR] [\fI\,files\/\fR]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Pdlzip is a permissively licensed implementation of the lzip data
|
Pdlzip \- A "public domain" version of the lzip data compressor
|
||||||
compressor, intended for those who can't distribute (or even use) GPL
|
also able to decompress legacy lzma\-alone (.lzma) files.
|
||||||
licensed Free Software. The name of pdlzip comes from 'public domain lzip'.
|
Lzma\-alone is a very bad format. If you keep any lzma\-alone files, it is
|
||||||
Pdlzip is written in C.
|
advisable to recompress them to lzip format.
|
||||||
.PP
|
|
||||||
Lzip is a lossless data compressor with a user interface similar to the one
|
|
||||||
of gzip or bzip2. Lzip uses a simplified form of LZMA (Lempel\-Ziv\-Markov
|
|
||||||
chain\-Algorithm) designed to achieve complete interoperability between
|
|
||||||
implementations. The maximum dictionary size is 512 MiB so that any lzip
|
|
||||||
file can be decompressed on 32\-bit machines. Lzip provides accurate and
|
|
||||||
robust 3\-factor integrity checking. 'lzip \fB\-0\fR' compresses about as fast as
|
|
||||||
gzip, while 'lzip \fB\-9\fR' compresses most files more than bzip2. Decompression
|
|
||||||
speed is intermediate between gzip and bzip2. Lzip provides better data
|
|
||||||
recovery capabilities than gzip and bzip2. Lzip has been designed, written,
|
|
||||||
and tested with great care to replace gzip and bzip2 as general\-purpose
|
|
||||||
compressed format for Unix\-like systems.
|
|
||||||
.PP
|
|
||||||
Pdlzip is also able to decompress legacy lzma\-alone (.lzma) files.
|
|
||||||
Lzma\-alone is a very bad format; it is essentially a raw LZMA stream.
|
|
||||||
If you keep any lzma\-alone files, it is advisable to recompress them to
|
|
||||||
lzip format. Lziprecover can convert some lzma\-alone files to lzip format
|
|
||||||
without recompressing.
|
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
\fB\-h\fR, \fB\-\-help\fR
|
\fB\-h\fR, \fB\-\-help\fR
|
||||||
|
@ -36,14 +18,11 @@ display this help and exit
|
||||||
\fB\-V\fR, \fB\-\-version\fR
|
\fB\-V\fR, \fB\-\-version\fR
|
||||||
output version information and exit
|
output version information and exit
|
||||||
.TP
|
.TP
|
||||||
\fB\-a\fR, \fB\-\-trailing\-error\fR
|
|
||||||
exit with error status if trailing data
|
|
||||||
.TP
|
|
||||||
\fB\-c\fR, \fB\-\-stdout\fR
|
\fB\-c\fR, \fB\-\-stdout\fR
|
||||||
write to standard output, keep input files
|
send output to standard output
|
||||||
.TP
|
.TP
|
||||||
\fB\-d\fR, \fB\-\-decompress\fR
|
\fB\-d\fR, \fB\-\-decompress\fR
|
||||||
decompress, test compressed file integrity
|
decompress
|
||||||
.TP
|
.TP
|
||||||
\fB\-f\fR, \fB\-\-force\fR
|
\fB\-f\fR, \fB\-\-force\fR
|
||||||
overwrite existing output files
|
overwrite existing output files
|
||||||
|
@ -58,7 +37,7 @@ keep (don't delete) input files
|
||||||
set match length limit in bytes [36]
|
set match length limit in bytes [36]
|
||||||
.TP
|
.TP
|
||||||
\fB\-o\fR, \fB\-\-output=\fR<file>
|
\fB\-o\fR, \fB\-\-output=\fR<file>
|
||||||
write to <file>, keep input files
|
if reading stdin, place the output into <file>
|
||||||
.TP
|
.TP
|
||||||
\fB\-q\fR, \fB\-\-quiet\fR
|
\fB\-q\fR, \fB\-\-quiet\fR
|
||||||
suppress all messages
|
suppress all messages
|
||||||
|
@ -72,47 +51,35 @@ test compressed file integrity
|
||||||
\fB\-v\fR, \fB\-\-verbose\fR
|
\fB\-v\fR, \fB\-\-verbose\fR
|
||||||
be verbose (a 2nd \fB\-v\fR gives more)
|
be verbose (a 2nd \fB\-v\fR gives more)
|
||||||
.TP
|
.TP
|
||||||
\fB\-0\fR .. \fB\-9\fR
|
\fB\-1\fR .. \fB\-9\fR
|
||||||
set compression level [default 6]
|
set compression level [default 6]
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-fast\fR
|
\fB\-\-fast\fR
|
||||||
alias for \fB\-0\fR
|
alias for \fB\-1\fR
|
||||||
.TP
|
.TP
|
||||||
\fB\-\-best\fR
|
\fB\-\-best\fR
|
||||||
alias for \fB\-9\fR
|
alias for \fB\-9\fR
|
||||||
.TP
|
|
||||||
\fB\-\-loose\-trailing\fR
|
|
||||||
allow trailing data seeming corrupt header
|
|
||||||
.PP
|
.PP
|
||||||
If no file names are given, or if a file is '\-', pdlzip compresses or
|
If no file names are given, pdlzip compresses or decompresses
|
||||||
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...
|
||||||
Dictionary sizes 12 to 27 are interpreted as powers of two, meaning 2^12 to
|
The bidimensional parameter space of LZMA can't be mapped to a linear
|
||||||
2^27 bytes.
|
scale optimal for all files. If your files are large, very repetitive,
|
||||||
|
etc, you may need to use the \fB\-\-match\-length\fR and \fB\-\-dictionary\-size\fR
|
||||||
|
options directly to achieve optimal performance. For example, \fB\-9m64\fR
|
||||||
|
usually compresses executables more (and faster) than \fB\-9\fR.
|
||||||
.PP
|
.PP
|
||||||
The bidimensional parameter space of LZMA can't be mapped to a linear scale
|
Exit status: 0 for a normal exit, 1 for environmental problems (file
|
||||||
optimal for all files. If your files are large, very repetitive, etc, you
|
not found, invalid flags, I/O errors, etc), 2 to indicate a corrupt or
|
||||||
may need to use the options \fB\-\-dictionary\-size\fR and \fB\-\-match\-length\fR directly
|
invalid input file, 3 for an internal consistency error (eg, bug) which
|
||||||
to achieve optimal performance. For example, \fB\-9m64\fR usually compresses
|
caused pdlzip to panic.
|
||||||
executables more (and faster) than \fB\-9\fR.
|
|
||||||
.PP
|
|
||||||
To extract all the files from archive 'foo.tar.lz', use the commands
|
|
||||||
\&'tar \fB\-xf\fR foo.tar.lz' or 'pdlzip \fB\-cd\fR foo.tar.lz | tar \fB\-xf\fR \-'.
|
|
||||||
.PP
|
|
||||||
Exit status: 0 for a normal exit, 1 for environmental problems
|
|
||||||
(file not found, invalid command\-line options, I/O errors, etc), 2 to
|
|
||||||
indicate a corrupt or invalid input file, 3 for an internal consistency
|
|
||||||
error (e.g., bug) which caused pdlzip to panic.
|
|
||||||
.PP
|
|
||||||
Pdlzip includes public domain compression/decompression code from the LZMA
|
|
||||||
SDK (Software Development Kit) written by Igor Pavlov.
|
|
||||||
.SH "REPORTING BUGS"
|
.SH "REPORTING BUGS"
|
||||||
Report bugs to lzip\-bug@nongnu.org
|
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 2025 Antonio Diaz Diaz.
|
Copyright \(co 2015 Antonio Diaz Diaz.
|
||||||
Public Domain 2009 Igor Pavlov.
|
Public Domain 2009 Igor Pavlov.
|
||||||
License 2\-clause BSD.
|
License 2\-clause BSD.
|
||||||
.br
|
.br
|
||||||
|
|
166
lzip.h
166
lzip.h
|
@ -1,15 +1,15 @@
|
||||||
/* Pdlzip - LZMA lossless data compressor
|
/* Pdlzip - LZMA lossless data compressor
|
||||||
Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
Copyright (C) 2010-2015 Antonio Diaz Diaz.
|
||||||
|
|
||||||
This program is free software. Redistribution and use in source and
|
This program is free software. Redistribution and use in source and
|
||||||
binary forms, with or without modification, are permitted provided
|
binary forms, with or without modification, are permitted provided
|
||||||
that the following conditions are met:
|
that the following conditions are met:
|
||||||
|
|
||||||
1. Redistributions of source code must retain the above copyright
|
1. Redistributions of source code must retain the above copyright
|
||||||
notice, this list of conditions, and the following disclaimer.
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
|
||||||
2. Redistributions in binary form must reproduce the above copyright
|
2. Redistributions in binary form must reproduce the above copyright
|
||||||
notice, this list of conditions, and the following disclaimer in the
|
notice, this list of conditions and the following disclaimer in the
|
||||||
documentation and/or other materials provided with the distribution.
|
documentation and/or other materials provided with the distribution.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
This program is distributed in the hope that it will be useful,
|
||||||
|
@ -17,21 +17,26 @@
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef __cplusplus
|
||||||
|
enum Bool { false = 0, true = 1 };
|
||||||
|
typedef enum Bool bool;
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef max
|
#ifndef max
|
||||||
#define max(x,y) ((x) >= (y) ? (x) : (y))
|
#define max(x,y) ((x) >= (y) ? (x) : (y))
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef min
|
||||||
|
#define min(x,y) ((x) <= (y) ? (x) : (y))
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef int State;
|
typedef int State;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
min_dictionary_bits = 12,
|
min_dictionary_bits = 12,
|
||||||
min_dictionary_size = 1 << min_dictionary_bits, /* >= modeled_distances */
|
min_dictionary_size = 1 << min_dictionary_bits,
|
||||||
max_dictionary_bits = 29,
|
max_dictionary_bits = 29,
|
||||||
max_dictionary_size = 1 << max_dictionary_bits,
|
max_dictionary_size = 1 << max_dictionary_bits,
|
||||||
max_dictionary_bits_c = 27, /* kDicLogSizeMaxCompress */
|
|
||||||
max_dictionary_size_c = 1 << max_dictionary_bits_c,
|
|
||||||
literal_context_bits = 3,
|
literal_context_bits = 3,
|
||||||
literal_pos_state_bits = 0, /* not used */
|
|
||||||
pos_state_bits = 2,
|
pos_state_bits = 2,
|
||||||
|
|
||||||
len_low_bits = 3,
|
len_low_bits = 3,
|
||||||
|
@ -47,6 +52,48 @@ enum {
|
||||||
min_match_len_limit = 5 };
|
min_match_len_limit = 5 };
|
||||||
|
|
||||||
|
|
||||||
|
struct Pretty_print
|
||||||
|
{
|
||||||
|
const char * name;
|
||||||
|
const char * stdin_name;
|
||||||
|
unsigned longest_name;
|
||||||
|
bool first_post;
|
||||||
|
};
|
||||||
|
|
||||||
|
static inline void Pp_init( struct Pretty_print * const pp,
|
||||||
|
const char * const filenames[], const int num_filenames )
|
||||||
|
{
|
||||||
|
unsigned stdin_name_len;
|
||||||
|
int i;
|
||||||
|
pp->name = 0;
|
||||||
|
pp->stdin_name = "(stdin)";
|
||||||
|
pp->longest_name = 0;
|
||||||
|
pp->first_post = false;
|
||||||
|
stdin_name_len = strlen( pp->stdin_name );
|
||||||
|
|
||||||
|
for( i = 0; i < num_filenames; ++i )
|
||||||
|
{
|
||||||
|
const char * const s = filenames[i];
|
||||||
|
const unsigned len = (strcmp( s, "-" ) == 0) ? stdin_name_len : strlen( s );
|
||||||
|
if( len > pp->longest_name ) pp->longest_name = len;
|
||||||
|
}
|
||||||
|
if( pp->longest_name == 0 ) pp->longest_name = stdin_name_len;
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
@ -64,24 +111,16 @@ static inline void CRC32_init( void )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* about as fast as it is possible without messing with endianness */
|
|
||||||
static inline void CRC32_update_buf( uint32_t * const crc,
|
static inline void CRC32_update_buf( uint32_t * const crc,
|
||||||
const uint8_t * const buffer,
|
const uint8_t * const buffer,
|
||||||
const int size )
|
const int size )
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
uint32_t c = *crc;
|
|
||||||
for( i = 0; i < size; ++i )
|
for( i = 0; i < size; ++i )
|
||||||
c = crc32[(c^buffer[i])&0xFF] ^ ( c >> 8 );
|
*crc = crc32[(*crc^buffer[i])&0xFF] ^ ( *crc >> 8 );
|
||||||
*crc = c;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline bool isvalid_ds( const unsigned dictionary_size )
|
|
||||||
{ return dictionary_size >= min_dictionary_size &&
|
|
||||||
dictionary_size <= max_dictionary_size; }
|
|
||||||
|
|
||||||
|
|
||||||
static inline int real_bits( unsigned value )
|
static inline int real_bits( unsigned value )
|
||||||
{
|
{
|
||||||
int bits = 0;
|
int bits = 0;
|
||||||
|
@ -90,125 +129,100 @@ static inline int real_bits( unsigned value )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static const uint8_t lzip_magic[4] = { 0x4C, 0x5A, 0x49, 0x50 }; /* "LZIP" */
|
static const uint8_t magic_string[4] = { 0x4C, 0x5A, 0x49, 0x50 }; /* "LZIP" */
|
||||||
|
|
||||||
enum { Lh_size = 6 };
|
typedef uint8_t File_header[6]; /* 0-3 magic bytes */
|
||||||
typedef uint8_t Lzip_header[Lh_size]; /* 0-3 magic bytes */
|
|
||||||
/* 4 version */
|
/* 4 version */
|
||||||
/* 5 coded dictionary size */
|
/* 5 coded_dict_size */
|
||||||
|
enum { Fh_size = 6 };
|
||||||
|
|
||||||
static inline void Lh_set_magic( Lzip_header data )
|
static inline void Fh_set_magic( File_header data )
|
||||||
{ memcpy( data, lzip_magic, 4 ); data[4] = 1; }
|
{ memcpy( data, magic_string, 4 ); data[4] = 1; }
|
||||||
|
|
||||||
static inline bool Lh_check_magic( const Lzip_header data )
|
static inline bool Fh_verify_magic( const File_header data )
|
||||||
{ return memcmp( data, lzip_magic, 4 ) == 0; }
|
{ return ( memcmp( data, magic_string, 4 ) == 0 ); }
|
||||||
|
|
||||||
/* detect (truncated) header */
|
static inline uint8_t Fh_version( const File_header data )
|
||||||
static inline bool Lh_check_prefix( const Lzip_header data, const int sz )
|
|
||||||
{
|
|
||||||
int i; for( i = 0; i < sz && i < 4; ++i )
|
|
||||||
if( data[i] != lzip_magic[i] ) return false;
|
|
||||||
return sz > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* detect corrupt header */
|
|
||||||
static inline bool Lh_check_corrupt( const Lzip_header data )
|
|
||||||
{
|
|
||||||
int matches = 0;
|
|
||||||
int i; for( i = 0; i < 4; ++i )
|
|
||||||
if( data[i] == lzip_magic[i] ) ++matches;
|
|
||||||
return matches > 1 && matches < 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint8_t Lh_version( const Lzip_header data )
|
|
||||||
{ return data[4]; }
|
{ return data[4]; }
|
||||||
|
|
||||||
static inline bool Lh_check_version( const Lzip_header data )
|
static inline bool Fh_verify_version( const File_header data )
|
||||||
{ return data[4] == 1; }
|
{ return ( data[4] == 1 ); }
|
||||||
|
|
||||||
static inline unsigned Lh_get_dictionary_size( const Lzip_header data )
|
static inline unsigned Fh_get_dictionary_size( const File_header data )
|
||||||
{
|
{
|
||||||
unsigned sz = 1 << ( data[5] & 0x1F );
|
unsigned sz = ( 1 << ( data[5] & 0x1F ) );
|
||||||
if( sz > min_dictionary_size )
|
if( sz > min_dictionary_size )
|
||||||
sz -= ( sz / 16 ) * ( ( data[5] >> 5 ) & 7 );
|
sz -= ( sz / 16 ) * ( ( data[5] >> 5 ) & 7 );
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool Lh_set_dictionary_size( Lzip_header data, const unsigned sz )
|
static inline bool Fh_set_dictionary_size( File_header data, const unsigned sz )
|
||||||
|
{
|
||||||
|
if( sz >= min_dictionary_size && sz <= max_dictionary_size )
|
||||||
{
|
{
|
||||||
if( !isvalid_ds( sz ) ) return false;
|
|
||||||
data[5] = real_bits( sz - 1 );
|
data[5] = real_bits( sz - 1 );
|
||||||
if( sz > min_dictionary_size )
|
if( sz > min_dictionary_size )
|
||||||
{
|
{
|
||||||
const unsigned base_size = 1 << data[5];
|
const unsigned base_size = 1 << data[5];
|
||||||
const unsigned fraction = base_size / 16;
|
const unsigned fraction = base_size / 16;
|
||||||
unsigned i;
|
int i;
|
||||||
for( i = 7; i >= 1; --i )
|
for( i = 7; i >= 1; --i )
|
||||||
if( base_size - ( i * fraction ) >= sz )
|
if( base_size - ( i * fraction ) >= sz )
|
||||||
{ data[5] |= i << 5; break; }
|
{ data[5] |= ( i << 5 ); break; }
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
enum { Lt_size = 20 };
|
typedef uint8_t File_trailer[20];
|
||||||
typedef uint8_t Lzip_trailer[Lt_size];
|
|
||||||
/* 0-3 CRC32 of the uncompressed data */
|
/* 0-3 CRC32 of the uncompressed data */
|
||||||
/* 4-11 size of the uncompressed data */
|
/* 4-11 size of the uncompressed data */
|
||||||
/* 12-19 member size including header and trailer */
|
/* 12-19 member size including header and trailer */
|
||||||
|
|
||||||
static inline unsigned Lt_get_data_crc( const Lzip_trailer data )
|
enum { Ft_size = 20 };
|
||||||
|
|
||||||
|
static inline unsigned Ft_get_data_crc( const File_trailer data )
|
||||||
{
|
{
|
||||||
unsigned tmp = 0;
|
unsigned tmp = 0;
|
||||||
int i; for( i = 3; i >= 0; --i ) { tmp <<= 8; tmp += data[i]; }
|
int i; for( i = 3; i >= 0; --i ) { tmp <<= 8; tmp += data[i]; }
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Lt_set_data_crc( Lzip_trailer data, unsigned crc )
|
static inline void Ft_set_data_crc( File_trailer data, unsigned crc )
|
||||||
{ int i; for( i = 0; i <= 3; ++i ) { data[i] = (uint8_t)crc; crc >>= 8; } }
|
{ int i; for( i = 0; i <= 3; ++i ) { data[i] = (uint8_t)crc; crc >>= 8; } }
|
||||||
|
|
||||||
static inline unsigned long long Lt_get_data_size( const Lzip_trailer data )
|
static inline unsigned long long Ft_get_data_size( const File_trailer data )
|
||||||
{
|
{
|
||||||
unsigned long long tmp = 0;
|
unsigned long long tmp = 0;
|
||||||
int i; for( i = 11; i >= 4; --i ) { tmp <<= 8; tmp += data[i]; }
|
int i; for( i = 11; i >= 4; --i ) { tmp <<= 8; tmp += data[i]; }
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Lt_set_data_size( Lzip_trailer data, unsigned long long sz )
|
static inline void Ft_set_data_size( File_trailer data, unsigned long long sz )
|
||||||
{ int i; for( i = 4; i <= 11; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; } }
|
{ int i; for( i = 4; i <= 11; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; } }
|
||||||
|
|
||||||
static inline unsigned long long Lt_get_member_size( const Lzip_trailer data )
|
static inline unsigned long long Ft_get_member_size( const File_trailer data )
|
||||||
{
|
{
|
||||||
unsigned long long tmp = 0;
|
unsigned long long tmp = 0;
|
||||||
int i; for( i = 19; i >= 12; --i ) { tmp <<= 8; tmp += data[i]; }
|
int i; for( i = 19; i >= 12; --i ) { tmp <<= 8; tmp += data[i]; }
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void Lt_set_member_size( Lzip_trailer data, unsigned long long sz )
|
static inline void Ft_set_member_size( File_trailer data, unsigned long long sz )
|
||||||
{ int i; for( i = 12; i <= 19; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; } }
|
{ int i; for( i = 12; i <= 19; ++i ) { data[i] = (uint8_t)sz; sz >>= 8; } }
|
||||||
|
|
||||||
|
|
||||||
typedef struct Cl_options /* command-line options */
|
/* defined in main.c */
|
||||||
{
|
int readblock( const int fd, uint8_t * const buf, const int size );
|
||||||
bool ignore_trailing;
|
int writeblock( const int fd, const uint8_t * const buf, const int size );
|
||||||
bool loose_trailing;
|
|
||||||
} Cl_options;
|
|
||||||
|
|
||||||
static inline void Cl_options_init( Cl_options * cl_opts )
|
|
||||||
{ cl_opts->ignore_trailing = true; cl_opts->loose_trailing = false; }
|
|
||||||
|
|
||||||
|
|
||||||
static inline void set_retval( int * retval, const int new_val )
|
|
||||||
{ if( *retval < new_val ) *retval = new_val; }
|
|
||||||
|
|
||||||
static const char * const empty_msg = "Empty member not allowed.";
|
|
||||||
static const char * const mem_msg = "Not enough memory.";
|
|
||||||
static const char * const trailing_msg = "Trailing data not allowed.";
|
|
||||||
|
|
||||||
/* defined in main.c */
|
/* defined in main.c */
|
||||||
extern int verbosity;
|
extern int verbosity;
|
||||||
int readblock( const int fd, uint8_t * const buf, const int size );
|
void cleanup_and_fail( const int retval );
|
||||||
int writeblock( const int fd, const uint8_t * const buf, const int size );
|
void show_error( const char * const msg, const int errcode, const bool help );
|
||||||
|
void internal_error( const char * const msg );
|
||||||
|
|
||||||
#define SZ_OK 0
|
#define SZ_OK 0
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# check script for Pdlzip - LZMA lossless data compressor
|
# check script for Pdlzip - LZMA lossless data compressor
|
||||||
# Copyright (C) 2010-2025 Antonio Diaz Diaz.
|
# Copyright (C) 2010-2015 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.
|
||||||
|
|
||||||
LC_ALL=C
|
LC_ALL=C
|
||||||
export LC_ALL
|
export LC_ALL
|
||||||
|
@ -17,391 +17,121 @@ if [ ! -f "${LZIP}" ] || [ ! -x "${LZIP}" ] ; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ -e "${LZIP}" ] 2> /dev/null ||
|
|
||||||
{
|
|
||||||
echo "$0: a POSIX shell is required to run the tests"
|
|
||||||
echo "Try bash -c \"$0 $1 $2\""
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ -d tmp ] ; then rm -rf tmp ; fi
|
if [ -d tmp ] ; then rm -rf tmp ; fi
|
||||||
mkdir tmp
|
mkdir tmp
|
||||||
cd "${objdir}"/tmp || framework_failure
|
cd "${objdir}"/tmp
|
||||||
|
|
||||||
cp "${testdir}"/test.txt in || framework_failure
|
cat "${testdir}"/test.txt > in || framework_failure
|
||||||
in_lz="${testdir}"/test.txt.lz
|
in_lz="${testdir}"/test.txt.lz
|
||||||
fox_lz="${testdir}"/fox.lz
|
|
||||||
fnz_lz="${testdir}"/fox_nz.lz
|
|
||||||
fail=0
|
fail=0
|
||||||
test_failed() { fail=1 ; printf " $1" ; [ -z "$2" ] || printf "($2)" ; }
|
|
||||||
|
|
||||||
printf "testing pdlzip-%s..." "$2"
|
printf "testing pdlzip-%s..." "$2"
|
||||||
|
|
||||||
"${LZIP}" -fkqm4 in
|
"${LZIP}" -cqm4 in > /dev/null
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
|
||||||
[ ! -e in.lz ] || test_failed $LINENO
|
"${LZIP}" -cqm274 in > /dev/null
|
||||||
"${LZIP}" -fkqm274 in
|
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
"${LZIP}" -cqs-1 in > /dev/null
|
||||||
[ ! -e in.lz ] || test_failed $LINENO
|
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
|
||||||
for i in bad_size -1 0 4095 513MiB 1G 1T 1P 1E 1Z 1Y 10KB ; do
|
"${LZIP}" -cqs0 in > /dev/null
|
||||||
"${LZIP}" -fkqs $i in
|
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
|
||||||
[ $? = 1 ] || test_failed $LINENO $i
|
"${LZIP}" -cqs4095 in > /dev/null
|
||||||
[ ! -e in.lz ] || test_failed $LINENO $i
|
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
|
||||||
done
|
"${LZIP}" -cqs513MiB in > /dev/null
|
||||||
"${LZIP}" -tq in
|
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
printf " in: Bad magic number (file not in lzip format).\n" > msg
|
||||||
"${LZIP}" -tq < in
|
"${LZIP}" -t in 2> out
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
if [ $? = 2 ] && cmp out msg ; then printf . ; else printf - ; fail=1 ; fi
|
||||||
|
printf " (stdin): Bad magic number (file not in lzip format).\n" > msg
|
||||||
|
"${LZIP}" -t < in 2> out
|
||||||
|
if [ $? = 2 ] && cmp out msg ; then printf . ; else printf - ; fail=1 ; fi
|
||||||
|
rm -f out msg
|
||||||
"${LZIP}" -cdq in
|
"${LZIP}" -cdq in
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
||||||
"${LZIP}" -cdq < in
|
"${LZIP}" -cdq < in
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
||||||
"${LZIP}" -dq -o in < "${in_lz}"
|
dd if="${in_lz}" bs=1 count=6 2> /dev/null | "${LZIP}" -tq
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
||||||
"${LZIP}" -dq -o in "${in_lz}"
|
dd if="${in_lz}" bs=1 count=20 2> /dev/null | "${LZIP}" -tq
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
if [ $? = 2 ] ; then printf . ; else printf - ; fail=1 ; fi
|
||||||
"${LZIP}" -dq -o out nx_file.lz
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
[ ! -e out ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -q -o out.lz nx_file
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
[ ! -e out.lz ] || test_failed $LINENO
|
|
||||||
# these are for code coverage
|
|
||||||
"${LZIP}" -cdt "${in_lz}" 2> /dev/null
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -t -- nx_file.lz 2> /dev/null
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -t "" < /dev/null 2> /dev/null
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" --help > /dev/null || test_failed $LINENO
|
|
||||||
"${LZIP}" -n1 -V > /dev/null || test_failed $LINENO
|
|
||||||
"${LZIP}" -m 2> /dev/null
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -z 2> /dev/null
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" --bad_option 2> /dev/null
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" --t 2> /dev/null
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" --test=2 2> /dev/null
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" --output= 2> /dev/null
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" --output 2> /dev/null
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
printf "LZIP\001-.............................." | "${LZIP}" -t 2> /dev/null
|
|
||||||
printf "LZIP\002-.............................." | "${LZIP}" -t 2> /dev/null
|
|
||||||
printf "LZIP\001+.............................." | "${LZIP}" -t 2> /dev/null
|
|
||||||
|
|
||||||
printf "\ntesting decompression..."
|
"${LZIP}" -t "${in_lz}" || fail=1
|
||||||
|
"${LZIP}" -cd "${in_lz}" > copy || fail=1
|
||||||
|
cmp in copy || fail=1
|
||||||
|
printf .
|
||||||
|
|
||||||
for i in "${in_lz}" "${testdir}"/test.txt.lzma ; do
|
"${LZIP}" -t "${testdir}"/test.txt.lzma || fail=1
|
||||||
"${LZIP}" -t "$i" || test_failed $LINENO "$i"
|
"${LZIP}" -cd "${testdir}"/test.txt.lzma > copy || fail=1
|
||||||
"${LZIP}" -d "$i" -o out || test_failed $LINENO "$i"
|
cmp in copy || fail=1
|
||||||
cmp in out || test_failed $LINENO "$i"
|
printf .
|
||||||
"${LZIP}" -cd "$i" > out || test_failed $LINENO "$i"
|
|
||||||
cmp in out || test_failed $LINENO "$i"
|
|
||||||
"${LZIP}" -d "$i" -o - > out || test_failed $LINENO "$i"
|
|
||||||
cmp in out || test_failed $LINENO "$i"
|
|
||||||
"${LZIP}" -d < "$i" > out || test_failed $LINENO "$i"
|
|
||||||
cmp in out || test_failed $LINENO "$i"
|
|
||||||
rm -f out || framework_failure
|
|
||||||
done
|
|
||||||
|
|
||||||
cp "${in_lz}" out.lz || framework_failure
|
cat "${in_lz}" > copy.lz || framework_failure
|
||||||
"${LZIP}" -dk out.lz || test_failed $LINENO
|
printf "to be overwritten" > copy || framework_failure
|
||||||
cmp in out || test_failed $LINENO
|
"${LZIP}" -df copy.lz || fail=1
|
||||||
rm -f out || framework_failure
|
cmp in copy || fail=1
|
||||||
"${LZIP}" -cd "${fox_lz}" > fox || test_failed $LINENO
|
printf .
|
||||||
cp fox copy || framework_failure
|
|
||||||
cp "${in_lz}" copy.lz || framework_failure
|
|
||||||
"${LZIP}" -d copy.lz out.lz 2> /dev/null # skip copy, decompress out
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
[ ! -e out.lz ] || test_failed $LINENO
|
|
||||||
cmp fox copy || test_failed $LINENO
|
|
||||||
cmp in out || test_failed $LINENO
|
|
||||||
"${LZIP}" -df copy.lz || test_failed $LINENO
|
|
||||||
[ ! -e copy.lz ] || test_failed $LINENO
|
|
||||||
cmp in copy || test_failed $LINENO
|
|
||||||
rm -f copy out || framework_failure
|
|
||||||
|
|
||||||
printf "to be overwritten" > out || framework_failure
|
printf "to be overwritten" > copy || framework_failure
|
||||||
"${LZIP}" -df -o out < "${in_lz}" || test_failed $LINENO
|
"${LZIP}" -df -o copy < "${in_lz}" || fail=1
|
||||||
cmp in out || test_failed $LINENO
|
cmp in copy || fail=1
|
||||||
"${LZIP}" -d -o ./- "${in_lz}" || test_failed $LINENO
|
printf .
|
||||||
cmp in ./- || test_failed $LINENO
|
|
||||||
rm -f ./- || framework_failure
|
|
||||||
"${LZIP}" -d -o ./- < "${in_lz}" || test_failed $LINENO
|
|
||||||
cmp in ./- || test_failed $LINENO
|
|
||||||
rm -f ./- || framework_failure
|
|
||||||
|
|
||||||
cp "${in_lz}" anyothername || framework_failure
|
"${LZIP}" -s16 < in > anyothername || fail=1
|
||||||
"${LZIP}" -dv - anyothername - < "${in_lz}" > out 2> /dev/null ||
|
"${LZIP}" -d anyothername || fail=1
|
||||||
test_failed $LINENO
|
cmp in anyothername.out || fail=1
|
||||||
cmp in out || test_failed $LINENO
|
printf .
|
||||||
cmp in anyothername.out || test_failed $LINENO
|
|
||||||
rm -f anyothername.out || framework_failure
|
|
||||||
|
|
||||||
"${LZIP}" -tq in "${in_lz}"
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -tq nx_file.lz "${in_lz}"
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -cdq in "${in_lz}" > out
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
cat out in | cmp in - || test_failed $LINENO # out must be empty
|
|
||||||
"${LZIP}" -cdq nx_file.lz "${in_lz}" > out # skip nx_file, decompress in
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
cmp in out || test_failed $LINENO
|
|
||||||
rm -f out || framework_failure
|
|
||||||
cp "${in_lz}" out.lz || framework_failure
|
|
||||||
for i in 1 2 3 4 5 6 7 ; do
|
|
||||||
printf "g" >> out.lz || framework_failure
|
|
||||||
"${LZIP}" -atvvvv out.lz "${in_lz}" 2> /dev/null
|
|
||||||
[ $? = 2 ] || test_failed $LINENO $i
|
|
||||||
done
|
|
||||||
"${LZIP}" -dq in out.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
[ -e out.lz ] || test_failed $LINENO
|
|
||||||
[ ! -e out ] || test_failed $LINENO
|
|
||||||
[ ! -e in.out ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -dq nx_file.lz out.lz
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
[ ! -e out.lz ] || test_failed $LINENO
|
|
||||||
[ ! -e nx_file ] || test_failed $LINENO
|
|
||||||
cmp in out || test_failed $LINENO
|
|
||||||
rm -f out || framework_failure
|
|
||||||
|
|
||||||
cat in in > in2 || framework_failure
|
cat in in > in2 || framework_failure
|
||||||
"${LZIP}" -t "${in_lz}" "${in_lz}" || test_failed $LINENO
|
"${LZIP}" -s16 -o copy2 < in2 || fail=1
|
||||||
"${LZIP}" -cd "${in_lz}" "${in_lz}" -o out > out2 || test_failed $LINENO
|
"${LZIP}" -t copy2.lz || fail=1
|
||||||
[ ! -e out ] || test_failed $LINENO # override -o
|
printf .
|
||||||
cmp in2 out2 || test_failed $LINENO
|
"${LZIP}" -cd copy2.lz > copy2 || fail=1
|
||||||
rm -f out2 || framework_failure
|
cmp in2 copy2 || fail=1
|
||||||
"${LZIP}" -d "${in_lz}" "${in_lz}" -o out2 || test_failed $LINENO
|
printf .
|
||||||
cmp in2 out2 || test_failed $LINENO
|
|
||||||
rm -f out2 || framework_failure
|
|
||||||
|
|
||||||
cat "${in_lz}" "${in_lz}" > out2.lz || framework_failure
|
printf "garbage" >> copy2.lz || framework_failure
|
||||||
lines=`"${LZIP}" -tvv out2.lz 2>&1 | wc -l` || test_failed $LINENO
|
printf "to be overwritten" > copy2 || framework_failure
|
||||||
[ "${lines}" -eq 2 ] || test_failed $LINENO "${lines}"
|
"${LZIP}" -df copy2.lz || fail=1
|
||||||
|
cmp in2 copy2 || fail=1
|
||||||
|
printf .
|
||||||
|
|
||||||
printf "\ngarbage" >> out2.lz || framework_failure
|
"${LZIP}" -cfq "${in_lz}" > out
|
||||||
"${LZIP}" -tvvvv out2.lz 2> /dev/null || test_failed $LINENO
|
if [ $? = 1 ] ; then printf . ; else printf - ; fail=1 ; fi
|
||||||
"${LZIP}" -atq out2.lz
|
"${LZIP}" -cF -s16 "${in_lz}" > out || fail=1
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
"${LZIP}" -cd out | "${LZIP}" -d > copy || fail=1
|
||||||
"${LZIP}" -atq < out2.lz
|
cmp in copy || fail=1
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
printf .
|
||||||
"${LZIP}" -adkq out2.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
[ ! -e out2 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -adkq -o out2 < out2.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
[ ! -e out2 ] || test_failed $LINENO
|
|
||||||
printf "to be overwritten" > out2 || framework_failure
|
|
||||||
"${LZIP}" -df out2.lz || test_failed $LINENO
|
|
||||||
cmp in2 out2 || test_failed $LINENO
|
|
||||||
rm -f out2 || framework_failure
|
|
||||||
|
|
||||||
touch empty em || framework_failure
|
|
||||||
"${LZIP}" -0 em || test_failed $LINENO
|
|
||||||
"${LZIP}" -dk em.lz || test_failed $LINENO
|
|
||||||
cmp empty em || test_failed $LINENO
|
|
||||||
cat em.lz em.lz | "${LZIP}" -t || test_failed $LINENO
|
|
||||||
cat em.lz em.lz | "${LZIP}" -d > em || test_failed $LINENO
|
|
||||||
cmp empty em || test_failed $LINENO
|
|
||||||
cat em.lz "${in_lz}" | "${LZIP}" -t || test_failed $LINENO
|
|
||||||
cat em.lz "${in_lz}" | "${LZIP}" -d > out || test_failed $LINENO
|
|
||||||
cmp in out || test_failed $LINENO
|
|
||||||
cat "${in_lz}" em.lz | "${LZIP}" -t || test_failed $LINENO
|
|
||||||
cat "${in_lz}" em.lz | "${LZIP}" -d > out || test_failed $LINENO
|
|
||||||
cmp in out || test_failed $LINENO
|
|
||||||
|
|
||||||
printf "\ntesting compression..."
|
|
||||||
|
|
||||||
"${LZIP}" -c -0 in in in -o out3.lz > copy2.lz || test_failed $LINENO
|
|
||||||
[ ! -e out3.lz ] || test_failed $LINENO # override -o
|
|
||||||
"${LZIP}" -0f in in --output=copy2.lz || test_failed $LINENO
|
|
||||||
"${LZIP}" -d copy2.lz -o out2 || test_failed $LINENO
|
|
||||||
[ -e copy2.lz ] || test_failed $LINENO
|
|
||||||
cmp in2 out2 || test_failed $LINENO
|
|
||||||
rm -f copy2.lz || framework_failure
|
|
||||||
|
|
||||||
"${LZIP}" -cf "${in_lz}" > lzlz 2> /dev/null # /dev/null is a tty on OS/2
|
|
||||||
[ $? = 1 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -Fvvm36 -o - -s16 "${in_lz}" > lzlz 2> /dev/null || test_failed $LINENO
|
|
||||||
"${LZIP}" -cd lzlz | "${LZIP}" -d > out || test_failed $LINENO
|
|
||||||
cmp in out || test_failed $LINENO
|
|
||||||
rm -f lzlz out || framework_failure
|
|
||||||
|
|
||||||
"${LZIP}" -0 -o ./- in || test_failed $LINENO
|
|
||||||
"${LZIP}" -cd ./- | cmp in - || test_failed $LINENO
|
|
||||||
rm -f ./- || framework_failure
|
|
||||||
"${LZIP}" -0 -o ./- < in || test_failed $LINENO # add .lz
|
|
||||||
[ ! -e ./- ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -cd -- -.lz | cmp in - || test_failed $LINENO
|
|
||||||
rm -f ./-.lz || framework_failure
|
|
||||||
|
|
||||||
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
|
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
|
||||||
"${LZIP}" -k -$i -s16 in || test_failed $LINENO $i
|
"${LZIP}" -k -$i -s16 in || fail=1
|
||||||
mv in.lz out.lz || test_failed $LINENO $i
|
mv -f in.lz copy.lz || fail=1
|
||||||
printf "garbage" >> out.lz || framework_failure
|
printf "garbage" >> copy.lz || fail=1
|
||||||
"${LZIP}" -df out.lz || test_failed $LINENO $i
|
"${LZIP}" -df copy.lz || fail=1
|
||||||
cmp in out || test_failed $LINENO $i
|
cmp in copy || fail=1
|
||||||
|
|
||||||
"${LZIP}" -$i -s16 in -c > out || test_failed $LINENO $i
|
|
||||||
"${LZIP}" -$i -s16 in -o o_out || test_failed $LINENO $i # don't add .lz
|
|
||||||
[ ! -e o_out.lz ] || test_failed $LINENO
|
|
||||||
cmp out o_out || test_failed $LINENO $i
|
|
||||||
rm -f o_out || framework_failure
|
|
||||||
printf "g" >> out || framework_failure
|
|
||||||
"${LZIP}" -cd out > copy || test_failed $LINENO $i
|
|
||||||
cmp in copy || test_failed $LINENO $i
|
|
||||||
|
|
||||||
"${LZIP}" -$i -s16 < in > out || test_failed $LINENO $i
|
|
||||||
"${LZIP}" -d < out > copy || test_failed $LINENO $i
|
|
||||||
cmp in copy || test_failed $LINENO $i
|
|
||||||
|
|
||||||
rm -f out || framework_failure
|
|
||||||
printf "to be overwritten" > out.lz || framework_failure
|
|
||||||
"${LZIP}" -f -$i -s16 -o out < in || test_failed $LINENO $i # add .lz
|
|
||||||
[ ! -e out ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -df -o copy < out.lz || test_failed $LINENO $i
|
|
||||||
cmp in copy || test_failed $LINENO $i
|
|
||||||
done
|
done
|
||||||
rm -f copy out.lz || framework_failure
|
printf .
|
||||||
|
|
||||||
printf "\ntesting bad input..."
|
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
|
||||||
|
"${LZIP}" -c -$i -s16 in > out || fail=1
|
||||||
cat em.lz em.lz > ee.lz || framework_failure
|
printf "g" >> out || fail=1
|
||||||
"${LZIP}" -t < ee.lz || test_failed $LINENO
|
"${LZIP}" -cd out > copy || fail=1
|
||||||
"${LZIP}" -d < ee.lz > em || test_failed $LINENO
|
cmp in copy || fail=1
|
||||||
cmp empty em || test_failed $LINENO
|
|
||||||
"${LZIP}" -tq ee.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -dq ee.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
[ ! -e ee ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -cdq ee.lz > em
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
cmp empty em || test_failed $LINENO
|
|
||||||
rm -f empty em || framework_failure
|
|
||||||
cat "${in_lz}" em.lz "${in_lz}" > inein.lz || framework_failure
|
|
||||||
"${LZIP}" -t < inein.lz || test_failed $LINENO
|
|
||||||
"${LZIP}" -d < inein.lz > out2 || test_failed $LINENO
|
|
||||||
cmp in2 out2 || test_failed $LINENO
|
|
||||||
"${LZIP}" -tq inein.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -dq inein.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
[ ! -e inein ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -cdq inein.lz > out2
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
cmp in2 out2 || test_failed $LINENO
|
|
||||||
rm -f in2 out2 inein.lz em.lz || framework_failure
|
|
||||||
|
|
||||||
headers='LZIp LZiP LZip LzIP LzIp LziP lZIP lZIp lZiP lzIP'
|
|
||||||
body='\001\014\000\000\101\376\367\377\377\340\000\200\000\215\357\002\322\001\000\000\000\000\000\000\000\045\000\000\000\000\000\000\000'
|
|
||||||
cp "${in_lz}" int.lz || framework_failure
|
|
||||||
printf "LZIP${body}" >> int.lz || framework_failure
|
|
||||||
if "${LZIP}" -t int.lz ; then
|
|
||||||
for header in ${headers} ; do
|
|
||||||
printf "${header}${body}" > int.lz || framework_failure
|
|
||||||
"${LZIP}" -tq int.lz # first member
|
|
||||||
[ $? = 2 ] || test_failed $LINENO ${header}
|
|
||||||
"${LZIP}" -tq < int.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO ${header}
|
|
||||||
"${LZIP}" -cdq int.lz > /dev/null
|
|
||||||
[ $? = 2 ] || test_failed $LINENO ${header}
|
|
||||||
"${LZIP}" -tq --loose-trailing int.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO ${header}
|
|
||||||
"${LZIP}" -tq --loose-trailing < int.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO ${header}
|
|
||||||
"${LZIP}" -cdq --loose-trailing int.lz > /dev/null
|
|
||||||
[ $? = 2 ] || test_failed $LINENO ${header}
|
|
||||||
cp "${in_lz}" int.lz || framework_failure
|
|
||||||
printf "${header}${body}" >> int.lz || framework_failure
|
|
||||||
"${LZIP}" -tq int.lz # trailing data
|
|
||||||
[ $? = 2 ] || test_failed $LINENO ${header}
|
|
||||||
"${LZIP}" -tq < int.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO ${header}
|
|
||||||
"${LZIP}" -cdq int.lz > /dev/null
|
|
||||||
[ $? = 2 ] || test_failed $LINENO ${header}
|
|
||||||
"${LZIP}" -t --loose-trailing int.lz ||
|
|
||||||
test_failed $LINENO ${header}
|
|
||||||
"${LZIP}" -t --loose-trailing < int.lz ||
|
|
||||||
test_failed $LINENO ${header}
|
|
||||||
"${LZIP}" -cd --loose-trailing int.lz > /dev/null ||
|
|
||||||
test_failed $LINENO ${header}
|
|
||||||
"${LZIP}" -tq --loose-trailing --trailing-error int.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO ${header}
|
|
||||||
"${LZIP}" -tq --loose-trailing --trailing-error < int.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO ${header}
|
|
||||||
"${LZIP}" -cdq --loose-trailing --trailing-error int.lz > /dev/null
|
|
||||||
[ $? = 2 ] || test_failed $LINENO ${header}
|
|
||||||
done
|
|
||||||
else
|
|
||||||
printf "warning: skipping header test: 'printf' does not work on your system."
|
|
||||||
fi
|
|
||||||
rm -f int.lz || framework_failure
|
|
||||||
|
|
||||||
"${LZIP}" -tq "${fnz_lz}"
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
|
|
||||||
for i in fox_v2.lz fox_s11.lz fox_de20.lz \
|
|
||||||
fox_bcrc.lz fox_crc0.lz fox_das46.lz fox_mes81.lz ; do
|
|
||||||
"${LZIP}" -tq "${testdir}"/$i
|
|
||||||
[ $? = 2 ] || test_failed $LINENO $i
|
|
||||||
done
|
done
|
||||||
|
printf .
|
||||||
|
|
||||||
for i in fox_bcrc.lz fox_crc0.lz fox_das46.lz fox_mes81.lz ; do
|
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
|
||||||
"${LZIP}" -cdq "${testdir}"/$i > out
|
"${LZIP}" -$i -s16 < in > out || fail=1
|
||||||
[ $? = 2 ] || test_failed $LINENO $i
|
"${LZIP}" -d < out > copy || fail=1
|
||||||
cmp fox out || test_failed $LINENO $i
|
cmp in copy || fail=1
|
||||||
done
|
done
|
||||||
rm -f fox || framework_failure
|
printf .
|
||||||
|
|
||||||
cat "${in_lz}" "${in_lz}" > in2.lz || framework_failure
|
for i in s4Ki 0 1 2 3 4 5 6 7 8 9 ; do
|
||||||
cat "${in_lz}" "${in_lz}" "${in_lz}" > in3.lz || framework_failure
|
"${LZIP}" -f -$i -s16 -o out < in || fail=1
|
||||||
if dd if=in3.lz of=trunc.lz bs=14682 count=1 2> /dev/null &&
|
"${LZIP}" -df -o copy < out.lz || fail=1
|
||||||
[ -e trunc.lz ] && cmp in2.lz trunc.lz ; then
|
cmp in copy || fail=1
|
||||||
for i in 6 20 14664 14683 14684 14685 14686 14687 14688 ; do
|
done
|
||||||
dd if=in3.lz of=trunc.lz bs=$i count=1 2> /dev/null
|
printf .
|
||||||
"${LZIP}" -tq trunc.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO $i
|
|
||||||
"${LZIP}" -tq < trunc.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO $i
|
|
||||||
"${LZIP}" -cdq trunc.lz > /dev/null
|
|
||||||
[ $? = 2 ] || test_failed $LINENO $i
|
|
||||||
"${LZIP}" -dq < trunc.lz > /dev/null
|
|
||||||
[ $? = 2 ] || test_failed $LINENO $i
|
|
||||||
done
|
|
||||||
else
|
|
||||||
printf "warning: skipping truncation test: 'dd' does not work on your system."
|
|
||||||
fi
|
|
||||||
rm -f in2.lz in3.lz trunc.lz || framework_failure
|
|
||||||
|
|
||||||
cp "${in_lz}" ingin.lz || framework_failure
|
|
||||||
printf "g" >> ingin.lz || framework_failure
|
|
||||||
cat "${in_lz}" >> ingin.lz || framework_failure
|
|
||||||
"${LZIP}" -atq ingin.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -atq < ingin.lz
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
"${LZIP}" -acdq ingin.lz > out
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
cmp in out || test_failed $LINENO
|
|
||||||
"${LZIP}" -adq < ingin.lz > out
|
|
||||||
[ $? = 2 ] || test_failed $LINENO
|
|
||||||
cmp in out || test_failed $LINENO
|
|
||||||
"${LZIP}" -t ingin.lz || test_failed $LINENO
|
|
||||||
"${LZIP}" -t < ingin.lz || test_failed $LINENO
|
|
||||||
"${LZIP}" -dk ingin.lz || test_failed $LINENO
|
|
||||||
cmp in ingin || test_failed $LINENO
|
|
||||||
"${LZIP}" -cd ingin.lz > out || test_failed $LINENO
|
|
||||||
cmp in out || test_failed $LINENO
|
|
||||||
"${LZIP}" -d < ingin.lz > out || test_failed $LINENO
|
|
||||||
cmp in out || test_failed $LINENO
|
|
||||||
rm -f out ingin ingin.lz || framework_failure
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
if [ ${fail} = 0 ] ; then
|
if [ ${fail} = 0 ] ; then
|
||||||
|
|
BIN
testsuite/fox.lz
BIN
testsuite/fox.lz
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,7 +1,8 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 2, June 1991
|
Version 2, June 1991
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. <http://fsf.org/>
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
@ -338,7 +339,8 @@ Public License instead of this License.
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 2, June 1991
|
Version 2, June 1991
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. <http://fsf.org/>
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||||
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue