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

📄 keyio.c

📁 一个用于银行视频联播网中客户端广告机的网络通信部分
💻 C
字号:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>

#include <unistd.h>
#include <sys/ioctl.h>
#include "keyio.h"

#include <termio.h>

#define PASSWORD_LENGTH 256

struct termio oldtty, noecho;

void EchoOff()
{

int fd = fileno(stdin);

if (ioctl(fd, TCGETA, &oldtty) < 0)
perror("ioctl");
noecho = oldtty;
noecho.c_lflag &= ~ECHO;

if (ioctl(fd, TCSETA, &noecho) < 0)
perror("ioctl");
}


void EchoOn()
{
int fd = fileno(stdin);

if (ioctl(fd, TCSETA, &oldtty) < 0)
perror("ioctl");
}


void GetPassword( char *szPass,char *passwd )
{


EchoOff();
(void)printf("Password:");
strcpy(szPass,passwd);
//(void)fgets(szPass,PASSWORD_LENGTH,stdin);
(void)strtok(szPass,"\n");
EchoOn(stdin,1);

(void)printf("\r\n");
}


int GetInput(char *command)
{

char ch;
int i;


while( (ch=getchar()) == ' ' || ch == '\t') ;

if( ch != '\n') {
command[0] = ch;
fgets(&command[1],1024,stdin);
strtok(command,"\n");
i = strlen(command) - 1;

while( i>0 && isspace(command[i]))
i--;
if( i>= 0)
command[i+1] = 0;

}
return 1;

}

⌨️ 快捷键说明

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