W3C home > Mailing lists > Public > www-lib@w3.org > January to March 1999

Streaming to standard output?

From: Vaclav Barta <vbar@comp.cz>
Date: Fri, 12 Feb 1999 20:10:51 +0000
Message-ID: <36C48ACB.EC3E4E8F@comp.cz>
To: wwwlib <www-lib@w3.org>
Hi,

the following is my first program using wwwlib:
=== cut ===
#include <stdio.h>

extern "C"
{
#include "wwwconf.h"
#include "WWWLib.h"
#include "HTTP.h"
#include "HTProfil.h"
#include "HTFWrite.h"
};

//#define BROKEN

int terminate_handler(HTRequest *request,
    HTResponse *response,
    void *param,
    int status)
{
    HTRequest_delete(request);
    HTProfile_delete();
    exit(status ? status : 0);
}

int main(int argc, char **argv)
{
    HTProfile_newRobot("test-spider", "0.01");
    /* Add our own filter to terminate the application */
    HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL,
HT_FILTER_LAST);

    HTRequest *request = HTRequest_new();

#ifdef BROKEN
    HTStream *output = HTFWriter_new(request,
	stdout,
	NO);
    HTLoadToStream(argc >= 2 ? argv[1] : "http://localhost/",
	output,
	request);
#else
    HTLoadToFile(argc >= 2 ? argv[1] : "http://localhost/",
	request,
	"out.txt");
#endif

    HTEventList_loop(request);

    // shouldn't get here
    return -1;
}
=== end cut ===
It works as expected (finally :-) ): GETs a page
and saves it into a local file. But when I
#define BROKEN, it doesn't work - i. e. it compiles
and runs, but produces no output. What am I doing
wrong? In case it matters, I'm running RedHat Linux
and egcs 2.91.60 (the program is compiled as C++).
I checked out the latest version of the library
(and tested my code with it) before posting.

	Bye
		Vasek
Received on Friday, 12 February 1999 15:15:39 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 23 April 2007 18:18:28 GMT