#!/bin/sh
# 
# $Copyright
# Copyright 1993, 1994, 1995  Intel Corporation
# INTEL CONFIDENTIAL
# The technical data and computer software contained herein are subject
# to the copyright notices; trademarks; and use and disclosure
# restrictions identified in the file located in /etc/copyright on
# this system.
# Copyright$
# 
 
#
# (c) Copyright 1990, OPEN SOFTWARE FOUNDATION, INC.
# ALL RIGHTS RESERVED
#
#
# OSF/1 Release 1.0

#
# COMPONENT_NAME: UUCP uulog
#
# FUNCTIONS:
#
# ORIGINS: 10  27  3
#
# (C) COPYRIGHT International Business Machines Corp. 1985, 1989
# All Rights Reserved
# Licensed Materials - Property of IBM
#
# US Government Users Restricted Rights - Use, duplication or
# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
#
# "@(#)uulog	1.3  com/cmd/uucp,3.1,9013 10/10/89 13:58:21"
#From: ulysses!smb (Steven Bellovin)
#
# usage:
# 	uulog
# or	uulog foo
# or	uulog -sfoo
# or	uulog -s foo
# or	uulog -ffoo
# or	uulog -f foo
#
#	-x means check the execute file
#	-nnn where 'nnn' is a number will do tail -nnn
#
LOGDIR=/usr/spool/uucp/.Log
type=uucico
n=""

cd $LOGDIR

while [ $# -gt 0 ]
do
	case $1 in
	-x)	type=uuxqt
		shift
		;;

	-[0-9]*)n=`echo $1|cut -c2-`
		shift
		;;

	-f)	fflag=1
		shift
		;;

	-f*)	x=`echo $1|cut -c3-`
		shift
		set - $x $*
		fflag=1
		;;

	-s)	shift
		;;

	-s*)	x=`echo $1|cut -c3-`
		shift
		set - $x $*
		;;

	-*)	if [ -x dspmsg ];
		        then dspmsg -s1 uucp.cat 3 "Invalid flag %s" $1 1>&2
        		else echo "Invalid flag $1" 1>&2
     		fi
		exit 1
		;;

	*)	sys="$sys $1"
		shift
		;;

	esac
done

set - $sys
if [ x$fflag = x ]; then
	if [ $# = 0 ]; then
		set - `ls $type`
	fi
	for i
	do
		if [ x$n = x ]; then
			cat $type/$i
		else
			tail -$n $type/$i
		fi
	done
else
	if [ $# != 1 ]; then
     		if [ -x dspmsg ];
		    then dspmsg -s1 uucp.cat 4 "Exactly one system with -f" 1>&2
        		else echo "Exactly one system with -f" 1>&2
     		fi
		exit 2
	fi
	exec tail -${n}f $type/$1
fi
