#!/bin/sh
# $Id: makecablists.sh,v 1.2 2001/11/07 18:06:44 rlawrence Exp $ 
# SCCSID(@(#)makecablists.sh	1.1) Modified 00:57:40 3/7/00
# Make lists of the contents of the cab files.
# Two parameters, both required.
# The first is the source directory where the cab files are.
# The second is the destination directory where to place the list files.
# Both directories must already exist and be valid:
#    The source directory must have cab files.
#    The destination directory must be writable.
# Note: This script is not intended to be normally used by end users.
# Thus the error messages about bad parameters do not need
# to be NLSized, because the calling scripts need to make sure
# the directories and parameters are correct.

SRC_DIR=$1
DEST_DIR=$2
if [ "x$SRC_DIR" = "x" -o "x$DEST_DIR" = "x" ]
then
	echo "$0: Missing paramters"
	exit 1
fi
if [ ! -d "$SRC_DIR" ]
then
	echo "Bad first parameter to $0: $SRC_DIR"
	exit 1
fi
cd $SRC_DIR

if [ ! -d "$DEST_DIR" ]
then
	echo "Bad second parameter to $0: $DEST_DIR"
	exit 1
fi

# mrgssv sets STATICMERGE, VARMERGE, DOSWINBINDIR, etc.
. /etc/mrgssv.sh

KOPT="+kmerge-internal-config:snap"
for i in *.cab *.CAB
do
	[ ! -f $i ] && continue
	rm -f $DEST_DIR/$i.txt
	$DOSWINBINDIR/dos +b -e -p -r -t $KOPT extract /D $i \
		| $STATICMERGE/charconv -d -x -z > $DEST_DIR/$i.txt
done
