W3C home > Mailing lists > Public > www-lib@w3.org > July to September 1999

HTLoadAnchorToChunk help!!

From: Vipul Doshi <v_doshi@hotmail.com>
Date: Tue, 6 Jul 1999 16:31:06 -0400 (EDT)
Message-ID: <19990706201854.50289.qmail@hotmail.com>
To: www-lib@w3.org
Hi,
Following is sample program in Windows NT4.0 which uses libwww.
I copied most of it from chunk.c in the Examples.

// libwwwtest.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "libwwwtest.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

#include "WWWLib.h"
#include "WWWHTTP.h"
#include "WWWInit.h"
#ifdef __cplusplus
   extern "C" {            /* Start extern C declarations */
#endif
	#include "HTInit.c"
	#include "HTProfil.c"
	#include "HTBInit.c"

#ifdef __cplusplus
   }                       /* End extern C declarations */
#endif

void getdata();

/////////////////////////////////////////////////////////////////////////////
// The one and only application object

CWinApp theApp;

using namespace std;

int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
{
	int nRetCode = 0;

	// initialize MFC and print and error on failure
	if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
	{
		// TODO: change error code to suit your needs
		cerr << _T("Fatal Error: MFC initialization failed") << endl;
		nRetCode = 1;
	}
	else
	{

		HTProfile_newClient("TestApp", "1.0");

   		getdata();

		getdata();

		HTProfile_delete();

		}

	return nRetCode;
}

void getdata()
{

	HTRequest * request = HTRequest_new();
   // HTChunk * chunk = NULL;
    char * url = "http://vipul/work/AMDSfromUPC.asp";


    HTRequest_setOutputFormat(request, WWW_SOURCE);
    HTRequest_setPreemptive(request, YES);

	char * cwd = HTGetCurrentDirectoryURL();
	char * absolute_url = HTParse(url, cwd, PARSE_ALL);
	HTAnchor * anchor = HTAnchor_findAddress(absolute_url);
	HTChunk * chunk = HTLoadAnchorToChunk(anchor, request);

	HT_FREE(absolute_url);
	HT_FREE(cwd);


	if (chunk) {
	    char * string = HTChunk_toCString(chunk);

		printf("%s", string ? string : "no text");
	    HT_FREE(string);
	}


    HTFormat_deleteAll();
	HTRequest_delete(request);

}

The problem I have is that when getdata() is called second time,
the HTLoadAnchorToChunk does not return the same value as it did
the first time around? The second time around it returns some IIS
header information and not the actual data as it did the first time
around.
Also, HTProfile_delete gives access violation in HTList_addObject
functiom at line newNode->next = me->next.

I even tried to put HTProfile_newclient and HTProfile_delete inside
getdata() function, but when it getdata is called second time,
HTProfile_newclient gives an error by it calls HTLibInit. This error
is something like "Cannot Register WinAsync class" or similar.

Please help me! Am I not calling some function?

Thanks

Vipul Doshi


_______________________________________________________________
Get Free Email and Do More On The Web. Visit http://www.msn.com
Received on Wednesday, 7 July 1999 03:04:25 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:15:16 UTC