www.pudn.com > ASYNC13.rar > IFLUSH.C


/* A module of ASYNCx.LIB version 1.20 */ 
 
#include  
#include "asyncdef.h" 
 
/* 
** Discard any data that may be in p's input buffer buffer. If an XOFF 
** character has been sent, send an XON character to let the other party 
** know that we can accept characters. If an XON character should be 
** sent and the output buffer is full and we have received an XOFF 
** character, return -1. If all goes well, return 0. 
*/ 
int a_iflush(register ASYNC *p) 
{byte *bp; 
 if (p) 
  {if (p->sentxoff) /* send an XON character */ 
    {bp=p->obufhead; 
     *bp++=XON; 
     if (bp==p->obufend) 
       bp=p->obuf; 
     while(bp==p->obuftail) 
       if (p->recvxoff) 
         return -1; 
     p->obufhead=bp; 
     p->ocount++; 
    } 
   disable(); 
   p->ibufhead=p->ibuftail=p->ibuf; 
   enable(); 
   return 0; 
  } 
 else 
   return -1; 
} /* end of a_iflush(p) */