Annotation of Amaya/amaya/AHTEvntrg.h, revision 1.1

1.1     ! cvs         1: /*                                         W3C Reference Library libwww Default Event Manager
        !             2:                                   DEFAULT EVENT MANAGER
        !             3:                                              
        !             4:  */
        !             5: /*
        !             6: **      (c) COPYRIGHT MIT 1995.
        !             7: **      Please first read the full copyright statement in the file COPYRIGH.
        !             8: */
        !             9: /*
        !            10: 
        !            11:    This module provides an event registry and a multi-threaded event loop. An application
        !            12:    may use this module for:
        !            13:    
        !            14:       event loop and registry - Application registers HTEvntrg_register and
        !            15:       HTEvntrg_unregister and calls HTEventrg_loop to dispatch events as they occur.
        !            16:       
        !            17:       event registry - Application just registers its own event handlers and chains them
        !            18:       to HTEvntrg_register and HTEvntrg_unregister. When the application's event loop gets
        !            19:       activity on a socket, it calls HTEvent_dispatch to handle it.
        !            20:       
        !            21:       nothing - Application registers its own event handler uses its own event loop to
        !            22:       dispatch those events.
        !            23:       
        !            24:    This module is implemented by HTEvntrg.c, and it is a part of the W3C Reference
        !            25:    Library.
        !            26:    
        !            27:  */
        !            28: #ifndef HTEVNTRG_H
        !            29: #define HTEVNTRG_H
        !            30: 
        !            31: #include "sysdep.h"
        !            32: #include "HTEvent.h"
        !            33: #include "HTReq.h"
        !            34: /*
        !            35: 
        !            36:   Windows Specific Handles
        !            37:   
        !            38:  */
        !            39: #if defined(WWW_WIN_ASYNC) || defined(WWW_WIN_DLL)
        !            40: extern BOOL HTEventrg_winHandle (HTRequest * request);
        !            41: extern BOOL HTEventrg_setWinHandle (HWND window, unsigned long message);
        !            42: extern HWND HTEventrg_getWinHandle (unsigned long * pMessage);
        !            43: extern LRESULT CALLBACK AsyncWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam
        !            44: );
        !            45: #endif
        !            46: /*
        !            47: 
        !            48: EVENT REAGISTRY
        !            49: 
        !            50:    The libwww's event registry binds a socket and operation (FD_READ, FD_WRITE...) to a
        !            51:    callback function. Event are registered, unregistered, and dispatched.
        !            52:    
        !            53:   Register an Event Handler
        !            54:   
        !            55:    For a given socket, reqister a request structure, a set of operations, a
        !            56:    HTEventCallback function, and a priority. For this implementation, we allow only a
        !            57:    single HTEventCallback function for all operations. and the priority field is ignored.
        !            58:    
        !            59:  */
        !            60: extern int HTEventrg_register   (SOCKET, HTRequest *,
        !            61:                                  SockOps, HTEventCallback *,
        !            62:                                  HTPriority);
        !            63: /*
        !            64: 
        !            65:   Unregister an Event Handler
        !            66:   
        !            67:    Remove the registered information for the specified socket for the actions specified in
        !            68:    ops. if no actions remain after the unregister, the registered info is deleted, and, if
        !            69:    the socket has been registered for notification, the HTEventCallback will be invoked.
        !            70:    
        !            71:  */
        !            72: extern int HTEventrg_unregister (SOCKET, SockOps);
        !            73: /*
        !            74: 
        !            75:   Unregister ALL Event Handlers
        !            76:   
        !            77:    Unregister all sockets. N.B. we just remove them for our internal data structures: it
        !            78:    is up to the application to actually close the socket.
        !            79:    
        !            80:  */
        !            81: extern int HTEventrg_unregisterAll (void);
        !            82: /*
        !            83: 
        !            84:   Register a TTY Event Handler
        !            85:   
        !            86:    Register the tty (console) as having events. If the TTY is select()-able (as is true
        !            87:    under Unix), then we treat it as just another socket. Otherwise, take steps depending
        !            88:    on the platform. This is the function to use to register user events!
        !            89:    
        !            90:  */
        !            91: extern int HTEventrg_registerTTY        (SOCKET, HTRequest *, SockOps,
        !            92:                                  HTEventCallback *, HTPriority);
        !            93: /*
        !            94: 
        !            95:   Unregister a TTY Event Handler
        !            96:   
        !            97:    Unregisters TTY I/O channel. If the TTY is select()-able (as is true under Unix), then
        !            98:    we treat it as just another socket.
        !            99:    
        !           100:  */
        !           101: extern int HTEventrg_unregisterTTY (SOCKET, SockOps);
        !           102: /*
        !           103: 
        !           104:   HTEventrg_dispatch
        !           105:   
        !           106:    Dispatches a callback based on the socket and operation (read/write/oob)
        !           107:    
        !           108:  */
        !           109: extern int HTEventrg_dispatch( SOCKET, SockOps);
        !           110: /*
        !           111: 
        !           112: HANDLER FOR TIMEOUT ON SOCKETS
        !           113: 
        !           114:    This function sets the timeout for sockets in the select()call and registers a timeout
        !           115:    function that is called if select times out. This does only works on NON windows
        !           116:    platforms as we need to poll for the console on windows If tv = NULLthen timeout is
        !           117:    disabled. Default is no timeout. If always=YESthen the callback is called at all times,
        !           118:    if NO then only when Library sockets are active. Returns YES if OK else NO.
        !           119:    
        !           120:  */
        !           121: typedef int HTEventTimeout (HTRequest *);
        !           122: 
        !           123: extern BOOL HTEventrg_registerTimeout (struct timeval *tp, HTRequest * request,
        !           124:                                      HTEventTimeout *tcbf, BOOL always);
        !           125: /*
        !           126: 
        !           127: EVENT LOOP
        !           128: 
        !           129:    The libwww's default event loop dispatches events to the event registry.
        !           130:    
        !           131:   Start and Stop the Event Manager
        !           132:   
        !           133:  */
        !           134: extern BOOL HTEventInit (void);
        !           135: extern BOOL HTEventTerminate (void);
        !           136: /*
        !           137: 
        !           138:   Start the Event Loop
        !           139:   
        !           140:    That is, we wait for activity from one of our registered channels, and dispatch on
        !           141:    that. Under Windows/NT, we must treat the console and sockets as distinct. That means
        !           142:    we can't avoid a busy wait, but we do our best.
        !           143:    
        !           144:  */
        !           145: extern int HTEventrg_loop (HTRequest * request);
        !           146: /*
        !           147: 
        !           148:   Stop the Event Loop
        !           149:   
        !           150:    Stops the (select based) event loop. The function does not guarantee that all requests
        !           151:    have terminated. This is for the app to do
        !           152:    
        !           153:  */
        !           154: extern void HTEventrg_stopLoop (void);
        !           155: 
        !           156: 
        !           157: /*
        !           158: ** __RetrieveCBF
        !           159: ** given a socket, return the HTEventCallback function registered for it
        !           160: ** and return the HTRequest pointer associated with it.
        !           161: ** If the socket isn't found, the function returns NULL
        !           162: */
        !           163: 
        !           164: /* JK: 15/oct/96: Made this function public */
        !           165: 
        !           166: extern HTEventCallback *__RetrieveCBF(SOCKET s, SockOps ops,HTRequest **arp);
        !           167: 
        !           168: 
        !           169: #endif /* HTEVENTRG_H */
        !           170: /*
        !           171: 
        !           172:    
        !           173:    ___________________________________
        !           174:    
        !           175:                              @(#) $Id: HTEvntrg.h,v 1.3 1996/10/15 13:40:32 cvs Exp $
        !           176:                                                                                           
        !           177:     */

Webmaster