mesg.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. /* VERSION 1 introduces plumbing
  10. 2 increases SNARFSIZE from 4096 to 32000
  11. */
  12. #define VERSION 2
  13. #define TBLOCKSIZE 512 /* largest piece of text sent to terminal */
  14. #define DATASIZE (UTFmax*TBLOCKSIZE+30) /* ... including protocol header stuff */
  15. #define SNARFSIZE 32000 /* maximum length of exchanged snarf buffer, must fit in 15 bits */
  16. /*
  17. * Messages originating at the terminal
  18. */
  19. typedef enum Tmesg
  20. {
  21. Tversion, /* version */
  22. Tstartcmdfile, /* terminal just opened command frame */
  23. Tcheck, /* ask host to poke with Hcheck */
  24. Trequest, /* request data to fill a hole */
  25. Torigin, /* gimme an Horigin near here */
  26. Tstartfile, /* terminal just opened a file's frame */
  27. Tworkfile, /* set file to which commands apply */
  28. Ttype, /* add some characters, but terminal already knows */
  29. Tcut,
  30. Tpaste,
  31. Tsnarf,
  32. Tstartnewfile, /* terminal just opened a new frame */
  33. Twrite, /* write file */
  34. Tclose, /* terminal requests file close; check mod. status */
  35. Tlook, /* search for literal current text */
  36. Tsearch, /* search for last regular expression */
  37. Tsend, /* pretend he typed stuff */
  38. Tdclick, /* double click */
  39. Tstartsnarf, /* initiate snarf buffer exchange */
  40. Tsetsnarf, /* remember string in snarf buffer */
  41. Tack, /* acknowledge Hack */
  42. Texit, /* exit */
  43. Tplumb, /* send plumb message */
  44. TMAX,
  45. }Tmesg;
  46. /*
  47. * Messages originating at the host
  48. */
  49. typedef enum Hmesg
  50. {
  51. Hversion, /* version */
  52. Hbindname, /* attach name[0] to text in terminal */
  53. Hcurrent, /* make named file the typing file */
  54. Hnewname, /* create "" name in menu */
  55. Hmovname, /* move file name in menu */
  56. Hgrow, /* insert space in rasp */
  57. Hcheck0, /* see below */
  58. Hcheck, /* ask terminal to check whether it needs more data */
  59. Hunlock, /* command is finished; user can do things */
  60. Hdata, /* store this data in previously allocated space */
  61. Horigin, /* set origin of file/frame in terminal */
  62. Hunlockfile, /* unlock file in terminal */
  63. Hsetdot, /* set dot in terminal */
  64. Hgrowdata, /* Hgrow + Hdata folded together */
  65. Hmoveto, /* scrolling, context search, etc. */
  66. Hclean, /* named file is now 'clean' */
  67. Hdirty, /* named file is now 'dirty' */
  68. Hcut, /* remove space from rasp */
  69. Hsetpat, /* set remembered regular expression */
  70. Hdelname, /* delete file name from menu */
  71. Hclose, /* close file and remove from menu */
  72. Hsetsnarf, /* remember string in snarf buffer */
  73. Hsnarflen, /* report length of implicit snarf */
  74. Hack, /* request acknowledgement */
  75. Hexit,
  76. Hplumb, /* return plumb message to terminal - version 1 */
  77. HMAX,
  78. }Hmesg;
  79. typedef struct Header{
  80. uchar type; /* one of the above */
  81. uchar count0; /* low bits of data size */
  82. uchar count1; /* high bits of data size */
  83. uchar data[1]; /* variable size */
  84. }Header;
  85. /*
  86. * File transfer protocol schematic, a la Holzmann
  87. * #define N 6
  88. *
  89. * chan h = [4] of { mtype };
  90. * chan t = [4] of { mtype };
  91. *
  92. * mtype = { Hgrow, Hdata,
  93. * Hcheck, Hcheck0,
  94. * Trequest, Tcheck,
  95. * };
  96. *
  97. * active proctype host()
  98. * { byte n;
  99. *
  100. * do
  101. * :: n < N -> n++; t!Hgrow
  102. * :: n == N -> n++; t!Hcheck0
  103. *
  104. * :: h?Trequest -> t!Hdata
  105. * :: h?Tcheck -> t!Hcheck
  106. * od
  107. * }
  108. *
  109. * active proctype term()
  110. * {
  111. * do
  112. * :: t?Hgrow -> h!Trequest
  113. * :: t?Hdata -> skip
  114. * :: t?Hcheck0 -> h!Tcheck
  115. * :: t?Hcheck ->
  116. * if
  117. * :: h!Trequest -> progress: h!Tcheck
  118. * :: break
  119. * fi
  120. * od;
  121. * printf("term exits\n")
  122. * }
  123. *
  124. * From: gerard@research.bell-labs.com
  125. * Date: Tue Jul 17 13:47:23 EDT 2001
  126. * To: rob@research.bell-labs.com
  127. *
  128. * spin -c (or -a) spec
  129. * pcc -DNP -o pan pan.c
  130. * pan -l
  131. *
  132. * proves that there are no non-progress cycles
  133. * (infinite executions *not* passing through
  134. * the statement marked with a label starting
  135. * with the prefix "progress")
  136. *
  137. */