vnc.h 2.6 KB

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