- From: Rob DeMillo <demillo@avs.com>
- Date: Wed, 23 Oct 1996 15:14:30 -0400
- To: www-lib@w3.org
Hi.
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()
function.
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");
WWWTRACE = SHOW_CORE_TRACE + SHOW_STREAM_TRACE + SHOW_PROTOCOL_TRACE;
// Initialize alerts and MIME stuff
HTAlertInit();
HTMIMEInit();
request = HTRequest_new();
if (argc == 3) {
url = calloc(strlen(argv[1]), sizeof(char));
filename = calloc(strlen(argv[2]), sizeof(char));
strcpy(url,argv[1]);
strcpy(filename,argv[2]);
} 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",
NULL,
1.0, 0.0, 0.0);
HTConversion_add(converters, "*/*", "application/octet-stream",
NULL,
1.0, 0.0, 0.0);
HTConversion_add(converters, "*/*", "www/debug",
NULL,
1.0, 0.0, 0.0);
HTEventInit();
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);
HTFormat_setConversion(converters);
HTAlert_add(HTPrompt, HT_A_PROMPT);
if (url && *url && filename && *filename)
HTLoadToFile(url, request, filename);
else
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