mesg.h 3.7 KB

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