W3C home > Mailing lists > Public > www-lib@w3.org > April to June 2001

Re: multiple URL call using HTLoadToFile()

From: <Timo.Ross@ic3s.de>
Date: Thu, 31 May 2001 09:48:01 +0200
To: "Thorsten Rinkenberger" <rinkenberger@falkag.de>
Cc: www-lib@w3.org
Message-ID: <OF2E62F232.2384545E-ONC1256A5D.00287C50@ic3s.de>

Hi!

I think you have to do all request before you jump in the deep,dark hole of
the "eventloop". If you go into the "eventloop" you loose control of the
programm. But its important to know that the "terminate_handler" is called
immediatly after every request is done, so you can't terminate the library.

Hope this will help you!

Also, greetings from Germany ....
Timo!



                                                                                                                   
                    "Thorsten                                                                                      
                    Rinkenberger"         To:     <www-lib@w3.org>                                                 
                    <rinkenberger@        cc:     (bcc: Timo Ross/IC3S)                                            
                    falkag.de>            Subject:     multiple URL call using HTLoadToFile()                      
                    Sent by:                                                                                       
                    www-lib-reques                                                                                 
                    t@w3.org                                                                                       
                                                                                                                   
                                                                                                                   
                    30.05.2001                                                                                     
                    14:53                                                                                          
                                                                                                                   
                                                                                                                   




Hi,
I have a little question concerning the w3c-libwww library and I'll be very
grateful if
one of you out there would be so kind and find some time to help me. Until
now
I'm not very known in web programming. But currently I'm writing a small C
program
in which I try to call several URL's. To call the URL's I use
HTLoadToFile(url, request,file) and  HTEventList_loop(request).
At last the terminate handler I defined with  HTNet_addAfter(...) is
called.
All this works fine when I call only one URL. But I like to call several
URL's in a while() loop. In my current
program version the terminate handler will be executed already after the
first URL
was called. How can I place all my requests in the event loop before the
terminate handler is called? Below you can find the related parts
of my source code.

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

int InitW3CLib()
{
    HTLibInit(APP_NAME,APP_VERSION);
if (HTLib_isInitialized() == YES)
  return 0;
else
  return -1;
}

int CallURL(char* strURL)
{
HTRequest* request = NULL;
BOOL state = NO;

HTProfile_newNoCacheClient(APP_NAME, APP_VERSION);
HTNet_addAfter(TerminateHandler,NULL,NULL,HT_ALL,HT_FILTER_LAST);

    while (...condition...)
{
  HTHost_setEventTimeout(10000);
  request = HTRequest_new();
  if (request == NULL)
   return -1;
  state = HTLoadToFile(strURL, request, file);
  if (state != YES)
   return -1;
     HTEventList_loop(request);
     // AFTER THIS (i.e. AFTER THE FIRST CALL) THE TERMINATE HANDLER IS
CALLED IMEDIATELY
}
return 0;
}

int main(int argc, char *argv[])
{
...

if (InitW3CLib() != 0)
  exit -1;

CallURL(strURL);

exit (0);
}


I hope one of you will find some time to give
me a useful hint. Many many thanks in advance.
Greetings from Germany ...

Best regards
Thorsten
Received on Thursday, 31 May 2001 03:48:32 GMT

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