Import of dcfldd_1.3.4.1.orig.tar.gz

version 1.3.4-1 from http://dcfldd.sourceforge.net/
This commit is contained in:
Alexandre Dulaunoy 2013-02-23 10:05:53 +01:00
parent 7f74c0d7ec
commit 388c7ffe3b
69 changed files with 21133 additions and 0 deletions

1
AUTHORS Normal file
View file

@ -0,0 +1 @@
dcfldd by Nicholas Harbour, GNU dd by Paul Rubin, David MacKenzie and Stuart Kemp

340
COPYING Normal file
View file

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 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
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.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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
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) year 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.
<signature of Ty Coon>, 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.

16
ChangeLog Normal file
View file

@ -0,0 +1,16 @@
Changes from version 1.2.2:
- Added ability to write to multiple output files.
- Added split capability with the "split=" and "splitformat=" switches.
- Converts "if=/dev/zero" to "pattern=00" to force efficiency.
- Fixed a few bugs with verify.
Changes from version 1.2.1:
- Fixed large file support bug
- added verify capability
Changes from version 1.0:
- Added SHA-1, SHA-256, SHA-384 and SHA-512 support
- Fixed compile errors.
- Fixed Megabyte constant.
- Fixed problem with not displaying the final hash remainder.
- Created an entirely new (and trim) build environment.

182
INSTALL Normal file
View file

@ -0,0 +1,182 @@
Basic Installation
==================
These are generic installation instructions.
The `configure' shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile' in each directory of the package.
It may also create one or more `.h' files containing system-dependent
definitions. Finally, it creates a shell script `config.status' that
you can run in the future to recreate the current configuration, a file
`config.cache' that saves the results of its tests to speed up
reconfiguring, and a file `config.log' containing compiler output
(useful mainly for debugging `configure').
If you need to do unusual things to compile the package, please try
to figure out how `configure' could check whether to do them, and mail
diffs or instructions to the address given in the `README' so they can
be considered for the next release. If at some point `config.cache'
contains results you don't want to keep, you may remove or edit it.
The file `configure.in' is used to create `configure' by a program
called `autoconf'. You only need `configure.in' if you want to change
it or regenerate `configure' using a newer version of `autoconf'.
The simplest way to compile this package is:
1. `cd' to the directory containing the package's source code and type
`./configure' to configure the package for your system. If you're
using `csh' on an old version of System V, you might need to type
`sh ./configure' instead to prevent `csh' from trying to execute
`configure' itself.
Running `configure' takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make' to compile the package.
3. Optionally, type `make check' to run any self-tests that come with
the package.
4. Type `make install' to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean'. To also remove the
files that `configure' created (so you can compile the package for
a different kind of computer), type `make distclean'. There is
also a `make maintainer-clean' target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure' script does not know about. You can give `configure'
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env' program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make' that
supports the `VPATH' variable, such as GNU `make'. `cd' to the
directory where you want the object files and executables to go and run
the `configure' script. `configure' automatically checks for the
source code in the directory that `configure' is in and in `..'.
If you have to use a `make' that does not supports the `VPATH'
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean' before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install' will install the package's files in
`/usr/local/bin', `/usr/local/man', etc. You can specify an
installation prefix other than `/usr/local' by giving `configure' the
option `--prefix=PATH'.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure' the option `--exec-prefix=PATH', the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH' to specify different values for particular
kinds of files. Run `configure --help' for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure' the
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE' options to
`configure', where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
is something like `gnu-as' or `x' (for the X Window System). The
`README' should mention any `--enable-' and `--with-' options that the
package recognizes.
For packages that use the X Window System, `configure' can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure' options `--x-includes=DIR' and
`--x-libraries=DIR' to specify their locations.
Specifying the System Type
==========================
There may be some features `configure' can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure' can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE' option. TYPE can either be a short name for the system
type, such as `sun4', or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub' for the possible values of each field. If
`config.sub' isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE' option to select the type of system they will
produce code for and the `--build=TYPE' option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure' scripts to share,
you can create a site shell script called `config.site' that gives
default values for variables like `CC', `cache_file', and `prefix'.
`configure' looks for `PREFIX/share/config.site' if it exists, then
`PREFIX/etc/config.site' if it exists. Or, you can set the
`CONFIG_SITE' environment variable to the location of the site script.
A warning: not all `configure' scripts look for a site script.
Operation Controls
==================
`configure' recognizes the following options to control how it
operates.
`--cache-file=FILE'
Use and save the results of the tests in FILE instead of
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
debugging `configure'.
`--help'
Print a summary of the options to `configure', and exit.
`--quiet'
`--silent'
`-q'
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null' (any error
messages will still be shown).
`--srcdir=DIR'
Look for the package's source code in directory DIR. Usually
`configure' can determine that directory automatically.
`--version'
Print the version of Autoconf used to generate the `configure'
script, and exit.
`configure' also accepts some other, not widely useful, options.

13
Makefile.am Normal file
View file

@ -0,0 +1,13 @@
bin_PROGRAMS = dcfldd
dcfldd_SOURCES = dcfldd.c md5.c md5.h sha1.c sha1.h sha2.c sha2.h human.c human.h \
getpagesize.h long-options.c long-options.h safe-read.c safe-read.h xstrtol.c \
xstrtol.h version-etc.c version-etc.h \
system.h sys2.h pathmax.h xalloc.h argmatch.c argmatch.h xstrtoul.c \
full-write.c xstrtoumax.c copy.c copy.h dcfldd.h hash.h hash.c verify.c verify.h \
translate.c translate.h sizeprobe.c sizeprobe.h pattern.c pattern.h util.c util.h \
log.c log.h full-write.h output.c output.h split.c split.h hashformat.c hashformat.h
man_MANS = dcfldd.1
EXTRA_DIST = $(man_MANS)

633
Makefile.in Normal file
View file

@ -0,0 +1,633 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = .
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
LIBOBJDIR =
bin_PROGRAMS = dcfldd$(EXEEXT)
DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
$(srcdir)/Makefile.in $(srcdir)/config.h.in \
$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
config.guess config.sub depcomp install-sh missing
subdir = .
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/configure.in
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
configure.lineno configure.status.lineno
mkinstalldirs = $(install_sh) -d
CONFIG_HEADER = config.h
CONFIG_CLEAN_FILES =
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
PROGRAMS = $(bin_PROGRAMS)
am_dcfldd_OBJECTS = dcfldd.$(OBJEXT) md5.$(OBJEXT) sha1.$(OBJEXT) \
sha2.$(OBJEXT) human.$(OBJEXT) long-options.$(OBJEXT) \
safe-read.$(OBJEXT) xstrtol.$(OBJEXT) version-etc.$(OBJEXT) \
argmatch.$(OBJEXT) xstrtoul.$(OBJEXT) full-write.$(OBJEXT) \
xstrtoumax.$(OBJEXT) copy.$(OBJEXT) hash.$(OBJEXT) \
verify.$(OBJEXT) translate.$(OBJEXT) sizeprobe.$(OBJEXT) \
pattern.$(OBJEXT) util.$(OBJEXT) log.$(OBJEXT) \
output.$(OBJEXT) split.$(OBJEXT) hashformat.$(OBJEXT)
dcfldd_OBJECTS = $(am_dcfldd_OBJECTS)
dcfldd_LDADD = $(LDADD)
DEFAULT_INCLUDES = -I. -I$(srcdir) -I.
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(dcfldd_SOURCES)
DIST_SOURCES = $(dcfldd_SOURCES)
man1dir = $(mandir)/man1
NROFF = nroff
MANS = $(man_MANS)
ETAGS = etags
CTAGS = ctags
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
distdir = $(PACKAGE)-$(VERSION)
top_distdir = $(distdir)
am__remove_distdir = \
{ test ! -d $(distdir) \
|| { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \
&& rm -fr $(distdir); }; }
DIST_ARCHIVES = $(distdir).tar.gz
GZIP_ENV = --best
distuninstallcheck_listfiles = find . -type f -print
distcleancheck_listfiles = find . -type f -print
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
RANLIB = @RANLIB@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
ac_ct_CC = @ac_ct_CC@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
dcfldd_SOURCES = dcfldd.c md5.c md5.h sha1.c sha1.h sha2.c sha2.h human.c human.h \
getpagesize.h long-options.c long-options.h safe-read.c safe-read.h xstrtol.c \
xstrtol.h version-etc.c version-etc.h \
system.h sys2.h pathmax.h xalloc.h argmatch.c argmatch.h xstrtoul.c \
full-write.c xstrtoumax.c copy.c copy.h dcfldd.h hash.h hash.c verify.c verify.h \
translate.c translate.h sizeprobe.c sizeprobe.h pattern.c pattern.h util.c util.h \
log.c log.h full-write.h output.c output.h split.c split.h hashformat.c hashformat.h
man_MANS = dcfldd.1
EXTRA_DIST = $(man_MANS)
all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-am
.SUFFIXES:
.SUFFIXES: .c .o .obj
am--refresh:
@:
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
echo ' cd $(srcdir) && $(AUTOMAKE) --gnu '; \
cd $(srcdir) && $(AUTOMAKE) --gnu \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
echo ' $(SHELL) ./config.status'; \
$(SHELL) ./config.status;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
$(SHELL) ./config.status --recheck
$(top_srcdir)/configure: $(am__configure_deps)
cd $(srcdir) && $(AUTOCONF)
$(ACLOCAL_M4): $(am__aclocal_m4_deps)
cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
config.h: stamp-h1
@if test ! -f $@; then \
rm -f stamp-h1; \
$(MAKE) stamp-h1; \
else :; fi
stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
@rm -f stamp-h1
cd $(top_builddir) && $(SHELL) ./config.status config.h
$(srcdir)/config.h.in: $(am__configure_deps)
cd $(top_srcdir) && $(AUTOHEADER)
rm -f stamp-h1
touch $@
distclean-hdr:
-rm -f config.h stamp-h1
install-binPROGRAMS: $(bin_PROGRAMS)
@$(NORMAL_INSTALL)
test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)"
@list='$(bin_PROGRAMS)'; for p in $$list; do \
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
if test -f $$p \
; then \
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \
$(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \
else :; fi; \
done
uninstall-binPROGRAMS:
@$(NORMAL_UNINSTALL)
@list='$(bin_PROGRAMS)'; for p in $$list; do \
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \
rm -f "$(DESTDIR)$(bindir)/$$f"; \
done
clean-binPROGRAMS:
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
dcfldd$(EXEEXT): $(dcfldd_OBJECTS) $(dcfldd_DEPENDENCIES)
@rm -f dcfldd$(EXEEXT)
$(LINK) $(dcfldd_LDFLAGS) $(dcfldd_OBJECTS) $(dcfldd_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/argmatch.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copy.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dcfldd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/full-write.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hash.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hashformat.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/human.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/long-options.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/output.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pattern.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/safe-read.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sizeprobe.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/split.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translate.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/verify.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/version-etc.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrtol.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrtoul.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xstrtoumax.Po@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
uninstall-info-am:
install-man1: $(man1_MANS) $(man_MANS)
@$(NORMAL_INSTALL)
test -z "$(man1dir)" || $(mkdir_p) "$(DESTDIR)$(man1dir)"
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \
else file=$$i; fi; \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
$(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst"; \
done
uninstall-man1:
@$(NORMAL_UNINSTALL)
@list='$(man1_MANS) $(dist_man1_MANS) $(nodist_man1_MANS)'; \
l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \
for i in $$l2; do \
case "$$i" in \
*.1*) list="$$list $$i" ;; \
esac; \
done; \
for i in $$list; do \
ext=`echo $$i | sed -e 's/^.*\\.//'`; \
case "$$ext" in \
1*) ;; \
*) ext='1' ;; \
esac; \
inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \
inst=`echo $$inst | sed -e 's/^.*\///'`; \
inst=`echo $$inst | sed '$(transform)'`.$$ext; \
echo " rm -f '$(DESTDIR)$(man1dir)/$$inst'"; \
rm -f "$(DESTDIR)$(man1dir)/$$inst"; \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
$(am__remove_distdir)
mkdir $(distdir)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \
|| chmod -R a+r $(distdir)
dist-gzip: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
dist-bzip2: distdir
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
$(am__remove_distdir)
dist-tarZ: distdir
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
$(am__remove_distdir)
dist-shar: distdir
shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
$(am__remove_distdir)
dist-zip: distdir
-rm -f $(distdir).zip
zip -rq $(distdir).zip $(distdir)
$(am__remove_distdir)
dist dist-all: distdir
tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
$(am__remove_distdir)
# This target untars the dist file and tries a VPATH configuration. Then
# it guarantees that the distribution is self-contained by making another
# tarfile.
distcheck: dist
case '$(DIST_ARCHIVES)' in \
*.tar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
*.tar.bz2*) \
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
*.tar.Z*) \
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
*.shar.gz*) \
GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
*.zip*) \
unzip $(distdir).zip ;;\
esac
chmod -R a-w $(distdir); chmod a+w $(distdir)
mkdir $(distdir)/_build
mkdir $(distdir)/_inst
chmod a-w $(distdir)
dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
&& cd $(distdir)/_build \
&& ../configure --srcdir=.. --prefix="$$dc_install_base" \
$(DISTCHECK_CONFIGURE_FLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) \
&& $(MAKE) $(AM_MAKEFLAGS) dvi \
&& $(MAKE) $(AM_MAKEFLAGS) check \
&& $(MAKE) $(AM_MAKEFLAGS) install \
&& $(MAKE) $(AM_MAKEFLAGS) installcheck \
&& $(MAKE) $(AM_MAKEFLAGS) uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
distuninstallcheck \
&& chmod -R a-w "$$dc_install_base" \
&& ({ \
(cd ../.. && umask 077 && mkdir "$$dc_destdir") \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
} || { rm -rf "$$dc_destdir"; exit 1; }) \
&& rm -rf "$$dc_destdir" \
&& $(MAKE) $(AM_MAKEFLAGS) dist \
&& rm -rf $(DIST_ARCHIVES) \
&& $(MAKE) $(AM_MAKEFLAGS) distcleancheck
$(am__remove_distdir)
@(echo "$(distdir) archives ready for distribution: "; \
list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}'
distuninstallcheck:
@cd $(distuninstallcheck_dir) \
&& test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
|| { echo "ERROR: files left after uninstall:" ; \
if test -n "$(DESTDIR)"; then \
echo " (check DESTDIR support)"; \
fi ; \
$(distuninstallcheck_listfiles) ; \
exit 1; } >&2
distcleancheck: distclean
@if test '$(srcdir)' = . ; then \
echo "ERROR: distcleancheck can only run from a VPATH build" ; \
exit 1 ; \
fi
@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
|| { echo "ERROR: files left in build directory after distclean:" ; \
$(distcleancheck_listfiles) ; \
exit 1; } >&2
check-am: all-am
check: check-am
all-am: Makefile $(PROGRAMS) $(MANS) config.h
installdirs:
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-am
install-exec: install-exec-am
install-data: install-data-am
uninstall: uninstall-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-am
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-am
clean-am: clean-binPROGRAMS clean-generic mostlyclean-am
distclean: distclean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-hdr distclean-tags
dvi: dvi-am
dvi-am:
html: html-am
info: info-am
info-am:
install-data-am: install-man
install-exec-am: install-binPROGRAMS
install-info: install-info-am
install-man: install-man1
installcheck-am:
maintainer-clean: maintainer-clean-am
-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-rm -rf $(top_srcdir)/autom4te.cache
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-am
mostlyclean-am: mostlyclean-compile mostlyclean-generic
pdf: pdf-am
pdf-am:
ps: ps-am
ps-am:
uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man
uninstall-man: uninstall-man1
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
clean-binPROGRAMS clean-generic ctags dist dist-all dist-bzip2 \
dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \
distclean-compile distclean-generic distclean-hdr \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-binPROGRAMS install-data install-data-am install-exec \
install-exec-am install-info install-info-am install-man \
install-man1 install-strip installcheck installcheck-am \
installdirs maintainer-clean maintainer-clean-generic \
mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \
ps ps-am tags uninstall uninstall-am uninstall-binPROGRAMS \
uninstall-info-am uninstall-man uninstall-man1
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

0
NEWS Normal file
View file

9
README Normal file
View file

@ -0,0 +1,9 @@
dcfldd is a modified version of GNU dd. The major features added
are hashing, fast disk wiping (through patterns) and status output.
dcfldd was originally created by Nicholas Harbour from the
DoD Computer Forensics Laboratory (DCFL). Nick Harbour still maintains
the package, although he is no longer affiliated with the DCFL.
Send any feature requests or ideas to the author at
<nicholasharbour@yahoo.com>.

862
aclocal.m4 vendored Normal file
View file

