From jan@swi.psy.uva.nl Thu Jun  7 22:25:55 2001
Received: from gollem.swi.psy.uva.nl (root@gollem [145.18.152.30])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f57KPt317404;
	Thu, 7 Jun 2001 22:25:55 +0200 (MET DST)
Received: (from jan@localhost)
	by gollem.swi.psy.uva.nl (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) id f57KPsx12382;
	Thu, 7 Jun 2001 22:25:54 +0200
Date: Thu, 7 Jun 2001 22:25:54 +0200
From: Jan Wielemaker <jan@swi.psy.uva.nl>
Message-Id: <200106072025.f57KPsx12382@gollem.swi.psy.uva.nl>
dFrom: Jan Wielemaker <jan>
Subject: Re: [SWIPL] eof_action of current input stream
To: "Michael A. Covington" <mc@ai.uga.edu>, <prolog@swi.psy.uva.nl>
In-Reply-To: Michael A. Covington's message of Thu, 7 Jun 2001 15:20:53 -0400
Phone: +31 - 20 - 525 6121

> OK, another question relating to CGI scripting.
> 
> I've got SWI Prolog 4.05 running as a CGI script engine under Windows 2000's
> web server.  So far so good.
> 
> Now I'm trying to get input into it using the POST method (i.e., standard
> input).
> 
> Windows sends it a string that does not end with an end-of-line mark.

No, but as far as I know, CGI's are passed the environment variable
CONTENT_LENGTH, indicating the number of bytes you must read from the
standard input.

I've just extended set_stream/2 to allow controlling the buffering
of open streams, but it appears it would be a good idea to add some
more (binary/text mode, eof_action).

> And the eof_action for console input is eof_action(reset), so I can't detect
> the end-of-file condition -- instead, SWI Prolog waits forever for more
> characters to be typed.

You can still detect the end-of-file, as it returns -1.  

	--- Jan

P.s.	The libc package contains cgi.c.  In my internal release I've
	added this to the standard suite for Windows too (it was already
	in the Unix version).  If you want I can send you the DLL (it
	hasn't really been tested on Windows I'm afraid).

