summaryrefslogtreecommitdiffstats
path: root/libvncclient
diff options
context:
space:
mode:
Diffstat (limited to 'libvncclient')
-rw-r--r--libvncclient/rfbproto.c52
-rw-r--r--libvncclient/sockets.c4
-rw-r--r--libvncclient/tls_openssl.c4
-rw-r--r--libvncclient/vncviewer.c10
4 files changed, 51 insertions, 19 deletions
diff --git a/libvncclient/rfbproto.c b/libvncclient/rfbproto.c
index 2f887c3..267c1c5 100644
--- a/libvncclient/rfbproto.c
+++ b/libvncclient/rfbproto.c
@@ -23,11 +23,6 @@
* rfbproto.c - functions to deal with client side of RFB protocol.
*/
-#ifdef __STRICT_ANSI__
-#define _BSD_SOURCE
-#define _POSIX_SOURCE
-#define _XOPEN_SOURCE 600
-#endif
#ifndef WIN32
#include <unistd.h>
#include <sys/types.h>
@@ -340,6 +335,8 @@ ConnectToRFBServer(rfbClient* client,const char *hostname, int port)
/* serverHost is a hostname */
if (!StringToIPAddr(hostname, &host)) {
+ if (client->NetworkStatus)
+ client->NetworkStatus(client, rfbNetworkNameResolutionFailed);
rfbClientLog("Couldn't convert '%s' to host address\n", hostname);
return FALSE;
}
@@ -348,6 +345,8 @@ ConnectToRFBServer(rfbClient* client,const char *hostname, int port)
}
if (client->sock < 0) {
+ if (client->NetworkStatus)
+ client->NetworkStatus(client, rfbNetworkConnectionFailed);
rfbClientLog("Unable to connect to VNC server\n");
return FALSE;
}
@@ -444,6 +443,9 @@ rfbHandleAuthResult(rfbClient* client)
authResult = rfbClientSwap32IfLE(authResult);
+ if (client->AuthenticationResults)
+ client->AuthenticationResults(client, authResult);
+
switch (authResult) {
case rfbVncAuthOK:
rfbClientLog("VNC authentication succeeded\n");
@@ -569,13 +571,19 @@ HandleVncAuth(rfbClient *client)
char *passwd=NULL;
int i;
- if (!ReadFromRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE;
+ if (!ReadFromRFBServer(client, (char *)challenge, CHALLENGESIZE)) {
+ if (client->AuthenticationResults)
+ client->AuthenticationResults(client, rfbVncAuthFailed);
+ return FALSE;
+ }
if (client->serverPort!=-1) { /* if not playing a vncrec file */
if (client->GetPassword)
passwd = client->GetPassword(client);
if ((!passwd) || (strlen(passwd) == 0)) {
+ if (client->AuthenticationResults)
+ client->AuthenticationResults(client, rfbVncAuthFailed);
rfbClientLog("Reading password failed\n");
return FALSE;
}
@@ -591,7 +599,11 @@ HandleVncAuth(rfbClient *client)
}
free(passwd);
- if (!WriteToRFBServer(client, (char *)challenge, CHALLENGESIZE)) return FALSE;
+ if (!WriteToRFBServer(client, (char *)challenge, CHALLENGESIZE)) {
+ if (client->AuthenticationResults)
+ client->AuthenticationResults(client, rfbVncAuthFailed);
+ return FALSE;
+ }
}
/* Handle the SecurityResult message */
@@ -1006,7 +1018,11 @@ InitialiseRFBConnection(rfbClient* client)
if (client->listenSpecified)
errorMessageOnReadFailure = FALSE;
- if (!ReadFromRFBServer(client, pv, sz_rfbProtocolVersionMsg)) return FALSE;
+ if (!ReadFromRFBServer(client, pv, sz_rfbProtocolVersionMsg)) {
+ if (client->NetworkStatus)
+ client->NetworkStatus(client, rfbNetworkRFBServerNotValid);
+ return FALSE;
+ }
pv[sz_rfbProtocolVersionMsg]=0;
errorMessageOnReadFailure = TRUE;
@@ -1014,6 +1030,8 @@ InitialiseRFBConnection(rfbClient* client)
pv[sz_rfbProtocolVersionMsg] = 0;
if (sscanf(pv,rfbProtocolVersionFormat,&major,&minor) != 2) {
+ if (client->NetworkStatus)
+ client->NetworkStatus(client, rfbNetworkRFBServerNotValid);
rfbClientLog("Not a valid VNC server (%s)\n",pv);
return FALSE;
}
@@ -1059,17 +1077,29 @@ InitialiseRFBConnection(rfbClient* client)
sprintf(pv,rfbProtocolVersionFormat,client->major,client->minor);
- if (!WriteToRFBServer(client, pv, sz_rfbProtocolVersionMsg)) return FALSE;
+ if (!WriteToRFBServer(client, pv, sz_rfbProtocolVersionMsg)) {
+ if (client->NetworkStatus)
+ client->NetworkStatus(client, rfbNetworkRFBProtocolFailure);
+ return FALSE;
+ }
/* 3.7 and onwards sends a # of security types first */
if (client->major==3 && client->minor > 6)
{
- if (!ReadSupportedSecurityType(client, &authScheme, FALSE)) return FALSE;
+ if (!ReadSupportedSecurityType(client, &authScheme, FALSE)) {
+ if (client->NetworkStatus)
+ client->NetworkStatus(client, rfbNetworkRFBProtocolFailure);
+ return FALSE;
+ }
}
else
{
- if (!ReadFromRFBServer(client, (char *)&authScheme, 4)) return FALSE;
+ if (!ReadFromRFBServer(client, (char *)&authScheme, 4)) {
+ if (client->NetworkStatus)
+ client->NetworkStatus(client, rfbNetworkRFBProtocolFailure);
+ return FALSE;
+ }
authScheme = rfbClientSwap32IfLE(authScheme);
}
diff --git a/libvncclient/sockets.c b/libvncclient/sockets.c
index f042472..2b0ee71 100644
--- a/libvncclient/sockets.c
+++ b/libvncclient/sockets.c
@@ -187,6 +187,8 @@ ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)
return FALSE;
}
} else {
+ if (client->NetworkStatus)
+ client->NetworkStatus(client, rfbNetworkConnectionClosed);
if (errorMessageOnReadFailure) {
rfbClientLog("VNC server closed connection\n");
}
@@ -230,6 +232,8 @@ ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)
return FALSE;
}
} else {
+ if (client->NetworkStatus)
+ client->NetworkStatus(client, rfbNetworkConnectionClosed);
if (errorMessageOnReadFailure) {
rfbClientLog("VNC server closed connection\n");
}
diff --git a/libvncclient/tls_openssl.c b/libvncclient/tls_openssl.c
index e2fadb2..304116a 100644
--- a/libvncclient/tls_openssl.c
+++ b/libvncclient/tls_openssl.c
@@ -18,10 +18,6 @@
* USA.
*/
-#ifndef _MSC_VER
-#define _XOPEN_SOURCE 500
-#endif
-
#include <rfb/rfbclient.h>
#include <errno.h>
diff --git a/libvncclient/vncviewer.c b/libvncclient/vncviewer.c
index ec1b73a..486390e 100644
--- a/libvncclient/vncviewer.c
+++ b/libvncclient/vncviewer.c
@@ -30,10 +30,6 @@
#define strdup _strdup /* Prevent POSIX deprecation warnings */
#endif
-#ifdef __STRICT_ANSI__
-#define _BSD_SOURCE
-#define _POSIX_SOURCE
-#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -376,11 +372,17 @@ static rfbBool rfbInitConnection(rfbClient* client)
}
}
+ if (client->NetworkStatus)
+ client->NetworkStatus(client, rfbNetworkConnectionSuccess);
+
/* Initialise the VNC connection, including reading the password */
if (!InitialiseRFBConnection(client))
return FALSE;
+ if (client->NetworkStatus)
+ client->NetworkStatus(client, rfbNetworkRFBConnectionSuccess);
+
client->width=client->si.framebufferWidth;
client->height=client->si.framebufferHeight;
if (!client->MallocFrameBuffer(client))