summaryrefslogtreecommitdiffstats
path: root/x11vnc/misc/turbovnc/convert
blob: f218f84e34d1bd392dafc481b3af6f35fcefbb78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/perl
#
# This script has been (or is hereby) released into the public domain by
# its author, Karl J. Runge <runge@karlrunge.com>. This applies worldwide.
# 
# In case this is not legally possible: Karl J. Runge grants anyone the
# right to use this work for any purpose, without any conditions, unless
# such conditions are required by law.

while (<>) {
	if (/^#include.*"rfb.h"/) {
		print <<END;
#include <rfb/rfb.h>
#define Bool rfbBool
#define CARD32 uint32_t
#define CARD16 uint16_t
#define CARD8 uint8_t
#define xalloc malloc
#define xrealloc realloc
#define rfbTightNoZlib 0x0A
#define tightSubsampLevel correMaxWidth

#if LIBVNCSERVER_HAVE_LIBPTHREAD && LIBVNCSERVER_HAVE_TLS
#define TLS __thread
#else
#define TLS
#endif

END
		next;
	}
	foreach $func (qw(FindBestSolidArea ExtendSolidArea CheckSolidTile CheckSolidTile##bpp CheckSolidTile8 CheckSolidTile16 CheckSolidTile32 Pack24)) {
		if (/static.*\b\Q$func\E\b/ && !exists $did_static{$func}) {
			$_ =~ s/\b\Q$func\E\b(\s*)\(/$func$1(rfbClientPtr cl, /;
			$did_static{$func} = 1;
		} elsif (/\b\Q$func\E\b\s*\(/) {
			$_ =~ s/\b\Q$func\E\b(\s*)\(/$func$1(cl, /;
		}
	}

#	if (/^\s*subsampLevel\s*=\s*cl/) {
#		$_ = "//$_";
#		print "subsampLevel = 0;\n";
#	}

#	$_ =~ s/cl->tightQualityLevel;/cl->tightQualityLevel * 10;/;

	if (/^static\s+(Bool|int|CARD32|PALETTE|char|unsigned|tjhandle)\s+[^()]*;\s*$/) {
		$_ =~ s/^static/static TLS /;
	}

	$_ =~ s/rfbScreen.pfbMemory/cl->scaledScreen->frameBuffer/g;
	$_ =~ s/rfbScreen.paddedWidthInBytes/cl->scaledScreen->paddedWidthInBytes/g;
	$_ =~ s/rfbScreen.bitsPerPixel/cl->scaledScreen->bitsPerPixel/g;
	$_ =~ s/rfbServerFormat/cl->screen->serverFormat/g;

	if (/^(FindBestSolidArea|ExtendSolidArea|static void Pack24|CheckSolidTile)\(cl/) {
		$_ .= "rfbClientPtr cl;\n";
	}
	if (/^(CheckSolidTile##bpp)\(cl/) {
		$_ .= "rfbClientPtr cl; \\\n";
	}
	$_ =~ s/\bublen\b/cl->ublen/;
	$_ =~ s/\bupdateBuf\b/cl->updateBuf/;

	if (/cl->(rfbRectanglesSent|rfbBytesSent)/) {
		$_ = "//$_";
	}
	print;
}

print <<END;

void rfbTightCleanup(rfbScreenInfoPtr screen) {
}

END