rzip-2.1/0040755000113300011330000000000010374223177011656 5ustar tridgetridgerzip-2.1/zlib/0040755000113300011330000000000010012625471012606 5ustar tridgetridgerzip-2.1/test-random.sh0100755000113300011330000000161607750344204014452 0ustar tridgetridge#! /bin/sh set -e # Size to test in MB. BIG=30 make mkrandom echo Testing ${BIG}MB of random ./mkrandom $BIG 0 0 > /tmp/rzip.random # Get starting size ./rzip -k -o /tmp/rzip.random.rz /tmp/rzip.random BASE_SIZE=`ls -l /tmp/rzip.random.rz | awk '{print $5}'` rm /tmp/rzip.random /tmp/rzip.random.rz echo Gain for ${BIG}MB: `expr $BASE_SIZE - $BIG \* 1024 \* 1024` echo `echo "scale=5; ( $BASE_SIZE - $BIG * 1024 * 1024 ) * 100 / ( $BIG * 1024 * 1024 )" | bc` percent. for size in 10 100 1000 10000 100000; do for dups in 1 4 16; do ./mkrandom $BIG $size $dups > /tmp/rzip.random ./rzip -k -o /tmp/rzip.random.rz /tmp/rzip.random SIZE=`ls -l /tmp/rzip.random.rz | awk '{print $5}'` rm /tmp/rzip.random /tmp/rzip.random.rz PERCENT=`echo "scale=5; ( $BASE_SIZE - $SIZE ) * 100 / ( $dups * $size )" | bc` echo "Improvement for $dups x $size: `expr $BASE_SIZE - $SIZE` $PERCENT%" done done rzip-2.1/COPYING0100644000113300011330000004307606536253600012717 0ustar tridgetridge GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. rzip-2.1/Makefile.in0100664000113300011330000000171510374223177013726 0ustar tridgetridge# Makefile for rzip. This is processed by configure to produce the final # Makefile prefix=@prefix@ exec_prefix=@exec_prefix@ INSTALL_BIN=$(exec_prefix)/bin INSTALL_MAN=$(prefix)/man LIBS=@LIBS@ CC=@CC@ CFLAGS=@CFLAGS@ INSTALLCMD=@INSTALL@ VPATH=@srcdir@ srcdir=@srcdir@ SHELL=/bin/sh .SUFFIXES: .SUFFIXES: .c .o OBJS= rzip.o runzip.o main.o stream.o util.o crc32.o # note that the -I. is needed to handle config.h when using VPATH .c.o: $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@ all: rzip man: rzip.1 install: all -mkdir -p ${INSTALL_BIN} ${INSTALLCMD} -m 755 rzip ${INSTALL_BIN} -mkdir -p ${INSTALL_MAN}/man1 ${INSTALLCMD} -m 644 $(srcdir)/rzip.1 ${INSTALL_MAN}/man1/ rzip: $(OBJS) $(CC) $(CFLAGS) -o rzip $(OBJS) $(LIBS) rzip.1: rzip.yo yodl2man -o rzip.1 rzip.yo web/rzip-man.html: rzip.yo mkdir -p man yodl2html -o web/rzip-man.html rzip.yo docs: rzip.1 web/rzip-man.html clean: rm -f *~ $(OBJS) rzip config.cache config.log config.status rzip-2.1/acconfig.h0100644000113300011330000000002707737675012013604 0ustar tridgetridge#undef HAVE_ERRNO_DECL rzip-2.1/aclocal.m40100644000113300011330000000526707737675012013535 0ustar tridgetridge#serial 12 # This file is used by aclocal to generate aclocal.m4 dnl By default, many hosts won't let programs access large files; dnl one must use special compiler options to get large-file access to work. dnl For more details about this brain damage please see: dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html dnl Written by Paul Eggert . dnl Internal subroutine of AC_SYS_LARGEFILE. dnl AC_SYS_LARGEFILE_TEST_INCLUDES AC_DEFUN([AC_SYS_LARGEFILE_TEST_INCLUDES], [[#include int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; ]]) dnl Internal subroutine of AC_SYS_LARGEFILE. dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY) AC_DEFUN([AC_SYS_LARGEFILE_MACRO_VALUE], [AC_CACHE_CHECK([for $1 value needed for large files], $3, [$3=no AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES $5 , [$6], , [AC_TRY_COMPILE([#define $1 $2] AC_SYS_LARGEFILE_TEST_INCLUDES $5 , [$6], [$3=$2])])]) if test "[$]$3" != no; then AC_DEFINE_UNQUOTED([$1], [$]$3, [$4]) fi]) AC_DEFUN([AC_SYS_LARGEFILE], [AC_ARG_ENABLE(largefile, [ --disable-largefile omit support for large files]) if test "$enable_largefile" != no; then AC_CACHE_CHECK([for special C compiler options needed for large files], ac_cv_sys_largefile_CC, [ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , , [ac_save_CC="$CC" CC="$CC -n32" AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ac_cv_sys_largefile_CC=' -n32') CC="$ac_save_CC"]) fi]) if test "$ac_cv_sys_largefile_CC" != no; then CC="$CC$ac_cv_sys_largefile_CC" fi AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits, [Number of bits in a file offset, on hosts where this is settable.]) AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1, ac_cv_sys_largefile_source, [Define to make ftello visible on some hosts (e.g. HP-UX 10.20).], [#include ], [return !ftello;]) AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files, [Define for large files, on AIX-style hosts.]) AC_SYS_LARGEFILE_MACRO_VALUE(_XOPEN_SOURCE, 500, ac_cv_sys_xopen_source, [Define to make ftello visible on some hosts (e.g. glibc 2.1.3).], [#include ], [return !ftello;]) fi ]) rzip-2.1/bzipall0100755000113300011330000000006506546315154013242 0ustar tridgetridge#!/bin/sh for f in $*; do bzip2 < $f > $f.bz2 donerzip-2.1/config.h.in0100644000113300011330000000410307737675012013704 0ustar tridgetridge/* config.h.in. Generated automatically from configure.in by autoheader. */ /* Define as __inline if that's what the C compiler calls it. */ #undef inline /* Define to `long' if doesn't define. */ #undef off_t /* Define to `unsigned' if doesn't define. */ #undef size_t /* Define if you have the ANSI C header files. */ #undef STDC_HEADERS #undef HAVE_ERRNO_DECL /* The number of bytes in a int. */ #undef SIZEOF_INT /* The number of bytes in a long. */ #undef SIZEOF_LONG /* The number of bytes in a short. */ #undef SIZEOF_SHORT /* Define if you have the getopt_long function. */ #undef HAVE_GETOPT_LONG /* Define if you have the mmap function. */ #undef HAVE_MMAP /* Define if you have the strerror function. */ #undef HAVE_STRERROR /* Define if you have the header file. */ #undef HAVE_CTYPE_H /* Define if you have the header file. */ #undef HAVE_FCNTL_H /* Define if you have the header file. */ #undef HAVE_STDLIB_H /* Define if you have the header file. */ #undef HAVE_STRING_H /* Define if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define if you have the header file. */ #undef HAVE_SYS_PARAM_H /* Define if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define if you have the header file. */ #undef HAVE_SYS_UNISTD_H /* Define if you have the header file. */ #undef HAVE_SYS_WAIT_H /* Define if you have the header file. */ #undef HAVE_UNISTD_H /* Define if you have the bz2 library (-lbz2). */ #undef HAVE_LIBBZ2 /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS /* Define to make ftello visible on some hosts (e.g. HP-UX 10.20). */ #undef _LARGEFILE_SOURCE /* Define for large files, on AIX-style hosts. */ #undef _LARGE_FILES /* Define to make ftello visible on some hosts (e.g. glibc 2.1.3). */ #undef _XOPEN_SOURCE /* */ #undef HAVE_LARGE_FILES rzip-2.1/configure0100755000113300011330000020252207737675012013575 0ustar tridgetridge#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated automatically using autoconf version 2.13 # Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. # Defaults: ac_help= ac_default_prefix=/usr/local # Any additions from configure.in: ac_help="$ac_help --disable-largefile omit support for large files" # Initialize some variables set by options. # The variables have the same names as the options, with # dashes changed to underlines. build=NONE cache_file=./config.cache exec_prefix=NONE host=NONE no_create= nonopt=NONE no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= target=NONE verbose= x_includes=NONE x_libraries=NONE bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datadir='${prefix}/share' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' libdir='${exec_prefix}/lib' includedir='${prefix}/include' oldincludedir='/usr/include' infodir='${prefix}/info' mandir='${prefix}/man' # Initialize some other variables. subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Maximum number of lines to put in a shell here document. ac_max_here_lines=12 ac_prev= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval "$ac_prev=\$ac_option" ac_prev= continue fi case "$ac_option" in -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; *) ac_optarg= ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case "$ac_option" in -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir="$ac_optarg" ;; -build | --build | --buil | --bui | --bu) ac_prev=build ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build="$ac_optarg" ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file="$ac_optarg" ;; -datadir | --datadir | --datadi | --datad | --data | --dat | --da) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ | --da=*) datadir="$ac_optarg" ;; -disable-* | --disable-*) ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` eval "enable_${ac_feature}=no" ;; -enable-* | --enable-*) ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } fi ac_feature=`echo $ac_feature| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "enable_${ac_feature}='$ac_optarg'" ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix="$ac_optarg" ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he) # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat << EOF Usage: configure [options] [host] Options: [defaults in brackets after descriptions] Configuration: --cache-file=FILE cache test results in FILE --help print this message --no-create do not create output files --quiet, --silent do not print \`checking...' messages --version print the version of autoconf that created configure Directory and file names: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [same as prefix] --bindir=DIR user executables in DIR [EPREFIX/bin] --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] --libexecdir=DIR program executables in DIR [EPREFIX/libexec] --datadir=DIR read-only architecture-independent data in DIR [PREFIX/share] --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data in DIR [PREFIX/com] --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] --libdir=DIR object code libraries in DIR [EPREFIX/lib] --includedir=DIR C header files in DIR [PREFIX/include] --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] --infodir=DIR info documentation in DIR [PREFIX/info] --mandir=DIR man documentation in DIR [PREFIX/man] --srcdir=DIR find the sources in DIR [configure dir or ..] --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names EOF cat << EOF Host type: --build=BUILD configure for building on BUILD [BUILD=HOST] --host=HOST configure for HOST [guessed] --target=TARGET configure for TARGET [TARGET=HOST] Features and packages: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR EOF if test -n "$ac_help"; then echo "--enable and --with options recognized:$ac_help" fi exit 0 ;; -host | --host | --hos | --ho) ac_prev=host ;; -host=* | --host=* | --hos=* | --ho=*) host="$ac_optarg" ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir="$ac_optarg" ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir="$ac_optarg" ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir="$ac_optarg" ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir="$ac_optarg" ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst \ | --locals | --local | --loca | --loc | --lo) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* \ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) localstatedir="$ac_optarg" ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir="$ac_optarg" ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir="$ac_optarg" ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix="$ac_optarg" ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix="$ac_optarg" ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix="$ac_optarg" ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name="$ac_optarg" ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir="$ac_optarg" ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir="$ac_optarg" ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site="$ac_optarg" ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir="$ac_optarg" ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir="$ac_optarg" ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target="$ac_optarg" ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers) echo "configure generated by autoconf version 2.13" exit 0 ;; -with-* | --with-*) ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` case "$ac_option" in *=*) ;; *) ac_optarg=yes ;; esac eval "with_${ac_package}='$ac_optarg'" ;; -without-* | --without-*) ac_package=`echo $ac_option|sed -e 's/-*without-//'` # Reject names that are not valid shell variable names. if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } fi ac_package=`echo $ac_package| sed 's/-/_/g'` eval "with_${ac_package}=no" ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes="$ac_optarg" ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries="$ac_optarg" ;; -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } ;; *) if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then echo "configure: warning: $ac_option: invalid host type" 1>&2 fi if test "x$nonopt" != xNONE; then { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } fi nonopt="$ac_option" ;; esac done if test -n "$ac_prev"; then { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } fi trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 # File descriptor usage: # 0 standard input # 1 file creation # 2 errors and warnings # 3 some systems may open it to /dev/tty # 4 used on the Kubota Titan # 6 checking for... messages and results # 5 compiler messages saved in config.log if test "$silent" = yes; then exec 6>/dev/null else exec 6>&1 fi exec 5>./config.log echo "\ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. " 1>&5 # Strip out --no-create and --no-recursion so they do not pile up. # Also quote any args containing shell metacharacters. ac_configure_args= for ac_arg do case "$ac_arg" in -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c) ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) ac_configure_args="$ac_configure_args '$ac_arg'" ;; *) ac_configure_args="$ac_configure_args $ac_arg" ;; esac done # NLS nuisances. # Only set these to C if already set. These must not be set unconditionally # because not all systems understand e.g. LANG=C (notably SCO). # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! # Non-C LC_CTYPE values break the ctype check. if test "${LANG+set}" = set; then LANG=C; export LANG; fi if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -rf conftest* confdefs.h # AIX cpp loses on an empty file, so make sure it contains at least a newline. echo > confdefs.h # A filename unique to this package, relative to the directory that # configure is in, which we can look for to find out if srcdir is correct. ac_unique_file=main.c # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then its parent. ac_prog=$0 ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. srcdir=$ac_confdir if test ! -r $srcdir/$ac_unique_file; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r $srcdir/$ac_unique_file; then if test "$ac_srcdir_defaulted" = yes; then { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } else { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } fi fi srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` # Prefer explicitly selected file to automatically selected ones. if test -z "$CONFIG_SITE"; then if test "x$prefix" != xNONE; then CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" else CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" fi fi for ac_site_file in $CONFIG_SITE; do if test -r "$ac_site_file"; then echo "loading site script $ac_site_file" . "$ac_site_file" fi done if test -r "$cache_file"; then echo "loading cache $cache_file" . $cache_file else echo "creating cache $cache_file" > $cache_file fi ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross ac_exeext= ac_objext=o if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then ac_n= ac_c=' ' ac_t=' ' else ac_n=-n ac_c= ac_t= fi else ac_n= ac_c='\c' ac_t= fi # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:532: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="gcc" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:562: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_prog_rejected=no ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" break fi done IFS="$ac_save_ifs" if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# -gt 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift set dummy "$ac_dir/$ac_word" "$@" shift ac_cv_prog_CC="$@" fi fi fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi if test -z "$CC"; then case "`uname -s`" in *win32* | *WIN32*) # Extract the first word of "cl", so it can be a program name with args. set dummy cl; ac_word=$2 echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 echo "configure:613: checking for $ac_word" >&5 if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" ac_dummy="$PATH" for ac_dir in $ac_dummy; do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then ac_cv_prog_CC="cl" break fi done IFS="$ac_save_ifs" fi fi CC="$ac_cv_prog_CC" if test -n "$CC"; then echo "$ac_t""$CC" 1>&6 else echo "$ac_t""no" 1>&6 fi ;; esac fi test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6 echo "configure:645: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5 ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross cat > conftest.$ac_ext << EOF #line 656 "configure" #include "confdefs.h" main(){return(0);} EOF if { (eval echo configure:661: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then ac_cv_prog_cc_works=yes # If we can't run a trivial program, we are probably using a cross compiler. if (./conftest; exit) 2>/dev/null; then ac_cv_prog_cc_cross=no else ac_cv_prog_cc_cross=yes fi else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 ac_cv_prog_cc_works=no fi rm -fr conftest* ac_ext=c # CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. ac_cpp='$CPP $CPPFLAGS' ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' cross_compiling=$ac_cv_prog_cc_cross echo "$ac_t""$ac_cv_prog_cc_works" 1>&6 if test $ac_cv_prog_cc_works = no; then { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; } fi echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6 echo "configure:687: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5 echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6 cross_compiling=$ac_cv_prog_cc_cross echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 echo "configure:692: checking whether we are using GNU C" >&5 if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then ac_cv_prog_gcc=yes else ac_cv_prog_gcc=no fi fi echo "$ac_t""$ac_cv_prog_gcc" 1>&6 if test $ac_cv_prog_gcc = yes; then GCC=yes else GCC= fi ac_test_CFLAGS="${CFLAGS+set}" ac_save_CFLAGS="$CFLAGS" CFLAGS= echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 echo "configure:720: checking whether ${CC-cc} accepts -g" >&5 if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else echo 'void f(){}' > conftest.c if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then ac_cv_prog_cc_g=yes else ac_cv_prog_cc_g=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 if test "$ac_test_CFLAGS" = set; then CFLAGS="$ac_save_CFLAGS" elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi ac_aux_dir= for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do if test -f $ac_dir/install-sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f $ac_dir/install.sh; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break fi done if test -z "$ac_aux_dir"; then { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } fi ac_config_guess=$ac_aux_dir/config.guess ac_config_sub=$ac_aux_dir/config.sub ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # ./install, which can be erroneously created by make from ./install.sh. echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 echo "configure:782: checking for a BSD compatible install" >&5 if test -z "$INSTALL"; then if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" for ac_dir in $PATH; do # Account for people who put trailing slashes in PATH elements. case "$ac_dir/" in /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do if test -f $ac_dir/$ac_prog; then if test $ac_prog = install && grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : else ac_cv_path_install="$ac_dir/$ac_prog -c" break 2 fi fi done ;; esac done IFS="$ac_save_IFS" fi if test "${ac_cv_path_install+set}" = set; then INSTALL="$ac_cv_path_install" else # As a last resort, use the slow shell script. We don't cache a # path for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the path is relative. INSTALL="$ac_install_sh" fi fi echo "$ac_t""$INSTALL" 1>&6 # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' # Check whether --enable-largefile or --disable-largefile was given. if test "${enable_largefile+set}" = set; then enableval="$enable_largefile" : fi if test "$enable_largefile" != no; then echo $ac_n "checking for special C compiler options needed for large files""... $ac_c" 1>&6 echo "configure:844: checking for special C compiler options needed for large files" >&5 if eval "test \"`echo '$''{'ac_cv_sys_largefile_CC'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_sys_largefile_CC=no if test "$GCC" != yes; then # IRIX 6.2 and later do not support large files by default, # so use the C compiler's -n32 option if that helps. cat > conftest.$ac_ext < int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; int main() { ; return 0; } EOF if { (eval echo configure:862: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_save_CC="$CC" CC="$CC -n32" cat > conftest.$ac_ext < int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; int main() { ; return 0; } EOF if { (eval echo configure:880: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sys_largefile_CC=' -n32' else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* CC="$ac_save_CC" fi rm -f conftest* fi fi echo "$ac_t""$ac_cv_sys_largefile_CC" 1>&6 if test "$ac_cv_sys_largefile_CC" != no; then CC="$CC$ac_cv_sys_largefile_CC" fi echo $ac_n "checking for _FILE_OFFSET_BITS value needed for large files""... $ac_c" 1>&6 echo "configure:900: checking for _FILE_OFFSET_BITS value needed for large files" >&5 if eval "test \"`echo '$''{'ac_cv_sys_file_offset_bits'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_sys_file_offset_bits=no cat > conftest.$ac_ext < int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; int main() { ; return 0; } EOF if { (eval echo configure:917: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cat > conftest.$ac_ext < int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; int main() { ; return 0; } EOF if { (eval echo configure:936: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sys_file_offset_bits=64 else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* fi rm -f conftest* fi echo "$ac_t""$ac_cv_sys_file_offset_bits" 1>&6 if test "$ac_cv_sys_file_offset_bits" != no; then cat >> confdefs.h <&6 echo "configure:956: checking for _LARGEFILE_SOURCE value needed for large files" >&5 if eval "test \"`echo '$''{'ac_cv_sys_largefile_source'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_sys_largefile_source=no cat > conftest.$ac_ext < int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; #include int main() { return !ftello; ; return 0; } EOF if { (eval echo configure:973: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cat > conftest.$ac_ext < int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; #include int main() { return !ftello; ; return 0; } EOF if { (eval echo configure:992: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sys_largefile_source=1 else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* fi rm -f conftest* fi echo "$ac_t""$ac_cv_sys_largefile_source" 1>&6 if test "$ac_cv_sys_largefile_source" != no; then cat >> confdefs.h <&6 echo "configure:1012: checking for _LARGE_FILES value needed for large files" >&5 if eval "test \"`echo '$''{'ac_cv_sys_large_files'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_sys_large_files=no cat > conftest.$ac_ext < int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; int main() { ; return 0; } EOF if { (eval echo configure:1029: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cat > conftest.$ac_ext < int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; int main() { ; return 0; } EOF if { (eval echo configure:1048: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sys_large_files=1 else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* fi rm -f conftest* fi echo "$ac_t""$ac_cv_sys_large_files" 1>&6 if test "$ac_cv_sys_large_files" != no; then cat >> confdefs.h <&6 echo "configure:1068: checking for _XOPEN_SOURCE value needed for large files" >&5 if eval "test \"`echo '$''{'ac_cv_sys_xopen_source'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_sys_xopen_source=no cat > conftest.$ac_ext < int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; #include int main() { return !ftello; ; return 0; } EOF if { (eval echo configure:1085: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* cat > conftest.$ac_ext < int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1]; #include int main() { return !ftello; ; return 0; } EOF if { (eval echo configure:1104: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_sys_xopen_source=500 else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* fi rm -f conftest* fi echo "$ac_t""$ac_cv_sys_xopen_source" 1>&6 if test "$ac_cv_sys_xopen_source" != no; then cat >> confdefs.h <&6 echo "configure:1127: checking how to run the C preprocessor" >&5 # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else # This must be in double quotes, not single quotes, because CPP may get # substituted into the Makefile and "${CC-cc}" will confuse make. CPP="${CC-cc} -E" # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1148: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -E -traditional-cpp" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1165: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP="${CC-cc} -nologo -E" cat > conftest.$ac_ext < Syntax Error EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1182: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then : else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* CPP=/lib/cpp fi rm -f conftest* fi rm -f conftest* fi rm -f conftest* ac_cv_prog_CPP="$CPP" fi CPP="$ac_cv_prog_CPP" else ac_cv_prog_CPP="$CPP" fi echo "$ac_t""$CPP" 1>&6 for ac_hdr in fcntl.h sys/time.h sys/unistd.h unistd.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1210: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1220: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done for ac_hdr in sys/param.h ctype.h sys/wait.h sys/ioctl.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1250: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1260: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done for ac_hdr in string.h stdlib.h sys/types.h do ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 echo "configure:1290: checking for $ac_hdr" >&5 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1300: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* eval "ac_cv_header_$ac_safe=yes" else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_header_$ac_safe=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'` cat >> confdefs.h <&6 fi done echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6 echo "configure:1328: checking for ANSI C header files" >&5 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #include #include #include EOF ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" { (eval echo configure:1341: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` if test -z "$ac_err"; then rm -rf conftest* ac_cv_header_stdc=yes else echo "$ac_err" >&5 echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "memchr" >/dev/null 2>&1; then : else rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat > conftest.$ac_ext < EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "free" >/dev/null 2>&1; then : else rm -rf conftest* ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat > conftest.$ac_ext < #define ISLOWER(c) ('a' <= (c) && (c) <= 'z') #define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); exit (0); } EOF if { (eval echo configure:1408: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then : else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_header_stdc=no fi rm -fr conftest* fi fi fi echo "$ac_t""$ac_cv_header_stdc" 1>&6 if test $ac_cv_header_stdc = yes; then cat >> confdefs.h <<\EOF #define STDC_HEADERS 1 EOF fi echo $ac_n "checking for off_t""... $ac_c" 1>&6 echo "configure:1432: checking for off_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS #include #include #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "(^|[^a-zA-Z_0-9])off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then rm -rf conftest* ac_cv_type_off_t=yes else rm -rf conftest* ac_cv_type_off_t=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_type_off_t" 1>&6 if test $ac_cv_type_off_t = no; then cat >> confdefs.h <<\EOF #define off_t long EOF fi echo $ac_n "checking for size_t""... $ac_c" 1>&6 echo "configure:1465: checking for size_t" >&5 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < #if STDC_HEADERS #include #include #endif EOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then rm -rf conftest* ac_cv_type_size_t=yes else rm -rf conftest* ac_cv_type_size_t=no fi rm -f conftest* fi echo "$ac_t""$ac_cv_type_size_t" 1>&6 if test $ac_cv_type_size_t = no; then cat >> confdefs.h <<\EOF #define size_t unsigned EOF fi echo $ac_n "checking size of int""... $ac_c" 1>&6 echo "configure:1499: checking size of int" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < int main() { FILE *f=fopen("conftestval", "w"); if (!f) return(1); fprintf(f, "%d\n", sizeof(int)); return(0); } EOF if { (eval echo configure:1518: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_int=`cat conftestval` else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_sizeof_int=0 fi rm -fr conftest* fi fi echo "$ac_t""$ac_cv_sizeof_int" 1>&6 cat >> confdefs.h <&6 echo "configure:1538: checking size of long" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < int main() { FILE *f=fopen("conftestval", "w"); if (!f) return(1); fprintf(f, "%d\n", sizeof(long)); return(0); } EOF if { (eval echo configure:1557: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_long=`cat conftestval` else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_sizeof_long=0 fi rm -fr conftest* fi fi echo "$ac_t""$ac_cv_sizeof_long" 1>&6 cat >> confdefs.h <&6 echo "configure:1577: checking size of short" >&5 if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then { echo "configure: error: can not run test program while cross compiling" 1>&2; exit 1; } else cat > conftest.$ac_ext < int main() { FILE *f=fopen("conftestval", "w"); if (!f) return(1); fprintf(f, "%d\n", sizeof(short)); return(0); } EOF if { (eval echo configure:1596: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then ac_cv_sizeof_short=`cat conftestval` else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* ac_cv_sizeof_short=0 fi rm -fr conftest* fi fi echo "$ac_t""$ac_cv_sizeof_short" 1>&6 cat >> confdefs.h <&6 echo "configure:1617: checking for large file support" >&5 if eval "test \"`echo '$''{'rzip_cv_HAVE_LARGE_FILES'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else if test "$cross_compiling" = yes; then rzip_cv_HAVE_LARGE_FILES=cross else cat > conftest.$ac_ext < #include main() { return (sizeof(off_t) == 4); } EOF if { (eval echo configure:1633: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null then rzip_cv_HAVE_LARGE_FILES=yes else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -fr conftest* rzip_cv_HAVE_LARGE_FILES=no fi rm -fr conftest* fi fi echo "$ac_t""$rzip_cv_HAVE_LARGE_FILES" 1>&6 if test x"$rzip_cv_HAVE_LARGE_FILES" = x"yes"; then cat >> confdefs.h <<\EOF #define HAVE_LARGE_FILES 1 EOF fi echo $ac_n "checking for inline""... $ac_c" 1>&6 echo "configure:1657: checking for inline" >&5 if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat > conftest.$ac_ext <&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* ac_cv_c_inline=$ac_kw; break else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 fi rm -f conftest* done fi echo "$ac_t""$ac_cv_c_inline" 1>&6 case "$ac_cv_c_inline" in inline | yes) ;; no) cat >> confdefs.h <<\EOF #define inline EOF ;; *) cat >> confdefs.h <&6 echo "configure:1699: checking for BZ2_bzBuffToBuffCompress in -lbz2" >&5 ac_lib_var=`echo bz2'_'BZ2_bzBuffToBuffCompress | sed 'y%./+-%__p_%'` if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else ac_save_LIBS="$LIBS" LIBS="-lbz2 $LIBS" cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_lib_$ac_lib_var=no" fi rm -f conftest* LIBS="$ac_save_LIBS" fi if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_lib=HAVE_LIB`echo bz2 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` cat >> confdefs.h <&6 { echo "configure: error: Could not find bz2 library - please install libbz2-devel" 1>&2; exit 1; } fi echo $ac_n "checking for errno in errno.h... $ac_c" cat > conftest.$ac_ext < int main() { int i = errno ; return 0; } EOF if { (eval echo configure:1756: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then rm -rf conftest* echo yes; cat >> confdefs.h <<\EOF #define HAVE_ERRNO_DECL 1 EOF else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* echo no fi rm -f conftest* for ac_func in mmap strerror do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1773: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1801: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done for ac_func in getopt_long do echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 echo "configure:1828: checking for $ac_func" >&5 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then echo $ac_n "(cached) $ac_c" 1>&6 else cat > conftest.$ac_ext < /* Override any gcc2 internal prototype to avoid an error. */ /* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $ac_func(); int main() { /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined (__stub_$ac_func) || defined (__stub___$ac_func) choke me #else $ac_func(); #endif ; return 0; } EOF if { (eval echo configure:1856: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then rm -rf conftest* eval "ac_cv_func_$ac_func=yes" else echo "configure: failed program was:" >&5 cat conftest.$ac_ext >&5 rm -rf conftest* eval "ac_cv_func_$ac_func=no" fi rm -f conftest* fi if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then echo "$ac_t""yes" 1>&6 ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'` cat >> confdefs.h <&6 fi done trap '' 1 2 15 cat > confcache <<\EOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs. It is not useful on other systems. # If it contains results you don't want to keep, you may remove or edit it. # # By default, configure uses ./config.cache as the cache file, # creating it if it does not exist already. You can give configure # the --cache-file=FILE option to use a different cache file; that is # what configure does when it calls configure scripts in # subdirectories, so they share the cache. # Giving --cache-file=/dev/null disables caching, for debugging configure. # config.status only pays attention to the cache file if you give it the # --recheck option to rerun configure. # EOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, don't put newlines in cache variables' values. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. (set) 2>&1 | case `(ac_space=' '; set | grep ac_space) 2>&1` in *ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote substitution # turns \\\\ into \\, and sed turns \\ into \). sed -n \ -e "s/'/'\\\\''/g" \ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" ;; *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' ;; esac >> confcache if cmp -s $cache_file confcache; then : else if test -w $cache_file; then echo "updating cache $cache_file" cat confcache > $cache_file else echo "not updating unwritable cache $cache_file" fi fi rm -f confcache trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' # Any assignment to VPATH causes Sun make to only execute # the first set of double-colon rules, so remove it if not needed. # If there is a colon in the path, we need to keep it. if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' fi trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 DEFS=-DHAVE_CONFIG_H # Without the "./", some shells look in PATH for config.status. : ${CONFIG_STATUS=./config.status} echo creating $CONFIG_STATUS rm -f $CONFIG_STATUS cat > $CONFIG_STATUS </dev/null | sed 1q`: # # $0 $ac_configure_args # # Compiler output produced by configure, useful for debugging # configure, is in ./config.log if it exists. ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" for ac_option do case "\$ac_option" in -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; -version | --version | --versio | --versi | --vers | --ver | --ve | --v) echo "$CONFIG_STATUS generated by autoconf version 2.13" exit 0 ;; -help | --help | --hel | --he | --h) echo "\$ac_cs_usage"; exit 0 ;; *) echo "\$ac_cs_usage"; exit 1 ;; esac done ac_given_srcdir=$srcdir ac_given_INSTALL="$INSTALL" trap 'rm -fr `echo "Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 EOF cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF $ac_vpsub $extrasub s%@SHELL@%$SHELL%g s%@CFLAGS@%$CFLAGS%g s%@CPPFLAGS@%$CPPFLAGS%g s%@CXXFLAGS@%$CXXFLAGS%g s%@FFLAGS@%$FFLAGS%g s%@DEFS@%$DEFS%g s%@LDFLAGS@%$LDFLAGS%g s%@LIBS@%$LIBS%g s%@exec_prefix@%$exec_prefix%g s%@prefix@%$prefix%g s%@program_transform_name@%$program_transform_name%g s%@bindir@%$bindir%g s%@sbindir@%$sbindir%g s%@libexecdir@%$libexecdir%g s%@datadir@%$datadir%g s%@sysconfdir@%$sysconfdir%g s%@sharedstatedir@%$sharedstatedir%g s%@localstatedir@%$localstatedir%g s%@libdir@%$libdir%g s%@includedir@%$includedir%g s%@oldincludedir@%$oldincludedir%g s%@infodir@%$infodir%g s%@mandir@%$mandir%g s%@CC@%$CC%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g s%@CPP@%$CPP%g CEOF EOF cat >> $CONFIG_STATUS <<\EOF # Split the substitutions into bite-sized pieces for seds with # small command number limits, like on Digital OSF/1 and HP-UX. ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. ac_file=1 # Number of current file. ac_beg=1 # First line for current file. ac_end=$ac_max_sed_cmds # Line after last line for current file. ac_more_lines=: ac_sed_cmds="" while $ac_more_lines; do if test $ac_beg -gt 1; then sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file else sed "${ac_end}q" conftest.subs > conftest.s$ac_file fi if test ! -s conftest.s$ac_file; then ac_more_lines=false rm -f conftest.s$ac_file else if test -z "$ac_sed_cmds"; then ac_sed_cmds="sed -f conftest.s$ac_file" else ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" fi ac_file=`expr $ac_file + 1` ac_beg=$ac_end ac_end=`expr $ac_end + $ac_max_sed_cmds` fi done if test -z "$ac_sed_cmds"; then ac_sed_cmds=cat fi EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" # A "../" for each directory in $ac_dir_suffix. ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` else ac_dir_suffix= ac_dots= fi case "$ac_given_srcdir" in .) srcdir=. if test -z "$ac_dots"; then top_srcdir=. else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; *) # Relative path. srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" top_srcdir="$ac_dots$ac_given_srcdir" ;; esac case "$ac_given_INSTALL" in [/$]*) INSTALL="$ac_given_INSTALL" ;; *) INSTALL="$ac_dots$ac_given_INSTALL" ;; esac echo creating "$ac_file" rm -f "$ac_file" configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." case "$ac_file" in *Makefile*) ac_comsub="1i\\ # $configure_input" ;; *) ac_comsub= ;; esac ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` sed -e "$ac_comsub s%@configure_input@%$configure_input%g s%@srcdir@%$srcdir%g s%@top_srcdir@%$top_srcdir%g s%@INSTALL@%$INSTALL%g " $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file fi; done rm -f conftest.s* # These sed commands are passed to sed as "A NAME B NAME C VALUE D", where # NAME is the cpp macro being defined and VALUE is the value it is being given. # # ac_d sets the value in "#define NAME VALUE" lines. ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)' ac_dB='\([ ][ ]*\)[^ ]*%\1#\2' ac_dC='\3' ac_dD='%g' # ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE". ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_uB='\([ ]\)%\1#\2define\3' ac_uC=' ' ac_uD='\4%g' # ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE". ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)' ac_eB='$%\1#\2define\3' ac_eC=' ' ac_eD='%g' if test "${CONFIG_HEADERS+set}" != set; then EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF fi for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". case "$ac_file" in *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; *) ac_file_in="${ac_file}.in" ;; esac echo creating $ac_file rm -f conftest.frag conftest.in conftest.out ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` cat $ac_file_inputs > conftest.in EOF # Transform confdefs.h into a sed script conftest.vals that substitutes # the proper values into config.h.in to produce config.h. And first: # Protect against being on the right side of a sed subst in config.status. # Protect against being in an unquoted here document in config.status. rm -f conftest.vals cat > conftest.hdr <<\EOF s/[\\&%]/\\&/g s%[\\$`]%\\&%g s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp s%ac_d%ac_u%gp s%ac_u%ac_e%gp EOF sed -n -f conftest.hdr confdefs.h > conftest.vals rm -f conftest.hdr # This sed command replaces #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. cat >> conftest.vals <<\EOF s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */% EOF # Break up conftest.vals because some shells have a limit on # the size of here documents, and old seds have small limits too. rm -f conftest.tail while : do ac_lines=`grep -c . conftest.vals` # grep -c gives empty output for an empty file on some AIX systems. if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi # Write a limited-size here document to conftest.frag. echo ' cat > conftest.frag <> $CONFIG_STATUS sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS echo 'CEOF sed -f conftest.frag conftest.in > conftest.out rm -f conftest.in mv conftest.out conftest.in ' >> $CONFIG_STATUS sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail rm -f conftest.vals mv conftest.tail conftest.vals done rm -f conftest.vals cat >> $CONFIG_STATUS <<\EOF rm -f conftest.frag conftest.h echo "/* $ac_file. Generated automatically by configure. */" > conftest.h cat conftest.in >> conftest.h rm -f conftest.in if cmp -s $ac_file conftest.h 2>/dev/null; then echo "$ac_file is unchanged" rm -f conftest.h else # Remove last slash and all that follows it. Not all systems have dirname. ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then # The file is in a subdirectory. test ! -d "$ac_dir" && mkdir "$ac_dir" fi rm -f $ac_file mv conftest.h $ac_file fi fi; done EOF cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF exit 0 EOF chmod +x $CONFIG_STATUS rm -fr confdefs* $ac_clean_files test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 rzip-2.1/configure.in0100644000113300011330000000245607751407577014210 0ustar tridgetridgednl Process this file with autoconf to produce a configure script. AC_INIT(main.c) AC_CONFIG_HEADER(config.h) dnl Checks for programs. AC_PROG_CC AC_PROG_INSTALL AC_SUBST(SHELL) AC_SYS_LARGEFILE # Thanks to Martin Pool if test x"$GCC" = xyes then CFLAGS="-g -Wall -O3" AC_MSG_NOTICE([Setting gcc options: $CFLAGS]) fi AC_CHECK_HEADERS(fcntl.h sys/time.h sys/unistd.h unistd.h) AC_CHECK_HEADERS(sys/param.h ctype.h sys/wait.h sys/ioctl.h) AC_CHECK_HEADERS(string.h stdlib.h sys/types.h) AC_TYPE_OFF_T AC_TYPE_SIZE_T AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(short) AC_CACHE_CHECK([for large file support],rzip_cv_HAVE_LARGE_FILES,[ AC_TRY_RUN([ #include #include main() { return (sizeof(off_t) == 4); }], rzip_cv_HAVE_LARGE_FILES=yes, rzip_cv_HAVE_LARGE_FILES=no, rzip_cv_HAVE_LARGE_FILES=cross)]) if test x"$rzip_cv_HAVE_LARGE_FILES" = x"yes"; then AC_DEFINE(HAVE_LARGE_FILES, 1, [ ]) fi AC_C_INLINE AC_CHECK_LIB(bz2, BZ2_bzBuffToBuffCompress, , AC_MSG_ERROR([Could not find bz2 library - please install libbz2-devel])) echo $ac_n "checking for errno in errno.h... $ac_c" AC_TRY_COMPILE([#include ],[int i = errno], echo yes; AC_DEFINE(HAVE_ERRNO_DECL), echo no) AC_CHECK_FUNCS(mmap strerror) AC_CHECK_FUNCS(getopt_long) AC_OUTPUT(Makefile) rzip-2.1/crc32.c0100644000113300011330000001025607737435552012752 0ustar tridgetridge/* Unix SMB/CIFS implementation. crc32 implementation Copyright (C) Andrew Tridgell 2003 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "rzip.h" /* table generated using algorithm from Mark Adler */ static const uint32 crc_table[] = { 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; /* see PNG specification or ISO-3309 for details */ uint32 crc32_buffer(const uchar *buf, int n, uint32 crc) { int i; for (i=0;i> 8); } return crc; } rzip-2.1/gzipall0100755000113300011330000000006606546315154013250 0ustar tridgetridge#!/bin/sh for f in $*; do gzip -9 < $f > $f.gz donerzip-2.1/install-sh0100755000113300011330000001124506536253601013662 0ustar tridgetridge#! /bin/sh # # install - install a program, script, or datafile # This comes from X11R5. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. # # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 rzip-2.1/magic0100644000113300011330000000064507737301531012663 0ustar tridgetridge# Magic local data for file(1) command. # Insert here your local magic data. Format is described in magic(5). # Supplementary magic data for the file(1) command to support # rzip(1). The format is described in magic(5). # # Copyright (C) 2003 by Andrew Tridgell. You may do whatever you want with # this file. # 0 string RZIP rzip compressed data >4 byte x - version %d >5 byte x \b.%d >6 belong x (%d bytes) rzip-2.1/main.c0100664000113300011330000002025410374223177012750 0ustar tridgetridge/* Copyright (C) Andrew Tridgell 1998-2003 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* rzip compression - main program */ #include "rzip.h" static void usage(void) { printf("rzip %d.%d\n", RZIP_MAJOR_VERSION, RZIP_MINOR_VERSION); printf("Copright (C) Andrew Tridgell 1998-2003\n\n"); printf("usage: rzip [options] \n"); printf(" Options:\n"); printf(" -0 fastest (worst) compression\n"); printf(" -6 default compression level\n"); printf(" -9 slowest (best) compression\n"); printf(" -d decompress\n"); printf(" -o filename specify the output file name\n"); printf(" -S suffix specify compressed suffix (default '.rz')\n"); printf(" -f force overwrite of any existing files\n"); printf(" -k keep existing files\n"); printf(" -P show compression progress\n"); printf(" -L level set compression level\n"); printf(" -V show version\n"); #if 0 /* damn, this will be quite hard to do */ printf(" -t test compressed file integrity\n"); #endif printf("\nnote that rzip cannot operate on stdin/stdout\n"); } static void write_magic(int fd_in, int fd_out) { struct stat st; char magic[24]; uint32_t v; memset(magic, 0, sizeof(magic)); strcpy(magic, "RZIP"); magic[4] = RZIP_MAJOR_VERSION; magic[5] = RZIP_MINOR_VERSION; if (fstat(fd_in, &st) != 0) { fatal("bad magic file descriptor!?\n"); } #if HAVE_LARGE_FILES v = htonl(st.st_size & 0xFFFFFFFF); memcpy(&magic[6], &v, 4); v = htonl(st.st_size >> 32); memcpy(&magic[10], &v, 4); #else v = htonl(st.st_size); memcpy(&magic[6], &v, 4); #endif if (write(fd_out, magic, sizeof(magic)) != sizeof(magic)) { fatal("Failed to write magic header\n"); } } static void read_magic(int fd_in, int fd_out, off_t *expected_size) { uint32_t v; char magic[24]; if (read(fd_in, magic, sizeof(magic)) != sizeof(magic)) { fatal("Failed to read magic header\n"); } *expected_size = 0; if (strncmp(magic, "RZIP", 4) != 0) { fatal("Not an rzip file\n"); } #if HAVE_LARGE_FILES memcpy(&v, &magic[6], 4); *expected_size = ntohl(v); memcpy(&v, &magic[10], 4); *expected_size |= ((off_t)ntohl(v)) << 32; #else memcpy(&v, &magic[6], 4); *expected_size = ntohl(v); #endif } /* preserve ownership and permissions where possible */ static void preserve_perms(struct rzip_control *control, int fd_in, int fd_out) { struct stat st; if (fstat(fd_in, &st) != 0) { fatal("Failed to fstat input file\n"); } if (fchmod(fd_out, (st.st_mode & 0777)) != 0) { fatal("Failed to set permissions on %s\n", control->outfile); } /* chown fail is not fatal */ fchown(fd_out, st.st_uid, st.st_gid); } /* decompress one file from the command line */ static void decompress_file(struct rzip_control *control) { int fd_in, fd_out = -1, fd_hist = -1; off_t expected_size; if (control->outname) { control->outfile = strdup(control->outname); } else { if (strlen(control->suffix) >= strlen(control->infile) || strcmp(control->suffix, control->infile + strlen(control->infile) - strlen(control->suffix)) != 0) { fatal("%s: unknown suffix\n", control->infile); } control->outfile = strdup(control->infile); control->outfile[strlen(control->infile) - strlen(control->suffix)] = 0; } fd_in = open(control->infile,O_RDONLY); if (fd_in == -1) { fatal("Failed to open %s: %s\n", control->infile, strerror(errno)); } if ((control->flags & FLAG_TEST_ONLY) == 0) { if (control->flags & FLAG_FORCE_REPLACE) { fd_out = open(control->outfile,O_WRONLY|O_CREAT|O_TRUNC,0666); } else { fd_out = open(control->outfile,O_WRONLY|O_CREAT|O_EXCL,0666); } if (fd_out == -1) { fatal("Failed to create %s: %s\n", control->outfile, strerror(errno)); } preserve_perms(control, fd_in, fd_out); fd_hist = open(control->outfile,O_RDONLY); if (fd_hist == -1) { fatal("Failed to open history file %s\n", control->outfile); } } read_magic(fd_in, fd_out, &expected_size); runzip_fd(fd_in, fd_out, fd_hist, expected_size); if ((control->flags & FLAG_TEST_ONLY) == 0) { if (close(fd_hist) != 0 || close(fd_out) != 0) { fatal("Failed to close files\n"); } } close(fd_in); if ((control->flags & (FLAG_KEEP_FILES | FLAG_TEST_ONLY)) == 0) { if (unlink(control->infile) != 0) { fatal("Failed to unlink %s: %s\n", control->infile, strerror(errno)); } } free(control->outfile); } /* compress one file from the command line */ static void compress_file(struct rzip_control *control) { int fd_in, fd_out; if (strlen(control->suffix) <= strlen(control->infile) && strcmp(control->suffix, control->infile + strlen(control->infile) - strlen(control->suffix)) == 0) { printf("%s: already has %s suffix\n", control->infile, control->suffix); return; } if (control->outname) { control->outfile = strdup(control->outname); } else { control->outfile = malloc(strlen(control->infile) + strlen(control->suffix) + 1); if (!control->outfile) { fatal("Failed to allocate outfile name\n"); } strcpy(control->outfile, control->infile); strcat(control->outfile, control->suffix); } fd_in = open(control->infile,O_RDONLY); if (fd_in == -1) { fatal("Failed to open %s: %s\n", control->infile, strerror(errno)); } if (control->flags & FLAG_FORCE_REPLACE) { fd_out = open(control->outfile,O_WRONLY|O_CREAT|O_TRUNC,0666); } else { fd_out = open(control->outfile,O_WRONLY|O_CREAT|O_EXCL,0666); } if (fd_out == -1) { fatal("Failed to create %s: %s\n", control->outfile, strerror(errno)); } preserve_perms(control, fd_in, fd_out); write_magic(fd_in, fd_out); rzip_fd(control, fd_in, fd_out); if (close(fd_in) != 0 || close(fd_out) != 0) { fatal("Failed to close files\n"); } if ((control->flags & FLAG_KEEP_FILES) == 0) { if (unlink(control->infile) != 0) { fatal("Failed to unlink %s: %s\n", control->infile, strerror(errno)); } } free(control->outfile); } int main(int argc, char *argv[]) { extern int optind; int c, i; struct rzip_control control; memset(&control, 0, sizeof(control)); control.compression_level = 6; control.flags = 0; control.suffix = ".rz"; if (strstr(argv[0], "runzip")) { control.flags |= FLAG_DECOMPRESS; } while ((c = getopt(argc, argv, "h0123456789dS:tVvkfPo:L:")) != -1) { if (isdigit(c)) { control.compression_level = c - '0'; continue; } switch (c) { case 'L': control.compression_level = atoi(optarg); break; case 'd': control.flags |= FLAG_DECOMPRESS; break; case 'S': control.suffix = optarg; break; case 'o': control.outname = optarg; break; case 't': fatal("integrity checking currently not implemented\n"); control.flags |= FLAG_TEST_ONLY; break; case 'f': control.flags |= FLAG_FORCE_REPLACE; break; case 'k': control.flags |= FLAG_KEEP_FILES; break; case 'v': control.verbosity++; break; case 'P': control.flags |= FLAG_SHOW_PROGRESS; break; case 'V': printf("rzip version %d.%d\n", RZIP_MAJOR_VERSION, RZIP_MINOR_VERSION); exit(0); break; default: case 'h': usage(); return -1; } } argc -= optind; argv += optind; if (control.outname && argc > 1) { fatal("Cannot specify output filename with more than 1 file\n"); } if (argc < 1) { usage(); exit(1); } for (i=0;i #include #include #include #if RAND_MAX < (1 << 16) #error Code assumes at least two bytes of randomness #endif /* Padding is because current algo doesn't quite go to end of file. */ #define END_PADDING 1024 static void randomize(uint16_t *data, unsigned int datasize) { unsigned int i; for (i = 0; i < datasize; i++) data[i] = random(); } static int write_random(int fd, unsigned int len) { uint16_t data[512]; unsigned int done, amount; for (done = 0; done < len; done += amount) { randomize(data, sizeof(data)/2); amount = len - done; if (amount > sizeof(data)) amount = sizeof(data); if (write(fd, data, amount) != amount) { perror("write"); return 0; } } return 1; } int main(int argc, char *argv[]) { unsigned int i, size, repsize; uint16_t *repeat; if (argc != 4) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(1); } /* Layout is [random][repeat][padding] [random][repeat][padding]... */ size = atol(argv[1]) * 1024 * 1024 / (atol(argv[3]) + 1); repsize = atoi(argv[2]); size -= repsize + END_PADDING; repeat = malloc(repsize + 2); randomize(repeat, repsize/2 + 1); for (i = 0; i <= atol(argv[3]); i++) { if (!write_random(STDOUT_FILENO, size)) return 1; if (write(STDOUT_FILENO, repeat, repsize) != repsize) { perror("write"); return 1; } if (!write_random(STDOUT_FILENO, END_PADDING)) return 1; } free(repeat); return 0; } rzip-2.1/ratios0100755000113300011330000000045007737301473013106 0ustar tridgetridge#!/bin/sh echo " bz2 rz gz" for f in $*; do s1=`filesize $f` s2=`filesize $f.bz2` s3=`filesize $f.rz` s4=`filesize $f.gz` echo $s1" "$s2" "$s3" "$s4" "$f | awk '{printf "%5.2f %5.2f %5.2f %s\n", $2/$2, $2/$3, $2/$4, $5}' donerzip-2.1/runzip.c0100644000113300011330000001006307740634534013354 0ustar tridgetridge/* Copyright (C) Andrew Tridgell 1998-2003 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* rzip decompression algorithm */ #include "rzip.h" static inline uchar read_u8(void *ss, int stream) { uchar b; if (read_stream(ss, stream, &b, 1) != 1) { fatal("Stream read failed\n"); } return b; } static inline unsigned read_u16(void *ss, int stream) { unsigned ret; ret = read_u8(ss, stream); ret |= read_u8(ss, stream)<<8; return ret; } static inline unsigned read_u32(void *ss, int stream) { unsigned ret; ret = read_u8(ss, stream); ret |= read_u8(ss, stream)<<8; ret |= read_u8(ss, stream)<<16; ret |= read_u8(ss, stream)<<24; return ret; } static inline unsigned read_u24(void *ss, int stream) { unsigned ret; ret = read_u8(ss, stream); ret |= read_u8(ss, stream)<<8; ret |= read_u8(ss, stream)<<16; return ret; } static int read_header(void *ss, uchar *head) { *head = read_u8(ss, 0); return read_u16(ss, 0); } static int unzip_literal(void *ss, int len, int fd_out, uint32 *cksum) { uchar *buf; buf = malloc(len); if (!buf) { fatal("Failed to allocate literal buffer of size %d\n", len); } read_stream(ss, 1, buf, len); if (write(fd_out, buf, len) != len) { fatal("Failed to write literal buffer of size %d\n", len); } *cksum = crc32_buffer(buf, len, *cksum); free(buf); return len; } static int unzip_match(void *ss, int len, int fd_out, int fd_hist, uint32 *cksum) { unsigned offset; int n, total=0; off_t cur_pos = lseek(fd_out, 0, SEEK_CUR); offset = read_u32(ss, 0); if (lseek(fd_hist, cur_pos-offset, SEEK_SET) == (off_t)-1) { fatal("Seek failed by %d from %d on history file in unzip_match - %s\n", offset, cur_pos, strerror(errno)); } while (len) { uchar *buf; n = MIN(len, offset); buf = malloc(n); if (!buf) { fatal("Failed to allocate %d bytes in unzip_match\n", n); } if (read(fd_hist, buf, n) != n) { fatal("Failed to read %d bytes in unzip_match\n", n); } if (write(fd_out, buf, n) != n) { fatal("Failed to write %d bytes in unzip_match\n", n); } *cksum = crc32_buffer(buf, n, *cksum); len -= n; free(buf); total += n; } return total; } /* decompress a section of an open file. Call fatal() on error return the number of bytes that have been retrieved */ static int runzip_chunk(int fd_in, int fd_out, int fd_hist) { uchar head; int len; struct stat st; void *ss; off_t ofs; int total = 0; uint32 good_cksum, cksum = 0; ofs = lseek(fd_in, 0, SEEK_CUR); if (ofs == (off_t)-1) { fatal("Failed to seek input file in runzip_fd\n"); } if (fstat(fd_in, &st) != 0 || st.st_size-ofs == 0) { return 0; } ss = open_stream_in(fd_in, NUM_STREAMS); if (!ss) { fatal(NULL); } while ((len = read_header(ss, &head)) || head) { switch (head) { case 0: total += unzip_literal(ss, len, fd_out, &cksum); break; default: total += unzip_match(ss, len, fd_out, fd_hist, &cksum); break; } } good_cksum = read_u32(ss, 0); if (good_cksum != cksum) { fatal("Bad checksum 0x%08x - expected 0x%08x\n", cksum, good_cksum); } if (close_stream_in(ss) != 0) { fatal("Failed to close stream!\n"); } return total; } /* decompress a open file. Call fatal() on error return the number of bytes that have been retrieved */ off_t runzip_fd(int fd_in, int fd_out, int fd_hist, off_t expected_size) { off_t total = 0; while (total < expected_size) { total += runzip_chunk(fd_in, fd_out, fd_hist); } return total; } rzip-2.1/rzip.10100664000113300011330000001111510374223177012722 0ustar tridgetridge.TH "rzip" "1" "October 2003" "" "" .SH "NAME" rzip \- a large-file compression program .SH "SYNOPSIS" .PP rzip [OPTIONS] .PP .SH "DESCRIPTION" .PP rzip is a file compression program designed to do particularly well on very large files containing long distance redundency\&. .PP .SH "OPTIONS SUMMARY" .PP Here is a summary of the options to rzip\&. .nf -0 fastest (worst) compression -6 default compression -9 slowest (best) compression -d decompress -o filename specify the output file name -S suffix specify compressed suffix (default \&'\&.rz\&') -f force overwrite of any existing files -k keep existing files -P show compression progress -V show version .fi .PP .SH "OPTIONS" .PP .IP "\fB-h\fP" Print an options summary page .IP .IP "\fB-V\fP" Print the rzip version number .IP .IP "\fB-0\&.\&.9\fP" Set the compression level from 0 to 9\&. The default is to use level 6, which is a reasonable compromise between speed and compression\&. The compression level is also strongly related to how much memory rzip uses, so if you are running rzip on a machine with limited amounts of memory then you will probably want to choose a smaller level\&. .IP .IP "\fB-d\fP" Decompress\&. If this option is not used then rzip looks at the name used to launch the program\&. If it contains the string \&'runzip\&' then the -d option is automatically set\&. .IP .IP "\fB-o\fP" Set the output file name\&. If this option is not set then the output file name is chosen based on the input name and the suffix\&. The -o option cannot be used if more than one file name is specified on the command line\&. .IP .IP "\fB-S\fP" Set the compression suffix\&. The default is \&'\&.rz\&'\&. .IP .IP "\fB-f\fP" If this option is not specified then rzip will not overwrite any existing files\&. If you set this option then rzip will silently overwrite any files as needed\&. .IP .IP "\fB-k\fP" If this option is not specified then rzip will delete the source file after successful compression or decompression\&. When this option is specified then the source files are not deleted\&. .IP .IP "\fB-P\fP" If this option is specified then rzip will show the percentage progress while compressing\&. .IP .PP .SH "INSTALLATION" .PP Just install rzip in your search path\&. .PP .SH "COMPRESSION ALGORITHM" .PP rzip operates in two stages\&. The first stage finds and encodes large chunks of duplicated data over potentially very long distances (up to nearly a gigabyte) in the input file\&. The second stage is to use a standard compression algorithm (bzip2) to compress the output of the first stage\&. .PP The key difference between rzip and other well known compression algorithms is its ability to take advantage of very long distance redundency\&. The well known deflate algorithm used in gzip uses a maximum history buffer of 32k\&. The block sorting algorithm used in bzip2 is limited to 900k of history\&. The history buffer in rzip can be up to 900MB long, several orders of magnitude larger than gzip or bzip2\&. .PP It is quite common these days to need to compress files that contain long distance redundancies\&. For example, when compressing a set of home directories several users might have copies of the same file, or of quite similar files\&. It is also common to have a single file that contains large duplicated chunks over long distances, such as pdf files containing repeated copies of the same image\&. Most compression programs won\&'t be able to take advantage of this redundency, and thus might achieve a much lower compression ratio than rzip can achieve\&. .PP .SH "HISTORY" .PP The ideas behind rzip were first implemented in 1998 while I was working on rsync\&. That version was too slow to be practical, and was replaced by this version in 2003\&. .PP .SH "BUGS" .PP Unlike most Unix compression programs, rzip cannot compress or decompress to or from standard input or standard output\&. This is due to the nature of the algorithm that rzip uses and cannot easily be fixed\&. .PP .SH "CREDITS" .PP Thanks to the following people for their contributions to rzip .IP o Paul Russell for many suggestions and the debian packaging .IP o The authors of bzlib for an excellent library .PP .SH "AUTHOR" .PP rzip was written by Andrew Tridgell http://samba\&.org/~tridge/ .PP If you wish to report a problem or make a suggestion then please email bugs-rzip@tridgell\&.net .PP rzip is released under the GNU General Public License version 2 or later\&. Please see the file COPYING for license details\&. rzip-2.1/rzip.c0100664000113300011330000003502510374223177013012 0ustar tridgetridge/* Copyright (C) Andrew Tridgell 1998 Modified to use flat hash, memory limit and variable hash culling by Rusty Russell copyright (C) 2003. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* rzip compression algorithm */ #include "rzip.h" #define CHUNK_MULTIPLE 100*1024*1024 #define CKSUM_CHUNK 1024*1024 #define GREAT_MATCH 1024 #define MINIMUM_MATCH 31 /* Hash table works as follows. We start by throwing tags at every * offset into the table. As it fills, we start eliminating tags * which don't have lower bits set to one (ie. first we eliminate all * even tags, then all tags divisible by four, etc.). This ensures * that on average, all parts of the file are covered by the hash, if * sparsely. */ typedef uint32 tag; /* All zero means empty. We might miss the first chunk this way. */ struct hash_entry { uint32 offset; tag t; }; /* Levels control hashtable size and bzip2 level. */ static const struct level { unsigned bzip_level; unsigned mb_used; unsigned initial_freq; unsigned max_chain_len; } levels[10] = { { 0, 1, 4, 1 }, { 1, 2, 4, 2 }, { 3, 4, 4, 2 }, { 5, 8, 4, 2 }, { 7, 16, 4, 3 }, { 9, 32, 4, 4 }, { 9, 32, 2, 6 }, { 9, 64, 1, 16 }, /* More MB makes sense, but need bigger test files */ { 9, 64, 1, 32 }, { 9, 64, 1, 128 }, }; struct rzip_state { struct rzip_control *control; void *ss; const struct level *level; tag hash_index[256]; struct hash_entry *hash_table; unsigned int hash_bits; unsigned int hash_count; unsigned int hash_limit; tag minimum_tag_mask; unsigned int tag_clean_ptr; uchar *last_match; uint32 cksum; uint32 chunk_size; int fd_in, fd_out; struct { uint32 inserts; uint32 literals; uint32 literal_bytes; uint32 matches; uint32 match_bytes; uint32 tag_hits; uint32 tag_misses; } stats; }; static inline void put_u8(void *ss, int stream, uchar b) { if (write_stream(ss, stream, &b, 1) != 0) { fatal(NULL); } } static inline void put_u16(void *ss, int stream, unsigned s) { put_u8(ss, stream, s & 0xFF); put_u8(ss, stream, (s>>8) & 0xFF); } static inline void put_uint32(void *ss, int stream, unsigned s) { put_u8(ss, stream, s & 0xFF); put_u8(ss, stream, (s>>8) & 0xFF); put_u8(ss, stream, (s>>16) & 0xFF); put_u8(ss, stream, (s>>24) & 0xFF); } static void put_header(void *ss, uchar head, int len) { put_u8(ss, 0, head); put_u16(ss, 0, len); } static void put_match(struct rzip_state *st, uchar *p, uchar *buf, uint32 offset, int len) { do { unsigned ofs; int n = len; if (n > 0xFFFF) n = 0xFFFF; ofs = (uint32)(p - (buf+offset)); put_header(st->ss, 1, n); put_uint32(st->ss, 0, ofs); st->stats.matches++; st->stats.match_bytes += n; len -= n; p += n; offset += n; } while (len); } static void put_literal(struct rzip_state *st, uchar *last, uchar *p) { do { int len = (int)(p - last); if (len > 0xFFFF) len = 0xFFFF; st->stats.literals++; st->stats.literal_bytes += len; put_header(st->ss, 0, len); if (len && write_stream(st->ss, 1, last, len) != 0) { fatal(NULL); } last += len; } while (p > last); } /* Could give false positive on offset 0. Who cares. */ static int empty_hash(struct rzip_state *st, unsigned int h) { return !st->hash_table[h].offset && !st->hash_table[h].t; } static unsigned int primary_hash(struct rzip_state *st, tag t) { return t & ((1 << st->hash_bits) - 1); } static inline tag increase_mask(tag tag_mask) { /* Get more precise. */ return (tag_mask << 1) | 1; } static int minimum_bitness(struct rzip_state *st, tag t) { tag better_than_min = increase_mask(st->minimum_tag_mask); if ((t & better_than_min) != better_than_min) return 1; return 0; } /* Is a going to be cleaned before b? ie. does a have fewer low bits * set than b? */ static int lesser_bitness(tag a, tag b) { tag mask; for (mask = 0; mask != (tag)-1; mask = ((mask<<1)|1)) { if ((a & b & mask) != mask) break; } return ((a & mask) < (b & mask)); } /* If hash bucket is taken, we spill into next bucket(s). Secondary hashing works better in theory, but modern caches make this 20% faster. */ static void insert_hash(struct rzip_state *st, tag t, uint32 offset) { unsigned int h, victim_h = 0, round = 0; /* If we need to kill one, this will be it. */ static int victim_round = 0; h = primary_hash(st, t); while (!empty_hash(st, h)) { /* If this due for cleaning anyway, just replace it: rehashing might move it behind tag_clean_ptr. */ if (minimum_bitness(st, st->hash_table[h].t)) { st->hash_count--; break; } /* If we are better than current occupant, we can't jump over it: it will be cleaned before us, and noone would then find us in the hash table. Rehash it, then take its place. */ if (lesser_bitness(st->hash_table[h].t, t)) { insert_hash(st, st->hash_table[h].t, st->hash_table[h].offset); break; } /* If we have lots of identical patterns, we end up with lots of the same hash number. Discard random. */ if (st->hash_table[h].t == t) { if (round == victim_round) { victim_h = h; } if (++round == st->level->max_chain_len) { h = victim_h; st->hash_count--; victim_round++; if (victim_round == st->level->max_chain_len) victim_round = 0; break; } } h++; h &= ((1 << st->hash_bits) - 1); } st->hash_table[h].t = t; st->hash_table[h].offset = offset; } /* Eliminate one hash entry with minimum number of lower bits set. Returns tag requirement for any new entries. */ static tag clean_one_from_hash(struct rzip_state *st) { tag better_than_min; again: better_than_min = increase_mask(st->minimum_tag_mask); if (st->control->verbosity > 1) { if (!st->tag_clean_ptr) printf("Starting sweep for mask %u\n", st->minimum_tag_mask); } for (; st->tag_clean_ptr < (1<hash_bits); st->tag_clean_ptr++) { if (empty_hash(st, st->tag_clean_ptr)) continue; if ((st->hash_table[st->tag_clean_ptr].t & better_than_min) != better_than_min) { st->hash_table[st->tag_clean_ptr].offset = 0; st->hash_table[st->tag_clean_ptr].t = 0; st->hash_count--; return better_than_min; } } /* We hit the end: everthing in hash satisfies the better mask. */ st->minimum_tag_mask = better_than_min; st->tag_clean_ptr = 0; goto again; } static inline tag next_tag(struct rzip_state *st, uchar *p, tag t) { t ^= st->hash_index[p[-1]]; t ^= st->hash_index[p[MINIMUM_MATCH-1]]; return t; } static inline tag full_tag(struct rzip_state *st, uchar *p) { tag ret = 0; int i; for (i=0;ihash_index[p[i]]; } return ret; } static inline int match_len(struct rzip_state *st, uchar *p0, uchar *op, uchar *buf, uchar *end, int *rev) { uchar *p = p0; int len = 0; if (op >= p0) return 0; while ((*p == *op) && (p < end)) { p++; op++; } len = p - p0; p = p0; op -= len; end = buf; if (end < st->last_match) end = st->last_match; while (p > end && op > buf && op[-1] == p[-1]) { op--; p--; } (*rev) = p0 - p; len += p0 - p; if (len < MINIMUM_MATCH) return 0; return len; } static int find_best_match(struct rzip_state *st, tag t, uchar *p, uchar *buf, uchar *end, uint32 *offset, int *reverse, int current_len) { int length = 0; int rev; unsigned int h, best_h; rev = 0; (*reverse) = 0; /* Could optimize: if lesser goodness, can stop search. But * chains are usually short anyway. */ h = primary_hash(st, t); while (!empty_hash(st, h)) { int mlen; if (t == st->hash_table[h].t) { mlen = match_len(st, p, buf+st->hash_table[h].offset, buf, end, &rev); if (mlen) st->stats.tag_hits++; else st->stats.tag_misses++; if (mlen >= length) { length = mlen; (*offset) = st->hash_table[h].offset - rev; (*reverse) = rev; best_h = h; } } h++; h &= ((1 << st->hash_bits) - 1); } return length; } static void show_distrib(struct rzip_state *st) { int i; uint32 total = 0; uint32 primary = 0; for (i=0;i<(1 << st->hash_bits);i++) { if (empty_hash(st, i)) continue; total++; if (primary_hash(st, st->hash_table[i].t) == i) primary++; } if (total != st->hash_count) printf("WARNING: hash_count says total %u\n", st->hash_count); printf("%d total hashes\n", total); printf("%d in primary bucket (%-2.3f%%)\n", primary, primary*100.0/total); } static void hash_search(struct rzip_state *st, uchar *buf, double pct_base, double pct_multiple) { uchar *p, *end; tag t = 0; uint32 cksum_limit = 0; int pct, lastpct=0; struct { uchar *p; uint32 ofs; int len; } current; tag tag_mask = (1 << st->level->initial_freq)-1; if (st->hash_table) { memset(st->hash_table, 0, sizeof(st->hash_table[0]) * (1<hash_bits)); } else { uint32 hashsize = st->level->mb_used * (1024*1024 / sizeof(st->hash_table[0])); for (st->hash_bits = 0; (1<hash_bits) < hashsize; st->hash_bits++); if (st->control->verbosity > 1) printf("hashsize = %u. bits = %u. %uMB\n", hashsize, st->hash_bits, st->level->mb_used); /* 66% full at max. */ st->hash_limit = (1<hash_bits)/3 * 2; st->hash_table = calloc(sizeof(st->hash_table[0]), (1<hash_bits)); } if (!st->hash_table) { fatal("Failed to allocate hash table in hash_search\n"); } st->minimum_tag_mask = tag_mask; st->tag_clean_ptr = 0; st->cksum = 0; st->hash_count = 0; p = buf; end = buf + st->chunk_size - MINIMUM_MATCH; st->last_match = p; current.len = 0; current.p = p; current.ofs = 0; t = full_tag(st, p); while (p < end) { uint32 offset; int mlen, reverse; p++; t = next_tag(st, p, t); /* Don't look for a match if there are no tags with this number of bits in the hash table. */ if ((t & st->minimum_tag_mask) != st->minimum_tag_mask) continue; mlen = find_best_match(st, t, p, buf, end, &offset, &reverse, current.len); /* Only insert occasionally into hash. */ if ((t & tag_mask) == tag_mask) { st->stats.inserts++; st->hash_count++; insert_hash(st, t, (uint32)(p - buf)); if (st->hash_count > st->hash_limit) tag_mask = clean_one_from_hash(st); } if (mlen > current.len) { current.p = p - reverse; current.len = mlen; current.ofs = offset; } if ((current.len >= GREAT_MATCH || p>=current.p+MINIMUM_MATCH) && current.len >= MINIMUM_MATCH) { if (st->last_match < current.p) put_literal(st, st->last_match, current.p); put_match(st, current.p, buf, current.ofs, current.len); st->last_match = current.p + current.len; current.p = p = st->last_match; current.len = 0; t = full_tag(st, p); } if ((st->control->flags & FLAG_SHOW_PROGRESS) && (p-buf) % 100 == 0) { pct = pct_base + (pct_multiple * (100.0*(p-buf))/st->chunk_size); if (pct != lastpct) { struct stat s1, s2; fstat(st->fd_in, &s1); fstat(st->fd_out, &s2); printf("%s %2d%%\r", st->control->infile, pct); fflush(stdout); lastpct = pct; } } if ((p-buf) > cksum_limit) { int n = st->chunk_size - (p-buf); st->cksum = crc32_buffer(buf+cksum_limit, n, st->cksum); cksum_limit += n; } } if (st->control->verbosity > 1) { show_distrib(st); } if (st->last_match < buf + st->chunk_size) { put_literal(st, st->last_match,buf + st->chunk_size); } if (st->chunk_size > cksum_limit) { int n = st->chunk_size - cksum_limit; st->cksum = crc32_buffer(buf+cksum_limit, n, st->cksum); cksum_limit += n; } put_literal(st, NULL,0); put_uint32(st->ss, 0, st->cksum); } static void init_hash_indexes(struct rzip_state *st) { int i; for (i=0;i<256;i++) { st->hash_index[i] = ((random()<<16) ^ random()); } } /* compress a chunk of an open file. Assumes that the file is able to be mmap'd and is seekable */ static void rzip_chunk(struct rzip_state *st, int fd_in, int fd_out, off_t offset, double pct_base, double pct_multiple) { uchar *buf; buf = (uchar *)mmap(NULL,st->chunk_size,PROT_READ,MAP_SHARED,fd_in,offset); if (buf == (uchar *)-1) { fatal("Failed to map buffer in rzip_fd\n"); } st->ss = open_stream_out(fd_out, NUM_STREAMS, st->level->bzip_level); if (!st->ss) { fatal("Failed to open streams in rzip_fd\n"); } hash_search(st, buf, pct_base, pct_multiple); if (close_stream_out(st->ss) != 0) { fatal("Failed to flush/close streams in rzip_fd\n"); } munmap(buf, st->chunk_size); } /* compress a whole file chunks at a time */ void rzip_fd(struct rzip_control *control, int fd_in, int fd_out) { struct stat s, s2; off_t len; struct rzip_state *st; st = calloc(sizeof(*st), 1); if (!st) { fatal("Failed to allocate control state in rzip_fd\n"); } st->level = &levels[MIN(9, control->compression_level)]; st->control = control; st->fd_in = fd_in; st->fd_out = fd_out; init_hash_indexes(st); if (fstat(fd_in, &s)) { fatal("Failed to stat fd_in in rzip_fd - %s\n", strerror(errno)); } len = s.st_size; while (len) { int chunk; double pct_base, pct_multiple; if (control->compression_level == 0) { chunk = CHUNK_MULTIPLE; } else { chunk = control->compression_level * CHUNK_MULTIPLE; } if (chunk > len) chunk = len; pct_base = (100.0 * (s.st_size - len)) / s.st_size; pct_multiple = ((double)chunk) / s.st_size; st->chunk_size = chunk; rzip_chunk(st, fd_in, fd_out, s.st_size - len, pct_base, pct_multiple); len -= chunk; } fstat(fd_out, &s2); if (st->control->verbosity > 1) { printf("matches=%d match_bytes=%d\n", st->stats.matches, st->stats.match_bytes); printf("literals=%d literal_bytes=%d\n", st->stats.literals, st->stats.literal_bytes); printf("true_tag_positives=%d false_tag_positives=%d\n", st->stats.tag_hits, st->stats.tag_misses); printf("inserts=%d match %.3f\n", st->stats.inserts, (1.0 + st->stats.match_bytes) / st->stats.literal_bytes); } if ((st->control->flags & FLAG_SHOW_PROGRESS) || st->control->verbosity > 0) { printf("%s - compression ratio %.3f\n", st->control->infile, 1.0 * s.st_size / s2.st_size); } if (st->hash_table) { free(st->hash_table); } free(st); } rzip-2.1/rzip.h0100664000113300011330000000541310374223177013015 0ustar tridgetridge/* Copyright (C) Andrew Tridgell 1998 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define RZIP_MAJOR_VERSION 2 #define RZIP_MINOR_VERSION 1 #define NUM_STREAMS 2 #define _GNU_SOURCE #include "config.h" #include #include #include #include #include #include #include #include #ifdef HAVE_STRING_H #include #endif #ifdef HAVE_MALLOC_H #include #endif #include #include #ifdef HAVE_CTYPE_H #include #endif #include #include #ifndef uchar #define uchar unsigned char #endif #ifndef int32 #if (SIZEOF_INT == 4) #define int32 int #elif (SIZEOF_LONG == 4) #define int32 long #elif (SIZEOF_SHORT == 4) #define int32 short #endif #endif #ifndef int16 #if (SIZEOF_INT == 2) #define int16 int #elif (SIZEOF_SHORT == 2) #define int16 short #endif #endif #ifndef uint32 #define uint32 unsigned int32 #endif #ifndef uint16 #define uint16 unsigned int16 #endif #ifndef MIN #define MIN(a,b) ((a)<(b)?(a):(b)) #endif #ifndef MAX #define MAX(a,b) ((a)>(b)?(a):(b)) #endif #if !HAVE_STRERROR extern char *sys_errlist[]; #define strerror(i) sys_errlist[i] #endif #ifndef HAVE_ERRNO_DECL extern int errno; #endif #define FLAG_SHOW_PROGRESS 2 #define FLAG_KEEP_FILES 4 #define FLAG_TEST_ONLY 8 #define FLAG_FORCE_REPLACE 16 #define FLAG_DECOMPRESS 32 struct rzip_control { const char *infile, *outname; char *outfile; const char *suffix; unsigned compression_level; unsigned flags; unsigned verbosity; }; void fatal(const char *format, ...); void err_msg(const char *format, ...); off_t runzip_fd(int fd_in, int fd_out, int fd_hist, off_t expected_size); void rzip_fd(struct rzip_control *control, int fd_in, int fd_out); void *open_stream_out(int f, int n, int bzip_level); void *open_stream_in(int f, int n); int write_stream(void *ss, int stream, uchar *p, int len); int read_stream(void *ss, int stream, uchar *p, int len); int close_stream_out(void *ss); int close_stream_in(void *ss); void *Realloc(void *p, int size); uint32 crc32_buffer(const uchar *buf, int n, uint32 crc); rzip-2.1/rzip.yo0100644000113300011330000001071607740527246013224 0ustar tridgetridgemailto(bugs-rzip@tridgell.net) manpage(rzip)(1)(October 2003)()() manpagename(rzip)(a large-file compression program) manpagesynopsis() rzip [OPTIONS] manpagedescription() rzip is a file compression program designed to do particularly well on very large files containing long distance redundency. manpagesection(OPTIONS SUMMARY) Here is a summary of the options to rzip. verb( -0 fastest (worst) compression -6 default compression -9 slowest (best) compression -d decompress -o filename specify the output file name -S suffix specify compressed suffix (default '.rz') -f force overwrite of any existing files -k keep existing files -P show compression progress -V show version ) manpageoptions() startdit() dit(bf(-h)) Print an options summary page dit(bf(-V)) Print the rzip version number dit(bf(-0..9)) Set the compression level from 0 to 9. The default is to use level 6, which is a reasonable compromise between speed and compression. The compression level is also strongly related to how much memory rzip uses, so if you are running rzip on a machine with limited amounts of memory then you will probably want to choose a smaller level. dit(bf(-d)) Decompress. If this option is not used then rzip looks at the name used to launch the program. If it contains the string 'runzip' then the -d option is automatically set. dit(bf(-o)) Set the output file name. If this option is not set then the output file name is chosen based on the input name and the suffix. The -o option cannot be used if more than one file name is specified on the command line. dit(bf(-S)) Set the compression suffix. The default is '.rz'. dit(bf(-f)) If this option is not specified then rzip will not overwrite any existing files. If you set this option then rzip will silently overwrite any files as needed. dit(bf(-k)) If this option is not specified then rzip will delete the source file after successful compression or decompression. When this option is specified then the source files are not deleted. dit(bf(-P)) If this option is specified then rzip will show the percentage progress while compressing. enddit() manpagesection(INSTALLATION) Just install rzip in your search path. manpagesection(COMPRESSION ALGORITHM) rzip operates in two stages. The first stage finds and encodes large chunks of duplicated data over potentially very long distances (up to nearly a gigabyte) in the input file. The second stage is to use a standard compression algorithm (bzip2) to compress the output of the first stage. The key difference between rzip and other well known compression algorithms is its ability to take advantage of very long distance redundency. The well known deflate algorithm used in gzip uses a maximum history buffer of 32k. The block sorting algorithm used in bzip2 is limited to 900k of history. The history buffer in rzip can be up to 900MB long, several orders of magnitude larger than gzip or bzip2. It is quite common these days to need to compress files that contain long distance redundancies. For example, when compressing a set of home directories several users might have copies of the same file, or of quite similar files. It is also common to have a single file that contains large duplicated chunks over long distances, such as pdf files containing repeated copies of the same image. Most compression programs won't be able to take advantage of this redundency, and thus might achieve a much lower compression ratio than rzip can achieve. manpagesection(HISTORY) The ideas behind rzip were first implemented in 1998 while I was working on rsync. That version was too slow to be practical, and was replaced by this version in 2003. manpagesection(BUGS) Unlike most Unix compression programs, rzip cannot compress or decompress to or from standard input or standard output. This is due to the nature of the algorithm that rzip uses and cannot easily be fixed. manpagesection(CREDITS) Thanks to the following people for their contributions to rzip itemize( it() Paul Russell for many suggestions and the debian packaging it() The authors of bzlib for an excellent library ) manpageauthor() rzip was written by Andrew Tridgell url(http://samba.org/~tridge/)(http://samba.org/~tridge/) If you wish to report a problem or make a suggestion then please email bugs-rzip@tridgell.net rzip is released under the GNU General Public License version 2 or later. Please see the file COPYING for license details. rzip-2.1/rzipall0100755000113300011330000000007207737301473013262 0ustar tridgetridge#!/bin/sh for f in $*; do $HOME/rzip/rzip $f $f.rz donerzip-2.1/stream.c0100664000113300011330000002426010374223177013320 0ustar tridgetridge/* Copyright (C) Andrew Tridgell 1998 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* multiplex N streams into a file - the streams are passed through bzlib */ #include "rzip.h" #include "bzlib.h" #define CTYPE_NONE 3 #define CTYPE_BZIP2 4 typedef uint16 u16; typedef uint32 u32; struct stream { u32 last_head; uchar *buf; int buflen; int bufp; int bzip_level; }; struct stream_info { struct stream *s; int num_streams; int fd; u32 bufsize; u32 cur_pos; off_t initial_pos; u32 total_read; }; /* try to compress a buffer. If compression fails for whatever reason then leave uncompressed. Return the compression type in c_type and resulting length in c_len */ static void compress_buf(struct stream *s, int *c_type, u32 *c_len) { uchar *c_buf; unsigned int dlen = s->buflen-1; if (s->bzip_level == 0) return; c_buf = malloc(dlen); if (!c_buf) return; if (BZ2_bzBuffToBuffCompress((char*)c_buf, &dlen, (char*)s->buf, s->buflen, s->bzip_level, 0, s->bzip_level*10) != BZ_OK) { free(c_buf); return; } *c_len = dlen; free(s->buf); s->buf = c_buf; *c_type = CTYPE_BZIP2; } /* try to decompress a buffer. Return 0 on success and -1 on failure. */ static int decompress_buf(struct stream *s, u32 c_len, int c_type) { uchar *c_buf; unsigned int dlen = s->buflen; int bzerr; if (c_type == CTYPE_NONE) return 0; c_buf = s->buf; s->buf = malloc(dlen); if (!s->buf) { err_msg("Failed to allocate %d bytes for decompression\n", dlen); return -1; } bzerr = BZ2_bzBuffToBuffDecompress((char*)s->buf, &dlen, (char*)c_buf, c_len, 0, 0); if (bzerr != BZ_OK) { err_msg("Failed to decompress buffer - bzerr=%d\n", bzerr); return -1; } if (dlen != s->buflen) { err_msg("Inconsistent length after decompression. Got %d bytes, expected %d\n", dlen, s->buflen); return -1; } free(c_buf); return 0; } /* write to a file, return 0 on success and -1 on failure */ static int write_buf(int f, uchar *p, int len) { int ret; ret = write(f, p, len); if (ret == -1) { err_msg("Write of length %d failed - %s\n", len, strerror(errno)); return -1; } if (ret != len) { err_msg("Partial write!? asked for %d bytes but got %d\n", len, ret); return -1; } return 0; } /* write a byte */ static int write_u8(int f, uchar v) { return write_buf(f, &v, 1); } /* write a short */ static int write_u16(int f, u16 v) { uchar p[2]; p[0] = v&0xFF; p[1] = (v>>8)&0xFF; return write_buf(f, p, 2); } /* write a long */ static int write_u32(int f, u32 v) { if (write_u16(f, v&0xFFFF) != 0 || write_u16(f, (v>>16)) != 0) { return -1; } return 0; } static int read_buf(int f, uchar *p, int len) { int ret; ret = read(f, p, len); if (ret == -1) { err_msg("Read of length %d failed - %s\n", len, strerror(errno)); return -1; } if (ret != len) { err_msg("Partial read!? asked for %d bytes but got %d\n", len, ret); return -1; } return 0; } static int read_u8(int f, uchar *v) { return read_buf(f, v, 1); } static int read_u16(int f, u16 *v) { uchar p[2]; if (read_buf(f, p, 2) != 0) { return -1; } *v = (p[1]<<8) | p[0]; return 0; } static int read_u32(int f, u32 *v) { u16 v1, v2; if (read_u16(f, &v1) != 0) { return -1; } if (read_u16(f, &v2) != 0) { return -1; } *v = v2; *v <<= 16; *v |= v1; return 0; } /* seek to a position within a set of streams - return -1 on failure */ static int seekto(struct stream_info *sinfo, u32 pos) { off_t spos = pos + sinfo->initial_pos; if (lseek(sinfo->fd, spos, SEEK_SET) != spos) { err_msg("Failed to seek to %d in stream\n", pos); return -1; } return 0; } /* open a set of output streams, compressing with the given bzip level */ void *open_stream_out(int f, int n, int bzip_level) { int i; struct stream_info *sinfo; sinfo = malloc(sizeof(*sinfo)); if (!sinfo) { return NULL; } sinfo->num_streams = n; sinfo->cur_pos = 0; sinfo->fd = f; if (bzip_level == 0) { sinfo->bufsize = 100*1024; } else { sinfo->bufsize = 100*1024*bzip_level; } sinfo->initial_pos = lseek(f, 0, SEEK_CUR); sinfo->s = (struct stream *)calloc(sizeof(sinfo->s[0]), n); if (!sinfo->s) { free(sinfo); return NULL; } for (i=0;is[i].buf = malloc(sinfo->bufsize); if (!sinfo->s[i].buf) goto failed; sinfo->s[i].bzip_level = bzip_level; } /* write the initial headers */ for (i=0;is[i].last_head = sinfo->cur_pos + 9; write_u8(sinfo->fd, CTYPE_NONE); write_u32(sinfo->fd, 0); write_u32(sinfo->fd, 0); write_u32(sinfo->fd, 0); sinfo->cur_pos += 13; } return (void *)sinfo; failed: for (i=0;is[i].buf) free(sinfo->s[i].buf); } free(sinfo); return NULL; } /* prepare a set of n streams for reading on file descriptor f */ void *open_stream_in(int f, int n) { int i; struct stream_info *sinfo; sinfo = calloc(sizeof(*sinfo), 1); if (!sinfo) { return NULL; } sinfo->num_streams = n; sinfo->fd = f; sinfo->initial_pos = lseek(f, 0, SEEK_CUR); sinfo->s = (struct stream *)calloc(sizeof(sinfo->s[0]), n); if (!sinfo->s) { free(sinfo); return NULL; } for (i=0;is[i].last_head) != 0) { goto failed; } if (c == CTYPE_NONE && v1==0 && v2==0 && sinfo->s[i].last_head==0 && i == 0) { err_msg("Enabling stream close workaround\n"); sinfo->initial_pos += 13; goto again; } sinfo->total_read += 13; if (c != CTYPE_NONE) { err_msg("Unexpected initial tag %d in streams\n", c); goto failed; } if (v1 != 0) { err_msg("Unexpected initial c_len %d in streams %d\n", v1, v2); goto failed; } if (v2 != 0) { err_msg("Unexpected initial u_len %d in streams\n", v2); goto failed; } } return (void *)sinfo; failed: free(sinfo->s); free(sinfo); return NULL; } /* flush out any data in a stream buffer. Return -1 on failure */ static int flush_buffer(struct stream_info *sinfo, int stream) { int c_type = CTYPE_NONE; u32 c_len = sinfo->s[stream].buflen; if (seekto(sinfo, sinfo->s[stream].last_head) != 0) { return -1; } if (write_u32(sinfo->fd, sinfo->cur_pos) != 0) { return -1; } sinfo->s[stream].last_head = sinfo->cur_pos + 9; if (seekto(sinfo, sinfo->cur_pos) != 0) { return -1; } compress_buf(&sinfo->s[stream], &c_type, &c_len); if (write_u8(sinfo->fd, c_type) != 0 || write_u32(sinfo->fd, c_len) != 0 || write_u32(sinfo->fd, sinfo->s[stream].buflen) != 0 || write_u32(sinfo->fd, 0) != 0) { return -1; } sinfo->cur_pos += 13; if (write_buf(sinfo->fd, sinfo->s[stream].buf, c_len) != 0) { return -1; } sinfo->cur_pos += c_len; sinfo->s[stream].buflen = 0; free(sinfo->s[stream].buf); sinfo->s[stream].buf = malloc(sinfo->bufsize); if (!sinfo->s[stream].buf) { return -1; } return 0; } /* fill a buffer from a stream - return -1 on failure */ static int fill_buffer(struct stream_info *sinfo, int stream) { uchar c_type; u32 u_len, c_len; if (seekto(sinfo, sinfo->s[stream].last_head) != 0) { return -1; } if (read_u8(sinfo->fd, &c_type) != 0) { return -1; } if (read_u32(sinfo->fd, &c_len) != 0) { return -1; } if (read_u32(sinfo->fd, &u_len) != 0) { return -1; } if (read_u32(sinfo->fd, &sinfo->s[stream].last_head) != 0) { return -1; } sinfo->total_read += 13; if (sinfo->s[stream].buf) { free(sinfo->s[stream].buf); } sinfo->s[stream].buf = malloc(u_len); if (!sinfo->s[stream].buf) { return -1; } if (read_buf(sinfo->fd, sinfo->s[stream].buf, c_len) != 0) { return -1; } sinfo->total_read += c_len; sinfo->s[stream].buflen = u_len; sinfo->s[stream].bufp = 0; if (decompress_buf(&sinfo->s[stream], c_len, c_type) != 0) { return -1; } return 0; } /* write some data to a stream. Return -1 on failure */ int write_stream(void *ss, int stream, uchar *p, int len) { struct stream_info *sinfo = ss; while (len) { int n = MIN(sinfo->bufsize - sinfo->s[stream].buflen, len); memcpy(sinfo->s[stream].buf+sinfo->s[stream].buflen, p, n); sinfo->s[stream].buflen += n; p += n; len -= n; if (sinfo->s[stream].buflen == sinfo->bufsize) { if (flush_buffer(sinfo, stream) != 0) { return -1; } } } return 0; } /* read some data from a stream. Return number of bytes read, or -1 on failure */ int read_stream(void *ss, int stream, uchar *p, int len) { struct stream_info *sinfo = ss; int ret=0; while (len) { int n = MIN(sinfo->s[stream].buflen-sinfo->s[stream].bufp, len); if (n > 0) { memcpy(p, sinfo->s[stream].buf+sinfo->s[stream].bufp, n); sinfo->s[stream].bufp += n; p += n; len -= n; ret += n; } if (len && sinfo->s[stream].bufp == sinfo->s[stream].buflen) { if (fill_buffer(sinfo, stream) != 0) { return -1; } if (sinfo->s[stream].bufp == sinfo->s[stream].buflen) break; } } return ret; } /* flush and close down a stream. return -1 on failure */ int close_stream_out(void *ss) { struct stream_info *sinfo = ss; int i; for (i=0;inum_streams;i++) { if (sinfo->s[i].buflen != 0 && flush_buffer(sinfo, i) != 0) { return -1; } if (sinfo->s[i].buf) free(sinfo->s[i].buf); } free(sinfo->s); free(sinfo); return 0; } /* close down an input stream */ int close_stream_in(void *ss) { struct stream_info *sinfo = ss; int i; if (lseek(sinfo->fd, sinfo->initial_pos + sinfo->total_read, SEEK_SET) != sinfo->initial_pos + sinfo->total_read) { return -1; } for (i=0;inum_streams;i++) { if (sinfo->s[i].buf) free(sinfo->s[i].buf); } free(sinfo->s); free(sinfo); return 0; } rzip-2.1/find_stream_match.c0100664000113300011330000002012210024176702015456 0ustar tridgetridge/* Example piece of code to demonstrate how to find a match in a stream, without buffering, for use in rzip on *really* huge files. Copyright (C) 2003 Rusty Russell, IBM Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include "md4.h" struct hash_entry { uint64_t offset; uchar bitness; uchar md4[MD4_DIGEST_SIZE]; }; typedef uint32_t tag; #define HASH_BITS 10 #define MINIMUM_BITNESS 1 #define MAXIMUM_BITNESS 32 /* need to increase tag size to increase this */ #define WINDOW_LENGTH 31 /* Simple optimization for read() */ #define BUFFER_SIZE 4096 static struct hash_entry hash[1 << HASH_BITS]; static const unsigned int hash_limit = (1 << HASH_BITS) * 2 / 3; static unsigned int hash_min_bitness = MINIMUM_BITNESS; static unsigned int hash_count; static unsigned int hash_clean_ptr; static tag hash_index[256]; static int verbosity = 2; static void barf_perror(const char *fmt, ...) { char *str = strerror(errno); va_list arglist; fprintf(stderr, "FATAL: "); va_start(arglist, fmt); vfprintf(stderr, fmt, arglist); va_end(arglist); fprintf(stderr, ": %s\n", str); exit(1); } static int bitness(tag t) { return ffs(t) ?: 32; } static int empty_hash(unsigned int h) { return !hash[h].bitness; } static uint32_t primary_hash(const struct hash_entry *h) { return h->md4[1] & ((1 << HASH_BITS) - 1); } static inline int hash_equals(const struct hash_entry *a, const struct hash_entry *b) { return memcmp(a->md4, b->md4, sizeof(a->md4)) == 0; } /* Eliminate one hash entry of minimum bitness. */ static void clean_one_from_hash(void) { again: if (verbosity > 1) { if (!hash_clean_ptr) printf("Starting sweep for mask %u\n", hash_min_bitness); } for (; hash_clean_ptr < (1<bitness) { struct hash_entry old = hash[h]; hash[h] = *new; insert_hash(&old); return NULL; } h++; h &= ((1 << HASH_BITS) - 1); } hash[h] = *new; if (++hash_count > hash_limit) clean_one_from_hash(); return NULL; } static inline tag next_tag(uchar old, uchar new, tag t) { t ^= hash_index[old]; t ^= hash_index[new]; return t; } static inline tag full_tag(uchar *p, unsigned int len) { tag ret = 0; int i; for (i=0;i 0) { assert(doff >= WINDOW_LENGTH); /* Make sure we always have some buffer. */ if (dlen == 1) { /* Keep WINDOW_LENGTH behind at all times. */ unsigned int newstart, keep; newstart = doff - WINDOW_LENGTH; keep = WINDOW_LENGTH + dlen; if (laststrong < newstart) { strong_sums(data+laststrong, md4, newstart-laststrong); laststrong = 0; } else laststrong -= newstart; memmove(data, data+newstart, keep); doff = WINDOW_LENGTH; r = read(fd_in, data+keep, BUFFER_SIZE-keep); if (r < 0) barf_perror("read of input failed: %s"); dlen += r; } t = next_tag(data[doff-WINDOW_LENGTH], data[doff], t); if (bitness(t) > hash_min_bitness) { /* Update strong sums. */ strong_sums(data+laststrong, md4, doff-laststrong); if (debug) printf("Adding: %lu - %lu %.*s\n", laststrong, doff, doff-laststrong, data+laststrong); laststrong = doff; /* End each block of sufficient bitness. */ lastlen = 0; for (i = bitness(t); i >= hash_min_bitness; i--) { struct hash_entry he, *old; md4_final(&md4[i], (unsigned char *)he.md4); he.bitness = i; he.offset = start[i]; /* Don't put in the same hash twice. */ if (off - start[i] != lastlen) { if (verbosity > 1) printf("%i: Putting %lu@%lu" " in hash\n", i, off - start[i], start[i]); old = insert_hash(&he); lastlen = off - start[i]; if (old) { found_match(fd_in, lastlen, start[i], old->offset); } } /* Start new strong hash, from *start* of window (ie. overlaps last one). */ md4_init(&md4[i]); md4_update(&md4[i], data + doff - WINDOW_LENGTH, WINDOW_LENGTH); start[i] = off - WINDOW_LENGTH; if (start[i] == 28039) debug = true; if (debug) printf("Starting %lu: %.*s\n", start[i], WINDOW_LENGTH, data + doff - WINDOW_LENGTH); } } doff++; dlen--; off++; } return off; } static void init_hash_indexes(void) { int i; for (i=0;i<256;i++) { hash_index[i] = ((random()<<16) ^ random()); } } int main(int argc, char *argv[]) { unsigned int i; init_hash_indexes(); for (i = 1; i < argc; i++) { off_t len; int fd = open(argv[i], O_RDONLY); if (fd < 0) barf_perror("Opening %s", argv[i]); len = stream_search(fd); close(fd); printf("Length of %s: %llu\n", argv[i], (long long)len); } return 0; } rzip-2.1/testfiles.sh0100755000113300011330000000133407740541212014211 0ustar tridgetridge#!/bin/sh tdir=/tmp/rzip.$$ mkdir $tdir || exit 1 failed() { f=$1 echo "Failed on $f" exit 1 } ratio() { echo $2 $1 | awk '{printf "%5.2f\n", $2/$1}' } ts1=0 ts2=0 for f in $*; do if [ ! -r $f -o ! -f $f ]; then continue; fi bname=`basename $f` ./rzip -k $f -o $tdir/$bname || failed $f s1=`stat -L -c '%s' $f` s2=`stat -L -c '%s' $tdir/$bname` r=`ratio $s1 $s2` echo $f $s1 $s2 $r ./rzip -k -d $tdir/$bname -o $tdir/$bname.2 || failed $f if ! cmp $f $tdir/$bname.2; then echo "Failed on $f!!" exit 1 fi ts1=`expr $ts1 + $s1` ts2=`expr $ts2 + $s2` rm -f $tdir/$bname.2 $tdir/$bname done echo ALL OK r=`ratio $ts1 $ts2` echo $ts1 $ts2 $r rm -rf $tdir rzip-2.1/util.c0100664000113300011330000000235010374223177012776 0ustar tridgetridge/* Copyright (C) Andrew Tridgell 1998 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. 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. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* Utilities used in rzip tridge, June 1996 */ #include "rzip.h" void *Realloc(void *p, int size) { if (!p) return (void *)malloc(size); return (void *)realloc(p, size); } void err_msg(const char *format, ...) { va_list ap; va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); } void fatal(const char *format, ...) { va_list ap; if (format) { va_start(ap, format); vfprintf(stderr, format, ap); va_end(ap); } fprintf(stderr, "Fatal error - exiting\n"); exit(1); } rzip-2.1/md4.c0100664000113300011330000001222610024176702012501 0ustar tridgetridge/* * Cryptographic API (taken from the Linux Kernel) * * MD4 Message Digest Algorithm (RFC1320). * * Implementation derived from Andrew Tridgell and Steve French's * CIFS MD4 implementation, and the cryptoapi implementation * originally based on the public domain implementation written * by Colin Plumb in 1993. * * Copyright (c) Andrew Tridgell 1997-1998. * Modified by Steve French (sfrench@us.ibm.com) 2002 * Copyright (c) Cryptoapi developers. * Copyright (c) 2002 David S. Miller (davem@redhat.com) * Copyright (c) 2002 James Morris * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * */ #include "rzip.h" #include "md4.h" #include #define u32 uint32 static inline u32 lshift(u32 x, unsigned int s) { x &= 0xFFFFFFFF; return ((x << s) & 0xFFFFFFFF) | (x >> (32 - s)); } static inline u32 F(u32 x, u32 y, u32 z) { return (x & y) | ((~x) & z); } static inline u32 G(u32 x, u32 y, u32 z) { return (x & y) | (x & z) | (y & z); } static inline u32 H(u32 x, u32 y, u32 z) { return x ^ y ^ z; } #define ROUND1(a,b,c,d,k,s) (a = lshift(a + F(b,c,d) + k, s)) #define ROUND2(a,b,c,d,k,s) (a = lshift(a + G(b,c,d) + k + (u32)0x5A827999,s)) #define ROUND3(a,b,c,d,k,s) (a = lshift(a + H(b,c,d) + k + (u32)0x6ED9EBA1,s)) /* XXX: this stuff can be optimized */ static inline void le32_to_cpu_array(u32 *buf, unsigned int words) { while (words--) { *buf = ntohl(*buf); buf++; } } static inline void cpu_to_le32_array(u32 *buf, unsigned int words) { while (words--) { *buf = htonl(*buf); buf++; } } static void md4_transform(u32 *hash, u32 const *in) { u32 a, b, c, d; a = hash[0]; b = hash[1]; c = hash[2]; d = hash[3]; ROUND1(a, b, c, d, in[0], 3); ROUND1(d, a, b, c, in[1], 7); ROUND1(c, d, a, b, in[2], 11); ROUND1(b, c, d, a, in[3], 19); ROUND1(a, b, c, d, in[4], 3); ROUND1(d, a, b, c, in[5], 7); ROUND1(c, d, a, b, in[6], 11); ROUND1(b, c, d, a, in[7], 19); ROUND1(a, b, c, d, in[8], 3); ROUND1(d, a, b, c, in[9], 7); ROUND1(c, d, a, b, in[10], 11); ROUND1(b, c, d, a, in[11], 19); ROUND1(a, b, c, d, in[12], 3); ROUND1(d, a, b, c, in[13], 7); ROUND1(c, d, a, b, in[14], 11); ROUND1(b, c, d, a, in[15], 19); ROUND2(a, b, c, d,in[ 0], 3); ROUND2(d, a, b, c, in[4], 5); ROUND2(c, d, a, b, in[8], 9); ROUND2(b, c, d, a, in[12], 13); ROUND2(a, b, c, d, in[1], 3); ROUND2(d, a, b, c, in[5], 5); ROUND2(c, d, a, b, in[9], 9); ROUND2(b, c, d, a, in[13], 13); ROUND2(a, b, c, d, in[2], 3); ROUND2(d, a, b, c, in[6], 5); ROUND2(c, d, a, b, in[10], 9); ROUND2(b, c, d, a, in[14], 13); ROUND2(a, b, c, d, in[3], 3); ROUND2(d, a, b, c, in[7], 5); ROUND2(c, d, a, b, in[11], 9); ROUND2(b, c, d, a, in[15], 13); ROUND3(a, b, c, d,in[ 0], 3); ROUND3(d, a, b, c, in[8], 9); ROUND3(c, d, a, b, in[4], 11); ROUND3(b, c, d, a, in[12], 15); ROUND3(a, b, c, d, in[2], 3); ROUND3(d, a, b, c, in[10], 9); ROUND3(c, d, a, b, in[6], 11); ROUND3(b, c, d, a, in[14], 15); ROUND3(a, b, c, d, in[1], 3); ROUND3(d, a, b, c, in[9], 9); ROUND3(c, d, a, b, in[5], 11); ROUND3(b, c, d, a, in[13], 15); ROUND3(a, b, c, d, in[3], 3); ROUND3(d, a, b, c, in[11], 9); ROUND3(c, d, a, b, in[7], 11); ROUND3(b, c, d, a, in[15], 15); hash[0] += a; hash[1] += b; hash[2] += c; hash[3] += d; } static inline void md4_transform_helper(struct md4_ctx *ctx) { le32_to_cpu_array(ctx->block, sizeof(ctx->block) / sizeof(u32)); md4_transform(ctx->hash, ctx->block); } void md4_init(struct md4_ctx *mctx) { mctx->hash[0] = 0x67452301; mctx->hash[1] = 0xefcdab89; mctx->hash[2] = 0x98badcfe; mctx->hash[3] = 0x10325476; mctx->byte_count = 0; } void md4_update(struct md4_ctx *mctx, const uchar *data, unsigned int len) { const u32 avail = sizeof(mctx->block) - (mctx->byte_count & 0x3f); mctx->byte_count += len; if (avail > len) { memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), data, len); return; } memcpy((char *)mctx->block + (sizeof(mctx->block) - avail), data, avail); md4_transform_helper(mctx); data += avail; len -= avail; while (len >= sizeof(mctx->block)) { memcpy(mctx->block, data, sizeof(mctx->block)); md4_transform_helper(mctx); data += sizeof(mctx->block); len -= sizeof(mctx->block); } memcpy(mctx->block, data, len); } void md4_final(struct md4_ctx *mctx, uchar *out) { const unsigned int offset = mctx->byte_count & 0x3f; char *p = (char *)mctx->block + offset; int padding = 56 - (offset + 1); *p++ = 0x80; if (padding < 0) { memset(p, 0x00, padding + sizeof (uint64)); md4_transform_helper(mctx); p = (char *)mctx->block; padding = 56; } memset(p, 0, padding); mctx->block[14] = mctx->byte_count << 3; mctx->block[15] = mctx->byte_count >> 29; le32_to_cpu_array(mctx->block, (sizeof(mctx->block) - sizeof(uint64)) / sizeof(u32)); md4_transform(mctx->hash, mctx->block); cpu_to_le32_array(mctx->hash, sizeof(mctx->hash) / sizeof(u32)); memcpy(out, mctx->hash, sizeof(mctx->hash)); memset(mctx, 0, sizeof(*mctx)); } rzip-2.1/md4.h0100664000113300011330000000077010024176702012507 0ustar tridgetridge#ifndef _RZIP_MD4_H #define _RZIP_MD4_H #include #define MD4_DIGEST_SIZE 16 #define MD4_HMAC_BLOCK_SIZE 64 #define MD4_BLOCK_WORDS 16 #define MD4_HASH_WORDS 4 typedef unsigned char uchar; struct md4_ctx { uint32_t hash[MD4_HASH_WORDS]; uint32_t block[MD4_BLOCK_WORDS]; uint64_t byte_count; }; void md4_init(struct md4_ctx *mctx); void md4_update(struct md4_ctx *mctx, const uchar *data, unsigned int len); void md4_final(struct md4_ctx *mctx, uchar *out); #endif /* _RZIP_MD4_H */