home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 199.img / HYPE4.ZIP / MAINTAIN.HP < prev    next >
Text File  |  1990-05-08  |  7KB  |  231 lines

  1. ; maintain.hp
  2. ;
  3. ; This script is used to maintain the data files assosiated with the EMAIL
  4. ; system.  Note that the operations performed in this script are done
  5. ; AFTER a caller LOGS OFF the HA5 host.  This is done because these file
  6. ; operations may take some time to complete, depending on the size of the
  7. ; EMAIL files.    For example, when a caller reads a piece of mail, and then
  8. ; deletes that message, a DEL_MSGIDX instruction is written to maintain.dat,
  9. ; and the message doesn't actually get removed from the MSGIDX file and the
  10. ; MSGS file until this script is executed.    After the caller has logged off,
  11. ; it doesn't matter how long these operations take. Remember that all file
  12. ; processing is done sequentially.
  13. ;
  14. ; Also, if additional file processing procedures are added in the future,
  15. ; this may be a good place for those additions.  For example, if the callers
  16. ; names, currently in the file named USERS, were to be maintained in
  17. ; alphabetical order, this would be a good place to reorganize that file.
  18. ;
  19. ; This script is also updates the LAST MESSAGE READ number for the current
  20. ; current caller.
  21.  
  22. ; Read maintain.dat into list for processing.  Note: a maximum of 128, (or
  23. ; the list size) instructions can be processed.
  24. ;
  25. ; F(1) = Have deletes been performed ? true or flase
  26. ; F(9) = True for trace option
  27.  
  28.     set flag(F(1),false)
  29.     set flag(F(9),false)
  30.  
  31.     ifnot get environment(S(3),"HA5_TRACE") set flag(F(9),false)
  32.     if string match(S(3),"true") set flag(F(9),true)
  33.  
  34.     if flag(F(9)) print("Maintain entered")
  35.     ifnot get environment(S(3),"HA5_EMAIL") branch(1)
  36.  
  37. label(1)
  38.     option("ignore case",yes)
  39.  
  40.     ifnot read from("/S(3)\maintain.dat") branch(25)
  41.     set flag(F(1),true)
  42.  
  43.     clear list(0)
  44.     set list("dummy")
  45.     read list(0,"")
  46.     list size(I(0))
  47.     if flag(F(9)) print("List size is /I(0)")
  48.     subtract(I(0),1)
  49.  
  50.     if flag(F(9))  set integer(I(1),1)
  51.     if flag(F(9)) print("List instructions are:")
  52.     ifnot flag(F(9)) branch(5)
  53.  
  54. label(4)
  55.     print("List element /I(1):/L(1)")
  56.     add(I(1),1)
  57.     ifnot greater(I(1),I(0)) branch(4)
  58.  
  59. label(5)
  60.     if flag(F(9)) print("label(5)")
  61.     read from("")
  62.     if flag(F(9)) print( "Maintain entered: /I(0) instructions to process")
  63.  
  64. ; Begin processing all DEL_MSGIDX: instructions.  First, remove all of the
  65. ; specified message numbers from the MSGIDX file, then go back and remove
  66. ; the message contents from the MSGS file.
  67. ;
  68.     set integer(I(1),1)
  69.     set string(S(9),"")
  70. label(10)
  71.     if flag(F(9)) print("Label(10)")
  72.     set string(S(0),"/L(1)")
  73.     if string match(S(0),"DEL_MSGIDX:") branch subroutine(90)
  74.     add(I(1),1)
  75.     ifnot greater(I(1),I(0)) branch(10)
  76.     set string(S(9),"/S(9)#")
  77.     ifnot length("/S(9)",I(9)) set integer(I(9),0)
  78.     ifnot greater(I(9),1) branch subroutine(300)
  79.     ifnot greater(I(9),1) branch(20)
  80.     branch subroutine(100)
  81.  
  82. ; As a final operation, update USERS with callers LAST-MSG read number and
  83. ; update the NEXT_MSG_NO header in the MSGIDX file.
  84. ;
  85. label(20)
  86.     if flag(F(9)) print("Label(20)")
  87.     erase("/S(3)\maintain.dat")
  88. label(25)
  89.     if flag(F(9)) print("Label(25)")
  90.     ifnot flag(F(1)) branch subroutine(300)
  91.     get environment(S(0),"NAME")
  92.     get environment(S(1),"LAST_MSG_NO")
  93.     ifnot read from("/S(3)\users") end()
  94.     if read string(S(9),"/S(0)~/S(1)") branch(45)
  95.     read from("")
  96.     ifnot read from("/S(3)\users") end()
  97.     write to("/S(3)\users.tmp")
  98. label(30)
  99.     if flag(F(9)) print("Label(30)")
  100.     ifnot read string(S(9),"") branch(40)
  101.     ifnot string match(S(9),"/S(0)") write("/S(9)")
  102.     if string match(S(9),"/S(0)") write("/S(0)~/S(1)")
  103.     branch(30)
  104. label(40)
  105.     if flag(F(9)) print("label(40)")
  106.     read from("")
  107.     write to("")
  108.     erase("/S(3)\users")
  109.     memory execute("rename /S(3)\users.tmp users")
  110.     erase("/S(3)\maintain.dat")
  111.     end()
  112.  
  113. label(45)
  114.     if flag(F(9)) print("label(45)")
  115.     read from("")
  116.     end()
  117.  
  118. ; Subroutine to build a string of message numbers that are to be deleted.
  119. ; S(0) contains DEL_MSGIDX:nn  The deletion string, built into S(9) will look
  120. ; like:
  121. ;
  122. ;         #10#11#12#13#14#
  123. ;
  124. label(90)
  125.     if flag(F(9)) print("label(90)")
  126.     ifnot cut(S(0),"DEL_MSGIDX:") return()
  127.     set string(S(9),"/S(9)/S(0)")
  128.     return()
  129.  
  130. ; Subroutine to delete the message headers from the MSGIDX file, and then
  131. ; the message content from the MSGS file.
  132. ;
  133. ; S(9) contains the message deletion string, built in the subroutine above.
  134.  
  135. ; Start to delete appropriate messages from MSGIDX
  136. ;
  137. label(100)
  138.     if flag(F(9)) print("label(100)")
  139.     get environment(S(2),"NEXT_MSG_NO")
  140.     read from("/S(3)\msgidx")
  141.     write to ("/S(3)\msgidx.tmp")
  142.     read string(S(1),"")
  143.     write("NEXT_MSG_NO:/S(2)")
  144.  
  145. label(110)
  146.     if flag(F(9)) print("label(110)")
  147.     ifnot read string(S(1),"") branch(120)
  148.     set string(S(2),"/S(1)")
  149.     truncate(S(2)," TO:")
  150.     set string(S(2),"/S(2)#")
  151.     ifnot string match(S(9),"/S(2)") write("/S(1)")
  152.     branch(110)
  153.  
  154. label(120)
  155.     if flag(F(9)) print("label(120)")
  156.     read from("")
  157.     write to("")
  158.     erase("/S(3)\msgidx")
  159.     memory execute("rename /S(3)\msgidx.tmp msgidx")
  160.  
  161. ; MSGIDX has been updated and is now current.  Begin to perform delete
  162. ; operation on MSGS.
  163. ;
  164.  
  165. label(130)
  166.     if flag(F(9)) print("label(130)")
  167.     read from("/S(3)\msgs")
  168.     write to("/S(3)\msgs.tmp")
  169. label(140)
  170.     if flag(F(9)) print("label(140)")
  171.     ifnot read string(S(1),"") branch(190)
  172. label(145)
  173.     if flag(F(9)) print("label(145)")
  174.     set string(S(2),"/S(1)")
  175.     if string match(S(2),"~#") cut(S(2),"~")
  176.     ifnot string match(S(9),"/S(2)#") write("/S(1)")
  177.     if string match(S(9),"/S(2)#") branch(150)
  178.     branch(140)
  179. label(150)
  180.     if flag(F(9)) print("label(150)")
  181.     ifnot read string(S(1),"") branch(190)
  182.     if string match(S(1),"~#") branch(145)
  183.     branch(150)
  184. label(190)
  185.     if flag(F(9)) print("label(190)")
  186.     read from("")
  187.     write to("")
  188.     erase("/S(3)\msgs")
  189.     memory execute("rename /S(3)\msgs.tmp msgs")
  190.     return()
  191.  
  192. ; Routine to update the file MSGIDX in the event that there are no
  193. ; messages to delete.  That is, this same operation takes place in
  194. ; subroutine 100, if there are messages to be deleted.  Here, only 
  195. ; the message header gets updated with NEXT_MSG_NO:
  196. ;
  197. label(300)
  198.     if flag(F(9)) print("label(300)")
  199.     get environment(S(2),"NEXT_MSG_NO")
  200.     ifnot read from("/S(3)\msgidx") branch(360)
  201.     ifnot read string(S(1),"")      branch(350)
  202.     set string(S(4),"/S(1)")
  203.     if string match(S(4),"NEXT_MSG_NO:/S(2)") branch(360)
  204.     write to ("/S(3)\msgidx.tmp")
  205.     write("NEXT_MSG_NO:/S(2)")
  206. label(345)
  207.     if flag(F(9)) print("label(345)")
  208.     ifnot read string(S(1),"") branch(350)
  209.     write("/S(1)")
  210.     branch(345)
  211. label(350)
  212.     if flag(F(9)) print("label(350)")
  213.     read from("")
  214.     write to("")
  215.     erase("/S(3)\msgidx")
  216.     memory execute("rename /S(3)\msgidx.tmp msgidx")
  217.     return()
  218. label(360)
  219.     if flag(F(9)) print("label(360)")
  220.     read from("")
  221.     return()
  222.  
  223. label(990)
  224.     read from("")
  225.     write to("")
  226.     write to("answer.log")
  227.     write("Error in processing data files: maintain.hp")
  228.     write to("")
  229.     if flag(F(9)) print("label(990)")
  230.     end()
  231.