#!/bin/sh

TMPFILE=`tempfile`

do_find ()
{
	grep -B5 -A10 "^ `echo $1 | tr [a-f] [A-F]`" os*
	grep -A14 "^ `echo $1 | tr [a-f] [A-F]`" os* > $TMPFILE
	n=1
	NEXTLOC=""
	while [ "$NEXTLOC" = "" ]; do
		NEXTLOC="`tail -$n $TMPFILE | \
			sed -ne 's/^os[0-9]*[-:] \([0-9a-fA-F]\+\).*/\1/gp'`"
		n="`expr $n + 1`"
	done
}

NEXTLOC=c000

while true; do
	echo -n "Location: "
	read LOC
	if [ "$LOC" = "q" ]; then
		rm -f $TMPFILE
		exit 0
	elif [ "$LOC" = "" ]; then
		LOC=$NEXTLOC
	fi
	do_find $LOC
done
