pty.cc

来自「一个mips虚拟机非常好代码,使用C++来编写的,希望大家多学学,」· CC 代码 · 共 59 行

CC
59
字号
#define _GNU_SOURCE#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include <ioqueue.hh>#include <termios.h>#include "escc.hh"voidZilogESCC::setup_pty(void){	struct termios orig_termios;	struct termios termios;	io_fd = getpt();	if (io_fd == -1)	{		perror("getpt");		return;	}	if (grantpt(io_fd) == -1)	{		perror("grantpt");		return;	}	if (unlockpt(io_fd) == -1)	{		perror("unlockpt");		return;	}	msg("Channel B on %s", ptsname(io_fd));	if (tcgetattr(io_fd, &orig_termios) != -1) {		termios = orig_termios;		termios.c_iflag &= ~(INLCR|ICRNL);		termios.c_lflag &= ~(ICANON|ECHO);		tcsetattr(io_fd, TCSANOW, &termios);	}	ioqueue->insert(this);}voidZilogESCC::io_poll(){	int len;	char c;	len = ::read(io_fd, &c, 1);	if (len > 0)		input((int)c, ChannelB);}

⌨️ 快捷键说明

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