]> git.lizzy.rs Git - plan9front.git/blob - sys/src/cmd/vnc/vnc.h
vnc/devdraw: fix topnwindows() panic when images are not windows (thanks aiju)
[plan9front.git] / sys / src / cmd / vnc / vnc.h
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         Rectangle       dim;
35         Pixfmt;
36         char            *name;  /* client only */
37
38         int             canresize;
39         struct {
40                 ulong           id;
41                 Rectangle       rect;
42                 ulong           flags;
43         }               screen[1];
44 };
45
46 enum {
47         /* authentication negotiation */
48         AFailed         = 0,
49         ANoAuth,
50         AVncAuth,
51
52         /* vnc auth negotiation */
53         VncAuthOK       = 0,
54         VncAuthFailed,
55         VncAuthTooMany,
56         VncChalLen      = 16,
57
58         /* server to client */
59         MFrameUpdate    = 0,
60         MSetCmap,
61         MBell,
62         MSCut,
63         MSAck,
64
65         /* client to server */
66         MPixFmt         = 0,
67         MFixCmap,
68         MSetEnc,
69         MFrameReq,
70         MKey,
71         MMouse,
72         MCCut,
73         MSetDesktopSize = 251,
74
75         /* image encoding methods */
76         EncRaw          = 0,
77         EncCopyRect     = 1,
78         EncRre          = 2,
79         EncCorre        = 4,
80         EncHextile      = 5,
81         EncZlib         = 6,  /* 6,7,8 have been used by others */
82         EncTight        = 7,
83         EncZHextile     = 8,
84         EncMouseWarp    = 9,
85
86         EncDesktopSize  = -223,
87         EncXDesktopSize = -308,
88
89         /* paramaters for hextile encoding */
90         HextileDim      = 16,
91         HextileRaw      = 1,
92         HextileBack     = 2,
93         HextileFore     = 4,
94         HextileRects    = 8,
95         HextileCols     = 16
96 };
97
98 /*
99  * we're only using the ulong as a place to store bytes,
100  * and as something to compare against.
101  * the bytes are stored in little-endian format.
102  */
103 typedef ulong Color;
104
105 /* auth.c */
106 extern  int             vncauth(Vnc*, char*);
107 extern  int             vnchandshake(Vnc*);
108 extern  int             vncsrvauth(Vnc*);
109 extern  int             vncsrvhandshake(Vnc*);
110
111 /* proto.c */
112 extern  Vnc*            vncinit(int, int, Vnc*);
113 extern  uchar           vncrdchar(Vnc*);
114 extern  ushort          vncrdshort(Vnc*);
115 extern  ulong           vncrdlong(Vnc*);
116 extern  Point           vncrdpoint(Vnc*);
117 extern  Rectangle       vncrdrect(Vnc*);
118 extern  Rectangle       vncrdcorect(Vnc*);
119 extern  Pixfmt          vncrdpixfmt(Vnc*);
120 extern  void            vncrdbytes(Vnc*, void*, int);
121 extern  char*           vncrdstring(Vnc*);
122 extern  char*   vncrdstringx(Vnc*);
123 extern  void            vncwrstring(Vnc*, char*);
124 extern  void            vncgobble(Vnc*, long);
125
126 extern  void            vncflush(Vnc*);
127 extern  void            vncterm(Vnc*);
128 extern  void            vncwrbytes(Vnc*, void*, int);
129 extern  void            vncwrlong(Vnc*, ulong);
130 extern  void            vncwrshort(Vnc*, ushort);
131 extern  void            vncwrchar(Vnc*, uchar);
132 extern  void            vncwrpixfmt(Vnc*, Pixfmt*);
133 extern  void            vncwrrect(Vnc*, Rectangle);
134 extern  void            vncwrpoint(Vnc*, Point);
135
136 extern  void            vnclock(Vnc*);          /* for writing */
137 extern  void            vncunlock(Vnc*);
138
139 extern  void            hexdump(void*, int);
140
141 /* implemented by clients of the io library */
142 extern  void            vnchungup(Vnc*);
143
144 extern  int             verbose;
145 extern  char*           serveraddr;