Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
libvncserver
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rasky
libvncserver
Commits
b583cf53
Commit
b583cf53
authored
Oct 16, 2004
by
dscho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move read buffer to rfbClient structure (thread safety); make rfbClientLog
overrideable
parent
8715a8ab
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
35 deletions
+46
-35
rfbproto.c
libvncclient/rfbproto.c
+7
-3
sockets.c
libvncclient/sockets.c
+16
-21
tight.c
libvncclient/tight.c
+4
-4
vncviewer.c
libvncclient/vncviewer.c
+5
-1
zlib.c
libvncclient/zlib.c
+2
-2
rfbclient.h
rfb/rfbclient.h
+12
-4
No files found.
libvncclient/rfbproto.c
View file @
b583cf53
...
...
@@ -43,7 +43,7 @@
rfbBool
rfbEnableClientLogging
=
TRUE
;
void
rfbClientLog
(
const
char
*
format
,
...)
rfb
Default
ClientLog
(
const
char
*
format
,
...)
{
va_list
args
;
char
buf
[
256
];
...
...
@@ -64,6 +64,9 @@ rfbClientLog(const char *format, ...)
va_end
(
args
);
}
rfbClientLogProc
rfbClientLog
=
rfbDefaultClientLog
;
rfbClientLogProc
rfbClientErr
=
rfbDefaultClientLog
;
void
FillRectangle
(
rfbClient
*
client
,
int
x
,
int
y
,
int
w
,
int
h
,
uint32_t
colour
)
{
int
i
,
j
;
...
...
@@ -271,13 +274,14 @@ InitialiseRFBConnection(rfbClient* client)
errorMessageOnReadFailure
=
FALSE
;
if
(
!
ReadFromRFBServer
(
client
,
pv
,
sz_rfbProtocolVersionMsg
))
return
FALSE
;
pv
[
sz_rfbProtocolVersionMsg
]
=
0
;
errorMessageOnReadFailure
=
TRUE
;
pv
[
sz_rfbProtocolVersionMsg
]
=
0
;
if
(
sscanf
(
pv
,
rfbProtocolVersionFormat
,
&
major
,
&
minor
)
!=
2
)
{
rfbClientLog
(
"Not a valid VNC server
\n
"
);
rfbClientLog
(
"Not a valid VNC server
(%s)
\n
"
,
pv
);
return
FALSE
;
}
...
...
@@ -769,7 +773,7 @@ HandleRFBServerMessage(rfbClient* client)
int
y
=
rect
.
r
.
y
,
h
=
rect
.
r
.
h
;
bytesPerLine
=
rect
.
r
.
w
*
client
->
format
.
bitsPerPixel
/
8
;
linesToRead
=
BUFFER_SIZE
/
bytesPerLine
;
linesToRead
=
RFB_
BUFFER_SIZE
/
bytesPerLine
;
while
(
h
>
0
)
{
if
(
linesToRead
>
h
)
...
...
libvncclient/sockets.c
View file @
b583cf53
...
...
@@ -36,11 +36,6 @@ void PrintInHex(char *buf, int len);
rfbBool
errorMessageOnReadFailure
=
TRUE
;
#define BUF_SIZE 8192
static
char
buf
[
BUF_SIZE
];
static
char
*
bufoutptr
=
buf
;
static
int
buffered
=
0
;
/*
* ReadFromRFBServer is called whenever we want to read some data from the RFB
* server. It is non-trivial for two reasons:
...
...
@@ -95,28 +90,28 @@ ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)
return
(
fread
(
out
,
1
,
n
,
rec
->
file
)
<
0
?
FALSE
:
TRUE
);
}
if
(
n
<=
buffered
)
{
memcpy
(
out
,
bufoutptr
,
n
);
bufoutptr
+=
n
;
buffered
-=
n
;
if
(
n
<=
client
->
buffered
)
{
memcpy
(
out
,
client
->
bufoutptr
,
n
);
client
->
bufoutptr
+=
n
;
client
->
buffered
-=
n
;
#ifdef DEBUG_READ_EXACT
goto
hexdump
;
#endif
return
TRUE
;
}
memcpy
(
out
,
bufoutptr
,
buffered
);
memcpy
(
out
,
client
->
bufoutptr
,
client
->
buffered
);
out
+=
buffered
;
n
-=
buffered
;
out
+=
client
->
buffered
;
n
-=
client
->
buffered
;
bufoutptr
=
buf
;
buffered
=
0
;
client
->
bufoutptr
=
client
->
buf
;
client
->
buffered
=
0
;
if
(
n
<=
BUF_SIZE
)
{
if
(
n
<=
RFB_
BUF_SIZE
)
{
while
(
buffered
<
n
)
{
int
i
=
read
(
client
->
sock
,
buf
+
buffered
,
BUF_SIZE
-
buffered
);
while
(
client
->
buffered
<
n
)
{
int
i
=
read
(
client
->
sock
,
client
->
buf
+
client
->
buffered
,
RFB_BUF_SIZE
-
client
->
buffered
);
if
(
i
<=
0
)
{
if
(
i
<
0
)
{
if
(
errno
==
EWOULDBLOCK
||
errno
==
EAGAIN
)
{
...
...
@@ -135,12 +130,12 @@ ReadFromRFBServer(rfbClient* client, char *out, unsigned int n)
return
FALSE
;
}
}
buffered
+=
i
;
client
->
buffered
+=
i
;
}
memcpy
(
out
,
bufoutptr
,
n
);
bufoutptr
+=
n
;
buffered
-=
n
;
memcpy
(
out
,
client
->
bufoutptr
,
n
);
client
->
bufoutptr
+=
n
;
client
->
buffered
-=
n
;
}
else
{
...
...
libvncclient/tight.c
View file @
b583cf53
...
...
@@ -227,10 +227,10 @@ HandleTightBPP (rfbClient* client, int rx, int ry, int rw, int rh)
/* Read, decode and draw actual pixel data in a loop. */
bufferSize
=
BUFFER_SIZE
*
bitsPixel
/
(
bitsPixel
+
BPP
)
&
0xFFFFFFFC
;
bufferSize
=
RFB_
BUFFER_SIZE
*
bitsPixel
/
(
bitsPixel
+
BPP
)
&
0xFFFFFFFC
;
buffer2
=
&
client
->
buffer
[
bufferSize
];
if
(
rowSize
>
bufferSize
)
{
/* Should be impossible when BUFFER_SIZE >= 16384 */
/* Should be impossible when
RFB_
BUFFER_SIZE >= 16384 */
rfbClientLog
(
"Internal error: incorrect buffer size.
\n
"
);
return
FALSE
;
}
...
...
@@ -586,12 +586,12 @@ DecompressJpegRectBPP(rfbClient* client, int x, int y, int w, int h)
if
(
jpegError
)
{
break
;
}
pixelPtr
=
(
CARDBPP
*
)
&
client
->
buffer
[
BUFFER_SIZE
/
2
];
pixelPtr
=
(
CARDBPP
*
)
&
client
->
buffer
[
RFB_
BUFFER_SIZE
/
2
];
for
(
dx
=
0
;
dx
<
w
;
dx
++
)
{
*
pixelPtr
++
=
RGB24_TO_PIXEL
(
BPP
,
client
->
buffer
[
dx
*
3
],
client
->
buffer
[
dx
*
3
+
1
],
client
->
buffer
[
dx
*
3
+
2
]);
}
CopyRectangle
(
client
,
&
client
->
buffer
[
BUFFER_SIZE
/
2
],
x
,
y
+
dy
,
w
,
1
);
CopyRectangle
(
client
,
&
client
->
buffer
[
RFB_
BUFFER_SIZE
/
2
],
x
,
y
+
dy
,
w
,
1
);
dy
++
;
}
...
...
libvncclient/vncviewer.c
View file @
b583cf53
...
...
@@ -23,6 +23,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <rfb/rfbclient.h>
...
...
@@ -128,6 +129,9 @@ rfbClient* rfbGetClient(int bitsPerSample,int samplesPerPixel,
}
}
client
->
bufoutptr
=
client
->
buf
;
client
->
buffered
=
0
;
client
->
HandleCursorPos
=
DummyPoint
;
client
->
SoftCursorLockArea
=
DummyRect
;
client
->
SoftCursorUnlockScreen
=
Dummy
;
...
...
@@ -188,7 +192,7 @@ rfbBool rfbInitClient(rfbClient* client,int* argc,char** argv) {
char
*
colon
=
strchr
(
argv
[
i
],
':'
);
if
(
colon
)
{
client
->
serverHost
=
strndup
(
argv
[
i
],
colon
-
argv
[
i
]
);
client
->
serverHost
=
strndup
(
argv
[
i
],
(
int
)(
colon
-
argv
[
i
])
);
client
->
serverPort
=
atoi
(
colon
+
1
);
}
else
{
client
->
serverHost
=
strdup
(
argv
[
i
]);
...
...
libvncclient/zlib.c
View file @
b583cf53
...
...
@@ -96,8 +96,8 @@ HandleZlibBPP (rfbClient* client, int rx, int ry, int rw, int rh)
while
((
remaining
>
0
)
&&
(
inflateResult
==
Z_OK
))
{
if
(
remaining
>
BUFFER_SIZE
)
{
toRead
=
BUFFER_SIZE
;
if
(
remaining
>
RFB_
BUFFER_SIZE
)
{
toRead
=
RFB_
BUFFER_SIZE
;
}
else
{
toRead
=
remaining
;
...
...
rfb/rfbclient.h
View file @
b583cf53
...
...
@@ -102,7 +102,7 @@ typedef struct _rfbClient {
AppData
appData
;
const
char
*
programName
;
c
onst
c
har
*
serverHost
;
char
*
serverHost
;
int
serverPort
;
/* if -1, then use file recorded by vncrec */
rfbBool
listenSpecified
;
int
listenPort
,
flashPort
;
...
...
@@ -112,8 +112,8 @@ typedef struct _rfbClient {
Hextile also assumes it is big enough to hold 16 * 16 * 32 bits.
Tight encoding assumes BUFFER_SIZE is at least 16384 bytes. */
#define BUFFER_SIZE (640*480)
char
buffer
[
BUFFER_SIZE
];
#define
RFB_
BUFFER_SIZE (640*480)
char
buffer
[
RFB_
BUFFER_SIZE
];
/* rfbproto.c */
...
...
@@ -126,6 +126,13 @@ typedef struct _rfbClient {
char
*
serverCutText
;
rfbBool
newServerCutText
;
/* sockets.c */
#define RFB_BUF_SIZE 8192
char
buf
[
RFB_BUF_SIZE
];
char
*
bufoutptr
;
int
buffered
;
/* cursor.c */
uint8_t
*
rcSource
,
*
rcMask
;
...
...
@@ -156,7 +163,8 @@ extern void listenForIncomingConnections(rfbClient* viewer);
/* rfbproto.c */
extern
rfbBool
rfbEnableClientLogging
;
extern
void
rfbClientLog
(
const
char
*
format
,
...);
typedef
void
(
*
rfbClientLogProc
)(
const
char
*
format
,
...);
extern
rfbClientLogProc
rfbClientLog
,
rfbClientErr
;
extern
rfbBool
ConnectToRFBServer
(
rfbClient
*
client
,
const
char
*
hostname
,
int
port
);
extern
rfbBool
InitialiseRFBConnection
(
rfbClient
*
client
);
extern
rfbBool
SetFormatAndEncodings
(
rfbClient
*
client
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment