home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 6
/
AACD06.ISO
/
AACD
/
Online
/
GMSuite
/
Rexx
/
GMSignature.thor
< prev
Wrap
Text File
|
2000-01-23
|
6KB
|
260 lines
/*
** $VER: GMSignature.thor 5.003 (23.01.00)
** © Gian Maria Calzolari <gcalzo@geocities.com>
**
** FUNCTION:
** Enhances Thor's signature systems implementing both a random tag
** and a specific conference's signature. Default signature allowed.
**
** $HISTORY:
**
** 23 Jan 2000 : 005.003 : Nothing, bumped up rev
** 07 Jan 2000 : 005.002 : Used ReadArguments in GMsignature to avoid errors when
** crossposting news
** 21 Dec 1999 : 005.001 : Nothing, bumped up rev
** 17 Nov 1999 : 005.000 : Nothing! Bumped up rev for consistency with first
** aminet release of GMsuite!
** 14 Nov 1999 : 001.000 : version for GMsuite, changed the cfg file name to
** avoid duplication with GMCleanConf!
** Now cfg name is 'system name' plus '_S'
** 21 Oct 1999 : 000.002 : Added pattern support for Conference name
** 20 Oct 1999 : 000.001 : First attempt, based from mine GMAutoWrite (try it! ;-)
**
*/
parse upper arg arguments
/*
parse upper arg "BBSNAME" BBS "CONFNAME" CNAME .
BBS = strip(compress(BBS,'"'))
CNAME = strip(compress(CNAME,'"'))
if BBS = "" | CNAME = "" then
call ExitMsg("GMSignature.thor must be called as Thor's Signature Command")
*/
call Init
call ReadConfig
call Validate
index = SrcConf(opts.CONFNAME)
if index = 0 then
index = SrcConf("DEFAULT")
if Exists(Tags.index.SIGFILE) then
address command 'type' Tags.index.SIGFILE
else
call ExitMsg("'SigFile' '" || Tags.index.SIGFILE || "' not found!")
if Tags.index.TAGPGM ~= '' then do
say "--"
if Tags.index.TAGPGMTYPE = 0 then /* Arexx */
Tags.index.TAGPGM
else /* dos */
address command Tags.index.TAGPGM
end
exit
/* ...game over... */
Validate:
DefFound = false
do i = 1 to Tags.0
if upper(Tags.i) = "DEFAULT" then
DefFound = true
do y = 1 to NumOpts
Opt = upper(word(TagOptions, y))
OptDef = symbol('Tags.i.Opt')
Select
When find(upper(TagOptsBlk),Opt) > 0 then
if OptDef ~= 'VAR' then Tags.i.Opt = ''
When find(upper(TagOptsZro),Opt) > 0 then
if OptDef ~= 'VAR' then Tags.i.Opt = 0
Otherwise
if OptDef ~= 'VAR' then call ExitMsg("'" || Opt || "' not defined in tag '" || Tags.i || "'")
end
end
end
if ~DefFound then
call ExitMsg("'DEFAULT' tag not defined in file '" || ConfigFile || "'")
return
/* Searches the conference in the config
** parm1 conference to be searched
**
** returns the index or 0 if not found
*/
SrcConf:
cnfr = upper(arg(1))
do i = 1 to Tags.0
CONF = cnfr
if Tags.i.PAT = 0 then do
if CONF = Tags.i then return i
end
else do
select
when Tags.i.PAT = 1 then do
CONF = left(CONF, length(Tags.i))
if CONF = Tags.i then return i
end
when Tags.i.PAT = 2 then do
CONF = right(CONF, length(Tags.i))
if CONF = Tags.i then return i
end
when Tags.i.PAT = 3 then do
if index(CONF, Tags.i) > 0 then return i
end
end
end
end
return 0
ReadConfig:
/* Tags.0 will contains the Conference numbers, Tags.X will be the
** Conference name (without the "*" if used...)
** Tags.X.y will be defined as follow:
** Tags.X.SigFile File to be used as message sign
** Tags.X.TagPgm External pgm that will write a tag to stdout
** Tags.X.TagPgmType External pgm type (0 = ARexx / 1 = dos)
** Tags.X.Pat internal field: 0=no pattern, 1=on right, 2=on left, 3=both
*/
drop Tags.
Tags.0 = 0
TagsNum = 0
CfgOpen = open(cfgfile,ConfigFile,'r')
if ~(CfgOpen) then call ExitMsg('Reading: failed to open' ConfigFile)
do until eof(cfgfile)
nextline = readln(cfgfile)
if compress(nextline) = "" then iterate
parse var nextline CfgName CfgVal
CfgName = upper(CfgName)
CfgVal = strip(compress(CfgVal,'"'))
if CfgName = 'TAG' then do
TagsNum = TagsNum + 1
pattern = 0
if right(CfgVal,1) = '*' then
pattern = pattern +1
if left(CfgVal,1) = '*' then
pattern = pattern +2
CfgVal = compress(CfgVal,'*')
Tags.TagsNum.PAT = pattern
Tags.TagsNum = upper(CfgVal)
end
else do
if TagsNum = 0 then call ExitMsg('No Tag names found!')
if find(upper(TagOptions), CfgName) > 0 then
Tags.TagsNum.CfgName = CfgVal
else
call ExitMsg("Option '" || CfgName || "' (with value '" || CfgVal || "') in tag '" || Tags.TagsNum || "' not allowed!")
end
end
if TagsNum = 0 then call ExitMsg('No Tag names found!')
Tags.0 = TagsNum
if (CfgOpen) then dummy = close(cfgfile)
return
/* Initialization */
Init:
Template = "BBSNAME/K,CONFNAME/K"
VerStr = subword(sourceline(2),3)
p = ' ' || address() || ' ' || show('P',,)
thorport = pos(' THOR.',p)
if thorport <= 0 then
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
drop opts.
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
ConfigFile = 'ENV:Thor/' || opts.BBSNAME || '_S.cfg'
/* If no Configfile simply exit! */
if ~Exists(ConfigFile) then
exit
VerStr = subword(sourceline(2),3)
true = 1
false = 0
/* This tags can be omitted, default will be "blank" */
TagOptsBlk = "TagPgm"
/* This tags can be omitted, default will be "zero" */
TagOptsZro = "TagPgmType"
TagOptions = "SigFile" TagOptsBlk TagOptsZro
NumOpts = words(TagOptions)
return
/* Exit with a message */
ExitMsg:
parse arg msgstr
address command
'RequestChoice >NIL: "GMSignature.thor" "'msgstr'" "OK :-("'
exit