home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Enigma Amiga Life 109
/
EnigmaAmiga109CD.iso
/
software
/
on-line
/
gmsuite
/
rexx
/
gmarchive.thor
next >
Wrap
Text File
|
2000-01-23
|
11KB
|
367 lines
/*
** $VER: GMarchive.thor 5.003 (23.01.00)
** © Gian Maria Calzolari <gcalzo@geocities.com>
**
** FUNCTION:
** Message(s) archivier for Thor
**
** Parameters:
** <none> to save the currently selected msg (useful as a Rexx menu script)
**
** or
**
** BBSNAME This is the System name, required
** CONFNAME This is the Conference name, required
** MSGNUM This is the Message Number, required
** ARCFILE This is the fully qualified file, default is THOR's Save dir
** plus 'GM' plus first_14_chars_of_subject plus '.txt'
** if there is no subject name is 'GMarchivedMsgs.txt'
** If file already exists the message is appended
** EXTRACOMM Switch to save *all* the message's comments, default to save
** only the basic ones
**
** $HISTORY:
**
** 23 Jan 2000 : 005.003 : Nothing, bumped up rev
** 07 Jan 2000 : 005.002 : Nothing, bumped up rev
** 21 Dec 1999 : 005.001 : Nothing, bumped up rev
** 17 Nov 1999 : 005.000 : Bumped up rev for consistency with first aminet
** release of GMsuite!
** Added flags 'Marked' and 'SuperMarked' but they mean
** 'Unread' and 'SuperUnread'!
** 16 Nov 1999 : 002.004 : tried to add flag 'UnRead' but it doesn't work!
** 15 Nov 1999 : 002.003 : Msg flags are now correctly printed for the 'main'
** msg only
** 14 Nov 1999 : 002.002 : changed the way parms are checked to allow use
** from Thor Rexx menu and changed the default filename
** 08 Nov 1999 : 002.001 : ExtraComments is now a parameter
** 07 Nov 1999 : 002.000 : First working version! :-))
** 31 Oct 1999 : 001.004 : Thor conversion started...
** 10 Jan 1999 : 001.003 : Last EMS version
**
*/
signal on syntax
parse upper arg arguments
call Init
drop HeadS.
drop TextS.
drop DataS.
address BBSREAD
ReadBRMessage bbsname '"' || opts.BBSNAME || '"',
confname '"' || opts.CONFNAME || '"',
msgnr opts.MSGNUM,
headstem HeadS textstem TextS datastem DataS
if rc > 5 then signal error
/* let's create a meaningfull filename... */
if symbol('opts.ARCFILE') ~= "VAR" then
if symbol('HeadS.SUBJECT') = "VAR" then
opts.ARCFILE = AltPath || "/" || 'GM' || trim(left(translate(HeadS.SUBJECT, '', ' :/;,*()?`#[]<>~|$%"', '_'),14)) || '.txt'
else
opts.ARCFILE = AltPath || "/" || 'GMarchivedMsgs.txt'
if ~bittst(DataS.FLAGS,MDB_DELETED) then do
if open( 'tempname', opts.ARCFILE, 'A') ~= 1 then
if open( 'tempname', opts.ARCFILE, 'W') ~= 1 then
call ExitMsg ("Can't open '" || opts.ARCFILE || "' file for output.")
flgs = ''
do k = 1 to flag.0
if bittst(DataS.FLAGS, flag.k) then flgs = flgs flag.k.desc
end
call ShowMessagePart('', 'HEADS', 'TEXTS')
call close('tempname')
end
exit 0
/* Show message part, since parts can be recursive, this function is recursive!
**
** parm1 left message indent, usually "" the first time and then incremented by a few blanks...
** parm2 HeadStem name
** parm3 TextStem name
*/
ShowMessagePart:
procedure expose HeadS. TextS. tempname flgs do_cmt
parse arg indent, hstem, tstem .
lf = '0a'x
from = ""
addfrom = ""
to = ""
addto = ""
subject = ""
CrtDate = ""
TmpHdr = ""
if symbol(hstem'.FROMNAME') = "VAR" then
from = value(hstem'.FROMNAME')
if symbol(hstem'.FROMADDR') = "VAR" then
addfrom = value(hstem'.FROMADDR')
if symbol(hstem'.TONAME') = "VAR" then
to = value(hstem'.TONAME')
if symbol(hstem'.TOADDR') = "VAR" then
addto = value(hstem'.TOADDR')
if symbol(hstem'.SUBJECT') = "VAR" then
subject = value(hstem'.SUBJECT')
if symbol(hstem'.CREATIONDATE') = "VAR" then do
Amiga2Date value(hstem'.CREATIONDATE') MsgD
if rc > 5 then signal error
CrtDate = MsgD.mday || '/' || MsgD.month || '/' || MsgD.year MsgD.hour || ':' || MsgD.min
end
if from ~= "" | addfrom ~= "" then
TmpHdr = indent || "From :" from "<" || addfrom || ">"
if to ~= "" | addto ~= "" then
TmpHdr = TmpHdr || lf || indent || "To :" to "<" || addto || ">"
if subject ~= "" then
TmpHdr = TmpHdr || lf || indent || "Subject:" subject
if CrtDate ~= "" then
TmpHdr = TmpHdr || lf || indent || "CrtDate:" CrtDate
if flgs ~= "" then
TmpHdr = TmpHdr || lf || indent || "Flags :" flgs
if length(TmpHdr) ~= 0 then do
call writeln('tempname', indent || "")
if length(indent) = 0 then
call writeln('tempname', indent || "-------------------------- Archived Message ---------------------------")
else
call writeln('tempname', indent || "-------------------------- Message Part ---------------------------")
call writeln('tempname', TmpHdr)
if length(indent) = 0 then
call writeln('tempname', indent || "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -")
else
call writeln('tempname', indent || "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -")
end
if do_cmt & symbol(tstem'.COMMENT.COUNT') = "VAR" then do
call writeln('tempname', indent || "Comment:")
cnt = value(tstem'.COMMENT.COUNT')
do n=1 to cnt
call writeln('tempname', indent || value(tstem'.COMMENT.'n))
end
call writeln('tempname', indent || "")
end
if symbol(tstem'.TEXT.COUNT') = "VAR" then do
cnt = value(tstem'.TEXT.COUNT')
do n=1 to cnt
call writeln('tempname', indent || value(tstem'.TEXT.'n))
end
end
if symbol(tstem'.PART.COUNT') = "VAR" then do
parts = value(tstem'.PART.COUNT')
do n=1 to parts
if symbol(tstem'.PART.'n'.BINARY') = "VAR" then do /* Is it a binary part? */
call writeln('tempname', indent || "======")
call writeln('tempname', indent || "Binary:" '[' || value(tstem'.PART.'n'.BINARY') || ']')
call writeln('tempname', indent || "BinDes:" '"' || value(tstem'.PART.'n'.BINARY.DESC') || '"')
if do_cmt then do
cnt = value(tstem'.PART.'n'.BINARY.COMMENT.COUNT')
do m=1 to cnt
call writeln('tempname', indent || "BinCom:" value(tstem'.PART.'n'.BINARY.COMMENT.'m))
end
end
end
else if(symbol(tstem'.PART.'n'.TEXT.COUNT') = "VAR") then do /* Is it a text part? */
call writeln('tempname', indent || "")
cnt = value(tstem'.PART.'n'.TEXT.COUNT')
do m=1 to cnt
call writeln('tempname', indent || "Text :" value(tstem'.PART.'n'.TEXT.'m))
end
if do_cmt then do
cnt = value(tstem'.PART.'n'.TEXT.COMMENT.COUNT')
do m=1 to cnt
call writeln('tempname', indent || "TxtCom:" value(tstem'.PART.'n'.TEXT.COMMENT.'m))
end
end
end
else do /* It is a message part. */
flgs = ''
usestem = tstem'.PART.'n'.MSG'
call ShowMessagePart(indent || ' ', usestem, usestem)
end
end
end
return 0
/* pad a string with blank to the left
** parm1 string to be padded with blank
** parm2 new lenght
*/
Pad:
return left( arg(1) || copies(' ', arg(2) ), arg(2) )
/* Initialization */
Init:
Template = 'BBSNAME/A,CONFNAME/A,MSGNUM/A/N,ARCFILE,EXTRACOMM/S'
VerStr = subword(sourceline(2),3)
AddressSaved = address()
p = ' ' || address() || ' ' || show('P',,)
thorport = pos(' THOR.',p)
if thorport > 0 then
thorport = word(substr(p,thorport+1),1)
else
ExitMsg('This script must be called from THOR!')
/* Load bbsread.library if necessary */
if ~show('p', 'BBSREAD') then do
address command
'run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead'
'WaitForPort BBSREAD'
end
address(thorport)
/* setting defaults */
GETGLOBALCONFIG stem GLOBALDATA
if rc > 5 then signal error
drop opts.
opts.EXTRACOMM = 0
AltPath = GLOBALDATA.SAVEDIR
/**/
if compress(arguments) = "" then do /* no parms, must be from Thor Rexx menu... */
CURRENTMSG stem MSG
if rc > 5 then signal error
opts.BBSNAME = MSG.BBSNAME
opts.CONFNAME = MSG.CONFNAME
opts.MSGNUM = MSG.MSGNR
end
else do /* probably from another script... */
address BBSREAD
ReadArgs Template opts CMDLINE arguments
if rc = 5 then call ExitMsg(arguments || '*N' || BBSREAD.LASTERROR || '*N' || "Template is:" Template)
if rc > 5 then signal error
end
if opts.EXTRACOMM = 0 then do_cmt = 0
else do_cmt = 1
/* from $VER: GlobalDefs.br 4.2 (9.9.97) */
/* Bit numbers for message flags */
MDB_READ = 0 /* Message is read. */
MDB_REPLIED = 1 /* Message is replied. */
MDB_PRIVATE = 2 /* Message is private. */
MDB_TO_USER = 3 /* Message is to the user. */
MDB_FROM_USER = 4 /* Message is from the user. */
MDB_DELETED = 5 /* Message is deleted. */
MDB_UNRECOVERABLE = 6 /* Message is can not be undeleted. */
MDB_KEEP = 7 /* Keep message. Message will not be deleted during conference packing. */
MDB_TO_ALL = 8 /* Message is to all. (has no reciever) */
MDB_XPK_TEXT = 9 /* Message text is Xpk'ed. (Private flag) */
MDB_MARKED = 10 /* Message is marked. */
MDB_URGENT = 11 /* Message is urgent. */
MDB_IMPORTANT = 12 /* Message is important. */
MDB_SUPERMARKED = 13 /* Message will not be unmarked as long as this flag is set. */
MDB_BINARY_PARTS = 14 /* Message contains 1 or more binary parts. */
MDB_TEXT_PARTS = 15 /* Message contains 1 or more extra text parts. */
/* These two flags does also concern possible message parts. */
MDB_MESSAGE_PARTS = 16 /* Message contains 1 or more message parts. */
MDB_HAZE_BIT0 = 24 /* Message haze level bit 0. */
MDB_HAZE_BIT1 = 25 /* Message haze level bit 1. */
flag.0 = 7
flag.1 = MDB_MARKED
flag.1.desc = 'UnRead'
flag.2 = MDB_SUPERMARKED
flag.2.desc = 'SuperUnRead'
flag.3 = MDB_READ
flag.3.desc = 'Read'
flag.4 = MDB_PRIVATE
flag.4.desc = 'Priv'
flag.5 = MDB_KEEP
flag.5.desc = 'Keep'
flag.6 = MDB_URGENT
flag.6.desc = 'Urg'
flag.7 = MDB_IMPORTANT
flag.7.desc = 'Imp'
return
/* Exit with a message */
ExitMsg:
parse arg msgstr
address command
'RequestChoice >NIL: "GMarchive.thor" "'msgstr'" "OK :-("'
exit
error:
syntax:
say '|'
say '|' VerStr
say '| ***BREAK: error at' sigl ',' rc ',' ErrorText(rc)
if symbol('THOR.LASTERROR') = 'VAR' then do
say '|'
say '| * Thor.LastError =' THOR.LASTERROR
end
if symbol('BBSREAD.LASTERROR') = 'VAR' then do
say '|'
say '| * BBSread.LastError =' BBSREAD.LASTERROR
end
exit rc