Diff for /Amaya/amaya/AHTBridge.c between versions 1.23 and 1.24

version 1.23, 1997/03/17 18:19:23 version 1.24, 1997/05/28 06:42:20
Line 51  static void         RequestKillExceptXte Line 51  static void         RequestKillExceptXte
   
 #endif  #endif
   
   #ifdef _WINDOWS
   static void         WIN_ResetMaxSock (void);
   static int          WIN_ProcessFds (fd_set * fdsp, SockOps ops);
   
   #endif /* _WINDOWS */
   
 /*  /*
  * Private variables    * Private variables 
  */   */
Line 67  static const SockOps ReadBits = FD_READ Line 73  static const SockOps ReadBits = FD_READ
 static const SockOps WriteBits = FD_WRITE | FD_CONNECT;  static const SockOps WriteBits = FD_WRITE | FD_CONNECT;
 static const SockOps ExceptBits = FD_OOB;  static const SockOps ExceptBits = FD_OOB;
   
   #ifdef _WINDOWS
   static fd_set read_fds, write_fds, except_fds, all_fds;
   static int maxfds;
   #endif /* _WINDOWS */
   
 /*  /*
  * Private functions   * Private functions
Line 88  static const SockOps ExceptBits = FD_OOB Line 98  static const SockOps ExceptBits = FD_OOB
   the state of the request and, if it's an asynchronous request, deletes    the state of the request and, if it's an asynchronous request, deletes
   the memory allocated to it.    the memory allocated to it.
   -------------------------------------------------------------------*/    -------------------------------------------------------------------*/
   #ifdef _WINDOWS
   static void *WIN_AHTCallback_bridge (SockOps _ops, int *s)
   #else
 #ifdef __STDC__  #ifdef __STDC__
 void *AHTCallback_bridge (caddr_t cd, int *s, XtInputId * id)  void *AHTCallback_bridge (caddr_t cd, int *s, XtInputId * id)
 #else  #else
Line 97  caddr_t             cd; Line 109  caddr_t             cd;
 int                *s;  int                *s;
 XtInputId          *id;  XtInputId          *id;
 #endif /* __STDC__ */  #endif /* __STDC__ */
   #endif /* _WINDOWS */
 {  {
    int                 status;  /* the status result of the libwwww call */     int                 status;  /* the status result of the libwwww call */
    HTRequest          *rqp = NULL;     HTRequest          *rqp = NULL;
Line 134  XtInputId          *id; Line 147  XtInputId          *id;
         return (0);          return (0);
      }       }
   
 #ifndef _WINDOWS  #ifdef _WINDOWS
      ops = _ops;
   #else
    switch ((XtInputId) cd)     switch ((XtInputId) cd)
          {           {
             case XtInputReadMask:              case XtInputReadMask:
Line 152  XtInputId          *id; Line 167  XtInputId          *id;
          default:           default:
            break;             break;
          }                      /* switch */           }                      /* switch */
 #endif /* !_WINDOWS */  #endif /* _WINDOWS */
   
      /* Invokes the callback associated to the requests */       /* Invokes the callback associated to the requests */
             
Line 180  XtInputId          *id; Line 195  XtInputId          *id;
     * HT_END:     Request has ended      * HT_END:     Request has ended
     */      */
   
 #ifndef _WINDOWS  
    if (me->reqStatus == HT_ABORT)     if (me->reqStatus == HT_ABORT)
    /* Has the user stopped the request? */     /* Has the user stopped the request? */
      {       {
Line 188  XtInputId          *id; Line 202  XtInputId          *id;
         StopRequest (me->docid);          StopRequest (me->docid);
         return (0);          return (0);
      }       }
 #endif /* !_WINDOWS */  
   
    if (me->reqStatus == HT_WAITING)     if (me->reqStatus == HT_WAITING)
    /* the request is being reissued */     /* the request is being reissued */
