termios.c
来自「俄罗斯高人Mamaich的Pocket gcc编译器(运行在PocketPC上)」· C语言 代码 · 共 122 行
C
122 行
#include <unistd.h>#include <stdio.h>#include <errno.h>#include <sys/termios.h>#include <sys/keycode.h>inttcsetattr(int fd, int flags, struct termios *tio){ if (tio == NULL) { errno = EINVAL; return(-1); } return(ioctl(fd, TCSETA, tio));}inttcgetattr(int fd, struct termios *tio){ if (tio == NULL) { errno = EINVAL; return(-1); } return(ioctl(fd, TCGETA, tio));}int tcflow(int fd, int action){ return(0);}intcfgetispeed(struct termios *t){ /* these are normally in c_cflag */ return B38400;}intcfgetospeed(struct termios *t){ return B38400;}intcfsetispeed(struct termios *t, int speed){ return 0;}intcfsetospeed(struct termios *t, int speed){ return 0;}int_termios_cookout(void *dest, void *src, int *ncopy, struct termios *tptr){ char c, *destcp, *srccp; int copied; int nread = 0; srccp = (char *) src; destcp = (char *) dest; copied = 0; while (copied < *ncopy) { c = *srccp; switch (c) { case '\n': if (tptr->c_oflag & ONLCR) { *destcp = '\r'; destcp++; copied++; } break; case K_DEL: if (tptr->c_oflag & OPOST) { *destcp = K_BS; destcp++; *destcp = ' '; destcp++; c = K_BS; copied += 2; } break; default: } *destcp = c; destcp++; copied++; srccp++; nread++; } if (copied > *ncopy) { *ncopy = copied; } return(nread);}int_termios_echo(int echofd, char *buf, int len, struct termios *tptr, void *echocxt){ if (tptr->c_lflag & ECHO) { _fifo_write(NULL, echofd, buf, len, echocxt); } return(0);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?