/* ** (c) COPYRIGHT CERN 1994. ** Please first read the full copyright statement in the file COPYRIGH. */This module is the application interface to the multi-threaded functionality in the Library. It contains a set of functions that the application can either use as are or they can be overwritten by the application. If the current implementation is kept, then the mode is called Active Mode of the multi-threaded model. If they are overwritten then it is called the Passive Mode implementation.
This module is implemented by HTEvent.c, and it is a part of the Library of Common Code.
Note: No matter of the mode used (active or passive) the module uses a set of call-back functions. The definition of these modules are for the application to provide.
The basic elements in the model are:
select
function
HTEventHandler
HTEventRegister
HTEventRequestTerminate
call-back
function to react to the result of the request.
HTEventLoop
with parameters to load the home
document.
#ifndef HTEVENT_H #define HTEVENT_H #include "HTAccess.h"
The appplication registers a set of event handlers to be used on a specified set of sockets. The eventhandlers must be defined as follows:
typedef enum _HTEventState { EVENT_OK = 0, EVENT_INTR, /* Interrupt the active thread */ EVENT_INTR_ALL, /* Interrupt all registered threads */ EVENT_TERM, /* Force a call to HTEventRequestTerminate() */ EVENT_QUIT /* QUIT eventloop */ } HTEventState; typedef HTEventState (*HTEventHandler) PARAMS((HTRequest ** request)); typedef struct _HTEventCallBack { int sockfd; HTEventHandler callback; } HTEventCallBack;
extern BOOL HTEventRegister PARAMS((HTEventCallBack * user_socket));
extern void HTEventCleanup NOPARAMS;When
select
returns one of the sockets registered for
user events, for example STDIN, as ready for READ then a function of
type HTEventHandler
is called to figure out what to do
with the event. As mentioned, it is for the client to implement these
functions, but the return codes must be as defined by
HTEventState
. The client can use the load functions directly described in HTAccess Module from within any of the functions registered.
When the library calls the application the request field always contains the current request structure. The library reacts to the return value of the eventhandler.
This function is a callback function to the client to tell the result
of a terminated request. The functionality is the same as for one of
the EventHandler
functions. The status code passed to the
application is equivalent to the set of codes defined for the load functions in HTAccess.
extern HTEventState HTEventRequestTerminate PARAMS((HTRequest * request, int status));This function can be used to update the history list, hotlist etc.
extern int HTEventLoop PARAMS((HTRequest * homerequest, HTParentAnchor * homeanchor, CONST char * homekeywords)); #endif /* HTEvent_H */End of interface definition module