#!/bin/sh

# mkbb.comp
# SCRIPT TO DETERMINE COLUMNS TO DISPLAY IN COMPRESSED FORMAT
# Sean MacGuire
# Version 1.9
# Mar 13th, 2002
#
# (c) Copyright Quest Software, Inc.  1997-2002  All rights reserved.
#

#
# WE NEED AT LEAST ON ARGUMENT....
#
if [ "$#" = 1 ]
then
	BBHOSTLINE="$1"
else
	exit
fi

if [ ! "$BBTMP" ]                      # GET DEFINITIONS IF NEEDED
then
        . $BBHOME/etc/bbdef.sh          # INCLUDE STANDARD DEFINITIONS
fi

OLDIFS=$IFS

$SED 1,${BBHOSTLINE}d ${BBHOSTS} > $BBTMP/mkbb.comp.$$

# Make read use this file
exec < $BBTMP/mkbb.comp.$$
while read line
do
	set bogus $line >/dev/null 2>&1
	shift

	case "$1"
	in
		[0-9]* )

			IFS='.'
			set -f
			set $2 >/dev/null 2>&1
			set +f
			IFS=$OLDIFS             
			ANAME=$1
			if test "$FQDN" = "TRUE"
			then           
				shift   
				for arg in $*
				do
					ANAME="$ANAME,$arg"
				done    
			fi
			echofiles=`echo ${BBLOGS}/${ANAME}.* 2>/dev/null`
			if [ "$echofiles" != "${BBLOGS}/${ANAME}.*" ]
			then
				BBARGS="$BBARGS ${ANAME}.*"		# ADD A LINE
			fi
			;;

		group | group-compress | group-only )

			break
			;;


		page | subpage )
			break
			;;
	esac
done

$RM -f $BBTMP/mkbb.comp.$$

if [ "$BBARGS" ]
then
	echo $BBARGS
fi

exit 0