Line 363  HTPriority          p; Line 376  HTPriority          p;
         if (ops & ReadBits)          if (ops & ReadBits)
           {            {
              me->read_ops = ops;               me->read_ops = ops;
 #ifndef _WINDOWS  
              RequestRegisterReadXtevent (me, sock);               RequestRegisterReadXtevent (me, sock);
 #endif /* !_WINDOWS */  
           }            }
   
         if (ops & WriteBits)          if (ops & WriteBits)
           {            {
              me->write_ops = ops;               me->write_ops = ops;
 #ifndef _WINDOWS  
              RequestRegisterWriteXtevent (me, sock);               RequestRegisterWriteXtevent (me, sock);
 #endif /* !_WINDOWS */  
           }            }
   
         if (ops & ExceptBits)          if (ops & ExceptBits)
           {            {
              me->except_ops = ops;               me->except_ops = ops;
 #ifndef _WINDOWS  
              RequestRegisterExceptXtevent (me, sock);               RequestRegisterExceptXtevent (me, sock);
 #endif /* !_WINDOWS */  
           }            }
      }       }
   
Line 415  SockOps             ops; Line 422  SockOps             ops;
   
    HTEventCallback    *cbf = (HTEventCallback *) __RetrieveCBF (sock, (SockOps) NULL, &rqp);     HTEventCallback    *cbf = (HTEventCallback *) __RetrieveCBF (sock, (SockOps) NULL, &rqp);
   
 #ifndef _WINDOWS  
    if (cbf)     if (cbf)
      {       {
         if (rqp)          if (rqp)
Line 434  SockOps             ops; Line 440  SockOps             ops;
      }       }
   
    status = HTEventrg_unregister (sock, ops);     status = HTEventrg_unregister (sock, ops);
 #endif /* !_WINDOWS */  
    return (status);     return (status);
 }  }
   
