<?xml version="1.0"?>
<paste-with-annotations>
  <paste>
    <number>
      <integer>96719</integer>
    </number>
    <user>
      <string>tziker</string>
    </user>
    <title>
      <string>xh.sh</string>
    </title>
    <contents>
      <string>#!/bin/ksh -p

export LANG=C
export LC_ALL=C
unset LC_CTYPE LC_COLLATE LC_MESSAGES LC_MONETARY LC_NUMERIC LC_TIME

CLEANFILES=&quot;&quot;

function msg
{
	local text=&quot;$*&quot;
	echo &quot;$text&quot; &gt;&amp;2
}

function cleanup
{
	if test -n &quot;${CLEANFILES}&quot; ; then
		for fname in ${CLEANFILES} ; do
			rm -f &quot;${file}&quot;
		done
	fi
}
trap &quot;cleanup ; exit 0&quot; 0
trap &quot;msg 'Interrupted.' ; cleanup ; exit 1&quot; 1 2 15

TMPFILE=$(mktemp &quot;/tmp/xh.$$.XXXX&quot;)
if test $? -ne 0 ; then
	msg &quot;cannot create temp page file&quot;
	exit 1
else
	CLEANFILES=&quot;${CLEANFILES} ${TMPFILE}&quot;
fi

function err
{
	local rc=$1
	shift
	local msg=&quot;$*&quot;

	echo &quot;error: ${msg}&quot; &gt;&amp;2
	exit ${rc}
}

function dopage
{
	local flist=&quot;$1&quot;
	local page=&quot;$2&quot;

	test -z &quot;${flist}&quot; &amp;&amp; err 1 &quot;dopage: no flist&quot;
	test -z &quot;${page}&quot; &amp;&amp; err 1 &quot;dopage: no page url&quot;
	msg &quot;fetching page ${page}&quot;
	wget -q -nd -np -O &quot;${TMPFILE}&quot; &quot;${page}&quot;
	if test $? -ne 0 ; then
		msg &quot;cannot fetch page ${page}&quot;
		return 1
	fi
	srv=$( expand &quot;${TMPFILE}&quot; | \
	    sed -n -e &quot;/'srv'/ s/.*'srv'[ ]*:[ ]*'\\([^']*\\)'.*/\\1/p&quot; )
	file=$( expand &quot;${TMPFILE}&quot; | \
	    sed -n -e &quot;/'file'/ s/.*'file'[ ]*:[ ]*'\\([^']*\\)'.*/\\1/p&quot; )

	if test -z &quot;${srv}&quot; ; then
		msg &quot;no server object&quot;
		return 1
	fi
	if test -z &quot;${file}&quot; ; then
		msg &quot;no file object&quot;
		return 1
	fi

	echo &quot;${srv}/flv2/${file}&quot;
	return 0
}

function doflist
{
	local flist=&quot;$1&quot;

	test -z &quot;${flist}&quot; &amp;&amp; err 1 &quot;doflist: no flist&quot;
	while read page ; do
		dopage &quot;${flist}&quot; &quot;${page}&quot;
	done &lt; &quot;${flist}&quot;
}

for flist in &quot;$@&quot; ; do
	doflist &quot;${flist}&quot;
done
</string>
    </contents>
    <universal-time>
      <integer>3478193048</integer>
    </universal-time>
    <channel>
      <string>None</string>
    </channel>
    <colorization-mode>
      <string>None</string>
    </colorization-mode>
    <maybe-spam>
      <null/>
    </maybe-spam>
    <is-unicode>
      <keyword>TRUE</keyword>
    </is-unicode>
    <deletion-requested>
      <null/>
    </deletion-requested>
    <deletion-requested-email>
      <null/>
    </deletion-requested-email>
    <expiration-time>
      <null/>
    </expiration-time>
  </paste>
</paste-with-annotations>
