Your IP : 216.73.216.48
| Current Path : /usr/X11R6/bin/ |
|
|
| Current File : //usr/X11R6/bin/showpartial |
#!/bin/sh -e
# Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
#
# Permission to use, copy, modify, and distribute this material
# for any purpose and without fee is hereby granted, provided
# that the above copyright notice and this permission notice
# appear in all copies, and that the name of Bellcore not be
# used in advertising or publicity pertaining to this
# material without the specific, prior written permission
# of an authorized representative of Bellcore. BELLCORE
# MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
# OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS",
# WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
# Conversion from C shell to Bourne shell by Z-Code Software Corp.
# Conversion Copyright (c) 1992 Z-Code Software Corp.
# Permission to use, copy, modify, and distribute this material
# for any purpose and without fee is hereby granted, provided
# that the above copyright notice and this permission notice
# appear in all copies, and that the name of Z-Code Software not
# be used in advertising or publicity pertaining to this
# material without the specific, prior written permission
# of an authorized representative of Z-Code. Z-CODE SOFTWARE
# MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY
# OF THIS MATERIAL FOR ANY PURPOSE. IT IS PROVIDED "AS IS",
# WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
if [ -z "$METAMAIL_TMPDIR" ]
then
METAMAIL_TMPDIR=/tmp
fi
if test -z "$3" -o ! -z "$5"
then
echo "Usage: showpartial file id partnum totalnum"
exit 1
fi
file=$1
# This next line is because message-id can contain weird chars
id=$(echo "$2" | tr -d \!\$\&\*\(\)\|\'\"\;\/\<\>\\\\ )
partnum=$3
if test -z "$4"
then
totalnum=-1
else
totalnum=$4
fi
if [ -n "$HOME" ] ; then
# If we have a home directory, create a temporary dir and
# store the name there unless the file already exists
# and the directory it points to is valid directory
[ -e "$HOME/.metamail_treeroot" ] && TREEROOT=`cat $HOME/.metamail_treeroot`
[ -e "$TREEROOT" ] && [ ! -d "$TREEROOT" ] && rm -f "$TREEROOT"
if [ ! -e "$HOME/.metamail_treeroot" ] || [ ! -e "$TREEROOT" ]; then
TREEROOT=`mktemp -d -t msg-parts.XXXXXX` || { echo "$0: Cannot create temporary dir!" >&2 ; exit 1; }
echo $TREEROOT >$HOME/.metamail_treeroot
fi
else
TREEROOT=$METAMAIL_TMPDIR/msg-parts-`whoami`
# Sanity check: is this a directory?
[ -e "$TREEROOT" ] && [ ! -d "$TREEROOT" ] && rm -f "$TREEROOT"
# Sanity check, does it belong to us?
if [ -d "$TREEROOT" ] ; then
treeuid=`stat -c %u "$TREEROOT"`
if [ "$treeuid" -ne "`id -u`" ]; then
echo "$0: Tried to use $TREEROOT but it does not belong to us! Aborting." >&2
exit 1
fi
else
mkdir -p "$TREEROOT" || { echo "$0: Cannot create dir $TREEROOT!" >&2 ; exit 1; }
fi
fi
if test ! -d "${TREEROOT}/$id"
then
mkdir "${TREEROOT}/$id"
if test $? -ne 0
then
echo mkdir "${TREEROOT}/$id" failed
exit 1
fi
fi
cp $file "${TREEROOT}/$id/$partnum"
if test $? -ne 0
then
echo cp $file "${TREEROOT}/$id/$partnum" failed
exit 1
fi
if test $totalnum -eq -1
then
if test -r "${TREEROOT}/$id/CT"
then
totalnum=`cat "${TREEROOT}/$id/CT"`
else
totalnum=-1
fi
else
echo $totalnum > "${TREEROOT}/$id/CT"
fi
# Slightly bogus here -- the shell messes up the newlines in the headers
# if ($partnum == 1) then
# echo $MM_HEADERS > "${TREEROOT}/$id/HDRS"
# endif
found=0
ix=1
list=
limit=$totalnum
if test "$limit" -eq -1
then
limit=25
fi
while test "$ix" -le "$limit"
do
if test -f "${TREEROOT}/$id/$ix"
then
list="$list $ix"
found=$(($found + 1))
fi
ix=`expr $ix + 1`
done
if test $found = "$totalnum"
then
cd "${TREEROOT}/$id"
cat $list > "${TREEROOT}/$id/FULL"
rm $list
echo All parts of this "${totalnum}"-part message have now been read.
metamail -d < "${TREEROOT}/$id/FULL"
echo WARNING: To save space, the full file is now being deleted.
echo You will have to read all "$totalnum" parts again to see the full message again.
rm "${TREEROOT}/$id/FULL"
rm "${TREEROOT}/$id/CT"
cd ${METAMAIL_TMPDIR}
rmdir "${TREEROOT}/$id"
rmdir ${TREEROOT} > /dev/null 2>&1
[ -e "$HOME/.metamail_treeroot" ] && > "$HOME/.metamail_treeroot"
else
if test "$totalnum" -eq -1
then
echo So far you have only read $found of the several parts of this message.
else
echo So far you have only read $found of the "$totalnum" parts of this message.
fi
echo When you have read them all, then you will see the message in full.
fi