#!/bin/sh

#
# This basic script can be used by the Autopsy Forensic Browser on Mac
# OS X so that the version of strings looks like the GNU binutils one.
#
#
# Instructions:
#  1.  Place it in /usr/local/bin
#  2.  Set it to be executable:
#     chmod +x /usr/local/bin/strings
#  3.  Type 'make' and autopsy will find it
#
#
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR ANY PARTICULAR PURPOSE.
#
# IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, 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.
#



STRINGS=/usr/bin/strings

# no args
if (test -z "$1") then
	$STRINGS
	exit
fi

# one arg: must be the file itself or -a
if (test -z "$2") then
	if (test "$1" = "-a") then 
		$STRINGS -
	else
		$STRINGS $1
	fi
	exit
fi

# two args: either -t d or -a file
if (test -z "$3") then
	if ((test "$1" = "-t") && (test "$2" = "d")) then
		$STRINGS -o -
	elif (test "$1" = "-a") then
		$STRINGS - $2
	fi
	exit
fi

# three args, -t d file
if (test -z "$4") then
	if ((test "$1" = "-t") && (test "$2" = "d")) then
		$STRINGS -o - $3
	fi
fi

# four args: -a -t d file
if (test -z "$5") then
	if ((test "$1" = "-a") && (test "$2" = "-t") && (test "$3" = "d")) then
		$STRINGS -o - $4 
		exit
	fi
fi

if (test -z "$6") then
	if ((test "$1" = "-t") && (test "$2" = "d") && (test "$3" = "-n")) then
		$STRINGS -o - -$4 $5
		exit
	fi
fi

echo "hmmm, try the original strings at: $STRINGS";

