aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-03-05 12:09:30 +0100
committerDenis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>2021-03-05 12:09:30 +0100
commit65eb92c9b6519c57546d93e0c83ccdbebafb632a (patch)
tree8f755d435e7f8859f5a0bdec74d02af41bb88ea0
downloadexternal_wipe-65eb92c9b6519c57546d93e0c83ccdbebafb632a.tar.gz
external_wipe-65eb92c9b6519c57546d93e0c83ccdbebafb632a.tar.bz2
external_wipe-65eb92c9b6519c57546d93e0c83ccdbebafb632a.zip
Import wipe from wipe-2.3.1.tar.bz2
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
-rw-r--r--CHANGES291
-rw-r--r--INSTALL73
-rw-r--r--LICENSE340
-rw-r--r--Makefile.in94
-rw-r--r--README78
-rw-r--r--TESTING22
-rw-r--r--TODO42
-rw-r--r--blkdev.c229
-rw-r--r--blkdev.h23
-rwxr-xr-xconfig.guess1321
-rw-r--r--config.h.in145
-rwxr-xr-xconfig.sub1443
-rwxr-xr-xconfigure2528
-rw-r--r--configure.in129
-rw-r--r--copyright19
-rw-r--r--debug.h5
-rw-r--r--dir.c336
-rw-r--r--dir.h24
-rw-r--r--file.c249
-rw-r--r--file.h94
-rw-r--r--header.h21
-rwxr-xr-xinstall-sh250
-rw-r--r--io.c294
-rw-r--r--io.h30
-rw-r--r--lock.c154
-rw-r--r--lock.h23
-rw-r--r--main.c496
-rw-r--r--main.h70
-rw-r--r--mt.c183
-rw-r--r--mt.h4
-rw-r--r--percent.c201
-rw-r--r--percent.h40
-rw-r--r--prompt.c279
-rw-r--r--prompt.h25
-rw-r--r--rand.c134
-rw-r--r--rand.h42
-rw-r--r--require.h58
-rw-r--r--std.h40
-rw-r--r--str.c93
-rw-r--r--str.h27
-rw-r--r--text.c159
-rw-r--r--text.h27
-rw-r--r--version.h30
-rw-r--r--wipe.1230
-rw-r--r--wipe.c595
-rw-r--r--wipe.h30
-rw-r--r--wipe.spec60
47 files changed, 11080 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
new file mode 100644
index 0000000..99bb15e
--- /dev/null
+++ b/CHANGES
@@ -0,0 +1,291 @@
+2.3.1:
+fixed Makefile bug! Running make uninstall removed target bin directory.
+
+2.3:
+
+DEFAULTS!
+the default is now one single random pass <-- MAJOR CHANGE
+special files are no longer deleted by default
+
+support for wiping char devices, such as tape drives
+
+percentage reporting improved (thanks to Jason Tackaberry for patch)
+
+cleanup and exit upon SIGINT
+
+each wiped file prints on a seperate line
+
+skip unnecessary fdatasync()s, unless you want the extra accuracy on the % shown (-e option)
+
+call fsync() on the file after name wipe, in addition to fsync on the directory
+
+if fdatasync() fails, try for O_SYNC and only complain once per file
+
+fixed some off-by-ones
+fixed percentages for non-static wipes
+
+2.2.1:
+added largefile support for linux and solaris (tested on linux)
+
+fixed drill_down(). it was using the wrong length to null term the string
+
+2.2.0:
+removed debian stuff (deprecated)
+stow, rpm, or rpm+alien is recommended.
+
+now builds on solaris 9
+
+cleaned up makefile
+
+fixed type mismatch in blkdev.c, broke on big endian archs
+
+directories are now renamed
+try to fsync() dirs
+
+you can now wipe to stdout
+
+write() wrapper is now more robust
+
+checks the termal's width, for proper line clear and truncation
+
+various minor bugs and typos fixed
+
+Suported:
+Linux, GNU, NetBSD, Solaris 9 (SunOS 5.9)
+
+Doesn't build:
+Mac OS 10.2
+
+2.1.1:
+typo in Makefile.in (Ricardo Branco)
+
+2.1:
+fixed percent reporting (James P. Rutledge)
+
+fixed block dev support (Matthew Kettler)
+
+typos (David M. DesRosiers)
+
+updated autoconf scripts
+wipe will now build on s/390 (Jochen Schmidt)
+
+2.0.1:
+don't rename over an existing file (Tomislav Greguric)
+
+fix debian changelog (pawan)
+
+2.0:
+dedicated to my dog, Cindy.
+
+split wipe.c into seperate modules
+
+removed raw /dev/urandom passes
+
+switched back to the Mersenne Twister - it's much faster and uses much
+less entropy from /dev/urandom
+
+changed a lot of cmd line options, so be sure to read the man page or
+wipe -h
+
+added proper syscall wrappers
+
+improved per-file fault tolerance - a failure during wiping of one
+file doesn't cause the rest to be aborted
+
+1.2.2:
+destroy_blkdev() was trying an ioctl before opening the fd
+block device wiping appears to work in linux; BSD (and other
+unixes) are still untested. let me know if you try it on
+something other than linux.
+
+silent mode is now silent
+
+fixed xor loop
+
+1.2.1:
+fixed missing '_H' in includes.h
+thanks to Peter Monta
+
+1.2.0:
+updated INSTALL
+
+fixed some bugs which would have effected block device
+support - block device support is still untested
+
+adopted new versioning scheme
+
+fixed PATH_MAX and NAME_MAX; should build on solaris now
+
+fixed verbose pathname + percent display
+
+documented secure levels in the man page (and changed them a
+little)
+
+fixed hash io code (hashin_update() and hashout_update())
+there were serious bugs in there, and it's likely that older
+versions were not outputting enough entropy.
+
+from the web site:
+Symptoms: seg faults or "cannot allocate" messages
+Cause: incorrect pointer math
+Result: truncated random hash passes, stack smashes
+
+there are debian scripts now; see INSTALL for more info
+
+Berke Durak beat me into debian, so everything'll come out
+saying 'ya-wipe' instead of 'wipe', just like on freshmeat.
+oh well, i still beat him to sunsite/metalab. ;P
+
+simplified makefile (see INSTALL for new targets)
+
+wipe with no arguments (other than options) prints version
+and copyright
+
+1.0.0:
+
+NOTE: this is an unstable prerelease
+
+files are now mmap()'ed instead of allocating a static buffer
+for the whole file
+
+block device support (untested). you should now be able to wipe
+entire devices. remember, i haven't even tried this yet, so i
+recommend backing up before trying to wipe any devices, just to
+be on the same side.
+
+wipe now prints the filename of the file it's wiping. i haven't
+refined it yet.
+
+added default options to man page
+
+0.58.6:
+fixed integer division bugs which prevented the main loop in
+hashout_update() from running
+
+0.58.5:
+fixed two heap smashing bugs
+removed unnecessary direntcheck(), which was broken anyway
+removed autoconf check for access()
+updated readme
+added PATH_MAX check to wipe.h for systems that don't define it
+
+0.58.4:
+fixed stupid bug that didn't check if the file size was zero
+
+added missing fflush, so now you'll see "100%"
+
+added missing closedir() call in direntcheck, probably never caused
+any problems
+
+added rpm spec file and removed chown stuff from the makefile
+
+0.58.3:
+fixed dirent scan algorithm bug which would make files beginning with
+'.' and '..' invisible
+
+0.58.2:
+ok, everything should really be fixed this time.
+
+added sym link check - sym links will now be seen by wipe, and removed
+also added sockets and fifo's; char and block dev's are skipped by default
+
+xor's are now done a (processor) word at a time, ie, each xor is done 32
+or 64-bits at a time or whatever you're arch is. this should increase
+performance some more.
+
+0.58.1:
+fixed strange malloc() related bug by switching to realloc() <-- not really fixed,
+fixed problem where directories weren't removed see 0.58.4
+
+0.58:
+added man page
+
+switched to tiger hash. big speed improvement.
+
+removed psuedo-random stuff, cuz my code sucked. if there's an easy
+way to get entropy on systems w/o /dev/*random it'll go back in.
+
+-t now sets the tiger hash input buffers size
+-T is no longer used
+
+0.57:
+lots of changes.
+
+added file renaming, cleaned up the code, some minor cosmetic changes,
+and other stuff i can't remember.
+
+0.56beta2:
+minor bug fixes
+
+0.56beta1:
+
+MAJOR: added autoconf, yeah! wipe should be MUCH more portable now.
+
+spelled checked 8)
+added mt19937 pseudo-random generator algorithm by Takuji Nishimura.
+
+added file locks.
+added -z option to only zero-out files. cleaned up the code a little.
+
+0.55beta3:
+
+got rid of all the unneeded struct passing. other minor things.
+
+0.55beta2:
+
+oops, forgot to update usage()
+
+0.55beta1:
+
+full recursion supported
+switched from switch to getopt()
+
+0.54alpha0:
+
+multiple pass support
+shows wipe completion percentage
+command line options using switch
+
+0.53beta0:
+
+added support for /dev/urandom.
+
+0.52beta1:
+
+minor bug fix.
+
+0.52beta0:
+
+i've rewritten the write_pass() and write3_pass() functions. now i just fill
+a buffer w/ the desired bit pattern, then write() it to the file descriptor.
+you'll need enough free contiguous memory to hold a buffer the size of file,
+or it'll fail w/ an out of memory error.
+
+0.45beta2:
+
+added better debugging support. use 'make debug' or add
+'-DPAUSE_AFTER_WIPE_PASS' to the gcc command to pause after each wipe pass.
+
+0.45beta1:
+
+first (semi) public release.
+
+added write3_pass(), pseudo-random number generation, and added all 35
+write passes.
+
+fixed some memory leaks in error checking if's, that would result if
+it aborted a file wipe due to lack of memory or read errors. probably
+won't have been noticeable unless you where wiping thousands of files,
+though.
+
+0.41alpha1:
+
+added better error handling and exit code status.
+
+0.41alpha0:
+
+basic functionality. performs a single wipe pass of 0x55.
+
+0.40alpha0:
+
+initial code for unbuffered I/O and inode data gathering.
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..7950b76
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,73 @@
+The preferred way to install wipe is to use something like stow, and put
+it in /usr/local/.
+
+Debian (dpkg):
+
+Build an rpm, then use alien to make a deb. I have removed the Debian
+directory, since (my version of) wipe is not part of Debian.
+
+Redhat (rpm):
+
+1. tar jxvf wipe*.tar.bz2 || (bunzip2 -c wipe*.tar.bz2 | tar xv)
+ cd wipe*/; cp wipe.spec /usr/src/rpm/SPECS/
+ cp wipe*.tar.bz2 /usr/src/rpm/SOURCES/
+
+2. cd /usr/src/rpm/; rpm -ba SPECS/wipe.spec
+
+3. rpm -ivh RPMS/`find . | grep -v noarch`/*wipe*.rpm
+ ls SRPMS/
+
+ to build a source rpm:
+
+ rpm --rebuild *wipe*.src.rpm
+
+Tarball:
+
+to install as root:
+
+ ./configure; make install
+
+or to install on a per user basis:
+
+ ./configure; make install_home
+
+to uninstall:
+
+ make uninstall
+or
+ make -f Makefile.in remove
+
+from ./configure --help:
+
+--enable and --with options recognized:
+ --enable-wall compile with -ansi -pedantic -Wall -Werror
+ --enable-debug compile with -g
+ --enable-efence same as debug, but link the binary with the
+ electric fence
+
+make targets:
+
+make:
+ compile standard wipe binary w/ -O3
+
+make debug:
+ same as ./configure --enable-debug
+
+make efence:
+ same as ./configure --enable-efence
+
+make install:
+ you must be root to run this. this will install all man pages
+ and put the compiled and stripped wipe binary in /usr/local/bin
+
+make install_home:
+ install wipe for personal use in ~/bin/. does not install man
+ pages.
+
+make info:
+ display file info and link data for wipe binary.
+
+make clean:
+ clean binaries from source tree.
+
+see README and LICENSE for more information.
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..5dbdc88
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,340 @@
+
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C) 19yy
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ , 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..ea9fe4e
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,94 @@
+# Makefile for wipe
+
+VERSION='2.3.1'
+DOCS='LICENSE copyright CHANGES README TODO INSTALL TESTING'
+
+CC=@CC@
+CFLAGS=@CFLAGS@ -I@srcdir@ -D@OSTYPE@ $(DEFINES)
+DEBUG=@DEBUG@ -I@srcdir@ -D@OSTYPE@ $(DEFINES)
+
+LIBS=@LIBS@
+
+srcdir=@srcdir@
+
+BIN=@bin@
+SRC=@src@
+REQ=@req@
+
+bindir=@bindir@
+sbindir=@sbindir@
+datadir=@datadir@
+mandir=@mandir@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+
+BIN_OUT=$(srcdir)/$(BIN)
+
+INSTALL=@INSTALL@
+INSTALL_BIN=@INSTALL@ -m 0755
+INSTALL_HOME=mv -f
+
+all: $(REQ) $(BIN)
+
+$(BIN): main.o wipe.o rand.o dir.o file.o blkdev.o lock.o text.o str.o percent.o prompt.o io.o mt.o
+ $(CC) $(LIBS) *.o -o $@
+
+
+# restores everything to a pre-configured state
+cleanconf:
+ # remove generated files
+ rm -f config.h
+ # remove cache, etc.
+ rm -f config.log config.cache config.status config.h.in
+
+# run this before compiling or packaging for distribution
+dist: cvsclean
+ # build autoconf files
+ autoheader
+ autoconf
+
+map: $(BIN_OUT)
+ nm $(BIN_OUT) | sort > $(BIN_OUT).map
+
+info: $(BIN_OUT)
+ @file $(BIN_OUT)
+ @echo
+ @echo "Linked:"
+ @ldd $(BIN_OUT)
+
+install: $(BIN_OUT)
+ $(INSTALL_BIN) -d $(bindir)
+ $(INSTALL_BIN) -s $(BIN_OUT) $(bindir)
+ $(INSTALL) -d $(mandir)/man1
+ $(INSTALL) -o root -m 0644 wipe.1 $(mandir)/man1/
+ rm -rf $(datadir)/doc/wipe*
+ $(INSTALL) -d $(datadir)/doc/wipe
+
+ for file in $(DOCS); do \
+ $(INSTALL) -o root -m 0644 $$file $(datadir)/doc/wipe/; \
+ done
+
+install_home: $(BIN_OUT)
+ strip $(BIN_OUT)
+ $(INSTALL_HOME) $(BIN_OUT) ~/bin/wipe
+ chmod 0755 ~/bin/wipe
+
+uninstall:
+ rm -f $(bindir)/$(BIN) $(mandir)/man1/wipe.1 $(datadir)/doc/wipe/
+
+remove:
+ rm -f /usr/local/bin/wipe /usr/local/man/man1/wipe.1 /usr/local/share/man/man1/wipe.1
+ rm -rf /usr/local/doc/wipe* /usr/local/share/doc/wipe*
+ rm -f /usr/bin/wipe /usr/man/man1/wipe.1 /usr/share/man/man1/wipe.1
+ rm -rf /usr/doc/wipe* /usr/share/doc/wipe*
+ rm -f ~/bin/wipe ~/man/man1/wipe.1 ~/share/man/man1/wipe.1
+ rm -rf ~/doc/wipe* ~/share/doc/wipe*
+
+clean:
+ rm -f *core* $(BIN_OUT) $(srcdir)/*.o *~
+
+cvsciclean: clean cleanconf
+ rm -f configure Makefile
+
+cvsclean: cvsciclean
+ rm -rf .cvsignore CVS
diff --git a/README b/README
new file mode 100644
index 0000000..65183e0
--- /dev/null
+++ b/README
@@ -0,0 +1,78 @@
+wipe (aka ya-wipe) by Tom Vier <nester@users.sf.net>
+
+See INSTALL for installation instructions and LICENSE for license
+and warranty.
+
+Wipe is a secure file wiping utility. There are some low level issues
+that must be taken into consideration. One of these is that there must
+be some sort of write barrier between passes. Wipe uses fdatasync(2)
+(or fsync(2)) as a write barrier, or if fsync(2) isn't available, the
+file is opened with the O_DSYNC or O_SYNC flag. For wipe to be
+effective, each pass must be completely written. To ensure this, the
+drive must support some form of a write barrier, write cache flush, or
+write cache disabling. SCSI supports ordered command tags, has a force
+media access bit for commands, and write cache can be disable on mode
+page 8. IDE/ATA drives support write cache flushes and write cache
+disabling. Unfortunetly, not all drives actually disable write cache
+when asked to. Those drives are broken. Write caching should always be
+disabled, unless your system is battery backed and always powers down
+cleanly. See this thread from the linux kernel list:
+
+http://www.uwsg.iu.edu/hypermail/linux/kernel/0103.0/0331.html
+
+Under linux, the mount option "mand" must be used (see
+linux/Documentation/mandatory.txt) for mandatory file locks to be
+enabled. Wipe should make it extremely difficult for all but the most
+determined person(s) to recover the original plaintext data. Utilities
+such as PGP and the GNU Privacy Guard provide strong encryption, but
+encryption is useless if the original plaintext can be recovered. When
+using PGP and GPG, temporary files that are disk-backed should be
+stored on an encrypted file system. That way, the plaintext never hits
+the platters. Wipe is designed for situations where an encrypted file
+system isn't practical.
+
+Making the following assumptions:
+
+1. at least one of Peter Guttman's patterns is correct for the device
+ you're wiping
+
+2. the patterns are actually being written to the media
+
+3. the correct sectors are being written to
+
+it's likely that wipe will make it more difficult to recover the
+original data.
+
+Those assumptions are respectively incorrect if:
+
+1. writing to a drive that uses a newer encoding scheme
+
+2. the passes are being buffered and merged by the drive electronics,
+ controller or the OS
+
+3. you're wiping a file in a log structured file system or any FS that
+ doesn't overwrite the file's previously allocated sectors
+
+ or the drive has reassigned one or more sectors due to errors
+
+If you're using LFS or something like it, the only way to wipe the
+file's previous contents (from userspace) is to wipe the whole
+partition. The more practical solution is for wiping to be done by the
+FS. Unfortunely, this has it's own problem; wiping is IO intense and
+synchronis.
+
+Some programs are vulnerable to symlink races. To avoid this problem
+with wipe, only wipe files in directories that are not writable by
+untrusted users.
+
+Wipe uses /dev/urandom, or if unavailable, /dev/random, as a source
+for entropy. The Mersenne Twister PRNG is used for speed. The MT site
+is at:
+
+http://www.math.keio.ac.jp/~matumoto/emt.html
+
+For more information on the secure deletion of magnetic media and
+solid state storage devices (such as DRAM) see the USENIX article by
+Peter Gutmann at:
+
+http://www.cs.auckland.ac.nz/~pgut001/secure_del.html
diff --git a/TESTING b/TESTING
new file mode 100644
index 0000000..b903982
--- /dev/null
+++ b/TESTING
@@ -0,0 +1,22 @@
+Testing of wipe involves examining each pass, to ensure completeness
+and correctness. First add '#define PAUSE' to debug.h and
+compile. Next, run wipe -vKD -x1 <file>. After each pass, use hexdump,
+ghex, or khexdit to view the pattern. Look for breaks in the sequence,
+for multi-byte passes. For single byte passes, just run hexdump; it'll
+make it obvious if the whole file isn't filled with the same byte. The
+most difficult to verify is the random pass. There are basically three
+ways to check entropy. The first way is to run hexdump, pick some
+sequences two to four bytes long, and hexdump | grep them, to see how
+many times they appear. The longer the sequence, the less likely it is
+to appear more than once. This is obviously not the best method. The
+second method is to run a compression algorithm on the data. The
+greater the entropy, the less effective the compression (in fact,
+compression is often used to increase hash input randomness). I tested
+both gzip and bzip2, using -9, and the output of both was larger than
+the original file.
+
+The third method, which I have not done, is to make a histogram of
+PRNG output, and make sure it has decent distribution. Distribution
+isn't too much of an issue, since this isn't a monte carlo application
+and it doesn't require cryptographically strong entropy. However,
+there shouldn't be any big spikes.
diff --git a/TODO b/TODO
new file mode 100644
index 0000000..8fedfd7
--- /dev/null
+++ b/TODO
@@ -0,0 +1,42 @@
+Things to do:
+
+ -- freebsd: fix block devs and file types
+
+ -- fix single quote in man page
+
+ -- follow symlinks when they point to a device
+
+ -- handle changes in window width (need sighandler for that)
+
+ -- show the path instead of just the filename & truncate beginning if too long
+
+ -- display throughput
+
+ -- realpath() might be useful
+
+ -- add more support for systems w/o a random dev
+ use stdin as an alternate entropy source
+
+ -- random length truncations
+ to try and screw with indirect block pointersn and extents
+
+ -- inode/directory scrambling
+ randomly create new files in directory containing target(s)
+ create random (dir local) hard links.
+
+ basically, try to wipe everything in struct stat
+
+ -- switch to a total percentage for all the files selected,
+ kind of like how apt-get does it.
+
+ something like these:
+
+ [blah.txt: 60%] 24%
+
+ blah.txt: 60% [24%]
+
+ [24%] blah.txt: 60%
+
+ probably go with the last example (or maybe the first, or
+ maybe even make it optional).
+
diff --git a/blkdev.c b/blkdev.c
new file mode 100644
index 0000000..680392e
--- /dev/null
+++ b/blkdev.c
@@ -0,0 +1,229 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+
+#include "config.h"
+
+#ifdef HAVE_LINUX_FS_H
+# include <linux/fs.h>
+# define LINUX_BLKDEV
+#else
+# ifdef LINUX
+# ifdef HAVE_SYS_MOUNT_H
+# include <sys/mount.h>
+# define LINUX_BLKDEV
+# endif
+# endif
+#endif
+
+#ifdef HAVE_SYS_DISKLABEL_H
+# include <sys/disklabel.h>
+# define BSD_BLKDEV
+#endif
+
+#ifndef LINUX_BLKDEV
+# ifndef BSD_BLKDEV
+# define NO_BLKDEV
+# endif
+#endif
+
+#include "std.h"
+#include "io.h"
+#include "main.h"
+#include "percent.h"
+#include "file.h"
+#include "wipe.h"
+#include "blkdev.h"
+
+extern int errno;
+extern int exit_code;
+extern char *argvzero;
+extern struct opt_s options;
+
+private int wipe_blkdev(struct file_s *f);
+private int zero_blkdev(struct file_s *f);
+
+/*
+ wipe_blkdev -- runs the wipe passes on a block device
+*/
+
+private int wipe_blkdev(struct file_s *f)
+{
+ if (options.zero || options.custom) return zero_blkdev(f);
+
+ fsetbuf(f);
+
+ if (fgetbuf(f) == FAILED)
+ return FAILED;
+
+ percent_init(&f->percent, f->name, f->bufsize, f->loop);
+
+ /**** run the passes ****/
+ if (wipe_passes(f))
+ {
+ fprintf(stderr, "\r%s: failed to wipe `%s'\n", argvzero, f->name);
+ ffreebuf(f);
+ return FAILED;
+ }
+
+ percent_done(&f->percent);
+
+ ffreebuf(f);
+
+ return 0;
+}
+
+/*
+ zero_blkdev -- zeroes out a block device
+*/
+
+private int zero_blkdev(struct file_s *f)
+{
+ fsetbuf(f);
+
+ if (fgetbuf(f) == FAILED)
+ {
+ fprintf(stderr, "\r%s: failed to wipe `%s'\n", argvzero, f->name);
+ return FAILED;
+ }
+
+ percent_init(&f->percent, f->name, f->bufsize, f->loop);
+
+ if (write_pass(f, options.custom_byte))
+ {
+ fprintf(stderr, "\r%s: failed to wipe `%s'\n", argvzero, f->name);
+ ffreebuf(f);
+ return FAILED;
+ }
+
+ percent_done(&f->percent);
+
+ ffreebuf(f);
+
+ return 0;
+}
+
+/*
+ destroy_blkdev -- destroy the device's data
+ calls subroutines wipeblkdev() and zero()
+*/
+
+public int destroy_blkdev(struct file_s *f)
+{
+ int code;
+
+#ifdef BSD_BLKDEV
+ struct partinfo pinfo;
+#endif
+
+#ifdef NO_BLKDEV
+ fprintf(stderr, "\r%s: block device support not available\n", argvzero);
+ return FAILED;
+#endif
+
+#ifdef SANITY
+ if (!S_ISBLK(f->st.st_mode))
+ {
+ fprintf(stderr, "\r%s: destroy_blkdev(): not a block dev: %s\n",
+ argvzero, f->name);
+ abort();
+ }
+
+ if (strncmp(f->name, f->real_name, PATH_MAX) != 0)
+ {
+ fprintf(stderr, "\r%s: destroyblkdev(): f->name != f->real_name\n",
+ argvzero);
+ abort();
+ }
+#endif
+
+ if ((f->fd = open(f->real_name, O_WRONLY | O_NOFOLLOW | SYNC)) < 0)
+ {
+ fprintf(stderr, "\r%s: cannot open `%s':%s\n",
+ argvzero, f->name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+
+#ifdef BSD_BLKDEV
+ if (ioctl(f->fd, DIOCGPART, &pinfo))
+ {
+ fprintf(stderr, "\r%s: ioctl failed, can't get disklabel for `%s': %s\n",
+ argvzero, f->name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+#endif
+
+ if (options.sectors == 0)
+ {
+#ifdef LINUX_BLKDEV
+ int tmp;
+
+ if (ioctl(f->fd, BLKGETSIZE, &tmp))
+ {
+ fprintf(stderr, "\r%s: ioctl failed, can't get sector count for `%s': %s\n",
+ argvzero, f->name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+ options.sectors = tmp;
+#endif
+
+#ifdef BSD_BLKDEV
+ options.sectors = pinfo.part->p_size;
+#endif
+ }
+
+ if (options.sector_size == 0)
+ {
+#ifdef BSD_BLKDEV
+ options.sector_size = pinfo.disklab->d_secsize;
+#else
+ options.sector_size = SECTOR_SIZE;
+#endif
+ }
+
+ f->fsize = (options.sectors) * options.sector_size;
+
+ if (f->fsize == 0)
+ {
+ fprintf(stderr, "\r%s: `%s' is zero length\n",
+ argvzero, f->name);
+ return FAILED;
+ }
+
+#ifdef DEBUG
+ fprintf(stderr, "\rzeroblkdev: f->fsize == %ld\n", f->fsize);
+#endif
+
+ code = wipe_blkdev(f); /**** wipe block device ****/
+
+ close(f->fd);
+ return code;
+}
diff --git a/blkdev.h b/blkdev.h
new file mode 100644
index 0000000..d100ad7
--- /dev/null
+++ b/blkdev.h
@@ -0,0 +1,23 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2001 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+public int destroy_blkdev(struct file_s *f);
diff --git a/config.guess b/config.guess
new file mode 100755
index 0000000..ed2e03b
--- /dev/null
+++ b/config.guess
@@ -0,0 +1,1321 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002 Free Software Foundation, Inc.
+
+timestamp='2002-03-20'
+
+# This file 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.
+#
+# 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 Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+
+dummy=dummy-$$
+trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script.
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int dummy(){}" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;
+ if test $? = 0 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ rm -f $dummy.c $dummy.o $dummy.rel ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit 0 ;;
+ amiga:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ arc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ hp300:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mac68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ macppc:OpenBSD:*:*)
+ echo powerpc-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme68k:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvme88k:OpenBSD:*:*)
+ echo m88k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ mvmeppc:OpenBSD:*:*)
+ echo powerpc-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ pmax:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sgi:OpenBSD:*:*)
+ echo mipseb-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ sun3:OpenBSD:*:*)
+ echo m68k-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ wgrisc:OpenBSD:*:*)
+ echo mipsel-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ *:OpenBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
+ exit 0 ;;
+ alpha:OSF1:*:*)
+ if test $UNAME_RELEASE = "V4.0"; then
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ fi
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ cat <<EOF >$dummy.s
+ .data
+\$Lformat:
+ .byte 37,100,45,37,120,10,0 # "%d-%x\n"
+
+ .text
+ .globl main
+ .align 4
+ .ent main
+main:
+ .frame \$30,16,\$26,0
+ ldgp \$29,0(\$27)
+ .prologue 1
+ .long 0x47e03d80 # implver \$0
+ lda \$2,-1
+ .long 0x47e20c21 # amask \$2,\$1
+ lda \$16,\$Lformat
+ mov \$0,\$17
+ not \$1,\$18
+ jsr \$26,printf
+ ldgp \$29,0(\$26)
+ mov 0,\$16
+ jsr \$26,exit
+ .end main
+EOF
+ eval $set_cc_for_build
+ $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+ if test "$?" = 0 ; then
+ case `./$dummy` in
+ 0-0)
+ UNAME_MACHINE="alpha"
+ ;;
+ 1-0)
+ UNAME_MACHINE="alphaev5"
+ ;;
+ 1-1)
+ UNAME_MACHINE="alphaev56"
+ ;;
+ 1-101)
+ UNAME_MACHINE="alphapca56"
+ ;;
+ 2-303)
+ UNAME_MACHINE="alphaev6"
+ ;;
+ 2-307)
+ UNAME_MACHINE="alphaev67"
+ ;;
+ 2-1307)
+ UNAME_MACHINE="alphaev68"
+ ;;
+ esac
+ fi
+ rm -f $dummy.s $dummy
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit 0 ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit 0 ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit 0 ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit 0;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit 0 ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit 0 ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit 0 ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit 0;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit 0;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit 0 ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit 0 ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ i86pc:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit 0 ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit 0 ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit 0 ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit 0 ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit 0 ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit 0 ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit 0 ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit 0 ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit 0 ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit 0 ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit 0 ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy \
+ && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+ && rm -f $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit 0 ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit 0 ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit 0 ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit 0 ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit 0 ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit 0 ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit 0 ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit 0 ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit 0 ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit 0 ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit 0 ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit 0 ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ echo rs6000-ibm-aix3.2.5
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit 0 ;;
+ *:AIX:*:[45])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit 0 ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit 0 ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit 0 ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit 0 ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit 0 ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit 0 ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit 0 ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit 0 ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null) && HP_ARCH=`./$dummy`
+ if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
+ rm -f $dummy.c $dummy
+ fi ;;
+ esac
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit 0 ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit 0 ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
+ rm -f $dummy.c $dummy
+ echo unknown-hitachi-hiuxwe2
+ exit 0 ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit 0 ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit 0 ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit 0 ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit 0 ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit 0 ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit 0 ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit 0 ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*T3D:*:*:*)
+ echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit 0 ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit 0 ;;
+ *:FreeBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit 0 ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit 0 ;;
+ i*:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit 0 ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit 0 ;;
+ x86:Interix*:3*)
+ echo i386-pc-interix3
+ exit 0 ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i386-pc-interix
+ exit 0 ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit 0 ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit 0 ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit 0 ;;
+ *:GNU:*:*)
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit 0 ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit 0 ;;
+ arm*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ mips:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mipsel
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+ rm -f $dummy.c
+ test x"${CPU}" != x && echo "${CPU}-pc-linux-gnu" && exit 0
+ ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit 0 ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit 0 ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit 0 ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+ exit 0 ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit 0 ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit 0 ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit 0 ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit 0 ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ # Set LC_ALL=C to ensure ld outputs messages in English.
+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+ | sed -ne '/supported targets:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported targets: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_targets" in
+ elf32-i386)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ a.out-i386-linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit 0 ;;
+ coff-i386)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit 0 ;;
+ "")
+ # Either a pre-BFD a.out linker (linux-gnuoldld) or
+ # one that does not give us useful --help.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+ exit 0 ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #ifdef __ELF__
+ # ifdef __GLIBC__
+ # if __GLIBC__ >= 2
+ LIBC=gnu
+ # else
+ LIBC=gnulibc1
+ # endif
+ # else
+ LIBC=gnulibc1
+ # endif
+ #else
+ #ifdef __INTEL_COMPILER
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+ #endif
+ #endif
+EOF
+ eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+ rm -f $dummy.c
+ test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
+ test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit 0 ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit 0 ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit 0 ;;
+ i*86:*:5:[78]*)
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit 0 ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit 0 ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit 0 ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit 0 ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit 0 ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit 0 ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit 0 ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit 0 ;;
+ M68*:*:R3V[567]*:*)
+ test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+ 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && echo i486-ncr-sysv4 && exit 0 ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit 0 ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit 0 ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit 0 ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit 0 ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit 0 ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit 0 ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit 0 ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit 0 ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit 0 ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit 0 ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit 0 ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit 0 ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit 0 ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit 0 ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit 0 ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit 0 ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit 0 ;;
+ *:Darwin:*:*)
+ echo `uname -p`-apple-darwin${UNAME_RELEASE}
+ exit 0 ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit 0 ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit 0 ;;
+ NSR-[GKLNPTVW]:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit 0 ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit 0 ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit 0 ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit 0 ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit 0 ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit 0 ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit 0 ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit 0 ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit 0 ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit 0 ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit 0 ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit 0 ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit 0 ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
+rm -f $dummy.c $dummy
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit 0 ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit 0 ;;
+ c34*)
+ echo c34-convex-bsd
+ exit 0 ;;
+ c38*)
+ echo c38-convex-bsd
+ exit 0 ;;
+ c4*)
+ echo c4-convex-bsd
+ exit 0 ;;
+ esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000..7e27e3c
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,145 @@
+/* config.h.in. Generated automatically from configure.in by autoheader 2.13. */
+
+/* Define to empty if the keyword does not work. */
+#undef const
+
+/* Define if you have a working `mmap' system call. */
+#undef HAVE_MMAP
+
+/* Define as __inline if that's what the C compiler calls it. */
+#undef inline
+
+/* Define to `long' if <sys/types.h> doesn't define. */
+#undef off_t
+
+/* Define if you need to in order for stat and other things to work. */
+#undef _POSIX_SOURCE
+
+/* Define to `unsigned' if <sys/types.h> doesn't define. */
+#undef size_t
+
+/* Define if the `S_IS*' macros in <sys/stat.h> do not work properly. */
+#undef STAT_MACROS_BROKEN
+
+/* Define if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define if you have the bzero function. */
+#undef HAVE_BZERO
+
+/* Define if you have the dirfd function. */
+#undef HAVE_DIRFD
+
+/* Define if you have the fchmod function. */
+#undef HAVE_FCHMOD
+
+/* Define if you have the fcntl function. */
+#undef HAVE_FCNTL
+
+/* Define if you have the fdatasync function. */
+#undef HAVE_FDATASYNC
+
+/* Define if you have the flock function. */
+#undef HAVE_FLOCK
+
+/* Define if you have the fsync function. */
+#undef HAVE_FSYNC
+
+/* Define if you have the getopt function. */
+#undef HAVE_GETOPT
+
+/* Define if you have the getpagesize function. */
+#undef HAVE_GETPAGESIZE
+
+/* Define if you have the ioctl function. */
+#undef HAVE_IOCTL
+
+/* Define if you have the lockf function. */
+#undef HAVE_LOCKF
+
+/* Define if you have the memcpy function. */
+#undef HAVE_MEMCPY
+
+/* Define if you have the memset function. */
+#undef HAVE_MEMSET
+
+/* Define if you have the realloc function. */
+#undef HAVE_REALLOC
+
+/* Define if you have the remove function. */
+#undef HAVE_REMOVE
+
+/* Define if you have the rename function. */
+#undef HAVE_RENAME
+
+/* Define if you have the rmdir function. */
+#undef HAVE_RMDIR
+
+/* Define if you have the strnlen function. */
+#undef HAVE_STRNLEN
+
+/* Define if you have the unlink function. */
+#undef HAVE_UNLINK
+
+/* Define if you have the <dirent.h> header file. */
+#undef HAVE_DIRENT_H
+
+/* Define if you have the <errno.h> header file. */
+#undef HAVE_ERRNO_H
+
+/* Define if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define if you have the <getopt.h> header file. */
+#undef HAVE_GETOPT_H
+
+/* Define if you have the <linux/fs.h> header file. */
+#undef HAVE_LINUX_FS_H
+
+/* Define if you have the <linux/mtio.h> header file. */
+#undef HAVE_LINUX_MTIO_H
+
+/* Define if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define if you have the <ndir.h> header file. */
+#undef HAVE_NDIR_H
+
+/* Define if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define if you have the <sys/dir.h> header file. */
+#undef HAVE_SYS_DIR_H
+
+/* Define if you have the <sys/disklabel.h> header file. */
+#undef HAVE_SYS_DISKLABEL_H
+
+/* Define if you have the <sys/file.h> header file. */
+#undef HAVE_SYS_FILE_H
+
+/* Define if you have the <sys/ioctl.h> header file. */
+#undef HAVE_SYS_IOCTL_H
+
+/* Define if you have the <sys/mount.h> header file. */
+#undef HAVE_SYS_MOUNT_H
+
+/* Define if you have the <sys/ndir.h> header file. */
+#undef HAVE_SYS_NDIR_H
+
+/* Define if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define if you have the <termio.h> header file. */
+#undef HAVE_TERMIO_H
+
+/* Define if you have the <termios.h> header file. */
+#undef HAVE_TERMIOS_H
+
+/* Define if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
diff --git a/config.sub b/config.sub
new file mode 100755
index 0000000..f365797
--- /dev/null
+++ b/config.sub
@@ -0,0 +1,1443 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002 Free Software Foundation, Inc.
+
+timestamp='2002-03-07'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file 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.
+
+# 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.
+
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit 0 ;;
+ --version | -v )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit 0;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | storm-chaos* | os2-emx* | windows32-* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+ | c4x | clipper \
+ | d10v | d30v | dsp16xx \
+ | fr30 \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | m32r | m68000 | m68k | m88k | mcore \
+ | mips | mips16 | mips64 | mips64el | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el | mips64vr4300 \
+ | mips64vr4300el | mips64vr5000 | mips64vr5000el \
+ | mipsbe | mipseb | mipsel | mipsle | mipstx39 | mipstx39el \
+ | mipsisa32 | mipsisa64 \
+ | mn10200 | mn10300 \
+ | ns16k | ns32k \
+ | openrisc | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | sh | sh[34] | sh[34]eb | shbe | shle | sh64 \
+ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \
+ | strongarm \
+ | tahoe | thumb | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xscale | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armv*-* \
+ | avr-* \
+ | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c54x-* \
+ | clipper-* | cydra-* \
+ | d10v-* | d30v-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fr30-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | m32r-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | mcore-* \
+ | mips-* | mips16-* | mips64-* | mips64el-* | mips64orion-* \
+ | mips64orionel-* | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* | mipsbe-* | mipseb-* \
+ | mipsle-* | mipsel-* | mipstx39-* | mipstx39el-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[34]-* | sh[34]eb-* | shbe-* | shle-* | sh64-* \
+ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
+ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* | tic30-* | tic54x-* | tic80-* | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
+ | xtensa-* \
+ | ymp-* \
+ | z8k-*)
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ mmix*)
+ basic_machine=mmix-knuth
+ os=-mmixware
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ or32 | or32-*)
+ basic_machine=or32-unknown
+ os=-coff
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2)
+ basic_machine=i686-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3d)
+ basic_machine=alpha-cray
+ os=-unicos
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ windows32)
+ basic_machine=i386-pc
+ os=-windows32-msvcrt
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh3 | sh4 | sh3eb | sh4eb)
+ basic_machine=sh-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparc | sparcv9 | sparcv9b)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ c4x*)
+ basic_machine=c4x-none
+ os=-coff
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
+ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto*)
+ os=-nto-qnx
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -vxsim* | -vxworks*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/configure b/configure
new file mode 100755
index 0000000..48c355e
--- /dev/null
+++ b/configure
@@ -0,0 +1,2528 @@
+#! /bin/sh
+
+# Guess values for system-dependent variables and create Makefiles.
+# Generated automatically using autoconf version 2.13
+# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc.
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+
+# Defaults:
+ac_help=
+ac_default_prefix=/usr/local
+# Any additions from configure.in:
+ac_help="$ac_help
+ --enable-wall compile with -ansi -pedantic -Wall -Werror"
+ac_help="$ac_help
+ --enable-debug compile for debugger compatibility"
+ac_help="$ac_help
+ --enable-efence debug build + link with electric fence"
+
+# Initialize some variables set by options.
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+build=NONE
+cache_file=./config.cache
+exec_prefix=NONE
+host=NONE
+no_create=
+nonopt=NONE
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+target=NONE
+verbose=
+x_includes=NONE
+x_libraries=NONE
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datadir='${prefix}/share'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+libdir='${exec_prefix}/lib'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+infodir='${prefix}/info'
+mandir='${prefix}/man'
+
+# Initialize some other variables.
+subdirs=
+MFLAGS= MAKEFLAGS=
+SHELL=${CONFIG_SHELL-/bin/sh}
+# Maximum number of lines to put in a shell here document.
+ac_max_here_lines=12
+
+ac_prev=
+for ac_option
+do
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval "$ac_prev=\$ac_option"
+ ac_prev=
+ continue
+ fi
+
+ case "$ac_option" in
+ -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+ *) ac_optarg= ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case "$ac_option" in
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir="$ac_optarg" ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build="$ac_optarg" ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file="$ac_optarg" ;;
+
+ -datadir | --datadir | --datadi | --datad | --data | --dat | --da)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \
+ | --da=*)
+ datadir="$ac_optarg" ;;
+
+ -disable-* | --disable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ eval "enable_${ac_feature}=no" ;;
+
+ -enable-* | --enable-*)
+ ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
+ fi
+ ac_feature=`echo $ac_feature| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "enable_${ac_feature}='$ac_optarg'" ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix="$ac_optarg" ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he)
+ # Omit some internal or obsolete options to make the list less imposing.
+ # This message is too long to be a string in the A/UX 3.1 sh.
+ cat << EOF
+Usage: configure [options] [host]
+Options: [defaults in brackets after descriptions]
+Configuration:
+ --cache-file=FILE cache test results in FILE
+ --help print this message
+ --no-create do not create output files
+ --quiet, --silent do not print \`checking...' messages
+ --version print the version of autoconf that created configure
+Directory and file names:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [same as prefix]
+ --bindir=DIR user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR read-only architecture-independent data in DIR
+ [PREFIX/share]
+ --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data in DIR
+ [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR info documentation in DIR [PREFIX/info]
+ --mandir=DIR man documentation in DIR [PREFIX/man]
+ --srcdir=DIR find the sources in DIR [configure dir or ..]
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM
+ run sed PROGRAM on installed program names
+EOF
+ cat << EOF
+Host type:
+ --build=BUILD configure for building on BUILD [BUILD=HOST]
+ --host=HOST configure for HOST [guessed]
+ --target=TARGET configure for TARGET [TARGET=HOST]
+Features and packages:
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --x-includes=DIR X include files are in DIR
+ --x-libraries=DIR X library files are in DIR
+EOF
+ if test -n "$ac_help"; then
+ echo "--enable and --with options recognized:$ac_help"
+ fi
+ exit 0 ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host="$ac_optarg" ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir="$ac_optarg" ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir="$ac_optarg" ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir="$ac_optarg" ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir="$ac_optarg" ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst \
+ | --locals | --local | --loca | --loc | --lo)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* \
+ | --locals=* | --local=* | --loca=* | --loc=* | --lo=*)
+ localstatedir="$ac_optarg" ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir="$ac_optarg" ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir="$ac_optarg" ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix="$ac_optarg" ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix="$ac_optarg" ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix="$ac_optarg" ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name="$ac_optarg" ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir="$ac_optarg" ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir="$ac_optarg" ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site="$ac_optarg" ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir="$ac_optarg" ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir="$ac_optarg" ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target="$ac_optarg" ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers)
+ echo "configure generated by autoconf version 2.13"
+ exit 0 ;;
+
+ -with-* | --with-*)
+ ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ case "$ac_option" in
+ *=*) ;;
+ *) ac_optarg=yes ;;
+ esac
+ eval "with_${ac_package}='$ac_optarg'" ;;
+
+ -without-* | --without-*)
+ ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+ # Reject names that are not valid shell variable names.
+ if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+ { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
+ fi
+ ac_package=`echo $ac_package| sed 's/-/_/g'`
+ eval "with_${ac_package}=no" ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes="$ac_optarg" ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries="$ac_optarg" ;;
+
+ -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; }
+ ;;
+
+ *)
+ if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+ echo "configure: warning: $ac_option: invalid host type" 1>&2
+ fi
+ if test "x$nonopt" != xNONE; then
+ { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; }
+ fi
+ nonopt="$ac_option"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; }
+fi
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 6 checking for... messages and results
+# 5 compiler messages saved in config.log
+if test "$silent" = yes; then
+ exec 6>/dev/null
+else
+ exec 6>&1
+fi
+exec 5>./config.log
+
+echo "\
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+" 1>&5
+
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Also quote any args containing shell metacharacters.
+ac_configure_args=
+for ac_arg
+do
+ case "$ac_arg" in
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c) ;;
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
+ *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+ ac_configure_args="$ac_configure_args '$ac_arg'" ;;
+ *) ac_configure_args="$ac_configure_args $ac_arg" ;;
+ esac
+done
+
+# NLS nuisances.
+# Only set these to C if already set. These must not be set unconditionally
+# because not all systems understand e.g. LANG=C (notably SCO).
+# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
+# Non-C LC_CTYPE values break the ctype check.
+if test "${LANG+set}" = set; then LANG=C; export LANG; fi
+if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
+if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
+if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -rf conftest* confdefs.h
+# AIX cpp loses on an empty file, so make sure it contains at least a newline.
+echo > confdefs.h
+
+# A filename unique to this package, relative to the directory that
+# configure is in, which we can look for to find out if srcdir is correct.
+ac_unique_file=wipe.c
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then its parent.
+ ac_prog=$0
+ ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+ test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
+ srcdir=$ac_confdir
+ if test ! -r $srcdir/$ac_unique_file; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r $srcdir/$ac_unique_file; then
+ if test "$ac_srcdir_defaulted" = yes; then
+ { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; }
+ else
+ { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; }
+ fi
+fi
+srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
+
+# Prefer explicitly selected file to automatically selected ones.
+if test -z "$CONFIG_SITE"; then
+ if test "x$prefix" != xNONE; then
+ CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site"
+ else
+ CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"
+ fi
+fi
+for ac_site_file in $CONFIG_SITE; do
+ if test -r "$ac_site_file"; then
+ echo "loading site script $ac_site_file"
+ . "$ac_site_file"
+ fi
+done
+
+if test -r "$cache_file"; then
+ echo "loading cache $cache_file"
+ . $cache_file
+else
+ echo "creating cache $cache_file"
+ > $cache_file
+fi
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+ac_exeext=
+ac_objext=o
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+ # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+ if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+ ac_n= ac_c='
+' ac_t=' '
+ else
+ ac_n=-n ac_c= ac_t=
+ fi
+else
+ ac_n= ac_c='\c' ac_t=
+fi
+
+
+
+
+
+
+
+
+
+srcdir="."
+src=wipe.c
+req="config.h require.h debug.h"
+obj=wipe.o
+bin=wipe
+
+fullCFLAGS=""
+wallCFLAGS=""
+pendanticCFLAGS=""
+tempCFLAGS=""
+temp2CFLAGS=""
+checkCFLAGS=""
+optCFLAGS=""
+#CFLAGS="-g -Wall -Werror -ansi -pedantic -O2 -finline-functions -ffast-math -fomit-frame-pointer"
+
+ac_aux_dir=
+for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+ if test -f $ac_dir/install-sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f $ac_dir/install.sh; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; }
+fi
+ac_config_guess=$ac_aux_dir/config.guess
+ac_config_sub=$ac_aux_dir/config.sub
+ac_configure=$ac_aux_dir/configure # This should be Cygnus configure.
+
+
+# Do some error checking and defaulting for the host and target type.
+# The inputs are:
+# configure --host=HOST --target=TARGET --build=BUILD NONOPT
+#
+# The rules are:
+# 1. You are not allowed to specify --host, --target, and nonopt at the
+# same time.
+# 2. Host defaults to nonopt.
+# 3. If nonopt is not specified, then host defaults to the current host,
+# as determined by config.guess.
+# 4. Target and build default to nonopt.
+# 5. If nonopt is not specified, then target and build default to host.
+
+# The aliases save the names the user supplied, while $host etc.
+# will get canonicalized.
+case $host---$target---$nonopt in
+NONE---*---* | *---NONE---* | *---*---NONE) ;;
+*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;;
+esac
+
+
+# Make sure we can run config.sub.
+if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then :
+else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking host system type""... $ac_c" 1>&6
+echo "configure:600: checking host system type" >&5
+
+host_alias=$host
+case "$host_alias" in
+NONE)
+ case $nonopt in
+ NONE)
+ if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then :
+ else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; }
+ fi ;;
+ *) host_alias=$nonopt ;;
+ esac ;;
+esac
+
+host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias`
+host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$host" 1>&6
+
+echo $ac_n "checking target system type""... $ac_c" 1>&6
+echo "configure:621: checking target system type" >&5
+
+target_alias=$target
+case "$target_alias" in
+NONE)
+ case $nonopt in
+ NONE) target_alias=$host_alias ;;
+ *) target_alias=$nonopt ;;
+ esac ;;
+esac
+
+target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias`
+target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$target" 1>&6
+
+echo $ac_n "checking build system type""... $ac_c" 1>&6
+echo "configure:639: checking build system type" >&5
+
+build_alias=$build
+case "$build_alias" in
+NONE)
+ case $nonopt in
+ NONE) build_alias=$host_alias ;;
+ *) build_alias=$nonopt ;;
+ esac ;;
+esac
+
+build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias`
+build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+echo "$ac_t""$build" 1>&6
+
+test "$host_alias" != "$target_alias" &&
+ test "$program_prefix$program_suffix$program_transform_name" = \
+ NONENONEs,x,x, &&
+ program_prefix=${target_alias}-
+
+
+
+OSTYPE=`echo $build_os | sed 's/\..*$//g' | sed 's/-.*//g' | tr [a-z] [A-Z]`
+
+# Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:668: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="gcc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:698: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_prog_rejected=no
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# -gt 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ set dummy "$ac_dir/$ac_word" "$@"
+ shift
+ ac_cv_prog_CC="$@"
+ fi
+fi
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+ if test -z "$CC"; then
+ case "`uname -s`" in
+ *win32* | *WIN32*)
+ # Extract the first word of "cl", so it can be a program name with args.
+set dummy cl; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:749: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":"
+ ac_dummy="$PATH"
+ for ac_dir in $ac_dummy; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_CC="cl"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+CC="$ac_cv_prog_CC"
+if test -n "$CC"; then
+ echo "$ac_t""$CC" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+ ;;
+ esac
+ fi
+ test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; }
+fi
+
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
+echo "configure:781: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
+
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+cat > conftest.$ac_ext << EOF
+
+#line 792 "configure"
+#include "confdefs.h"
+
+main(){return(0);}
+EOF
+if { (eval echo configure:797: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ ac_cv_prog_cc_works=yes
+ # If we can't run a trivial program, we are probably using a cross compiler.
+ if (./conftest; exit) 2>/dev/null; then
+ ac_cv_prog_cc_cross=no
+ else
+ ac_cv_prog_cc_cross=yes
+ fi
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ ac_cv_prog_cc_works=no
+fi
+rm -fr conftest*
+ac_ext=c
+# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo "$ac_t""$ac_cv_prog_cc_works" 1>&6
+if test $ac_cv_prog_cc_works = no; then
+ { echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
+fi
+echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
+echo "configure:823: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
+echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
+cross_compiling=$ac_cv_prog_cc_cross
+
+echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
+echo "configure:828: checking whether we are using GNU C" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.c <<EOF
+#ifdef __GNUC__
+ yes;
+#endif
+EOF
+if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:837: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+ ac_cv_prog_gcc=yes
+else
+ ac_cv_prog_gcc=no
+fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+
+ac_test_CFLAGS="${CFLAGS+set}"
+ac_save_CFLAGS="$CFLAGS"
+CFLAGS=
+echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
+echo "configure:856: checking whether ${CC-cc} accepts -g" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ echo 'void f(){}' > conftest.c
+if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then
+ ac_cv_prog_cc_g=yes
+else
+ ac_cv_prog_cc_g=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_prog_cc_g" 1>&6
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+
+echo $ac_n "checking for POSIXized ISC""... $ac_c" 1>&6
+echo "configure:888: checking for POSIXized ISC" >&5
+if test -d /etc/conf/kconfig.d &&
+ grep _POSIX_VERSION /usr/include/sys/unistd.h >/dev/null 2>&1
+then
+ echo "$ac_t""yes" 1>&6
+ ISC=yes # If later tests want to check for ISC.
+ cat >> confdefs.h <<\EOF
+#define _POSIX_SOURCE 1
+EOF
+
+ if test "$GCC" = yes; then
+ CC="$CC -posix"
+ else
+ CC="$CC -Xp"
+ fi
+else
+ echo "$ac_t""no" 1>&6
+ ISC=
+fi
+
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:909: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+#line 924 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:930: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+#line 941 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:947: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 958 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:964: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+if test $ac_cv_prog_gcc = yes; then
+ echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
+echo "configure:990: checking whether ${CC-cc} needs -traditional" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_pattern="Autoconf.*'x'"
+ cat > conftest.$ac_ext <<EOF
+#line 996 "configure"
+#include "confdefs.h"
+#include <sgtty.h>
+Autoconf TIOCGETP
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "$ac_pattern" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_prog_gcc_traditional=yes
+else
+ rm -rf conftest*
+ ac_cv_prog_gcc_traditional=no
+fi
+rm -f conftest*
+
+
+ if test $ac_cv_prog_gcc_traditional = no; then
+ cat > conftest.$ac_ext <<EOF
+#line 1014 "configure"
+#include "confdefs.h"
+#include <termio.h>
+Autoconf TCGETA
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "$ac_pattern" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_prog_gcc_traditional=yes
+fi
+rm -f conftest*
+
+ fi
+fi
+
+echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6
+ if test $ac_cv_prog_gcc_traditional = yes; then
+ CC="$CC -traditional"
+ fi
+fi
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# ./install, which can be erroneously created by make from ./install.sh.
+echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
+echo "configure:1047: checking for a BSD compatible install" >&5
+if test -z "$INSTALL"; then
+if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":"
+ for ac_dir in $PATH; do
+ # Account for people who put trailing slashes in PATH elements.
+ case "$ac_dir/" in
+ /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ if test -f $ac_dir/$ac_prog; then
+ if test $ac_prog = install &&
+ grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ else
+ ac_cv_path_install="$ac_dir/$ac_prog -c"
+ break 2
+ fi
+ fi
+ done
+ ;;
+ esac
+ done
+ IFS="$ac_save_IFS"
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL="$ac_cv_path_install"
+ else
+ # As a last resort, use the slow shell script. We don't cache a
+ # path for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the path is relative.
+ INSTALL="$ac_install_sh"
+ fi
+fi
+echo "$ac_t""$INSTALL" 1>&6
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+
+echo $ac_n "checking whether the C compiler accepts -pipe""... $ac_c" 1>&6
+echo "configure:1101: checking whether the C compiler accepts -pipe" >&5
+CFLAGS="-pipe"
+cat > conftest.$ac_ext <<EOF
+#line 1104 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1111: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; tempCFLAGS="$CFLAGS"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+echo $ac_n "checking whether the C compiler accepts -g""... $ac_c" 1>&6
+echo "configure:1123: checking whether the C compiler accepts -g" >&5
+CFLAGS="-g"
+cat > conftest.$ac_ext <<EOF
+#line 1126 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1133: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; debugCFLAGS="$CFLAGS"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+echo $ac_n "checking whether the C compiler accepts -O0""... $ac_c" 1>&6
+echo "configure:1145: checking whether the C compiler accepts -O0" >&5
+CFLAGS="-O0"
+cat > conftest.$ac_ext <<EOF
+#line 1148 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1155: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; debugCFLAGS="$debugCFLAGS $CFLAGS"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+echo $ac_n "checking whether the C compiler accepts -O2""... $ac_c" 1>&6
+echo "configure:1167: checking whether the C compiler accepts -O2" >&5
+CFLAGS="-O2"
+cat > conftest.$ac_ext <<EOF
+#line 1170 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1177: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; tempCFLAGS="$tempCFLAGS $CFLAGS"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+echo $ac_n "checking whether the C compiler accepts -ansi""... $ac_c" 1>&6
+echo "configure:1189: checking whether the C compiler accepts -ansi" >&5
+CFLAGS="-ansi"
+cat > conftest.$ac_ext <<EOF
+#line 1192 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1199: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; checkCFLAGS="$checkCFLAGS $CFLAGS"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+echo $ac_n "checking whether the C compiler accepts -pedantic""... $ac_c" 1>&6
+echo "configure:1211: checking whether the C compiler accepts -pedantic" >&5
+CFLAGS="-pedantic"
+cat > conftest.$ac_ext <<EOF
+#line 1214 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1221: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; checkCFLAGS="$checkCFLAGS $CFLAGS"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+echo $ac_n "checking whether the C compiler accepts -Wall""... $ac_c" 1>&6
+echo "configure:1233: checking whether the C compiler accepts -Wall" >&5
+CFLAGS="-Wall"
+cat > conftest.$ac_ext <<EOF
+#line 1236 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1243: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; wallCFLAGS="$CFLAGS"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+echo $ac_n "checking whether the C compiler accepts -Werror""... $ac_c" 1>&6
+echo "configure:1255: checking whether the C compiler accepts -Werror" >&5
+CFLAGS="-Werror"
+cat > conftest.$ac_ext <<EOF
+#line 1258 "configure"
+#include "confdefs.h"
+
+int main() {
+
+; return 0; }
+EOF
+if { (eval echo configure:1265: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ echo "$ac_t""yes" 1>&6; pedanticCFLAGS="$wallCFLAGS $CFLAGS"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ echo "$ac_t""no" 1>&6
+fi
+rm -f conftest*
+
+#AC_MSG_CHECKING([whether the C compiler accepts -ffast-math])
+#CFLAGS="-ffast-math"
+#AC_TRY_COMPILE(,,AC_MSG_RESULT(yes); optCFLAGS="$optCFLAGS $CFLAGS",AC_MSG_RESULT(no))
+
+# Check whether --enable-wall or --disable-wall was given.
+if test "${enable_wall+set}" = set; then
+ enableval="$enable_wall"
+ with_wall=$enableval
+else
+ with_wall=no
+fi
+
+test "$with_wall" = "yes" && fullCFLAGS="$checkCFLAGS $wallCFLAGS $pendanticCFLAGS $fullCFLAGS"
+
+temp2CFLAGS="$tempCFLAGS $optCFLAGS"
+
+# Check whether --enable-debug or --disable-debug was given.
+if test "${enable_debug+set}" = set; then
+ enableval="$enable_debug"
+ with_debug=$enableval
+else
+ with_debug=no
+fi
+
+test "$with_debug" = "yes" && temp2CFLAGS="$wallCFLAGS $debugCFLAGS"
+
+# Check whether --enable-efence or --disable-efence was given.
+if test "${enable_efence+set}" = set; then
+ enableval="$enable_efence"
+ with_efence=$enableval
+else
+ with_efence=no
+fi
+
+test "$with_efence" = "yes" && temp2CFLAGS="$debugCFLAGS" && LIBS="-lefence"
+
+DEBUG="$debugCFLAGS $fullCFLAGS"
+fullCFLAGS="$temp2CFLAGS $fullCFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+CFLAGS="$checkCFLAGS -D__USE_BSD -D_BSD_SOURCE -D__USE_POSIX -D_POSIX_SOURCE -D_POSIX_MAPPED_FILES"
+
+
+ac_header_dirent=no
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
+echo "configure:1322: checking for $ac_hdr that defines DIR" >&5
+if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1327 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <$ac_hdr>
+int main() {
+DIR *dirp = 0;
+; return 0; }
+EOF
+if { (eval echo configure:1335: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ eval "ac_cv_header_dirent_$ac_safe=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_dirent_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+ ac_header_dirent=$ac_hdr; break
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+if test $ac_header_dirent = dirent.h; then
+echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
+echo "configure:1360: checking for opendir in -ldir" >&5
+ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-ldir $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1368 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char opendir();
+
+int main() {
+opendir()
+; return 0; }
+EOF
+if { (eval echo configure:1379: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ LIBS="$LIBS -ldir"
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+else
+echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
+echo "configure:1401: checking for opendir in -lx" >&5
+ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_save_LIBS="$LIBS"
+LIBS="-lx $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 1409 "configure"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char opendir();
+
+int main() {
+opendir()
+; return 0; }
+EOF
+if { (eval echo configure:1420: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ LIBS="$LIBS -lx"
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+fi
+
+echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
+echo "configure:1443: checking for ANSI C header files" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1448 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1456: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ ac_cv_header_stdc=yes
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1473 "configure"
+#include "confdefs.h"
+#include <string.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "memchr" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+cat > conftest.$ac_ext <<EOF
+#line 1491 "configure"
+#include "confdefs.h"
+#include <stdlib.h>
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "free" >/dev/null 2>&1; then
+ :
+else
+ rm -rf conftest*
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+if test "$cross_compiling" = yes; then
+ :
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1512 "configure"
+#include "confdefs.h"
+#include <ctype.h>
+#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int main () { int i; for (i = 0; i < 256; i++)
+if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
+exit (0); }
+
+EOF
+if { (eval echo configure:1523: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ :
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_header_stdc=no
+fi
+rm -fr conftest*
+fi
+
+fi
+fi
+
+echo "$ac_t""$ac_cv_header_stdc" 1>&6
+if test $ac_cv_header_stdc = yes; then
+ cat >> confdefs.h <<\EOF
+#define STDC_HEADERS 1
+EOF
+
+fi
+
+for ac_hdr in unistd.h stdint.h fcntl.h memory.h linux/fs.h sys/mount.h sys/disklabel.h sys/ioctl.h sys/file.h sys/stat.h sys/time.h sys/types.h getopt.h errno.h termio.h termios.h linux/mtio.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1550: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1555 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1560: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+echo $ac_n "checking for working const""... $ac_c" 1>&6
+echo "configure:1588: checking for working const" >&5
+if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1593 "configure"
+#include "confdefs.h"
+
+int main() {
+
+/* Ultrix mips cc rejects this. */
+typedef int charset[2]; const charset x;
+/* SunOS 4.1.1 cc rejects this. */
+char const *const *ccp;
+char **p;
+/* NEC SVR4.0.2 mips cc rejects this. */
+struct point {int x, y;};
+static struct point const zero = {0,0};
+/* AIX XL C 1.02.0.0 rejects this.
+ It does not let you subtract one const X* pointer from another in an arm
+ of an if-expression whose if-part is not a constant expression */
+const char *g = "string";
+ccp = &g + (g ? g-g : 0);
+/* HPUX 7.0 cc rejects these. */
+++ccp;
+p = (char**) ccp;
+ccp = (char const *const *) p;
+{ /* SCO 3.2v4 cc rejects this. */
+ char *t;
+ char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+ *t++ = 0;
+}
+{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */
+ int x[] = {25, 17};
+ const int *foo = &x[0];
+ ++foo;
+}
+{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+ typedef const int *iptr;
+ iptr p = 0;
+ ++p;
+}
+{ /* AIX XL C 1.02.0.0 rejects this saying
+ "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+ struct s { int j; const int *ap[3]; };
+ struct s *b; b->j = 5;
+}
+{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+ const int foo = 10;
+}
+
+; return 0; }
+EOF
+if { (eval echo configure:1642: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_const=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ ac_cv_c_const=no
+fi
+rm -f conftest*
+fi
+
+echo "$ac_t""$ac_cv_c_const" 1>&6
+if test $ac_cv_c_const = no; then
+ cat >> confdefs.h <<\EOF
+#define const
+EOF
+
+fi
+
+echo $ac_n "checking for inline""... $ac_c" 1>&6
+echo "configure:1663: checking for inline" >&5
+if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+ cat > conftest.$ac_ext <<EOF
+#line 1670 "configure"
+#include "confdefs.h"
+
+int main() {
+} $ac_kw foo() {
+; return 0; }
+EOF
+if { (eval echo configure:1677: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_c_inline=$ac_kw; break
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+done
+
+fi
+
+echo "$ac_t""$ac_cv_c_inline" 1>&6
+case "$ac_cv_c_inline" in
+ inline | yes) ;;
+ no) cat >> confdefs.h <<\EOF
+#define inline
+EOF
+ ;;
+ *) cat >> confdefs.h <<EOF
+#define inline $ac_cv_c_inline
+EOF
+ ;;
+esac
+
+echo $ac_n "checking for off_t""... $ac_c" 1>&6
+echo "configure:1703: checking for off_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1708 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])off_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_off_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_off_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_off_t" 1>&6
+if test $ac_cv_type_off_t = no; then
+ cat >> confdefs.h <<\EOF
+#define off_t long
+EOF
+
+fi
+
+echo $ac_n "checking for size_t""... $ac_c" 1>&6
+echo "configure:1736: checking for size_t" >&5
+if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1741 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "(^|[^a-zA-Z_0-9])size_t[^a-zA-Z_0-9]" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_type_size_t=yes
+else
+ rm -rf conftest*
+ ac_cv_type_size_t=no
+fi
+rm -f conftest*
+
+fi
+echo "$ac_t""$ac_cv_type_size_t" 1>&6
+if test $ac_cv_type_size_t = no; then
+ cat >> confdefs.h <<\EOF
+#define size_t unsigned
+EOF
+
+fi
+
+echo $ac_n "checking whether stat file-mode macros are broken""... $ac_c" 1>&6
+echo "configure:1769: checking whether stat file-mode macros are broken" >&5
+if eval "test \"`echo '$''{'ac_cv_header_stat_broken'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1774 "configure"
+#include "confdefs.h"
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#if defined(S_ISBLK) && defined(S_IFDIR)
+# if S_ISBLK (S_IFDIR)
+You lose.
+# endif
+#endif
+
+#if defined(S_ISBLK) && defined(S_IFCHR)
+# if S_ISBLK (S_IFCHR)
+You lose.
+# endif
+#endif
+
+#if defined(S_ISLNK) && defined(S_IFREG)
+# if S_ISLNK (S_IFREG)
+You lose.
+# endif
+#endif
+
+#if defined(S_ISSOCK) && defined(S_IFREG)
+# if S_ISSOCK (S_IFREG)
+You lose.
+# endif
+#endif
+
+EOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ egrep "You lose" >/dev/null 2>&1; then
+ rm -rf conftest*
+ ac_cv_header_stat_broken=yes
+else
+ rm -rf conftest*
+ ac_cv_header_stat_broken=no
+fi
+rm -f conftest*
+
+fi
+
+echo "$ac_t""$ac_cv_header_stat_broken" 1>&6
+if test $ac_cv_header_stat_broken = yes; then
+ cat >> confdefs.h <<\EOF
+#define STAT_MACROS_BROKEN 1
+EOF
+
+fi
+
+
+
+for ac_hdr in unistd.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:1830: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1835 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:1840: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+for ac_func in getpagesize
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:1869: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1874 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:1897: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+echo $ac_n "checking for working mmap""... $ac_c" 1>&6
+echo "configure:1922: checking for working mmap" >&5
+if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test "$cross_compiling" = yes; then
+ ac_cv_func_mmap_fixed_mapped=no
+else
+ cat > conftest.$ac_ext <<EOF
+#line 1930 "configure"
+#include "confdefs.h"
+
+/* Thanks to Mike Haertel and Jim Avera for this test.
+ Here is a matrix of mmap possibilities:
+ mmap private not fixed
+ mmap private fixed at somewhere currently unmapped
+ mmap private fixed at somewhere already mapped
+ mmap shared not fixed
+ mmap shared fixed at somewhere currently unmapped
+ mmap shared fixed at somewhere already mapped
+ For private mappings, we should verify that changes cannot be read()
+ back from the file, nor mmap's back from the file at a different
+ address. (There have been systems where private was not correctly
+ implemented like the infamous i386 svr4.0, and systems where the
+ VM page cache was not coherent with the filesystem buffer cache
+ like early versions of FreeBSD and possibly contemporary NetBSD.)
+ For shared mappings, we should conversely verify that changes get
+ propogated back to all the places they're supposed to be.
+
+ Grep wants private fixed already mapped.
+ The main things grep needs to know about mmap are:
+ * does it exist and is it safe to write into the mmap'd area
+ * how to use it (BSD variants) */
+#include <sys/types.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+
+/* This mess was copied from the GNU getpagesize.h. */
+#ifndef HAVE_GETPAGESIZE
+# ifdef HAVE_UNISTD_H
+# include <unistd.h>
+# endif
+
+/* Assume that all systems that can run configure have sys/param.h. */
+# ifndef HAVE_SYS_PARAM_H
+# define HAVE_SYS_PARAM_H 1
+# endif
+
+# ifdef _SC_PAGESIZE
+# define getpagesize() sysconf(_SC_PAGESIZE)
+# else /* no _SC_PAGESIZE */
+# ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+# ifdef EXEC_PAGESIZE
+# define getpagesize() EXEC_PAGESIZE
+# else /* no EXEC_PAGESIZE */
+# ifdef NBPG
+# define getpagesize() NBPG * CLSIZE
+# ifndef CLSIZE
+# define CLSIZE 1
+# endif /* no CLSIZE */
+# else /* no NBPG */
+# ifdef NBPC
+# define getpagesize() NBPC
+# else /* no NBPC */
+# ifdef PAGESIZE
+# define getpagesize() PAGESIZE
+# endif /* PAGESIZE */
+# endif /* no NBPC */
+# endif /* no NBPG */
+# endif /* no EXEC_PAGESIZE */
+# else /* no HAVE_SYS_PARAM_H */
+# define getpagesize() 8192 /* punt totally */
+# endif /* no HAVE_SYS_PARAM_H */
+# endif /* no _SC_PAGESIZE */
+
+#endif /* no HAVE_GETPAGESIZE */
+
+#ifdef __cplusplus
+extern "C" { void *malloc(unsigned); }
+#else
+char *malloc();
+#endif
+
+int
+main()
+{
+ char *data, *data2, *data3;
+ int i, pagesize;
+ int fd;
+
+ pagesize = getpagesize();
+
+ /*
+ * First, make a file with some known garbage in it.
+ */
+ data = malloc(pagesize);
+ if (!data)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ *(data + i) = rand();
+ umask(0);
+ fd = creat("conftestmmap", 0600);
+ if (fd < 0)
+ exit(1);
+ if (write(fd, data, pagesize) != pagesize)
+ exit(1);
+ close(fd);
+
+ /*
+ * Next, try to mmap the file at a fixed address which
+ * already has something else allocated at it. If we can,
+ * also make sure that we see the same garbage.
+ */
+ fd = open("conftestmmap", O_RDWR);
+ if (fd < 0)
+ exit(1);
+ data2 = malloc(2 * pagesize);
+ if (!data2)
+ exit(1);
+ data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
+ if (data2 != mmap(data2, pagesize, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_FIXED, fd, 0L))
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data2 + i))
+ exit(1);
+
+ /*
+ * Finally, make sure that changes to the mapped area
+ * do not percolate back to the file as seen by read().
+ * (This is a bug on some variants of i386 svr4.0.)
+ */
+ for (i = 0; i < pagesize; ++i)
+ *(data2 + i) = *(data2 + i) + 1;
+ data3 = malloc(pagesize);
+ if (!data3)
+ exit(1);
+ if (read(fd, data3, pagesize) != pagesize)
+ exit(1);
+ for (i = 0; i < pagesize; ++i)
+ if (*(data + i) != *(data3 + i))
+ exit(1);
+ close(fd);
+ unlink("conftestmmap");
+ exit(0);
+}
+
+EOF
+if { (eval echo configure:2070: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+then
+ ac_cv_func_mmap_fixed_mapped=yes
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -fr conftest*
+ ac_cv_func_mmap_fixed_mapped=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$ac_cv_func_mmap_fixed_mapped" 1>&6
+if test $ac_cv_func_mmap_fixed_mapped = yes; then
+ cat >> confdefs.h <<\EOF
+#define HAVE_MMAP 1
+EOF
+
+fi
+
+for ac_func in getopt strnlen bzero memset memcpy realloc fchmod ioctl fcntl lockf flock fsync fdatasync unlink rmdir remove rename dirfd
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:2095: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2100 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2123: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
+
+
+CFLAGS="$fullCFLAGS"
+
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs. It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already. You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+ case `(ac_space=' '; set | grep ac_space) 2>&1` in
+ *ac_space=\ *)
+ # `set' does not quote correctly, so add quotes (double-quote substitution
+ # turns \\\\ into \\, and sed turns \\ into \).
+ sed -n \
+ -e "s/'/'\\\\''/g" \
+ -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+ ;;
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+ ;;
+ esac >> confcache
+if cmp -s $cache_file confcache; then
+ :
+else
+ if test -w $cache_file; then
+ echo "updating cache $cache_file"
+ cat confcache > $cache_file
+ else
+ echo "not updating unwritable cache $cache_file"
+ fi
+fi
+rm -f confcache
+
+trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Any assignment to VPATH causes Sun make to only execute
+# the first set of double-colon rules, so remove it if not needed.
+# If there is a colon in the path, we need to keep it.
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d'
+fi
+
+trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15
+
+DEFS=-DHAVE_CONFIG_H
+
+# Without the "./", some shells look in PATH for config.status.
+: ${CONFIG_STATUS=./config.status}
+
+echo creating $CONFIG_STATUS
+rm -f $CONFIG_STATUS
+cat > $CONFIG_STATUS <<EOF
+#! /bin/sh
+# Generated automatically by configure.
+# Run this file to recreate the current configuration.
+# This directory was configured as follows,
+# on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# $0 $ac_configure_args
+#
+# Compiler output produced by configure, useful for debugging
+# configure, is in ./config.log if it exists.
+
+ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]"
+for ac_option
+do
+ case "\$ac_option" in
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+ exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
+ -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
+ echo "$CONFIG_STATUS generated by autoconf version 2.13"
+ exit 0 ;;
+ -help | --help | --hel | --he | --h)
+ echo "\$ac_cs_usage"; exit 0 ;;
+ *) echo "\$ac_cs_usage"; exit 1 ;;
+ esac
+done
+
+ac_given_srcdir=$srcdir
+ac_given_INSTALL="$INSTALL"
+
+trap 'rm -fr `echo "Makefile config.h" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+# Protect against being on the right side of a sed subst in config.status.
+sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > conftest.subs <<\\CEOF
+$ac_vpsub
+$extrasub
+s%@SHELL@%$SHELL%g
+s%@CFLAGS@%$CFLAGS%g
+s%@CPPFLAGS@%$CPPFLAGS%g
+s%@CXXFLAGS@%$CXXFLAGS%g
+s%@FFLAGS@%$FFLAGS%g
+s%@DEFS@%$DEFS%g
+s%@LDFLAGS@%$LDFLAGS%g
+s%@LIBS@%$LIBS%g
+s%@exec_prefix@%$exec_prefix%g
+s%@prefix@%$prefix%g
+s%@program_transform_name@%$program_transform_name%g
+s%@bindir@%$bindir%g
+s%@sbindir@%$sbindir%g
+s%@libexecdir@%$libexecdir%g
+s%@datadir@%$datadir%g
+s%@sysconfdir@%$sysconfdir%g
+s%@sharedstatedir@%$sharedstatedir%g
+s%@localstatedir@%$localstatedir%g
+s%@libdir@%$libdir%g
+s%@includedir@%$includedir%g
+s%@oldincludedir@%$oldincludedir%g
+s%@infodir@%$infodir%g
+s%@mandir@%$mandir%g
+s%@src@%$src%g
+s%@req@%$req%g
+s%@obj@%$obj%g
+s%@bin@%$bin%g
+s%@DEBUG@%$DEBUG%g
+s%@host@%$host%g
+s%@host_alias@%$host_alias%g
+s%@host_cpu@%$host_cpu%g
+s%@host_vendor@%$host_vendor%g
+s%@host_os@%$host_os%g
+s%@target@%$target%g
+s%@target_alias@%$target_alias%g
+s%@target_cpu@%$target_cpu%g
+s%@target_vendor@%$target_vendor%g
+s%@target_os@%$target_os%g
+s%@build@%$build%g
+s%@build_alias@%$build_alias%g
+s%@build_cpu@%$build_cpu%g
+s%@build_vendor@%$build_vendor%g
+s%@build_os@%$build_os%g
+s%@OSTYPE@%$OSTYPE%g
+s%@CC@%$CC%g
+s%@CPP@%$CPP%g
+s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
+s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g
+s%@INSTALL_DATA@%$INSTALL_DATA%g
+
+CEOF
+EOF
+
+cat >> $CONFIG_STATUS <<\EOF
+
+# Split the substitutions into bite-sized pieces for seds with
+# small command number limits, like on Digital OSF/1 and HP-UX.
+ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script.
+ac_file=1 # Number of current file.
+ac_beg=1 # First line for current file.
+ac_end=$ac_max_sed_cmds # Line after last line for current file.
+ac_more_lines=:
+ac_sed_cmds=""
+while $ac_more_lines; do
+ if test $ac_beg -gt 1; then
+ sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file
+ else
+ sed "${ac_end}q" conftest.subs > conftest.s$ac_file
+ fi
+ if test ! -s conftest.s$ac_file; then
+ ac_more_lines=false
+ rm -f conftest.s$ac_file
+ else
+ if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds="sed -f conftest.s$ac_file"
+ else
+ ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file"
+ fi
+ ac_file=`expr $ac_file + 1`
+ ac_beg=$ac_end
+ ac_end=`expr $ac_end + $ac_max_sed_cmds`
+ fi
+done
+if test -z "$ac_sed_cmds"; then
+ ac_sed_cmds=cat
+fi
+EOF
+
+cat >> $CONFIG_STATUS <<EOF
+
+CONFIG_FILES=\${CONFIG_FILES-"Makefile"}
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories.
+
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`"
+ # A "../" for each directory in $ac_dir_suffix.
+ ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'`
+ else
+ ac_dir_suffix= ac_dots=
+ fi
+
+ case "$ac_given_srcdir" in
+ .) srcdir=.
+ if test -z "$ac_dots"; then top_srcdir=.
+ else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;;
+ /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;;
+ *) # Relative path.
+ srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix"
+ top_srcdir="$ac_dots$ac_given_srcdir" ;;
+ esac
+
+ case "$ac_given_INSTALL" in
+ [/$]*) INSTALL="$ac_given_INSTALL" ;;
+ *) INSTALL="$ac_dots$ac_given_INSTALL" ;;
+ esac
+
+ echo creating "$ac_file"
+ rm -f "$ac_file"
+ configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure."
+ case "$ac_file" in
+ *Makefile*) ac_comsub="1i\\
+# $configure_input" ;;
+ *) ac_comsub= ;;
+ esac
+
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ sed -e "$ac_comsub
+s%@configure_input@%$configure_input%g
+s%@srcdir@%$srcdir%g
+s%@top_srcdir@%$top_srcdir%g
+s%@INSTALL@%$INSTALL%g
+" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file
+fi; done
+rm -f conftest.s*
+
+# These sed commands are passed to sed as "A NAME B NAME C VALUE D", where
+# NAME is the cpp macro being defined and VALUE is the value it is being given.
+#
+# ac_d sets the value in "#define NAME VALUE" lines.
+ac_dA='s%^\([ ]*\)#\([ ]*define[ ][ ]*\)'
+ac_dB='\([ ][ ]*\)[^ ]*%\1#\2'
+ac_dC='\3'
+ac_dD='%g'
+# ac_u turns "#undef NAME" with trailing blanks into "#define NAME VALUE".
+ac_uA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_uB='\([ ]\)%\1#\2define\3'
+ac_uC=' '
+ac_uD='\4%g'
+# ac_e turns "#undef NAME" without trailing blanks into "#define NAME VALUE".
+ac_eA='s%^\([ ]*\)#\([ ]*\)undef\([ ][ ]*\)'
+ac_eB='$%\1#\2define\3'
+ac_eC=' '
+ac_eD='%g'
+
+if test "${CONFIG_HEADERS+set}" != set; then
+EOF
+cat >> $CONFIG_STATUS <<EOF
+ CONFIG_HEADERS="config.h"
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+fi
+for ac_file in .. $CONFIG_HEADERS; do if test "x$ac_file" != x..; then
+ # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in".
+ case "$ac_file" in
+ *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'`
+ ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
+ *) ac_file_in="${ac_file}.in" ;;
+ esac
+
+ echo creating $ac_file
+
+ rm -f conftest.frag conftest.in conftest.out
+ ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"`
+ cat $ac_file_inputs > conftest.in
+
+EOF
+
+# Transform confdefs.h into a sed script conftest.vals that substitutes
+# the proper values into config.h.in to produce config.h. And first:
+# Protect against being on the right side of a sed subst in config.status.
+# Protect against being in an unquoted here document in config.status.
+rm -f conftest.vals
+cat > conftest.hdr <<\EOF
+s/[\\&%]/\\&/g
+s%[\\$`]%\\&%g
+s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
+s%ac_d%ac_u%gp
+s%ac_u%ac_e%gp
+EOF
+sed -n -f conftest.hdr confdefs.h > conftest.vals
+rm -f conftest.hdr
+
+# This sed command replaces #undef with comments. This is necessary, for
+# example, in the case of _POSIX_SOURCE, which is predefined and required
+# on some systems where configure will not decide to define it.
+cat >> conftest.vals <<\EOF
+s%^[ ]*#[ ]*undef[ ][ ]*[a-zA-Z_][a-zA-Z_0-9]*%/* & */%
+EOF
+
+# Break up conftest.vals because some shells have a limit on
+# the size of here documents, and old seds have small limits too.
+
+rm -f conftest.tail
+while :
+do
+ ac_lines=`grep -c . conftest.vals`
+ # grep -c gives empty output for an empty file on some AIX systems.
+ if test -z "$ac_lines" || test "$ac_lines" -eq 0; then break; fi
+ # Write a limited-size here document to conftest.frag.
+ echo ' cat > conftest.frag <<CEOF' >> $CONFIG_STATUS
+ sed ${ac_max_here_lines}q conftest.vals >> $CONFIG_STATUS
+ echo 'CEOF
+ sed -f conftest.frag conftest.in > conftest.out
+ rm -f conftest.in
+ mv conftest.out conftest.in
+' >> $CONFIG_STATUS
+ sed 1,${ac_max_here_lines}d conftest.vals > conftest.tail
+ rm -f conftest.vals
+ mv conftest.tail conftest.vals
+done
+rm -f conftest.vals
+
+cat >> $CONFIG_STATUS <<\EOF
+ rm -f conftest.frag conftest.h
+ echo "/* $ac_file. Generated automatically by configure. */" > conftest.h
+ cat conftest.in >> conftest.h
+ rm -f conftest.in
+ if cmp -s $ac_file conftest.h 2>/dev/null; then
+ echo "$ac_file is unchanged"
+ rm -f conftest.h
+ else
+ # Remove last slash and all that follows it. Not all systems have dirname.
+ ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'`
+ if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then
+ # The file is in a subdirectory.
+ test ! -d "$ac_dir" && mkdir "$ac_dir"
+ fi
+ rm -f $ac_file
+ mv conftest.h $ac_file
+ fi
+fi; done
+
+EOF
+cat >> $CONFIG_STATUS <<EOF
+
+EOF
+cat >> $CONFIG_STATUS <<\EOF
+
+exit 0
+EOF
+chmod +x $CONFIG_STATUS
+rm -fr confdefs* $ac_clean_files
+test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1
+
diff --git a/configure.in b/configure.in
new file mode 100644
index 0000000..e7fed52
--- /dev/null
+++ b/configure.in
@@ -0,0 +1,129 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(wipe.c)
+AC_CONFIG_HEADER(config.h)
+
+AC_SUBST(src)
+AC_SUBST(req)
+AC_SUBST(obj)
+AC_SUBST(bin)
+AC_SUBST(DEBUG)
+srcdir="."
+src=wipe.c
+req="config.h require.h debug.h"
+obj=wipe.o
+bin=wipe
+
+fullCFLAGS=""
+wallCFLAGS=""
+pendanticCFLAGS=""
+tempCFLAGS=""
+temp2CFLAGS=""
+checkCFLAGS=""
+optCFLAGS=""
+#CFLAGS="-g -Wall -Werror -ansi -pedantic -O2 -finline-functions -ffast-math -fomit-frame-pointer"
+
+AC_CANONICAL_SYSTEM
+
+AC_SUBST(OSTYPE)
+OSTYPE=`echo $build_os | sed 's/\..*$//g' | sed 's/-.*//g' | tr [[a-z]] [[A-Z]]`
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_ISC_POSIX
+AC_PROG_GCC_TRADITIONAL
+AC_PROG_INSTALL
+
+dnl Compilation tests
+AC_MSG_CHECKING([whether the C compiler accepts -pipe])
+CFLAGS="-pipe"
+AC_TRY_COMPILE(,,AC_MSG_RESULT(yes); tempCFLAGS="$CFLAGS",AC_MSG_RESULT(no))
+
+AC_MSG_CHECKING([whether the C compiler accepts -g])
+CFLAGS="-g"
+AC_TRY_COMPILE(,,AC_MSG_RESULT(yes); debugCFLAGS="$CFLAGS",AC_MSG_RESULT(no))
+
+AC_MSG_CHECKING([whether the C compiler accepts -O0])
+CFLAGS="-O0"
+AC_TRY_COMPILE(,,AC_MSG_RESULT(yes); debugCFLAGS="$debugCFLAGS $CFLAGS",AC_MSG_RESULT(no))
+
+AC_MSG_CHECKING([whether the C compiler accepts -O2])
+CFLAGS="-O2"
+AC_TRY_COMPILE(,,AC_MSG_RESULT(yes); tempCFLAGS="$tempCFLAGS $CFLAGS",AC_MSG_RESULT(no))
+
+AC_MSG_CHECKING([whether the C compiler accepts -ansi])
+CFLAGS="-ansi"
+AC_TRY_COMPILE(,,AC_MSG_RESULT(yes); checkCFLAGS="$checkCFLAGS $CFLAGS",AC_MSG_RESULT(no))
+
+AC_MSG_CHECKING([whether the C compiler accepts -pedantic])
+CFLAGS="-pedantic"
+AC_TRY_COMPILE(,,AC_MSG_RESULT(yes); checkCFLAGS="$checkCFLAGS $CFLAGS",AC_MSG_RESULT(no))
+
+AC_MSG_CHECKING([whether the C compiler accepts -Wall])
+CFLAGS="-Wall"
+AC_TRY_COMPILE(,,AC_MSG_RESULT(yes); wallCFLAGS="$CFLAGS",AC_MSG_RESULT(no))
+
+AC_MSG_CHECKING([whether the C compiler accepts -Werror])
+CFLAGS="-Werror"
+AC_TRY_COMPILE(,,AC_MSG_RESULT(yes); pedanticCFLAGS="$wallCFLAGS $CFLAGS",AC_MSG_RESULT(no))
+
+#AC_MSG_CHECKING([whether the C compiler accepts -ffast-math])
+#CFLAGS="-ffast-math"
+#AC_TRY_COMPILE(,,AC_MSG_RESULT(yes); optCFLAGS="$optCFLAGS $CFLAGS",AC_MSG_RESULT(no))
+
+AC_ARG_ENABLE(wall,
+ [ --enable-wall compile with -ansi -pedantic -Wall -Werror],
+ [with_wall=$enableval],
+ [with_wall=no])
+test "$with_wall" = "yes" && fullCFLAGS="$checkCFLAGS $wallCFLAGS $pendanticCFLAGS $fullCFLAGS"
+
+temp2CFLAGS="$tempCFLAGS $optCFLAGS"
+
+AC_ARG_ENABLE(debug,
+ [ --enable-debug compile for debugger compatibility],
+ [with_debug=$enableval],
+ [with_debug=no])
+test "$with_debug" = "yes" && temp2CFLAGS="$wallCFLAGS $debugCFLAGS"
+
+AC_ARG_ENABLE(efence,
+ [ --enable-efence debug build + link with electric fence],
+ [with_efence=$enableval],
+ [with_efence=no])
+test "$with_efence" = "yes" && temp2CFLAGS="$debugCFLAGS" && LIBS="-lefence"
+
+DEBUG="$debugCFLAGS $fullCFLAGS"
+fullCFLAGS="$temp2CFLAGS $fullCFLAGS -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+CFLAGS="$checkCFLAGS -D__USE_BSD -D_BSD_SOURCE -D__USE_POSIX -D_POSIX_SOURCE -D_POSIX_MAPPED_FILES"
+
+dnl Checks for libraries.
+
+dnl Checks for header files.
+AC_HEADER_DIRENT
+AC_HEADER_STDC
+AC_CHECK_HEADERS(unistd.h stdint.h fcntl.h memory.h linux/fs.h sys/mount.h sys/disklabel.h sys/ioctl.h sys/file.h sys/stat.h sys/time.h sys/types.h getopt.h errno.h termio.h termios.h linux/mtio.h)
+
+dnl Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_C_INLINE
+dnl AC_SYS_LARGEFILE doesn't work, i give up
+AC_TYPE_OFF_T
+AC_TYPE_SIZE_T
+AC_HEADER_STAT
+
+dnl for solaris
+dnl AC_CHECK_TYPES(u_int32_t)
+dnl AC_CHECK_TYPE(uint32_t, AC_DEFINE(HAVE_UINT32_T, 1), , )
+
+dnl Checks for library functions.
+AC_FUNC_MMAP
+AC_CHECK_FUNCS(getopt strnlen bzero memset memcpy realloc fchmod ioctl fcntl lockf flock fsync fdatasync unlink rmdir remove rename dirfd)
+
+dnl commented out, it's not defining
+dnl to avoid cache, check row the second time
+dnl AC_CHECK_MEMBER(struct winsize.ws_col, AC_DEFINE(HAVE_WINSIZE), , #include <sys/ioctl.h>)
+dnl AC_CHECK_MEMBER(struct winsize.ws_row, AC_DEFINE(HAVE_WINSIZE), , #include <termio.h>)
+
+dnl Done with tests
+
+CFLAGS="$fullCFLAGS"
+
+AC_OUTPUT(Makefile)
diff --git a/copyright b/copyright
new file mode 100644
index 0000000..6e11b64
--- /dev/null
+++ b/copyright
@@ -0,0 +1,19 @@
+Wipe was created by Tom Vier <nester@users.sf.net>. Please see
+LICENSE for licensing information.
+
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2003 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
diff --git a/debug.h b/debug.h
new file mode 100644
index 0000000..4045854
--- /dev/null
+++ b/debug.h
@@ -0,0 +1,5 @@
+/*
+ just a blank include for debugging defines
+
+ just echo '#define VAR' >> debug.h to enable the option
+*/
diff --git a/dir.c b/dir.c
new file mode 100644
index 0000000..38f8536
--- /dev/null
+++ b/dir.c
@@ -0,0 +1,336 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <dirent.h>
+
+#define __USE_GNU
+#include <string.h>
+
+#include "config.h"
+
+#ifndef HAVE_RMDIR
+# define rmdir(x) remove(x)
+#endif
+
+#include "std.h"
+#include "str.h"
+#include "main.h"
+#include "percent.h"
+#include "file.h"
+#include "io.h"
+#include "dir.h"
+
+extern int errno;
+extern int exit_code;
+extern char *argvzero;
+extern struct rename_s rns;
+extern struct opt_s options;
+
+private int dir_sync(int ffd, char name[]);
+
+/*
+ drill_down -- drill down through a directory
+
+ char str[] -- directory name
+*/
+
+public void drill_down(const char str[])
+{
+ DIR *dir;
+ struct dirent *entry;
+ char *base, real_base[PATH_MAX+1];
+ char dirname[PATH_MAX+1];
+ size_t len;
+ char prompt[4];
+
+ strncpy(dirname, str, PATH_MAX);
+ dirname[sizeof(dirname)-1] = 0;
+
+#ifdef DEBUG
+ fprintf(stderr, "checking %s\n", dirname);
+#endif
+
+ if ((dir = opendir(dirname)) == NULL)
+ {
+ fprintf(stderr, "\r%s: cannot open directory `%s': %s\n",
+ argvzero, dirname, strerror(errno));
+ exit_code = errno; return;
+ }
+
+ if (chdir(dirname))
+ {
+ fprintf(stderr, "\r%s: cannot enter directory `%s': %s\n",
+ argvzero, dirname, strerror(errno));
+ exit_code = errno; goto cleanup;
+ }
+
+ while ((entry = readdir(dir)) != NULL)
+ {
+ if (strncmp(entry->d_name, ".", 2) && strncmp(entry->d_name, "..", 3) != 0)
+ do_file(entry->d_name); /*** process file ***/
+ }
+
+ if (chdir(".."))
+ {
+ fprintf(stderr, "\r%s: cannot exit current directory `%s': %s\n"
+ "We're trapped!\n", argvzero, dirname, strerror(errno));
+ abort();
+ }
+
+#ifdef DEBUG
+ if (options.delete)
+ fprintf(stderr, "\rwould have removed: %s\n", dirname);
+#endif
+
+#ifndef DEBUG
+ if (options.delete)
+ {
+ /*
+ make sure dirname doesn't end in a slash,
+ otherwise base will end up pointing to \0
+ */
+#ifdef HAVE_STRNLEN
+ len = strnlen(dirname, PATH_MAX);
+#else
+ len = strlen(dirname);
+ if (len > PATH_MAX) len = PATH_MAX;
+#endif
+ base = (char *) (dirname + (len-1)); /* find the last char */
+
+ /* loop it, in case of multiple slashes */
+ /* note that base is decremented after each use */
+ while (strncmp((char *) base--, "/", 1) == 0)
+ dirname[--len] = (char) 0; /* truncate string and update length */
+
+ /*
+ point base at just after the path to the directory,
+ since we're in the same directory that the target is.
+ in other words, this strips the path the directory
+ */
+ if ((base = strrchr(dirname, '/')) == NULL)
+ base = dirname;
+ else
+ ++base;
+
+ if (options.interactive)
+ {
+ prompt[0] = 0;
+ while (prompt[0] != 'y' && prompt[0] != 'n')
+ {
+ printf("\r%s: remove directory `%s'? ",
+ argvzero, dirname);
+ fgets(prompt, sizeof(prompt), stdin);
+
+ if (prompt[0] == 'y' || prompt[0] == 'Y') break;
+ if (prompt[0] == 'n' || prompt[0] == 'N') goto cleanup;
+ }
+ }
+
+ strncpy(real_base, base, PATH_MAX);
+ real_base[sizeof(real_base)-1] = 0;
+
+ wipe_name(-1, real_base, strnlen(real_base, sizeof(real_base)));
+ wipe_name(-1, real_base, 0);
+
+ if (rmdir(real_base))
+ {
+ fprintf(stderr, "\r%s: %s: unable to remove directory: `%s'\n",
+ argvzero, strerror(errno), base);
+
+ rename(real_base, base); /* try to rename it back */
+ exit_code = errno;
+ }
+ }
+
+ cleanup:
+ if (closedir(dir))
+ {
+ fprintf(stderr, "\r%s: closedir failed for `%s': %s\n",
+ argvzero, dirname, strerror(errno));
+ exit_code = errno; return;
+ }
+#endif
+}
+
+/*
+ wipe_name -- rename to random characters
+
+ real_name - assumed to be PATHMAX+1 long
+ rnlen - length to overwrite, or 0 for don't care (NAME_MAX)
+
+ this won't work for hashed dirs
+*/
+
+public int wipe_name(int ffd, char *real_name, size_t rnlen)
+{
+ int i;
+ size_t len, pathlen;
+ char *base, dest_name[PATH_MAX+1];
+
+#ifdef SANITY
+ if ((!options.random) || (!options.delete))
+ {
+ fprintf(stderr, "%s: options.random is %d, options.delete is %d\n",
+ argvzero, options.random, options.delete);
+ abort();
+ }
+#endif
+
+ if (rnlen == 0 || rnlen > NAME_MAX)
+ rnlen = NAME_MAX;
+
+ if (rnlen > 0) ++rnlen;
+
+ /* copy the path to the file */
+
+ /*
+ strncpy does NOT guarantee NUL termination
+ it's an often over looked hole for a buffer overflow exploit from
+ untrusted input.
+ */
+ strncpy(dest_name, real_name, rnlen);
+ dest_name[sizeof(dest_name)-1] = 0;
+
+ /* point base at just after the path, ie, strip the path */
+ base = strrchr(dest_name, '/');
+
+ /* strrchr doesn't ask for the boundry */
+ if (base == NULL // not found
+ || base >= (dest_name + sizeof(dest_name))) // boundry check
+ base = dest_name;
+ else
+ ++base;
+
+ /* truncate the path to get the length */
+ *base = 0x00;
+
+ pathlen = strnlen(dest_name, sizeof(dest_name));
+
+ /*
+ overwrite the filename, same length
+ won't work for hashed dirs
+
+ the second time wipe_name() called, it'll be trying to
+ overwrite the rand name used last time
+ */
+
+ //len = strnlen((strrchr(real_name, '/')+1));
+
+ /*
+ we try to use as long a filename as possible,
+ but not longer than PATH_MAX.
+ */
+
+ len = pathlen + rnlen;
+ if (len > PATH_MAX)
+ rnlen -= len - PATH_MAX;
+
+ /*
+ get a random filename, but make sure that there
+ isn't one with the same name prior renaming --tg
+ */
+
+ i=0;
+ while (!i)
+ {
+ rename_str(base, rnlen);
+ i = access(dest_name, F_OK);
+ }
+
+#ifdef NORENAME
+ /* debugging aid */
+ fprintf(stderr, "\rwould have renamed to %s\n", base);
+ return 0;
+#endif
+
+ if (rename(real_name, dest_name) == 0)
+ {
+ /* update pathname */
+ strncpy(real_name, dest_name, strnlen(dest_name, sizeof(dest_name)));
+ real_name[PATH_MAX] = 0;
+ strncpy(rns.cur_name, dest_name, strnlen(dest_name, sizeof(dest_name)));
+ rns.cur_name[PATH_MAX] = 0;
+ rns.valid = 1;
+ }
+ else
+ {
+ fprintf(stderr, "\r%s: cannot rename `%s': %s\n",
+ argvzero, real_name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+
+ /* now try to commit the rename to storage */
+ if (dir_sync(ffd, ".")) return FAILED;
+
+ if (ffd == -1)
+ {
+ /* if the object is itself a dir, sync it also */
+ if (dir_sync(ffd, real_name)) return FAILED;
+ }
+
+ return 0;
+}
+
+private int dir_sync(int ffd, char name[])
+{
+
+#ifdef HAVE_DIRFD
+ int dfd;
+ DIR *dir;
+
+ /* sync the dir */
+ if ((dir = opendir(".")) == NULL)
+ {
+ fprintf(stderr, "\r%s: cannot open directory `%s': %s\n",
+ argvzero, name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+
+ if ((dfd = dirfd(dir)) < 0)
+ {
+ fprintf(stderr, "\r%s: dirfd() failed for `%s': %s\n",
+ argvzero, name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+
+ sync_data(".", dfd, 0); /* this should force a write of the dir entry */
+
+ if (closedir(dir))
+ {
+ fprintf(stderr, "\r%s: closedir failed for `%s': %s\n",
+ argvzero, name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+#endif
+
+ /* fsync() the file, in case that's how to force the dir entry on some OS */
+ if (ffd > -1) sync_data("FSYNC FOR wipe_name()", ffd, 1);
+
+ return 0;
+}
diff --git a/dir.h b/dir.h
new file mode 100644
index 0000000..a2e6ba9
--- /dev/null
+++ b/dir.h
@@ -0,0 +1,24 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+public void drill_down(const char str[]);
+public int wipe_name(int ffd, char *real_name, size_t rnlen);
diff --git a/file.c b/file.c
new file mode 100644
index 0000000..512af80
--- /dev/null
+++ b/file.c
@@ -0,0 +1,249 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <unistd.h>
+
+#ifndef _POSIX_SYNCHRONIZED_IO
+# define _POSIX_SYNCHRONIZED_IO
+# include <unistd.h>
+#endif
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+
+#include "config.h"
+
+#include "std.h"
+#include "main.h"
+#include "percent.h"
+#include "file.h"
+#include "rand.h"
+#include "prompt.h"
+#include "wipe.h"
+
+extern int errno;
+extern int exit_code;
+extern char *argvzero;
+extern struct rename_s rns;
+extern struct opt_s options;
+
+private int fgetdata(const char *name, struct file_s *f);
+
+/*
+ do_file -- file processing begins here
+*/
+
+public void do_file(const char *name)
+{
+ int code;
+ struct file_s f;
+
+ rns.valid=0; rns.valid_mode=0;
+
+ if ((code = fgetdata(name, &f)) == FAILED)
+ {exit_code = code; return;}
+
+ if (options.no_file)
+ {destroy_file(&f); return;}
+
+ switch (f.st.st_mode & S_IFMT)
+ {
+ case S_IFREG: /* regular file */
+ case S_IFBLK: /* block device */
+ case S_IFCHR: /* char dev */
+ prompt_destroy(&f, R_OK|W_OK);
+ break;
+
+ case S_IFDIR: /* directory */
+ prompt_recursion(name, R_OK|W_OK|X_OK, f.st.st_mode);
+ break;
+
+ case S_IFIFO: /* fifo */
+ prompt_unlink(name, "fifo", W_OK, f.st.st_mode);
+ return;
+
+ case S_IFSOCK: /* socket */
+ prompt_unlink(name, "socket", W_OK, f.st.st_mode);
+ return;
+
+ case S_IFLNK: /* sym link */
+ prompt_unlink(name, "symbolic link", W_OK, f.st.st_mode);
+ return;
+
+ default:
+ abort();
+ }
+}
+
+/*
+ fsetbuf -- inits fsize, bufsize, loop, sfail
+*/
+
+public void fsetbuf(struct file_s *f)
+{
+ /* init */
+ f->sfail = 0;
+ f->bufsize = options.chunk_size;
+
+ /*
+ the block size is a multiple of the sector size, so
+ covering all allocated blocks covers all sectors
+ */
+
+ /*
+ cover all allocated blocks
+
+ since sector_size % 3 is almost always > 0, we
+ always run ++f->fsize at least once, so that it'll
+ effectively do an if (fsize % 3) ++three_write_count,
+ if you catch my drift. that way, write3_pass() doesn't
+ have to worry about f->bufsize % 3 == 0
+ */
+
+ if (!options.no_file)
+ {
+ if (!S_ISBLK(f->st.st_mode) && !S_ISCHR(f->st.st_mode))
+ {
+ f->fsize = f->st.st_size;
+
+ if (f->fsize % f->st.st_blksize)
+ f->fsize += f->st.st_blksize - (f->fsize % f->st.st_blksize);
+ else
+ ++f->fsize;
+ }
+ }
+ else
+ f->fsize = options.stdout_size;
+
+ /*
+ note that i don't do
+ while (f->bufsize % sizeof(unsigned long)) ++f->bufsize;
+ which would simplify prng_fillbuf()
+
+ in order for both that and f->bufsize % 3 == 0 to be true,
+ you'd have to loop repeatedly which could possibly make
+ the file much larger than we'd want
+
+ see previous comment block for why we don't have to worry
+ about this. this block is left here for historical reasons.
+ */
+
+ if (f->fsize > options.chunk_size)
+ {
+ f->loop = f->fsize / options.chunk_size;
+ f->loopr = f->fsize % options.chunk_size;
+ }
+ else
+ {
+ f->loop = 1; f->loopr = 0;
+ if (f->fsize) f->bufsize = f->fsize;
+ }
+}
+
+/*
+ ffreebuf -- deallocate file buffer
+*/
+
+public void ffreebuf(struct file_s *f)
+{
+ free(f->buf);
+}
+
+/*
+ fgetbuf -- allocate file buffer
+*/
+
+public int fgetbuf(struct file_s *f)
+{
+ if ((f->buf = malloc(f->bufsize)) == NULL)
+ {
+ fprintf(stderr, "\r%s: cannot allocate %ld bytes for `%s': %s\n",
+ argvzero, (long int) f->bufsize, f->name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+
+#ifdef SANITY
+ if ((unsigned long int) f->buf % sizeof(u_rand_t))
+ {
+ fprintf(stderr, "\r%s: buffer not %ld byte aligned! Skipping `%s'\n",
+ argvzero, (long int) sizeof(u_rand_t), f->name);
+ return FAILED;
+ }
+#endif
+
+ return 0;
+}
+
+/*
+ fgetdata -- gets stat() info and fills in struct file_s
+*/
+
+private int fgetdata(const char *name, struct file_s *f)
+{
+ /*
+ * save the original pathname, so we can use it
+ * when interacting with the user
+ */
+
+ /* copy pathname */
+ strncpy(f->name, name, PATH_MAX);
+ strncpy(f->real_name, name, PATH_MAX);
+ strncpy(rns.orig_name, name, PATH_MAX);
+ strncpy(rns.cur_name, name, PATH_MAX);
+
+ /*
+ * make sure the destination string is NUL terminated
+ * strncpy() does NOT guarantee dest strings are NUL terminated
+ */
+ f->name[sizeof(f->name)-1] = 0;
+ f->real_name[sizeof(f->real_name)-1] = 0;
+ rns.orig_name[sizeof(rns.orig_name)-1] = 0;
+ rns.cur_name[sizeof(rns.cur_name)-1] = 0;
+
+ if (!options.no_file)
+ {
+ rns.valid = 0;
+ /* get inode data */
+ if (lstat(f->name, &f->st))
+ {
+ fprintf(stderr, "\r%s: cannot stat `%s': %s\n",
+ argvzero, f->name, strerror(errno));
+ return FAILED;
+ }
+ rns.mode = f->st.st_mode;
+ rns.valid_mode = 1;
+ }
+
+ /* init to safe values */
+ if (options.no_file)
+ f->fd = 1;
+ else
+ f->fd = -1;
+
+ f->buf = NULL;
+ f->bufsize=0; f->loop=0;
+
+ return 0;
+}
diff --git a/file.h b/file.h
new file mode 100644
index 0000000..97c9c0a
--- /dev/null
+++ b/file.h
@@ -0,0 +1,94 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/* this pre-processor stuff is for both file.c and dir.c to use */
+
+#ifdef HAVE_DIRENT_H
+# include <dirent.h>
+# define NAMLEN(dirent) (strlen((dirent)->d_name))
+#endif
+
+#ifndef HAVE_DIRENT_H
+# define dirent direct
+# define NAMLEN(dirent) ((dirent)->d_namlen)
+# ifdef HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# ifdef HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# ifdef HAVE_NDIR_H
+# include <ndir.h>
+# endif
+#endif
+
+/* these should be safe for darwin */
+#ifndef PATH_MAX
+# define PATH_MAX 1023
+#endif
+#ifndef NAME_MAX
+# define NAME_MAX 255
+#endif
+
+#ifndef O_NOFOLLOW
+# define O_NOFOLLOW 0
+#endif
+
+#ifndef O_DSYNC
+# define O_DSYNC O_SYNC
+#endif
+
+#if defined HAVE_FSYNC || defined HAVE_FDATASYNC
+# define SYNC 0
+#else
+# ifdef O_DSYNC
+# define SYNC O_DSYNC
+# else
+# define SYNC O_SYNC
+# endif
+#endif
+
+#include <sys/stat.h>
+
+/* file data */
+struct file_s
+{
+ int fd; /* file descriptor */
+ short sfail; /* fsync failed */
+
+ void *buf; /* file buffer */
+ size_t bufsize; /* requested buffer size from fsetbuf() */
+
+ unsigned long long fsize; /* intended file length or block dev length */
+ unsigned long loop, loopr; /* fsize / bufsize and fsize % bufsize */
+
+ char name[PATH_MAX+1], /* original pathname */
+ real_name[PATH_MAX+1]; /* current filename -- path is the same */
+
+ struct stat st; /* file status */
+ struct percent_s percent; /* percent data for the current file */
+};
+
+public void do_file(const char *name);
+public void fsetbuf(struct file_s *f);
+public void ffreebuf(struct file_s *f);
+public int fgetbuf(struct file_s *f);
diff --git a/header.h b/header.h
new file mode 100644
index 0000000..de168a4
--- /dev/null
+++ b/header.h
@@ -0,0 +1,21 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) ****___xxxxxxx___**** by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
diff --git a/install-sh b/install-sh
new file mode 100755
index 0000000..e843669
--- /dev/null
+++ b/install-sh
@@ -0,0 +1,250 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission. M.I.T. makes no representations about the
+# suitability of this software for any purpose. It is provided "as is"
+# without express or implied warranty.
+#
+# 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}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ true
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ else
+ instcmd=mkdir
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f $src -o -d $src ]
+ then
+ true
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ true
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ true
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ true
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/io.c b/io.c
new file mode 100644
index 0000000..580f1b5
--- /dev/null
+++ b/io.c
@@ -0,0 +1,294 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _POSIX_SYNCHRONIZED_IO
+# define _POSIX_SYNCHRONIZED_IO
+#endif
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "config.h"
+
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+
+#ifdef HAVE_SYS_IOCTL_H
+# ifdef HAVE_LINUX_MTIO_H
+# include <sys/ioctl.h>
+# include <linux/mtio.h>
+# endif
+#endif
+
+#include "std.h"
+#include "percent.h"
+#include "file.h"
+#include "wipe.h"
+#include "main.h"
+#include "io.h"
+
+extern int errno;
+extern int exit_code;
+extern char *argvzero;
+extern struct opt_s options;
+
+/*
+ do_fwb -- file write barrier
+
+ hopefully, linux and others will export a real
+ write barrier to userspace some day
+*/
+
+public int do_fwb(const char name[], const int fd, const short failed)
+{
+ return sync_data(name, fd, failed);
+}
+
+/*
+ sync_data -- sync file to disk
+*/
+
+public int sync_data(const char name[], const int fd, const short failed)
+{
+#ifdef SANITY
+ if (fd == -1) abort(); /* catch any callers with invalid fd's */
+#endif
+
+#if !defined (HAVE_FSYNC) || !defined (HAVE_FDATASYNC)
+ /*
+ the file will still get written out
+ file.h will make the file be opened with a sync flag
+ */
+ return 0;
+#endif
+
+#ifdef HAVE_FDATASYNC
+ if (fdatasync(fd))
+#endif
+#ifdef HAVE_FSYNC
+ if (fsync(fd))
+#endif
+ {
+ if (!failed)
+ {
+ fprintf(stderr, "\r%s: cannot synchronize `%s': %s\n",
+ argvzero, name, strerror(errno));
+#ifdef HAVE_FCNTL
+ if (fcntl(fd, F_SETFL, O_SYNC) == -1)
+ {
+ fprintf(stderr, "\r%s: cannot set synchronis writes `%s': %s\n",
+ argvzero, name, strerror(errno));
+ exit_code = errno;
+ }
+#endif
+ }
+ return FAILED;
+ }
+ return 0;
+}
+
+/*
+ do_ftruncate -- ftruncate(2) wrapper
+*/
+
+public int do_ftruncate(const char name[], const int fd, off_t length)
+{
+ if (ftruncate(fd, length))
+ {
+ fprintf(stderr, "\r%s: cannot truncate `%s': %s\n",
+ argvzero, name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+ return 0;
+}
+
+/*
+ do_open -- open(2) wrapper
+*/
+
+public int do_open(const char name[], const char real_name[], int *fd)
+{
+ /*
+ shred (GNU fileutils) was using fopen() in write-only
+ mode which truncates the file before returning. this
+ encouraged reallocation of the file's blocks as shred
+ wrote to it.
+
+ one major flaw with file wipers like this one and shred,
+ is that nothing guarantees that the FS isn't reallocating
+ different blocks to the file. log structured FSes, like
+ LFS, will almost never use the same blocks. in that case,
+ block wiping must be done by wiping free space and any
+ old file versions or snapshots.
+ */
+
+ /* see file.h about the SYNC flag */
+ if ((*fd = open(real_name, O_WRONLY | O_NOFOLLOW | SYNC)) < 0)
+ {
+ fprintf(stderr, "\r%s: cannot open `%s': %s\n",
+ argvzero, name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+
+ return 0;
+}
+
+
+/*
+ do_close -- close(2) wrapper
+*/
+
+public int do_close(const char name[], const int fd)
+{
+ if (close(fd))
+ {
+ fprintf(stderr, "\r%s: close failed for `%s': %s\n",
+ argvzero, name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+ return 0;
+}
+
+/*
+ do_read -- read(2) wrapper
+*/
+
+public int do_read(const char name[], const int fd, void *buf, size_t count)
+{
+ ssize_t c;
+ int retries;
+
+ retry:
+ c = read(fd, buf, count);
+
+ if (c == -1)
+ {
+ if (errno == EINTR)
+ goto retry;
+
+ if (errno == EIO)
+ {
+ if (retries == 5)
+ goto abort;
+ else
+ {++retries; goto retry;}
+ }
+
+ abort:
+ fprintf(stderr, "\r%s: cannot read `%s': %s\n",
+ argvzero, name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+ else
+ {
+ if (c < count)
+ {
+ count -= c;
+ do_read(name, fd, (buf + c), count); /* recurse */
+ }
+ }
+
+ return 0;
+}
+
+/*
+ do_write -- write(2) wrapper
+*/
+
+public int do_write(const char name[], const int fd, void *buf, size_t count)
+{
+ int ret;
+ ssize_t c, written;
+
+ if (count == 0) abort(); /* i'd like to know about it */
+
+ ret=0; written=0;
+
+ while (written < count)
+ {
+ c = write(fd, buf, count - written);
+
+ if (c == 0) abort(); /* shouldn't happen */
+
+ if (c > 0) /* full or partial success */
+ {
+ written += c; buf += c;
+ }
+ else /* failed, c < 0 */
+ {
+ if (errno == ENOSPC && options.until_full)
+ {
+ --count; ret = ENOSPC;
+ }
+ else if (errno == EAGAIN || errno == EINTR)
+ continue;
+ else
+ {
+ fprintf(stderr, "\r%s: write failed to `%s': %s\n",
+ argvzero, name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+ }
+ }
+ return ret;
+}
+
+public int do_rewindfd(const char name[], const char real_name[], int *fd, const mode_t mode)
+{
+ /* can't seek on stdout */
+ if (options.no_file) return 0;
+
+ if (lseek(*fd, 0, SEEK_SET))
+ {
+ fprintf(stderr, "\r%s: lseek() failed for `%s': %s\n",
+ argvzero, real_name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+
+ if (S_ISCHR(mode))
+ {
+ /* probably a tape drive - try to rewind */
+
+#ifdef MTIOCTOP
+ struct mtop cmd;
+ cmd.mt_op = MTREW; cmd.mt_count = 1;
+
+ if (ioctl(*fd, MTIOCTOP, cmd))
+ {
+ fprintf(stderr, "\r%s: warning: ioctl() failed for `%s': %s - will attempt reopen\n",
+ argvzero, real_name, strerror(errno));
+ }
+ else return 0;
+#endif
+ /* this won't work on non-rewind devices like /dev/nst0 */
+ if (do_close(name, *fd)) return FAILED;
+ return do_open(name, real_name, fd);
+ }
+
+ return 0;
+}
diff --git a/io.h b/io.h
new file mode 100644
index 0000000..0d38032
--- /dev/null
+++ b/io.h
@@ -0,0 +1,30 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+public int do_fwb(const char name[], const int fd, const short failed);
+public int sync_data(const char name[], const int fd, const short failed);
+public int do_open(const char name[], const char real_name[], int *fd);
+public int do_close(const char name[], const int fd);
+public int do_ftruncate(const char name[], const int fd, off_t length);
+public int do_read(const char name[], const int fd, void *buf, size_t count);
+public int do_write(const char name[], const int fd, void *buf, size_t count);
+public int do_rewindfd(const char name[], const char real_name[], int *fd, const mode_t mode);
diff --git a/lock.c b/lock.c
new file mode 100644
index 0000000..6ed2bba
--- /dev/null
+++ b/lock.c
@@ -0,0 +1,154 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <unistd.h>
+#include <stdio.h>
+
+#include "config.h"
+
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#else
+# undef HAVE_FCNTL
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#ifndef HAVE_FCNTL
+# ifndef HAVE_LOCKF
+# ifdef HAVE_FLOCK
+# ifdef HAVE_SYS_FILE_H
+# include <sys/file.h>
+# else
+# undef HAVE_FLOCK
+# endif
+# endif
+# endif
+#endif
+
+#undef LOCKABLE
+#ifdef HAVE_FCNTL
+# define LOCKABLE
+#elif HAVE_LOCKF
+# define LOCKABLE
+#elif HAVE_FLOCK
+# define LOCKABLE
+#endif
+
+#include "std.h"
+#include "main.h"
+#include "percent.h"
+#include "file.h"
+#include "lock.h"
+
+extern char *argvzero;
+extern struct opt_s options;
+
+/*
+ lock -- create as good a lock as possible
+ what a mess
+*/
+
+public int do_lock(struct file_s *f)
+{
+ char prompt[4];
+
+#ifndef LOCKABLE
+ return(0);
+#endif
+
+#ifdef HAVE_FCNTL
+ struct flock file_lock;
+
+ file_lock.l_type = F_WRLCK;
+ file_lock.l_whence = 0;
+ file_lock.l_start = 0;
+ file_lock.l_len = 0;
+#endif
+
+#ifdef LOCKTEST
+ fprintf(stderr, "\rattempting lock on %s...", f->name);
+#endif
+
+#ifdef HAVE_FCHMOD
+ /* try for a mandatory lock */
+ if (fchmod(f->fd, 02600))
+ {
+# ifdef LOCKTEST
+ fprintf(stderr, "mandatory lock failed\ntrying for advisory...");
+# endif
+ }
+#endif
+
+#ifdef HAVE_FCNTL
+ if (fcntl(f->fd, F_SETLKW, &file_lock) == 0)
+ {
+# ifdef LOCKTEST
+ fprintf(stderr, "got it\n");
+# endif
+ return 0; /* lock successful */
+ }
+
+#elif HAVE_LOCKF
+
+ if (lseek(f->fd, 0, SEEK_SET))
+ {
+ fprintf(stderr, "\r%s: lseek() failed for `%s': %s\n",
+ argvzero, name, strerror(errno));
+ exit_code = errno; return FAILED;
+ }
+
+ if (lockf(f->fd, F_LOCK, f->fsize) == 0)
+ {
+# ifdef LOCKTEST
+ fprintf(stderr, "got it\n");
+# endif
+ return 0; /* lock successful */
+ }
+
+#elif HAVE_FLOCK
+ if (flock(f->fd, LOCK_EX) == 0)
+ {
+# ifdef LOCKTEST
+ fprintf(stderr, "got it\n");
+# endif
+ return 0; /* lock successful */
+ }
+#endif
+
+ /* lock failed */
+ if (options.force && !options.verbose)
+ return 0;
+
+ prompt[0] = 0; /* clear prompt */
+ while (prompt[0] != 'y' && prompt[0] != 'n')
+ {
+ printf("\r%s: lock failed: \'%s\'. Wipe anyway? ", argvzero, f->name);
+ fgets(prompt, sizeof(prompt), stdin);
+
+ if (prompt[0] == 'y') return 0;
+ if (prompt[0] == 'n') return FAILED;
+ }
+
+ return 0;
+}
diff --git a/lock.h b/lock.h
new file mode 100644
index 0000000..4e777f7
--- /dev/null
+++ b/lock.h
@@ -0,0 +1,23 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2001 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+public int do_lock(struct file_s *f);
diff --git a/main.c b/main.c
new file mode 100644
index 0000000..d1dc671
--- /dev/null
+++ b/main.c
@@ -0,0 +1,496 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe v2.3
+ by Tom Vier <nester@users.sf.net>
+
+ http://wipe.sf.net/
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <signal.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#ifdef HAVE_GETOPT_H
+# include <getopt.h>
+#endif
+
+#include "config.h"
+#include "require.h"
+
+#include "std.h"
+#include "percent.h"
+#include "file.h"
+#include "rand.h"
+#include "text.h"
+#include "wipe.h"
+#include "main.h"
+
+/* global vars */
+char *argvzero;
+int exit_code;
+
+extern int errno;
+
+struct opt_s options; /* cmd line options */
+struct rename_s rns;
+struct sigaction sigact;
+
+
+/* catch ctr-c */
+public void int_hand(int sig)
+{
+ printf("\n%s: caught signal %d, exiting\n", argvzero, sig);
+
+ restore_file();
+
+ exit(sig);
+}
+
+public void restore_file(void)
+{
+ /* hack to restore current filename before exitting */
+ if (rns.valid)
+ if (rename(rns.cur_name, rns.orig_name))
+ {
+ fprintf(stderr, "%s: cannot rename `%s': %s\n",
+ argvzero, rns.orig_name, strerror(errno));
+ }
+
+ if (rns.valid_mode)
+ {
+ /* restore file mode */
+ if (chmod(rns.cur_name, (rns.mode & 07777)))
+ {
+ fprintf(stderr, "\r%s: cannot restore file mode for `%s': %s\n",
+ argvzero, rns.orig_name, strerror(errno));
+ }
+ }
+}
+
+public int main(int argc, char **argv)
+{
+ int opt; /* option character */
+ long long tmp; int tmpd; /* to check input range */
+ extern int optopt; /* getopt() stuff */
+ extern char *optarg; /* getopt() stuff */
+ extern int optind, opterr; /* getopt() stuff */
+
+ opterr=0; /* we'll handle bad options */
+
+ errno=0;
+ exit_code=0;
+ argvzero = argv[0];
+
+ /* set defaults */
+ options.sectors = 0;
+ options.sector_size = SECTOR_SIZE;
+ options.chunk_size = CHUNK_SIZE;
+ options.stdout_size = 0;
+ options.custom_byte = 0x00;
+ options.verbose = 1; /* show percent if >= PERCENT_ENABLE_SIZE */
+ options.percent_sync = 0; /* call fsync before printing percentage */
+ options.recursion = 0; /* do not traverse directories */
+ options.no_file = 0; /* use named files */
+ options.until_full = 0; /* don't write until out of space */
+ options.zero = 0; /* don't just zero-out the file */
+ options.force = 0; /* respect file permissions */
+ options.delete = 1; /* remove targets */
+ options.rmspcl = 0; /* don't unlink all special files */
+ options.custom = 0; /* don't use a custom byte */
+ options.random = 1; /* perform random passes */
+ options.statics = 0; /* don't preform static passes */
+ options.seclevel = 1; /* fast/secure mode */
+ options.interactive = 0; /* don't confirm each file */
+ options.random_loop = 1; /* one random pass per main loop */
+ options.wipe_multiply = 1; /* perform wipe loop once */
+
+#ifdef SANITY
+ /* sanity checks */
+ if (sizeof(size_t) != sizeof(off_t))
+ {
+ printf("sizeof(size_t) != sizeof(off_t): file offsets are screwed!\n");
+ abort();
+ }
+#endif
+
+ /* set signal handler */
+ rns.valid=0; rns.valid_mode=0;
+ sigact.sa_handler = int_hand;
+ sigemptyset(&sigact.sa_mask);
+ sigact.sa_flags = 0;
+ sigaction(SIGINT, &sigact, 0);
+
+ while ((opt = getopt(argc, argv, "S:C:B:p:b:l::x::XucwsiIhHfFnNdDvVzZrRtTkKaAeEo::O")) != -1)
+ {
+ switch (opt)
+ {
+ case 'B': /* sector count */
+ sscanf(optarg, "%lld", &tmp);
+
+ if (tmp < 1)
+ {
+ fprintf(stderr, "%s: bad option: sector count < 1\n",
+ argvzero);
+ exit(BAD_USAGE);
+ }
+
+ options.sectors = tmp;
+ break;
+
+ case 'S': /* sector size */
+ sscanf(optarg, "%lld", &tmp);
+
+ if (tmp < 1)
+ {
+ fprintf(stderr, "%s: bad option: sector size < 1\n",
+ argvzero);
+ exit(BAD_USAGE);
+ }
+
+ options.sector_size = tmp;
+ break;
+
+ case 'C': /* chunk size -- max buf size */
+ sscanf(optarg, "%lld", &tmp);
+
+ if (tmp < 1)
+ {
+ fprintf(stderr, "%s: bad option: block device buffer size < 1k\n",
+ argvzero);
+ exit(BAD_USAGE);
+ }
+
+ options.chunk_size = tmp << 10;
+ break;
+
+ case 'p': /* wipe multiply */
+ sscanf(optarg, "%lld", &tmp);
+
+ if (tmp < 1)
+ {
+ fprintf(stderr, "%s: bad option: wipe multiply < 1\n",
+ argvzero);
+ exit(BAD_USAGE);
+ }
+
+ if (tmp > 32)
+ {
+ fprintf(stderr, "%s: bad option: wipe multiply > 32\n",
+ argvzero);
+ exit(BAD_USAGE);
+ }
+
+ options.wipe_multiply = tmp;
+ break;
+
+ case 'b': /* overwrite file with byte */
+ sscanf(optarg, "%i", &tmpd);
+
+ if (tmpd < 0)
+ {
+ fprintf(stderr, "%s: bad option: wipe byte < 0\n", argvzero);
+ exit(BAD_USAGE);
+ }
+
+ if (tmpd > 255)
+ {
+ fprintf(stderr, "%s: bad option: wipe byte > 255\n", argvzero);
+ exit(BAD_USAGE);
+ }
+
+ options.custom = 1; options.custom_byte = tmpd;
+ break;
+
+ case 'l': /* set wipe secure level */
+ if (!optarg)
+ options.seclevel = 1;
+ else
+ {
+ sscanf(optarg, "%lld", &tmp);
+
+ if (tmp < 0 || tmp > 2)
+ {
+ fprintf(stderr, "%s: bad option: secure level < 0 or > 2\n",
+ argvzero);
+ exit(BAD_USAGE);
+ }
+
+ options.seclevel = tmp;
+ }
+ break;
+
+ case 'x': /* perform random passes */
+ if (!optarg)
+ options.random = 1;
+ else
+ {
+ tmp = atoi(optarg);
+
+ if (tmp < 0)
+ {
+ fprintf(stderr, "%s: bad option: random loop < 0\n",
+ argvzero);
+ exit(BAD_USAGE);
+ }
+
+ if (tmp > 32)
+ {
+ fprintf(stderr, "%s: bad option: random loop > 32\n",
+ argvzero);
+ exit(BAD_USAGE);
+ }
+
+ if (!tmp)
+ options.random = 0;
+ else
+ options.random_loop = tmp;
+ }
+ break;
+
+ case 'X': /* don't perform random passes */
+ /* random and static passes can't both be disabled */
+ options.random = 0;
+ options.statics = 1;
+ break;
+
+ case 'r': /* recursion */
+ case 'R': /* some people are used to '-R' */
+ options.recursion = 1; /* enable recursion */
+ break;
+
+ case 'i': /* interactive -- disables force */
+ options.force = 0;
+ options.interactive = 1;
+ break;
+
+ case 'I': /* non-interactive */
+ options.interactive = 0;
+ break;
+
+ case 'f': /* force -- ignore permissions and override interaction */
+ options.force = 1;
+ options.interactive = 0;
+ break;
+
+ case 'F': /* disable force */
+ options.force = 0;
+ break;
+
+ case 'n': /* remove special files, except blkdevs */
+ options.rmspcl = 1;
+ break;
+
+ case 'N': /* skip special files */
+ options.rmspcl = 0;
+ break;
+
+ case 'd': /* delete targets */
+ options.delete = 1;
+ break;
+
+ case 'D': /* don't remove targets */
+ options.delete = 0;
+ break;
+
+ case 'c': /* copyright */
+ show_copyright(); exit(0);
+ break;
+
+ case 'w': /* warranty */
+ show_war(); exit(0);
+ break;
+
+ case 'u': /* usage */
+ usage(stdout); exit(0);
+ break;
+
+ case 'h': /* help */
+ case 'H': /* undocumented */
+ help(stdout); exit(0);
+ break;
+
+ case 'v': /* force verbose */
+ if (!options.until_full)
+ options.verbose = 2;
+ break;
+
+ case 'V': /* verbose */
+ if (!options.until_full)
+ options.verbose = 1;
+ break;
+
+ case 's': /* silent */
+ options.verbose = 0;
+ options.interactive = 0;
+ break;
+
+ case 'z': /* zero */
+ options.zero = 1;
+ break;
+
+ case 'Z': /* don't just zero */
+ options.zero = 0;
+ break;
+
+ case 't': /* enable static passes */
+ options.statics = 1;
+ break;
+
+ case 'T': /* disable static passes */
+ options.statics = 0;
+ /* random and static passes can't both be disabled */
+ if (!options.random)
+ options.random = 1;
+ break;
+
+ case 'k': /* enable file locks */
+ options.lock = 1;
+ break;
+
+ case 'K': /* disable file locks */
+ options.lock = 0;
+ break;
+
+ case 'a': /* enable write until full */
+ options.until_full = 1;
+ options.verbose = 0; /* screws up percentage reporting */
+ break;
+
+ case 'A': /* disable write until full */
+ options.until_full = 0;
+ break;
+
+ case 'e': /* fsync before printing percentage */
+ options.percent_sync = 1;
+ break;
+
+ case 'E': /* don't - faster, but more accurate */
+ options.percent_sync = 0;
+ break;
+
+ case 'o': /* write to stdout */
+ if (optarg)
+ {
+ sscanf(optarg, "%lld", &tmp);
+
+ if (tmp < 1)
+ {
+ fprintf(stderr, "%s: bad option: stdout size < 1\n",
+ argvzero);
+ exit(BAD_USAGE);
+ }
+
+ options.stdout_size = tmp;
+ }
+ else
+ options.until_full = 1;
+
+ options.no_file = 1;
+ options.verbose = 0;
+ break;
+
+ case 'O': /* use named files */
+ options.no_file = 0;
+ options.stdout_size = 0;
+ break;
+
+ default:
+ badopt(optopt);
+ break;
+ }
+ }
+
+#ifdef OPTIONTEST
+ printf("options are:\n");
+ printf("sectors = %lld\n", options.sectors);
+ printf("sector_size = %ld\n", options.sector_size);
+ printf("chunk_size = %ld\n", options.chunk_size);
+ printf("stdout_size = %ld\n", options.stdout_size);
+ printf("verbose = %d\n", options.verbose);
+ printf("percent_sync = %d\n", options.percent_sync);
+ printf("recursion = %d\n", options.recursion);
+ printf("until_full = %d\n", options.until_full);
+ printf("stdout = %d\n", options.no_file);
+ printf("zero = %d\n", options.zero);
+ printf("force = %d\n", options.force);
+ printf("delete = %d\n", options.delete);
+ printf("rmspcl = %d\n", options.rmspcl);
+ printf("custom = %d\n", options.custom);
+ printf("custom_byte = 0x%x\n", options.custom_byte);
+ printf("random = %d\n", options.random);
+ printf("statics = %d\n", options.statics);
+ printf("seclevel = %d\n", options.seclevel);
+ printf("interactive = %d\n", options.interactive);
+ printf("random_loop = %d\n", options.random_loop);
+ printf("wipe_multiply = %d\n\n", options.wipe_multiply);
+ abort();
+#endif
+
+#ifdef FILETEST
+ fprintf(stderr, "getopt() parsed %d args\n", optind - 1);
+#endif
+
+ if (optind == argc && !options.no_file)
+ {
+ show_copyright();
+ fprintf(stderr, "\nType \'%s -u\' for usage.\n",
+ argvzero);
+ exit(BAD_USAGE);
+ }
+
+ /* check for bad combinations */
+ if (options.no_file)
+ {
+ if (options.statics && !options.stdout_size &&
+ !(options.zero || options.custom_byte))
+ {
+ fprintf(stderr, "%s: bad option: "
+ "you must give a stdout length for static passes\n",
+ argvzero);
+ exit(BAD_USAGE);
+ }
+ }
+
+ if (rand_init())
+ {
+ fprintf(stderr, "\r%s: rand_init(): fatal error\n", argvzero);
+ exit(exit_code);
+ }
+
+ if (!options.no_file)
+ /* check access and wipe if ok */
+ while (optind < argc) do_file(argv[optind++]); /*** parse files ***/
+ else
+ do_file("stdout"); /*** write to stdout ***/
+
+#ifdef FILETEST
+ fprintf(stderr, "\n");
+#endif
+
+ percent_shutdown();
+
+ return exit_code;
+}
diff --git a/main.h b/main.h
new file mode 100644
index 0000000..4b0a448
--- /dev/null
+++ b/main.h
@@ -0,0 +1,70 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <string.h>
+#include <limits.h>
+
+#include "config.h"
+
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+/* elif, might be defined somewhere else, but every *nix should have mode_t */
+
+/* command line options */
+struct opt_s
+{
+ unsigned long long sectors; /* block device sector count */
+ size_t sector_size; /* sector size */
+ size_t chunk_size; /* how big bufsize should be */
+ size_t stdout_size; /* stdout write length */
+ unsigned char custom_byte; /* custom overwrite byte */
+ unsigned int verbose:2; /* verbose level */
+ unsigned int percent_sync:1; /* call fsync before printing progress */
+ unsigned int recursion:1; /* traverse directories */
+ unsigned int until_full:1; /* write until out of space */
+ unsigned int no_file:1; /* write to stdout */
+ unsigned int zero:1; /* zero-out file */
+ unsigned int lock:1; /* lock files */
+ unsigned int force:1; /* force wipes -- override interaction */
+ unsigned int delete:1; /* remove targets */
+ unsigned int rmspcl:1; /* remove special files (except blkdevs) */
+ unsigned int custom:1; /* wipe file with user specified byte */
+ unsigned int random:1; /* perform random passes */
+ unsigned int statics:1; /* perform static passes */
+ unsigned int seclevel:2; /* secure level */
+ unsigned int interactive:1; /* prompt for each file */
+ unsigned int random_loop:6; /* how many times to loop the random passes */
+ unsigned int wipe_multiply:6; /* how many times to loop all 35 passes */
+};
+
+struct rename_s
+{
+ unsigned int valid:1, valid_mode:1;
+ char orig_name[PATH_MAX+1],
+ cur_name[PATH_MAX+1];
+ mode_t mode;
+};
+
+public void int_hand(int sig);
+public void restore_file(void);
+public int main(int argc, char **argv);
diff --git a/mt.c b/mt.c
new file mode 100644
index 0000000..9f8ec28
--- /dev/null
+++ b/mt.c
@@ -0,0 +1,183 @@
+// This is the ``Mersenne Twister'' random number generator MT19937, which
+// generates pseudorandom integers uniformly distributed in 0..(2^32 - 1)
+// starting from any odd seed in 0..(2^32 - 1). This version is a recode
+// by Shawn Cokus (Cokus@math.washington.edu) on March 8, 1998 of a version by
+// Takuji Nishimura (who had suggestions from Topher Cooper and Marc Rieffel in
+// July-August 1997).
+//
+// Effectiveness of the recoding (on Goedel2.math.washington.edu, a DEC Alpha
+// running OSF/1) using GCC -O3 as a compiler: before recoding: 51.6 sec. to
+// generate 300 million random numbers; after recoding: 24.0 sec. for the same
+// (i.e., 46.5% of original time), so speed is now about 12.5 million random
+// number generations per second on this machine.
+//
+// According to the URL <http://www.math.keio.ac.jp/~matumoto/emt.html>
+// (and paraphrasing a bit in places), the Mersenne Twister is ``designed
+// with consideration of the flaws of various existing generators,'' has
+// a period of 2^19937 - 1, gives a sequence that is 623-dimensionally
+// equidistributed, and ``has passed many stringent tests, including the
+// die-hard test of G. Marsaglia and the load test of P. Hellekalek and
+// S. Wegenkittl.'' It is efficient in memory usage (typically using 2506
+// to 5012 bytes of static data, depending on data type sizes, and the code
+// is quite short as well). It generates random numbers in batches of 624
+// at a time, so the caching and pipelining of modern systems is exploited.
+// It is also divide- and mod-free.
+//
+// This library is free software; you can redistribute it and/or modify it
+// under the terms of the GNU Library General Public License as published by
+// the Free Software Foundation (either version 2 of the License or, at your
+// option, any later version). This library 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 Library General Public License for more details. You should have
+// received a copy of the GNU Library General Public License along with this
+// library; if not, write to the Free Software Foundation, Inc., 59 Temple
+// Place, Suite 330, Boston, MA 02111-1307, USA.
+//
+// The code as Shawn received it included the following notice:
+//
+// Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura. When
+// you use this, send an e-mail to <matumoto@math.keio.ac.jp> with
+// an appropriate reference to your work.
+//
+// It would be nice to CC: <Cokus@math.washington.edu> when you write.
+//
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+#include "config.h"
+#include "std.h"
+#include "rand.h"
+
+//
+// u_rand_t must be an unsigned integer type capable of holding at least 32
+// bits; exactly 32 should be fastest, but 64 is better on an Alpha with
+// GCC at -O3 optimization so try your options and see what's best for you
+
+#define N (624) // length of state vector
+#define M (397) // a period parameter
+#define K (0x9908B0DFU) // a magic constant
+#define hiBit(u) ((u) & 0x80000000U) // mask all but highest bit of u
+#define loBit(u) ((u) & 0x00000001U) // mask all but lowest bit of u
+#define loBits(u) ((u) & 0x7FFFFFFFU) // mask the highest bit of u
+#define mixBits(u, v) (hiBit(u)|loBits(v)) // move hi bit of u to hi bit of v
+
+static u_rand_t state[N+1]; // state vector + 1 extra to not violate ANSI C
+static u_rand_t *next; // next random value is computed from here
+static int left = -1; // can *next++ this many times before reloading
+
+private inline u_rand_t reloadMT(void);
+
+public void seedMT(u_rand_t seed)
+ {
+ //
+ // We initialize state[0..(N-1)] via the generator
+ //
+ // x_new = (69069 * x_old) mod 2^32
+ //
+ // from Line 15 of Table 1, p. 106, Sec. 3.3.4 of Knuth's
+ // _The Art of Computer Programming_, Volume 2, 3rd ed.
+ //
+ // Notes (SJC): I do not know what the initial state requirements
+ // of the Mersenne Twister are, but it seems this seeding generator
+ // could be better. It achieves the maximum period for its modulus
+ // (2^30) iff x_initial is odd (p. 20-21, Sec. 3.2.1.2, Knuth); if
+ // x_initial can be even, you have sequences like 0, 0, 0, ...;
+ // 2^31, 2^31, 2^31, ...; 2^30, 2^30, 2^30, ...; 2^29, 2^29 + 2^31,
+ // 2^29, 2^29 + 2^31, ..., etc. so I force seed to be odd below.
+ //
+ // Even if x_initial is odd, if x_initial is 1 mod 4 then
+ //
+ // the lowest bit of x is always 1,
+ // the next-to-lowest bit of x is always 0,
+ // the 2nd-from-lowest bit of x alternates ... 0 1 0 1 0 1 0 1 ... ,
+ // the 3rd-from-lowest bit of x 4-cycles ... 0 1 1 0 0 1 1 0 ... ,
+ // the 4th-from-lowest bit of x has the 8-cycle ... 0 0 0 1 1 1 1 0 ... ,
+ // ...
+ //
+ // and if x_initial is 3 mod 4 then
+ //
+ // the lowest bit of x is always 1,
+ // the next-to-lowest bit of x is always 1,
+ // the 2nd-from-lowest bit of x alternates ... 0 1 0 1 0 1 0 1 ... ,
+ // the 3rd-from-lowest bit of x 4-cycles ... 0 0 1 1 0 0 1 1 ... ,
+ // the 4th-from-lowest bit of x has the 8-cycle ... 0 0 1 1 1 1 0 0 ... ,
+ // ...
+ //
+ // The generator's potency (min. s>=0 with (69069-1)^s = 0 mod 2^32) is
+ // 16, which seems to be alright by p. 25, Sec. 3.2.1.3 of Knuth. It
+ // also does well in the dimension 2..5 spectral tests, but it could be
+ // better in dimension 6 (Line 15, Table 1, p. 106, Sec. 3.3.4, Knuth).
+ //
+ // Note that the random number user does not see the values generated
+ // here directly since reloadMT() will always munge them first, so maybe
+ // none of all of this matters. In fact, the seed values made here could
+ // even be extra-special desirable if the Mersenne Twister theory says
+ // so-- that's why the only change I made is to restrict to odd seeds.
+ //
+
+ register u_rand_t x = (seed | 1U) & 0xFFFFFFFFU, *s = state;
+ register int j;
+
+ for(left=0, *s++=x, j=N; --j;
+ *s++ = (x*=69069U) & 0xFFFFFFFFU);
+ }
+
+
+private inline u_rand_t reloadMT(void)
+ {
+ register u_rand_t *p0=state, *p2=state+2, *pM=state+M, s0, s1;
+ register int j;
+
+ if(left < -1)
+ seedMT(4357U);
+
+ left=N-1, next=state+1;
+
+ for(s0=state[0], s1=state[1], j=N-M+1; --j; s0=s1, s1=*p2++)
+ *p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
+
+ for(pM=state, j=M; --j; s0=s1, s1=*p2++)
+ *p0++ = *pM++ ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
+
+ s1=state[0], *p0 = *pM ^ (mixBits(s0, s1) >> 1) ^ (loBit(s1) ? K : 0U);
+ s1 ^= (s1 >> 11);
+ s1 ^= (s1 << 7) & 0x9D2C5680U;
+ s1 ^= (s1 << 15) & 0xEFC60000U;
+ return(s1 ^ (s1 >> 18));
+ }
+
+
+public u_rand_t randomMT(void)
+ {
+ u_rand_t y;
+
+ if(--left < 0)
+ return(reloadMT());
+
+ y = *next++;
+ y ^= (y >> 11);
+ y ^= (y << 7) & 0x9D2C5680U;
+ y ^= (y << 15) & 0xEFC60000U;
+ return(y ^ (y >> 18));
+ }
+
+/*
+int main(void)
+ {
+ int j;
+
+ // you can seed with any u_rand_t, but the best are odds in 0..(2^32 - 1)
+
+ seedMT(4357U);
+
+ // print the first 2,002 random numbers seven to a line as an example
+
+ for(j=0; j<2002; j++)
+ printf(" %10lu%s", (u_rand_t) randomMT(), (j%7)==6 ? "\n" : "");
+
+ return(EXIT_SUCCESS);
+ }
+*/
diff --git a/mt.h b/mt.h
new file mode 100644
index 0000000..877681c
--- /dev/null
+++ b/mt.h
@@ -0,0 +1,4 @@
+/* ANSI proto header for mt.c */
+
+public void seedMT(unsigned long seed);
+public unsigned long randomMT(void);
diff --git a/percent.c b/percent.c
new file mode 100644
index 0000000..9364ff8
--- /dev/null
+++ b/percent.c
@@ -0,0 +1,201 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "config.h"
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+/* assume either ioctl.h or termio.h has struct winsize */
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+# define HAVE_WINSIZE
+#endif
+#if HAVE_TERMIO_H
+# include <termio.h>
+# define HAVE_WINSIZE
+#endif
+#if HAVE_TERMIOS_H
+# include <termios.h>
+# define HAVE_WINSIZE
+#endif
+
+#define __USE_GNU
+#include <string.h>
+
+#include "std.h"
+#include "main.h"
+#include "percent.h"
+#include "file.h"
+#include "str.h"
+
+extern struct opt_s options;
+
+short p_reported;
+size_t oldpathlen, lastpathlen, lastpathlen;
+
+private void percent_line_clear(struct percent_s *p);
+
+/*
+ percent_init -- initialize percent data
+*/
+
+public void percent_init(struct percent_s *p, const char *name, const size_t bufsize, const long int loop)
+{
+ unsigned short scrwid = DEFAULT_SWIDTH;
+#ifdef HAVE_WINSIZE
+ struct winsize ws;
+#endif
+
+ p->display = 0;
+ p->total_passes = 0;
+
+ if (options.no_file)
+ return;
+
+ if ((options.verbose == 1 && bufsize >= PERCENT_ENABLE_SIZE)
+ || options.verbose == 2)
+ p->display = 1; /* enable percentage reporting */
+
+#ifdef HAVE_WINSIZE
+ if (ioctl(1, TIOCGWINSZ, &ws))
+ {/* didn't work */}
+ else
+ scrwid = ws.ws_col;
+#endif
+
+ p->cur_pass = 0;
+ p->name = (char *) name;
+ p->nlen = strnlen(name, PATH_MAX);
+
+ /* length of ": 100% " is 7 */
+ if (p->nlen + 7 > scrwid)
+ {
+ /* truncate to fit screen */
+ p->nlen = (scrwid - 10) + 3;
+ strncpy(p->name + p->nlen-4, "...", scrwid);
+ p->name[p->nlen-1] = 0;
+ }
+
+ if (options.statics) p->total_passes = STATIC_PASSES;
+
+ if (!(options.zero || options.custom))
+ {
+ if (options.random)
+ p->total_passes += options.random_loop; // correct? two rand loops per wipe
+
+ p->total_passes *= options.wipe_multiply;
+ }
+ else
+ p->total_passes = 1;
+
+ /* percent_update() should be called after each loop */
+ if (loop)
+ p->total_passes *= loop;
+
+ if (p->display)
+ {
+ percent_line_clear(p);
+ printf(" \r%s: 0%%", p->name); fflush(stdout); /* display */
+ }
+}
+
+/*
+ percent_line_clear -- clear line
+*/
+
+private void percent_line_clear(struct percent_s *p)
+{
+ char spaces[PATH_MAX+1];
+
+ if (oldpathlen)
+ {
+ //printf("pathlen == %d\noldpathlen == %d\n", strnlen(pathname, PATH_MAX), oldpathlen);
+ memset(spaces, (char) 0x20, oldpathlen);
+
+ spaces[oldpathlen-1] = (char) 0x00;
+ printf("\r%s \r", spaces);
+ }
+
+ oldpathlen = p->nlen;
+}
+
+/*
+ percent_update -- update and display progress
+*/
+
+public void percent_update(struct percent_s *p)
+{
+ int percent;
+
+ percent = (int)(((float) ++p->cur_pass / (float) p->total_passes) * 100);
+
+ printf(" \r%s: %d%%", p->name, percent); fflush(stdout);
+}
+
+/*
+ percent_done -- called between percent_init()s after reporting
+*/
+
+public void percent_done(struct percent_s *p)
+{
+ fflush(stdout);
+ lastpathlen = p->nlen;
+
+ if (!p->display)
+ {p->reported = 0; return;}
+ else
+ {
+ p_reported = 1;
+ printf("\n"); fflush(stdout);
+ }
+}
+
+/*
+ percent_shutdown -- called by main(), after last percentage report
+
+ this is obsolete, since we print a new line after each item now
+*/
+
+public void percent_shutdown(void)
+{
+ char spaces[PATH_MAX+1];
+
+#ifdef SANITY
+ /* can be triggered, eg by lstat() failure when options.verbose > 0 */
+ if (options.verbose && p_reported == 0)
+ {
+ fprintf(stderr, "\nwarning: p_reported == %d\n", p_reported);
+ }
+#endif
+
+ if (p_reported)
+ {
+ //printf("pathlen == %d\noldpathlen == %d\n", strnlen(pathname, PATH_MAX), oldpathlen);
+ memset(spaces, (char) 0x20, lastpathlen);
+
+ spaces[lastpathlen-1] = (char) 0x00;
+ printf("\r%s \r", spaces);
+ }
+}
diff --git a/percent.h b/percent.h
new file mode 100644
index 0000000..a22e1cb
--- /dev/null
+++ b/percent.h
@@ -0,0 +1,40 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2003 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#define STATIC_PASSES 27
+#define DEFAULT_SWIDTH 78
+
+/* percent data */
+struct percent_s
+{
+ char *name; /* pointer to f->name */
+ size_t nlen; /* length of string pointed to by name */
+ int cur_pass; /* current pass */
+ int total_passes; /* per file */
+ unsigned int display:1; /* show percentage */
+ unsigned int reported:1; /* set if percentage was reported */
+};
+
+public void percent_init(struct percent_s *p, const char *name, const size_t bufsize, const long int loop);
+public void percent_update(struct percent_s *p);
+public void percent_done(struct percent_s *p);
+public void percent_shutdown(void);
diff --git a/prompt.c b/prompt.c
new file mode 100644
index 0000000..9d099c7
--- /dev/null
+++ b/prompt.c
@@ -0,0 +1,279 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "config.h"
+
+#include <errno.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+
+#ifdef STAT_MACROS_BROKEN
+/* just in case, so we don't unlink a directory,
+ we don't currently handle broken stat macros */
+# define unlink(x) remove(x)
+#endif
+
+#ifndef HAVE_UNLINK
+# define unlink(x) remove(x)
+#endif
+
+#include "std.h"
+#include "percent.h"
+#include "file.h"
+#include "dir.h"
+#include "main.h"
+#include "wipe.h"
+#include "blkdev.h"
+#include "prompt.h"
+
+extern char *argvzero;
+extern struct opt_s options;
+
+/*
+ prompt_destroy -- prompt user before destroying target
+*/
+
+public void prompt_destroy(struct file_s *f, const int perm)
+{
+ int permdenied;
+ char prompt[4];
+
+#ifdef SANITY
+ if (!S_ISBLK(f->st.st_mode) && !S_ISREG(f->st.st_mode))
+ {
+ fprintf(stderr, "\r%s: prompt_destroy: not a file or block dev, `%s' mode %o\n",
+ argvzero, f->name, f->st.st_mode);
+ abort();
+ }
+#endif
+
+ if (options.force) goto destroy;
+
+ permdenied = access(f->name, perm);
+ if (options.interactive) /* force overrides interaction */
+ {
+ prompt[0] = 0; /* clear prompt */
+
+ if (!permdenied)
+ {
+ while (1)
+ {
+ switch (f->st.st_mode & S_IFMT)
+ {
+ case S_IFBLK:
+ printf("\r%s: destroy block device `%s'? ", argvzero, f->name);
+ break;
+ case S_IFCHR:
+ printf("\r%s: destory character device `%s'? ", argvzero, f->name);
+ break;
+ default:
+ printf("\r%s: destroy file `%s'? ", argvzero, f->name);
+ break;
+ }
+
+ fgets(prompt, sizeof(prompt), stdin);
+
+ if (prompt[0] == 'y' || prompt[0] == 'Y') goto destroy;
+ if (prompt[0] == 'n' || prompt[0] == 'N') return;
+ }
+ }
+ else /* perm denied */
+ {
+ while (1)
+ {
+ switch (f->st.st_mode & S_IFMT)
+ {
+ case S_IFBLK:
+ printf("\r%s: destroy block device `%s', "
+ "overriding mode %04o? ",
+ argvzero, f->name, (unsigned int) f->st.st_mode & 07777);
+ break;
+ default:
+ printf("\r%s: destroy file `%s', "
+ "overriding mode %04o? ",
+ argvzero, f->name, (unsigned int) f->st.st_mode & 07777);
+ break;
+ }
+
+ fgets(prompt, sizeof(prompt), stdin);
+
+ if (prompt[0] == 'y' || prompt[0] == 'Y') goto destroy;
+ if (prompt[0] == 'n' || prompt[0] == 'N') return;
+ }
+ }
+ }
+
+ destroy:
+ switch (f->st.st_mode & S_IFMT)
+ {
+ case S_IFBLK:
+ options.delete = 0;
+ destroy_blkdev(f); return;
+ break;
+
+ case S_IFCHR:
+ options.delete = 0;
+ destroy_file(f); return;
+ break;
+
+ case S_IFREG:
+ destroy_file(f); return;
+ break;
+
+ default:
+ abort();
+ }
+}
+
+/*
+ prompt_unlink -- prompt for removal of non-wiped files
+*/
+
+public void prompt_unlink(const char name[], const char type[], const int perm, const mode_t mode)
+{
+ int permdenied;
+ char prompt[4];
+
+ if (!options.delete) return;
+
+ if (!options.rmspcl)
+ {
+ if (options.verbose)
+ fprintf(stderr, "\r%s: `%s' is a %s -- skipping unlink\n", argvzero, name, type);
+ return;
+ }
+
+ if (options.force) goto unlink;
+
+ permdenied = access(name, perm);
+
+ if (options.interactive)
+ {
+ prompt[0] = 0; /* clear prompt */
+
+ if (!permdenied)
+ {
+ while (1)
+ {
+ printf("\r%s: remove %s `%s'? ",
+ argvzero, type, name);
+
+ fgets(prompt, sizeof(prompt), stdin);
+
+ if (prompt[0] == 'y' || prompt[0] == 'Y') goto unlink;
+ if (prompt[0] == 'n' || prompt[0] == 'N') return; /* skip to next file */
+ }
+ }
+ else /* permdenied */
+ {
+ while (1)
+ {
+ printf("\r%s: remove %s `%s', "
+ "overriding mode %04o? ",
+ argvzero, type, name, (unsigned int) mode & 07777);
+
+ fgets(prompt, sizeof(prompt), stdin);
+
+ if (prompt[0] == 'y' || prompt[0] == 'Y') goto unlink;
+ if (prompt[0] == 'n' || prompt[0] == 'N') return;
+ }
+ }
+ }
+
+ unlink:
+ if (unlink(name))
+ {
+ if (options.verbose)
+ {
+ fprintf(stderr, "\r%s: cannot remove %s `%s': %s\n",
+ argvzero, type, name, strerror(errno));
+ }
+ }
+}
+
+/*
+ prompt_recursion -- prompt for directory recursion
+*/
+
+public void prompt_recursion(const char name[], const int perm, const mode_t mode)
+{
+ int permdenied;
+ char prompt[4];
+
+ if (!options.recursion)
+ {
+ fprintf(stderr, "\r%s: `%s' is a directory -- skipping\n", argvzero, name);
+ return;
+ }
+
+#ifdef SANITY
+ if (!S_ISDIR(mode))
+ {
+ fprintf(stderr, "\r%s: prompt_recursion: not a directory, `%s' mode %o\n",
+ argvzero, name, mode);
+ abort();
+ }
+#endif
+
+ if (options.force) goto recurse;
+
+ permdenied = access(name, perm);
+
+ if (options.interactive)
+ {
+ prompt[0] = 0; /* clear prompt */
+
+ if (!permdenied)
+ {
+ while (1)
+ {
+ printf("\r%s: destroy files in `%s'? ",
+ argvzero, name);
+
+ fgets(prompt, sizeof(prompt), stdin);
+
+ if (prompt[0] == 'y' || prompt[0] == 'Y') goto recurse;
+ if (prompt[0] == 'n' || prompt[0] == 'N') return; /* skip to next file */
+ }
+ }
+ else /* permdenied */
+ {
+ while (1)
+ {
+ printf("\r%s: remove files in `%s', "
+ "overriding mode %04o? ",
+ argvzero, name, (unsigned int) mode & 07777);
+
+ fgets(prompt, sizeof(prompt), stdin);
+
+ if (prompt[0] == 'y' || prompt[0] == 'Y') goto recurse;
+ if (prompt[0] == 'n' || prompt[0] == 'N') return;
+ }
+ }
+ }
+
+ recurse:
+ drill_down(name);
+}
diff --git a/prompt.h b/prompt.h
new file mode 100644
index 0000000..7126f03
--- /dev/null
+++ b/prompt.h
@@ -0,0 +1,25 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2001 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+public void prompt_destroy(struct file_s *f, const int perm);
+public void prompt_unlink(const char name[], const char type[], const int perm, const mode_t mode);
+public void prompt_recursion(const char name[], const int perm, const mode_t mode);
diff --git a/rand.c b/rand.c
new file mode 100644
index 0000000..1542bc3
--- /dev/null
+++ b/rand.c
@@ -0,0 +1,134 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "config.h"
+#include "std.h"
+#include "io.h"
+#include "mt.h"
+#include "main.h"
+#include "rand.h"
+
+extern char *argvzero;
+extern int errno, exit_code;
+extern struct opt_s options;
+
+int entropyfd;
+char entropy_name[13]; /* for do_read error reporting */
+
+/*
+ rand_init -- inits the entropy source file descriptor
+*/
+
+public int rand_init(void)
+{
+ /* try /dev/urandom first; if that fails, try /dev/random */
+ if ((entropyfd = open("/dev/urandom", O_RDONLY)) < 0)
+ {
+ if ((entropyfd = open("/dev/random", O_RDONLY)) < 0)
+ {
+ fprintf(stderr, "\r%s: cannot open entropy source: %s\n",
+ argvzero, strerror(errno));
+ exit(1);
+ }
+ else
+ {
+ strncpy(entropy_name, "/dev/random", sizeof(entropy_name));
+ fprintf(stderr, "\r%s: warning: cannot open /dev/urandom, "
+ "using /dev/random instead\n", argvzero);
+ }
+ }
+ else
+ strncpy(entropy_name, "/dev/urandom", sizeof(entropy_name));
+
+ /* we must seed once at least regardless of seclevel --tg */
+ if (prng_seed())
+ return FAILED;
+
+ return 0;
+}
+
+/*** the following functions are PRNG dependent ***/
+
+/*
+ prng_seed -- init seed
+*/
+
+public int prng_seed(void)
+{
+ u_rand_t seed;
+
+ if (do_read(entropy_name, entropyfd, &seed, sizeof(prng_seed)))
+ return FAILED;
+
+ seedMT(seed);
+ return 0;
+}
+
+/*
+ prng_get_rand -- return u_rand_t PRN
+*/
+
+public u_rand_t prng_get_rand(void)
+{
+ return randomMT();
+}
+
+/*
+ prng_fillbuf -- fills a buffer with pseudo-random values
+ the buffer must be u_rand_t aligned
+*/
+
+public void prng_fillbuf(const int seclevel, u_rand_t *buf, const size_t size)
+{
+ int i, ii;
+ u_rand_t rand;
+ unsigned char *cbuf, *randp;
+
+ i=0; ii = size / sizeof(u_rand_t);
+
+ while (i < ii)
+ buf[i++] = randomMT();
+
+ ii = size % sizeof(u_rand_t);
+
+ if (ii)
+ {
+ rand = randomMT();
+ cbuf = (unsigned char *) ((void *) buf + (size - ii));
+ randp = (unsigned char *) &rand;
+
+ i=0;
+ while (i < ii)
+ {
+ cbuf[i] = randp[i];
+ i++;
+ }
+ }
+}
diff --git a/rand.h b/rand.h
new file mode 100644
index 0000000..bc48674
--- /dev/null
+++ b/rand.h
@@ -0,0 +1,42 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2003 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifdef HAVE_STDINT_H
+# include "stdint.h"
+#else
+# ifndef LINUX
+# define u_int32_t uint32_t
+# endif
+#endif
+
+typedef u_int32_t u_rand_t;
+
+#ifndef UINT32_MAX
+# define UINT32_MAX ULONG_MAX
+#endif
+
+#define URAND_MAX UINT32_MAX
+
+public int rand_init(void);
+public int prng_seed(void);
+public u_rand_t prng_get_rand(void);
+public void prng_fillbuf(const int seclevel, u_rand_t *buf, size_t size);
diff --git a/require.h b/require.h
new file mode 100644
index 0000000..c49f2d1
--- /dev/null
+++ b/require.h
@@ -0,0 +1,58 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/* minimum requirements for wipe */
+#ifndef HAVE_GETOPT
+# error missing function: getopt() required
+#endif
+
+#ifndef HAVE_MEMSET
+# error missing function: memset() required
+#endif
+
+#ifndef HAVE_UNLINK
+# ifndef HAVE_REMOVE
+# error missing function: unlink() or remove() required
+# endif
+#endif
+
+#ifndef HAVE_RMDIR
+# ifndef HAVE_REMOVE
+# error missing function: rmdir() or remove() required
+# endif
+#endif
+
+#ifndef HAVE_UNLINK
+# ifndef HAVE_REMOVE
+# error missing function: unlink() or remove() required
+# endif
+#endif
+
+#ifndef HAVE_RENAME
+# error missing functions: rename() required
+#endif
+
+#ifndef HAVE_FSYNC
+# ifndef O_SYNC
+# error fsync() or O_SYNC required
+# endif
+#endif
diff --git a/std.h b/std.h
new file mode 100644
index 0000000..8457cf7
--- /dev/null
+++ b/std.h
@@ -0,0 +1,40 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2001 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#define public extern
+#define private static
+
+#include "debug.h"
+
+/* exit codes */
+#define SUCCESS 0
+#define FAILED -1
+#define BAD_USAGE 2
+
+/* 25K */
+#define PERCENT_ENABLE_SIZE (25 << 10)
+
+/* default sector size */
+#define SECTOR_SIZE 512
+
+/* default buffer size -- 4MB */
+#define CHUNK_SIZE (4 << 20)
diff --git a/str.c b/str.c
new file mode 100644
index 0000000..3d2f216
--- /dev/null
+++ b/str.c
@@ -0,0 +1,93 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2003 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "config.h"
+
+#include <sys/types.h>
+#include <limits.h>
+#include <string.h>
+
+#include "std.h"
+#include "rand.h"
+#include "str.h"
+
+private char rand_safe_char(void);
+
+/*
+ strnlen -- glibc strnlen() emulator
+*/
+
+#ifndef HAVE_STRNLEN
+public size_t strnlen(const char *str, const size_t maxlen)
+{
+ size_t len;
+
+ len = strlen(str);
+ if (len > maxlen) len = maxlen;
+
+ return len;
+}
+#endif
+
+/*
+ rename_str -- fill a string with random chars
+*/
+
+public void rename_str(char str[], const size_t len)
+{
+ int i;
+
+ i=0;
+ while (i <= (len-2))
+ str[i++] = rand_safe_char();
+
+ str[len-1] = 0;
+}
+
+/*
+ rand_safe_char -- return a safe low-ASCII char
+*/
+
+private char rand_safe_char(void)
+{
+ int i;
+
+ /* Colin Plumb's string - taken from his program, sterilize */
+ /* Possible file name characters - a very safe set. */
+ const char nameset[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_+=%@#.";
+
+ /*
+ see the man page for rand(3) for more info on this algorithm.
+
+ it was originally adapted from:
+
+ Numerical Recipes in C: The Art of Scientific Computing
+ (William H. Press, Brian P. Flannery, Saul A. Teukolsky,
+ William T. Vetterling; New York: Cambridge University
+ Press, 1990 (1st ed, p. 207))
+ */
+
+ /* now pick a random char from nameset */
+ i = (int) ((float) (sizeof(nameset) - 1.0) * prng_get_rand() / (URAND_MAX+1.0));
+
+ return nameset[i];
+}
diff --git a/str.h b/str.h
new file mode 100644
index 0000000..08443f2
--- /dev/null
+++ b/str.h
@@ -0,0 +1,27 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2001 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef HAVE_STRNLEN
+public size_t strnlen(const char *str, const size_t maxlen);
+#endif
+
+public void rename_str(char str[], const size_t len);
diff --git a/text.c b/text.c
new file mode 100644
index 0000000..4495198
--- /dev/null
+++ b/text.c
@@ -0,0 +1,159 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <stdio.h>
+#include "version.h"
+
+#include "std.h"
+#include "main.h"
+#include "text.h"
+
+extern char *argvzero;
+
+const char version[] = VERSION;
+const char email[] = EMAIL;
+const char copyright[] = COPYRIGHT;
+const char reldate[] = RELEASE_DATE;
+
+/*
+ help -- prints extented help
+*/
+
+public void help(FILE *out)
+{
+
+ fprintf(out, ""
+ "Wipe v%s - released %s\n"
+ "by Tom Vier <%s>\n\n"
+
+ "Usage is %s [options] [file-list]\n\n"
+
+ "Options: Default: %s -ZdNTVEAkO -S512 -C%d -l1 -x1 -p1\n\n"
+
+ "-h -- help - display this screen\n"
+ "-u -- usage\n"
+ "-c -- show copyright and license\n"
+ "-w -- show warranty information\n"
+ "-i and -I -- enable (-i) or disable (-I) interaction - overrides force\n"
+ "-f -- force file wiping and override interaction\n"
+ "-r and -R -- recursion - traverse subdirectories\n"
+ "-s -- silent - disable percentage and error reporting\n"
+ "-v -- force verbose - always show percentage\n"
+ "-V -- verbose - show percentage if file is >= %dK\n"
+ "-e and -E -- enhance (-e) percentage accuracy or faster writes (-E)\n"
+ "-d and -D -- delete (-d) or keep (-D) after wiping\n"
+ "-n and -N -- delete (-n) or skip (-N) special files\n"
+ "-k and -K -- lock (-k) or don't lock (-K) files\n"
+ "-z -- zero-out file - single pass of zeroes\n"
+ "-Z -- perform normal wipe passes\n"
+ "-t and -T -- enable (-t) or disable (-T) static passes\n"
+ "-a and -A -- write until out of space (-a) or don't (-A)\n"
+ "-o[size] -O -- write to stdout (-o) or use files (-O)\n"
+ "-B(count) -- block device sector count\n"
+ "-S(size) -- block device sector size - default 512 bytes\n"
+ " or stdout write length when used with -A\n"
+ "-C(size) -- chunk size - maximum file buffer size in kilobytes (2^10)\n"
+ "-l[0-2] -- sets wipe secure level\n"
+ "-x[1-32] -X -- sets number of random passes per wipe or disables\n"
+ "-p(1-32) -- wipe file x number of times\n"
+ "-b(0-255) -- overwrite file with this value byte\n"
+ "", version, reldate, email, argvzero, argvzero,
+ (CHUNK_SIZE >> 10), (PERCENT_ENABLE_SIZE >> 10));
+}
+
+/*
+ badopt -- prints bad option error
+*/
+
+public void badopt(const int c)
+{
+ fprintf(stderr, ""
+ "error: bad option: %c\n"
+ "Type \'%s -h\' for help.\n"
+ "", c, argvzero);
+}
+
+/*
+ usage -- prints usage info
+*/
+
+public void usage(FILE *out)
+{
+ fprintf(out, ""
+ "Wipe v%s - released %s\n"
+ "by Tom Vier <%s>\n\n"
+ "", version, reldate, email);
+
+ fprintf(out, ""
+ "default: "
+ "%s -ZdNTVEAkO -S512 -C%d -l1 -x1 -p1\n\n"
+
+ "usage: "
+ "%s [-ucwsiIhfFdDnNvVzZrRtTkKaAeE] "
+ "[-B(count)] [-S(size)] [-C(size)] [-l[0-2]] [-x[1-32] -X] "
+ "[-p(1-32)] [-b(0-255)] [-o[size] -O] [files]\n"
+ "", argvzero, (CHUNK_SIZE >> 10), argvzero);
+}
+
+/*
+ show_copyright -- shows copyright info from version.h
+*/
+
+public void show_copyright(void)
+{
+ printf(""
+ "Wipe v%s - released %s\nby Tom Vier <%s>\n\n"
+ "%s\n\n"
+
+ "Wipe homepage: %s\n"
+ "Freshmeat Appindex: %s\n\n"
+
+ "Licensed under the GNU Public License.\n"
+ "Wipe comes with ABSOLUTELY NO WARRANTY; for details type \"%s -w\".\n"
+ "", version, reldate, email, copyright, URL, FRESHMEAT, argvzero);
+}
+
+/*
+ show_war -- shows lack of warranty
+*/
+
+public void show_war(void)
+{
+ printf(""
+ "Wipe v%s - released %s\n\n"
+ "%s\n\n"
+
+ "This program is free software; you can redistribute it and/or modify\n"
+ "it under the terms of the GNU General Public License as published by\n"
+ "the Free Software Foundation; either version 2 of the License, or\n"
+ "(at your option) any later version.\n\n"
+
+ "This program is distributed in the hope that it will be useful,\n"
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
+ "GNU General Public License for more details.\n\n"
+
+ "You should have received a copy of the GNU General Public License\n"
+ "along with this program; if not, write to the Free Software\n"
+ "Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\n"
+ "", version, reldate, copyright);
+}
diff --git a/text.h b/text.h
new file mode 100644
index 0000000..44be12e
--- /dev/null
+++ b/text.h
@@ -0,0 +1,27 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2001 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+public void help(FILE *out);
+public void badopt(const int c);
+public void usage(FILE *out);
+public void show_copyright(void);
+public void show_war(void);
diff --git a/version.h b/version.h
new file mode 100644
index 0000000..7c2619c
--- /dev/null
+++ b/version.h
@@ -0,0 +1,30 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#define VERSION "2.3.1"
+#define COPYRIGHT "Copyright (C) 1998-2009 Thomas M. Vier, Jr. All Rights Reserved.\nMersenne Twister Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura"
+#define RELEASE_DATE "November 1st, 2009"
+
+#define EMAIL "nester@users.sf.net"
+
+#define URL "http://wipe.sf.net/"
+#define FRESHMEAT "http://freshmeat.net/projects/ya-wipe/"
diff --git a/wipe.1 b/wipe.1
new file mode 100644
index 0000000..78beb7a
--- /dev/null
+++ b/wipe.1
@@ -0,0 +1,230 @@
+.TH WIPE 1
+
+.SH NAME
+wipe \- secure file deletion utility
+
+.SH SYNOPSIS
+.B wipe
+
+[\-ucwsiIhfFdDnNvVzZrRtTkKaAeE] [\-B(count)] [\-S(size)] [\-C(size)]
+[\-o[size] \-O] [\-l[0\-2]] [\-x[1\-32] \-X] [\-p(1\-32)] [\-b(0\-255)] [files]
+
+.SH DEFAULT
+.B wipe
+\-ZdNTVEAkO \-S512 \-C4096 \-l1 \-x1 \-p1
+
+.SH DESCRIPTION
+Wipe is a secure file wiping utility. There are some low level issues
+that must be taken into consideration. One of these is that there must
+be some sort of write barrier between passes. Wipe uses fdatasync(2)
+(or fsync(2)) as a write barrier, or if fsync(2) isn't available, the
+file is opened with the O_DSYNC or O_SYNC flag. For wipe to be
+effective, each pass must be completely written. To ensure this, the
+drive must support some form of a write barrier, write cache flush, or
+write cache disabling. SCSI supports ordered command tags, has a force
+media access bit for commands, and write cache can be disable on mode
+page 8. IDE/ATA drives support write cache flushes and write cache
+disabling. Unfortunetly, not all drives actually disable write cache
+when asked to. Those drives are broken. Write caching should always be
+disabled, unless your system is battery backed and always powers down
+cleanly.
+.PP
+Under linux, the mount option "mand" must be used (see
+linux/Documentation/mandatory.txt) for mandatory file locks to be
+enabled. Wipe should make it extremely difficult for all but the most
+determined person(s) to recover the original plaintext data. Utilities
+such as PGP and the GNU Privacy Guard provide strong encryption, but
+encryption is useless if the original plaintext can be recovered. When
+using PGP and GPG, temporary files that are disk-backed should be
+stored on an encrypted file system. That way, the plaintext never hits
+the platters. Wipe is designed for situations where an encrypted file
+system isn't practical.
+.PP
+Wipe uses /dev/urandom, or if unavailable, /dev/random, as a source
+for entropy. The Mersenne Twister PRNG is used for speed. The MT site
+is at:
+.PP
+\fIhttp://www.math.keio.ac.jp/~matumoto/emt.html\fP
+.PP
+For more information on the secure deletion of magnetic media and
+solid state storage devices (such as DRAM) see the USENIX article by
+Peter Gutmann at:
+.PP
+\fIhttp://www.cs.auckland.ac.nz/~pgut001/secure_del.html\fP
+
+.SH OPTIONS
+.TP
+.B \-h
+Display help screen. Shows options and what they do.
+.TP
+.B \-u
+usage \- shows options
+.TP
+.B \-c
+shows copywrite information
+.TP
+.B \-w
+shows warranty
+.TP
+.B \-i
+interactive \- prompt whether to remove each file
+explicitly checks file permissions
+.TP
+.B \-I
+disables interaction
+.TP
+.B \-f
+forces file wiping and suppresses permission warnings
+.TP
+.B \-r or \-R
+recursion \- traverse subdirectories
+.TP
+.B \-s
+silent \- disable percent reporting and some warnings
+.TP
+.B \-V
+verbose \- shows percentage if file size is above a certain limit (see
+wipe -h)
+.TP
+.B \-v
+force verbose \- always show percentage
+.TP
+.B \-e and \-E
+on (-e) makes the percentage (only if shown) more accurate by calling
+fdatasync() before each update
+off (-E) will be slightly less accurate, but wipe will only call
+fdatasync() between passes
+.TP
+.B \-d and \-D
+delete (\-d) or keep (\-D) after wiping
+.TP
+.B \-n and \-N
+delete (\-n) or skip (\-N) fifos, sockets, sym links, and char devices
+.TP
+.B \-k and \-K
+lock (\-k) or don't lock (\-K) files during wiping
+.TP
+.B \-z
+zero-out file \- performs a single pass of zeros
+.TP
+.B \-Z
+perform normal passes \- overrides \-z
+.TP
+.B \-t and \-T
+enable (\-t) or disable (\-T) static passes
+.TP
+.B \-a and \-A
+write until out of space (\-a) or don't (\-A)
+.TP
+.B \-o and \-O
+write [size] to stdout (\-o) or use files (\-O)
+
+Since wipe does not have specific support for char devs, like it does
+for block devs, this is the preferred method of wiping them, such as
+tape drives; eg, wipe \-za -o | buffer > /dev/nst0
+It can also be used for block devs; eg wipe \-To | dd count=size of=blkdev
+
+You can also use this to create files containing pseudo-random output
+from the MT PRNG; eg, wipe \-To10240 -x1 > prand
+
+For static passes, you must specify a stdout length.
+.TP
+.B \-B
+override block device sector count
+.TP
+.B \-S
+override block device sector size
+.TP
+.B \-C
+chunk size - the maximum file buffer size
+.TP
+.B \-l
+sets generic security level
+
+level 0, the PRNG is only seeded once
+
+level 1, the PRNG is seeded once per file
+
+level 2, the PRNG is seeded once per random pass
+.TP
+.B \-x
+enables random passes and optionally, how many random passes to
+perform \- note that this option now sets the number of random passes
+per wipe loop \- in other words, the total number of random passes
+will be random passes * wipe loops (\-p)
+.TP
+.B \-X
+disable random passes
+.TP
+.B \-p
+loop passes \- perform wipe sequence x times, including random passes
+.TP
+.B \-b
+custom byte \- overwrite once with a specific byte
+
+.SH FILES
+.TP
+.B /dev/urandom
+Wipe uses this character device for a source of entropy
+.TP
+.B /dev/random
+Wipe falls back to using this if /dev/urandom is not available
+
+.SH DIAGNOSTICS
+If an error occurs, the exit code will be the errno value. An exit
+code of 2 indicates bad usage.
+
+.SH BUGS
+Wipe does not work on log structured file systems, or any other type
+of file system or block device that reallocates sectors on write.
+
+Some programs are vulnerable to symlink races. To avoid this problem
+with wipe, only wipe files in directories that are not writable by
+untrusted users.
+
+.SH NOTES
+.B Tapes and other sequential access devices
+
+Choose an appropriate buffer size to match the logic or physical block
+size of the device. When using the pattern passes, you should disable
+compression on the drive, and it's generally best to so for other
+passes as well.
+
+For VXA drives, I used mt-st under linux to set the block size to 0
+(variable) and turn off compression, and I run wipe with a 64k block
+size, to match the on-tape format''s native block size.
+
+.B Example:
+
+mt-st setblk 0
+
+mt-st compression 0
+
+wipe -C64 /dev/st0
+
+.SH ALTERNATIVES
+.P
+
+.B Other file wiping utilities:
+
+Another "wipe" by Berke Durak <\fIdurakb@crit2.univ-montp2.fr\fP>
+
+Colin Plumb's <\fIcolin@nyx.net\fP> sterilize.
+
+Todd Burgess's <\fItburgess@eddie.cis.uoguelph.ca\fP> srm is available on sunsite/metalab in
+
+\fIftp://metalab.unc.edu/pub/Linux/system/filesystems/\fP
+
+.SH SEE ALSO
+/usr/doc/wipe/README
+
+.SH AUTHORS
+.P
+Wipe
+.br
+Copyright (C) 1998-2009 Thomas M. Vier, Jr. <\fInester@users.sf.net\fP>
+
+Mersenne Twister PRNG module
+.br
+Copyright (C) 1997 Makoto Matsumoto and Takuji Nishimura
+
diff --git a/wipe.c b/wipe.c
new file mode 100644
index 0000000..3e3399c
--- /dev/null
+++ b/wipe.c
@@ -0,0 +1,595 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2009 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
+#include <fcntl.h>
+
+#define __USE_GNU
+#include <string.h>
+#include <strings.h>
+
+#include "config.h"
+
+#ifdef STAT_MACROS_BROKEN
+/* just in case, so we don't unlink a directory,
+ we don't currently handle broken stat macros */
+# define unlink(x) remove(x)
+#endif
+
+#ifndef HAVE_UNLINK
+# define unlink(x) remove(x)
+#endif
+
+#include "std.h"
+#include "str.h"
+#include "io.h"
+#include "main.h"
+#include "percent.h"
+#include "file.h"
+#include "lock.h"
+#include "dir.h"
+#include "rand.h"
+#include "wipe.h"
+
+extern int errno;
+extern int exit_code;
+extern char *argvzero;
+extern struct rename_s rns;
+extern struct opt_s options;
+
+private void pass_pause(void);
+private int random_pass(struct file_s *f, int passes);
+private int write3_pass(struct file_s *f, const unsigned char byte1, const unsigned char byte2, const unsigned char byte3);
+
+private int zero(struct file_s *f);
+private int wipe(struct file_s *f);
+
+/*
+ pass_pause -- pause for pass inspection
+*/
+
+private void pass_pause(void)
+{
+#ifdef PAUSE
+ printf("Hit a key:");
+ fgetc(stdin);
+#endif
+}
+
+/*
+ random_pass -- fills file with random bytes
+*/
+
+private int random_pass(struct file_s *f, int passes)
+{
+ int i;
+
+#ifdef PAUSE
+ fprintf(stderr, "\rentering random_pass()\n");
+#endif
+
+ while (passes--)
+ {
+ if (options.seclevel == 2)
+ prng_seed();
+
+ if (!options.until_full)
+ {
+ i=0;
+ while (i++ < f->loop)
+ {
+ prng_fillbuf(options.seclevel, f->buf, f->bufsize);
+ if (do_write(f->name, f->fd, f->buf, f->bufsize)) return FAILED;
+
+ if (f->percent.display)
+ {
+ if (options.percent_sync)
+ {
+ f->sfail = sync_data(f->name, f->fd, f->sfail);
+ if (f->sfail && !S_ISCHR(f->st.st_mode)) return FAILED;
+ }
+
+ percent_update(&f->percent);
+ }
+ }
+
+ if (f->loopr)
+ {
+ prng_fillbuf(options.seclevel, f->buf, f->loopr);
+ if (do_write(f->name, f->fd, f->buf, f->loopr)) return FAILED;
+ /* no percent update */
+ }
+ }
+ else
+ {
+ while (1)
+ {
+ prng_fillbuf(options.seclevel, f->buf, f->bufsize);
+ i = do_write(f->name, f->fd, f->buf, f->bufsize);
+
+ if (i == ENOSPC) break;
+ else if (i != 0) return FAILED;
+ }
+ }
+
+ f->sfail = do_fwb(f->name, f->fd, f->sfail);
+ if (f->sfail && !S_ISCHR(f->st.st_mode)) return FAILED;
+
+ pass_pause();
+ if (do_rewindfd(f->name, f->real_name, &f->fd, f->st.st_mode)) return FAILED; /* rewind */
+ }
+
+#ifdef PAUSE
+ fprintf(stderr, "\rleaving random_pass()\n");
+#endif
+
+ return 0;
+}
+
+/*
+ write_pass -- fill file with given byte
+*/
+
+public int write_pass(struct file_s *f, const unsigned char byte)
+{
+ int i;
+
+#ifdef PAUSE
+ fprintf(stderr, "\rentering write_pass()\n");
+#endif
+
+#ifdef HAVE_BZERO
+ if (byte == 0)
+ bzero(f->buf, f->bufsize);
+ else
+#endif
+ memset(f->buf, byte, f->bufsize);
+
+ if (!options.until_full)
+ {
+ i=0;
+ while (i++ < f->loop)
+ {
+ if (do_write(f->name, f->fd, f->buf, f->bufsize)) return FAILED;
+
+ if (f->percent.display)
+ {
+ if (options.percent_sync)
+ {
+ f->sfail = sync_data(f->name, f->fd, f->sfail);
+ if (f->sfail && !S_ISCHR(f->st.st_mode)) return FAILED;
+ }
+
+ percent_update(&f->percent);
+ }
+ }
+
+ if (f->loopr)
+ {
+ if (do_write(f->name, f->fd, f->buf, f->loopr)) return FAILED;
+ /* no percent update */
+ }
+ }
+ else
+ {
+ while (1)
+ {
+ i = do_write(f->name, f->fd, f->buf, f->bufsize);
+
+ if (i == ENOSPC) break;
+ else if (i != 0) return FAILED;
+ }
+ }
+
+ f->sfail = do_fwb(f->name, f->fd, f->sfail);
+ if (f->sfail && !S_ISCHR(f->st.st_mode)) return FAILED;
+
+ pass_pause();
+ if (do_rewindfd(f->name, f->real_name, &f->fd, f->st.st_mode)) return FAILED; /* rewind */
+
+#ifdef PAUSE
+ fprintf(stderr, "\rleaving write_pass()\n");
+#endif
+
+ return 0;
+}
+
+/*
+ write3_pass -- over writes file with given bytes
+*/
+
+private int write3_pass(struct file_s *f,
+ const unsigned char byte1,
+ const unsigned char byte2,
+ const unsigned char byte3)
+{
+ int i, r;
+ size_t size;
+ off_t offset;
+ unsigned char bytes[3], *cbuf;
+
+#ifdef PAUSE
+ fprintf(stderr, "\rentering write3_pass()\n");
+#endif
+
+ /* size must be a multiple of 3 */
+ size = f->bufsize - (f->bufsize % 3);
+ cbuf = (unsigned char *) f->buf;
+
+ i=0;
+ while (i < size)
+ {
+ cbuf[i++] = byte1;
+ cbuf[i++] = byte2;
+ cbuf[i++] = byte3;
+ }
+
+ r = f->bufsize - size; /* find remainder */
+
+ if (r)
+ {
+ offset = size; i=0;
+
+ bytes[0] = byte1;
+ bytes[1] = byte2;
+ bytes[2] = byte3;
+
+ while (r--)
+ *(unsigned char *)((void *) f->buf + offset++) = bytes[i++];
+ }
+
+ /*
+ ok, we've filled the buffer with the pass image
+
+ see fsetbuf() for why we don't have to worry about
+ f->bufsize (or f->fsize) being an interger
+ multiple of 3
+ */
+
+ if (!options.until_full)
+ {
+ i=0;
+ while (i++ < f->loop)
+ {
+ if (do_write(f->name, f->fd, f->buf, f->bufsize)) return FAILED;
+
+ if (f->percent.display)
+ {
+ if (options.percent_sync)
+ {
+ f->sfail = sync_data(f->name, f->fd, f->sfail);
+ if (f->sfail && !S_ISCHR(f->st.st_mode)) return FAILED;
+ }
+
+ percent_update(&f->percent);
+ }
+ }
+
+ /* smooth out any wrinkles */
+ offset = f->bufsize - size;
+
+ if (f->loopr)
+ {
+ if (do_write(f->name, f->fd, (f->buf + offset), f->loopr)) return FAILED;
+ /* no percent update */
+ }
+ }
+ else
+ {
+ while (1)
+ {
+ i = do_write(f->name, f->fd, f->buf, f->bufsize);
+
+ if (i == ENOSPC) break;
+ else if (i != 0) return FAILED;
+ }
+ }
+
+ f->sfail = do_fwb(f->name, f->fd, f->sfail);
+ if (f->sfail && !S_ISCHR(f->st.st_mode)) return FAILED;
+
+ pass_pause();
+ if (do_rewindfd(f->name, f->real_name, &f->fd, f->st.st_mode)) return FAILED; /* rewind */
+
+#ifdef PAUSE
+ fprintf(stderr, "\rleaving write3_pass()\n");
+#endif
+
+ return 0;
+}
+
+/*
+ destroy_file -- destroy the file
+ calls wipe() and zero()
+*/
+
+public int destroy_file(struct file_s *f)
+{
+ rns.valid=0; rns.valid_mode=0;
+
+ if (options.no_file)
+ {
+ /**** wipe ****/
+ if (wipe(f) == FAILED)
+ return FAILED;
+
+ return 0;
+ }
+
+#ifdef SANITY
+ if (strncmp(f->name, f->real_name, PATH_MAX))
+ {
+ fprintf(stderr, "\r%s: destroy(): f->name != f->real_name\n",
+ argvzero);
+ abort();
+ }
+#endif
+
+#ifdef DEBUG
+ fprintf(stderr, "filename: %s\n", f->name);
+#endif
+
+ /* open */
+ if (do_open(f->name, f->name, &f->fd)) return FAILED;
+
+ /** lock **/
+ if (options.lock)
+ if (do_lock(f))
+ goto failure;
+
+ /*
+ if they don't want random passes, or the file won't
+ be unlinked, we'll skip the rename
+ */
+
+ /** rename **/
+ if (options.delete && options.random)
+ {
+ if ((S_ISCHR(f->st.st_mode) || S_ISBLK(f->st.st_mode)) && !options.rmspcl)
+ { /* skip devices, unless we're going to delete */ }
+ else
+ {
+ /* first, just (hopefully) overwrite the name */
+ if (wipe_name(f->fd, f->real_name, strnlen(f->real_name, sizeof(f->real_name))) == FAILED)
+ goto failure;
+
+ /* now use a rand name */
+ if (wipe_name(f->fd, f->real_name, 0) == FAILED)
+ goto failure;
+ }
+ }
+
+ /**** wipe ****/
+ if (wipe(f) == FAILED)
+ goto failure;
+
+ if (options.delete)
+ {
+ /* destroy file references, unless this is debug build */
+# ifdef HAVE_FTRUNCATE
+ do_ftruncate(f->name, f->fd, 0);
+# endif
+
+ /** rename again **/
+ if (options.random)
+ {
+ if ((S_ISCHR(f->st.st_mode) || S_ISBLK(f->st.st_mode)) && !options.rmspcl)
+ { /* skip devices, unless we're going to delete */ }
+ else
+ {
+ if (wipe_name(f->fd, f->real_name, 0) == FAILED)
+ goto failure;
+ }
+ }
+
+#ifndef DEBUG
+ if (unlink(f->real_name))
+ {
+ fprintf(stderr, "\r%s: cannot unlink `%s': %s\n",
+ argvzero, f->name, strerror(errno));
+ exit_code = errno; goto failure;
+ }
+#endif
+
+ rns.valid=0; rns.valid_mode=0;
+ }
+
+ if (!options.delete)
+ {
+ /* restore file mode */
+ if (fchmod(f->fd, (f->st.st_mode & 07777)))
+ {
+ fprintf(stderr, "\r%s: cannot restore file mode for `%s': %s\n",
+ argvzero, f->name, strerror(errno));
+ exit_code = errno; goto failure;
+ }
+ }
+
+ if (sync_data(f->name, f->fd, f->sfail) && !S_ISCHR(f->st.st_mode)) goto failure;
+
+ do_close(f->name, f->fd);
+ return 0;
+
+ failure:
+ restore_file();
+ rns.valid=0; rns.valid_mode=0;
+ sync_data(f->name, f->fd, f->sfail);
+ do_close(f->name, f->fd);
+ fprintf(stderr, "\r%s: failed to wipe `%s'\n", argvzero, f->name);
+ return FAILED;
+}
+
+/*
+ zero -- zeroes out a file. if options.custom, fills with custom byte
+*/
+
+private int zero(struct file_s *f)
+{
+ fsetbuf(f);
+
+ if (fgetbuf(f))
+ return FAILED;
+
+ percent_init(&f->percent, f->name, f->bufsize, f->loop);
+
+ if (write_pass(f, options.custom_byte)) return FAILED;
+
+ percent_done(&f->percent);
+
+ ffreebuf(f);
+
+ return 0;
+}
+
+/*
+ wipe -- runs wipe passes on a given file
+*/
+
+private int wipe(struct file_s *f)
+{
+ if (!options.no_file && (f->st.st_size == 0 && !options.until_full))
+ {
+ if (options.verbose)
+ {
+ fprintf(stderr, "\r%s: zero length, skipping `%s'\n",
+ argvzero, f->name);
+
+ }
+ return 0; /* no need to write anything */
+ }
+
+ if (options.zero || options.custom) return zero(f);
+
+ fsetbuf(f);
+
+ if (fgetbuf(f))
+ return FAILED;
+
+ percent_init(&f->percent, f->name, f->bufsize, f->loop);
+
+ /**** run the passes ****/
+ if (wipe_passes(f)) {ffreebuf(f); return FAILED;}
+
+ percent_done(&f->percent);
+
+ ffreebuf(f);
+
+ return 0;
+}
+
+/*
+ wipe_passes -- runs the actual passes
+*/
+
+public int wipe_passes(struct file_s *f)
+{
+ int i, loop;
+
+ if (STATIC_PASSES != 27)
+ {
+ /*
+ STATIC_PASSES is defined in percent.h and used by percent_init()
+ it should only need to be changed if this function is changed
+
+ if this function is changed, STATIC_PASSES in percent_init()
+ must be updated and the above constant must be changed to match
+ */
+ fprintf(stderr, "\rSTATIC_PASSES != 27\npercent code broken!\n");
+ abort();
+ }
+
+ if (options.seclevel == 1)
+ if (prng_seed())
+ return FAILED;
+
+ loop = options.wipe_multiply;
+
+ while (loop--)
+ {
+ if (options.random)
+ if (random_pass(f, options.random_loop / 2))
+ return FAILED;
+
+ /*
+ these patterns where taking from Peter Gutmann's 1996 USENIX article,
+ Secure Deletion of Data from Magnetic and Solid-State Memory
+
+ http://www.cs.auckland.ac.nz/~pgut001/secure_del.html
+ http://wipe.sourceforge.net/secure_del.html
+
+ thanks, peter!
+ */
+
+ if (options.statics)
+ {
+ /*
+ comment format:
+ pass number -- binary pattern -- target encoding scheme
+ */
+
+ /* fifth pass -- 01 -- RLL(1,7) and MFM */
+ if (write_pass(f, 0x55)) return FAILED;
+
+ /* sixth pass -- 10 -- same */
+ if (write_pass(f, 0xaa)) return FAILED;
+
+ /* seventh pass -- 10010010 01001001 00100100 -- RLL(2,7) and MFM */
+ if (write3_pass(f, 0x92, 0x49, 0x24)) return FAILED;
+
+ /* eighth pass -- 01001001 00100100 10010010 -- same */
+ if (write3_pass(f, 0x49, 0x24, 0x92)) return FAILED;
+
+ /* ninth pass -- 00100100 10010010 01001001 -- same */
+ if (write3_pass(f, 0x24, 0x92, 0x49)) return FAILED;
+
+ /* tenth pass -- start 0x11 increment passes */
+ for (i = 0x00; i <= 0xff; i += 0x11)
+ if (write_pass(f, i))
+ return FAILED;
+
+ /* 26 -- RLL(2,7) and MFM passes, again */
+ if (write3_pass(f, 0x92, 0x49, 0x24)) return FAILED;
+ if (write3_pass(f, 0x49, 0x24, 0x92)) return FAILED;
+ if (write3_pass(f, 0x24, 0x92, 0x49)) return FAILED;
+
+ /* 29 -- 01101101 10110110 11011011 -- RLL(2,7) */
+ if (write3_pass(f, 0x6d, 0xb6, 0xdb)) return FAILED;
+ /* 10110110 11011011 01101101 */
+ if (write3_pass(f, 0xb6, 0xdb, 0x6d)) return FAILED;
+ /* 11011011 01101101 10110110 */
+ if (write3_pass(f, 0xdb, 0x6d, 0xb6)) return FAILED;
+ }
+
+ /* odd rand passes are done last */
+ if (options.random)
+ if (random_pass(f, options.random_loop / 2 + options.random_loop % 2))
+ return FAILED;
+ }
+
+ return 0;
+}
diff --git a/wipe.h b/wipe.h
new file mode 100644
index 0000000..07f5e69
--- /dev/null
+++ b/wipe.h
@@ -0,0 +1,30 @@
+/*
+ Licensed under the GNU Public License.
+ Copyright (C) 1998-2002 by Thomas M. Vier, Jr. All Rights Reserved.
+
+ wipe is free software.
+ See LICENSE for more information.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef HAVE_BZERO
+# define bzero(x, y) memset(x, 0, y)
+#endif
+
+public int wipe_stdout(void);
+public int destroy_file(struct file_s *f);
+public int wipe_passes(struct file_s *f);
+public int write_pass(struct file_s *f, const unsigned char byte);
diff --git a/wipe.spec b/wipe.spec
new file mode 100644
index 0000000..190703b
--- /dev/null
+++ b/wipe.spec
@@ -0,0 +1,60 @@
+%define ver 2.3
+%define rel 1
+%define prefix /usr
+%define docs LICENSE copyright README CHANGES TODO INSTALL TESTING
+
+Prefix: %{prefix}
+BuildRoot: %{_tmppath}/%{name}-buildroot
+Docdir: %{prefix}/doc
+
+Summary: secure file wiper
+Name: wipe
+Version: %ver
+Release: %rel
+License: GPL
+Group: Utilities/File
+Source: metalab.unc.edu:/pub/Linux/utils/file/wipe-%{ver}.tar.bz2
+URL: http://wipe.sf.net/
+Packager: Tom Vier <nester@users.sf.net>
+
+%description
+Wipe is a tool that attemps to effectively degauses the surface of
+a hard disk, making it virtually impossible to retrieve the data
+that was stored on it. This tool is designed to make sure secure
+data that is erased from a hard drive is unrecoverable.
+
+%prep
+rm -rf $RPM_BUILD_DIR/wipe-%{ver}
+bunzip2 < $RPM_SOURCE_DIR/wipe-%{ver}.tar.bz2 | tar xv
+
+%build
+cd wipe-%{ver}
+./configure --prefix=$RPM_BUILD_ROOT/%{prefix}
+make
+
+%install
+cd wipe-%{ver}
+#make install
+cp %{docs} $RPM_BUILD_DIR
+install -d $RPM_BUILD_ROOT%{_bindir}
+install -s ./wipe $RPM_BUILD_ROOT%{_bindir}
+install -d $RPM_BUILD_ROOT%{_mandir}/man1/
+install -m 0644 wipe.1 $RPM_BUILD_ROOT%{_mandir}/man1/
+rm -rf $RPM_BUILD_ROOT/%{_prefix}/doc/wipe/
+install -d $RPM_BUILD_ROOT%{_prefix}/doc/wipe/
+for file in %{docs}
+do
+ install -m 0644 $file $RPM_BUILD_ROOT/%{_prefix}/doc/wipe/
+done
+
+%files
+%defattr(-,root,root)
+%doc %{docs}
+/usr/bin/wipe
+#/usr/man/man1/wipe.1
+%{_mandir}/man1/wipe.1*
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+rm -rf $RPM_BUILD_DIR/wipe-%{ver}
+rm -f %{docs}