diff options
author | dscho <dscho> | 2004-06-30 10:34:30 +0000 |
---|---|---|
committer | dscho <dscho> | 2004-06-30 10:34:30 +0000 |
commit | b68e3879493c12777ad375742e6871acae6d93c6 (patch) | |
tree | e14f12cc33803fafe367e2b01ac582bdf30d5b72 /libvncclient/vncviewer.c | |
parent | b6caa102d1d1f61f5795691f23376a79ad2a9c4d (diff) | |
download | libtdevnc-b68e3879493c12777ad375742e6871acae6d93c6.tar.gz libtdevnc-b68e3879493c12777ad375742e6871acae6d93c6.zip |
do not use GNU-only getline
Diffstat (limited to 'libvncclient/vncviewer.c')
-rw-r--r-- | libvncclient/vncviewer.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libvncclient/vncviewer.c b/libvncclient/vncviewer.c index 712f52e..4a327ed 100644 --- a/libvncclient/vncviewer.c +++ b/libvncclient/vncviewer.c @@ -39,7 +39,7 @@ static char* NoPassword(rfbClient* client) { #include <stdio.h> #include <termios.h> static char* ReadPassword(rfbClient* client) { - int i=8; + int i; char* p=malloc(9); struct termios save,noecho; p[0]=0; @@ -47,8 +47,17 @@ static char* ReadPassword(rfbClient* client) { noecho=save; noecho.c_lflag &= ~ECHO; if(tcsetattr(fileno(stdin),TCSAFLUSH,&noecho)!=0) return p; fprintf(stderr,"Password: "); - getline(&p,&i,stdin); - if(i>0 && p[i-2]=='\n') p[i-2]=0; + i=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); return p; } |