⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ungetc.c

📁 异步通讯C语言例行子程序
💻 C
字号:
/* A module of ASYNCx.LIB version 1.20 */

#include <dos.h>
#include "asyncdef.h"

/*
** Place the character c into the input buffer being used by p so that
** it will be the next character to be read from the port. This
** operation may be performed until the buffer is full of the characters
** that have been pushed into it. If the port cannot accept the
** character, a value of -1 is returned. Otherwise, the value of the
** character that was pushed into the port's input buffer is returned.
*/
int a_ungetc(int c,register ASYNC *p)
{byte *bp;
 if (p)
  {disable();
   bp=p->ibuftail;
   if (bp==p->ibuf)
     bp=p->ibufend-1;
   else
     bp--;
   if (bp==p->ibufhead)
    {enable();
     return -1;
    }
   else
    {*bp=(byte)c;
     p->ibuftail=bp;
     p->icount++;
    }
   enable();
   return c;
  }
 return -1;
} /* end of a_ungetc(c,p) */

⌨️ 快捷键说明

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