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
964aa162
Commit
964aa162
authored
Jul 29, 2003
by
dscho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
further valgrinding showed leaked mallocs
parent
9b46601d
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
101 additions
and
24 deletions
+101
-24
cursor.c
cursor.c
+24
-7
client_test.c
libvncclient/client_test.c
+37
-7
rfbproto.c
libvncclient/rfbproto.c
+4
-4
vncviewer.c
libvncclient/vncviewer.c
+4
-0
main.c
main.c
+10
-5
rfb.h
rfb/rfb.h
+2
-0
rfbclient.h
rfb/rfbclient.h
+1
-0
tight-1.c
test/tight-1.c
+8
-1
tight.c
tight.c
+11
-0
No files found.
cursor.c
View file @
964aa162
...
@@ -258,12 +258,14 @@ rfbCursorPtr rfbMakeXCursor(int width,int height,char* cursorString,char* maskSt
...
@@ -258,12 +258,14 @@ rfbCursorPtr rfbMakeXCursor(int width,int height,char* cursorString,char* maskSt
char
*
cp
;
char
*
cp
;
unsigned
char
bit
;
unsigned
char
bit
;
cursor
->
cleanup
=
TRUE
;
cursor
->
width
=
width
;
cursor
->
width
=
width
;
cursor
->
height
=
height
;
cursor
->
height
=
height
;
/*cursor->backRed=cursor->backGreen=cursor->backBlue=0xffff;*/
/*cursor->backRed=cursor->backGreen=cursor->backBlue=0xffff;*/
cursor
->
foreRed
=
cursor
->
foreGreen
=
cursor
->
foreBlue
=
0xffff
;
cursor
->
foreRed
=
cursor
->
foreGreen
=
cursor
->
foreBlue
=
0xffff
;
cursor
->
source
=
(
unsigned
char
*
)
calloc
(
w
,
height
);
cursor
->
source
=
(
unsigned
char
*
)
calloc
(
w
,
height
);
cursor
->
cleanupSource
=
TRUE
;
for
(
j
=
0
,
cp
=
cursorString
;
j
<
height
;
j
++
)
for
(
j
=
0
,
cp
=
cursorString
;
j
<
height
;
j
++
)
for
(
i
=
0
,
bit
=
0x80
;
i
<
width
;
i
++
,
bit
=
(
bit
&
1
)
?
0x80
:
bit
>>
1
,
cp
++
)
for
(
i
=
0
,
bit
=
0x80
;
i
<
width
;
i
++
,
bit
=
(
bit
&
1
)
?
0x80
:
bit
>>
1
,
cp
++
)
if
(
*
cp
!=
' '
)
cursor
->
source
[
j
*
w
+
i
/
8
]
|=
bit
;
if
(
*
cp
!=
' '
)
cursor
->
source
[
j
*
w
+
i
/
8
]
|=
bit
;
...
@@ -275,6 +277,7 @@ rfbCursorPtr rfbMakeXCursor(int width,int height,char* cursorString,char* maskSt
...
@@ -275,6 +277,7 @@ rfbCursorPtr rfbMakeXCursor(int width,int height,char* cursorString,char* maskSt
if
(
*
cp
!=
' '
)
cursor
->
mask
[
j
*
w
+
i
/
8
]
|=
bit
;
if
(
*
cp
!=
' '
)
cursor
->
mask
[
j
*
w
+
i
/
8
]
|=
bit
;
}
else
}
else
cursor
->
mask
=
(
unsigned
char
*
)
rfbMakeMaskForXCursor
(
width
,
height
,(
char
*
)
cursor
->
source
);
cursor
->
mask
=
(
unsigned
char
*
)
rfbMakeMaskForXCursor
(
width
,
height
,(
char
*
)
cursor
->
source
);
cursor
->
cleanupMask
=
TRUE
;
return
(
cursor
);
return
(
cursor
);
}
}
...
@@ -305,11 +308,19 @@ char* rfbMakeMaskForXCursor(int width,int height,char* source)
...
@@ -305,11 +308,19 @@ char* rfbMakeMaskForXCursor(int width,int height,char* source)
void
rfbFreeCursor
(
rfbCursorPtr
cursor
)
void
rfbFreeCursor
(
rfbCursorPtr
cursor
)
{
{
if
(
cursor
)
{
if
(
cursor
)
{
if
(
cursor
->
richSource
)
if
(
cursor
->
cleanupRichSource
&&
cursor
->
richSource
)
free
(
cursor
->
richSource
);
free
(
cursor
->
richSource
);
free
(
cursor
->
source
);
if
(
cursor
->
cleanupSource
&&
cursor
->
source
)
free
(
cursor
->
mask
);
free
(
cursor
->
source
);
free
(
cursor
);
if
(
cursor
->
cleanupMask
&&
cursor
->
mask
)
free
(
cursor
->
mask
);
if
(
cursor
->
cleanup
)
free
(
cursor
);
else
{
cursor
->
cleanup
=
cursor
->
cleanupSource
=
cursor
->
cleanupMask
=
cursor
->
cleanupRichSource
=
FALSE
;
cursor
->
source
=
cursor
->
mask
=
cursor
->
richSource
=
0
;
}
}
}
}
}
...
@@ -323,8 +334,11 @@ void MakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
...
@@ -323,8 +334,11 @@ void MakeXCursorFromRichCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
uint32_t
background
;
uint32_t
background
;
char
*
back
=
(
char
*
)
&
background
;
char
*
back
=
(
char
*
)
&
background
;
unsigned
char
bit
;
unsigned
char
bit
;
if
(
cursor
->
source
&&
cursor
->
cleanupSource
)
free
(
cursor
->
source
);
cursor
->
source
=
(
unsigned
char
*
)
calloc
(
w
,
cursor
->
height
);
cursor
->
source
=
(
unsigned
char
*
)
calloc
(
w
,
cursor
->
height
);
cursor
->
cleanupSource
=
TRUE
;
if
(
format
->
bigEndian
)
if
(
format
->
bigEndian
)
back
+=
4
-
bpp
;
back
+=
4
-
bpp
;
...
@@ -347,7 +361,10 @@ void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
...
@@ -347,7 +361,10 @@ void MakeRichCursorFromXCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr cursor)
unsigned
char
*
cp
;
unsigned
char
*
cp
;
unsigned
char
bit
;
unsigned
char
bit
;
if
(
cursor
->
richSource
&&
cursor
->
cleanupRichSource
)
free
(
cursor
->
richSource
);
cp
=
cursor
->
richSource
=
(
unsigned
char
*
)
calloc
(
cursor
->
width
*
bpp
,
cursor
->
height
);
cp
=
cursor
->
richSource
=
(
unsigned
char
*
)
calloc
(
cursor
->
width
*
bpp
,
cursor
->
height
);
cursor
->
cleanupRichSource
=
TRUE
;
if
(
format
->
bigEndian
)
{
if
(
format
->
bigEndian
)
{
back
+=
4
-
bpp
;
back
+=
4
-
bpp
;
...
@@ -494,7 +511,7 @@ void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c,Bool freeOld)
...
@@ -494,7 +511,7 @@ void rfbSetCursor(rfbScreenInfoPtr rfbScreen,rfbCursorPtr c,Bool freeOld)
LOCK
(
rfbScreen
->
cursorMutex
);
LOCK
(
rfbScreen
->
cursorMutex
);
}
}
if
(
freeOld
&&
rfbScreen
->
cursor
)
if
(
rfbScreen
->
cursor
&&
(
freeOld
||
rfbScreen
->
cursor
->
cleanup
)
)
rfbFreeCursor
(
rfbScreen
->
cursor
);
rfbFreeCursor
(
rfbScreen
->
cursor
);
rfbScreen
->
cursor
=
c
;
rfbScreen
->
cursor
=
c
;
...
...
libvncclient/client_test.c
View file @
964aa162
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <time.h>
#include <time.h>
#include <errno.h>
#include <rfb/rfbclient.h>
#include <rfb/rfbclient.h>
void
PrintRect
(
rfbClient
*
client
,
int
x
,
int
y
,
int
w
,
int
h
)
{
void
PrintRect
(
rfbClient
*
client
,
int
x
,
int
y
,
int
w
,
int
h
)
{
...
@@ -39,14 +40,33 @@ void SaveFramebufferAsPGM(rfbClient* client, int x, int y, int w, int h) {
...
@@ -39,14 +40,33 @@ void SaveFramebufferAsPGM(rfbClient* client, int x, int y, int w, int h) {
fputc
(
client
->
frameBuffer
[
j
+
i
+
bpp
-
2
],
f
);
fputc
(
client
->
frameBuffer
[
j
+
i
+
bpp
-
2
],
f
);
fputc
(
client
->
frameBuffer
[
j
+
i
+
bpp
-
3
],
f
);
fputc
(
client
->
frameBuffer
[
j
+
i
+
bpp
-
3
],
f
);
}
else
{
}
else
{
fputc
(
client
->
frameBuffer
[
j
+
i
+
bpp
+
0
],
f
);
fputc
(
client
->
frameBuffer
[
j
+
i
+
0
],
f
);
fputc
(
client
->
frameBuffer
[
j
+
i
+
bpp
+
1
],
f
);
fputc
(
client
->
frameBuffer
[
j
+
i
+
1
],
f
);
fputc
(
client
->
frameBuffer
[
j
+
i
+
bpp
+
2
],
f
);
fputc
(
client
->
frameBuffer
[
j
+
i
+
2
],
f
);
}
}
}
}
fclose
(
f
);
fclose
(
f
);
}
}
int
WaitForMessage
(
rfbClient
*
client
,
unsigned
int
usecs
)
{
fd_set
fds
;
struct
timeval
timeout
;
int
num
;
timeout
.
tv_sec
=
(
usecs
/
1000000
);
timeout
.
tv_usec
=
(
usecs
%
1000000
);
FD_ZERO
(
&
fds
);
FD_SET
(
client
->
sock
,
&
fds
);
num
=
select
(
client
->
sock
+
1
,
&
fds
,
NULL
,
NULL
,
&
timeout
);
if
(
num
<
0
)
rfbClientLog
(
"Waiting for message failed: %d (%s)
\n
"
,
errno
,
strerror
(
errno
));
return
num
;
}
int
int
main
(
int
argc
,
char
**
argv
)
main
(
int
argc
,
char
**
argv
)
{
{
...
@@ -54,9 +74,10 @@ main(int argc, char **argv)
...
@@ -54,9 +74,10 @@ main(int argc, char **argv)
rfbClient
*
client
=
rfbGetClient
(
&
argc
,
argv
,
8
,
3
,
4
);
rfbClient
*
client
=
rfbGetClient
(
&
argc
,
argv
,
8
,
3
,
4
);
const
char
*
vncServerHost
=
""
;
const
char
*
vncServerHost
=
""
;
int
vncServerPort
=
5900
;
int
vncServerPort
=
5900
;
time_t
t
=
time
(
0
);
client
->
GotFrameBufferUpdate
=
PrintRect
;
client
->
GotFrameBufferUpdate
=
PrintRect
;
client
->
GotFrameBufferUpdate
=
SaveFramebufferAsPGM
;
//
client->GotFrameBufferUpdate = SaveFramebufferAsPGM;
/* The -listen option is used to make us a daemon process which listens for
/* The -listen option is used to make us a daemon process which listens for
incoming connections from servers, rather than actively connecting to a
incoming connections from servers, rather than actively connecting to a
...
@@ -86,13 +107,22 @@ main(int argc, char **argv)
...
@@ -86,13 +107,22 @@ main(int argc, char **argv)
}
}
client
->
appData
.
encodingsString
=
"tight"
;
client
->
appData
.
encodingsString
=
"tight"
;
rfbInitClient
(
client
,
vncServerHost
,
vncServerPort
);
if
(
!
rfbInitClient
(
client
,
vncServerHost
,
vncServerPort
))
{
rfbClientCleanup
(
client
);
return
1
;
}
while
(
1
)
{
while
(
time
(
0
)
-
t
<
5
)
{
if
(
!
HandleRFBServerMessage
(
client
))
static
int
i
=
0
;
fprintf
(
stderr
,
"
\r
%d"
,
i
++
);
if
(
WaitForMessage
(
client
,
500
)
<
0
)
break
;
if
(
!
HandleRFBServerMessage
(
client
))
break
;
break
;
}
}
rfbClientCleanup
(
client
);
return
0
;
return
0
;
}
}
libvncclient/rfbproto.c
View file @
964aa162
...
@@ -979,10 +979,10 @@ PrintPixelFormat(format)
...
@@ -979,10 +979,10 @@ PrintPixelFormat(format)
(
format
->
bigEndian
?
"Most"
:
"Least"
));
(
format
->
bigEndian
?
"Most"
:
"Least"
));
}
}
if
(
format
->
trueColour
)
{
if
(
format
->
trueColour
)
{
rfbClientLog
(
" TRUE colour: max red %d green %d blue %d"
,
rfbClientLog
(
" TRUE colour: max red %d green %d blue %d"
format
->
redMax
,
format
->
greenMax
,
format
->
blueMax
);
", shift red %d green %d blue %d
\n
"
,
rfbClientLog
(
", shift red %d green %d blue %d
\n
"
,
format
->
redMax
,
format
->
greenMax
,
format
->
blueMax
,
format
->
redShift
,
format
->
greenShift
,
format
->
blueShift
);
format
->
redShift
,
format
->
greenShift
,
format
->
blueShift
);
}
else
{
}
else
{
rfbClientLog
(
" Colour map (not true colour).
\n
"
);
rfbClientLog
(
" Colour map (not true colour).
\n
"
);
}
}
...
...
libvncclient/vncviewer.c
View file @
964aa162
...
@@ -121,3 +121,7 @@ Bool rfbInitClient(rfbClient* client,const char* vncServerHost,int vncServerPort
...
@@ -121,3 +121,7 @@ Bool rfbInitClient(rfbClient* client,const char* vncServerHost,int vncServerPort
return
TRUE
;
return
TRUE
;
}
}
void
rfbClientCleanup
(
rfbClient
*
client
)
{
free
(
client
);
}
main.c
View file @
964aa162
...
@@ -404,6 +404,7 @@ void defaultSetXCutText(char* text, int len, rfbClientPtr cl)
...
@@ -404,6 +404,7 @@ void defaultSetXCutText(char* text, int len, rfbClientPtr cl)
#if defined(WIN32) || defined(sparc) || !defined(NO_STRICT_ANSI)
#if defined(WIN32) || defined(sparc) || !defined(NO_STRICT_ANSI)
static
rfbCursor
myCursor
=
static
rfbCursor
myCursor
=
{
{
FALSE
,
FALSE
,
FALSE
,
FALSE
,
(
unsigned
char
*
)
"
\000\102\044\030\044\102\000
"
,
(
unsigned
char
*
)
"
\000\102\044\030\044\102\000
"
,
(
unsigned
char
*
)
"
\347\347\176\074\176\347\347
"
,
(
unsigned
char
*
)
"
\347\347\176\074\176\347\347
"
,
8
,
7
,
3
,
3
,
8
,
7
,
3
,
3
,
...
@@ -414,14 +415,13 @@ static rfbCursor myCursor =
...
@@ -414,14 +415,13 @@ static rfbCursor myCursor =
#else
#else
static
rfbCursor
myCursor
=
static
rfbCursor
myCursor
=
{
{
cleanup
:
FALSE
,
cleanupSource
:
FALSE
,
cleanupMask
:
FALSE
,
cleanupRichSource
:
FALSE
,
source
:
"
\000\102\044\030\044\102\000
"
,
source
:
"
\000\102\044\030\044\102\000
"
,
mask
:
"
\347\347\176\074\176\347\347
"
,
mask
:
"
\347\347\176\074\176\347\347
"
,
width
:
8
,
height
:
7
,
xhot
:
3
,
yhot
:
3
,
width
:
8
,
height
:
7
,
xhot
:
3
,
yhot
:
3
,
/*
width: 8, height: 7, xhot: 0, yhot: 0,
source: "\000\074\176\146\176\074\000",
mask: "\176\377\377\377\377\377\176",
*/
foreRed
:
0
,
foreGreen
:
0
,
foreBlue
:
0
,
foreRed
:
0
,
foreGreen
:
0
,
foreBlue
:
0
,
backRed
:
0xffff
,
backGreen
:
0xffff
,
backBlue
:
0xffff
,
backRed
:
0xffff
,
backGreen
:
0xffff
,
backBlue
:
0xffff
,
richSource
:
0
richSource
:
0
...
@@ -713,6 +713,8 @@ void rfbNewFramebuffer(rfbScreenInfoPtr rfbScreen, char *framebuffer,
...
@@ -713,6 +713,8 @@ void rfbNewFramebuffer(rfbScreenInfoPtr rfbScreen, char *framebuffer,
rfbReleaseClientIterator
(
iterator
);
rfbReleaseClientIterator
(
iterator
);
}
}
extern
void
TightCleanup
();
void
rfbScreenCleanup
(
rfbScreenInfoPtr
rfbScreen
)
void
rfbScreenCleanup
(
rfbScreenInfoPtr
rfbScreen
)
{
{
rfbClientIteratorPtr
i
=
rfbGetClientIterator
(
rfbScreen
);
rfbClientIteratorPtr
i
=
rfbGetClientIterator
(
rfbScreen
);
...
@@ -729,7 +731,10 @@ void rfbScreenCleanup(rfbScreenInfoPtr rfbScreen)
...
@@ -729,7 +731,10 @@ void rfbScreenCleanup(rfbScreenInfoPtr rfbScreen)
FREE_IF
(
colourMap
.
data
.
bytes
);
FREE_IF
(
colourMap
.
data
.
bytes
);
FREE_IF
(
underCursorBuffer
);
FREE_IF
(
underCursorBuffer
);
TINI_MUTEX
(
rfbScreen
->
cursorMutex
);
TINI_MUTEX
(
rfbScreen
->
cursorMutex
);
if
(
rfbScreen
->
cursor
)
rfbFreeCursor
(
rfbScreen
->
cursor
);
free
(
rfbScreen
);
free
(
rfbScreen
);
TightCleanup
();
}
}
void
rfbInitServer
(
rfbScreenInfoPtr
rfbScreen
)
void
rfbInitServer
(
rfbScreenInfoPtr
rfbScreen
)
...
...
rfb/rfb.h
View file @
964aa162
...
@@ -635,6 +635,8 @@ extern Bool rfbSendRectEncodingTight(rfbClientPtr cl, int x,int y,int w,int h);
...
@@ -635,6 +635,8 @@ extern Bool rfbSendRectEncodingTight(rfbClientPtr cl, int x,int y,int w,int h);
/* cursor.c */
/* cursor.c */
typedef
struct
rfbCursor
{
typedef
struct
rfbCursor
{
/* set this to true if LibVNCServer has to free this cursor */
Bool
cleanup
,
cleanupSource
,
cleanupMask
,
cleanupRichSource
;
unsigned
char
*
source
;
/* points to bits */
unsigned
char
*
source
;
/* points to bits */
unsigned
char
*
mask
;
/* points to bits */
unsigned
char
*
mask
;
/* points to bits */
unsigned
short
width
,
height
,
xhot
,
yhot
;
/* metrics */
unsigned
short
width
,
height
,
xhot
,
yhot
;
/* metrics */
...
...
rfb/rfbclient.h
View file @
964aa162
...
@@ -189,3 +189,4 @@ extern Bool SameMachine(int sock);
...
@@ -189,3 +189,4 @@ extern Bool SameMachine(int sock);
/* vncviewer.c */
/* vncviewer.c */
rfbClient
*
rfbGetClient
(
int
*
argc
,
char
**
argv
,
int
bitsPerSample
,
int
samplesPerPixel
,
int
bytesPerPixel
);
rfbClient
*
rfbGetClient
(
int
*
argc
,
char
**
argv
,
int
bitsPerSample
,
int
samplesPerPixel
,
int
bytesPerPixel
);
Bool
rfbInitClient
(
rfbClient
*
client
,
const
char
*
vncServerHost
,
int
vncServerPort
);
Bool
rfbInitClient
(
rfbClient
*
client
,
const
char
*
vncServerHost
,
int
vncServerPort
);
void
rfbClientCleanup
(
rfbClient
*
client
);
test/tight-1.c
View file @
964aa162
#include <time.h>
#include <rfb/rfb.h>
#include <rfb/rfb.h>
#include <rfb/rfbclient.h>
#include <rfb/rfbclient.h>
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
int
i
,
j
;
int
i
,
j
;
time_t
t
=
time
(
0
);
rfbScreenInfoPtr
server
=
rfbGetScreen
(
&
argc
,
argv
,
400
,
300
,
8
,
3
,
4
);
rfbScreenInfoPtr
server
=
rfbGetScreen
(
&
argc
,
argv
,
400
,
300
,
8
,
3
,
4
);
rfbClient
*
client
=
rfbGetClient
(
&
argc
,
argv
,
8
,
3
,
4
);
rfbClient
*
client
=
rfbGetClient
(
&
argc
,
argv
,
8
,
3
,
4
);
...
@@ -13,7 +15,7 @@ int main(int argc,char** argv)
...
@@ -13,7 +15,7 @@ int main(int argc,char** argv)
server
->
frameBuffer
[
j
]
=
j
;
server
->
frameBuffer
[
j
]
=
j
;
//server->maxRectsPerUpdate=-1;
//server->maxRectsPerUpdate=-1;
rfbInitServer
(
server
);
rfbInitServer
(
server
);
while
(
1
)
{
while
(
time
(
0
)
-
t
<
20
)
{
for
(
j
=
0
;
j
<
400
;
j
+=
10
)
for
(
j
=
0
;
j
<
400
;
j
+=
10
)
for
(
i
=
0
;
i
<
300
;
i
+=
10
)
for
(
i
=
0
;
i
<
300
;
i
+=
10
)
...
@@ -21,5 +23,10 @@ int main(int argc,char** argv)
...
@@ -21,5 +23,10 @@ int main(int argc,char** argv)
rfbProcessEvents
(
server
,
5000
);
rfbProcessEvents
(
server
,
5000
);
}
}
free
(
server
->
frameBuffer
);
rfbScreenCleanup
(
server
);
rfbClientCleanup
(
client
);
return
(
0
);
return
(
0
);
}
}
tight.c
View file @
964aa162
...
@@ -115,6 +115,17 @@ static char *tightAfterBuf = NULL;
...
@@ -115,6 +115,17 @@ static char *tightAfterBuf = NULL;
static
int
*
prevRowBuf
=
NULL
;
static
int
*
prevRowBuf
=
NULL
;
void
TightCleanup
()
{
if
(
tightBeforeBufSize
)
{
free
(
tightBeforeBuf
);
tightBeforeBufSize
=
0
;
}
if
(
tightAfterBufSize
)
{
free
(
tightAfterBuf
);
tightAfterBufSize
=
0
;
}
}
/* Prototypes for static functions. */
/* Prototypes for static functions. */
...
...
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