Home | History | Annotate | Download | only in turbovnc
      1 #!/usr/bin/perl
      2 #
      3 # This script has been (or is hereby) released into the public domain by
      4 # its author, Karl J. Runge <runge (at] karlrunge.com>. This applies worldwide.
      5 # 
      6 # In case this is not legally possible: Karl J. Runge grants anyone the
      7 # right to use this work for any purpose, without any conditions, unless
      8 # such conditions are required by law.
      9 
     10 while (<>) {
     11 	if (/^#include.*"rfb.h"/) {
     12 		print <<END;
     13 #include <rfb/rfb.h>
     14 #define Bool rfbBool
     15 #define CARD32 uint32_t
     16 #define CARD16 uint16_t
     17 #define CARD8 uint8_t
     18 #define xalloc malloc
     19 #define xrealloc realloc
     20 #define rfbTightNoZlib 0x0A
     21 #define tightSubsampLevel correMaxWidth
     22 
     23 #if LIBVNCSERVER_HAVE_LIBPTHREAD && LIBVNCSERVER_HAVE_TLS
     24 #define TLS __thread
     25 #else
     26 #define TLS
     27 #endif
     28 
     29 END
     30 		next;
     31 	}
     32 	foreach $func (qw(FindBestSolidArea ExtendSolidArea CheckSolidTile CheckSolidTile##bpp CheckSolidTile8 CheckSolidTile16 CheckSolidTile32 Pack24)) {
     33 		if (/static.*\b\Q$func\E\b/ && !exists $did_static{$func}) {
     34 			$_ =~ s/\b\Q$func\E\b(\s*)\(/$func$1(rfbClientPtr cl, /;
     35 			$did_static{$func} = 1;
     36 		} elsif (/\b\Q$func\E\b\s*\(/) {
     37 			$_ =~ s/\b\Q$func\E\b(\s*)\(/$func$1(cl, /;
     38 		}
     39 	}
     40 
     41 #	if (/^\s*subsampLevel\s*=\s*cl/) {
     42 #		$_ = "//$_";
     43 #		print "subsampLevel = 0;\n";
     44 #	}
     45 
     46 #	$_ =~ s/cl->tightQualityLevel;/cl->tightQualityLevel * 10;/;
     47 
     48 	if (/^static\s+(Bool|int|CARD32|PALETTE|char|unsigned|tjhandle)\s+[^()]*;\s*$/) {
     49 		$_ =~ s/^static/static TLS /;
     50 	}
     51 
     52 	$_ =~ s/rfbScreen.pfbMemory/cl->scaledScreen->frameBuffer/g;
     53 	$_ =~ s/rfbScreen.paddedWidthInBytes/cl->scaledScreen->paddedWidthInBytes/g;
     54 	$_ =~ s/rfbScreen.bitsPerPixel/cl->scaledScreen->bitsPerPixel/g;
     55 	$_ =~ s/rfbServerFormat/cl->screen->serverFormat/g;
     56 
     57 	if (/^(FindBestSolidArea|ExtendSolidArea|static void Pack24|CheckSolidTile)\(cl/) {
     58 		$_ .= "rfbClientPtr cl;\n";
     59 	}
     60 	if (/^(CheckSolidTile##bpp)\(cl/) {
     61 		$_ .= "rfbClientPtr cl; \\\n";
     62 	}
     63 	$_ =~ s/\bublen\b/cl->ublen/;
     64 	$_ =~ s/\bupdateBuf\b/cl->updateBuf/;
     65 
     66 	if (/cl->(rfbRectanglesSent|rfbBytesSent)/) {
     67 		$_ = "//$_";
     68 	}
     69 	print;
     70 }
     71 
     72 print <<END;
     73 
     74 void rfbTightCleanup(rfbScreenInfoPtr screen) {
     75 }
     76 
     77 END
     78 
     79 
     80