Annotation of libwww/Library/src/HTEvntrg.html, revision 2.13

2.1       cbrooks     1: <HTML>
                      2: <HEAD>
2.7       frystyk     3: <TITLE>Event Manager</TITLE>
2.13    ! frystyk     4: <!-- Changed by: Henrik Frystyk Nielsen,  1-Dec-1995 -->
2.1       cbrooks     5: </HEAD>
                      6: <BODY>
                      7: 
2.7       frystyk     8: <H1>Event Manager</H1>
2.1       cbrooks     9: 
                     10: <PRE>
                     11: /*
                     12: **     (c) COPYRIGHT MIT 1995.
                     13: **     Please first read the full copyright statement in the file COPYRIGH.
                     14: */
                     15: </PRE>
                     16: 
                     17: This module is the application interface to the multi-threaded
                     18: functionality in the Library. It contains a set of functions that the
                     19: application can either use as are or they can be overwritten by the
2.7       frystyk    20: application. <P>
2.1       cbrooks    21: 
2.3       frystyk    22: This module is implemented by <A HREF="HTEvntrg.c">HTEvntrg.c</A>, and
2.7       frystyk    23: it is a part of the <A HREF="http://www.w3.org/pub/WWW/Library/">W3C
                     24: Reference Library</A>. <P>
2.1       cbrooks    25: 
                     26: <PRE>
                     27: #ifndef HTEVNTRG_H
                     28: #define HTEVNTRG_H
2.9       frystyk    29: #include "HTReq.h"
2.1       cbrooks    30: #include "tcp.h"
2.11      frystyk    31: </PRE>
                     32: 
                     33: <H2>Windows Specific Handles</H2>
                     34: 
                     35: <PRE>
2.12      frystyk    36: #if defined(WWW_WIN_ASYNC) || defined(WWW_WIN_DLL)
2.11      frystyk    37: extern BOOL HTEvent_winHandle (HTRequest * request);
                     38: extern BOOL HTEvent_setWinHandle (HWND window, unsigned long message);
2.13    ! frystyk    39: extern HWND HTEvent_getWinHandle (unsigned long * pMessage);
        !            40: extern LRESULT CALLBACK AsyncWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
2.11      frystyk    41: #endif
2.8       frystyk    42: </PRE>
                     43: 
2.7       frystyk    44: <H2>Event Handlers</H2>
2.1       cbrooks    45: 
                     46: The appplication registers a set of event handlers to be used on a
                     47: specified set of sockets. The eventhandlers must be defined as follows:
                     48: 
                     49: <PRE>
2.7       frystyk    50: typedef u_long SockOps; 
2.1       cbrooks    51: 
2.7       frystyk    52: #define FD_NONE        0
                     53: #define FD_ALL (FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | FD_CONNECT |FD_CLOSE)
                     54: #define FD_UNREGISTER (((FD_ALL) &lt;&lt; 1) & (~(FD_ALL)))
2.13    ! frystyk    55: 
        !            56: typedef enum _HTPriority {
        !            57:     HT_PRIORITY_INV = -1,
        !            58:     HT_PRIORITY_OFF = 0,
        !            59:     HT_PRIORITY_MIN = 1,
        !            60:     HT_PRIORITY_MAX = 20
        !            61: } HTPriority; 
2.1       cbrooks    62: 
2.10      frystyk    63: typedef int HTEventCallback (SOCKET, HTRequest *, SockOps);
2.1       cbrooks    64: </PRE>
                     65: 
2.7       frystyk    66: <H3>Register a TTY Event Handler</H3>
2.1       cbrooks    67: 
2.7       frystyk    68: Register the tty (console) as having events. If the TTY is
                     69: select()-able (as is true under Unix), then we treat it as just
2.8       frystyk    70: another socket. Otherwise, take steps depending on the platform. This
                     71: is the function to use to register user events!
2.1       cbrooks    72: 
                     73: <PRE>
2.7       frystyk    74: extern int HTEvent_RegisterTTY (SOCKET, HTRequest *, SockOps,
2.10      frystyk    75:                                 HTEventCallback *, HTPriority);
2.1       cbrooks    76: </PRE>
                     77: 
