📄 waitquie.c
字号:
/* A module of ASYNCx.LIB version 1.10 */
#include <dos.h>
#include "asyncdef.h"
/*
** Wait for between t and t+1 18ths of a second to elapse without any
** characters arriving at port p. If max 18ths of a second elapse before
** a gap in the incomming data of t 18ths of a second has been found, a
** value of -1 is returned. If the gap is found within max 18ths of a
** second, a value of 0 is returned. If mode is set to 0, any characters
** that do arrive during the execution of this routine are discarded and
** the input buffer for the port p is empty when this routine returns.
** If mode is set to 1, characters arriving at the port are detected but
** not discarded. Be careful of buffer overflow if use mode 1. If the
** input buffer overflows, the least recent data will be lost and the
** newest data will be retained.
*/
int a_waitquiet(ASYNC *p,int t,int max,int mode)
{unsigned long t0,t1,far *t2;
int count0;
if (!p)
return -1;
/*
** *t2 is the current time and is incrimented by the operating system
** 18.21 times per second.
*/
t2=(unsigned long far *)MK_FP(0x40,0x6c);
/*
** t0 is the initial time. t1 is the time at which the last character
** was received. (Assume that a character was just received.)
*/
t0=t1=*t2;
if (mode==0)
while ((*t2)-t1<=(unsigned long)t && (*t2)-t0<=(unsigned long)max)
{if (a_getc(p)!=-1) /* If another character has been received, */
t1=*t2; /* update t1. */
}
else
{count0=a_icount(p); /* count0 = # of chars in buffer */
while((*t2)-t1<=(unsigned long)t && (*t2)-t0<=(unsigned long)max)
if (a_icount(p)!=count0) /* If more characters are received */
{t1=*t2; /* update t1 and */
count0=a_icount(p); /* the character counter. */
}
}
if ((*t2)-t1>=(unsigned long)t)
return 0;
else
return -1;
} /* end of int a_waitquiet(p,t,max,mode) */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -