#!/bin/bash
#
# This is not the normal parser, just the front-end for the CGI interface.
# The real CGI stuff is written in Prolog in the file online.pl.  The
# request is in online.html
#
# The RDF parser itself is just a Prolog library.  See rdf2pl.{html,pdf}.

base=@BASEDIR@
tmp=/tmp/rdf-parser-$$
export ERROR_FILE=$tmp

ulimit -t 20			# seconds CPU time limit

function error()
{ cat << _EOM_
Content-type: text/plain

Sorry, an internal error occurred.  For details, see below.

_EOM_
  cat $tmp
  rm -r $tmp
  exit 0
}

cd $base > $tmp 2>&1
@SWI@ -f none -F none -t halt \
	  -g "load_files(online,[silent(true)]),go" 2>$tmp

case $? in
    0)	rm -f $tmp
        exit 0 ;;
    *)  error ;;
esac
