#!/bin/sh

# -
# Copyright (c) 2002, Ramsey G. Brenner <rgbrenner@myrealbox.com>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
# 3. Redistributions of products derived from this software must obtain
#    the specific prior written permission of the author.
# 4. Neither the name of the author nor the names of its contributors may
#    be used to endorse or promote products derived from this software
#    without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
# -

DOC_DIR=/usr/local/man
INSTALL_DIR=/usr/local/bin

unknown_answer()
{
	printf "\
Please answer with 'Y', 'y', 'N', or 'n'.\n\n"
}

still_no_answer()
{
	printf "\
This script cannot understand answers other than 'Y',
'y', 'N', or 'n'!\n\n."
}

#Start uninstall
case "$USER" in
root)
	;;
*)
	printf "\
You must be root to uninstall.\n"
	exit 1
	;;
esac

case "$1" in
-f)
	;;
*)
	for cnt in 1 2 3
	{
		printf "\
Are you sure you want to uninstall? (y|n) "
		read tmp
		printf "\n"
		case "$tmp" in
		Y | y)
			break
			;;
		N | n)
			printf "Aborting uninstall.\n"
			exit 0
			break
			;;
		*)
			case "$cnt" in
			3)
				still_no_answer
				exit 1
				break
				;;
			*)
				unknown_answer
				continue
				;;
			esac
			;;
		esac
	}
	;;
esac

#start removing the files
#remove binaries
	rm -f "$INSTALL_DIR"/XOREncrypt
	rm -f "$INSTALL_DIR"/xorencrypt
	rm -f "$INSTALL_DIR"/XORDecrypt
	rm -f "$INSTALL_DIR"/xordecrypt
	rm -f "$INSTALL_DIR"/XORCreateKey
	rm -f "$INSTALL_DIR"/xorcreatekey
	rm -f "$INSTALL_DIR"/XORFakeKey
	rm -f "$INSTALL_DIR"/xorfakekey
	rm -f "$INSTALL_DIR"/XORSplit
	rm -f "$INSTALL_DIR"/xorsplit
#remove docs
	rm -f "$DOC_DIR"/[cm]a[tn][17]/XORCrypt.[17]*
	rm -f "$DOC_DIR"/[cm]a[tn][17]/xorcrypt.[17]*
	rm -f "$DOC_DIR"/[cm]a[tn]1/XOREncrypt.1*
	rm -f "$DOC_DIR"/[cm]a[tn]1/xorencrypt.1*
	rm -f "$DOC_DIR"/[cm]a[tn]1/XORDecrypt.1*
	rm -f "$DOC_DIR"/[cm]a[tn]1/xordecrypt.1*
	rm -f "$DOC_DIR"/[cm]a[tn]1/XORCreateKey.1*
	rm -f "$DOC_DIR"/[cm]a[tn]1/xorcreatekey.1*
	rm -f "$DOC_DIR"/[cm]a[tn]1/XORFakeKey.1*
	rm -f "$DOC_DIR"/[cm]a[tn]1/xorfakekey.1*
	rm -f "$DOC_DIR"/[cm]a[tn]1/XORSplit.1*
	rm -f "$DOC_DIR"/[cm]a[tn]1/xorsplit.1*
exit 0
