vnc.h 3.0 KB

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