scrinit.c

来自「tcp/ip原理的第三卷」· C语言 代码 · 共 49 行

C
49
字号
/* scrinit.c - scrinit */

#include <stdio.h>

#include "telnet.h"
#include "local.h"

extern int		scrindex;
extern struct termios	tntty;

/*------------------------------------------------------------------------
 * scrinit - initialize tty modes for script file collection
 *------------------------------------------------------------------------
 */
/*ARGSUSED*/
int
scrinit(sfp, tfp, c)
FILE	*sfp, *tfp;
int	c;
{
	struct termios	newtty;

	if (!doecho) {
		fprintf(tfp, "\nscripting requires remote ECHO.\n");
		return -1;
	}
	if (scrfp) {
		fprintf(tfp,"\nalready scripting to \"%s\".\n", scrname);
		return -1;
	}
	scrindex = 0;

	if (tcgetattr(0, &tntty))	/* save current tty settings	*/
		errexit("can't get tty modes: %s\n", sys_errlist[errno]);

	newtty = oldtty;
	newtty.c_cc[VINTR] = _POSIX_VDISABLE;	/* disable interrupt	*/
	newtty.c_cc[VQUIT] = _POSIX_VDISABLE;	/* disable interrupt	*/
	newtty.c_cc[VSUSP] = _POSIX_VDISABLE;	/* disable suspend	*/
	newtty.c_cc[VDSUSP] = _POSIX_VDISABLE;	/* disable suspend	*/

	if (tcsetattr(0, TCSADRAIN, &newtty))
		errexit("can't set tty modes: %s\n", sys_errlist[errno]);

	fprintf(tfp, "\nscript file: ");
	(void) fflush(tfp);
	return 0;
}

⌨️ 快捷键说明

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