Re: WWW Library

Rik Turnbull writes:
 > > > 1) I take it I need to use PASSIVE mode because X windows has
 > > >    its own event loop? This means writing my own HTEventLoop()
 > > >    or HTEvent_Loop() function.  Do I have to explicitly set
 > > >    something to PASSIVE mode or is it implied?
 > > 
 > > No, as you can redirect X events to a socket, you can actually
 > > use the internal event loop in the Library (thus using ACTIVE
 > > mode). Arena is doing this and it seems to work without slowing
 > > user interactions down.
 > I wasn't aware you could redirect X events this way. 
 > ...

In case you decide to use passive mode, the answer to your original
question is that you don't need to explicitly set anything. You just
don't start the library event loop. This means, of course, that you
have to do something to make sure that library requests get processed
all the way through. 

The key thing is to ensure that request processing is continued (after
an HT_WOULD_BLOCK) when its socket becomes ready. Usually this means
adding the request's socket file descriptor to some set of file
descriptors that is maintained and checked (via select()) by your
application's event loop.

When your event loop determines that a library request's file
descriptor is now ready, it should call a procedure to continue that
request. The code that I use to do that looks like the following:

  /* This stuff is basically just stolen from HTEvent.c in the WWW lib
     and mimics part of the library's event loop. */

  callback = (HTProtocol *) HTAnchor_protocol(request->anchor);
  if (request->method == METHOD_GET ||
      request->method == METHOD_HEAD) {
    status = (*callback->load)(request);
  } else {
    return return_state_error;
  switch (status) {
  case HT_LOADED:
    HTLoadTerminate(request, status);
    return return_state_done;
    return return_state_continue;
  case HT_ERROR:
    HTLoadTerminate(request, status);
    return return_state_error;

where the return_state_XXX stuff is just my own set of internal return


Received on Wednesday, 30 August 1995 13:40:12 UTC