iflush.c

来自「异步通讯C语言例行子程序」· C语言 代码 · 共 35 行

C
35
字号
/* A module of ASYNCx.LIB version 1.20 */

#include <dos.h>
#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) */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?