mirror of
https://github.com/sheumann/VNCviewGS.git
synced 2024-11-24 00:30:46 +00:00
Access data in read buffer using pointer instead of handle.
This is a prelude to revamping the read routines.
This commit is contained in:
parent
e8a4d86f6b
commit
ceeaeb7767
@ -48,7 +48,7 @@ void DoServerCutText (void) {
|
|||||||
DoClose(vncWindow);
|
DoClose(vncWindow);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
textLen = SwapBytes4((unsigned long) **readBufferHndl);
|
textLen = SwapBytes4(*(unsigned long *)readBufferPtr);
|
||||||
|
|
||||||
if (! DoWaitingReadTCP(textLen)) {
|
if (! DoWaitingReadTCP(textLen)) {
|
||||||
DoClose(vncWindow);
|
DoClose(vncWindow);
|
||||||
@ -59,11 +59,11 @@ void DoServerCutText (void) {
|
|||||||
|
|
||||||
/* Convert lf->cr; Use pointer arithmetic so we can go over 64k */
|
/* Convert lf->cr; Use pointer arithmetic so we can go over 64k */
|
||||||
for (i = 0; i < textLen; i++)
|
for (i = 0; i < textLen; i++)
|
||||||
if (*((*(char **)readBufferHndl)+i) == '\n')
|
if (*(readBufferPtr+i) == '\n')
|
||||||
*((*(char **)readBufferHndl)+i) = '\r';
|
*(readBufferPtr+i) = '\r';
|
||||||
|
|
||||||
/* Below function call requires <scrap.h> to be fixed */
|
/* Below function call requires <scrap.h> to be fixed */
|
||||||
PutScrap(textLen, textScrap, (Pointer) *readBufferHndl);
|
PutScrap(textLen, textScrap, (Pointer) readBufferPtr);
|
||||||
/* Potential errors (e.g. out of memory) ignored */
|
/* Potential errors (e.g. out of memory) ignored */
|
||||||
DoneWithReadBuffer();
|
DoneWithReadBuffer();
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ void DoCopyRect (void) {
|
|||||||
|
|
||||||
contentOrigin.l = GetContentOrigin(vncWindow);
|
contentOrigin.l = GetContentOrigin(vncWindow);
|
||||||
|
|
||||||
dataPtr = (unsigned int *) ((char *) (*readBufferHndl));
|
dataPtr = (unsigned int *) readBufferPtr;
|
||||||
srcRect.h1 = SwapBytes2(dataPtr[0]) - contentOrigin.pt.h;
|
srcRect.h1 = SwapBytes2(dataPtr[0]) - contentOrigin.pt.h;
|
||||||
srcRect.v1 = SwapBytes2(dataPtr[1]) - contentOrigin.pt.v;
|
srcRect.v1 = SwapBytes2(dataPtr[1]) - contentOrigin.pt.v;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ static void HexRawDraw (Origin contentOrigin, int rectWidth, int rectHeight) {
|
|||||||
|
|
||||||
static Rect srcRect = {0,0,0,0};
|
static Rect srcRect = {0,0,0,0};
|
||||||
|
|
||||||
dataPtr = (unsigned char *) *readBufferHndl;
|
dataPtr = readBufferPtr;
|
||||||
|
|
||||||
if ((hRez==640 && (rectWidth & 0x03)) || (hRez==320 && (rectWidth & 0x01)))
|
if ((hRez==640 && (rectWidth & 0x03)) || (hRez==320 && (rectWidth & 0x01)))
|
||||||
extraByteAdvance = TRUE;
|
extraByteAdvance = TRUE;
|
||||||
@ -209,8 +209,8 @@ void HexDispatch (void) {
|
|||||||
|
|
||||||
/* If we don't have the next bit of needed data yet, return. */
|
/* If we don't have the next bit of needed data yet, return. */
|
||||||
while (DoReadTCP(bytesNeeded)) {
|
while (DoReadTCP(bytesNeeded)) {
|
||||||
dataPtr = *(unsigned char **) readBufferHndl;
|
dataPtr = readBufferPtr;
|
||||||
/* If we're here, readBufferHndl contains bytesNeeded bytes of data. */
|
/* If we're here, readBufferPtr contains bytesNeeded bytes of data. */
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case hexWaitingForSubencoding:
|
case hexWaitingForSubencoding:
|
||||||
subencoding = *dataPtr;
|
subencoding = *dataPtr;
|
||||||
|
4
mouse.cc
4
mouse.cc
@ -161,8 +161,8 @@ void DoCursor (void) {
|
|||||||
if (!DoReadTCP((unsigned long)rectWidth * rectHeight + bitmaskLineBytes * rectHeight))
|
if (!DoReadTCP((unsigned long)rectWidth * rectHeight + bitmaskLineBytes * rectHeight))
|
||||||
return; /* Try again later */
|
return; /* Try again later */
|
||||||
|
|
||||||
cursorPixels = (unsigned char *)(*readBufferHndl);
|
cursorPixels = readBufferPtr;
|
||||||
bitmask = (unsigned char *)(*readBufferHndl) + (unsigned long)rectWidth * rectHeight;
|
bitmask = readBufferPtr + (unsigned long)rectWidth * rectHeight;
|
||||||
|
|
||||||
if (hRez == 640)
|
if (hRez == 640)
|
||||||
lineWords = ((unsigned long)rectWidth + 7) / 8 + 1;
|
lineWords = ((unsigned long)rectWidth + 7) / 8 + 1;
|
||||||
|
2
raw.cc
2
raw.cc
@ -122,7 +122,7 @@ void RawDraw (void) {
|
|||||||
if (linesAvailable == 0) {
|
if (linesAvailable == 0) {
|
||||||
linesAvailable = DoReadMultipleTCP(rectWidth, rectHeight - drawingLine);
|
linesAvailable = DoReadMultipleTCP(rectWidth, rectHeight - drawingLine);
|
||||||
if (linesAvailable) {
|
if (linesAvailable) {
|
||||||
lineDataPtr = (unsigned char *) *readBufferHndl;
|
lineDataPtr = readBufferPtr;
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ static void DoFBUpdate (void) {
|
|||||||
//printf("Closing in DoFBUpdate\n");
|
//printf("Closing in DoFBUpdate\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dataPtr = (unsigned int *) (((char *) (*readBufferHndl)) + 1);
|
dataPtr = (unsigned int *) (readBufferPtr + 1);
|
||||||
numRects = SwapBytes2(dataPtr[0]); /* Get data */
|
numRects = SwapBytes2(dataPtr[0]); /* Get data */
|
||||||
rectX = SwapBytes2(dataPtr[1]);
|
rectX = SwapBytes2(dataPtr[1]);
|
||||||
rectY = SwapBytes2(dataPtr[2]);
|
rectY = SwapBytes2(dataPtr[2]);
|
||||||
@ -246,7 +246,7 @@ static void DoSetColourMapEntries (void) {
|
|||||||
|
|
||||||
DoWaitingReadTCP(3);
|
DoWaitingReadTCP(3);
|
||||||
DoWaitingReadTCP(2);
|
DoWaitingReadTCP(2);
|
||||||
numColors = SwapBytes2((unsigned int) **readBufferHndl);
|
numColors = SwapBytes2(*(unsigned int *)readBufferPtr);
|
||||||
skipBytes = 6UL * numColors;
|
skipBytes = 6UL * numColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,7 +275,7 @@ void NextRect (void) {
|
|||||||
DoClose(vncWindow);
|
DoClose(vncWindow);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dataPtr = (unsigned int *) ((char *) (*readBufferHndl));
|
dataPtr = (unsigned int *)readBufferPtr;
|
||||||
rectX = SwapBytes2(dataPtr[0]);
|
rectX = SwapBytes2(dataPtr[0]);
|
||||||
rectY = SwapBytes2(dataPtr[1]);
|
rectY = SwapBytes2(dataPtr[1]);
|
||||||
rectWidth = SwapBytes2(dataPtr[2]);
|
rectWidth = SwapBytes2(dataPtr[2]);
|
||||||
@ -344,7 +344,7 @@ void ConnectedEventLoop (void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (DoReadTCP(1)) { /* Read message type byte */
|
else if (DoReadTCP(1)) { /* Read message type byte */
|
||||||
messageType = ((unsigned char) **readBufferHndl);
|
messageType = *readBufferPtr;
|
||||||
switch (messageType) {
|
switch (messageType) {
|
||||||
case FBUpdate: DoFBUpdate();
|
case FBUpdate: DoFBUpdate();
|
||||||
break;
|
break;
|
||||||
|
@ -54,10 +54,8 @@ segment "VNCview GS";
|
|||||||
GrafPortPtr connectStatusWindowPtr = NULL;
|
GrafPortPtr connectStatusWindowPtr = NULL;
|
||||||
|
|
||||||
unsigned int hostIpid;
|
unsigned int hostIpid;
|
||||||
void ** readBufferHndl; /* Handle to the data read by the last
|
void ** readBufferHndl; /* User internally by TCP read routines. */
|
||||||
* DoReadTCP call. Copy this elsewhere if more
|
unsigned char *readBufferPtr; /* Ptr to data read by last DoReadTCP call. */
|
||||||
* data may be read while it is still in use.
|
|
||||||
*/
|
|
||||||
static BOOLEAN alerted = FALSE;
|
static BOOLEAN alerted = FALSE;
|
||||||
|
|
||||||
static void CloseConnectStatusWindow (void);
|
static void CloseConnectStatusWindow (void);
|
||||||
@ -340,6 +338,7 @@ static BOOLEAN ReadFixup (unsigned long requested, unsigned long returned) {
|
|||||||
DisposeHandle(theRRBuff.rrBuffHandle);
|
DisposeHandle(theRRBuff.rrBuffHandle);
|
||||||
} while (returned < requested);
|
} while (returned < requested);
|
||||||
|
|
||||||
|
readBufferPtr = *readBufferHndl;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -378,6 +377,7 @@ BOOLEAN DoReadTCP (unsigned long dataLength) {
|
|||||||
return ReadFixup(dataLength, theRRBuff.rrBuffCount);
|
return ReadFixup(dataLength, theRRBuff.rrBuffCount);
|
||||||
|
|
||||||
HLock(readBufferHndl);
|
HLock(readBufferHndl);
|
||||||
|
readBufferPtr = *readBufferHndl;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -417,6 +417,7 @@ static BOOLEAN DoVNCHandshaking (void) {
|
|||||||
static char versionString[12];
|
static char versionString[12];
|
||||||
unsigned long reasonLength;
|
unsigned long reasonLength;
|
||||||
char *errorString;
|
char *errorString;
|
||||||
|
char **errorStringPtr = &errorString;
|
||||||
|
|
||||||
WaitCursor();
|
WaitCursor();
|
||||||
DisplayConnectStatus("\pConnecting to VNC server...", FALSE);
|
DisplayConnectStatus("\pConnecting to VNC server...", FALSE);
|
||||||
@ -425,10 +426,10 @@ static BOOLEAN DoVNCHandshaking (void) {
|
|||||||
strcpy(versionString, "");
|
strcpy(versionString, "");
|
||||||
if (! DoWaitingReadTCP(12))
|
if (! DoWaitingReadTCP(12))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if ( ! ((strncmp((char *)*readBufferHndl, "RFB ", 4) == 0) &&
|
if ( ! ((strncmp((char *)readBufferPtr, "RFB ", 4) == 0) &&
|
||||||
(strncmp((char *)*readBufferHndl+4, RFBMAJORVERSIONSTR, 3) >= 0) &&
|
(strncmp((char *)readBufferPtr+4, RFBMAJORVERSIONSTR, 3) >= 0) &&
|
||||||
(strncmp((char *)*readBufferHndl+7, ".", 1) == 0) &&
|
(strncmp((char *)readBufferPtr+7, ".", 1) == 0) &&
|
||||||
(strncmp((char *)*readBufferHndl+11, "\n", 1) == 0))) {
|
(strncmp((char *)readBufferPtr+11, "\n", 1) == 0))) {
|
||||||
InitCursor();
|
InitCursor();
|
||||||
AlertWindow(awResource, NULL, badRFBVersionAlert);
|
AlertWindow(awResource, NULL, badRFBVersionAlert);
|
||||||
alerted = TRUE;
|
alerted = TRUE;
|
||||||
@ -446,30 +447,28 @@ static BOOLEAN DoVNCHandshaking (void) {
|
|||||||
if (! DoWaitingReadTCP(4)) { /* Read authentication type */
|
if (! DoWaitingReadTCP(4)) { /* Read authentication type */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
switch ((unsigned long) (**readBufferHndl)) {
|
switch (*(unsigned long *) readBufferPtr) {
|
||||||
case vncConnectionFailed: if (! DoWaitingReadTCP(4))
|
case vncConnectionFailed: if (! DoWaitingReadTCP(4))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (toolerror())
|
if (toolerror())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
reasonLength = SwapBytes4(**readBufferHndl);
|
reasonLength = SwapBytes4(
|
||||||
|
*(unsigned long *)readBufferPtr);
|
||||||
if (! DoWaitingReadTCP(reasonLength))
|
if (! DoWaitingReadTCP(reasonLength))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
if (toolerror())
|
if (toolerror())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
HUnlock(readBufferHndl);
|
errorString = calloc(reasonLength + 1, 1);
|
||||||
SetHandleSize(
|
if (errorString == NULL)
|
||||||
GetHandleSize(readBufferHndl)+1,
|
return FALSE;
|
||||||
readBufferHndl);
|
memcpy(errorString, readBufferPtr,
|
||||||
if (! toolerror()) {
|
reasonLength);
|
||||||
HLock(readBufferHndl);
|
InitCursor();
|
||||||
*((char *) *readBufferHndl+reasonLength)
|
AlertWindow(awResource,
|
||||||
= 0;
|
(Pointer) errorStringPtr,
|
||||||
InitCursor();
|
connectionFailedAlert);
|
||||||
AlertWindow(awResource,
|
free(errorString);
|
||||||
(Pointer) readBufferHndl,
|
alerted = TRUE;
|
||||||
connectionFailedAlert);
|
|
||||||
alerted = TRUE;
|
|
||||||
}
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
case vncNoAuthentication: break;
|
case vncNoAuthentication: break;
|
||||||
case vncVNCAuthentication: if (DoDES())
|
case vncVNCAuthentication: if (DoDES())
|
||||||
@ -569,8 +568,8 @@ static BOOLEAN DoDES (void) {
|
|||||||
|
|
||||||
DESAddParity(theKey, &vncPassword[1]);
|
DESAddParity(theKey, &vncPassword[1]);
|
||||||
|
|
||||||
DESCipher(theResponse, theKey, *(char **)readBufferHndl, modeEncrypt);
|
DESCipher(theResponse, theKey, (char *)readBufferPtr, modeEncrypt);
|
||||||
DESCipher(&theResponse[8], theKey, *(char **)readBufferHndl+8, modeEncrypt);
|
DESCipher(&theResponse[8], theKey, (char *)readBufferPtr+8, modeEncrypt);
|
||||||
|
|
||||||
if (TCPIPWriteTCP(hostIpid, theResponse, sizeof(theResponse), TRUE, FALSE))
|
if (TCPIPWriteTCP(hostIpid, theResponse, sizeof(theResponse), TRUE, FALSE))
|
||||||
{
|
{
|
||||||
@ -586,18 +585,18 @@ static BOOLEAN DoDES (void) {
|
|||||||
goto UnloadCrypto;
|
goto UnloadCrypto;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((**readBufferHndl) == statusOK) {
|
if (*readBufferPtr == statusOK) {
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
goto UnloadCrypto;
|
goto UnloadCrypto;
|
||||||
}
|
}
|
||||||
else if ((**readBufferHndl) == statusFailed) {
|
else if (*readBufferPtr == statusFailed) {
|
||||||
InitCursor();
|
InitCursor();
|
||||||
AlertWindow(awResource, NULL, authFailedError);
|
AlertWindow(awResource, NULL, authFailedError);
|
||||||
alerted = TRUE;
|
alerted = TRUE;
|
||||||
success = FALSE;
|
success = FALSE;
|
||||||
goto UnloadCrypto;
|
goto UnloadCrypto;
|
||||||
}
|
}
|
||||||
else if ((**readBufferHndl) == statusTooMany) {
|
else if (*readBufferPtr == statusTooMany) {
|
||||||
InitCursor();
|
InitCursor();
|
||||||
AlertWindow(awResource, NULL, authTooManyError);
|
AlertWindow(awResource, NULL, authTooManyError);
|
||||||
alerted = TRUE;
|
alerted = TRUE;
|
||||||
@ -695,10 +694,10 @@ static BOOLEAN FinishVNCHandshaking (void) {
|
|||||||
/* ServerInitialisation */
|
/* ServerInitialisation */
|
||||||
if (! DoWaitingReadTCP(2))
|
if (! DoWaitingReadTCP(2))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
fbWidth = SwapBytes2(**(unsigned **)readBufferHndl);
|
fbWidth = SwapBytes2(*(unsigned *)readBufferPtr);
|
||||||
if (! DoWaitingReadTCP(2))
|
if (! DoWaitingReadTCP(2))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
fbHeight = SwapBytes2(**(unsigned **)readBufferHndl);
|
fbHeight = SwapBytes2(*(unsigned *)readBufferPtr);
|
||||||
|
|
||||||
if ((fbWidth > 16384) || (fbHeight > 16384)) {
|
if ((fbWidth > 16384) || (fbHeight > 16384)) {
|
||||||
AlertWindow(awResource, NULL, screenTooBigError);
|
AlertWindow(awResource, NULL, screenTooBigError);
|
||||||
@ -710,7 +709,7 @@ static BOOLEAN FinishVNCHandshaking (void) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
if (! DoWaitingReadTCP(4))
|
if (! DoWaitingReadTCP(4))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
serverNameLen = SwapBytes4(**(unsigned long **)readBufferHndl);
|
serverNameLen = SwapBytes4(*(unsigned long *)readBufferPtr);
|
||||||
if (! DoWaitingReadTCP(serverNameLen))
|
if (! DoWaitingReadTCP(serverNameLen))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -16,7 +16,8 @@
|
|||||||
|
|
||||||
extern GrafPortPtr connectStatusWindowPtr;
|
extern GrafPortPtr connectStatusWindowPtr;
|
||||||
|
|
||||||
extern void ** readBufferHndl;
|
extern void ** readBufferHndl; /* User internally by TCP read routines. */
|
||||||
|
extern unsigned char *readBufferPtr; /* Ptr to data read by last DoReadTCP call. */
|
||||||
|
|
||||||
extern unsigned int hostIpid;
|
extern unsigned int hostIpid;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user