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
af4e0267
Commit
af4e0267
authored
Aug 14, 2001
by
dscho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
hooks inserted
parent
757fdc24
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
70 additions
and
42 deletions
+70
-42
Makefile
Makefile
+2
-2
example.c
example.c
+29
-11
main.c
main.c
+16
-25
rfb.h
rfb.h
+15
-2
rfbserver.c
rfbserver.c
+8
-2
No files found.
Makefile
View file @
af4e0267
...
@@ -8,10 +8,10 @@ VNCAUTHLIB=-Llibvncauth -lvncauth
...
@@ -8,10 +8,10 @@ VNCAUTHLIB=-Llibvncauth -lvncauth
VNCSERVERLIB
=
-L
.
-lvncserver
-lz
-ljpeg
VNCSERVERLIB
=
-L
.
-lvncserver
-lz
-ljpeg
# These two lines enable useage of PThreads
# These two lines enable useage of PThreads
CFLAGS
+=
-DHAVE_PTHREADS
#
CFLAGS += -DHAVE_PTHREADS
VNCSERVERLIB
+=
-lpthread
VNCSERVERLIB
+=
-lpthread
LIBS
=
$(VNCSERVERLIB)
$(VNCAUTHLIB)
LIBS
=
$(
LDFLAGS)
$(
VNCSERVERLIB)
$(VNCAUTHLIB)
# for Mac OS X
# for Mac OS X
OSX_LIBS
=
-framework
ApplicationServices
-framework
Carbon
OSX_LIBS
=
-framework
ApplicationServices
-framework
Carbon
...
...
example.c
View file @
af4e0267
...
@@ -32,26 +32,49 @@
...
@@ -32,26 +32,49 @@
const
int
maxx
=
640
,
maxy
=
480
,
bpp
=
4
;
const
int
maxx
=
640
,
maxy
=
480
,
bpp
=
4
;
void
initBuffer
(
char
*
buffer
)
{
int
i
,
j
;
for
(
i
=
0
;
i
<
maxx
;
++
i
)
for
(
j
=
0
;
j
<
maxy
;
++
j
)
{
buffer
[(
j
*
maxx
+
i
)
*
bpp
]
=
i
*
256
/
maxx
;
buffer
[(
j
*
maxx
+
i
)
*
bpp
+
1
]
=
j
*
256
/
maxy
;
buffer
[(
j
*
maxx
+
i
)
*
bpp
+
2
]
=
(
i
+
j
)
*
256
/
(
maxx
*
maxy
);
buffer
[(
j
*
maxx
+
i
)
*
bpp
+
3
]
=
(
i
-
j
)
*
256
/
(
maxx
*
maxy
);
}
}
void
doptr
(
int
buttonMask
,
int
x
,
int
y
,
rfbClientPtr
cl
)
void
doptr
(
int
buttonMask
,
int
x
,
int
y
,
rfbClientPtr
cl
)
{
{
if
(
buttonMask
&&
x
>=
0
&&
y
>=
0
&&
x
<
maxx
&&
y
<
maxy
)
{
if
(
buttonMask
&&
x
>=
0
&&
y
>=
0
&&
x
<
maxx
&&
y
<
maxy
)
{
int
i
;
int
i
,
j
,
x1
,
x2
,
y1
,
y2
;
for
(
i
=
0
;
i
<
bpp
;
i
++
)
x1
=
x
-
buttonMask
;
if
(
x1
<
0
)
x1
=
0
;
cl
->
screen
->
frameBuffer
[
y
*
cl
->
screen
->
paddedWidthInBytes
+
x
*
bpp
+
i
]
^=
0xff
;
x2
=
x
+
buttonMask
;
if
(
x2
>
maxx
)
x2
=
maxx
;
rfbMarkRectAsModified
(
cl
->
screen
,
x
,
y
,
x
+
1
,
y
+
1
);
y1
=
y
-
buttonMask
;
if
(
y1
<
0
)
y1
=
0
;
y2
=
y
+
buttonMask
;
if
(
y2
>
maxy
)
y2
=
maxy
;
for
(
i
=
x1
*
bpp
;
i
<
x2
*
bpp
;
i
++
)
for
(
j
=
y1
;
j
<
y2
;
j
++
)
cl
->
screen
->
frameBuffer
[
j
*
cl
->
screen
->
paddedWidthInBytes
+
i
]
=
0xff
;
rfbMarkRectAsModified
(
cl
->
screen
,
x1
,
y1
,
x2
,
y2
);
rfbGotXCutText
(
cl
->
screen
,
"Hallo"
,
5
);
rfbGotXCutText
(
cl
->
screen
,
"Hallo"
,
5
);
}
}
}
}
void
dokey
(
Bool
down
,
KeySym
key
,
rfbClientPtr
cl
)
void
dokey
(
Bool
down
,
KeySym
key
,
rfbClientPtr
cl
)
{
{
if
(
down
&&
key
==
XK_Escape
)
if
(
down
&&
key
==
XK_Escape
)
rfbCloseClient
(
cl
);
rfbCloseClient
(
cl
);
else
if
(
down
&&
key
==
'c'
)
{
initBuffer
(
cl
->
screen
->
frameBuffer
);
rfbMarkRectAsModified
(
cl
->
screen
,
0
,
0
,
maxx
,
maxy
);
}
}
}
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
int
i
,
j
;
rfbScreenInfoPtr
rfbScreen
=
rfbDefaultScreenInit
(
argc
,
argv
);
rfbScreenInfoPtr
rfbScreen
=
rfbDefaultScreenInit
(
argc
,
argv
);
rfbScreen
->
desktopName
=
"LibVNCServer Example"
;
rfbScreen
->
desktopName
=
"LibVNCServer Example"
;
rfbScreen
->
frameBuffer
=
(
char
*
)
malloc
(
maxx
*
maxy
*
bpp
);
rfbScreen
->
frameBuffer
=
(
char
*
)
malloc
(
maxx
*
maxy
*
bpp
);
...
@@ -61,12 +84,7 @@ int main(int argc,char** argv)
...
@@ -61,12 +84,7 @@ int main(int argc,char** argv)
rfbScreen
->
ptrAddEvent
=
doptr
;
rfbScreen
->
ptrAddEvent
=
doptr
;
rfbScreen
->
kbdAddEvent
=
dokey
;
rfbScreen
->
kbdAddEvent
=
dokey
;
for
(
i
=
0
;
i
<
maxx
;
++
i
)
initBuffer
(
rfbScreen
->
frameBuffer
);
for
(
j
=
0
;
j
<
maxy
;
++
j
)
{
rfbScreen
->
frameBuffer
[(
j
*
maxx
+
i
)
*
bpp
]
=
i
*
256
/
maxx
;
rfbScreen
->
frameBuffer
[(
j
*
maxx
+
i
)
*
bpp
+
1
]
=
j
*
256
/
maxy
;
rfbScreen
->
frameBuffer
[(
j
*
maxx
+
i
)
*
bpp
+
2
]
=
(
i
+
j
)
*
256
/
(
maxx
*
maxy
);
}
runEventLoop
(
rfbScreen
,
40000
,
FALSE
);
runEventLoop
(
rfbScreen
,
40000
,
FALSE
);
runEventLoop
(
rfbScreen
,
40000
,
TRUE
);
runEventLoop
(
rfbScreen
,
40000
,
TRUE
);
...
...
main.c
View file @
af4e0267
...
@@ -279,32 +279,20 @@ processArguments(rfbScreenInfoPtr rfbScreen,int argc, char *argv[])
...
@@ -279,32 +279,20 @@ processArguments(rfbScreenInfoPtr rfbScreen,int argc, char *argv[])
}
}
void
void
DefaultKbdAddEvent
(
down
,
keySym
,
cl
)
defaultKbdAddEvent
(
Bool
down
,
KeySym
keySym
,
rfbClientPtr
cl
)
Bool
down
;
KeySym
keySym
;
rfbClientPtr
cl
;
{
{
}
}
void
void
DefaultPtrAddEvent
(
buttonMask
,
x
,
y
,
cl
)
defaultPtrAddEvent
(
int
buttonMask
,
int
x
,
int
y
,
rfbClientPtr
cl
)
int
buttonMask
;
int
x
;
int
y
;
rfbClientPtr
cl
;
{
{
}
}
void
void
defaultSetXCutText
(
char
*
text
,
int
len
,
rfbClientPtr
cl
)
DefaultKbdReleaseAllKeys
(
cl
)
rfbClientPtr
cl
;
{
{
}
}
void
DefaultSetXCutText
(
text
,
len
,
cl
)
void
doNothingWithClient
(
rfbClientPtr
cl
)
char
*
text
;
int
len
;
rfbClientPtr
cl
;
{
{
}
}
...
@@ -378,10 +366,12 @@ rfbScreenInfoPtr rfbDefaultScreenInit(int argc,char** argv)
...
@@ -378,10 +366,12 @@ rfbScreenInfoPtr rfbDefaultScreenInit(int argc,char** argv)
rfbScreen
->
screen
.
RegionAppend
=
miRegionAppend
;
rfbScreen
->
screen
.
RegionAppend
=
miRegionAppend
;
rfbScreen
->
screen
.
RegionValidate
=
miRegionValidate
;
rfbScreen
->
screen
.
RegionValidate
=
miRegionValidate
;
rfbScreen
->
kbdAddEvent
=
DefaultKbdAddEvent
;
rfbScreen
->
kbdAddEvent
=
defaultKbdAddEvent
;
rfbScreen
->
kbdReleaseAllKeys
=
DefaultKbdReleaseAllKeys
;
rfbScreen
->
kbdReleaseAllKeys
=
doNothingWithClient
;
rfbScreen
->
ptrAddEvent
=
DefaultPtrAddEvent
;
rfbScreen
->
ptrAddEvent
=
defaultPtrAddEvent
;
rfbScreen
->
setXCutText
=
DefaultSetXCutText
;
rfbScreen
->
setXCutText
=
defaultSetXCutText
;
rfbScreen
->
newClientHook
=
doNothingWithClient
;
return
(
rfbScreen
);
return
(
rfbScreen
);
}
}
...
@@ -394,14 +384,15 @@ processEvents(rfbScreenInfoPtr rfbScreen,long usec)
...
@@ -394,14 +384,15 @@ processEvents(rfbScreenInfoPtr rfbScreen,long usec)
corbaCheckFds
(
rfbScreen
);
corbaCheckFds
(
rfbScreen
);
#endif
#endif
{
{
rfbClient
IteratorPtr
iterator
;
rfbClient
Ptr
cl
,
cl_next
;
rfbClientPtr
cl
;
cl
=
rfbScreen
->
rfbClientHead
;
iterator
=
rfbGetClientIterator
(
rfbScreen
);
while
(
cl
)
{
while
((
cl
=
rfbClientIteratorNext
(
iterator
)))
cl_next
=
cl
->
next
;
if
(
cl
->
sock
>=
0
&&
FB_UPDATE_PENDING
(
cl
))
{
if
(
cl
->
sock
>=
0
&&
FB_UPDATE_PENDING
(
cl
))
{
rfbSendFramebufferUpdate
(
cl
,
cl
->
modifiedRegion
);
rfbSendFramebufferUpdate
(
cl
,
cl
->
modifiedRegion
);
}
}
rfbReleaseClientIterator
(
iterator
);
cl
=
cl_next
;
}
}
}
}
}
...
...
rfb.h
View file @
af4e0267
...
@@ -66,6 +66,8 @@ typedef void (*KbdReleaseAllKeysProcPtr) (struct rfbClientRec* cl);
...
@@ -66,6 +66,8 @@ typedef void (*KbdReleaseAllKeysProcPtr) (struct rfbClientRec* cl);
typedef
void
(
*
PtrAddEventProcPtr
)
(
int
buttonMask
,
int
x
,
int
y
,
struct
rfbClientRec
*
cl
);
typedef
void
(
*
PtrAddEventProcPtr
)
(
int
buttonMask
,
int
x
,
int
y
,
struct
rfbClientRec
*
cl
);
typedef
void
(
*
SetXCutTextProcPtr
)
(
char
*
str
,
int
len
,
struct
rfbClientRec
*
cl
);
typedef
void
(
*
SetXCutTextProcPtr
)
(
char
*
str
,
int
len
,
struct
rfbClientRec
*
cl
);
typedef
void
(
*
NewClientHookPtr
)(
struct
rfbClientRec
*
cl
);
/*
/*
* Per-screen (framebuffer) structure. There is only one of these, since we
* Per-screen (framebuffer) structure. There is only one of these, since we
* don't allow the X server to have multiple screens.
* don't allow the X server to have multiple screens.
...
@@ -167,6 +169,12 @@ typedef struct
...
@@ -167,6 +169,12 @@ typedef struct
KbdReleaseAllKeysProcPtr
kbdReleaseAllKeys
;
KbdReleaseAllKeysProcPtr
kbdReleaseAllKeys
;
PtrAddEventProcPtr
ptrAddEvent
;
PtrAddEventProcPtr
ptrAddEvent
;
SetXCutTextProcPtr
setXCutText
;
SetXCutTextProcPtr
setXCutText
;
/* the following members are hooks, i.e. they are called if set,
but not overriding original functionality */
/* newClientHook is called just after a new client is created */
NewClientHookPtr
newClientHook
;
}
rfbScreenInfo
,
*
rfbScreenInfoPtr
;
}
rfbScreenInfo
,
*
rfbScreenInfoPtr
;
...
@@ -174,7 +182,6 @@ typedef struct
...
@@ -174,7 +182,6 @@ typedef struct
* rfbTranslateFnType is the type of translation functions.
* rfbTranslateFnType is the type of translation functions.
*/
*/
struct
rfbClientRec
;
typedef
void
(
*
rfbTranslateFnType
)(
char
*
table
,
rfbPixelFormat
*
in
,
typedef
void
(
*
rfbTranslateFnType
)(
char
*
table
,
rfbPixelFormat
*
in
,
rfbPixelFormat
*
out
,
rfbPixelFormat
*
out
,
char
*
iptr
,
char
*
optr
,
char
*
iptr
,
char
*
optr
,
...
@@ -186,8 +193,12 @@ typedef void (*rfbTranslateFnType)(char *table, rfbPixelFormat *in,
...
@@ -186,8 +193,12 @@ typedef void (*rfbTranslateFnType)(char *table, rfbPixelFormat *in,
* Per-client structure.
* Per-client structure.
*/
*/
typedef
void
(
*
ClientGoneHookPtr
)(
struct
rfbClientRec
*
cl
);
typedef
struct
rfbClientRec
{
typedef
struct
rfbClientRec
{
rfbScreenInfoPtr
screen
;
rfbScreenInfoPtr
screen
;
void
*
clientData
;
ClientGoneHookPtr
clientGoneHook
;
int
sock
;
int
sock
;
char
*
host
;
char
*
host
;
...
@@ -415,6 +426,8 @@ extern Bool rfbSendFramebufferUpdate(rfbClientPtr cl, RegionRec updateRegion);
...
@@ -415,6 +426,8 @@ extern Bool rfbSendFramebufferUpdate(rfbClientPtr cl, RegionRec updateRegion);
extern
Bool
rfbSendRectEncodingRaw
(
rfbClientPtr
cl
,
int
x
,
int
y
,
int
w
,
int
h
);
extern
Bool
rfbSendRectEncodingRaw
(
rfbClientPtr
cl
,
int
x
,
int
y
,
int
w
,
int
h
);
extern
Bool
rfbSendUpdateBuf
(
rfbClientPtr
cl
);
extern
Bool
rfbSendUpdateBuf
(
rfbClientPtr
cl
);
extern
void
rfbSendServerCutText
(
rfbScreenInfoPtr
rfbScreen
,
char
*
str
,
int
len
);
extern
void
rfbSendServerCutText
(
rfbScreenInfoPtr
rfbScreen
,
char
*
str
,
int
len
);
extern
Bool
rfbSendCopyRegion
(
rfbClientPtr
cl
,
RegionPtr
reg
,
int
dx
,
int
dy
);
extern
Bool
rfbSendLastRectMarker
(
rfbClientPtr
cl
);
void
rfbGotXCutText
(
rfbScreenInfoPtr
rfbScreen
,
char
*
str
,
int
len
);
void
rfbGotXCutText
(
rfbScreenInfoPtr
rfbScreen
,
char
*
str
,
int
len
);
...
@@ -508,7 +521,7 @@ extern void rfbDisconnectUDPSock(rfbScreenInfoPtr cl);
...
@@ -508,7 +521,7 @@ extern void rfbDisconnectUDPSock(rfbScreenInfoPtr cl);
void
rfbMarkRectAsModified
(
rfbScreenInfoPtr
rfbScreen
,
int
x1
,
int
y1
,
int
x2
,
int
y2
);
void
rfbMarkRectAsModified
(
rfbScreenInfoPtr
rfbScreen
,
int
x1
,
int
y1
,
int
x2
,
int
y2
);
void
rfbMarkRegionAsModified
(
rfbScreenInfoPtr
rfbScreen
,
RegionPtr
modRegion
);
void
rfbMarkRegionAsModified
(
rfbScreenInfoPtr
rfbScreen
,
RegionPtr
modRegion
);
void
doNothingWithClient
(
rfbClientPtr
cl
);
/* functions to make a vnc server */
/* functions to make a vnc server */
extern
rfbScreenInfoPtr
rfbDefaultScreenInit
(
int
argc
,
char
**
argv
);
extern
rfbScreenInfoPtr
rfbDefaultScreenInit
(
int
argc
,
char
**
argv
);
...
...
rfbserver.c
View file @
af4e0267
...
@@ -237,6 +237,10 @@ rfbNewClient(rfbScreen,sock)
...
@@ -237,6 +237,10 @@ rfbNewClient(rfbScreen,sock)
sprintf
(
pv
,
rfbProtocolVersionFormat
,
rfbProtocolMajorVersion
,
sprintf
(
pv
,
rfbProtocolVersionFormat
,
rfbProtocolMajorVersion
,
rfbProtocolMinorVersion
);
rfbProtocolMinorVersion
);
cl
->
clientData
=
NULL
;
cl
->
clientGoneHook
=
doNothingWithClient
;
cl
->
screen
->
newClientHook
(
cl
);
if
(
WriteExact
(
cl
,
pv
,
sz_rfbProtocolVersionMsg
)
<
0
)
{
if
(
WriteExact
(
cl
,
pv
,
sz_rfbProtocolVersionMsg
)
<
0
)
{
rfbLogPerror
(
"rfbNewClient: write"
);
rfbLogPerror
(
"rfbNewClient: write"
);
rfbCloseClient
(
cl
);
rfbCloseClient
(
cl
);
...
@@ -261,6 +265,8 @@ rfbClientConnectionGone(cl)
...
@@ -261,6 +265,8 @@ rfbClientConnectionGone(cl)
pthread_mutex_lock
(
&
rfbClientListMutex
);
pthread_mutex_lock
(
&
rfbClientListMutex
);
#endif
#endif
cl
->
clientGoneHook
(
cl
);
rfbLog
(
"Client %s gone
\n
"
,
cl
->
host
);
rfbLog
(
"Client %s gone
\n
"
,
cl
->
host
);
free
(
cl
->
host
);
free
(
cl
->
host
);
...
@@ -1052,7 +1058,7 @@ rfbSendFramebufferUpdate(cl, updateRegion)
...
@@ -1052,7 +1058,7 @@ rfbSendFramebufferUpdate(cl, updateRegion)
* of a later one.
* of a later one.
*/
*/
static
Bool
Bool
rfbSendCopyRegion
(
cl
,
reg
,
dx
,
dy
)
rfbSendCopyRegion
(
cl
,
reg
,
dx
,
dy
)
rfbClientPtr
cl
;
rfbClientPtr
cl
;
RegionPtr
reg
;
RegionPtr
reg
;
...
@@ -1216,7 +1222,7 @@ rfbSendRectEncodingRaw(cl, x, y, w, h)
...
@@ -1216,7 +1222,7 @@ rfbSendRectEncodingRaw(cl, x, y, w, h)
* protocol).
* protocol).
*/
*/
static
Bool
Bool
rfbSendLastRectMarker
(
cl
)
rfbSendLastRectMarker
(
cl
)
rfbClientPtr
cl
;
rfbClientPtr
cl
;
{
{
...
...
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