Annotation of libwww/Library/src/HTEvent.c, revision 2.3.2.2

2.1       eric        1: /*                                                                  HTEvntrg.c
                      2: **     EVENT DISPATCHER
                      3: **
                      4: **     (c) COPYRIGHT MIT 1996.
                      5: **     Please first read the full copyright statement in the file COPYRIGH.
2.3.2.2 ! eric        6: **      @(#) $Id: HTEvent.c,v 2.3.2.1 1996/10/29 21:26:46 eric Exp $
2.1       eric        7: **
                      8: **     The event dispatcher allows applications to register their own event
                      9: **     models. They may register the standard HTEventrg methods from 
                     10: **     HTEventrg.c, of implement their functionality with their on methods.
                     11: **
                     12: ** Authors:
                     13: **     EGP     Eric Gordon Prud'hommeuax
                     14: ** Bugs
                     15: **
                     16: */
                     17: 
                     18: /* Implementation dependent include files */
                     19: #include "sysdep.h"
2.2       frystyk    20: #include "WWWUtil.h"
2.1       eric       21: #include "HTEvent.h"                                    /* Implemented here */
                     22: 
2.2       frystyk    23: PRIVATE HTEvent_registerCallback * RegisterCBF = NULL;
                     24: PRIVATE HTEvent_unregisterCallback * UnregisterCBF = NULL;
2.1       eric       25: 
                     26: PUBLIC void HTEvent_setRegisterCallback(HTEvent_registerCallback * registerCBF)
                     27: {
2.2       frystyk    28:     if (CORE_TRACE) HTTrace("Event....... registering %p\n", registerCBF);
2.1       eric       29:     RegisterCBF = registerCBF;
                     30: }
                     31: 
                     32: PUBLIC void HTEvent_setUnregisterCallback(HTEvent_unregisterCallback * unregisterCBF)
                     33: {
2.2       frystyk    34:     if (CORE_TRACE) HTTrace("Event....... registering %p\n", unregisterCBF);
2.1       eric       35:     UnregisterCBF = unregisterCBF;
                     36: }
                     37: 
2.3.2.2 ! eric       38: PUBLIC int HTEvent_unregister (SOCKET s, HTEventType type)
2.1       eric       39: {
2.3.2.1   eric       40:     if (!UnregisterCBF) {
2.2       frystyk    41:        if (CORE_TRACE) HTTrace("Event....... No handler registered\n");
2.1       eric       42:         return -1;
2.2       frystyk    43:     }
2.3.2.1   eric       44:     return (*UnregisterCBF)(s, type);
2.1       eric       45: }
                     46: 
2.3.2.2 ! eric       47: PUBLIC int HTEvent_register(SOCKET s, HTEventType type, HTEvent * event)
2.1       eric       48: {
2.3.2.1   eric       49:     if (!RegisterCBF) {
2.2       frystyk    50:        if (CORE_TRACE) HTTrace("Event....... No handler registered\n");
2.1       eric       51:         return -1;
2.2       frystyk    52:     }
2.3.2.1   eric       53:     return (*RegisterCBF)(s, type, event);
                     54: }
                     55: 
                     56: PUBLIC BOOL HTEvent_setCallback(HTEvent * event, HTEventCallback * cbf)
                     57: {
                     58:     if (!event) return NO;
                     59:     event->cbf = cbf;
                     60:     return YES;
                     61: }
                     62: 
                     63: PUBLIC BOOL HTEvent_setParam(HTEvent * event, void * param)
                     64: {
                     65:     if (!event) return NO;
                     66:     event->param = param;
                     67:     return YES;
                     68: }
                     69: 
                     70: PUBLIC BOOL HTEvent_setPriority(HTEvent * event, HTPriority priority)
                     71: {
                     72:     if (!event) return NO;
                     73:     event->priority = priority;
                     74:     return YES;
2.1       eric       75: }
                     76: 

Webmaster