home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Jason Aller Floppy Collection
/
199.img
/
HYPE4.ZIP
/
MAINTAIN.HP
< prev
next >
Wrap
Text File
|
1990-05-08
|
7KB
|
231 lines
; maintain.hp
;
; This script is used to maintain the data files assosiated with the EMAIL
; system. Note that the operations performed in this script are done
; AFTER a caller LOGS OFF the HA5 host. This is done because these file
; operations may take some time to complete, depending on the size of the
; EMAIL files. For example, when a caller reads a piece of mail, and then
; deletes that message, a DEL_MSGIDX instruction is written to maintain.dat,
; and the message doesn't actually get removed from the MSGIDX file and the
; MSGS file until this script is executed. After the caller has logged off,
; it doesn't matter how long these operations take. Remember that all file
; processing is done sequentially.
;
; Also, if additional file processing procedures are added in the future,
; this may be a good place for those additions. For example, if the callers
; names, currently in the file named USERS, were to be maintained in
; alphabetical order, this would be a good place to reorganize that file.
;
; This script is also updates the LAST MESSAGE READ number for the current
; current caller.
; Read maintain.dat into list for processing. Note: a maximum of 128, (or
; the list size) instructions can be processed.
;
; F(1) = Have deletes been performed ? true or flase
; F(9) = True for trace option
set flag(F(1),false)
set flag(F(9),false)
ifnot get environment(S(3),"HA5_TRACE") set flag(F(9),false)
if string match(S(3),"true") set flag(F(9),true)
if flag(F(9)) print("Maintain entered")
ifnot get environment(S(3),"HA5_EMAIL") branch(1)
label(1)
option("ignore case",yes)
ifnot read from("/S(3)\maintain.dat") branch(25)
set flag(F(1),true)
clear list(0)
set list("dummy")
read list(0,"")
list size(I(0))
if flag(F(9)) print("List size is /I(0)")
subtract(I(0),1)
if flag(F(9)) set integer(I(1),1)
if flag(F(9)) print("List instructions are:")
ifnot flag(F(9)) branch(5)
label(4)
print("List element /I(1):/L(1)")
add(I(1),1)
ifnot greater(I(1),I(0)) branch(4)
label(5)
if flag(F(9)) print("label(5)")
read from("")
if flag(F(9)) print( "Maintain entered: /I(0) instructions to process")
; Begin processing all DEL_MSGIDX: instructions. First, remove all of the
; specified message numbers from the MSGIDX file, then go back and remove
; the message contents from the MSGS file.
;
set integer(I(1),1)
set string(S(9),"")
label(10)
if flag(F(9)) print("Label(10)")
set string(S(0),"/L(1)")
if string match(S(0),"DEL_MSGIDX:") branch subroutine(90)
add(I(1),1)
ifnot greater(I(1),I(0)) branch(10)
set string(S(9),"/S(9)#")
ifnot length("/S(9)",I(9)) set integer(I(9),0)
ifnot greater(I(9),1) branch subroutine(300)
ifnot greater(I(9),1) branch(20)
branch subroutine(100)
; As a final operation, update USERS with callers LAST-MSG read number and
; update the NEXT_MSG_NO header in the MSGIDX file.
;
label(20)
if flag(F(9)) print("Label(20)")
erase("/S(3)\maintain.dat")
label(25)
if flag(F(9)) print("Label(25)")
ifnot flag(F(1)) branch subroutine(300)
get environment(S(0),"NAME")
get environment(S(1),"LAST_MSG_NO")
ifnot read from("/S(3)\users") end()
if read string(S(9),"/S(0)~/S(1)") branch(45)
read from("")
ifnot read from("/S(3)\users") end()
write to("/S(3)\users.tmp")
label(30)
if flag(F(9)) print("Label(30)")
ifnot read string(S(9),"") branch(40)
ifnot string match(S(9),"/S(0)") write("/S(9)")
if string match(S(9),"/S(0)") write("/S(0)~/S(1)")
branch(30)
label(40)
if flag(F(9)) print("label(40)")
read from("")
write to("")
erase("/S(3)\users")
memory execute("rename /S(3)\users.tmp users")
erase("/S(3)\maintain.dat")
end()
label(45)
if flag(F(9)) print("label(45)")
read from("")
end()
; Subroutine to build a string of message numbers that are to be deleted.
; S(0) contains DEL_MSGIDX:nn The deletion string, built into S(9) will look
; like:
;
; #10#11#12#13#14#
;
label(90)
if flag(F(9)) print("label(90)")
ifnot cut(S(0),"DEL_MSGIDX:") return()
set string(S(9),"/S(9)/S(0)")
return()
; Subroutine to delete the message headers from the MSGIDX file, and then
; the message content from the MSGS file.
;
; S(9) contains the message deletion string, built in the subroutine above.
; Start to delete appropriate messages from MSGIDX
;
label(100)
if flag(F(9)) print("label(100)")
get environment(S(2),"NEXT_MSG_NO")
read from("/S(3)\msgidx")
write to ("/S(3)\msgidx.tmp")
read string(S(1),"")
write("NEXT_MSG_NO:/S(2)")
label(110)
if flag(F(9)) print("label(110)")
ifnot read string(S(1),"") branch(120)
set string(S(2),"/S(1)")
truncate(S(2)," TO:")
set string(S(2),"/S(2)#")
ifnot string match(S(9),"/S(2)") write("/S(1)")
branch(110)
label(120)
if flag(F(9)) print("label(120)")
read from("")
write to("")
erase("/S(3)\msgidx")
memory execute("rename /S(3)\msgidx.tmp msgidx")
; MSGIDX has been updated and is now current. Begin to perform delete
; operation on MSGS.
;
label(130)
if flag(F(9)) print("label(130)")
read from("/S(3)\msgs")
write to("/S(3)\msgs.tmp")
label(140)
if flag(F(9)) print("label(140)")
ifnot read string(S(1),"") branch(190)
label(145)
if flag(F(9)) print("label(145)")
set string(S(2),"/S(1)")
if string match(S(2),"~#") cut(S(2),"~")
ifnot string match(S(9),"/S(2)#") write("/S(1)")
if string match(S(9),"/S(2)#") branch(150)
branch(140)
label(150)
if flag(F(9)) print("label(150)")
ifnot read string(S(1),"") branch(190)
if string match(S(1),"~#") branch(145)
branch(150)
label(190)
if flag(F(9)) print("label(190)")
read from("")
write to("")
erase("/S(3)\msgs")
memory execute("rename /S(3)\msgs.tmp msgs")
return()
; Routine to update the file MSGIDX in the event that there are no
; messages to delete. That is, this same operation takes place in
; subroutine 100, if there are messages to be deleted. Here, only
; the message header gets updated with NEXT_MSG_NO:
;
label(300)
if flag(F(9)) print("label(300)")
get environment(S(2),"NEXT_MSG_NO")
ifnot read from("/S(3)\msgidx") branch(360)
ifnot read string(S(1),"") branch(350)
set string(S(4),"/S(1)")
if string match(S(4),"NEXT_MSG_NO:/S(2)") branch(360)
write to ("/S(3)\msgidx.tmp")
write("NEXT_MSG_NO:/S(2)")
label(345)
if flag(F(9)) print("label(345)")
ifnot read string(S(1),"") branch(350)
write("/S(1)")
branch(345)
label(350)
if flag(F(9)) print("label(350)")
read from("")
write to("")
erase("/S(3)\msgidx")
memory execute("rename /S(3)\msgidx.tmp msgidx")
return()
label(360)
if flag(F(9)) print("label(360)")
read from("")
return()
label(990)
read from("")
write to("")
write to("answer.log")
write("Error in processing data files: maintain.hp")
write to("")
if flag(F(9)) print("label(990)")
end()