# =====================================================================
# prg: generic PRG processor.
#
# Copyright (c) 2007 Carlo Strozzi
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 dated June, 1991.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
# =====================================================================

# =====================================================================
#		Local variables and functions
# =====================================================================

cgi.prgurl = ()
mime_header = ()

# =====================================================================
#			Main program
# =====================================================================

csaGetArgs GET

cgi.prgurl = $CSA_SESSION(5)^-prg

~ $REMOTE_ADDR 192.168.1.2 && csaExit.env

# Only TagURI format is acceptable in CSA_RPC_GUID value for PRG.

if (!~ $'cgi.prgurl' tag:* || ~ $'cgi.prgurl' */*) {
   csaExit.fault 0041 cgi.prgurl
}

csaIsFullPath --exists $TMPDIR/$'cgi.prgurl' || csaExit.fault 1005

csaTrapFile $TMPDIR/$'cgi.prgurl'

# Note: I use '--has-header' to tell csaExit.bdata that the response
# already contains a minimal response header, namely Content-Length,
# Content-Type and possibly others.

csaExit.bdata --has-header $TMPDIR/$'cgi.prgurl'

# End of program.
