#!/bin/sh

. ./paths

# print headers
echo 'Content-Type: text/xml'
echo 'Cache-control: no-cache'
echo 'Cache-control: no-store'
echo 'Pragma: no-cache'
echo 'Expires: 0'
echo ''


# ARGUMENTS:


# print XML
echo '<?xml version="1.0" encoding="ISO-8859-1"?>'
echo '<result>'

relookrun=`ps | grep $PATH_RELOOKAPP | wc -l`
if [ $relookrun -le 1 ] 
then 
  echo ''
else

  # Channelname
  echo web_get_cur_ch > /dev/commander
  data=`$PATH_WWW/cgi-bin/read_weboutput`
  	if [ `echo $data | awk '{print $1}'` = "CUR_CH" ]
  	then
  	cur_ch=`echo $data | awk '{gsub(/&/,"\\&amp;");	gsub(/>/,"\\&gt;"); gsub(/</,"\\&lt;"); print $2," ", $3," ", $4," ", $5," ", $6}'` 
  	echo '<cur_channelname>'
  	echo $cur_ch
  	echo '</cur_channelname>'
  
  	fi
  
  # EPG data
  echo web_get_cur_epg > /dev/commander
  data=`$PATH_WWW/cgi-bin/read_weboutput`
      if [ `echo $data | awk '{print $1}'` = "CUR_EPG" ]
      then
      cur_epg=`echo $data | awk '{gsub(/&/,"\\&amp;");	gsub(/>/,"\\&gt;"); gsub(/</,"\\&lt;"); print $2," ",$3," ", $4," ", $5," ", $6}'`
      echo '<cur_progname>'
      echo $cur_epg
      echo '</cur_progname>'
  fi

fi

echo '</result>'



