📄 draino.c
字号:
#ifdef lintstatic char *sccsid = "@(#)draino.c 4.1 (ULTRIX) 7/2/90";#endif lint/* * Code for various kinds of delays. Most of this is nonportable and * requires various enhancements to the operating system, so it won't * work on all systems. It is included in curses to provide a portable * interface, and so curses itself can use it for function keys. */#include "curses.ext"#include <signal.h>#define NAPINTERVAL 100#define HZ 60/* From early specs - this may change by 4.2BSD */struct _timeval { long tv_sec; long tv_usec;};/* * Wait until the output has drained enough that it will only take * ms more milliseconds to drain completely. * Needs Berkeley TIOCOUTQ ioctl. Returns ERR if impossible. */intdraino(ms)int ms;{ int ncthere; /* number of chars actually in output queue */ int ncneeded; /* number of chars = that many ms */ int rv; /* ioctl return value */#ifdef TIOCOUTQ# define _DRAINO /* 10 bits/char, 1000 ms/sec, baudrate in bits/sec */ ncneeded = baudrate() * ms / (10 * 1000); for (;;) { ncthere = 0; rv = ioctl(cur_term->Filedes, TIOCOUTQ, &ncthere);#ifdef DEBUG fprintf(outf, "draino: rv %d, ncneeded %d, ncthere %d\n", rv, ncneeded, ncthere);#endif if (rv < 0) return ERR; /* ioctl didn't work */ if (ncthere <= ncneeded) { return 0; } napms(NAPINTERVAL); }#endif#ifdef TCSETAW# define _DRAINO /* * USG simulation - waits until the entire queue is empty, * then sets the state to what it already is (e.g. no-op). * Unfortunately this only works if ms is zero. */ if (ms <= 0) { /* ioctl(cur_term->Filedes, TCSETAW, cur_term->Nttyb); */ return OK; }#endif#ifndef _DRAINO /* No way to fake it, so we return failure. */ /* Used #else to avoid warning from compiler about unreached stmt */ return ERR;#endif}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -