Merge pull request #113 from pete4abw/master

update to lrzip.conf.5 manpage and example file.
This commit is contained in:
Con Kolivas 2019-06-19 20:44:20 +10:00 committed by GitHub
commit b922018128
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 72 deletions

View file

@ -1,55 +1,47 @@
# lrzip.conf example file # lrzip.conf example file
# anything beginning with a # or whitespace will be ignored # anything beginning with a # or whitespace will be ignored
# valid parameters are separated with an = and a value # valid parameters are separated with an = and a value
# parameters and values are not case sensitive # parameters and values are not case sensitive except where specified
# #
# lrzip 0.24+, peter hyman, pete@peterhyman.com # lrzip 0.24+, peter hyman, pete@peterhyman.com
# ignored by earlier versions. # ignored by earlier versions.
# Compression Window size in 100MB. Normally selected by program. # Compression Window size in 100MB. Normally selected by program. (-w)
# WINDOW = 20 # WINDOW = 20
# Compression Level 1-9 (7 Default). (-L)
# Compression Level 1-9 (7 Default).
# COMPRESSIONLEVEL = 7 # COMPRESSIONLEVEL = 7
# Use -U setting, Unlimited ram. Yes or No # Use -U setting, Unlimited ram. Yes or No
# UNLIMITED = NO # UNLIMITED = NO
# Compression Method, rzip, gzip, bzip2, lzo, or lzma (default), or zpaq. (-n -g -b -l --lzma -z)
# Compression Method, rzip, gzip, bzip2, lzo, or lzma (default), or zpaq.
# If specified here, command line options not usable. # If specified here, command line options not usable.
# COMPRESSIONMETHOD = lzma # COMPRESSIONMETHOD = lzma
# Perform LZO Test. Default = YES (-T )
# Perform LZO Test. Default = YES (-T option, NO)
# LZOTEST = NO # LZOTEST = NO
# Hash Check on decompression, (-c)
# Hash Check on decompression, YES
# HASHCHECK = YES # HASHCHECK = YES
# Show HASH value on Compression even if Verbose is off, YES (-H)
# Show HASH value on Compression even if Verbose is off, YES
# SHOWHASH = YES # SHOWHASH = YES
# Default output directory # Default output directory (-O)
# OUTPUTDIRECTORY = location # OUTPUTDIRECTORY = location
# Verbosity, YES or MAX (v, vv)
# Verbosity, Yes or Max
# VERBOSITY = max # VERBOSITY = max
# Show Progress as file is parsed, YES or no (NO = -q option)
# SHOWPROGRESS = YES
# Show Progress as file is parsed, Yes or no # Set Niceness. 19 is default. -20 to 19 is the allowable range (-N)
# SHOWPROGRESS = true
# Set Niceness. 19 is default. -20 to 19 is the allowable range
# NICE = 19 # NICE = 19
# Keep broken or damaged output files, YES # Keep broken or damaged output files, YES (-K)
# KEEPBROKEN = YES # KEEPBROKEN = YES
# Delete source file after compression # Delete source file after compression (-D)
# this parameter and value are case sensitive # this parameter and value are case sensitive
# value must be YES to activate # value must be YES to activate
# DELETEFILES = NO # DELETEFILES = NO
# Replace existing lrzip file when compressing # Replace existing lrzip file when compressing (-f)
# this parameter and value are case sensitive # this parameter and value are case sensitive
# value must be YES to activate # value must be YES to activate
@ -58,6 +50,6 @@
# Override for Temporary Directory. Only valid when stdin/out or Test is used # Override for Temporary Directory. Only valid when stdin/out or Test is used
# TMPDIR = /tmp # TMPDIR = /tmp
# Whether to use encryption on compression YES, NO (-e)
# ENCRYPT = NO # ENCRYPT = NO
# Whether to use encryption on compression

52
main.c
View file

