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

📄 getstatus.c

📁 unix高级编程源代码.<<unix高级编程>>
💻 C
字号:
#include	"lprps.h"

/* Called by main() before printing job.
 * We send a Control-T to the printer to fetch its status.
 * If we timeout before reading the printer's status, something
 * is wrong. */

void
get_status(void)
{
	char	c;

	set_alrm(5);			/* 5 second timeout to fetch status */

	tty_flush();
	c = '\024';
	block_write(&c, 1);		/* send Control-T to printer */

	init_input(0);
	while (status == INVALID)
		proc_some_input();	/* wait for something back */

	switch (status) {
	case IDLE:		/* this is what we're looking for ... */
		clear_alrm();
		return;

	case WAITING:	/* printer thinks it's in the middle of a job */
		block_write(&eofc, 1);	/* send EOF to printer */
		sleep(5);
		exit(EXIT_REPRINT);

	case BUSY:
	case UNKNOWN:
		sleep(15);
		exit(EXIT_REPRINT);
	}
}

⌨️ 快捷键说明

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