- From: Manish Ballav <mballav@hotmail.com>
- Date: Sun, 08 Jul 2001 17:11:48 -0700
- To: www-lib@w3.org
Hi,
I have successfully compiled and installed the libwww on solaris 7. I have
even run "chunk.c" without any problems, but when I wrote my own application
in C++ which has a download routine containing the exact same lines from
chunk.c, it core dumps. I am including the code and a trace from the
debugger. Seems like a memory problem, but I have no clue why...
Please help.
Thanks,
Manish
PS: Please send a copy to this my hotmail address as well as I am not a
subscriber yet....
------------------------ backtrace from gdb ------------------------
#0 0xfeec5558 in _smalloc () from /usr/lib/libc.so.1
#1 0xfeec559c in malloc () from /usr/lib/libc.so.1
#2 0xfeeb9c20 in calloc () from /usr/lib/libc.so.1
#3 0xff0a4570 in HTMemory_calloc (nobj=1, size=24) at HTMemory.c:88
#4 0xff143fec in HTStreamToChunk (request=0x2a7b0, chunk=0xffbef93c,
max_size=0) at HTSChunk.c:121
#5 0xff2d75bc in HTLoadToChunk (
url=0x30748 "http://www.eecs.umich.edu/~aprakash/585/index.html",
request=0x2a7b0) at HTAccess.c:188
#6 0x137dc in HttpDownloader::download (this=0x2a3b0,
remotefilename=0x18428 "/~aprakash/585/index.html",
localfile=0x18448 "index.html") at http.cpp:58
------------------------ C++ Code ----------------------------------
#include "WWWLib.h"
#include "WWWHTTP.h"
#include "WWWInit.h"
#include "downloader.h"
#include "http.h"
#include "global.h"
HttpDownloader::HttpDownloader(char *hostname) {
this->host = hostname;
}
int HttpDownloader::download(char *remotefilename, char *localfile) {
HTRequest * request = HTRequest_new();
HTChunk * chunk = NULL;
/* Initialize libwww core */
HTProfile_newPreemptiveClient("TestApp", "1.0");
/* Gotta set up our own traces */
HTPrint_setCallback(printer);
HTTrace_setCallback(tracer);
/* Turn on TRACE so we can see what is going on */
#if 1
HTSetTraceMessageMask("sop");
#endif
char * url1;
url1 = new char[sizeof(this->host) + sizeof(remotefilename) + 10];
strcpy(url1, "http://");
strcat(url1, this->host);
strcat(url1, remotefilename);
char *url = strdup(url1);
printf("URL = %s\n", url);
/* We want raw output including headers */
HTRequest_setOutputFormat(request, WWW_RAW);
/* Close connection immediately */
HTRequest_addConnection(request, "close", "");
/* Add our own filter to handle termination */
// HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST);
if (url) {
char * cwd = HTGetCurrentDirectoryURL();
// char * absolute_url = HTParse(url, cwd, PARSE_ALL);
printf("check 4 cwd = %s, url = %s\n", cwd, url);
if (!request)
printf("Ha Ha\n");
chunk = HTLoadToChunk(url, request);
printf("check 4\n");
// HT_FREE(absolute_url);
HT_FREE(cwd);
/* If chunk != NULL then we have the data */
if (chunk) {
char * string;
/* Go into the event loop... */
HTEventList_loop(request);
/* print the chunk result */
string = HTChunk_toCString(chunk);
HTPrint("%s", string ? string : "no text");
HT_FREE(string);
}
} else {
HTPrint("Type the URL you want to accces on the command line\n");
}
/* Clean up the request */
HTRequest_delete(request);
/* Terminate the Library */
HTProfile_delete();
return 0;
}
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com
Received on Sunday, 8 July 2001 20:12:19 UTC