Commit b68e3879 authored by dscho's avatar dscho

do not use GNU-only getline

parent b6caa102
...@@ -39,7 +39,7 @@ static char* NoPassword(rfbClient* client) { ...@@ -39,7 +39,7 @@ static char* NoPassword(rfbClient* client) {
#include <stdio.h> #include <stdio.h>
#include <termios.h> #include <termios.h>
static char* ReadPassword(rfbClient* client) { static char* ReadPassword(rfbClient* client) {
int i=8; int i;
char* p=malloc(9); char* p=malloc(9);
struct termios save,noecho; struct termios save,noecho;
p[0]=0; p[0]=0;
...@@ -47,8 +47,17 @@ static char* ReadPassword(rfbClient* client) { ...@@ -47,8 +47,17 @@ static char* ReadPassword(rfbClient* client) {
noecho=save; noecho.c_lflag &= ~ECHO; noecho=save; noecho.c_lflag &= ~ECHO;
if(tcsetattr(fileno(stdin),TCSAFLUSH,&noecho)!=0) return p; if(tcsetattr(fileno(stdin),TCSAFLUSH,&noecho)!=0) return p;
fprintf(stderr,"Password: "); fprintf(stderr,"Password: ");
getline(&p,&i,stdin); i=0;
if(i>0 && p[i-2]=='\n') p[i-2]=0; while(1) {
int c=fgetc(stdin);
if(c=='\n')
break;
if(i<8) {
p[i]=c;
i++;
p[i]=0;
}
}
tcsetattr(fileno(stdin),TCSAFLUSH,&save); tcsetattr(fileno(stdin),TCSAFLUSH,&save);
return p; return p;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment