1 #include <u.h> 2 #include <libc.h> 3 #include <bio.h> 4 #include <draw.h> 5 #include <memdraw.h> 6 7 typedef struct Pixfmt Pixfmt; 8 typedef struct Colorfmt Colorfmt; 9 typedef struct Vnc Vnc; 10 11 struct Colorfmt { 12 int max; 13 int shift; 14 }; 15 16 struct Pixfmt { 17 int bpp; 18 int depth; 19 int bigendian; 20 int truecolor; 21 Colorfmt red; 22 Colorfmt green; 23 Colorfmt blue; 24 }; 25 26 struct Vnc { 27 QLock; 28 int datafd; /* for network connection */ 29 int ctlfd; /* control for network connection */ 30 31 Biobuf in; 32 Biobuf out; 33 34 Point dim; 35 Pixfmt; 36 char *name; /* client only */ 37 }; 38 39 enum { 40 /* authentication negotiation */ 41 AFailed = 0, 42 ANoAuth, 43 AVncAuth, 44 45 /* vnc auth negotiation */ 46 VncAuthOK = 0, 47 VncAuthFailed, 48 VncAuthTooMany, 49 VncChalLen = 16, 50 51 /* server to client */ 52 MFrameUpdate = 0, 53 MSetCmap, 54 MBell, 55 MSCut, 56 MSAck, 57 58 /* client to server */ 59 MPixFmt = 0, 60 MFixCmap, 61 MSetEnc, 62 MFrameReq, 63 MKey, 64 MMouse, 65 MCCut, 66 67 /* image encoding methods */ 68 EncRaw = 0, 69 EncCopyRect = 1, 70 EncRre = 2, 71 EncCorre = 4, 72 EncHextile = 5, 73 EncZlib = 6, /* 6,7,8 have been used by others */ 74 EncTight = 7, 75 EncZHextile = 8, 76 EncMouseWarp = 9, 77 78 /* paramaters for hextile encoding */ 79 HextileDim = 16, 80 HextileRaw = 1, 81 HextileBack = 2, 82 HextileFore = 4, 83 HextileRects = 8, 84 HextileCols = 16 85 }; 86 87 /* 88 * we're only using the ulong as a place to store bytes, 89 * and as something to compare against. 90 * the bytes are stored in little-endian format. 91 */ 92 typedef ulong Color; 93 94 /* auth.c */ 95 extern int vncauth(Vnc*, char*); 96 extern int vnchandshake(Vnc*); 97 extern int vncsrvauth(Vnc*); 98 extern int vncsrvhandshake(Vnc*); 99 100 /* proto.c */ 101 extern Vnc* vncinit(int, int, Vnc*); 102 extern uchar vncrdchar(Vnc*); 103 extern ushort vncrdshort(Vnc*); 104 extern ulong vncrdlong(Vnc*); 105 extern Point vncrdpoint(Vnc*); 106 extern Rectangle vncrdrect(Vnc*); 107 extern Rectangle vncrdcorect(Vnc*); 108 extern Pixfmt vncrdpixfmt(Vnc*); 109 extern void vncrdbytes(Vnc*, void*, int); 110 extern char* vncrdstring(Vnc*); 111 extern char* vncrdstringx(Vnc*); 112 extern void vncwrstring(Vnc*, char*); 113 extern void vncgobble(Vnc*, long); 114 115 extern void vncflush(Vnc*); 116 extern void vncterm(Vnc*); 117 extern void vncwrbytes(Vnc*, void*, int); 118 extern void vncwrlong(Vnc*, ulong); 119 extern void vncwrshort(Vnc*, ushort); 120 extern void vncwrchar(Vnc*, uchar); 121 extern void vncwrpixfmt(Vnc*, Pixfmt*); 122 extern void vncwrrect(Vnc*, Rectangle); 123 extern void vncwrpoint(Vnc*, Point); 124 125 extern void vnclock(Vnc*); /* for writing */ 126 extern void vncunlock(Vnc*); 127 128 extern void hexdump(void*, int); 129 130 /* implemented by clients of the io library */ 131 extern void vnchungup(Vnc*); 132 133 extern int verbose; 134 extern char* serveraddr;