@ -308,6 +308,7 @@ static const char *coptions = "bcCdefghHikKlLnN:o:O:p:PrS:tTUm:vVw:z?123456789";
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
bool lrzcat = false, compat = false, recurse = false; bool lrzcat = false, compat = false, recurse = false;
bool options_file = false; /* for environment and tracking of compression setting */
struct timeval start_time, end_time; struct timeval start_time, end_time;
struct sigaction handler; struct sigaction handler;
double seconds,total_time; // for timers double seconds,total_time; // for timers
@ -342,19 +343,44 @@ int main(int argc, char *argv[])
/* Get Preloaded Defaults from lrzip.conf /* Get Preloaded Defaults from lrzip.conf
* Look in ., $HOME/.lrzip/, /etc/lrzip. * Look in ., $HOME/.lrzip/, /etc/lrzip.
* If LRZIP=NOCONFIG is set, then ignore config * If LRZIP=NOCONFIG is set, then ignore config
* If lrzip.conf sets a compression mode, options_file will be true.
* This will allow for a test to permit an override of compression mode.
* If there is an override, then all compression settings will be reset
* and command line switches will prevail, including for --lzma.
*/ */
eptr = getenv("LRZIP"); eptr = getenv("LRZIP");
if (eptr == NULL) if (eptr == NULL)
read_config(control); options_file = read_config(control);
else if (!strstr(eptr,"NOCONFIG")) else if (!strstr(eptr,"NOCONFIG"))
read_config(control); options_file = read_config(control);
if (options_file)
if (control->flags & FLAG_NOT_LZMA) /* if compression set in conf file */
control->flags &= ~FLAG_NOT_LZMA; /* clear compression flags (LZMA now default) */
while ((c = getopt_long(argc, argv, compat ? coptions : loptions, long_options, &i)) != -1) { while ((c = getopt_long(argc, argv, compat ? coptions : loptions, long_options, &i)) != -1) {
switch (c) { switch (c) {
case 'b': case 'b':
case 'g':
case 'l':
case 'n':
case 'z':
if (control->flags & FLAG_NOT_LZMA) if (control->flags & FLAG_NOT_LZMA)
failure("Can only use one of -l, -b, -g, -z or -n\n"); failure("Can only use one of -l, -b, -g, -z or -n\n");
control->flags |= FLAG_BZIP2_COMPRESS; /* Select Compression Mode */
if (c == 'b')
control->flags |= FLAG_BZIP2_COMPRESS;
else if (c == 'g')
control->flags |= FLAG_ZLIB_COMPRESS;
else if (c == 'l')
control->flags |= FLAG_LZO_COMPRESS;
else if (c == 'n')
control->flags |= FLAG_NO_COMPRESS;
else if (c == 'z')
control->flags |= FLAG_ZPAQ_COMPRESS;
break;
case '/': /* LZMA Compress selected */
control->flags &= ~FLAG_NOT_LZMA; /* clear alternate compression flags */
break; break;
case 'c': case 'c':
if (compat) { if (compat) {
@ -380,11 +406,6 @@ int main(int argc, char *argv[])
case 'f': case 'f':
control->flags |= FLAG_FORCE_REPLACE; control->flags |= FLAG_FORCE_REPLACE;
break; break;
case 'g':
if (control->flags & FLAG_NOT_LZMA)
failure("Can only use one of -l, -b, -g, -z or -n\n");
control->flags |= FLAG_ZLIB_COMPRESS;
break;
case 'h': case 'h':
case '?': case '?':
usage(compat); usage(compat);
@ -405,11 +426,6 @@ int main(int argc, char *argv[])
case 'K': case 'K':
control->flags |= FLAG_KEEP_BROKEN; control->flags |= FLAG_KEEP_BROKEN;
break; break;
case 'l':
if (control->flags & FLAG_NOT_LZMA)
failure("Can only use one of -l, -b, -g, -z or -n\n");
control->flags |= FLAG_LZO_COMPRESS;
break;
case 'L': case 'L':
if (compat) { if (compat) {
license(); license();
@ -422,11 +438,6 @@ int main(int argc, char *argv[])
case 'm': case 'm':
control->ramsize = atol(optarg) * 1024 * 1024 * 100; control->ramsize = atol(optarg) * 1024 * 1024 * 100;
break; break;
case 'n':
if (control->flags & FLAG_NOT_LZMA)
failure("Can only use one of -l, -b, -g, -z or -n\n");
control->flags |= FLAG_NO_COMPRESS;
break;
case 'N': case 'N':
control->nice_val = atoi(optarg); control->nice_val = atoi(optarg);
if (control->nice_val < -20 || control->nice_val > 19) if (control->nice_val < -20 || control->nice_val > 19)
@ -508,11 +519,6 @@ int main(int argc, char *argv[])
if (control->window < 1) if (control->window < 1)
failure("Window must be positive\n"); failure("Window must be positive\n");
break; break;
case 'z':
if (control->flags & FLAG_NOT_LZMA)
failure("Can only use one of -l, -b, -g, -z or -n\n");
control->flags |= FLAG_ZPAQ_COMPRESS;
break;
case '1': case '1':
case '2': case '2':
case '3': case '3':

View file

@ -1,4 +1,4 @@
.TH "lrzip.conf" "5" "January 2009" "" "" .TH "lrzip.conf" "5" "January 2009, updated May 2019" "" ""
.SH "NAME" .SH "NAME"
lrzip.conf \- Configuration File for lrzip lrzip.conf \- Configuration File for lrzip
.SH "DESCRIPTION" .SH "DESCRIPTION"
@ -13,54 +13,63 @@ three places\&:
.nf .nf
$PWD \- Current Directory $PWD \- Current Directory
/etc/lrzip /etc/lrzip
$HOME/\&./lrzip $HOME/\&.lrzip
.PP .PP
Parameters are set in \fBPARAMETER\&=VALUE\fP fashion where any line Parameters are set in \fBPARAMETER\&=VALUE\fP fashion where any line
beginning with a \fB#\fP or that is blank will be ignored\&. beginning with a \fB#\fP or that is blank will be ignored\&.
Parameter values are not case sensitive\&. Parameter values are not case sensitive except where specified\&.
.PP .PP
.SH "CONFIG FILE EXAMPLE" .SH "CONFIG FILE EXAMPLE"
.nf .nf
# This is a comment. # This is a comment.
# Compression Window size in 100MB. Normally selected by program. # Compression Window size in 100MB. Normally selected by program. (-w)
# WINDOW = 5 # WINDOW = 20
# Compression Level 1-9 (7 Default). # Compression Level 1-9 (7 Default). (-L)
# COMPRESSIONLEVEL = 7 # COMPRESSIONLEVEL = 7
# Unlimited Ram Compression # Use -U setting, Unlimited ram. Yes or No
# UNLIMITED = YES # UNLIMITED = NO
# Compression Method, rzip, gzip, bzip2, lzo, or lzma (default), zpaq. # Compression Method, rzip, gzip, bzip2, lzo, or lzma (default), or zpaq. (-n -g -b -l --lzma -z)
# COMPRESSIONMETHOD = LZMA # If specified here, command line options not usable.
# Perform LZO Test. Default = YES (\-T option, NO) # COMPRESSIONMETHOD = lzma
# Perform LZO Test. Default = YES (-T )
# LZOTEST = NO # LZOTEST = NO
# Hash Check on decompression, YES # Hash Check on decompression, (-c)
# HASHCHECK = YES # HASHCHECK = YES
# Show HASH value on Compression even if Verbose is off, YES # Show HASH value on Compression even if Verbose is off, YES (-H)
# SHOWHASH = YES # SHOWHASH = YES
# Default output directory # Default output directory (-O)
# OUTPUTDIRECTORY = location # OUTPUTDIRECTORY = location
# Verbosity, Yes or Max # Verbosity, YES or MAX (v, vv)
# VERBOSITY = MAX # VERBOSITY = max
# Show Progress as file is parsed, YES, NO (yes is default) # Show Progress as file is parsed, YES or no (NO = -q option)
# SHOWPROGRESS = NO # SHOWPROGRESS = YES
# Set Niceness. 19 is default. \-20 to 19 is the allowable range
# Set Niceness. 19 is default. -20 to 19 is the allowable range (-N)
# NICE = 19 # NICE = 19
# Keep broken or damaged output files, YES # Keep broken or damaged output files, YES (-K)
# KEEPBROKEN = YES # KEEPBROKEN = YES
# Delete source file after compression
# Delete source file after compression (-D)
# this parameter and value are case sensitive # this parameter and value are case sensitive
# value must be YES to activate # value must be YES to activate
# DELETEFILES = NO # DELETEFILES = NO
# Replace existing lrzip file when compressing # Replace existing lrzip file when compressing (-f)
# this parameter and value are case sensitive # this parameter and value are case sensitive
# value must be YES to activate # value must be YES to activate
# REPLACEFILE = NO
# Select Temporary Directory when stdin/stdout or Test file is used # REPLACEFILE = YES
# Override for Temporary Directory. Only valid when stdin/out or Test is used
# TMPDIR = /tmp # TMPDIR = /tmp
# Whether to use encryption on compression YES, NO (-e)
# ENCRYPT = NO
.fi .fi
.PP .PP
.SH "NOTES" .SH "NOTES"

2
util.c
View file

@ -205,7 +205,7 @@ bool read_config(rzip_control *control)
fprintf(control->msgout, "Using configuration file /etc/lrzip/lrzip.conf\n"); fprintf(control->msgout, "Using configuration file /etc/lrzip/lrzip.conf\n");
} }
if (fp == NULL) if (fp == NULL)
return true; return false;
/* if we get here, we have a file. read until no more. */ /* if we get here, we have a file. read until no more. */