Trailing-Edge
-
PDP-10 Archives
-
decuslib10-11
-
43,50527/readma.bli
There are no other files named readma.bli in the archive.
Module Readma(entries=(Readmail),reserve(1,2,3,4))=
Begin
Require machop.bli;
Require macros.bli;
Require extern.bli;
External Sendmail,typemail,Savemail,Listmail,Getdate;
Global routine READMAIL(key1,key2)=
BEGIN
Own a,b,word, ! Temporaries
cmd, ! Current command
lookuparg[4], ! Lookup argument block
enterarg[4], ! Enter argument block
opb1[4], ! First open block
opb2[4], ! Second open block
saw, ! At least one message in file
givmsg, ! Desires message
del, ! Delete message
copied, ! A message was copied
renblk[4], ! Rename block
tmpptr; ! Pointer from command line
Label Readem; ! Loop label
if .key1 EQL 0 then key1 _ sixbit'BOTH';
if (.key2 EQL 0)AND(NOT .summary) then key2 _ sixbit'NEW';
if (.key2 EQL 0)AND(.summary) then key2 _ sixbit'ALL';
b _ FALSE; a _ FALSE;
if unique(.key1,sixbit'BOTH',1) then (key1 _ sixbit'BOTH';b _ true);
if unique(.key1,sixbit'SYSTEM',1) then (key1 _ sixbit'SYSTEM';b _ true);
if unique(.key1,sixbit'USER',1) then (key1 _ sixbit'USER';b _ true);
if unique(.key2,sixbit'ALL',1) then (key2 _ sixbit'ALL';a _ true);
if unique(.key2,sixbit'NEW',1) then (key2 _ sixbit'NEW';a _ true);
if NOT .b then
Begin
Print('?M?J?G%Unrecognized argument: '); Sixout(.key1,-1);
Print(' - Assumed BOTH?M?J'); key1 _ sixbit'BOTH';
End;
if NOT .a then
Begin
Print('?M?J?G%Unrecognized argument: '); Sixout(.key2,-1);
If (NOT .summary) then (Print(' - Assumed NEW?M?J'); key2 _ sixbit'NEW';);
If (.summary) then (Print(' - Assumed ALL?M?J'); key2 _ sixbit'ALL';);
End;
Incr a from 0 to 1 do
Begin
If (.key1 EQL sixbit'USER') then a _ 1;
lookuparg[0] _ enterarg[0] _ (if (.a EQL 1) then .acct[accmlf] else sixbit'.ALL.');
lookuparg[1] _ enterarg[1] _ (if (.a EQL 1) then .acct[accmfe] else mlrext);
lookuparg[2] _ enterarg[2] _ #777^27;
lookuparg[3] _ enterarg[3] _ (if (.a EQL 1) then .acct[accppn] else mlrppn);
opb1[0] _ opb2[0] _ 12;
opb1[1] _ opb2[1] _ (if (.a EQL 1) then .acct[accmfd] else mlrdev);
opb1[2] _ address(ibufhdr);
opb2[2] _ Xwd(address(obufhdr),0);
opb1[3] _ opb2[3] _ 0;
reset;
saw _ FALSE;
ifskip open(in,address(opb1)) then
Begin
If NOT Lockchn(in,0) then
Begin
Releas(IN);
Return(0);
End;
End
else
Begin
If (.login) then return 0;
Print('?M?J?G??MAIDNA Device ');
Sixout(.opb1[1],-1);
Print(' not available for input?M?J');
Return 0;
End;
If NOT (.login)AND NOT (.summary) then
Begin
ifskip open(out,address(opb2)) then 0
else
Begin
Print('?M?J?G??MAIDNA Device ');
Sixout(.opb2[1],-1);
Print(' not available for output?M?J');
Releas(IN);
Return 0;
End;
End;
copied _ FALSE;
incr b from 0 to 3 do renblk[.b]_0;
ifskip lookup(in,address(lookuparg)) then
Begin
if (NOT .login)AND (NOT .summary) then
ifskip enter(out,address(enterarg)) then 0
else Begin
If (.enterarg[1]<righthalf> EQL 3) then
Print('?M?J?G??MAIMBB Mailbox is busy...Try again later?M?J')
else begin
Print('?M?J?G??MAIUCO Unable to create mail output file?M?J');
Error(.Enterarg[1]<righthalf>);
end;
Close(in);
Releas(in);
Releas(out);
Return;
End;
Readem:
While TRUE do
Begin
del _ FALSE;
b _ 0;
word _ 0;
until ((.word EQL -1)OR(.word EQL "EOF")) do
Begin
word _ INFILE("IN");
auxbuf[.b] _ .word;
if (.word EQL -1)AND(.b LEQ mlfsub) then word _ 0;
b _ .b + 1;
if (.b GEQ maxbuf) then
Begin
Print('?M?J?G??MAIMFC Mail file is corrupt?M?J');
Ifskip rename(in,address(renblk)) then
Begin
Print('[Deleting mail file]?M?J');
End;
Close(in);
Releas(in);
ac1 _ out;
ifskip Resdv(ac1) then 0;
End;
End;
if (.word EQL "EOF") then
Begin
If (NOT .login)AND (NOT .summary) then
If .a EQL 0 then
If (.saw) then
Print('?M?J[No more SYSTEM mail]?M?J')
else Print('?M?J[No new SYSTEM mail]?M?J')
else if (.saw) then
Print('?M?J[No more mail]?M?J')
else Print('?M?J[No new mail]?M?J');
Saw _ FALSE;
If (NOT .copied)AND(NOT .login)AND(NOT .summary) then
Ifskip rename(in,address(renblk)) then
Begin
ac1 _ out;
ifskip Resdv(ac1) then
Print('?M?J[All mail deleted - Mail file deleted]?M?J')
else copied _ TRUE;
End
Else
Begin
Print('?M?JMAIUDF Unable to delete empty mail file?M?J');
Error(.renblk[1]<righthalf>);
End;
Close(IN);
Releas(IN);
If (.copied)AND NOT(.login)AND NOT(.summary) then
Begin
Close(OUT);
Releas(OUT);
End;
Reset;
If (.a EQL 0) then
Begin
sysdate _ gettab(#53,#11);
Getdate(.acct[accnm1],.acct[accnm2],true);
End;
If (.acct[accnm1] EQL sixbit'ALL') then a _ 1;
If (.key1 EQL sixbit'SYSTEM') then a _ 1;
Leave readem;
End;
b _ FALSE;
if (.key2 EQL sixbit'ALL') then b _ TRUE;
if (.auxbuf[mlfsdt] NEQ 0)AND(.a EQL 0) then
if (.auxbuf[mlfsdt] GEQ .sysdate) then b _ TRUE
else 0
else if ((bittst(.auxbuf[mlfflg],mfgred))EQL 0) then b _ TRUE;
if (.auxbuf[mlfexp] NEQ 0) then
if ((gettab(#53,#11))GEQ(.auxbuf[mlfexp])) then
Begin
del _ TRUE;
Print('?M?J[Found expired message - Deleting]?M?J?G');
b _ FALSE;
End;
if (.b) then
Begin
Crlf;
typemail(auxbuf);
Saw _ TRUE;
cmd _ 0;
While ((.cmd NEQ sixbit'NEXT')AND(NOT .login)AND(NOT .Summary)) do
Begin
Print('READ> ');
cmd _ sixin(0,-6);
tmpptr _ .ac3;
proccmd(cmd,'NEXT',1);
proccmd(cmd,'EXIT',1);
proccmd(cmd,'DELETE',1);
proccmd(cmd,'REPLY',1);
proccmd(cmd,'HELP',1);
proccmd(cmd,'LIST',1);
proccmd(cmd,'SAVE',1);
If (.cmd EQL 0) then cmd _ sixbit'NEXT';
Select .cmd of
NSET
Sixbit'NEXT':del_FALSE;
Sixbit'SAVE':Savemail(.tmpptr,auxbuf);
Sixbit'LIST':Listmail(auxbuf);
Sixbit'DELETE':
Begin
del _ FALSE;
if (.a EQL 0) then
if (prvbit(pvdall)) then
del _ TRUE
else Print('?G??MAICDS You cannot delete system mail?M?J')
else del _ TRUE;
if (.del EQL TRUE) then
Begin
cmd _ sixbit'NEXT';
print('?M?J[Deleting message]?M?J');
End;
End;
Sixbit'REPLY':
If Auser(.auxbuf[accnm1],.auxbuf[accnm2]) then
Print('?G??MAICRS Cannot reply to self?M?J')
else Sendmail(.auxbuf[accnm1],.auxbuf[accnm2],FALSE);
Sixbit'HELP':
Begin
Print('?M?JREAD commands are:?M?J');
Tab; Print('Delete - Delete this message?M?J');
Tab; Print('Exit - Leave read mode?M?J');
Tab; Print('Help - Print this text?M?J');
Tab; Print('List - Print message to LPT:?M?J');
Tab; Print('Next - Go to next message (Same as <CR>)?M?J');
Tab; Print('Reply - Reply to sender?M?J');
Tab; Print('Save - Save message?M?J');
Crlf;
End;
Sixbit'EXIT':
Begin
If (.a EQL 1) then
Bitset(Auxbuf[mlfflg],mfgred) _ 1;
b _ word _ 0;
If (.login)OR(.summary) then word _ -1;
Until (.word EQL -1) do
Begin
word _ .auxbuf[.b];
outfile(.word);
if (.b LEQ mlfsub)AND(.word EQL -1) then word _ 0;
b _ .b + 1;
End;
If (.login)OR(.summary) then word _ "EOF";
Until (.word EQL "EOF") do
Begin
word _ infile("IN");
If (.word NEQ "EOF") then outfile(.word);
End;
Close(in);
If NOT(.login)AND NOT(.summary) then Close(out);
Releas(in);
If NOT(.login)AND NOT(.summary) then Releas(out);
Return 0;
End;
Otherwise:Print('?G??MAIURC Unrecognised READ command - Type HELP?M?J');
TESN;
End;
End;
If (.a EQL 1) then
Bitset(Auxbuf[mlfflg],mfgred) _ 1;
b _ word _ 0;
if (.del)OR(.login)OR(.summary) then word _ -1;
copied _ (.copied)OR(NOT .del);
Until (.word EQL -1) do
Begin
word _ .auxbuf[.b];
outfile(.word);
if (.b LEQ mlfsub)AND(.word EQL -1) then word _ 0;
b _ .b + 1;
End;
End;
End
else
Begin
if (.login)OR(.summary) then 0
else
If (.a EQL 0) then print('?M?J[No SYSTEM mail]?M?J')
else print('?M?J[No mail]?M?J');
Releas(in);
End;
End;
END; ! End of READMAIL
End
Eludom