2.7       frystyk    78: <H3>Unregister a TTY Event Handler</H3>
                     79: 
                     80: Unregisters TTY I/O channel. If the TTY is select()-able (as is true
                     81: under Unix), then we treat it as just another socket.
2.1       cbrooks    82: 
                     83: <PRE>
2.7       frystyk    84: extern int HTEvent_UnRegisterTTY (SOCKET, SockOps);
2.1       cbrooks    85: </PRE>
                     86: 
2.7       frystyk    87: <H3>Register an Event Handler</H3>
2.1       cbrooks    88: 
2.7       frystyk    89: For a given socket, reqister a request structure, a set of operations,
2.10      frystyk    90: a HTEventCallback function, and a priority. For this implementation,
                     91: we allow only a single HTEventCallback function for all operations.
2.7       frystyk    92: and the priority field is ignored.
2.1       cbrooks    93: 
                     94: <PRE>
2.7       frystyk    95: extern int HTEvent_Register    (SOCKET, HTRequest *,
2.10      frystyk    96:                                 SockOps, HTEventCallback *,
2.7       frystyk    97:                                 HTPriority);
2.1       cbrooks    98: </PRE>
                     99: 
2.7       frystyk   100: <H3>Unregister an Event Handler</H3>
                    101: 
                    102: Remove the registered information for the specified socket for the
                    103: actions specified in ops. if no actions remain after the unregister,
                    104: the registered info is deleted, and, if the socket has been registered
2.10      frystyk   105: for notification, the HTEventCallback will be invoked.
2.1       cbrooks   106: 
                    107: <PRE>
2.7       frystyk   108: extern int HTEvent_UnRegister  (SOCKET, SockOps);
2.1       cbrooks   109: </PRE>
                    110: 
2.7       frystyk   111: <H3>Unregister ALL Event Handlers</H3>
2.1       cbrooks   112: 
2.7       frystyk   113: Unregister all sockets. N.B. we just remove them for our internal data
                    114: structures: it is up to the application to actually close the socket.
2.1       cbrooks   115: 
                    116: <PRE>
2.7       frystyk   117: extern int HTEvent_UnregisterAll (void);
2.9       frystyk   118: </PRE>
                    119: 
                    120: <H2>Handler for Timeout on Sockets</H2>
                    121: 
                    122: This function sets the timeout for sockets in the
                    123: <CODE>select()</CODE> call and registers a timeout function that is
                    124: called if select times out. This does only works on NON windows
                    125: platforms as we need to poll for the console on windows If <CODE>tv =
                    126: NULL</CODE> then timeout is disabled. Default is no timeout. If
                    127: <EM>always=YES</EM> then the callback is called at all times, if NO
                    128: then only when Library sockets are active. Returns YES if OK else NO.
                    129: 
                    130: <PRE>
                    131: typedef int HTEventTimeout (HTRequest *);
                    132: 
                    133: extern BOOL HTEvent_registerTimeout (struct timeval *tp, HTRequest * request,
                    134:                                     HTEventTimeout *tcbf, BOOL always);
2.1       cbrooks   135: </PRE>
                    136: 
2.7       frystyk   137: <H2>Eventloop</H2>
2.1       cbrooks   138: 
2.7       frystyk   139: That is, we wait for activity from one of our registered channels, and
                    140: dispatch on that. Under Windows/NT, we must treat the console and
                    141: sockets as distinct.  That means we can't avoid a busy wait, but we do
                    142: our best.
2.1       cbrooks   143: 
                    144: <PRE>
2.7       frystyk   145: extern int HTEvent_Loop (HTRequest * request);
2.1       cbrooks   146: </PRE>
                    147: 
                    148: 
                    149: <PRE>
                    150: #endif /* HTEvent_H */
                    151: </PRE>
                    152: 
2.7       frystyk   153: End of declartion module
2.1       cbrooks   154: 
                    155: </BODY>
                    156: </HTML>

Webmaster