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
e0168dbd
Commit
e0168dbd
authored
Nov 18, 2001
by
dscho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
start x11vnc, an x0rfbserver clone
parent
4415df95
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
153 additions
and
7 deletions
+153
-7
Makefile
Makefile
+7
-3
example.c
example.c
+1
-1
main.c
main.c
+5
-0
rfb.h
rfb.h
+3
-2
rfbserver.c
rfbserver.c
+2
-1
x11vnc.c
x11vnc.c
+135
-0
No files found.
Makefile
View file @
e0168dbd
...
...
@@ -9,8 +9,8 @@ VNCSERVERLIB=-L. -lvncserver -L/usr/local/lib -lz -ljpeg
# The code for 3 Bytes/Pixel is not very efficient!
FLAG24
=
-DALLOW24BPP
#
OPTFLAGS=-g # -Wall
OPTFLAGS
=
-O2
-Wall
OPTFLAGS
=
-g
# -Wall
#
OPTFLAGS=-O2 -Wall
CFLAGS
=
$(OPTFLAGS)
$(PTHREADDEF)
$(FLAG24)
$(INCLUDES)
RANLIB
=
ranlib
...
...
@@ -19,7 +19,8 @@ LIBS=$(LDFLAGS) $(VNCSERVERLIB) $(PTHREADLIB)
# for Mac OS X
OSX_LIBS
=
-framework
ApplicationServices
-framework
Carbon
# for Example
# for x11vnc
XLIBS
=
-L
/usr/X11R6/lib
-lX11
SOURCES
=
main.c rfbserver.c sraRegion.c auth.c sockets.c
\
stats.c corre.c hextile.c rre.c translate.c cutpaste.c
\
...
...
@@ -56,6 +57,9 @@ pnmshow: pnmshow.o libvncserver.a
OSXvnc-server
:
mac.o libvncserver.a
$(CC)
-o
OSXvnc-server mac.o
$(LIBS)
$(OSX_LIBS)
x11vnc
:
x11vnc.o libvncserver.a
$(CC)
-o
x11vnc x11vnc.o
$(LIBS)
$(XLIBS)
storepasswd
:
storepasswd.o d3des.o vncauth.o
$(CC)
-o
storepasswd storepasswd.o d3des.o vncauth.o
...
...
example.c
View file @
e0168dbd
...
...
@@ -270,7 +270,7 @@ int main(int argc,char** argv)
#endif
/* this is the non-blocking event loop; a background thread is started */
rfbRunEventLoop
(
rfbScreen
,
40000
,
TRUE
);
rfbRunEventLoop
(
rfbScreen
,
-
1
,
TRUE
);
/* now we could do some cool things like rendering */
while
(
1
)
sleep
(
5
);
/* render(); */
...
...
main.c
View file @
e0168dbd
...
...
@@ -34,6 +34,8 @@
MUTEX
(
logMutex
);
char
rfbEndianTest
=
(
_BYTE_ORDER
==
_LITTLE_ENDIAN
);
/*
* rfbLog prints a time-stamped message to the log file (stderr).
*/
...
...
@@ -580,6 +582,9 @@ rfbProcessEvents(rfbScreenInfoPtr rfbScreen,long usec)
rfbClientPtr
cl
,
clPrev
;
struct
timeval
tv
;
if
(
usec
<
0
)
usec
=
rfbScreen
->
rfbDeferUpdateTime
*
1000
;
rfbCheckFds
(
rfbScreen
,
usec
);
httpCheckFds
(
rfbScreen
);
#ifdef CORBA
...
...
rfb.h
View file @
e0168dbd
...
...
@@ -37,7 +37,8 @@ typedef unsigned char CARD8;
typedef
unsigned
short
CARD16
;
typedef
unsigned
int
CARD32
;
typedef
CARD32
Pixel
;
typedef
CARD32
KeySym
;
/* typedef CARD32 KeySym; */
typedef
unsigned
long
KeySym
;
#define SIGNED signed
/* for some strange reason, "typedef signed char Bool;" yields a four byte
signed int on IRIX, but only for rfbserver.o!!! */
...
...
@@ -518,7 +519,7 @@ typedef struct rfbClientRec {
((l) << 24))
static
const
int
rfbEndianTest
=
(
_BYTE_ORDER
==
_LITTLE_ENDIAN
)
;
extern
char
rfbEndianTest
;
#define Swap16IfLE(s) (rfbEndianTest ? Swap16(s) : (s))
#define Swap24IfLE(l) (rfbEndianTest ? Swap24(l) : (l))
...
...
rfbserver.c
View file @
e0168dbd
...
...
@@ -328,7 +328,8 @@ rfbClientConnectionGone(cl)
}
#endif
FD_CLR
(
cl
->
sock
,
&
(
cl
->
screen
->
allFds
));
if
(
cl
->
sock
>=
0
)
FD_CLR
(
cl
->
sock
,
&
(
cl
->
screen
->
allFds
));
cl
->
clientGoneHook
(
cl
);
...
...
x11vnc.c
0 → 100644
View file @
e0168dbd
#include <X11/Xlib.h>
#include <X11/keysym.h>
#define KEYSYM_H
#include "rfb.h"
int
c
=
0
,
blockLength
=
32
;
void
getImage
(
Display
*
dpy
,
int
xscreen
,
XImage
**
i
)
{
*
i
=
XGetImage
(
dpy
,
RootWindow
(
dpy
,
xscreen
),
0
,
0
,
DisplayWidth
(
dpy
,
xscreen
),
DisplayHeight
(
dpy
,
xscreen
),
AllPlanes
,
ZPixmap
);
}
void
checkForImageUpdates
(
rfbScreenInfoPtr
s
,
char
*
b
)
{
Bool
changed
;
int
i
,
j
,
k
,
l
,
x1
,
y1
;
for
(
j
=
0
;
j
<
s
->
height
;
j
+=
blockLength
)
for
(
i
=
0
;
i
<
s
->
width
;
i
+=
blockLength
)
{
y1
=
j
+
blockLength
;
if
(
y1
>
s
->
height
)
y1
=
s
->
height
;
x1
=
i
+
blockLength
;
if
(
x1
>
s
->
width
)
x1
=
s
->
width
;
y1
*=
s
->
paddedWidthInBytes
;
x1
*=
s
->
bitsPerPixel
/
8
;
changed
=
FALSE
;
for
(
l
=
j
*
s
->
paddedWidthInBytes
;
!
changed
&&
l
<
y1
;
l
+=
s
->
paddedWidthInBytes
)
for
(
k
=
i
*
s
->
bitsPerPixel
/
8
;
k
<
x1
;
k
++
)
if
(
s
->
frameBuffer
[
l
+
k
]
!=
b
[
l
+
k
])
{
// fprintf(stderr,"changed: %d, %d\n",k,l);
changed
=
TRUE
;
goto
changed_p
;
}
if
(
changed
)
{
changed_p:
for
(;
l
<
0
*
y1
;
l
++
)
memcpy
(
/*b+l,*/
s
->
frameBuffer
+
l
,
b
+
l
,
x1
-
l
);
rfbMarkRectAsModified
(
s
,
i
,
j
,
i
+
blockLength
,
j
+
blockLength
);
}
}
}
int
main
(
int
argc
,
char
**
argv
)
{
XImage
*
framebufferImage
;
char
*
backupImage
;
Display
*
dpy
;
int
xscreen
;
rfbScreenInfoPtr
screen
;
dpy
=
XOpenDisplay
(
""
);
xscreen
=
DefaultScreen
(
dpy
);
getImage
(
dpy
,
xscreen
,
&
framebufferImage
);
screen
=
rfbGetScreen
(
&
argc
,
argv
,
framebufferImage
->
width
,
framebufferImage
->
height
,
framebufferImage
->
bits_per_pixel
,
8
,
framebufferImage
->
bits_per_pixel
/
8
);
screen
->
paddedWidthInBytes
=
framebufferImage
->
bytes_per_line
;
screen
->
rfbServerFormat
.
bitsPerPixel
=
framebufferImage
->
bits_per_pixel
;
screen
->
rfbServerFormat
.
depth
=
framebufferImage
->
depth
;
rfbEndianTest
=
framebufferImage
->
bitmap_bit_order
!=
MSBFirst
;
screen
->
rfbServerFormat
.
trueColour
=
TRUE
;
if
(
screen
->
rfbServerFormat
.
bitsPerPixel
==
8
)
{
screen
->
rfbServerFormat
.
redShift
=
0
;
screen
->
rfbServerFormat
.
greenShift
=
2
;
screen
->
rfbServerFormat
.
blueShift
=
5
;
screen
->
rfbServerFormat
.
redMax
=
3
;
screen
->
rfbServerFormat
.
greenMax
=
7
;
screen
->
rfbServerFormat
.
blueMax
=
3
;
}
else
{
screen
->
rfbServerFormat
.
redShift
=
0
;
if
(
framebufferImage
->
red_mask
)
while
(
!
(
framebufferImage
->
red_mask
&
(
1
<<
screen
->
rfbServerFormat
.
redShift
)
)
)
screen
->
rfbServerFormat
.
redShift
++
;
screen
->
rfbServerFormat
.
greenShift
=
0
;
if
(
framebufferImage
->
green_mask
)
while
(
!
(
framebufferImage
->
green_mask
&
(
1
<<
screen
->
rfbServerFormat
.
greenShift
)
)
)
screen
->
rfbServerFormat
.
greenShift
++
;
screen
->
rfbServerFormat
.
blueShift
=
0
;
if
(
framebufferImage
->
blue_mask
)
while
(
!
(
framebufferImage
->
blue_mask
&
(
1
<<
screen
->
rfbServerFormat
.
blueShift
)
)
)
screen
->
rfbServerFormat
.
blueShift
++
;
screen
->
rfbServerFormat
.
redMax
=
framebufferImage
->
red_mask
>>
screen
->
rfbServerFormat
.
redShift
;
screen
->
rfbServerFormat
.
greenMax
=
framebufferImage
->
green_mask
>>
screen
->
rfbServerFormat
.
greenShift
;
screen
->
rfbServerFormat
.
blueMax
=
framebufferImage
->
blue_mask
>>
screen
->
rfbServerFormat
.
blueShift
;
}
backupImage
=
malloc
(
screen
->
height
*
screen
->
paddedWidthInBytes
);
//memcpy(backupImage,framebufferImage->data,screen->height*screen->paddedWidthInBytes);
screen
->
frameBuffer
=
backupImage
;
screen
->
rfbDeferUpdateTime
=
500
;
screen
->
cursor
=
0
;
rfbInitServer
(
screen
);
while
(
1
)
{
rfbProcessEvents
(
screen
,
-
1
);
if
(
1
||
/*c++>7 &&*/
(
!
screen
->
rfbClientHead
||
!
FB_UPDATE_PENDING
(
screen
->
rfbClientHead
)))
{
c
=
0
;
framebufferImage
->
f
.
destroy_image
(
framebufferImage
);
getImage
(
dpy
,
xscreen
,
&
framebufferImage
);
//checkForImageUpdates(screen,framebufferImage->data);
}
fprintf
(
stderr
,
"%x
\n
%x
\n
---
\n
"
,
screen
->
frameBuffer
,
framebufferImage
->
data
);
memcpy
(
screen
->
frameBuffer
,
framebufferImage
->
data
,
screen
->
height
/
10
*
screen
->
paddedWidthInBytes
);
rfbMarkRectAsModified
(
screen
,
0
,
0
,
screen
->
width
,
screen
->
height
);
#if 0
{
int i,j,r,g,b;
FILE* f=fopen("test.pnm","wb");
fprintf(f,"P6\n%d %d\n255\n",screen->width,screen->height);
for(j=0;j<screen->height;j++)
for(i=0;i<screen->width;i++) {
//r=screen->frameBuffer[j*screen->paddedWidthInBytes+i*2];
r=framebufferImage->data[j*screen->paddedWidthInBytes+i*2];
fputc(((r>>screen->rfbServerFormat.redShift)&screen->rfbServerFormat.redMax)*255/screen->rfbServerFormat.redMax,f);
fputc(((r>>screen->rfbServerFormat.greenShift)&screen->rfbServerFormat.greenMax)*255/screen->rfbServerFormat.greenMax,f);
fputc(((r>>screen->rfbServerFormat.blueShift)&screen->rfbServerFormat.blueMax)*255/screen->rfbServerFormat.blueMax,f);
}
fclose(f);
}
#endif
}
return
(
0
);
}
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