@ -0,0 +1,862 @@
# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION so it can be traced.
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.9.6])])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
#
# Of course, Automake must honor this variable whenever it calls a
# tool from the auxiliary directory. The problem is that $srcdir (and
# therefore $ac_aux_dir as well) can be either absolute or relative,
# depending on how configure is run. This is pretty annoying, since
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
# source directory, any form will work fine, but in subdirectories a
# relative path needs to be adjusted first.
#
# $ac_aux_dir/missing
# fails when called from a subdirectory if $ac_aux_dir is relative
# $top_srcdir/$ac_aux_dir/missing
# fails if $ac_aux_dir is absolute,
# fails when called from a subdirectory in a VPATH build with
# a relative $ac_aux_dir
#
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
# are both prefixed by $srcdir. In an in-source build this is usually
# harmless because $srcdir is `.', but things will broke when you
# start a VPATH build or use an absolute $srcdir.
#
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
# and then we would define $MISSING as
# MISSING="\${SHELL} $am_aux_dir/missing"
# This will work as long as MISSING is not called from configure, because
# unfortunately $(top_srcdir) has no meaning in configure.
# However there are other variables, like CC, which are often used in
# configure, and could therefore not use this "fixed" $ac_aux_dir.
#
# Another solution, used here, is to always expand $ac_aux_dir to an
# absolute PATH. The drawback is that using absolute paths prevent a
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 7
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ(2.52)dnl
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])
AC_SUBST([$1_FALSE])
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 8
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "GCJ", or "OBJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
# dependency, and given that the user is not expected to run this macro,
# just rely on AC_PROG_CC.
AC_DEFUN([_AM_DEPENDENCIES],
[AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
[$1], CXX, [depcc="$CXX" am_compiler_list=],
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named `D' -- because `-MD' means `put the output
# in D'.
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
cp "$am_depcomp" conftest.dir
cd conftest.dir
# We will build objects and dependencies in a subdirectory because
# it helps to detect inapplicable dependency modes. For instance
# both Tru64's cc and ICC support -MD to output dependencies as a
# side effect of compilation, but ICC will put the dependencies in
# the current directory while Tru64 will put them in the object
# directory.
mkdir sub
am_cv_$1_dependencies_compiler_type=none
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
fi
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
# we should not choose a depcomp mode which is confused by this.
#
# We need to recreate these files for each test, as the compiler may
# overwrite some of them when testing with obscure command lines.
# This happens at least with the AIX C compiler.
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
# Solaris 8's {/usr,}/bin/sh.
touch sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
case $depmode in
nosideeffect)
# after this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
none) break ;;
esac
# We check with `-c' and `-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle `-M -o', and we need to detect this.
if depmode=$depmode \
source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
am_cv_$1_dependencies_compiler_type=$depmode
break
fi
fi
done
cd ..
rm -rf conftest.dir
else
am_cv_$1_dependencies_compiler_type=none
fi
])
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
AM_CONDITIONAL([am__fastdep$1], [
test "x$enable_dependency_tracking" != xno \
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
])
# AM_SET_DEPDIR
# -------------
# Choose a directory name for dependency files.
# This macro is AC_REQUIREd in _AM_DEPENDENCIES
AC_DEFUN([AM_SET_DEPDIR],
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
])
# AM_DEP_TRACK
# ------------
AC_DEFUN([AM_DEP_TRACK],
[AC_ARG_ENABLE(dependency-tracking,
[ --disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors])
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
AC_SUBST([AMDEPBACKSLASH])
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#serial 3
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[for mf in $CONFIG_FILES; do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named `Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# So let's grep whole file.
if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running `make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# When using ansi2knr, U may be empty or an underscore; expand it
U=`sed -n 's/^U = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
done
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
# AM_OUTPUT_DEPENDENCY_COMMANDS
# -----------------------------
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each `.P' file that we will
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
])
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 8
# AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS.
AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 12
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
# The call with PACKAGE and VERSION arguments is the old style
# call (pre autoconf-2.50), which is being phased out. PACKAGE
# and VERSION should now be passed to AC_INIT and removed from
# the call to AM_INIT_AUTOMAKE.
# We support both call styles for the transition. After
# the next Automake release, Autoconf can make the AC_INIT
# arguments mandatory, and then we can depend on a new Autoconf
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.58])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
# test to see if srcdir already configured
if test "`cd $srcdir && pwd`" != "`pwd`" &&
test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
# test whether we have cygpath
if test -z "$CYGPATH_W"; then
if (cygpath --version) >/dev/null 2>/dev/null; then
CYGPATH_W='cygpath -w'
else
CYGPATH_W=echo
fi
fi
AC_SUBST([CYGPATH_W])
# Define the identity of the package.
dnl Distinguish between old-style and new-style calls.
m4_ifval([$2],
[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
AC_SUBST([PACKAGE], [$1])dnl
AC_SUBST([VERSION], [$2])],
[_AM_SET_OPTIONS([$1])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
_AM_IF_OPTION([no-define],,
[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
# Some tools Automake needs.
AC_REQUIRE([AM_SANITY_CHECK])dnl
AC_REQUIRE([AC_ARG_PROGRAM])dnl
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
AM_MISSING_PROG(AUTOCONF, autoconf)
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
AM_MISSING_PROG(AUTOHEADER, autoheader)
AM_MISSING_PROG(MAKEINFO, makeinfo)
AM_PROG_INSTALL_SH
AM_PROG_INSTALL_STRIP
AC_REQUIRE([AM_PROG_MKDIR_P])dnl
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
[_AM_PROG_TAR([v7])])])
_AM_IF_OPTION([no-dependencies],,
[AC_PROVIDE_IFELSE([AC_PROG_CC],
[_AM_DEPENDENCIES(CC)],
[define([AC_PROG_CC],
defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[_AM_DEPENDENCIES(CXX)],
[define([AC_PROG_CXX],
defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
])
])
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
# loop where config.status creates the headers, so we can generate
# our stamp files there.
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
[# Compute $1's index in $config_headers.
_am_stamp_count=1
for _am_header in $config_headers :; do
case $_am_header in
$1 | $1:* )
break ;;
* )
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
esac
done
echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_SH
# ------------------
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
install_sh=${install_sh-"$am_aux_dir/install-sh"}
AC_SUBST(install_sh)])
# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# Check whether the underlying file-system supports filenames
# with a leading dot. For instance MS-DOS doesn't.
AC_DEFUN([AM_SET_LEADING_DOT],
[rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# AM_MAKE_INCLUDE()
# -----------------
# Check to see how make treats includes.
AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo done
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
AC_MSG_CHECKING([for style of include used by $am_make])
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# We grep out `Entering directory' and `Leaving directory'
# messages which can occur if `w' ends up in MAKEFLAGS.
# In particular we don't look at `^make:' because GNU make might
# be invoked under some other name (usually "gmake"), in which
# case it prints its new name instead of `make'.
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
am__include=include
am__quote=
_am_result=GNU
fi
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
am__include=.include
am__quote="\""
_am_result=BSD
fi
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# AM_MISSING_PROG(NAME, PROGRAM)
# ------------------------------
AC_DEFUN([AM_MISSING_PROG],
[AC_REQUIRE([AM_MISSING_HAS_RUN])
$1=${$1-"${am_missing_run}$2"}
AC_SUBST($1)])
# AM_MISSING_HAS_RUN
# ------------------
# Define MISSING if not defined so far and test if it supports --run.
# If it does, set am_missing_run to use it, otherwise, to nothing.
AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
# Use eval to expand $SHELL
if eval "$MISSING --run true"; then
am_missing_run="$MISSING --run "
else
am_missing_run=
AC_MSG_WARN([`missing' script is too old or missing])
fi
])
# Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_MKDIR_P
# ---------------
# Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise.
#
# Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories
# created by `make install' are always world readable, even if the
# installer happens to have an overly restrictive umask (e.g. 077).
# This was a mistake. There are at least two reasons why we must not
# use `-m 0755':
# - it causes special bits like SGID to be ignored,
# - it may be too restrictive (some setups expect 775 directories).
#
# Do not use -m 0755 and let people choose whatever they expect by
# setting umask.
#
# We cannot accept any implementation of `mkdir' that recognizes `-p'.
# Some implementations (such as Solaris 8's) are not thread-safe: if a
# parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c'
# concurrently, both version can detect that a/ is missing, but only
# one can create it and the other will error out. Consequently we
# restrict ourselves to GNU make (using the --version option ensures
# this.)
AC_DEFUN([AM_PROG_MKDIR_P],
[if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
# We used to keeping the `.' as first argument, in order to
# allow $(mkdir_p) to be used without argument. As in
# $(mkdir_p) $(somedir)
# where $(somedir) is conditionally defined. However this is wrong
# for two reasons:
# 1. if the package is installed by a user who cannot write `.'
# make install will fail,
# 2. the above comment should most certainly read
# $(mkdir_p) $(DESTDIR)$(somedir)
# so it does not work when $(somedir) is undefined and
# $(DESTDIR) is not.
# To support the latter case, we have to write
# test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir),
# so the `.' trick is pointless.
mkdir_p='mkdir -p --'
else
# On NextStep and OpenStep, the `mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because `.' already
# exists.
for d in ./-p ./--version;
do
test -d $d && rmdir $d
done
# $(mkinstalldirs) is defined by Automake if mkinstalldirs exists.
if test -f "$ac_aux_dir/mkinstalldirs"; then
mkdir_p='$(mkinstalldirs)'
else
mkdir_p='$(install_sh) -d'
fi
fi
AC_SUBST([mkdir_p])])
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# _AM_MANGLE_OPTION(NAME)
# -----------------------
AC_DEFUN([_AM_MANGLE_OPTION],
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
# _AM_SET_OPTION(NAME)
# ------------------------------
# Set option NAME. Presently that only means defining a flag for this option.
AC_DEFUN([_AM_SET_OPTION],
[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
# _AM_SET_OPTIONS(OPTIONS)
# ----------------------------------
# OPTIONS is a space-separated list of Automake options.
AC_DEFUN([_AM_SET_OPTIONS],
[AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
# -------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# AM_SANITY_CHECK
# ---------------
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftest.file
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
if test "$[*]" = "X"; then
# -L didn't work.
set X `ls -t $srcdir/configure conftest.file`
fi
rm -f conftest.file
if test "$[*]" != "X $srcdir/configure conftest.file" \
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "$[2]" = conftest.file
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
AC_MSG_RESULT(yes)])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_STRIP
# ---------------------
# One issue with vendor `install' (even GNU) is that you can't
# specify the program used to strip binaries. This is especially
# annoying in cross-compiling environments, where the build's strip
# is unlikely to handle the host's binaries.
# Fortunately install-sh will honor a STRIPPROG variable, so we
# always use install-sh in `make install-strip', and initialize
# STRIPPROG with the value of the STRIP variable (set by the user).
AC_DEFUN([AM_PROG_INSTALL_STRIP],
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
# Installed binaries are usually stripped using `strip' when the user
# run `make install-strip'. However `strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the `STRIP' environment variable to overrule this program.
dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
if test "$cross_compiling" != no; then
AC_CHECK_TOOL([STRIP], [strip], :)
fi
INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# _AM_PROG_TAR(FORMAT)
# --------------------
# Check how to create a tarball in format FORMAT.
# FORMAT should be one of `v7', `ustar', or `pax'.
#
# Substitute a variable $(am__tar) that is a command
# writing to stdout a FORMAT-tarball containing the directory
# $tardir.
# tardir=directory && $(am__tar) > result.tar
#
# Substitute a variable $(am__untar) that extract such
# a tarball read from stdin.
# $(am__untar) < result.tar
AC_DEFUN([_AM_PROG_TAR],
[# Always define AMTAR for backward compatibility.
AM_MISSING_PROG([AMTAR], [tar])
m4_if([$1], [v7],
[am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
[m4_case([$1], [ustar],, [pax],,
[m4_fatal([Unknown tar format])])
AC_MSG_CHECKING([how to create a $1 tar archive])
# Loop over all known methods to create a tar archive until one works.
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
# Do not fold the above two line into one, because Tru64 sh and
# Solaris sh will not grok spaces in the rhs of `-'.
for _am_tool in $_am_tools
do
case $_am_tool in
gnutar)
for _am_tar in tar gnutar gtar;
do
AM_RUN_LOG([$_am_tar --version]) && break
done
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
am__untar="$_am_tar -xf -"
;;
plaintar)
# Must skip GNU tar: if it does not support --format= it doesn't create
# ustar tarball either.
(tar --version) >/dev/null 2>&1 && continue
am__tar='tar chf - "$$tardir"'
am__tar_='tar chf - "$tardir"'
am__untar='tar xf -'
;;
pax)
am__tar='pax -L -x $1 -w "$$tardir"'
am__tar_='pax -L -x $1 -w "$tardir"'
am__untar='pax -r'
;;
cpio)
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
am__untar='cpio -i -H $1 -d'
;;
none)
am__tar=false
am__tar_=false
am__untar=false
;;
esac
# If the value was cached, stop now. We just wanted to have am__tar
# and am__untar set.
test -n "${am_cv_prog_tar_$1}" && break
# tar/untar a dummy directory, and stop if the command works
rm -rf conftest.dir
mkdir conftest.dir
echo GrepMe > conftest.dir/file
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
rm -rf conftest.dir
if test -s conftest.tar; then
AM_RUN_LOG([$am__untar <conftest.tar])
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
fi
done
rm -rf conftest.dir
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR

305
argmatch.c Normal file
View file

@ -0,0 +1,305 @@
/* argmatch.c -- find a match for a string in an array
Copyright (C) 1990, 1998, 1999 Free Software Foundation, Inc.
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, 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. */
/* Written by David MacKenzie <djm@ai.mit.edu>
Modified by Akim Demaille <demaille@inf.enst.fr> */
#include "dcfldd.h"
#include "argmatch.h"
#include "log.h"
#include <stdio.h>
#ifdef STDC_HEADERS
# include <string.h>
#endif
#if HAVE_LOCALE_H
# include <locale.h>
#endif
#if ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
/* When reporting an invalid argument, show nonprinting characters
by using the quoting style ARGMATCH_QUOTING_STYLE. Do not use
literal_quoting_style. */
#ifndef ARGMATCH_QUOTING_STYLE
# define ARGMATCH_QUOTING_STYLE locale_quoting_style
#endif
/* The following test is to work around the gross typo in
systems like Sony NEWS-OS Release 4.0C, whereby EXIT_FAILURE
is defined to 0, not 1. */
#if !EXIT_FAILURE
# undef EXIT_FAILURE
# define EXIT_FAILURE 1
#endif
/* Non failing version of argmatch call this function after failing. */
#ifndef ARGMATCH_DIE
# define ARGMATCH_DIE exit (EXIT_FAILURE)
#endif
#ifdef ARGMATCH_DIE_DECL
ARGMATCH_DIE_DECL;
#endif
static void
__argmatch_die (void)
{
ARGMATCH_DIE;
}
/* Used by XARGMATCH and XARGCASEMATCH. See description in argmatch.h.
Default to __argmatch_die, but allow caller to change this at run-time. */
argmatch_exit_fn argmatch_die = __argmatch_die;
/* If ARG is an unambiguous match for an element of the
null-terminated array ARGLIST, return the index in ARGLIST
of the matched element, else -1 if it does not match any element
or -2 if it is ambiguous (is a prefix of more than one element).
If SENSITIVE, comparison is case sensitive.
If VALLIST is none null, use it to resolve ambiguities limited to
synonyms, i.e., for
"yes", "yop" -> 0
"no", "nope" -> 1
"y" is a valid argument, for `0', and "n" for `1'. */
static int
__argmatch_internal (const char *arg, const char *const *arglist,
const char *vallist, size_t valsize,
int case_sensitive)
{
int i; /* Temporary index in ARGLIST. */
size_t arglen; /* Length of ARG. */
int matchind = -1; /* Index of first nonexact match. */
int ambiguous = 0; /* If nonzero, multiple nonexact match(es). */
arglen = strlen (arg);
/* Test all elements for either exact match or abbreviated matches. */
for (i = 0; arglist[i]; i++)
{
if (case_sensitive
? !strncmp (arglist[i], arg, arglen)
: !strncasecmp (arglist[i], arg, arglen))
{
if (strlen (arglist[i]) == arglen)
/* Exact match found. */
return i;
else if (matchind == -1)
/* First nonexact match found. */
matchind = i;
else
{
/* Second nonexact match found. */
if (vallist == NULL
|| memcmp (vallist + valsize * matchind,
vallist + valsize * i, valsize))
{
/* There is a real ambiguity, or we could not
disambiguate. */
ambiguous = 1;
}
}
}
}
if (ambiguous)
return -2;
else
return matchind;
}
/* argmatch - case sensitive version */
int
argmatch (const char *arg, const char *const *arglist,
const char *vallist, size_t valsize)
{
return __argmatch_internal (arg, arglist, vallist, valsize, 1);
}
/* argcasematch - case insensitive version */
int
argcasematch (const char *arg, const char *const *arglist,
const char *vallist, size_t valsize)
{
return __argmatch_internal (arg, arglist, vallist, valsize, 0);
}
/* Error reporting for argmatch.
CONTEXT is a description of the type of entity that was being matched.
VALUE is the invalid value that was given.
PROBLEM is the return value from argmatch. */
void
argmatch_invalid (const char *context, const char *value, int problem)
{
char *format = (problem == -1
? "invalid argument %s for `%s'"
: "ambiguous argument %s for `%s'");
log_info(format, value, context);
}
/* List the valid arguments for argmatch.
ARGLIST is the same as in argmatch.
VALLIST is a pointer to an array of values.
VALSIZE is the size of the elements of VALLIST */
void
argmatch_valid (const char *const *arglist,
const char *vallist, size_t valsize)
{
int i;
const char *last_val = NULL;
/* We try to put synonyms on the same line. The assumption is that
synonyms follow each other */
fprintf (stderr, "Valid arguments are:");
for (i = 0; arglist[i]; i++)
if ((i == 0)
|| memcmp (last_val, vallist + valsize * i, valsize))
{
log_info("\n - `%s'", arglist[i]);
last_val = vallist + valsize * i;
}
else
{
log_info(", `%s'", arglist[i]);
}
putc ('\n', stderr);
}
/* Never failing versions of the previous functions.
CONTEXT is the context for which argmatch is called (e.g.,
"--version-control", or "$VERSION_CONTROL" etc.). Upon failure,
calls the (supposed never to return) function EXIT_FN. */
int
__xargmatch_internal (const char *context,
const char *arg, const char *const *arglist,
const char *vallist, size_t valsize,
int case_sensitive,
argmatch_exit_fn exit_fn)
{
int res = __argmatch_internal (arg, arglist,
vallist, valsize,
case_sensitive);
if (res >= 0)
/* Success. */
return res;
/* We failed. Explain why. */
argmatch_invalid (context, arg, res);
argmatch_valid (arglist, vallist, valsize);
(*exit_fn) ();
return -1; /* To please the compilers. */
}
/* Look for VALUE in VALLIST, an array of objects of size VALSIZE and
return the first corresponding argument in ARGLIST */
const char *
argmatch_to_argument (const char *value,
const char *const *arglist,
const char *vallist, size_t valsize)
{
int i;
for (i = 0; arglist[i]; i++)
if (!memcmp (value, vallist + valsize * i, valsize))
return arglist[i];
return NULL;
}
#ifdef TEST
/*
* Based on "getversion.c" by David MacKenzie <djm@gnu.ai.mit.edu>
*/
char *program_name;
extern const char *getenv ();
/* When to make backup files. */
enum backup_type
{
/* Never make backups. */
none,
/* Make simple backups of every file. */
simple,
/* Make numbered backups of files that already have numbered backups,
and simple backups of the others. */
numbered_existing,
/* Make numbered backups of every file. */
numbered
};
/* Two tables describing arguments (keys) and their corresponding
values */
static const char *const backup_args[] =
{
"no", "none", "off",
"simple", "never",
"existing", "nil",
"numbered", "t",
0
};
static const enum backup_type backup_vals[] =
{
none, none, none,
simple, simple,
numbered_existing, numbered_existing,
numbered, numbered
};
int
main (int argc, const char *const *argv)
{
const char *cp;
enum backup_type backup_type = none;
program_name = (char *) argv[0];
if (argc > 2)
{
fprintf(stderr, "Usage: %s [VERSION_CONTROL]\n", program_name);
exit (1);
}
if ((cp = getenv ("VERSION_CONTROL")))
backup_type = XARGCASEMATCH ("$VERSION_CONTROL", cp,
backup_args, backup_vals);
if (argc == 2)
backup_type = XARGCASEMATCH (program_name, argv[1],
backup_args, backup_vals);
printf ("The version control is `%s'\n",
ARGMATCH_TO_ARGUMENT (backup_type, backup_args, backup_vals));
return 0;
}
#endif

129
argmatch.h Normal file
View file

@ -0,0 +1,129 @@
/* argmatch.h -- definitions and prototypes for argmatch.c
Copyright (C) 1990, 1998, 1999 Free Software Foundation, Inc.
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, 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. */
/* Written by David MacKenzie <djm@ai.mit.edu>
Modified by Akim Demaille <demaille@inf.enst.fr> */
#ifndef ARGMATCH_H_
# define ARGMATCH_H_ 1
# if HAVE_CONFIG_H
# include <config.h>
# endif
# include <sys/types.h>
# ifndef PARAMS
# if PROTOTYPES || (defined (__STDC__) && __STDC__)
# define PARAMS(args) args
# else
# define PARAMS(args) ()
# endif /* GCC. */
# endif /* Not PARAMS. */
/* Assert there are as many real arguments as there are values
(argument list ends with a NULL guard). There is no execution
cost, since it will be statically evalauted to `assert (0)' or
`assert (1)'. Unfortunately there is no -Wassert-0. */
# undef ARRAY_CARDINALITY
# define ARRAY_CARDINALITY(Array) (sizeof ((Array)) / sizeof (*(Array)))
# define ARGMATCH_ASSERT(Arglist, Vallist) \
assert (ARRAY_CARDINALITY ((Arglist)) == ARRAY_CARDINALITY ((Vallist)) + 1)
/* Return the index of the element of ARGLIST (NULL terminated) that
matches with ARG. If VALLIST is not NULL, then use it to resolve
false ambiguities (i.e., different matches of ARG but corresponding
to the same values in VALLIST). */
int argmatch
PARAMS ((const char *arg, const char *const *arglist,
const char *vallist, size_t valsize));
int argcasematch
PARAMS ((const char *arg, const char *const *arglist,
const char *vallist, size_t valsize));
# define ARGMATCH(Arg, Arglist, Vallist) \
argmatch ((Arg), (Arglist), (const char *) (Vallist), sizeof (*(Vallist)))
# define ARGCASEMATCH(Arg, Arglist, Vallist) \
argcasematch ((Arg), (Arglist), (const char *) (Vallist), sizeof (*(Vallist)))
/* xargmatch calls this function when it fails. This function should not
return. By default, this is a function that calls ARGMATCH_DIE which
in turn defaults to `exit (EXIT_FAILURE)'. */
typedef void (*argmatch_exit_fn) PARAMS ((void));
extern argmatch_exit_fn argmatch_die;
/* Report on stderr why argmatch failed. Report correct values. */
void argmatch_invalid
PARAMS ((const char *context, const char *value, int problem));
/* Left for compatibility with the old name invalid_arg */
# define invalid_arg(Context, Value, Problem) \
argmatch_invalid ((Context), (Value), (Problem))
/* Report on stderr the list of possible arguments. */
void argmatch_valid
PARAMS ((const char *const *arglist,
const char *vallist, size_t valsize));
# define ARGMATCH_VALID(Arglist, Vallist) \
argmatch_valid (Arglist, (const char *) Vallist, sizeof (*(Vallist)))
/* Same as argmatch, but upon failure, reports a explanation on the
failure, and exits using the function EXIT_FN. */
int __xargmatch_internal
PARAMS ((const char *context,
const char *arg, const char *const *arglist,
const char *vallist, size_t valsize,
int case_sensitive, argmatch_exit_fn exit_fn));
/* Programmer friendly interface to __xargmatch_internal. */
# define XARGMATCH(Context, Arg, Arglist, Vallist) \
(Vallist [__xargmatch_internal ((Context), (Arg), (Arglist), \
(const char *) (Vallist), \
sizeof (*(Vallist)), \
1, argmatch_die)])
# define XARGCASEMATCH(Context, Arg, Arglist, Vallist) \
(Vallist [__xargmatch_internal ((Context), (Arg), (Arglist), \
(const char *) (Vallist), \
sizeof (*(Vallist)), \
0, argmatch_die)])
/* Convert a value into a corresponding argument. */
const char *argmatch_to_argument
PARAMS ((char const *value, const char *const *arglist,
const char *vallist, size_t valsize));
# define ARGMATCH_TO_ARGUMENT(Value, Arglist, Vallist) \
argmatch_to_argument ((char const *) &(Value), (Arglist), \
(const char *) (Vallist), sizeof (*(Vallist)))
#endif /* ARGMATCH_H_ */

1447
config.guess vendored Executable file

File diff suppressed because it is too large Load diff

77
config.h.in Normal file
View file

@ -0,0 +1,77 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* Define to 1 if you have the declaration of `strndup', and to 0 if you
don't. */
#undef HAVE_DECL_STRNDUP
/* Define to 1 if you have the declaration of `strtol', and to 0 if you don't.
*/
#undef HAVE_DECL_STRTOL
/* Define to 1 if you have the declaration of `strtoul', and to 0 if you
don't. */
#undef HAVE_DECL_STRTOUL
/* Define to 1 if you have the declaration of `strtoumax', and to 0 if you
don't. */
#undef HAVE_DECL_STRTOUMAX
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* Version number of package */
#undef VERSION
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `long' if <sys/types.h> does not define. */
#undef off_t
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t

1555
config.sub vendored Executable file

File diff suppressed because it is too large Load diff

5570
configure vendored Executable file

File diff suppressed because it is too large Load diff

24
configure.in Normal file
View file

@ -0,0 +1,24 @@
dnl Process this file with autoconf to produce a configure script. -*-m4-*-
AC_INIT(dcfldd.c)
AM_CONFIG_HEADER(config.h)
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([dcfldd], [1.3.4-1])
AC_PROG_CC
AC_PROG_CPP
AC_PROG_GCC_TRADITIONAL
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_HEADER_STDC
AC_C_CONST
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_CHECK_DECLS([strtol, strtoul, strtoumax, strndup])
AC_OUTPUT(Makefile)

383
copy.c Normal file
View file

@ -0,0 +1,383 @@
/* $Id: copy.c,v 1.6 2005/05/19 20:59:12 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#include "dcfldd.h"
#include <sys/types.h>
#include <stdlib.h>
#include <time.h>
#include "hash.h"
#include "getpagesize.h"
#include "safe-read.h"
#include "full-write.h"
#include "translate.h"
#include "sizeprobe.h"
#include "pattern.h"
#include "util.h"
#include "log.h"
#include "output.h"
static void write_output(void);
static void copy_simple(unsigned char const *, int);
static void copy_with_block(unsigned char const *, size_t);
static void copy_with_unblock(unsigned char const *, size_t);
/* Output buffer. */
unsigned char *obuf;
/* Current index into `obuf'. */
static size_t oc;
/* Index into current line, for `conv=block' and `conv=unblock'. */
static size_t col;
/* Write, then empty, the output buffer `obuf'. */
static void write_output(void)
{
/*int nwritten = full_write(STDOUT_FILENO, obuf, output_blocksize); */
int nwritten = outputlist_write(obuf, output_blocksize);
if (nwritten != output_blocksize) {
if (nwritten > 0)
w_partial++;
quit(1);
}
else
w_full++;
oc = 0;
}
/* Copy NREAD bytes of BUF, with no conversions. */
static void copy_simple(unsigned char const *buf, int nread)
{
int nfree; /* Number of unused bytes in `obuf'. */
const unsigned char *start = buf; /* First uncopied char in BUF. */
do {
nfree = output_blocksize - oc;
if (nfree > nread)
nfree = nread;
memcpy((char *) (obuf + oc), (char *) start, nfree);
nread -= nfree; /* Update the number of bytes left to copy. */
start += nfree;
oc += nfree;
if (oc >= output_blocksize)
write_output();
} while (nread > 0);
}
/* Copy NREAD bytes of BUF, doing conv=block
(pad newline-terminated records to `conversion_blocksize',
replacing the newline with trailing spaces). */
static void copy_with_block(unsigned char const *buf, size_t nread)
{
size_t i;
for (i = nread; i; i--, buf++) {
if (*buf == newline_character) {
if (col < conversion_blocksize) {
size_t j;
for (j = col; j < conversion_blocksize; j++)
output_char(space_character);
}
col = 0;
} else {
if (col == conversion_blocksize)
r_truncate++;
else if (col < conversion_blocksize)
output_char(*buf);
col++;
}
}
}
/* Copy NREAD bytes of BUF, doing conv=unblock
(replace trailing spaces in `conversion_blocksize'-sized records
with a newline). */
static void copy_with_unblock(unsigned char const *buf, size_t nread)
{
size_t i;
unsigned char c;
static int pending_spaces = 0;
for (i = 0; i < nread; i++) {
c = buf[i];
if (col++ >= conversion_blocksize) {
col = pending_spaces = 0; /* Wipe out any pending spaces. */
i--; /* Push the char back; get it later. */
output_char(newline_character);
} else if (c == space_character)
pending_spaces++;
else {
/* `c' is the character after a run of spaces that were not
at the end of the conversion buffer. Output them. */
while (pending_spaces) {
output_char(space_character);
--pending_spaces;
}
output_char(c);
}
}
}
/* The main loop. */
int dd_copy(void)
{
unsigned char *ibuf, *bufstart; /* Input buffer. */
unsigned char *real_buf; /* real buffer address before alignment */
unsigned char *real_obuf;
ssize_t nread; /* Bytes read in the current block. */
int exit_status = 0;
int input_from_stream = !!input_file;
int input_from_pattern = !input_from_stream;
size_t page_size = getpagesize();
size_t n_bytes_read;
/* Leave at least one extra byte at the beginning and end of `ibuf'
for conv=swab, but keep the buffer address even. But some peculiar
device drivers work only with word-aligned buffers, so leave an
extra two bytes. */
/* Some devices require alignment on a sector or page boundary
(e.g. character disk devices). Align the input buffer to a
page boundary to cover all bases. Note that due to the swab
algorithm, we must have at least one byte in the page before
the input buffer; thus we allocate 2 pages of slop in the
real buffer. 8k above the blocksize shouldn't bother anyone.
The page alignment is necessary on any linux system that supports
either the SGI raw I/O patch or Steven Tweedies raw I/O patch.
It is necessary when accessing raw (i.e. character special) disk
devices on Unixware or other SVR4-derived system. */
real_buf = (unsigned char *) malloc(input_blocksize
+ 2 * SWAB_ALIGN_OFFSET
+ 2 * page_size - 1);
ibuf = real_buf;
ibuf += SWAB_ALIGN_OFFSET; /* allow space for swab */
ibuf = PTR_ALIGN(ibuf, page_size);
/* Init */
if (do_hash)
hash_update(ihashlist, NULL, 0);
if (conversions_mask & C_TWOBUFS) {
/* Page-align the output buffer, too. */
real_obuf = (unsigned char *) malloc(output_blocksize + page_size - 1);
obuf = PTR_ALIGN(real_obuf, page_size);
} else {
real_obuf = NULL;
obuf = ibuf;
}
if (!input_from_pattern)
if (skip_records != 0)
skip(STDIN_FILENO, input_file, skip_records, input_blocksize, ibuf);
if (seek_records != 0) {
outputlist_t *listptr;
for (listptr = outputlist; listptr != NULL; listptr = listptr->next) {
skip(listptr->data.fd, "", seek_records, output_blocksize, obuf);
}
}
if (max_records == 0)
quit(exit_status);
if (input_from_pattern) {
replicate_pattern(pattern, ibuf, input_blocksize);
nread = n_bytes_read = input_blocksize;
}
while (1) {
/* Display an update message */
if (do_status && w_full % update_thresh == 0 && w_full != 0) {
off_t total_bytes = w_full * input_blocksize;
off_t total_mb = total_bytes / 1048576;
if (probe == PROBE_NONE || probed_size == 0)
fprintf(stderr, "\r%llu blocks (%lluMb) written.",
w_full, total_mb);
else {
time_t curr_time = time(NULL);
int seconds = (int)difftime(curr_time, start_time);
off_t probed_mb = probed_size / 1048576;
float fprcnt = total_bytes / (float)probed_size;
float fprcnt_remaining = 1.0 - fprcnt;
int prcnt = (int)(fprcnt * 100);
int seconds_remaining = (int)(seconds *
(fprcnt_remaining / fprcnt));
char secstr[100];
time_left(secstr, sizeof secstr, seconds_remaining);
fprintf(stderr, "\r[%d%% of %lluMb] %llu blocks (%lluMb) written. %s",
prcnt, probed_mb, w_full, total_mb, secstr);
}
}
if (r_partial + r_full >= max_records)
break;
/* Zero the buffer before reading, so that if we get a read error,
whatever data we are able to read is followed by zeros.
This minimizes data loss. */
if (!input_from_pattern) {
if ((conversions_mask & C_SYNC) && (conversions_mask & C_NOERROR))
memset((char *) ibuf,
(conversions_mask & (C_BLOCK | C_UNBLOCK)) ? ' ' : '\0',
input_blocksize);
nread = safe_read(STDIN_FILENO, ibuf, input_blocksize);
}
if (nread == 0)
break; /* EOF. */
if (nread < 0 && !input_from_pattern) {
syscall_error_noexit(input_file);
if (conversions_mask & C_NOERROR)
{
print_stats();
/* Seek past the bad block if possible. */
lseek(STDIN_FILENO, (off_t) input_blocksize, SEEK_CUR);
if (conversions_mask & C_SYNC) {
/* Replace the missing input with null bytes and
proceed normally. */
// EXPERIMENTAL: let's try re-zeroing this buffer
memset((char *) ibuf,
(conversions_mask & (C_BLOCK | C_UNBLOCK)) ? ' ' : '\0',
input_blocksize);
nread = 0;
} else
continue;
} else {
/* Write any partial block. */
exit_status = 2;
break;
}
}
n_bytes_read = nread;
if (do_hash && hashconv == HASHCONV_BEFORE)
hash_update(ihashlist, ibuf, n_bytes_read);
if (n_bytes_read < input_blocksize) {
r_partial++;
if (conversions_mask & C_SYNC) {
if (!(conversions_mask & C_NOERROR))
/* If C_NOERROR, we zeroed the block before reading. */
memset((char *) (ibuf + n_bytes_read),
(conversions_mask & (C_BLOCK | C_UNBLOCK)) ? ' ' : '\0',
input_blocksize - n_bytes_read);
n_bytes_read = input_blocksize;
}
}
else
r_full++;
if (ibuf == obuf) { /* If not C_TWOBUFS. */
/* int nwritten = full_write(STDOUT_FILENO, obuf, n_bytes_read); */
int nwritten = outputlist_write(obuf, n_bytes_read);
if (nwritten < 0)
syscall_error(output_file);
else if (n_bytes_read == input_blocksize)
w_full++;
else
w_partial++;
} else { /* If C_TWOBUFS */
/* Do any translations on the whole buffer at once. */
if (translation_needed)
translate_buffer(ibuf, n_bytes_read);
if (conversions_mask & C_SWAB)
bufstart = swab_buffer(ibuf, &n_bytes_read);
else
bufstart = ibuf;
if (conversions_mask & C_BLOCK)
copy_with_block(bufstart, n_bytes_read);
else if (conversions_mask & C_UNBLOCK)
copy_with_unblock(bufstart, n_bytes_read);
else
copy_simple(bufstart, n_bytes_read);
}
if (do_hash && hashconv == HASHCONV_AFTER)
hash_update(ihashlist, ibuf, n_bytes_read);
}
/* If we have a char left as a result of conv=swab, output it. */
if (char_is_saved) {
if (conversions_mask & C_BLOCK)
copy_with_block(&saved_char, 1);
else if (conversions_mask & C_UNBLOCK)
copy_with_unblock(&saved_char, 1);
else
output_char(saved_char);
}
if ((conversions_mask & C_BLOCK) && col > 0) {
/* If the final input line didn't end with a '\n', pad
the output block to `conversion_blocksize' chars. */
unsigned int i;
for (i = col; i < conversion_blocksize; i++)
output_char(space_character);
}
if ((conversions_mask & C_UNBLOCK) && col == conversion_blocksize)
/* Add a final '\n' if there are exactly `conversion_blocksize'
characters in the final record. */
output_char(newline_character);
/* Write out the last block. */
if (oc != 0) {
/* int nwritten = full_write(STDOUT_FILENO, obuf, oc); */
int nwritten = outputlist_write(obuf, oc);
if (nwritten > 0)
w_partial++;
if (nwritten < 0) {
syscall_error(output_file);
}
}
free(real_buf);
if (real_obuf)
free(real_obuf);
if (do_hash) {
hash_remainder(ihashlist, WINDOW_CTX);
display_totalhash(ihashlist, TOTAL_CTX);
}
return exit_status;
}

29
copy.h Normal file
View file

@ -0,0 +1,29 @@
/* $Id: copy.h,v 1.3 2005/05/13 18:52:06 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#ifndef COPY_H
#define COPY_H
extern int dd_copy(void);
#endif /* COPY_H */

248
dcfldd.1 Normal file
View file

@ -0,0 +1,248 @@
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35.
.TH DCFLDD "1" "February 2006" "dcfldd (dcfldd) 1.3.4" "User Commands"
.SH NAME
dcfldd \- manual page for dcfldd (dcfldd) 1.3.4
.SH SYNOPSIS
.B dcfldd
[\fIOPTION\fR]...
.SH DESCRIPTION
Copy a file, converting and formatting according to the options.
.TP
bs=BYTES
force ibs=BYTES and obs=BYTES
.TP
cbs=BYTES
convert BYTES bytes at a time
.TP
conv=KEYWORDS
convert the file as per the comma separated keyword list
.TP
count=BLOCKS
copy only BLOCKS input blocks
.TP
ibs=BYTES
read BYTES bytes at a time
.TP
if=FILE
read from FILE instead of stdin
.TP
obs=BYTES
write BYTES bytes at a time
.TP
of=FILE
write to FILE instead of stdout
.IP
NOTE: of=FILE may be used several times to write
.IP
output to multiple files simultaneously
.TP
of:=COMMAND
exec and write output to process COMMAND
.TP
seek=BLOCKS
skip BLOCKS obs\-sized blocks at start of output
.TP
skip=BLOCKS
skip BLOCKS ibs\-sized blocks at start of input
.TP
pattern=HEX
use the specified binary pattern as input
.TP
textpattern=TEXT
use repeating TEXT as input
.TP
errlog=FILE
send error messages to FILE as well as stderr
.TP
hashwindow=BYTES
perform a hash on every BYTES amount of data
.TP
hash=NAME
either md5, sha1, sha256, sha384 or sha512
.IP
default algorithm is md5. To select multiple
algorithms to run simultaneously enter the names
in a comma separated list
.TP
hashlog=FILE
send MD5 hash output to FILE instead of stderr
.IP
if you are using multiple hash algorithms you
can send each to a seperate file using the
convention ALGORITHMlog=FILE, for example
md5log=FILE1, sha1log=FILE2, etc.
.TP
hashlog:=COMMAND
exec and write hashlog to process COMMAND
.IP
ALGORITHMlog:=COMMAND also works in the same fashion
.TP
hashconv=[before|after]
perform the hashing before or after the conversions
.TP
hashformat=FORMAT
display each hashwindow according to FORMAT
.IP
the hash format mini\-language is described below
.TP
totalhashformat=FORMAT
display the total hash value according to FORMAT
.TP
status=[on|off]
display a continual status message on stderr
.IP
default state is "on"
.TP
statusinterval=N
update the status message every N blocks
.IP
default value is 256
.TP
sizeprobe=[if|of]
determine the size of the input or output file
.IP
for use with status messages. (this option
gives you a percentage indicator)
WARNING: do not use this option against a
.IP
tape device.
.TP
split=BYTES
write every BYTES amount of data to a new file
.IP
This operation applies to any of=FILE that follows
.TP
splitformat=TEXT
the file extension format for split operation.
.IP
you may use any number of 'a' or 'n' in any combo
the default format is "nnn"
NOTE: The split and splitformat options take effect
.IP
only for output files specified AFTER these
options appear in the command line. Likewise,
you may specify these several times for
for different output files within the same
command line. you may use as many digits in
any combination you would like.
(e.g. "anaannnaana" would be valid, but
quite insane)
.TP
vf=FILE
verify that FILE matches the specified input
.TP
verifylog=FILE
send verify results to FILE instead of stderr
.TP
verifylog:=COMMAND
exec and write verify results to process COMMAND
.TP
\fB\-\-help\fR
display this help and exit
.TP
\fB\-\-version\fR
output version information and exit
.PP
The structure of of FORMAT may contain any valid text and special variables.
The built\-in variables are used the following format: #variable_name#
To pass FORMAT strings to the program from a command line, it may be
necessary to surround your FORMAT strings with "quotes."
The built\-in variables are listed below:
.TP
window_start
The beginning byte offset of the hashwindow
.TP
window_end
The ending byte offset of the hashwindow
.TP
block_start
The beginning block (by input blocksize) of the window
.TP
block_end
The ending block (by input blocksize) of the hash window
.TP
hash
The hash value
.TP
algorithm
The name of the hash algorithm
.SS "For example, the default FORMAT for hashformat and totalhashformat are:"
.IP
hashformat="#window_start# \- #window_end#: #hash#"
totalhashformat="Total (#algorithm#): #hash#"
.SS "The FORMAT structure accepts the following escape codes:"
.TP
\en
Newline
.TP
\et
Tab
.TP
\er
Carriage return
.TP
\e\e
Insert the '\e' character
.TP
##
Insert the '#' character as text, not a variable
.PP
BLOCKS and BYTES may be followed by the following multiplicative suffixes:
xM M, c 1, w 2, b 512, kD 1000, k 1024, MD 1,000,000, M 1,048,576,
GD 1,000,000,000, G 1,073,741,824, and so on for T, P, E, Z, Y.
Each KEYWORD may be:
.TP
ascii
from EBCDIC to ASCII
.TP
ebcdic
from ASCII to EBCDIC
.TP
ibm
from ASCII to alternated EBCDIC
.TP
block
pad newline\-terminated records with spaces to cbs\-size
.TP
unblock
replace trailing spaces in cbs\-size records with newline
.TP
lcase
change upper case to lower case
.TP
notrunc
do not truncate the output file
.TP
ucase
change lower case to upper case
.TP
swab
swap every pair of input bytes
.TP
noerror
continue after read errors
.TP
sync
pad every input block with NULs to ibs\-size; when used
with block or unblock, pad with spaces rather than NULs
.SH AUTHOR
Written by: dcfldd by Nicholas Harbour, GNU dd by Paul Rubin, David MacKenzie and Stuart Kemp.
.SH "REPORTING BUGS"
Report bugs to <nicholasharbour@yahoo.com>.
.SH COPYRIGHT
Copyright \(co 1985-2006 Free Software Foundation, Inc.
.br
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
.SH "SEE ALSO"
The full documentation for
.B dcfldd
is maintained as a Texinfo manual. If the
.B info
and
.B dcfldd
programs are properly installed at your site, the command
.IP
.B info dcfldd
.PP
should give you access to the complete manual.

772
dcfldd.c Normal file
View file

@ -0,0 +1,772 @@
/* $Id: dcfldd.c,v 1.7 2005/06/15 14:33:04 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#include "dcfldd.h"
/*
*
* How bored are you? sitting around reading source code, its sad.
*
*/
#include "config.h"
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <ctype.h>
#include <signal.h>
#include <getopt.h>
#include <time.h>
#include <fcntl.h>
#include "system.h"
#include "human.h"
#include "long-options.h"
#include "safe-read.h"
#include "xstrtol.h"
#include "full-write.h"
#include "copy.h"
#include "hash.h"
#include "verify.h"
#include "translate.h"
#include "sizeprobe.h"
#include "pattern.h"
#include "output.h"
#include "split.h"
#include "hashformat.h"
#include "util.h"
#include "log.h"
/* The name this program was run with. */
char *program_name;
/* The name of the input file, or NULL for the standard input. */
char *input_file = NULL;
/* The name of the output file, or NULL for the standard output. */
char *output_file = NULL;
/* The number of bytes in which atomic reads are done. */
size_t input_blocksize = 0;
/* The number of bytes in which atomic writes are done. */
size_t output_blocksize = 0;
/* Conversion buffer size, in bytes. 0 prevents conversions. */
size_t conversion_blocksize = 0;
/* Skip this many records of `input_blocksize' bytes before input. */
uintmax_t skip_records = 0;
/* Skip this many records of `output_blocksize' bytes before output. */
uintmax_t seek_records = 0;
/* Copy only this many records. The default is effectively infinity. */
uintmax_t max_records = (uintmax_t) -1;
/* Bit vector of conversions to apply. */
int conversions_mask = 0;
/* Number of partial blocks written. */
uintmax_t w_partial = 0;
/* Number of full blocks written. */
uintmax_t w_full = 0;
/* Number of partial blocks read. */
uintmax_t r_partial = 0;
/* Number of full blocks read. */
uintmax_t r_full = 0;
/* If nonzero, filter characters through the translation table. */
int translation_needed = 0;
/* Records truncated by conv=block. */
uintmax_t r_truncate = 0;
/* If nonnzero, the last char from the previous call to `swab_buffer'
is saved in `saved_char'. */
int char_is_saved = 0;
/* Odd char from previous call. */
unsigned char saved_char;
int do_status = 1;
int do_hash = 0;
int do_verify = 0;
int do_split = 0;
hashconv_t hashconv = DEFAULT_HASHCONV;
static char *splitformat = DEFAULT_SPLIT_FORMAT;
static off_t splitsize;
/* How many blocks in between screen writes for status output. */
ssize_t update_thresh = 256;
time_t start_time;
static struct conversion conversions[] =
{
{"ascii", C_ASCII | C_TWOBUFS}, /* EBCDIC to ASCII. */
{"ebcdic", C_EBCDIC | C_TWOBUFS}, /* ASCII to EBCDIC. */
{"ibm", C_IBM | C_TWOBUFS}, /* Slightly different ASCII to EBCDIC. */
{"block", C_BLOCK | C_TWOBUFS}, /* Variable to fixed length records. */
{"unblock", C_UNBLOCK | C_TWOBUFS}, /* Fixed to variable length records. */
{"lcase", C_LCASE | C_TWOBUFS}, /* Translate upper to lower case. */
{"ucase", C_UCASE | C_TWOBUFS}, /* Translate lower to upper case. */
{"swab", C_SWAB | C_TWOBUFS}, /* Swap bytes of input. */
{"noerror", C_NOERROR}, /* Ignore i/o errors. */
{"notrunc", C_NOTRUNC}, /* Do not truncate output file. */
{"sync", C_SYNC}, /* Pad input records to ibs with NULs. */
{NULL, 0}
};
void usage(int status)
{
if (status != 0)
log_info("Try `%s --help' for more information.\n", program_name);
else {
printf("Usage: %s [OPTION]...\n", program_name);
printf("\
Copy a file, converting and formatting according to the options.\n\
\n\
bs=BYTES force ibs=BYTES and obs=BYTES\n\
cbs=BYTES convert BYTES bytes at a time\n\
conv=KEYWORDS convert the file as per the comma separated keyword list\n\
count=BLOCKS copy only BLOCKS input blocks\n\
ibs=BYTES read BYTES bytes at a time\n\
if=FILE read from FILE instead of stdin\n\
obs=BYTES write BYTES bytes at a time\n\
of=FILE write to FILE instead of stdout\n\
NOTE: of=FILE may be used several times to write\n\
output to multiple files simultaneously\n\
of:=COMMAND exec and write output to process COMMAND\n\
seek=BLOCKS skip BLOCKS obs-sized blocks at start of output\n\
skip=BLOCKS skip BLOCKS ibs-sized blocks at start of input\n\
pattern=HEX use the specified binary pattern as input\n\
textpattern=TEXT use repeating TEXT as input\n\
errlog=FILE send error messages to FILE as well as stderr\n\
hashwindow=BYTES perform a hash on every BYTES amount of data\n\
hash=NAME either md5, sha1, sha256, sha384 or sha512\n\
default algorithm is md5. To select multiple\n\
algorithms to run simultaneously enter the names\n\
in a comma separated list\n\
hashlog=FILE send MD5 hash output to FILE instead of stderr\n\
if you are using multiple hash algorithms you\n\
can send each to a seperate file using the\n\
convention ALGORITHMlog=FILE, for example\n\
md5log=FILE1, sha1log=FILE2, etc.\n\
hashlog:=COMMAND exec and write hashlog to process COMMAND\n\
ALGORITHMlog:=COMMAND also works in the same fashion\n\
hashconv=[before|after] perform the hashing before or after the conversions\n\
hashformat=FORMAT display each hashwindow according to FORMAT\n\
the hash format mini-language is described below\n\
totalhashformat=FORMAT display the total hash value according to FORMAT\n\
status=[on|off] display a continual status message on stderr\n\
default state is \"on\"\n\
statusinterval=N update the status message every N blocks\n\
default value is 256\n\
sizeprobe=[if|of] determine the size of the input or output file\n\
for use with status messages. (this option\n\
gives you a percentage indicator)\n\
WARNING: do not use this option against a\n\
tape device.\n\
split=BYTES write every BYTES amount of data to a new file\n\
This operation applies to any of=FILE that follows\n\
splitformat=TEXT the file extension format for split operation.\n\
you may use any number of 'a' or 'n' in any combo\n\
the default format is \"nnn\"\n\
NOTE: The split and splitformat options take effect\n\
only for output files specified AFTER these\n\
options appear in the command line. Likewise,\n\
you may specify these several times for\n\
for different output files within the same\n\
command line. you may use as many digits in\n\
any combination you would like.\n\
(e.g. \"anaannnaana\" would be valid, but\n\
quite insane)\n\
vf=FILE verify that FILE matches the specified input\n\
verifylog=FILE send verify results to FILE instead of stderr\n\
verifylog:=COMMAND exec and write verify results to process COMMAND\n\
\n\
--help display this help and exit\n\
--version output version information and exit\n\
\n\
The structure of of FORMAT may contain any valid text and special variables.\n\
The built-in variables are used the following format: #variable_name#\n\
To pass FORMAT strings to the program from a command line, it may be\n\
necessary to surround your FORMAT strings with \"quotes.\"\n\
The built-in variables are listed below:\n\
\n\
window_start The beginning byte offset of the hashwindow\n\
window_end The ending byte offset of the hashwindow\n\
block_start The beginning block (by input blocksize) of the window\n\
block_end The ending block (by input blocksize) of the hash window\n\
hash The hash value\n\
algorithm The name of the hash algorithm\n\
\n\
For example, the default FORMAT for hashformat and totalhashformat are:\n\
hashformat=\"#window_start# - #window_end#: #hash#\"\n\
totalhashformat=\"Total (#algorithm#): #hash#\"\n\
\n\
The FORMAT structure accepts the following escape codes:\n\
\\n Newline\n\
\\t Tab\n\
\\r Carriage return\n\
\\\\ Insert the '\\' character\n\
## Insert the '#' character as text, not a variable\n\
\n\
BLOCKS and BYTES may be followed by the following multiplicative suffixes:\n\
xM M, c 1, w 2, b 512, kD 1000, k 1024, MD 1,000,000, M 1,048,576,\n\
GD 1,000,000,000, G 1,073,741,824, and so on for T, P, E, Z, Y.\n\
Each KEYWORD may be:\n\
\n\
ascii from EBCDIC to ASCII\n\
ebcdic from ASCII to EBCDIC\n\
ibm from ASCII to alternated EBCDIC\n\
block pad newline-terminated records with spaces to cbs-size\n\
unblock replace trailing spaces in cbs-size records with newline\n\
lcase change upper case to lower case\n\
notrunc do not truncate the output file\n\
ucase change lower case to upper case\n\
swab swap every pair of input bytes\n\
noerror continue after read errors\n\
sync pad every input block with NULs to ibs-size; when used\n\
with block or unblock, pad with spaces rather than NULs\n\
");
puts("\nReport bugs to <nicholasharbour@yahoo.com>.");
}
exit(status);
}
void print_stats(void)
{
char buf[2][LONGEST_HUMAN_READABLE + 1];
log_info("%s+%s records in\n",
human_readable (r_full, buf[0], 1, 1),
human_readable (r_partial, buf[1], 1, 1));
log_info("%s+%s records out\n",
human_readable (w_full, buf[0], 1, 1),
human_readable (w_partial, buf[1], 1, 1));
if (r_truncate > 0) {
log_info("%s %s\n",
human_readable (r_truncate, buf[0], 1, 1),
(r_truncate == 1
? "truncated record"
: "truncated records"));
}
}
void cleanup(void)
{
if (do_status)
fprintf(stderr, "\n");
if (!do_verify)
print_stats();
if (close(STDIN_FILENO) < 0)
;
if (close(STDOUT_FILENO) < 0)
;
}
inline void quit(int code)
{
cleanup();
exit(code);
}
static void interrupt_handler(int sig)
{
#ifdef SA_NOCLDSTOP
struct sigaction sigact;
sigact.sa_handler = SIG_DFL;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
sigaction(sig, &sigact, NULL);
#else
signal(sig, SIG_DFL);
#endif
cleanup();
kill(getpid(), sig);
}
static void siginfo_handler(int sig)
{
print_stats();
}
/* Encapsulate portability mess of establishing signal handlers. */
static void install_handler(int sig_num, void (*sig_handler) (int sig))
{
#ifdef SA_NOCLDSTOP
struct sigaction sigact;
sigaction(sig_num, NULL, &sigact);
if (sigact.sa_handler != SIG_IGN) {
sigact.sa_handler = sig_handler;
sigemptyset(&sigact.sa_mask);
sigact.sa_flags = 0;
sigaction(sig_num, &sigact, NULL);
}
#else
if (signal(sig_num, SIG_IGN) != SIG_IGN)
signal(sig_num, sig_handler);
#endif
}
/* Open a file to a particular file descriptor. This is like standard
`open', except it always returns DESIRED_FD if successful. */
static int open_fd(int desired_fd, char const *filename,
int options, mode_t mode)
{
int fd;
close(desired_fd);
fd = open(filename, options, mode);
if (fd < 0)
return -1;
if (fd != desired_fd) {
if (dup2(fd, desired_fd) != desired_fd)
desired_fd = -1;
if (close(fd) != 0)
return -1;
}
return desired_fd;
}
/* Interpret one "conv=..." option.
* As a by product, this function replaces each `,' in STR with a NUL byte.
*/
void parse_conversion(char *str)
{
char *new;
unsigned int i;
do {
new = strchr(str, ',');
if (new != NULL)
*new++ = '\0';
for (i = 0; conversions[i].convname != NULL; i++)
if (STREQ(conversions[i].convname, str)) {
conversions_mask |= conversions[i].conversion;
break;
}
if (conversions[i].convname == NULL) {
log_info("invalid conversion: %s\n", str);
usage(1);
}
str = new;
} while (new != NULL);
}
void parse_hash(char *str)
{
char *new;
unsigned int i;
do {
new = strchr(str, ',');
if (new != NULL)
*new++ = '\0';
for (i = 0; hashops[i].name != NULL; i++)
if (STREQ(hashops[i].name, str)) {
hashflags |= hashops[i].flag;
break;
}
if (hashops[i].name == NULL) {
log_info("invalid hash: %s\n", str);
usage(1);
}
str = new;
} while (new != NULL);
}
/* Return the value of STR, interpreted as a non-negative decimal integer,
* optionally multiplied by various values.
* Assign nonzero to *INVALID if STR does not represent a number in
* this format.
*/
#if HAVE_DECL_STRTOUMAX
# define __strtol_t uintmax_t
# define __strtol xstrtoumax
#elif HAVE_DECL_STRTOUL
# define __strtol_t unsigned long int
# define __strtol xstrtoul
#else
# define __strtol_t long int
# define __strtol xstrtol
#endif
__strtol_t parse_integer(const char *str, int *invalid)
{
__strtol_t n;
char *suffix;
enum strtol_error e = __strtol(str, &suffix, 10, &n, "bcEGkMPTwYZ0");
if (e == LONGINT_INVALID_SUFFIX_CHAR && *suffix == 'x') {
__strtol_t multiplier = parse_integer(suffix + 1, invalid);
if (multiplier != 0 && n * multiplier / multiplier != n) {
*invalid = 1;
return 0;
}
n *= multiplier;
}
else if (e != LONGINT_OK) {
*invalid = 1;
return 0;
}
return n;
}
int hex2char(char *hstr)
{
int retval;
if (strlen(hstr) != 2)
return -1;
if (EOF == sscanf(hstr, "%x", &retval))
return -1;
return retval;
}
static void scanargs(int argc, char **argv)
{
int i;
--argc;
++argv;
for (i = optind; i < argc; i++) {
char *name, *val;
name = argv[i];
val = strchr(name, '=');
if (val == NULL) {
log_info("%s: unrecognized option %s\n", program_name, name);
usage(1);
}
*val++ = '\0';
if (STREQ(name, "if"))
if (STREQ(val, "/dev/zero")) { /* replace if=/dev/zero with pattern=00 */
pattern = make_pattern("00");
pattern_len = 1;
input_from_pattern = 1;
} else
input_file = val;
else if (STREQ(name, "of"))
if (do_split)
outputlist_add(SPLIT_FILE, val, splitformat, splitsize);
else
open_output(val);
else if (STREQ(name, "of:"))
open_output_pipe(val);
else if (STREQ(name, "vf")) {
verify_file = val;
do_verify++;
} else if (STREQ(name, "conv"))
parse_conversion(val);
else if (STREQ(name, "pattern")) {
pattern = make_pattern(val);
if (pattern == NULL) {
log_info("%s: invalid hex pattern: %s", program_name, val);
quit(1);
}
input_from_pattern = 1;
} else if (STREQ(name, "textpattern")) {
pattern = val;
pattern_len = strlen(pattern);
input_from_pattern = 1;
} else if (STREQ(name, "hashlog")) {
hash_log = fopen(val, "w");
if (hash_log == NULL)
syscall_error(val);
do_hash++;
} else if (STREQ(name, "hashlog:")) {
hash_log = popen2(val, "w");
if (hash_log == NULL)
syscall_error(val);
do_hash++;
} else if (STREQ(name, "hashformat"))
hashformat = parse_hashformat(val);
else if (STREQ(name, "totalhashformat"))
totalhashformat = parse_hashformat(val);
else if (STREQ(name, "md5log")) {
hashops[MD5].log = fopen(val, "w");
if (hashops[MD5].log == NULL)
syscall_error(val);
do_hash++;
} else if (STREQ(name, "md5log:")) {
hashops[MD5].log = popen2(val, "w");
if (hashops[MD5].log == NULL)
syscall_error(val);
do_hash++;
} else if (STREQ(name, "sha1log")) {
hashops[SHA1].log = fopen(val, "w");
if (hashops[SHA1].log == NULL)
syscall_error(val);
do_hash++;
} else if (STREQ(name, "sha1log:")) {
hashops[SHA1].log = popen2(val, "w");
if (hashops[SHA1].log == NULL)
syscall_error(val);
do_hash++;
} else if (STREQ(name, "sha256log")) {
hashops[SHA256].log = fopen(val, "w");
if (hashops[SHA256].log == NULL)
syscall_error(val);
do_hash++;
} else if (STREQ(name, "sha256log:")) {
hashops[SHA256].log = popen2(val, "w");
if (hashops[SHA256].log == NULL)
syscall_error(val);
do_hash++;
} else if (STREQ(name, "sha384log")) {
hashops[SHA384].log = fopen(val, "w");
if (hashops[SHA384].log == NULL)
syscall_error(val);
do_hash++;
} else if (STREQ(name, "sha384log:")) {
hashops[SHA384].log = popen2(val, "w");
if (hashops[SHA384].log == NULL)
syscall_error(val);
do_hash++;
} else if (STREQ(name, "sha512log")) {
hashops[SHA512].log = fopen(val, "w");
if (hashops[SHA512].log == NULL)
syscall_error(val);
do_hash++;
} else if (STREQ(name, "sha512log:")) {
hashops[SHA512].log = popen2(val, "w");
if (hashops[SHA512].log == NULL)
syscall_error(val);
do_hash++;
} else if (STREQ(name, "verifylog")) {
verify_log = fopen(val, "w");
if (verify_log == NULL)
syscall_error(val);
} else if (STREQ(name, "verifylog:")) {
verify_log = popen2(val, "w");
if (verify_log == NULL)
syscall_error(val);
} else if (STREQ(name, "errlog")) {
errlog = fopen(val, "w");
if (errlog == NULL)
syscall_error(val);
} else if (STREQ(name, "errlog:")) {
errlog = popen2(val, "w");
if (errlog == NULL)
syscall_error(val);
} else if (STREQ(name, "splitformat"))
splitformat = val;
else if (STREQ(name, "status")) {
if (STREQ(val, "off"))
do_status = 0;
else if (STREQ(val, "on"))
do_status = 1;
} else if (STREQ(name, "hashalgorithm") || STREQ(name, "hash")) {
parse_hash(val);
do_hash++;
} else if (STREQ(name, "hashconv"))
if (STREQ(val, "before"))
hashconv = HASHCONV_BEFORE;
else if (STREQ(val, "after"))
hashconv = HASHCONV_AFTER;
else
user_error("invalid hashconv value \"%s\"", val);
else if (STREQ(name, "sizeprobe")) {
if (STREQ(val, "if"))
probe = PROBE_INPUT;
else if (STREQ(val, "of"))
probe = PROBE_OUTPUT;
else
probe = PROBE_NONE;
} else {
int invalid = 0;
uintmax_t n = parse_integer(val, &invalid);
if (STREQ(name, "ibs")) {
input_blocksize = n;
invalid |= input_blocksize != n || input_blocksize == 0;
conversions_mask |= C_TWOBUFS;
}
else if (STREQ(name, "obs")) {
output_blocksize = n;
invalid |= output_blocksize != n || output_blocksize == 0;
conversions_mask |= C_TWOBUFS;
} else if (STREQ(name, "bs")) {
output_blocksize = input_blocksize = n;
invalid |= output_blocksize != n || output_blocksize == 0;
} else if (STREQ(name, "cbs")) {
conversion_blocksize = n;
invalid |= (conversion_blocksize != n
|| conversion_blocksize == 0);
} else if (STREQ(name, "skip"))
skip_records = n;
else if (STREQ(name, "vskip"))
vskip_records = n;
else if (STREQ(name, "seek"))
seek_records = n;
else if (STREQ(name, "count"))
max_records = n;
else if (STREQ(name, "split")) {
splitsize = n;
do_split++;
} else if (STREQ(name, "hashwindow")) {
hash_windowlen = n;
do_hash++;
} else if (STREQ(name, "statusinterval")) {
update_thresh = n;
} else {
log_info("%s: unrecognized option %s=%s",
program_name, name, val);
usage(1);
}
if (invalid)
log_info("%s: invalid number %s", program_name, val);
}
}
/* If bs= was given, both `input_blocksize' and `output_blocksize' will
have been set to positive values. If either has not been set,
bs= was not given, so make sure two buffers are used. */
if (input_blocksize == 0 || output_blocksize == 0)
conversions_mask |= C_TWOBUFS;
if (input_blocksize == 0)
input_blocksize = DEFAULT_BLOCKSIZE;
if (output_blocksize == 0)
output_blocksize = DEFAULT_BLOCKSIZE;
if (conversion_blocksize == 0)
conversions_mask &= ~(C_BLOCK | C_UNBLOCK);
/* set all unset hashlogs to go to the overall hashlog */
for (i = 0; hashops[i].name != NULL; i++)
if (hashops[i].log == NULL)
hashops[i].log = hash_log;
if (do_hash && hashflags == 0)
hashflags = hashops[DEFAULT_HASH].flag;
if (do_verify) {
do_hash = 0;
init_hashlist(&ihashlist, hashops[VERIFY_HASH].flag);
} else if (do_hash)
init_hashlist(&ihashlist, hashflags);
/* make sure selected options make sense */
if (output_file != NULL && verify_file != NULL)
user_error("Please select either an output file or a verify file, not both.");
}
int main(int argc, char **argv)
{
int i;
int exit_status;
char *def_hashwin_fmt;
char *def_totalhash_fmt;
def_hashwin_fmt = strndup(DEFAULT_HASHWINDOW_FORMAT,
strlen(DEFAULT_HASHWINDOW_FORMAT));
def_totalhash_fmt = strndup(DEFAULT_TOTALHASH_FORMAT,
strlen(DEFAULT_TOTALHASH_FORMAT));
/* disable buffering on stderr */
setbuf(stderr, NULL);
hash_log = stderr;
verify_log = stderr;
program_name = argv[0];
hashformat = parse_hashformat(def_hashwin_fmt);
totalhashformat = parse_hashformat(def_totalhash_fmt);
/* Arrange to close stdout if parse_long_options exits. */
//atexit (close_stdout_wrapper);
parse_long_options(argc, argv, PROGRAM_NAME, PACKAGE, VERSION,
AUTHORS, usage);
/* Don't close stdout on exit from here on. */
//closeout_func = NULL;
/* Initialize translation table to identity translation. */
for (i = 0; i < 256; i++)
trans_table[i] = i;
/* Decode arguments. */
scanargs(argc, argv);
apply_translations();
if (input_file != NULL) {
if (open_fd(STDIN_FILENO, input_file, O_RDONLY, 0) < 0)
syscall_error(input_file);
} else if (pattern == NULL)
input_file = "standard input";
if (verify_file != NULL)
if ((verify_fd = open(verify_file, O_RDONLY)) < 0)
syscall_error(verify_file);
if (outputlist == NULL)
outputlist_add(SINGLE_FILE, STDOUT_FILENO);
install_handler(SIGINT, interrupt_handler);
install_handler(SIGQUIT, interrupt_handler);
install_handler(SIGPIPE, interrupt_handler);
install_handler(SIGINFO, siginfo_handler);
if (probe == PROBE_INPUT)
if (input_from_pattern)
probe = PROBE_NONE;
else
sizeprobe(STDIN_FILENO);
else if (probe == PROBE_OUTPUT)
sizeprobe(STDOUT_FILENO);
start_time = time(NULL);
if (do_verify)
exit_status = dd_verify();
else
exit_status = dd_copy();
close(1);
quit(exit_status);
}

167
dcfldd.h Normal file
View file

@ -0,0 +1,167 @@
/* $Id: dcfldd.h,v 1.7 2005/05/19 21:00:07 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#ifndef DCFLDD_H
#define DCFLDD_H
#define _FILE_OFFSET_BITS 64
#define LARGEFILE_SOURCE
#if HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#include <sys/types.h>
#include <ctype.h>
#include <time.h>
#include <stdio.h>
#include "config.h"
#include "system.h"
#include "hash.h"
/* The official name of this program (e.g., no `g' prefix). */
#define PROGRAM_NAME "dcfldd"
#define AUTHORS "dcfldd by Nicholas Harbour, GNU dd by Paul Rubin, David MacKenzie and Stuart Kemp"
#define SWAB_ALIGN_OFFSET 2
#ifndef SIGINFO
# define SIGINFO SIGUSR1
#endif
#ifndef S_TYPEISSHM
# define S_TYPEISSHM(Stat_ptr) 0
#endif
#define ROUND_UP_OFFSET(X, M) ((M) - 1 - (((X) + (M) - 1) % (M)))
#define PTR_ALIGN(Ptr, M) ((Ptr) \
+ ROUND_UP_OFFSET ((char *)(Ptr) - (char *)0, (M)))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define output_char(c) \
do \
{ \
obuf[oc++] = (c); \
if (oc >= output_blocksize) \
write_output (); \
} \
while (0)
/* Default input and output blocksize. */
/* #define DEFAULT_BLOCKSIZE 512 */
#ifndef DEFAULT_BLOCKSIZE
#define DEFAULT_BLOCKSIZE 32768 /* 32k blocksize is HUGELY more efficient
* for large device IO than 512 */
#endif /* DEFAULT_BLOCKSIZE */
#ifndef DEFAULT_SPLIT_FORMAT
#define DEFAULT_SPLIT_FORMAT "nnn"
#endif /* DEFAULT_SPLIT_FORMAT */
#ifndef DEFAULT_HASHWINDOW_FORMAT
#define DEFAULT_HASHWINDOW_FORMAT "#window_start# - #window_end#: #hash#"
#endif /* DEFAULT_HASHWINDOW_FORMAT */
#ifndef DEFAULT_TOTALHASH_FORMAT
#define DEFAULT_TOTALHASH_FORMAT "Total (#algorithm#): #hash#"
#endif /* DEFAULT_TOTALHASH_FORMAT */
#ifndef DEFAULT_HASHCONV
#define DEFAULT_HASHCONV HASHCONV_BEFORE
#endif /* DEFAULT_HASHCONV */
/* Conversions bit masks. */
#define C_ASCII 01
#define C_EBCDIC 02
#define C_IBM 04
#define C_BLOCK 010
#define C_UNBLOCK 020
#define C_LCASE 040
#define C_UCASE 0100
#define C_SWAB 0200
#define C_NOERROR 0400
#define C_NOTRUNC 01000
#define C_SYNC 02000
/* Use separate input and output buffers, and combine partial input blocks. */
#define C_TWOBUFS 04000
typedef enum {
HASHCONV_BEFORE,
HASHCONV_AFTER
} hashconv_t;
extern hashconv_t hashconv;
extern char *program_name;
extern char *input_file;
extern char *output_file;
extern size_t input_blocksize;
extern size_t output_blocksize;
extern size_t conversion_blocksize;
extern uintmax_t skip_records;
extern uintmax_t seek_records;
extern uintmax_t max_records;
extern int conversions_mask;
extern int translation_needed;
extern uintmax_t w_partial;
extern uintmax_t w_full;
extern uintmax_t r_partial;
extern uintmax_t r_full;
extern uintmax_t r_partial;
extern uintmax_t r_truncate;
extern int do_hash;
extern int do_verify;
extern int do_status;
extern int char_is_saved;
extern unsigned char saved_char;
extern time_t start_time;
extern ssize_t update_thresh;
struct conversion
{
char *convname;
int conversion;
};
/* FIXME: Figure out where usage() is getting called from and delete this if needed */
extern void usage(int);
extern void print_stats(void);
extern void cleanup(void);
extern inline void quit(int);
extern void parse_conversion(char *);
extern int hex2char(char *);
#endif /* DCFLDD_H */

522
depcomp Executable file
View file

@ -0,0 +1,522 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2004-05-31.23
# Copyright (C) 1999, 2000, 2003, 2004 Free Software Foundation, Inc.
# 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, 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.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit 0
;;
-v | --v*)
echo "depcomp $scriptversion"
exit 0
;;
esac
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test -f "$tmpdepfile"; then :
else
stripped=`echo "$stripped" | sed 's,^.*/,,'`
tmpdepfile="$stripped.u"
fi
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
outname="$stripped.o"
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# Dependencies are output in .lo.d with libtool 1.4.
# With libtool 1.5 they are output both in $dir.libs/$base.o.d
# and in $dir.libs/$base.o.d and $dir$base.o.d. We process the
# latter, because the former will be cleaned when $dir.libs is
# erased.
tmpdepfile1="$dir.libs/$base.lo.d"
tmpdepfile2="$dir$base.o.d"
tmpdepfile3="$dir.libs/$base.d"
"$@" -Wc,-MD
else
tmpdepfile1="$dir$base.o.d"
tmpdepfile2="$dir$base.d"
tmpdepfile3="$dir$base.d"
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
if test -f "$tmpdepfile1"; then
tmpdepfile="$tmpdepfile1"
elif test -f "$tmpdepfile2"; then
tmpdepfile="$tmpdepfile2"
else
tmpdepfile="$tmpdepfile3"
fi
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
IFS=" "
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

68
full-write.c Normal file
View file

@ -0,0 +1,68 @@
/* full-write.c -- an interface to write that retries after interrupts
Copyright (C) 1993, 1994, 1997, 1998, 2000 Free Software Foundation, Inc.
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, 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.
Copied largely from GNU C's cccp.c.
*/
#include "dcfldd.h"
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <errno.h>
#ifndef errno
extern int errno;
#endif
/* Write LEN bytes at PTR to descriptor DESC, retrying if interrupted.
Return LEN upon success, write's (negative) error code otherwise. */
int
full_write (int desc, const char *ptr, size_t len)
{
int total_written;
total_written = 0;
while (len > 0)
{
int written = write (desc, ptr, len);
/* write on an old Slackware Linux 1.2.13 returns zero when
I try to write more data than there is room on a floppy disk.
This puts dd into an infinite loop. Reproduce with
dd if=/dev/zero of=/dev/fd0. If you have this problem,
consider upgrading to a newer kernel. */
if (written < 0)
{
#ifdef EINTR
if (errno == EINTR)
continue;
#endif
return written;
}
total_written += written;
ptr += written;
len -= written;
}
return total_written;
}

29
full-write.h Normal file
View file

@ -0,0 +1,29 @@
/* $Id: full-write.h,v 1.3 2005/05/13 18:52:06 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#ifndef FULL_WRITE_H
#define FULL_WRITE_H
int full_write(int, const char *, size_t);
#endif /* FULL_WRITE_H */

49
getpagesize.h Normal file
View file

@ -0,0 +1,49 @@
/* Emulate getpagesize on systems that lack it. */
#ifndef HAVE_GETPAGESIZE
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#if !defined getpagesize && defined _SC_PAGESIZE
# if !(defined VMS && __VMS_VER < 70000000)
# define getpagesize() sysconf (_SC_PAGESIZE)
# endif
#endif
#if !defined getpagesize && defined VMS
# ifdef __ALPHA
# define getpagesize() 8192
# else
# define getpagesize() 512
# endif
#endif
/* This is for BeOS. */
#if !defined getpagesize && HAVE_OS_H
# include <OS.h>
# if defined B_PAGE_SIZE
# define getpagesize() B_PAGE_SIZE
# endif
#endif
#ifndef getpagesize
# include <sys/param.h>
# ifdef EXEC_PAGESIZE
# define getpagesize() EXEC_PAGESIZE
# else
# ifdef NBPG
# ifndef CLSIZE
# define CLSIZE 1
# endif
# define getpagesize() (NBPG * CLSIZE)
# else
# ifdef NBPC
# define getpagesize() NBPC
# endif
# endif
# endif
#endif
#endif /* not HAVE_GETPAGESIZE */

358
hash.c Normal file
View file

@ -0,0 +1,358 @@
/* $Id: hash.c,v 1.4 2005/05/14 23:20:30 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#include "dcfldd.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "md5.h"
#include "sha1.h"
#include "sha2.h"
#include "hash.h"
#include "log.h"
hashflag_t hashflags = 0;
/* Md5 global data */
MD5_CTX MD5_total_context;
MD5_CTX MD5_window_context;
MD5_CTX MD5_vtotal_context;
MD5_CTX MD5_vwindow_context;
char MD5_hashstr[MD5_DIGEST_STRING_LENGTH + 1] = {'\0'};
/* SHA1 global data */
SHA1Context SHA1_total_context;
SHA1Context SHA1_window_context;
SHA1Context SHA1_vtotal_context;
SHA1Context SHA1_vwindow_context;
char SHA1_hashstr[SHA1_DIGEST_STRING_LENGTH + 1] = {'\0'};
/* SHA256 global data */
SHA256_CTX SHA256_total_context;
SHA256_CTX SHA256_window_context;
SHA256_CTX SHA256_vtotal_context;
SHA256_CTX SHA256_vwindow_context;
char SHA256_hashstr[SHA256_DIGEST_STRING_LENGTH + 1] = {'\0'};
/* SHA384 global data */
SHA384_CTX SHA384_total_context;
SHA384_CTX SHA384_window_context;
SHA384_CTX SHA384_vtotal_context;
SHA384_CTX SHA384_vwindow_context;
char SHA384_hashstr[SHA384_DIGEST_STRING_LENGTH + 1] = {'\0'};
/* SHA512 global data */
SHA512_CTX SHA512_total_context;
SHA512_CTX SHA512_window_context;
SHA512_CTX SHA512_vtotal_context;
SHA512_CTX SHA512_vwindow_context;
char SHA512_hashstr[SHA512_DIGEST_STRING_LENGTH + 1] = {'\0'};
off_t hash_windowlen = 0;
off_t window_beginning = 0;
off_t bytes_in_window = 0;
off_t bytes_in_total = 0;
void (*hashinit)(void *);
void (*hashupdate)(void *, const void *, size_t);
void (*hashfinal)(void *, void *);
void *hashstr_buf;
size_t hashstr_buf_size;
FILE *hash_log;
/* Hash algorithms */
hashlist_t *ihashlist;
hashtype_t hashops[] =
{
{"md5",
1,
&MD5_window_context,
&MD5_total_context,
&MD5_vwindow_context,
&MD5_vtotal_context,
(void (*)(void *)) MD5Init,
(void (*)(void *, const void *, size_t)) MD5Update,
(void (*)(void *, void *)) MD5Final,
&MD5_hashstr[0],
sizeof (MD5_hashstr),
NULL},
{"sha1",
1<<1,
&SHA1_window_context,
&SHA1_total_context,
&SHA1_vwindow_context,
&SHA1_vtotal_context,
(void (*)(void *)) SHA1Init,
(void (*)(void *, const void *, size_t)) SHA1Update,
(void (*)(void *, void *)) SHA1End,
&SHA1_hashstr[0],
sizeof (SHA1_hashstr),
NULL},
{"sha256",
1<<2,
&SHA256_window_context,
&SHA256_total_context,
&SHA256_vwindow_context,
&SHA256_vtotal_context,
(void (*)(void *)) SHA256_Init,
(void (*)(void *, const void *, size_t)) SHA256_Update,
(void (*)(void *, void *)) SHA256_End,
SHA256_hashstr,
sizeof (SHA256_hashstr),
NULL},
{"sha384",
1<<3,
&SHA384_window_context,
&SHA384_total_context,
&SHA384_vwindow_context,
&SHA384_vtotal_context,
(void (*)(void *)) SHA384_Init,
(void (*)(void *, const void *, size_t)) SHA384_Update,
(void (*)(void *, void *)) SHA384_End,
&SHA384_hashstr[0],
sizeof (SHA384_hashstr),
NULL},
{"sha512",
1<<4,
&SHA512_window_context,
&SHA512_total_context,
&SHA512_vwindow_context,
&SHA512_vtotal_context,
(void (*)(void *)) SHA512_Init,
(void (*)(void *, const void *, size_t)) SHA512_Update,
(void (*)(void *, void *)) SHA512_End,
&SHA512_hashstr[0],
sizeof (SHA512_hashstr),
NULL},
{NULL,
0,
NULL,
NULL,
NULL,
NULL,
(void (*)(void *)) NULL,
(void (*)(void *, const void *, size_t)) NULL,
(void (*)(void *, void *)) NULL,
NULL,
0,
NULL}
};
static void add_hash(hashlist_t **hashlist, int hash)
{
hashlist_t *hlptr = *hashlist;
int i;
if (hlptr == NULL) {
hlptr = malloc(sizeof (hashlist_t));
*hashlist = hlptr;
} else {
for ( ; hlptr->next != NULL; hlptr = hlptr->next)
;
hlptr->next = malloc(sizeof (hashlist_t));
hlptr = hlptr->next;
}
hlptr->next = NULL;
hlptr->hash = &hashops[hash];
}
/* add all the appropriate hashops according to the flags */
void init_hashlist(hashlist_t **hashlist, hashflag_t flags)
{
int i;
for (i = 0; hashops[i].name != NULL; i++)
if (hashops[i].flag & flags)
add_hash(hashlist, i);
}
/* not to be confused with init_hashlist, this function calls
* the hashtype specific init function for each hash type in
* the list */
void hashl_init(hashlist_t *hashlist, int context)
{
hashlist_t *hptr;
for (hptr = hashlist; hptr != NULL; hptr = hptr->next) {
void *ctx;
switch (context) {
case WINDOW_CTX:
ctx = hptr->hash->window_context;
break;
case TOTAL_CTX:
ctx = hptr->hash->total_context;
break;
case VWINDOW_CTX:
ctx = hptr->hash->vwindow_context;
break;
case VTOTAL_CTX:
ctx = hptr->hash->vtotal_context;
break;
default:
internal_error("unreachable branch encountered in hashl_init()");
break;
}
(hptr->hash->init)(ctx);
}
}
void hashl_update(hashlist_t *hashlist, int context, const void *buf, size_t len)
{
hashlist_t *hptr;
for (hptr = hashlist; hptr != NULL; hptr = hptr->next) {
void *ctx;
switch (context) {
case WINDOW_CTX:
ctx = hptr->hash->window_context;
break;
case TOTAL_CTX:
ctx = hptr->hash->total_context;
break;
case VWINDOW_CTX:
ctx = hptr->hash->vwindow_context;
break;
case VTOTAL_CTX:
ctx = hptr->hash->vtotal_context;
break;
default:
internal_error("unreachable branch encountered in hashl_update()");
break;
}
(hptr->hash->update)(ctx, buf, len);
}
}
void hashl_final(hashlist_t *hashlist, int context)
{
hashlist_t *hptr;
for (hptr = hashlist; hptr != NULL; hptr = hptr->next) {
void *ctx;
switch (context) {
case WINDOW_CTX:
ctx = hptr->hash->window_context;
break;
case TOTAL_CTX:
ctx = hptr->hash->total_context;
break;
case VWINDOW_CTX:
ctx = hptr->hash->vwindow_context;
break;
case VTOTAL_CTX:
ctx = hptr->hash->vtotal_context;
break;
default:
internal_error("unreachable branch encountered in hashl_final()");
break;
}
/* note that this writes the hash string to the global buffer
* for the specific hashtype, when calling this multiple times
* (i.e. like in verify) copy that buffer out before finalizing
* another list */
(hptr->hash->final)(ctx, hptr->hash->hashstr_buf);
}
}
void hash_update_buf(hashlist_t *hashlist, int winctx, int ttlctx,
void *buf, size_t len)
{
if (hash_windowlen != 0) {
hashl_update(hashlist, winctx, buf, len);
if (winctx == WINDOW_CTX) /* don't do this for verify or you'll get double */
bytes_in_window += len;
}
hashl_update(hashlist, ttlctx, buf, len);
if(ttlctx == TOTAL_CTX)
bytes_in_total += len;
}
void hash_update(hashlist_t *hashlist, void *buf, size_t len)
{
size_t left_in_window = hash_windowlen - bytes_in_window;
if (bytes_in_total == 0)
hashl_init(hashlist, TOTAL_CTX);
if (hash_windowlen == 0)
hash_update_buf(hashlist, WINDOW_CTX, TOTAL_CTX, buf, len);
else {
if (bytes_in_window == 0)
hashl_init(hashlist, WINDOW_CTX);
if (len >= left_in_window) {
hash_update_buf(hashlist, WINDOW_CTX, TOTAL_CTX, buf, left_in_window);
hashl_final(hashlist, WINDOW_CTX);
display_windowhash(hashlist, hash_windowlen);
window_beginning += hash_windowlen;
bytes_in_window = 0;
hash_update(hashlist, buf + left_in_window, len - left_in_window);
} else
hash_update_buf(hashlist, WINDOW_CTX, TOTAL_CTX, buf, len);
}
}
void display_windowhash(hashlist_t *hashlist, off_t windowlen)
{
hashlist_t *hptr;
for (hptr = hashlist; hptr != NULL; hptr = hptr->next)
log_hashwindow(hptr->hash, window_beginning, (window_beginning + windowlen),
input_blocksize, hptr->hash->hashstr_buf);
}
void display_totalhash(hashlist_t *hashlist, int ttlctx)
{
hashlist_t *hptr;
hashl_final(hashlist, ttlctx);
for (hptr = hashlist; hptr != NULL; hptr = hptr->next)
log_hashtotal(hptr->hash, 0, 0,
input_blocksize, hptr->hash->hashstr_buf);
}
void hash_remainder(hashlist_t *hashlist, int winctx)
{
if (hash_windowlen > 0 && bytes_in_window > 0) {
hashl_final(hashlist, winctx);
display_windowhash(hashlist, bytes_in_window);
}
}

107
hash.h Normal file
View file

@ -0,0 +1,107 @@
/* $Id: hash.h,v 1.4 2005/05/14 23:20:30 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#ifndef HASH_H
#define HASH_H
#include "dcfldd.h"
#include "md5.h"
#include "sha1.h"
#include "sha2.h"
#include <sys/types.h>
#include <stdio.h>
/* bytes_in_window and bytes_in_total are only used for dd_copy() */
extern off_t bytes_in_window;
extern off_t bytes_in_total;
extern void (*hashinit)(void *);
extern void (*hashupdate)(void *, const void *, size_t);
extern void (*hashfinal)(void *, void *);
extern void *hashstr_buf;
extern size_t hashstr_buf_size;
typedef uint32_t hashflag_t;
extern hashflag_t hashflags;
typedef struct hashtype
{
char *name;
hashflag_t flag;
void *window_context;
void *total_context;
void *vwindow_context;
void *vtotal_context;
void (*init)(void *);
void (*update)(void *, const void *, size_t);
void (*final)(void *, void *);
void *hashstr_buf;
size_t hashstr_buf_size;
FILE *log;
} hashtype_t;
typedef struct hashlist_s
{
struct hashlist_s *next;
hashtype_t *hash;
} hashlist_t;
extern hashlist_t *ihashlist;
extern struct hashtype hashops[];
extern FILE *hash_log;
/* this enum order must correspond to their position in the hashops[] array */
enum {MD5 = 0, SHA1, SHA256, SHA384, SHA512};
enum {WINDOW_CTX, TOTAL_CTX, VWINDOW_CTX, VTOTAL_CTX};
#ifndef VERIFY_HASH
#define VERIFY_HASH MD5
#endif
#ifndef DEFAULT_HASH
#define DEFAULT_HASH MD5
#endif
extern off_t bytes_in_window;
extern off_t bytes_in_total;
extern off_t hash_windowlen;
extern off_t window_beginning;
extern void display_windowhash(hashlist_t *, off_t);
extern void display_totalhash(hashlist_t *, int);
extern void hash_update(hashlist_t *, void *, size_t);
extern void hash_update_buf(hashlist_t *, int, int, void *, size_t);
extern void hash_remainder(hashlist_t *, int);
/* inner hashl_* funcitons are for iterating over hashlists */
extern void hashl_init(hashlist_t *, int);
extern void hashl_update(hashlist_t *, int, const void *, size_t);
extern void hashl_final(hashlist_t *, int);
#endif /* HASH_H */

168
hashformat.c Normal file
View file

@ -0,0 +1,168 @@
/* $Id: hashformat.c,v 1.2 2005/05/15 13:18:27 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#include "dcfldd.h"
#include "hashformat.h"
#include "log.h"
#include "util.h"
#include "sys2.h"
#include <stdio.h>
#include <sys/types.h>
#include <assert.h>
#include <string.h>
#include <stdlib.h>
format_t *hashformat = NULL;
format_t *totalhashformat = NULL;
static fmtatom_op_t fmt_string_op;
static fmtatom_op_t fmt_window_start_op;
static fmtatom_op_t fmt_window_end_op;
static fmtatom_op_t fmt_winblk_start_op;
static fmtatom_op_t fmt_winblk_end_op;
static fmtatom_op_t fmt_algorithm_op;
static fmtatom_op_t *fmtatom_op_table[] =
{ /* order must conform to fmtatom_t enum */
fmt_string_op,
fmt_window_start_op,
fmt_window_end_op,
fmt_winblk_start_op,
fmt_winblk_end_op,
fmt_string_op,
fmt_algorithm_op
};
static void add_fmtatom(format_t **, fmtatom_t, void *);
static void add_fmtatom(format_t **format, fmtatom_t atom, void *data)
{
format_t *fmt;
if (*format == NULL) {
*format = malloc(sizeof **format);
fmt = *format;
} else {
/* cycle to the end of the list */
for (fmt = *format; fmt->next != NULL; fmt = fmt->next)
;
fmt->next = malloc(sizeof *fmt);
fmt = fmt->next;
}
fmt->next = NULL;
fmt->type = atom;
fmt->op = fmtatom_op_table[atom];
fmt->data = data;
}
format_t *parse_hashformat(char *str)
{
format_t *fmt = NULL;
int i;
if (str == NULL || strlen(str) == 0)
return NULL;
replace_escapes(str);
if (*str == VARIABLE_HOOK) {
for (i = 1; str[i] != '\0' && str[i] != VARIABLE_HOOK; i++)
;
if (str[i] == '\0')
user_error("invalid variable specifier \"%s\", variables should be terminated with another \'%c\'", str, VARIABLE_HOOK);
else if (i == 1) {
/* if there is two HOOKs with nothing between, remove the second and
* push up all the following chars one position */
for (i = 0; str[i] != '\0'; i++)
str[i] = str[i + 1];
} else {
str[i] = '\0';
str++;
if (STREQ(str, "window_start"))
add_fmtatom(&fmt, FMT_WINDOW_START, NULL);
else if (STREQ(str, "window_end"))
add_fmtatom(&fmt, FMT_WINDOW_END, NULL);
else if (STREQ(str, "block_start"))
add_fmtatom(&fmt, FMT_WINBLK_START, NULL);
else if (STREQ(str, "block_end"))
add_fmtatom(&fmt, FMT_WINBLK_END, NULL);
else if (STREQ(str, "hash"))
add_fmtatom(&fmt, FMT_HASH, NULL);
else if (STREQ(str, "algorithm"))
add_fmtatom(&fmt, FMT_ALGORITHM, NULL);
else
user_error("invalid variable specifier \"%c%s%c\"",
VARIABLE_HOOK, str, VARIABLE_HOOK);
fmt->next = parse_hashformat(&str[i]);
return fmt;
}
}
/* this loop needs to start at 1 so that "$$" will display a '$' properly */
for (i = 1; str[i] != '\0' && str[i] != VARIABLE_HOOK; i++)
;
add_fmtatom(&fmt, FMT_STRING, strndup(str, i));
fmt->next = parse_hashformat(&str[i]);
return fmt;
}
void print_fmt(format_t *fmt, FMTATOMOP_ARGS)
{
for (; fmt != NULL; fmt = fmt->next)
(fmt->op)(stream, wina, winb, blksize, alg, fmt->data == NULL ? data : fmt->data);
fputc('\n', stream);
}
static void fmt_string_op(FMTATOMOP_ARGS)
{
char *str = (char *)data;
fputs(str, stream);
}
static void fmt_window_start_op(FMTATOMOP_ARGS)
{
fprintf(stream, "%llu", (unsigned long long int) wina);
}
static void fmt_window_end_op(FMTATOMOP_ARGS)
{
fprintf(stream, "%llu", (unsigned long long int) winb);
}
static void fmt_winblk_start_op(FMTATOMOP_ARGS)
{
fprintf(stream, "%llu", (unsigned long long int) wina / blksize);
}
static void fmt_winblk_end_op(FMTATOMOP_ARGS)
{
fprintf(stream, "%llu", (unsigned long long int) winb / blksize);
}
static void fmt_algorithm_op(FMTATOMOP_ARGS)
{
fputs(alg, stream);
}

63
hashformat.h Normal file
View file

@ -0,0 +1,63 @@
/* $Id: hashformat.h,v 1.1 2005/05/14 23:20:30 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#ifndef HASH_FORMAT_H
#define HASH_FORMAT_H
#include "dcfldd.h"
#include "hash.h"
#include <stdio.h>
#include <sys/types.h>
typedef enum {
FMT_STRING,
FMT_WINDOW_START,
FMT_WINDOW_END,
FMT_WINBLK_START, /* window offsets / blocksize */
FMT_WINBLK_END,
FMT_HASH,
FMT_ALGORITHM
} fmtatom_t;
#define FMTATOMOP_ARGS FILE *stream, off_t wina, off_t winb, size_t blksize, char *alg, void *data
typedef void (fmtatom_op_t)(FMTATOMOP_ARGS);
#ifndef VARIABLE_HOOK
#define VARIABLE_HOOK '#'
#endif
typedef struct format_s {
struct format_s *next;
fmtatom_t type;
fmtatom_op_t *op;
void *data; /* optional */
} format_t;
extern format_t *hashformat;
extern format_t *totalhashformat;
extern void print_fmt(format_t *, FMTATOMOP_ARGS);
extern format_t *parse_hashformat(char *);
#endif /* HASH_FORMAT_H */

334
human.c Normal file
View file

@ -0,0 +1,334 @@
/* human.c -- print human readable file size
Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
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, 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. */
/* Originally contributed by lm@sgi.com;
--si, output block size selection, and large file support
added by eggert@twinsun.com. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <stdio.h>
#if HAVE_LIMITS_H
# include <limits.h>
#endif
#if HAVE_STRING_H
# include <string.h>
#else
# include <strings.h>
#endif
#ifndef CHAR_BIT
# define CHAR_BIT 8
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#if ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
#include <argmatch.h>
#include <xstrtol.h>
#include "human.h"
static const char suffixes[] =
{
0, /* not used */
'k', /* kilo */
'M', /* Mega */
'G', /* Giga */
'T', /* Tera */
'P', /* Peta */
'E', /* Exa */
'Z', /* Zetta */
'Y' /* Yotta */
};
/* If INEXACT_STYLE is not human_round_to_even, and if easily
possible, adjust VALUE according to the style. */
static double
adjust_value (enum human_inexact_style inexact_style, double value)
{
/* Do not use the floor or ceil functions, as that would mean
linking with the standard math library, which is a porting pain.
So leave the value alone if it is too large to easily round. */
if (inexact_style != human_round_to_even && value < (uintmax_t) -1)
{
uintmax_t u = value;
value = u + (inexact_style == human_ceiling && u != value);
}
return value;
}
/* Like human_readable_inexact, except always round to even. */
char *
human_readable (uintmax_t n, char *buf,
int from_block_size, int output_block_size)
{
return human_readable_inexact (n, buf, from_block_size, output_block_size,
human_round_to_even);
}
/* Convert N to a human readable format in BUF.
N is expressed in units of FROM_BLOCK_SIZE. FROM_BLOCK_SIZE must
be nonnegative.
OUTPUT_BLOCK_SIZE must be nonzero. If it is positive, use units of
OUTPUT_BLOCK_SIZE in the output number.
Use INEXACT_STYLE to determine whether to take the ceiling or floor
of any result that cannot be expressed exactly.
If OUTPUT_BLOCK_SIZE is negative, use a format like "127k" if
possible, using powers of -OUTPUT_BLOCK_SIZE; otherwise, use
ordinary decimal format. Normally -OUTPUT_BLOCK_SIZE is either
1000 or 1024; it must be at least 2. Most people visually process
strings of 3-4 digits effectively, but longer strings of digits are
more prone to misinterpretation. Hence, converting to an
abbreviated form usually improves readability. Use a suffix
indicating which power is being used. For example, assuming
-OUTPUT_BLOCK_SIZE is 1024, 8500 would be converted to 8.3k,
133456345 to 127M, 56990456345 to 53G, and so on. Numbers smaller
than -OUTPUT_BLOCK_SIZE aren't modified. */
char *
human_readable_inexact (uintmax_t n, char *buf,
int from_block_size, int output_block_size,
enum human_inexact_style inexact_style)
{
uintmax_t amt;
int base;
int to_block_size;
int tenths = 0;
int power;
char *p;
/* 0 means adjusted N == AMT.TENTHS;
1 means AMT.TENTHS < adjusted N < AMT.TENTHS + 0.05;
2 means adjusted N == AMT.TENTHS + 0.05;
3 means AMT.TENTHS + 0.05 < adjusted N < AMT.TENTHS + 0.1. */
int rounding = 0;
if (output_block_size < 0)
{
base = -output_block_size;
to_block_size = 1;
}
else
{
base = 0;
to_block_size = output_block_size;
}
p = buf + LONGEST_HUMAN_READABLE;
*p = '\0';
#ifdef lint
/* Suppress `used before initialized' warning. */
power = 0;
#endif
/* Adjust AMT out of FROM_BLOCK_SIZE units and into TO_BLOCK_SIZE units. */
{
int multiplier;
int divisor;
int r2;
int r10;
if (to_block_size <= from_block_size
? (from_block_size % to_block_size != 0
|| (multiplier = from_block_size / to_block_size,
(amt = n * multiplier) / multiplier != n))
: (from_block_size == 0
|| to_block_size % from_block_size != 0
|| (divisor = to_block_size / from_block_size,
r10 = (n % divisor) * 10,
r2 = (r10 % divisor) * 2,
amt = n / divisor,
tenths = r10 / divisor,
rounding = r2 < divisor ? 0 < r2 : 2 + (divisor < r2),
0)))
{
/* Either the result cannot be computed easily using uintmax_t,
or from_block_size is zero. Fall back on floating point.
FIXME: This can yield answers that are slightly off. */
double damt = n * (from_block_size / (double) to_block_size);
if (! base)
sprintf (buf, "%.0f", adjust_value (inexact_style, damt));
else
{
double e = 1;
power = 0;
do
{
e *= base;
power++;
}
while (e * base <= damt && power < sizeof suffixes - 1);
damt /= e;
sprintf (buf, "%.1f%c", adjust_value (inexact_style, damt),
suffixes[power]);
if (4 < strlen (buf))
sprintf (buf, "%.0f%c",
adjust_value (inexact_style, damt * 10) / 10,
suffixes[power]);
}
return buf;
}
}
/* Use power of BASE notation if adjusted AMT is large enough. */
if (base && base <= amt)
{
power = 0;
do
{
int r10 = (amt % base) * 10 + tenths;
int r2 = (r10 % base) * 2 + (rounding >> 1);
amt /= base;
tenths = r10 / base;
rounding = (r2 < base
? 0 < r2 + rounding
: 2 + (base < r2 + rounding));
power++;
}
while (base <= amt && power < sizeof suffixes - 1);
*--p = suffixes[power];
if (amt < 10)
{
if (2 * (1 - (int) inexact_style)
< rounding + (tenths & (inexact_style == human_round_to_even)))
{
tenths++;
rounding = 0;
if (tenths == 10)
{
amt++;
tenths = 0;
}
}
if (amt < 10)
{
*--p = '0' + tenths;
*--p = '.';
tenths = rounding = 0;
}
}
}
if (inexact_style == human_ceiling
? 0 < tenths + rounding
: inexact_style == human_round_to_even
? 5 < tenths + (2 < rounding + (amt & 1))
: /* inexact_style == human_floor */ 0)
{
amt++;
if (amt == base && power < sizeof suffixes - 1)
{
*p = suffixes[power + 1];
*--p = '0';
*--p = '.';
amt = 1;
}
}
do
*--p = '0' + (int) (amt % 10);
while ((amt /= 10) != 0);
return p;
}
/* The default block size used for output. This number may change in
the future as disks get larger. */
#ifndef DEFAULT_BLOCK_SIZE
# define DEFAULT_BLOCK_SIZE 1024
#endif
static char const *const block_size_args[] = { "human-readable", "si", 0 };
static int const block_size_types[] = { -1024, -1000 };
static int
default_block_size (void)
{
return getenv ("POSIXLY_CORRECT") ? 512 : DEFAULT_BLOCK_SIZE;
}
static strtol_error
humblock (char const *spec, int *block_size)
{
int i;
if (! spec && ! (spec = getenv ("BLOCK_SIZE")))
*block_size = default_block_size ();
else if (0 <= (i = ARGMATCH (spec, block_size_args, block_size_types)))
*block_size = block_size_types[i];
else
{
char *ptr;
unsigned long val;
strtol_error e = xstrtoul (spec, &ptr, 0, &val, "eEgGkKmMpPtTyYzZ0");
if (e != LONGINT_OK)
return e;
if (*ptr)
return LONGINT_INVALID_SUFFIX_CHAR;
if ((int) val < 0 || val != (int) val)
return LONGINT_OVERFLOW;
*block_size = (int) val;
}
return LONGINT_OK;
}
void
human_block_size (char const *spec, int report_errors, int *block_size)
{
strtol_error e = humblock (spec, block_size);
if (*block_size == 0)
{
*block_size = default_block_size ();
e = LONGINT_INVALID;
}
if (e != LONGINT_OK && report_errors)
fprintf(stderr, "Invalid block size entered\n");
}

39
human.h Normal file
View file

@ -0,0 +1,39 @@
#ifndef HUMAN_H_
# define HUMAN_H_ 1
# if HAVE_CONFIG_H
# include <config.h>
# endif
# if HAVE_INTTYPES_H
# include <inttypes.h>
# endif
/* A conservative bound on the maximum length of a human-readable string.
The output can be the product of the largest uintmax_t and the largest int,
so add their sizes before converting to a bound on digits. */
# define LONGEST_HUMAN_READABLE ((sizeof (uintmax_t) + sizeof (int)) \
* CHAR_BIT / 3)
# ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
# endif
enum human_inexact_style
{
human_floor = -1,
human_round_to_even = 0,
human_ceiling = 1
};
char *human_readable PARAMS ((uintmax_t, char *, int, int));
char *human_readable_inexact PARAMS ((uintmax_t, char *, int, int,
enum human_inexact_style));
void human_block_size PARAMS ((char const *, int, int *));
#endif /* HUMAN_H_ */

322
install-sh Executable file
View file

@ -0,0 +1,322 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2004-09-10.20
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# 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. It can only install one file at a time, a restriction
# shared with many OS's install programs.
# 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}"
chmodcmd="$chmodprog 0755"
chowncmd=
chgrpcmd=
stripcmd=
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=
dst=
dir_arg=
dstarg=
no_target_directory=
usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
-c (ignored)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
--help display this help and exit.
--version display version info and exit.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
"
while test -n "$1"; do
case $1 in
-c) shift
continue;;
-d) dir_arg=true
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
--help) echo "$usage"; exit 0;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
-s) stripcmd=$stripprog
shift
continue;;
-t) dstarg=$2
shift
shift
continue;;
-T) no_target_directory=true
shift
continue;;
--version) echo "$0 $scriptversion"; exit 0;;
*) # When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
test -n "$dir_arg$dstarg" && break
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dstarg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dstarg"
shift # fnord
fi
shift # arg
dstarg=$arg
done
break;;
esac
done
if test -z "$1"; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
for src
do
# Protect names starting with `-'.
case $src in
-*) src=./$src ;;
esac
if test -n "$dir_arg"; then
dst=$src
src=
if test -d "$dst"; then
mkdircmd=:
chmodcmd=
else
mkdircmd=$mkdirprog
fi
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dstarg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dstarg
# Protect names starting with `-'.
case $dst in
-*) dst=./$dst ;;
esac
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dstarg: Is a directory" >&2
exit 1
fi
dst=$dst/`basename "$src"`
fi
fi
# This sed command emulates the dirname command.
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Make sure that the destination directory exists.
# Skip lots of stat calls in the usual case.
if test ! -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 test $# -ne 0 ; do
pathcomp=$pathcomp$1
shift
if test ! -d "$pathcomp"; then
$mkdirprog "$pathcomp"
# mkdir can fail with a `File exist' error in case several
# install-sh are creating the directory concurrently. This
# is OK.
test -d "$pathcomp" || exit
fi
pathcomp=$pathcomp/
done
fi
if test -n "$dir_arg"; then
$doit $mkdircmd "$dst" \
&& { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
else
dstfile=`basename "$dst"`
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
trap '(exit $?); exit' 1 2 13 15
# Copy the file name to the temp name.
$doit $cpprog "$src" "$dsttmp" &&
# 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 $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
&& { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
&& { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
&& { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
# Now rename the file to the real destination.
{ $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
|| {
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
if test -f "$dstdir/$dstfile"; then
$doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
|| $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
|| {
echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
(exit 1); exit
}
else
:
fi
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
}
}
fi || { (exit 1); exit; }
done
# The final little trick to "correctly" pass the exit status to the exit trap.
{
(exit 0); exit
}
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

112
log.c Normal file
View file

@ -0,0 +1,112 @@
/* $Id: log.c,v 1.6 2005/05/15 20:15:28 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#include "dcfldd.h"
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <string.h>
#include "log.h"
#include "hash.h"
#include "verify.h"
#include <stdarg.h>
#include "hashformat.h"
FILE *errlog = NULL;
void syscall_error(char *str)
{
syscall_error_noexit(str);
exit(1);
}
void syscall_error_noexit(char *str)
{
char *errstr = strerror(errno);
fprintf(stderr, "%s:%s: %s\n", program_name, str == NULL ? "" : str, errstr);
if (errlog != NULL)
fprintf(errlog, "%s:%s: %s\n", program_name, str == NULL ? "" : str, errstr);
}
void user_error(char *str, ...)
{
va_list ap;
va_start(ap, str);
fprintf(stderr, "%s: ", program_name);
vfprintf(stderr, str, ap);
fprintf(stderr, "\n");
if (errlog != NULL) {
fprintf(errlog, "%s: ", program_name);
vfprintf(errlog, str, ap);
fprintf(errlog, "\n");
}
va_end(ap);
exit(1);
}
void log_info(char *str, ...)
{
va_list ap;
va_start(ap, str);
vfprintf(stderr, str, ap);
if (errlog != NULL) {
vfprintf(errlog, str, ap);
}
va_end(ap);
}
void internal_error(char *str)
{
fprintf(stderr, "%s: internal error: %s\n", program_name, str);
if (errlog != NULL)
fprintf(errlog, "%s: internal error: %s\n", program_name, str);
exit(1);
}
void log_hashwindow(hashtype_t *htype, off_t wina, off_t winb, size_t bs, char *hash)
{
print_fmt(hashformat, htype->log, wina, winb, bs, htype->name, hash);
}
void log_hashtotal(hashtype_t *htype, off_t wina, off_t winb, size_t bs, char *hash)
{
print_fmt(totalhashformat, htype->log, wina, winb, bs, htype->name, hash);
}
void log_verifywindow(hashtype_t *htype, off_t wina, off_t winb, int mismatch)
{
fprintf(htype->log, "%llu - %llu: %s\n",
(unsigned long long int) wina,
(unsigned long long int) winb,
mismatch ? "Mismatch" : "Match");
}
void log_verifytotal(hashtype_t *htype, int mismatch)
{
fprintf(htype->log, "Total: %s\n", mismatch ? "Mismatch" : "Match");
}

47
log.h Normal file
View file

@ -0,0 +1,47 @@
/* $Id: log.h,v 1.5 2005/05/15 20:15:28 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#ifndef LOG_H
#define LOG_H
#include "dcfldd.h"
#include "hash.h"
#include <stdarg.h>
#include <sys/types.h>
#include <stdio.h>
extern FILE *errlog;
extern void syscall_error(char *);
extern void syscall_error_noexit(char *);
extern void user_error(char *, ...);
extern void internal_error(char *);
extern void log_info(char *, ...);
extern void log_hashwindow(hashtype_t *, off_t, off_t, size_t, char *);
extern void log_hashtotal(hashtype_t *, off_t, off_t, size_t, char *);
extern void log_verifywindow(hashtype_t *, off_t, off_t, int);
extern void log_verifytotal(hashtype_t *, int);
#endif /* LOG_H */

91
long-options.c Normal file
View file

@ -0,0 +1,91 @@
/* Utility to accept --help and --version options as unobtrusively as possible.
Copyright (C) 1993, 1994, 1998, 1999, 2000 Free Software Foundation, Inc.
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, 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. */
/* Written by Jim Meyering. */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <getopt.h>
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include "long-options.h"
#include "version-etc.h"
#if ENABLE_NLS
# include <libintl.h>
# define _(Text) gettext (Text)
#else
# define _(Text) Text
#endif
static struct option const long_options[] =
{
{"help", no_argument, 0, 'h'},
{"version", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
/* Process long options --help and --version, but only if argc == 2.
Be careful not to gobble up `--'. */
void
parse_long_options (int argc,
char **argv,
const char *command_name,
const char *package,
const char *version,
const char *authors,
void (*usage_func)())
{
int c;
int saved_opterr;
saved_opterr = opterr;
/* Don't print an error message for unrecognized options. */
opterr = 0;
if (argc == 2
&& (c = getopt_long (argc, argv, "+", long_options, NULL)) != -1)
{
switch (c)
{
case 'h':
(*usage_func) (0);
case 'v':
version_etc (stdout, command_name, package, version, authors);
exit (0);
default:
/* Don't process any other long-named options. */
break;
}
}
/* Restore previous value. */
opterr = saved_opterr;
/* Reset this to zero so that getopt internals get initialized from
the probably-new parameters when/if getopt is called later. */
optind = 0;
}

35
long-options.h Normal file
View file

@ -0,0 +1,35 @@
/* long-options.h -- declaration for --help- and --version-handling function.
Copyright (C) 1993, 1994, 1998, 1999 Free Software Foundation, Inc.
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, 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. */
/* Written by Jim Meyering. */
#ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
#endif
void
parse_long_options PARAMS ((int _argc,
char **_argv,
const char *_command_name,
const char *_package,
const char *_version,
const char *_authors,
void (*_usage) (int)));

286
md5.c Normal file
View file

@ -0,0 +1,286 @@
/*
**********************************************************************
** md5.c **
** RSA Data Security, Inc. MD5 Message Digest Algorithm **
** Created: 2/17/90 RLR **
** Revised: 1/91 SRD,AJ,BSK,JT Reference C Version **
**********************************************************************
*/
/*
**********************************************************************
** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
** **
** License to copy and use this software is granted provided that **
** it is identified as the "RSA Data Security, Inc. MD5 Message **
** Digest Algorithm" in all material mentioning or referencing this **
** software or this function. **
** **
** License is also granted to make and use derivative works **
** provided that such works are identified as "derived from the RSA **
** Data Security, Inc. MD5 Message Digest Algorithm" in all **
** material mentioning or referencing the derived work. **
** **
** RSA Data Security, Inc. makes no representations concerning **
** either the merchantability of this software or the suitability **
** of this software for any particular purpose. It is provided "as **
** is" without express or implied warranty of any kind. **
** **
** These notices must be retained in any copies of any part of this **
** documentation and/or software. **
**********************************************************************
*/
/* -- include the following line if the md5.h header file is separate -- */
#include "md5.h"
/* forward declaration */
static void Transform ();
static unsigned char PADDING[64] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
/* F, G and H are basic MD5 functions: selection, majority, parity */
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/* ROTATE_LEFT rotates x left n bits */
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4 */
/* Rotation is separate from addition to prevent recomputation */
#define FF(a, b, c, d, x, s, ac) \
{(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) \
{(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) \
{(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) \
{(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
void MD5Init (mdContext)
MD5_CTX *mdContext;
{
mdContext->i[0] = mdContext->i[1] = (UINT4)0;
/* Load magic initialization constants.
*/
mdContext->buf[0] = (UINT4)0x67452301;
mdContext->buf[1] = (UINT4)0xefcdab89;
mdContext->buf[2] = (UINT4)0x98badcfe;
mdContext->buf[3] = (UINT4)0x10325476;
}
void MD5Update (mdContext, inBuf, inLen)
MD5_CTX *mdContext;
const unsigned char *inBuf;
unsigned int inLen;
{
UINT4 in[16];
int mdi;
unsigned int i, ii;
/* compute number of bytes mod 64 */
mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
/* update number of bits */
if ((mdContext->i[0] + ((UINT4)inLen << 3)) < mdContext->i[0])
mdContext->i[1]++;
mdContext->i[0] += ((UINT4)inLen << 3);
mdContext->i[1] += ((UINT4)inLen >> 29);
while (inLen--) {
/* add new character to buffer, increment mdi */
mdContext->in[mdi++] = *inBuf++;
/* transform if necessary */
if (mdi == 0x40) {
for (i = 0, ii = 0; i < 16; i++, ii += 4)
in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
(((UINT4)mdContext->in[ii+2]) << 16) |
(((UINT4)mdContext->in[ii+1]) << 8) |
((UINT4)mdContext->in[ii]);
Transform (mdContext->buf, in);
mdi = 0;
}
}
}
void MD5Final (mdContext, buf)
MD5_CTX *mdContext;
char *buf;
{
UINT4 in[16];
int mdi;
unsigned int i, ii;
unsigned int padLen;
/* save number of bits */
in[14] = mdContext->i[0];
in[15] = mdContext->i[1];
/* compute number of bytes mod 64 */
mdi = (int)((mdContext->i[0] >> 3) & 0x3F);
/* pad out to 56 mod 64 */
padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi);
MD5Update (mdContext, PADDING, padLen);
/* append length in bits and transform */
for (i = 0, ii = 0; i < 14; i++, ii += 4)
in[i] = (((UINT4)mdContext->in[ii+3]) << 24) |
(((UINT4)mdContext->in[ii+2]) << 16) |
(((UINT4)mdContext->in[ii+1]) << 8) |
((UINT4)mdContext->in[ii]);
Transform (mdContext->buf, in);
/* store buffer in digest */
for (i = 0, ii = 0; i < 4; i++, ii += 4) {
mdContext->digest[ii] = (unsigned char)(mdContext->buf[i] & 0xFF);
mdContext->digest[ii+1] =
(unsigned char)((mdContext->buf[i] >> 8) & 0xFF);
mdContext->digest[ii+2] =
(unsigned char)((mdContext->buf[i] >> 16) & 0xFF);
mdContext->digest[ii+3] =
(unsigned char)((mdContext->buf[i] >> 24) & 0xFF);
}
MD5Sprint(mdContext, buf);
}
/* Print the context to the given buffer (32 digits)
*/
void MD5Sprint (mdContext, buf)
MD5_CTX *mdContext;
char *buf;
{
int i;
for (i = 0; i < 16; i++)
sprintf (&buf[i*2], "%02x", mdContext->digest[i]);
}
/* Basic MD5 step. Transform buf based on in.
*/
static void Transform (buf, in)
UINT4 *buf;
UINT4 *in;
{
UINT4 a = buf[0], b = buf[1], c = buf[2], d = buf[3];
/* Round 1 */
#define S11 7
#define S12 12
#define S13 17
#define S14 22
FF ( a, b, c, d, in[ 0], S11, 3614090360u); /* 1 */
FF ( d, a, b, c, in[ 1], S12, 3905402710u); /* 2 */
FF ( c, d, a, b, in[ 2], S13, 606105819u); /* 3 */
FF ( b, c, d, a, in[ 3], S14, 3250441966u); /* 4 */
FF ( a, b, c, d, in[ 4], S11, 4118548399u); /* 5 */
FF ( d, a, b, c, in[ 5], S12, 1200080426u); /* 6 */
FF ( c, d, a, b, in[ 6], S13, 2821735955u); /* 7 */
FF ( b, c, d, a, in[ 7], S14, 4249261313u); /* 8 */
FF ( a, b, c, d, in[ 8], S11, 1770035416u); /* 9 */
FF ( d, a, b, c, in[ 9], S12, 2336552879u); /* 10 */
FF ( c, d, a, b, in[10], S13, 4294925233u); /* 11 */
FF ( b, c, d, a, in[11], S14, 2304563134u); /* 12 */
FF ( a, b, c, d, in[12], S11, 1804603682u); /* 13 */
FF ( d, a, b, c, in[13], S12, 4254626195u); /* 14 */
FF ( c, d, a, b, in[14], S13, 2792965006u); /* 15 */
FF ( b, c, d, a, in[15], S14, 1236535329u); /* 16 */
/* Round 2 */
#define S21 5
#define S22 9
#define S23 14
#define S24 20
GG ( a, b, c, d, in[ 1], S21, 4129170786u); /* 17 */
GG ( d, a, b, c, in[ 6], S22, 3225465664u); /* 18 */
GG ( c, d, a, b, in[11], S23, 643717713u); /* 19 */
GG ( b, c, d, a, in[ 0], S24, 3921069994u); /* 20 */
GG ( a, b, c, d, in[ 5], S21, 3593408605u); /* 21 */
GG ( d, a, b, c, in[10], S22, 38016083u); /* 22 */
GG ( c, d, a, b, in[15], S23, 3634488961u); /* 23 */
GG ( b, c, d, a, in[ 4], S24, 3889429448u); /* 24 */
GG ( a, b, c, d, in[ 9], S21, 568446438u); /* 25 */
GG ( d, a, b, c, in[14], S22, 3275163606u); /* 26 */
GG ( c, d, a, b, in[ 3], S23, 4107603335u); /* 27 */
GG ( b, c, d, a, in[ 8], S24, 1163531501u); /* 28 */
GG ( a, b, c, d, in[13], S21, 2850285829u); /* 29 */
GG ( d, a, b, c, in[ 2], S22, 4243563512u); /* 30 */
GG ( c, d, a, b, in[ 7], S23, 1735328473u); /* 31 */
GG ( b, c, d, a, in[12], S24, 2368359562u); /* 32 */
/* Round 3 */
#define S31 4
#define S32 11
#define S33 16
#define S34 23
HH ( a, b, c, d, in[ 5], S31, 4294588738u); /* 33 */
HH ( d, a, b, c, in[ 8], S32, 2272392833u); /* 34 */
HH ( c, d, a, b, in[11], S33, 1839030562u); /* 35 */
HH ( b, c, d, a, in[14], S34, 4259657740u); /* 36 */
HH ( a, b, c, d, in[ 1], S31, 2763975236u); /* 37 */
HH ( d, a, b, c, in[ 4], S32, 1272893353u); /* 38 */
HH ( c, d, a, b, in[ 7], S33, 4139469664u); /* 39 */
HH ( b, c, d, a, in[10], S34, 3200236656u); /* 40 */
HH ( a, b, c, d, in[13], S31, 681279174u); /* 41 */
HH ( d, a, b, c, in[ 0], S32, 3936430074u); /* 42 */
HH ( c, d, a, b, in[ 3], S33, 3572445317u); /* 43 */
HH ( b, c, d, a, in[ 6], S34, 76029189u); /* 44 */
HH ( a, b, c, d, in[ 9], S31, 3654602809u); /* 45 */
HH ( d, a, b, c, in[12], S32, 3873151461u); /* 46 */
HH ( c, d, a, b, in[15], S33, 530742520u); /* 47 */
HH ( b, c, d, a, in[ 2], S34, 3299628645u); /* 48 */
/* Round 4 */
#define S41 6
#define S42 10
#define S43 15
#define S44 21
II ( a, b, c, d, in[ 0], S41, 4096336452u); /* 49 */
II ( d, a, b, c, in[ 7], S42, 1126891415u); /* 50 */
II ( c, d, a, b, in[14], S43, 2878612391u); /* 51 */
II ( b, c, d, a, in[ 5], S44, 4237533241u); /* 52 */
II ( a, b, c, d, in[12], S41, 1700485571u); /* 53 */
II ( d, a, b, c, in[ 3], S42, 2399980690u); /* 54 */
II ( c, d, a, b, in[10], S43, 4293915773u); /* 55 */
II ( b, c, d, a, in[ 1], S44, 2240044497u); /* 56 */
II ( a, b, c, d, in[ 8], S41, 1873313359u); /* 57 */
II ( d, a, b, c, in[15], S42, 4264355552u); /* 58 */
II ( c, d, a, b, in[ 6], S43, 2734768916u); /* 59 */
II ( b, c, d, a, in[13], S44, 1309151649u); /* 60 */
II ( a, b, c, d, in[ 4], S41, 4149444226u); /* 61 */
II ( d, a, b, c, in[11], S42, 3174756917u); /* 62 */
II ( c, d, a, b, in[ 2], S43, 718787259u); /* 63 */
II ( b, c, d, a, in[ 9], S44, 3951481745u); /* 64 */
buf[0] += a;
buf[1] += b;
buf[2] += c;
buf[3] += d;
}

68
md5.h Normal file
View file

@ -0,0 +1,68 @@
/*
**********************************************************************
** md5.h -- Header file for implementation of MD5 **
** RSA Data Security, Inc. MD5 Message Digest Algorithm **
** Created: 2/17/90 RLR **
** Revised: 12/27/90 SRD,AJ,BSK,JT Reference C version **
** Revised (for MD5): RLR 4/27/91 **
** -- G modified to have y&~z instead of y&z **
** -- FF, GG, HH modified to add in last register done **
** -- Access pattern: round 2 works mod 5, round 3 works mod 3 **
** -- distinct additive constant for each step **
** -- round 4 added, working mod 7 **
**********************************************************************
*/
/*
**********************************************************************
** Copyright (C) 1990, RSA Data Security, Inc. All rights reserved. **
** **
** License to copy and use this software is granted provided that **
** it is identified as the "RSA Data Security, Inc. MD5 Message **
** Digest Algorithm" in all material mentioning or referencing this **
** software or this function. **
** **
** License is also granted to make and use derivative works **
** provided that such works are identified as "derived from the RSA **
** Data Security, Inc. MD5 Message Digest Algorithm" in all **
** material mentioning or referencing the derived work. **
** **
** RSA Data Security, Inc. makes no representations concerning **
** either the merchantability of this software or the suitability **
** of this software for any particular purpose. It is provided "as **
** is" without express or implied warranty of any kind. **
** **
** These notices must be retained in any copies of any part of this **
** documentation and/or software. **
**********************************************************************
*/
#ifndef MD5_H
#define MD5_H
#if HAVE_INTTYPES_H
# include <inttypes.h>
#else
# if HAVE_STDINT_H
# include <stdint.h>
# endif
#endif
#include "hash.h"
/* typedef a 32 bit type */
typedef uint32_t UINT4;
#define MD5_DIGEST_STRING_LENGTH 32
/* Data structure for MD5 (Message Digest) computation */
typedef struct {
UINT4 i[2]; /* number of _bits_ handled mod 2^64 */
UINT4 buf[4]; /* scratch buffer */
unsigned char in[64]; /* input buffer */
unsigned char digest[16]; /* actual digest after MD5Final call */
} MD5_CTX;
void MD5Init (MD5_CTX *);
void MD5Update (MD5_CTX *, const unsigned char *, unsigned int);
void MD5Final (MD5_CTX *, char *);
void MD5Sprint (MD5_CTX *, char *);
#endif /* MD5_H */

353
missing Executable file
View file

@ -0,0 +1,353 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
scriptversion=2004-09-07.08
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004
# Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# 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, 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.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
msg="missing on your system"
case "$1" in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
tar try tar, gnutar, gtar, then tar without non-portable flags
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
Send bug reports to <bug-automake@gnu.org>."
exit 0
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit 0
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
esac
# Now exit if we have it, but it failed. Also exit now if we
# don't have it and --version was passed (most likely to detect
# the program).
case "$1" in
lex|yacc)
# Not GNU programs, they don't have --version.
;;
tar)
if test -n "$run"; then
echo 1>&2 "ERROR: \`tar' requires --run"
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
exit 1
fi
;;
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case "$1" in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case "$f" in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison|yacc)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if [ ! -f y.tab.h ]; then
echo >y.tab.h
fi
if [ ! -f y.tab.c ]; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex|flex)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if [ $# -ne 1 ]; then
eval LASTARG="\${$#}"
case "$LASTARG" in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if [ -f "$SRCFILE" ]; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if [ ! -f lex.yy.c ]; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
fi
if [ -f "$file" ]; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit 1
fi
;;
makeinfo)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
if test -z "$file"; then
file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
fi
touch $file
;;
tar)
shift
# We have already tried tar in the generic part.
# Look for gnutar/gtar before invocation to avoid ugly error
# messages.
if (gnutar --version > /dev/null 2>&1); then
gnutar "$@" && exit 0
fi
if (gtar --version > /dev/null 2>&1); then
gtar "$@" && exit 0
fi
firstarg="$1"
if shift; then
case "$firstarg" in
*o*)
firstarg=`echo "$firstarg" | sed s/o//`
tar "$firstarg" "$@" && exit 0
;;
esac
case "$firstarg" in
*h*)
firstarg=`echo "$firstarg" | sed s/h//`
tar "$firstarg" "$@" && exit 0
;;
esac
fi
echo 1>&2 "\
WARNING: I can't seem to be able to run \`tar' with the given arguments.
You may want to install GNU tar or Free paxutils, or check the
command line arguments."
exit 1
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

163
output.c Normal file
View file

@ -0,0 +1,163 @@
/* $Id: output.c,v 1.5 2005/06/15 14:33:04 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#include "dcfldd.h"
#include "output.h"
#include "full-write.h"
#include "config.h"
#include <stdarg.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include "split.h"
#include "log.h"
#include "util.h"
outputlist_t *outputlist = NULL;
void open_output(char *filename)
{
mode_t perms = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH;
int fd;
int opts
= (O_CREAT
| (seek_records || (conversions_mask & C_NOTRUNC) ? 0 : O_TRUNC));
/* Open the output file with *read* access only if we might
need to read to satisfy a `seek=' request. If we can't read
the file, go ahead with write-only access; it might work. */
if ((! seek_records
|| (fd = open(filename, O_RDWR | opts, perms)) < 0)
&& (fd = open(filename, O_WRONLY | opts, perms)) < 0)
{
syscall_error(filename);
}
#if HAVE_FTRUNCATE
if (seek_records != 0 && !(conversions_mask & C_NOTRUNC)) {
struct stat statbuf;
off_t o = seek_records * output_blocksize;
if (o / output_blocksize != seek_records)
syscall_error(filename);
if (fstat(fd, &statbuf) != 0)
syscall_error(filename);
/* Complain only when ftruncate fails on a regular file, a
directory, or a shared memory object, as the 2000-08
POSIX draft specifies ftruncate's behavior only for these
file types. For example, do not complain when Linux 2.4
ftruncate fails on /dev/fd0. */
if (ftruncate(fd, o) != 0
&& (S_ISREG(statbuf.st_mode)
|| S_ISDIR(statbuf.st_mode)
|| S_TYPEISSHM(&statbuf)))
{
char buf[LONGEST_HUMAN_READABLE + 1];
log_info("%s: %s: advancing past %s bytes in output file %s",
program_name,
strerror(errno),
human_readable(o, buf, 1, 1),
filename);
}
}
#endif /* HAVE_FTRUNCATE */
outputlist_add(SINGLE_FILE, fd);
}
void open_output_pipe(char *command)
{
FILE *stream;
stream = popen2(command, "w");
if (stream == NULL)
syscall_error(command);
outputlist_add(SINGLE_FILE, fileno(stream));
}
void outputlist_add(outputtype_t type, ...)
{
va_list ap;
outputlist_t *ptr;
split_t *split;
va_start(ap, type);
/* forward to the last struct in outputlist */
for (ptr = outputlist; ptr != NULL && ptr->next != NULL; ptr = ptr->next)
;
if (ptr == NULL)
outputlist = ptr = malloc(sizeof (*ptr));
else {
ptr->next = malloc(sizeof (*ptr));
ptr = ptr->next;
}
ptr->next = NULL;
ptr->type = type;
switch (type) {
case SINGLE_FILE:
ptr->data.fd = va_arg(ap, int);
break;
case SPLIT_FILE:
split = malloc(sizeof *split);
split->name = strdup(va_arg(ap, char *));
split->format = strdup(va_arg(ap, char *));
split->max_bytes = va_arg(ap, off_t);
split->total_bytes = 0;
split->curr_bytes = 0;
split->currfd = -1;
ptr->data.split = split;
break;
}
va_end(ap);
}
int outputlist_write(const char *buf, size_t len)
{
outputlist_t *ptr;
int nwritten = 0;
for (ptr = outputlist; ptr != NULL; ptr = ptr->next) {
nwritten = 0;
switch (ptr->type) {
case SINGLE_FILE:
nwritten = full_write(ptr->data.fd, buf, len);
break;
case SPLIT_FILE:
nwritten = split_write(ptr->data.split, buf, len);
break;
}
if (nwritten < len)
break;
}
return nwritten;
}

55
output.h Normal file
View file

@ -0,0 +1,55 @@
/* $Id: output.h,v 1.4 2005/05/15 20:15:28 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#ifndef OUTPUT_H
#define OUTPUT_H
#include "dcfldd.h"
#include <sys/types.h>
#include "split.h"
typedef enum
{
NONE,
SINGLE_FILE,
SPLIT_FILE
} outputtype_t;
typedef struct outputlist_s
{
struct outputlist_s *next;
outputtype_t type;
union {
int fd;
split_t *split;
} data;
} outputlist_t;
extern outputlist_t *outputlist;
extern void open_output(char *);
extern void open_output_pipe(char *);
extern void outputlist_add(outputtype_t, ...);
extern int outputlist_write(const char *, size_t);
#endif /* OUTPUT_H */

54
pathmax.h Normal file
View file

@ -0,0 +1,54 @@
/* Define PATH_MAX somehow. Requires sys/types.h.
Copyright (C) 1992, 1999 Free Software Foundation, Inc.
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, 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. */
#ifndef _PATHMAX_H
# define _PATHMAX_H
# ifdef HAVE_UNISTD_H
# include <unistd.h>
# endif
/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define
PATH_MAX but might cause redefinition warnings when sys/param.h is
later included (as on MORE/BSD 4.3). */
# if defined(_POSIX_VERSION) || (defined(HAVE_LIMITS_H) && !defined(__GNUC__))
# include <limits.h>
# endif
# ifndef _POSIX_PATH_MAX
# define _POSIX_PATH_MAX 255
# endif
# if !defined(PATH_MAX) && defined(_PC_PATH_MAX)
# define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 \
: pathconf ("/", _PC_PATH_MAX))
# endif
/* Don't include sys/param.h if it already has been. */
# if defined(HAVE_SYS_PARAM_H) && !defined(PATH_MAX) && !defined(MAXPATHLEN)
# include <sys/param.h>
# endif
# if !defined(PATH_MAX) && defined(MAXPATHLEN)
# define PATH_MAX MAXPATHLEN
# endif
# ifndef PATH_MAX
# define PATH_MAX _POSIX_PATH_MAX
# endif
#endif /* _PATHMAX_H */

72
pattern.c Normal file
View file

@ -0,0 +1,72 @@
/* $Id: pattern.c,v 1.3 2005/05/13 18:52:06 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#include "dcfldd.h"
#include <sys/types.h>
/* Pattern to be written out */
char *pattern;
size_t pattern_len;
int input_from_pattern;
char *make_pattern(char *pattern)
{
size_t plen, numbytes, i;
char *buffer;
plen = strlen(pattern);
if (plen == 0 || plen % 2 != 0)
return NULL;
numbytes = plen / 2;
buffer = malloc(numbytes);
for (i = 0; i < numbytes; i++) {
char tmpstring[3];
int byteval;
strncpy(tmpstring, &pattern[i*2], 2);
tmpstring[2] = '\0';
byteval = hex2char(tmpstring);
if (byteval == -1) {
free(buffer);
return NULL;
}
buffer[i] = (char)byteval;
}
pattern_len = numbytes;
return buffer;
}
void replicate_pattern(char *pattern, char *buffer, size_t size)
{
size_t i;
for (i = 0; i < size; i++)
buffer[i] = pattern[i % pattern_len];
}

37
pattern.h Normal file
View file

@ -0,0 +1,37 @@
/* $Id: pattern.h,v 1.3 2005/05/13 18:52:06 harbourn Exp $
* dcfldd - The Enhanced Forensic DD
* By Nicholas Harbour
*/
/* Copyright (C) 85, 90, 91, 1995-2001, 2005 Free Software Foundation, Inc.
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, 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. */
/* GNU dd originally written by Paul Rubin, David MacKenzie, and Stuart Kemp. */
#ifndef PATTERN_H
#define PATTERN_H
#include "dcfldd.h"
#include <sys/types.h>
extern char *pattern;
extern size_t pattern_len;
extern int input_from_pattern;
extern char *make_pattern(char *);
extern void replicate_pattern(char *, char *, size_t);
#endif /* PATTERN_H */

59
safe-read.c Normal file
View file

@ -0,0 +1,59 @@
/* safe-read.c -- an interface to read that retries after interrupts
Copyright (C) 1993, 1994, 1998 Free Software Foundation, Inc.
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, 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.
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <errno.h>
#ifndef errno
extern int errno;
#endif
#include "safe-read.h"
/* Read LEN bytes at PTR from descriptor DESC, retrying if interrupted.
Return the actual number of bytes read, zero for EOF, or negative
for an error. */
ssize_t
safe_read (int desc, void *ptr, size_t len)
{
ssize_t n_chars;
if (len <= 0)
return len;
#ifdef EINTR
do
{
n_chars = read (desc, ptr, len);
}
while (n_chars < 0 && errno == EINTR);
#else
n_chars = read (desc, ptr, len);
#endif
return n_chars;
}

10
safe-read.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef PARAMS
# if defined PROTOTYPES || (defined __STDC__ && __STDC__)
# define PARAMS(Args) Args
# else
# define PARAMS(Args) ()
# endif
#endif
ssize_t
safe_read PARAMS ((int desc, void *ptr, size_t len));

649
sha1.c Normal file
View file

@ -0,0 +1,649 @@
/*-
* Copyright (c) 2001-2003 Allan Saddi <allan@saddi.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY ALLAN SADDI AND HIS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL ALLAN SADDI OR HIS CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id: sha1.c,v 1.3 2005/05/13 18:52:06 harbourn Exp $
*/
/*
* Define WORDS_BIGENDIAN if compiling on a big-endian architecture.
*
* Define SHA1_TEST to test the implementation using the NIST's
* sample messages. The output should be:
*
* a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d
* 84983e44 1c3bd26e baae4aa1 f95129e5 e54670f1
* 34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */
#if HAVE_INTTYPES_H
# include <inttypes.h>
#else
# if HAVE_STDINT_H
# include <stdint.h>
# endif
#endif
#include <string.h>
#include "sha1.h"
#ifndef lint
static const char rcsid[] =
"$Id: sha1.c,v 1.3 2005/05/13 18:52:06 harbourn Exp $";
#endif /* !lint */
#define ROTL(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
#define ROTR(x, n) (((x) >> (n)) | ((x) << (32 - (n))))
#define F_0_19(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
#define F_20_39(x, y, z) ((x) ^ (y) ^ (z))
#define F_40_59(x, y, z) (((x) & ((y) | (z))) | ((y) & (z)))
#define F_60_79(x, y, z) ((x) ^ (y) ^ (z))
#define DO_ROUND(F, K) { \
temp = ROTL(a, 5) + F(b, c, d) + e + *(W++) + K; \
e = d; \
d = c; \
c = ROTL(b, 30); \
b = a; \
a = temp; \
}
#define K_0_19 0x5a827999L
#define K_20_39 0x6ed9eba1L
#define K_40_59 0x8f1bbcdcL
#define K_60_79 0xca62c1d6L
#ifndef RUNTIME_ENDIAN
#ifdef WORDS_BIGENDIAN
#define BYTESWAP(x) (x)
#define BYTESWAP64(x) (x)
#else /* WORDS_BIGENDIAN */
#define BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | \
(ROTL((x), 8) & 0x00ff00ffL))
#define BYTESWAP64(x) _byteswap64(x)
static inline uint64_t _byteswap64(uint64_t x)
{
uint32_t a = x >> 32;
uint32_t b = (uint32_t) x;
return ((uint64_t) BYTESWAP(b) << 32) | (uint64_t) BYTESWAP(a);
}
#endif /* WORDS_BIGENDIAN */
#else /* !RUNTIME_ENDIAN */
#define BYTESWAP(x) _byteswap(sc->littleEndian, x)
#define BYTESWAP64(x) _byteswap64(sc->littleEndian, x)
#define _BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | \
(ROTL((x), 8) & 0x00ff00ffL))
#define _BYTESWAP64(x) __byteswap64(x)
static inline uint64_t __byteswap64(uint64_t x)
{
uint32_t a = x >> 32;
uint32_t b = (uint32_t) x;
return ((uint64_t) _BYTESWAP(b) << 32) | (uint64_t) _BYTESWAP(a);
}
static inline uint32_t _byteswap(int littleEndian, uint32_t x)
{
if (!littleEndian)
return x;
else
return _BYTESWAP(x);
}
static inline uint64_t _byteswap64(int littleEndian, uint64_t x)
{
if (!littleEndian)
return x;
else
return _BYTESWAP64(x);
}
static inline void setEndian(int *littleEndianp)
{
union {
uint32_t w;
uint8_t b[4];
} endian;
endian.w = 1L;
*littleEndianp = endian.b[0] != 0;
}
#endif /* !RUNTIME_ENDIAN */
static const uint8_t padding[64] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void
SHA1Init (SHA1Context *sc)
{
#ifdef RUNTIME_ENDIAN
setEndian (&sc->littleEndian);
#endif /* RUNTIME_ENDIAN */
sc->totalLength = 0LL;
sc->hash[0] = 0x67452301L;
sc->hash[1] = 0xefcdab89L;
sc->hash[2] = 0x98badcfeL;
sc->hash[3] = 0x10325476L;
sc->hash[4] = 0xc3d2e1f0L;
sc->bufferLength = 0L;
}
static void
burnStack (int size)
{
char buf[128];
memset (buf, 0, sizeof (buf));
size -= sizeof (buf);
if (size > 0)
burnStack (size);
}
static void
SHA1Guts (SHA1Context *sc, const uint32_t *cbuf)
{
uint32_t buf[80];
uint32_t *W, *W3, *W8, *W14, *W16;
uint32_t a, b, c, d, e, temp;
int i;
W = buf;
for (i = 15; i >= 0; i--) {
*(W++) = BYTESWAP(*cbuf);
cbuf++;
}
W16 = &buf[0];
W14 = &buf[2];
W8 = &buf[8];
W3 = &buf[13];
for (i = 63; i >= 0; i--) {
*W = *(W3++) ^ *(W8++) ^ *(W14++) ^ *(W16++);
*W = ROTL(*W, 1);
W++;
}
a = sc->hash[0];
b = sc->hash[1];
c = sc->hash[2];
d = sc->hash[3];
e = sc->hash[4];
W = buf;
#ifndef SHA1_UNROLL
#define SHA1_UNROLL 20
#endif /* !SHA1_UNROLL */
#if SHA1_UNROLL == 1
for (i = 19; i >= 0; i--)
DO_ROUND(F_0_19, K_0_19);
for (i = 19; i >= 0; i--)
DO_ROUND(F_20_39, K_20_39);
for (i = 19; i >= 0; i--)
DO_ROUND(F_40_59, K_40_59);
for (i = 19; i >= 0; i--)
DO_ROUND(F_60_79, K_60_79);
#elif SHA1_UNROLL == 2
for (i = 9; i >= 0; i--) {
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
}
for (i = 9; i >= 0; i--) {
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
}
for (i = 9; i >= 0; i--) {
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
}
for (i = 9; i >= 0; i--) {
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
}
#elif SHA1_UNROLL == 4
for (i = 4; i >= 0; i--) {
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
}
for (i = 4; i >= 0; i--) {
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
}
for (i = 4; i >= 0; i--) {
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);