pub(super) use crate::compat::host::printf;
pub(super) const PREFIX: &str = "%s: ";
pub(super) const ERRNO_SUFFIX: &str = ": %s\n";
pub(super) const NEWLINE: &str = "\n";
pub(super) const GZIP_VERSION: &str = "Apple gzip 487.0.1\n";
pub(super) const VERSION_FIRST_LINE: &str = concat!(
"Apple gzip (stuffr ",
env!("CARGO_PKG_VERSION"),
") 487.0.1\n"
);
pub(super) const LICENSE_FIRST_LINE: &str = concat!(
"Apple gzip (stuffr ",
env!("CARGO_PKG_VERSION"),
") 487.0.1 (based on FreeBSD gzip 20190107, NetBSD gzip 20150113)\n"
);
pub(super) const LICENSE_REST: &str = concat!(
" Copyright (c) 1997, 1998, 2003, 2004, 2006 Matthew R. Green\n",
" All rights reserved.\n",
"\n",
" Redistribution and use in source and binary forms, with or without\n",
" modification, are permitted provided that the following conditions\n",
" are met:\n",
" 1. Redistributions of source code must retain the above copyright\n",
" notice, this list of conditions and the following disclaimer.\n",
" 2. Redistributions in binary form must reproduce the above copyright\n",
" notice, this list of conditions and the following disclaimer in the\n",
" documentation and/or other materials provided with the distribution.\n",
"\n",
" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR\n",
" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\n",
" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\n",
" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,\n",
" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n",
" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n",
" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED\n",
" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,\n",
" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n",
" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n",
" SUCH DAMAGE.\n",
);
pub(super) const USAGE: &str = concat!(
"usage: %s [-123456789acdfhklLNnqrtVv] [-S .suffix] [<file> [<file> ...]]\n",
" -1 --fast fastest (worst) compression\n",
" -2 .. -8 set compression level\n",
" -9 --best best (slowest) compression\n",
" -c --stdout write to stdout, keep original files\n",
" --to-stdout\n",
" -d --decompress uncompress files\n",
" --uncompress\n",
" -f --force force overwriting & compress links\n",
" -h --help display this help\n",
" -k --keep don't delete input files during operation\n",
" -l --list list compressed file contents\n",
" -N --name save or restore original file name and time stamp\n",
" -n --no-name don't save original file name or time stamp\n",
" -q --quiet output no warnings\n",
" -r --recursive recursively compress files in directories\n",
" -S .suf use suffix .suf instead of .gz\n",
" --suffix .suf\n",
" -t --test test compressed file\n",
" -V --version display program version\n",
" -v --verbose print extra statistics\n",
);
pub(super) const INVALID_OPTION: &str = "invalid option -- %s\n";
pub(super) const ILLEGAL_OPTION: &str = "illegal option -- %s\n";
pub(super) const NEEDS_ARGUMENT_SHORT: &str = "option requires an argument -- %s\n";
pub(super) const AMBIGUOUS: &str = "option `--%s' is ambiguous\n";
pub(super) const NO_ARGUMENT: &str = "option `--%s' doesn't allow an argument\n";
pub(super) const NEEDS_ARGUMENT_LONG: &str = "option `--%s' requires an argument\n";
pub(super) const UNRECOGNIZED: &str = "unrecognized option `--%s'\n";
pub(super) const ASCII_IGNORED: &str = "%s: option --ascii ignored on this system\n";
pub(super) const SUFFIX_TOO_LONG: &str = "incorrect suffix: '%s': too long\n";
pub(super) const CANT_STAT: &str = "can't stat: %s (%s)";
pub(super) const IS_DIRECTORY: &str = "%s is a directory";
pub(super) const NOT_REGULAR: &str = "%s is not a regular file";
pub(super) const PATH_ONLY: &str = "%s";
pub(super) const CANT_OPEN: &str = "can't open %s";
pub(super) const COULDNT_STAT: &str = "couldn't stat: %s";
pub(super) const HAS_LINKS: &str = "%s has %s other link%s -- skipping";
pub(super) const HAS_SUFFIX: &str = "%s already has %s suffix -- unchanged";
pub(super) const ALREADY_EXISTS: &str = "%s already exists -- skipping";
pub(super) const ASK_OVERWRITE: &str = "%s already exists -- do you wish to overwrite (y or n)? ";
pub(super) const NOT_OVERWRITING: &str = "\tnot overwriting\n";
pub(super) const COULD_NOT_CREATE: &str = "could not create output: %s";
pub(super) const WRONG_SIZE: &str = "output file: %s wrong size (%s != %s), deleting";
pub(super) const LEAVING_ORIGINAL: &str = "leaving original %s";
pub(super) const COULDNT_FCHOWN: &str = "couldn't fchown: %s";
pub(super) const COULDNT_FCHMOD: &str = "couldn't fchmod: %s";
pub(super) const COULDNT_FUTIMENS: &str = "couldn't futimens: %s";
#[cfg_attr(not(target_os = "macos"), allow(dead_code))]
pub(super) const COULDNT_FCHFLAGS: &str = "couldn't fchflags: %s";
pub(super) const READ: &str = "read";
pub(super) const WRITE: &str = "write";
pub(super) const DEFLATE_FAILED: &str = "deflate failed";
pub(super) const STDOUT_IS_TERMINAL: &str = "standard output is a terminal -- ignoring";
pub(super) const CANT_STAT_STDIN: &str = "Can't stat stdin";
pub(super) const VERBOSE_NAME: &str = "%s:%s ";
pub(super) const TABS_SHORT: &str = "\t\t";
pub(super) const TAB_LONG: &str = "\t";
pub(super) const RATIO: &str = "%s%%";
pub(super) const REPLACED_WITH: &str = " -- replaced with %s";
pub(super) const STDIN_IS_TERMINAL: &str = "standard input is a terminal -- ignoring";
pub(super) const FSTAT: &str = "fstat";
pub(super) const CANT_READ_STDIN: &str = "can't read stdin";
pub(super) const STDIN_UNEXPECTED_EOF: &str = "(stdin): unexpected end of file";
pub(super) const UNKNOWN_FORMAT: &str = "unknown compression format";
pub(super) const STDIN_NAME: &str = "(stdin)";
pub(super) const CANT_STAT_FILE: &str = "can't stat %s";
pub(super) const UNKNOWN_SUFFIX: &str = "%s: unknown suffix -- ignored";
pub(super) const CANT_READ: &str = "can't read %s";
pub(super) const UNEXPECTED_EOF: &str = "%s: unexpected end of file";
pub(super) const NOT_IN_GZIP_FORMAT: &str = "%s: not in gzip format";
pub(super) const HAS_LINKS_UNCOMPRESS: &str = "%s has %s other links -- skipping";
pub(super) const CANT_OPEN_OUTPUT: &str = "can't open %s";
pub(super) const NO_L_BZIP2: &str = "no -l with bzip2 files";
pub(super) const NO_L_COMPRESS: &str = "no -l with Lempel-Ziv files";
pub(super) const NO_L_PACK: &str = "no -l with packed files";
pub(super) const NO_L_LZIP: &str = "no -l with lzip files";
pub(super) const NO_L_UNKNOWN: &str = "no -l for unknown filetypes";
pub(super) const FAILED_INFILE: &str = "failed infile";
pub(super) const UNCOMPRESS_FAILED: &str = "%s: uncompress failed";
pub(super) const DIFFERENT_SIZE: &str = "stat gave different size: %s != %s (leaving original)";
pub(super) const COULDNT_OPEN_LEAVING: &str = "couldn't open (leaving original): %s";
pub(super) const FAILED_TO_READ: &str = "failed to read stdin";
pub(super) const TRAILING_GARBAGE: &str = "%s: trailing garbage ignored";
pub(super) const NOT_GZIPED_MAGIC1: &str = "input not gziped (MAGIC1)";
pub(super) const UNKNOWN_METHOD: &str = "unknown compression method";
pub(super) const DATA_STREAM_ERROR: &str = "data stream error";
pub(super) const ERROR_WRITING: &str = "error writing to output";
pub(super) const TRUNCATED_INPUT: &str = "truncated input";
pub(super) const CRC_ERROR: &str = "invalid compressed data--crc error";
pub(super) const LENGTH_ERROR: &str = "invalid compressed data--length error";
pub(super) const WRITE_TO_STDOUT: &str = "write to stdout";
pub(super) const READ_FROM_FD: &str = "read from fd %s";
pub(super) const BZ_TRUNCATED: &str = "truncated file";
pub(super) const BZ_READ: &str = "read";
pub(super) const BZ_WRITE: &str = "write";
pub(super) const BZ_DATA_ERROR: &str = "bzip2 data integrity error";
pub(super) const BZ_MAGIC_ERROR: &str = "bzip2 magic number error";
pub(super) const BZ_MEMORY: &str = "bzip2 out of memory";
pub(super) const BZ_UNKNOWN: &str = "unknown bzip2 error: %s";
pub(super) const XZ_READ_FAILED: &str = "read failed";
#[cfg_attr(not(feature = "xz-c"), allow(dead_code))] pub(super) const XZ_CANT_INITIALIZE: &str = "Can't initialize decoder (%s)";
#[cfg_attr(not(feature = "xz-c"), allow(dead_code))] pub(super) const XZ_FORMAT: &str = "File format not recognized";
#[cfg_attr(not(feature = "xz-c"), allow(dead_code))] pub(super) const XZ_UNKNOWN: &str = "Unknown error (%s)";
pub(super) const XZ_CANT_READ_HEADERS: &str = "Can't read headers (%s)";
pub(super) const XZ_WRITE_FAILED: &str = "write failed";
#[cfg_attr(not(feature = "xz-c"), allow(dead_code))] pub(super) const XZ_OPTIONS: &str = "Unsupported compression options";
pub(super) const XZ_CORRUPT: &str = "File is corrupt";
pub(super) const XZ_UNEXPECTED_END: &str = "Unexpected end of input";
#[cfg_attr(not(feature = "xz-c"), allow(dead_code))] pub(super) const XZ_MEMLIMIT: &str = "Reached memory limit";
pub(super) const PACK_INSANE_LEVELS: &str = "Huffman tree has insane levels";
pub(super) const PACK_TRUNCATED: &str = "File appears to be truncated";
pub(super) const PACK_BAD_TABLE: &str = "Bad symbol table";
pub(super) const PACK_TABLE_TRUNCATED: &str = "Symbol table truncated";
pub(super) const PACK_CORRUPT: &str = "File corrupt";
pub(super) const PACK_PREMATURE_EOF: &str = "Premature EOF";
pub(super) const TEST_LINE: &str = "%s:%s %s\n";
pub(super) const OK: &str = "OK";
pub(super) const NOT_OK: &str = "NOT OK";
pub(super) const LIST_VERBOSE_HEADER: &str = "method crc date time ";
pub(super) const LIST_HEADER: &str = " compressed uncompressed ratio uncompressed_name\n";
pub(super) const READ_OF_SIZE: &str = "read of uncompressed size";
pub(super) const LIST_VERBOSE_TOTALS: &str = " ";
pub(super) const LIST_VERBOSE_ROW: &str = "defla %s %s ";
pub(super) const LIST_ROW: &str = "%s %s ";
pub(super) const LIST_NAME: &str = " %s\n";
pub(super) const TOTALS: &str = "(totals)";
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn only_version_and_license_name_stuffr() {
assert!(VERSION_FIRST_LINE.starts_with("Apple gzip (stuffr "));
assert!(LICENSE_FIRST_LINE.starts_with("Apple gzip (stuffr "));
assert!(!GZIP_VERSION.contains("stuffr"));
assert!(!USAGE.contains("stuffr"));
assert!(!LICENSE_REST.contains("stuffr"));
}
}