Line 452  AHTReqContext      *me; Line 457  AHTReqContext      *me;
   
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
 #ifndef _WINDOWS  
    if (THD_TRACE)     if (THD_TRACE)
       fprintf (stderr, "Request_kill: Clearing Xtinputs\n");        fprintf (stderr, "Request_kill: Clearing Xtinputs\n");
   
    RequestKillReadXtevent (me);     RequestKillReadXtevent (me);
    RequestKillWriteXtevent (me);     RequestKillWriteXtevent (me);
    RequestKillExceptXtevent (me);     RequestKillExceptXtevent (me);
 #endif /* !_WINDOWS */  
 }  }
   
 /*----------------------------------------------------------------------  /*----------------------------------------------------------------------
Line 475  SOCKET sock; Line 478  SOCKET sock;
   
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
 #ifndef _WINDOWS  #ifdef _WINDOWS
       FD_SET (sock, &read_fds);
       FD_SET (sock, &all_fds);
       me->read_sock = sock;
   
       if (sock > maxfds) 
           maxfds = sock;
   #else
   if (me->read_xtinput_id)    if (me->read_xtinput_id)
     {      {
       if (THD_TRACE)        if (THD_TRACE)
Line 509  AHTReqContext      *me; Line 519  AHTReqContext      *me;
   
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
 #ifndef _WINDOWS  #ifdef _WINDOWS
       if(me->except_sock != INVSOC) 
           {
               FD_CLR (me->read_sock, &read_fds);
               FD_CLR (me->read_sock, &all_fds);
               me->read_sock = INVSOC;
               WIN_ResetMaxSock();
           }
   #else
    if (me->read_xtinput_id)     if (me->read_xtinput_id)
      {       {
         if (THD_TRACE)          if (THD_TRACE)
Line 533  SOCKET              sock; Line 551  SOCKET              sock;
   
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
 #ifndef _WINDOWS  #ifdef _WINDOWS
       FD_SET (sock, &write_fds);
       FD_SET (sock, &all_fds);
       me->write_sock = sock;
   
       if (sock > maxfds) 
           maxfds = sock ;
   
   #else
    if (me->write_xtinput_id)     if (me->write_xtinput_id)
     {      {
       if (THD_TRACE)        if (THD_TRACE)
Line 567  AHTReqContext      *me; Line 593  AHTReqContext      *me;
   
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
 #ifndef _WINDOWS  #ifdef _WINDOWS
       if(me->except_sock != INVSOC) 
           {
               FD_CLR (me->write_sock, &write_fds);
               FD_CLR (me->write_sock, &all_fds);
               me->write_sock = INVSOC;
               WIN_ResetMaxSock();
           }
   #else
    if (me->write_xtinput_id)     if (me->write_xtinput_id)
      {       {
         if (THD_TRACE)          if (THD_TRACE)
Line 591  SOCKET              sock; Line 625  SOCKET              sock;
   
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
 #ifndef _WINDOWS  #ifdef _WINDOWS
       FD_SET (sock, &except_fds);
       FD_SET (sock, &all_fds);
       me->except_sock = sock;
   
       if (sock > maxfds) 
           maxfds = sock ;
   #else
    if (me->except_xtinput_id)     if (me->except_xtinput_id)
      {       {
        if (THD_TRACE)         if (THD_TRACE)
Line 626  AHTReqContext      *me; Line 667  AHTReqContext      *me;
   
 #endif /* __STDC__ */  #endif /* __STDC__ */
 {  {
 #ifndef _WINDOWS  #ifdef _WINDOWS
       if(me->except_sock != INVSOC) 
           {
               FD_CLR (me->except_sock, &except_fds);
               FD_CLR (me->except_sock, &all_fds);
               me->except_sock = INVSOC;
               WIN_ResetMaxSock();
           }
   #else
    if (me->except_xtinput_id)     if (me->except_xtinput_id)
      {       {
         if (THD_TRACE)          if (THD_TRACE)
Line 637  AHTReqContext      *me; Line 686  AHTReqContext      *me;
 #endif /* !_WINDOWS */  #endif /* !_WINDOWS */
 }  }
   
   #ifdef _WINDOWS
   
   static void WIN_ResetMaxSock(void)
   {
       SOCKET s ;
       SOCKET t_max = 0;
       
       for (s = 0 ; s <= maxfds; s++) { 
           if (FD_ISSET(s, &all_fds))
               {
                   if (s > t_max)
                       t_max = s ;
               } /* scope */
       } /* for */
   
       maxfds = t_max ;
   }
   
   #ifdef __STDC__
   void         WIN_ProcessSocketActivity (void)
   #else
   void         WIN_ProcessSocketActivity ()
   #endif /* __STDC */
   {
       int active_sockets;
       SOCKET s;
       struct timeval tv;
       int exceptions, readings, writings;
       fd_set treadset, twriteset, texceptset ;    
   
       treadset = read_fds;
       twriteset = write_fds ;
       texceptset = except_fds ;  
   
       /* do a non-blocking select */
       tv.tv_sec = 0; 
       tv.tv_usec = 0;
   
       active_sockets = select(maxfds+1, &treadset, &twriteset, &texceptset, 
                                   (struct timeval *) &tv);
   
       switch(active_sockets)  {
       case 0:         /* no activity - timeout - allowed */
           return;
           break;
               
       case -1:        /* error has occurred */
           return;
           break;
   
       default:
           break;
       } /* switch */
   
       exceptions = 0;
       readings = 0;
       writings = 0;
   
       for (s = 0 ; s <= maxfds ; s++) 
           { 
               if (FD_ISSET(s, &texceptset))
                   exceptions++;
               if (FD_ISSET(s, &treadset))
                   readings++;
               if (FD_ISSET(s, &twriteset))
                   writings++;
           } /* for */
   
           if (exceptions) {
               WIN_ProcessFds (&texceptset, FD_OOB);
           }
   
           if (readings) {
               WIN_ProcessFds (&treadset, FD_READ);
           }
   
           if (writings) { 
               WIN_ProcessFds (&twriteset, FD_WRITE);
           }
   }
   
   
   static int WIN_ProcessFds( fd_set * fdsp, SockOps ops)
   {
       SOCKET s ;
   
       for (s = 0 ; s <= maxfds; s++) {
           if (FD_ISSET( s, fdsp)) 
               {
                   WIN_AHTCallback_bridge (ops, &s);
                   return;
               }
       }
       return HT_OK;
   }
   
   #endif /* _WINDOWS */
 /*  /*
   End of Module AHTBridge.c    End of Module AHTBridge.c
 */  */

Removed from v.1.23  
changed lines
  Added in v.1.24


Webmaster