conftufr.cc

来自「C++写的一个邮件pop3.smtp」· CC 代码 · 共 37 行

CC
37
字号
/* configuration du terminal en non-bloquant et mode flot   (non-canonique). conformite aux normes posix : ici   utilisation de tcgetattr() et tcsetattr(). */#include <iostream.h>#include <stdio.h> // pour perror()#include <fcntl.h>   /* pour non bloquant */#include <sys/termios.h> /* pour mode non-canonique : "flot" de car. */#include <unistd.h>#include <stdlib.h>//#include <errno.h>int  retrd, fini; /* retour de read et fin d'E-S */int fcntl1, fcntl2; /* retours de fcntl()*/int rettc;   /* retour tcset et tcget */char c;struct termios etatermi, etatermj; /* etat du terminal - cf stty par exemple */main (){/* on positionne stdin en non bloquant. recuperation de la config   courante  d'abord. Ensuite passage en non bloquant. */    fcntl1=fcntl(0,F_GETFL);     fcntl2=fcntl(0,F_SETFL,O_NONBLOCK);/* on se met en mode canonique et-ou en mode sans   echo pour ne pas afficher les cars. tapes : 3 etapes.   1. recuperation 閠at courant*/   rettc=tcgetattr(0,&etatermi);   if (rettc != 0){ perror("pb sur tcgetattr"); exit(1); }/* deuxieme 閠ape : on sauvegarde dans etatermj le partie qu'on va   modifier, puis modification  de l'etat actuel */   etatermj.c_lflag = etatermi.c_lflag;   //pour mode non canonique   //etatermi.c_lflag &= ~ICANON;   //pour masquer la frappe des cars.   etatermi.c_lflag &= ~ECHO;/* Grosse difficult

⌨️ 快捷键说明

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