123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- /*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
- #include <u.h>
- #include <libc.h>
- #include <bio.h>
- #include <draw.h>
- #include <memdraw.h>
- typedef struct Pixfmt Pixfmt;
- typedef struct Colorfmt Colorfmt;
- typedef struct Vnc Vnc;
- struct Colorfmt {
- int max;
- int shift;
- };
- struct Pixfmt {
- int bpp;
- int depth;
- int bigendian;
- int truecolor;
- Colorfmt red;
- Colorfmt green;
- Colorfmt blue;
- };
- struct Vnc {
- QLock qlock;
- int datafd; /* for network connection */
- int ctlfd; /* control for network connection */
- Biobuf in;
- Biobuf out;
- Point dim;
- Pixfmt pixfmt;
- char *name; /* client only */
- };
- enum {
- /* authentication negotiation */
- AFailed = 0,
- ANoAuth,
- AVncAuth,
- /* vnc auth negotiation */
- VncAuthOK = 0,
- VncAuthFailed,
- VncAuthTooMany,
- VncChalLen = 16,
- /* server to client */
- MFrameUpdate = 0,
- MSetCmap,
- MBell,
- MSCut,
- MSAck,
- /* client to server */
- MPixFmt = 0,
- MFixCmap,
- MSetEnc,
- MFrameReq,
- MKey,
- MMouse,
- MCCut,
- /* image encoding methods */
- EncRaw = 0,
- EncCopyRect = 1,
- EncRre = 2,
- EncCorre = 4,
- EncHextile = 5,
- EncZlib = 6, /* 6,7,8 have been used by others */
- EncTight = 7,
- EncZHextile = 8,
- EncMouseWarp = 9,
- /* paramaters for hextile encoding */
- HextileDim = 16,
- HextileRaw = 1,
- HextileBack = 2,
- HextileFore = 4,
- HextileRects = 8,
- HextileCols = 16
- };
- /*
- * we're only using the uint32_t as a place to store bytes,
- * and as something to compare against.
- * the bytes are stored in little-endian format.
- */
- typedef uint32_t Color;
- /* auth.c */
- extern int vncauth(Vnc*, char*);
- extern int vnchandshake(Vnc*);
- extern int vncsrvauth(Vnc*);
- extern int vncsrvhandshake(Vnc*);
- /* proto.c */
- extern Vnc* vncinit(int, int, Vnc*);
- extern uint8_t vncrdchar(Vnc*);
- extern uint16_t vncrdshort(Vnc*);
- extern uint32_t vncrdlong(Vnc*);
- extern Point vncrdpoint(Vnc*);
- extern Rectangle vncrdrect(Vnc*);
- extern Rectangle vncrdcorect(Vnc*);
- extern Pixfmt vncrdpixfmt(Vnc*);
- extern void vncrdbytes(Vnc*, void*, int);
- extern char* vncrdstring(Vnc*);
- extern char* vncrdstringx(Vnc*);
- extern void vncwrstring(Vnc*, char*);
- extern void vncgobble(Vnc*, int32_t);
- extern void vncflush(Vnc*);
- extern void vncterm(Vnc*);
- extern void vncwrbytes(Vnc*, void*, int);
- extern void vncwrlong(Vnc*, uint32_t);
- extern void vncwrshort(Vnc*, uint16_t);
- extern void vncwrchar(Vnc*, uint8_t);
- extern void vncwrpixfmt(Vnc*, Pixfmt*);
- extern void vncwrrect(Vnc*, Rectangle);
- extern void vncwrpoint(Vnc*, Point);
- extern void vnclock(Vnc*); /* for writing */
- extern void vncunlock(Vnc*);
- extern void hexdump(void*, int);
- /* implemented by clients of the io library */
- extern void vnchungup(Vnc*);
- extern int verbose;
- extern char* serveraddr;
|