home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume28 / m0 / part01 / fragment.m0 < prev    next >
Text File  |  1994-06-05  |  1KB  |  46 lines

  1. # fragment.m0
  2.  
  3. # fragmentation procedure (cuts a messenger into messenger fragments)
  4. # usage: string int  fragment  array_of_strings
  5. #               int is the maximum length a fragment can have
  6.  
  7. # Note: this is a toy example because it assumes a reliable submission
  8. # channel (with en exactly-once transfer semantics, although messenger
  9. # fragments are allowed to arrive out of order).
  10. # A real fragmentation logic should be able to cope with fragment
  11. # loss and duplification.
  12. # Another limitation is that it can fail if more than 999 fragments
  13. # must be created.
  14.  
  15.  
  16. . 'fragment {
  17.   D ( .X'mX: .X'sX:
  18.   s`m>{
  19.     .'a
  20. #includestring frag_0.m0
  21.     :
  22.     . 'm m a`- 30- :    # header: 20, 2xinteger: 7, padding: 3
  23.     . 'n s` m+1- m / :
  24.     . 't n _cte " "+ :
  25.     . 'k ; :
  26.     [ n {
  27.         [k t3I_cte+a+ s[0m s`>{s`}{m}?]G .'s s[4I`s`1I-]G: ]_ctm XP
  28.       }L
  29.     ]
  30.   }{[s]}? )
  31. } :
  32.  
  33.  
  34. 'printF { P    # define the test procedure only if the console is defined.
  35.         # This test creates many fragments and submits them localy.
  36.         # They reassemble themselves - the recreated final messenger
  37.         # prints a hello msg on the console.
  38.   .'test_fragment{
  39.     [;
  40.      "null0{}_cha'consoleG'_keyG!\"\x0aori=\"_ori _cte+\" (it worked!)\x0a\"+ $"
  41.      120S ]_ctm 150 fragment
  42.      {['console 0 null] X $} L
  43.   }:
  44.   "file `fragment.m0' loaded\x0a" print
  45. }{}?
  46.