#!/bin/ksh

# Delete all DIF entries in the file 'difentries'

# Build directory from adtag base directory and then the subdir passed in.
TAG_BASEDIR=`/twc/bin/db_exp -f c_adtag_directory -s dif /twc/dif/wxl_dif`
TAG_DIRECTORY=$1
TAG_PATH=$TAG_BASEDIR/$TAG_DIRECTORY

echo "DELETE $TAG_DIRECTORY""_version_stamp" | /twc/bin/fire_str >/dev/null 2>&1

IFS=,

exec 0< $TAG_PATH/difentries
while read difname otherargs
do
  echo "UPDATE $difname=\"\"" | /twc/bin/fire_str >/dev/null 2>&1
done

exec 0< $TAG_PATH/difentries
while read difname otherargs
do
  echo "DELETE $difname" | /twc/bin/fire_str >/dev/null 2>&1
done

# Okay, now get all product page DIF entries for this tag (containing 'g_tag_<adtag>_').
DIFNAME="g_tag_$TAG_DIRECTORY""_"
/twc/bin/db_exp -s dif /twc/dif/wxl_dif | grep $DIFNAME > entries_temp

IFS=,
exec 0< entries_temp
while read difname otherargs
do
  echo "DELETE $difname" | /twc/bin/fire_str >/dev/null 2>&1
done

rm entries_temp
