W3C home > Mailing lists > Public > www-lib@w3.org > October to December 1996

Problems with file streams on libwww 5.0 under NT

From: Rob DeMillo <demillo@avs.com>
Date: Wed, 23 Oct 1996 15:14:30 -0400
Message-Id: <3.0b36.32.19961023151427.009aa9e0@avs.com>
To: www-lib@w3.org

My current environment is Windows NT 4.0 Workstation,
usng the MS VC++ 4.2 compiler. I have the latest
5.0 library release: 5.0a. It built without (almost)
a hitch.

I have a simple chunk of source code (included at the 
end of this message) that wants to 
open up the document at an URL and dump the contents
to a file. Its based on one of the "simple examples"
on the W3C page, and uses the nice little HTLoadToFile()

After 3/4ths of a day of monkeying around, I have
come to the conclusion that the contents of
the original file pointer opened up by HTLoadToFile() gets 
whacked somewhere along the way. Any other function that tries to 
access that file pointer (such as fwrite() in HTFWriter_write()
or fflush() in HTFWriter_flush()) causes the program 
to crash...although I cannot find where this is happening. 

Any pointers (pun intended) that could be passed my way 
would be greatly appreciated.

Thanks in advance.

_ Rob


#include <stdio.h>
#include <malloc.h>
#include <string.h>

#include "WWWLib.h"
#include "WWWInit.h"

**      Loads a URL to a local file
int main (int argc, char ** argv)
	HTList * converters = HTList_new();
     HTRequest * request;
	char *url;
	char *filename;

	HTLibInit("TestApp", "1.0");

	// Initialize alerts and MIME stuff

    request = HTRequest_new();
    if (argc == 3) {
		url = calloc(strlen(argv[1]), sizeof(char));
		filename = calloc(strlen(argv[2]), sizeof(char));
    } else {
        printf("Type the URL to fetch and the name of the local file to put
it in\n");
        printf("\t%s <url> <filename>\n", argv[0]);
	HTConversion_add(converters, "*/*", "www/present",
                     1.0, 0.0, 0.0);
    HTConversion_add(converters, "*/*", "application/octet-stream",
                     1.0, 0.0, 0.0);
    HTConversion_add(converters, "*/*", "www/debug",
                     1.0, 0.0, 0.0);
    HTTransport_add("tcp", HT_TP_SINGLE, HTReader_new, HTWriter_new);
    HTProtocol_add("http", "tcp", YES, HTLoadHTTP, NULL);
    HTConversion_add(converters, "text/x-http","*/*", HTTPStatus_new,
                     1.0, 0.0, 0.0);
    HTConversion_add(converters, "message/rfc822", "*/*", HTMIMEConvert,
                     1.0, 0.0, 0.0);
    HTAlert_add(HTPrompt, HT_A_PROMPT);

	if (url && *url && filename && *filename)
        HTLoadToFile(url, request, filename);
		printf("Bad parameters - please try again\n");

    HTRequest_delete(request);                  /* Delete the request
object */
    return 0;


Rob DeMillo		 email:     demillo@avs.com
Advanced Visual Systems  reality:   617-890-8192 x2113

URL:       http://www.tiac.net/users/demillo/persons/demillo.htm
Received on Wednesday, 23 October 1996 15:13:21 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:33:47 UTC