diff options
author | dscho <dscho> | 2004-06-18 09:02:15 +0000 |
---|---|---|
committer | dscho <dscho> | 2004-06-18 09:02:15 +0000 |
commit | 11271316d39bca7fa006de635d7ef4d17666a6f1 (patch) | |
tree | a6e74f11a3d4ee753592129c169f04343de24f3e /libvncclient/rfbproto.c | |
parent | a7446d7123bac6ef1bbccee213a1a388bb6b4819 (diff) | |
download | libtdevnc-11271316d39bca7fa006de635d7ef4d17666a6f1.tar.gz libtdevnc-11271316d39bca7fa006de635d7ef4d17666a6f1.zip |
support password reading with getpass(); support -play to play vncrec'orded files
Diffstat (limited to 'libvncclient/rfbproto.c')
-rw-r--r-- | libvncclient/rfbproto.c | 65 |
1 files changed, 48 insertions, 17 deletions
diff --git a/libvncclient/rfbproto.c b/libvncclient/rfbproto.c index c30c46b..4517b07 100644 --- a/libvncclient/rfbproto.c +++ b/libvncclient/rfbproto.c @@ -175,8 +175,7 @@ static rfbBool decompStreamInited = FALSE; */ /* Separate buffer for compressed data. */ -// TODO: -// #define ZLIB_BUFFER_SIZE 512 +/* TODO: threading issues */ #define ZLIB_BUFFER_SIZE 30000 static char zlib_buffer[ZLIB_BUFFER_SIZE]; @@ -205,6 +204,33 @@ ConnectToRFBServer(rfbClient* client,const char *hostname, int port) { unsigned int host; + if (client->serverPort==-1) { + /* serverHost is a file recorded by vncrec. */ + const char* magic="vncLog0.0"; + char buffer[10]; + rfbVNCRec* rec = (rfbVNCRec*)malloc(sizeof(rfbVNCRec)); + client->vncRec = rec; + + rec->file = fopen(client->serverHost,"rb"); + rec->tv.tv_sec = 0; + rec->readTimestamp = FALSE; + rec->doNotSleep = FALSE; + + if (!rec->file) { + rfbClientLog("Could not open %s.\n",client->serverHost); + return FALSE; + } + setbuf(rec->file,0); + fread(buffer,1,strlen(magic),rec->file); + if (strncmp(buffer,magic,strlen(magic))) { + rfbClientLog("File %s was not recorded by vncrec.\n",client->serverHost); + fclose(rec->file); + return FALSE; + } + client->sock = 0; + return TRUE; + } + if (!StringToIPAddr(hostname, &host)) { rfbClientLog("Couldn't convert '%s' to host address\n", hostname); return FALSE; @@ -289,25 +315,28 @@ InitialiseRFBConnection(rfbClient* client) case rfbVncAuth: if (!ReadFromRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE; - if (client->GetPassword) - passwd = client->GetPassword(client); + if (client->serverPort!=-1) { /* if not playing a vncrec file */ + if (client->GetPassword) + passwd = client->GetPassword(client); - if ((!passwd) || (strlen(passwd) == 0)) { - rfbClientLog("Reading password failed\n"); - return FALSE; - } - if (strlen(passwd) > 8) { - passwd[8] = '\0'; - } + if ((!passwd) || (strlen(passwd) == 0)) { + rfbClientLog("Reading password failed\n"); + return FALSE; + } + if (strlen(passwd) > 8) { + passwd[8] = '\0'; + } - rfbEncryptBytes(challenge, passwd); + rfbEncryptBytes(challenge, passwd); - /* Lose the password from memory */ - for (i = strlen(passwd); i >= 0; i--) { - passwd[i] = '\0'; - } + /* Lose the password from memory */ + for (i = strlen(passwd); i >= 0; i--) { + passwd[i] = '\0'; + } + free(passwd); - if (!WriteToRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE; + if (!WriteToRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE; + } if (!ReadFromRFBServer(client, (char *)&authResult, 4)) return FALSE; @@ -638,6 +667,8 @@ HandleRFBServerMessage(rfbClient* client) { rfbServerToClientMsg msg; + if (client->serverPort==-1) + client->vncRec->readTimestamp = TRUE; if (!ReadFromRFBServer(client, (char *)&msg, 1)) return FALSE; |