home *** CD-ROM | disk | FTP | other *** search
- /* rexx:newsexec.rexx, (c) Thu, 18 Mar 1993 02:58:10 +0100 by "Kai 'wusel' Siering" <wusel@hactar.hanse.de> */
- /* based on */
- /* ARexx-NewsExec (c)1991 by Friedrich Gentner E-Mail: fgent@gentle.nbg.sub.org */
-
- mailfile = 't:execmail.file'
-
- accessfalid = 0
- from = ''
- exec = ''
- checkgroups. = ''
- checkline. = ''
- orggroups. = ''
- orgflag. = ''
- news = "news"
- name = "USENET Daemon"
- autoexec = "newsexec"
-
- if ~exists('t:') then do
- say 'T: has not been assigned, aborting!'
- exit(25)
- end
-
- say 'newsexec engaged'
-
- /* Config scannen */
-
- if (open(conf,"uulib:config",r)) then do
- do while ~eof(conf)
- in=readln(conf)
-
- in2 = Translate(in, ' ', D2C(9))
- parse var in2 key cont
-
- select
- when upper(key)="USERNAME" then user=strip(cont)
- when upper(key)="NEWSMASTER" then news=strip(cont)
- /* when upper(key)="NODENAME" then node=strip(cont)
- when upper(key)="DOMAINNAME" then domain=strip(cont)
- when upper(key)="TIMEZONE" then tzone=strip(cont) */
- otherwise nop
- end
- end
- err=close(conf)
- end
- else do
- say 'Configuration file (UUlib:config) not found, aborting!'
- exit(20)
- end
-
- root = strip(user)
-
- /* Achja hier wird das aktuelle Datum generiert */
-
- /* curdate=left(date(w),3)", "date(n) time() tzone */
-
-
- do while ~eof(stdin)
- inline = readln(stdin)
- parse var inline '#exec#' exec
- parse var inline 'From ' from senddate
- if (from ~= '') then
- do
- if (from ~= root & from ~= news) then exit 0
- else say 'access validation complete'
- accessvalid = 1
- end
- if (exec ~= '') then
- do
- exec = strip(exec)
- if (accessvalid ~= 1) then exit 0
-
- parse var exec cmd group comment
- select
- when cmd = 'newgroup' then
- do
- addnewgroup(group,'uulib:.grouplist',':',':')
- addnewgroup(group,'uulib:news/newsgroups',' ', ' '||comment)
- if (index(upper(comment), 'MODERATED') ~= 0) then
- addnewgroup(group,'uulib:news/active',' ',' 0000000000 0000000001 m')
- else
- addnewgroup(group,'uulib:news/active',' ',' 0000000000 0000000001 y')
- end
- when cmd = 'rmgroup' then
- do
- removegroup(group,'uulib:.grouplist',':')
- removegroup(group,'uulib:news/newsgroups',' ')
- removegroup(group,'uulib:news/active',' ')
- end
- when cmd = 'checkgroups' then
- do
- say 'checking groups'
- /* to get some speed at first both list are read in compounds */
- c = 0
- do while ~eof(stdin)
- inline = readln(stdin)
- parse var inline group comment
- /* This line could cause trouble because also other */
- /* words might contain points */
- if (index(group,'.') ~= 0) then
- do
- c = c + 1
- checkline.c = inline /* for #exec#-line */
- checkgroups.c = strip(group) /* for comparison */
- end
- end
- n = 0
- if open(infile, 'uulib:news/active', 'read') then
- do
- do while ~eof(infile)
- inline = readln(infile)
- parse var inline group bla1 bla2 flag
- n = n + 1
- orggroups.n = strip(group) /* for comparison */
- orgflags.n = flag /* for m-check */
- end
- close(infile)
- end
-
- /* Now every group in both lists are compared with each other. */
- /* Groups which are in both liste get deleted. */
- /* The remaining groups in orggroups are obsolet and the grous */
- /* in checkgroups are missing. */
- do i = 1 to n
- do j = 1 to c
- if (orggroups.i = checkgroups.j) then
- do
- orggroups.i = ''
- checkgroups.j = ''
- end
- end
- end
-
- /* Now generate an apropriate Mail for USENET */
- if open(outfile, mailfile, 'write') then
- do
- writeln( outfile, 'To: 'news)
- writeln( outfile, 'Reply-To: 'autoexec)
- writeln( outfile, 'From: 'news' ('name')')
- writeln( outfile, 'Subject: checkgroup results')
- writeln( outfile, '')
- writeln( outfile, 'Please check the following commands, delete')
- writeln( outfile, 'unconvenient lines and confirm by replying')
- writeln( outfile, '')
- writeln( outfile, 'The following groups are obsolet')
- do i = 1 to n
- if (orggroups.i ~= '') then
- writeln( outfile, '#exec# rmgroup' orggroups.i)
- end
- writeln( outfile, 'The following groups are missing')
- do j = 1 to c
- if (checkgroups.j ~= '') then
- writeln( outfile, '#exec# newgroup' checkline.j)
- end
- close(outfile)
-
- address COMMAND 'sendmail <'mailfile
- address COMMAND 'delete 'mailfile' quiet'
- end
-
- /* Checkgroup needs a moderated-flag comparison. */
- /* Therefore, 2 #exec# commands need to be added */
- /* For example 'setmoderated' and 'rmmoderated' */
- /* Maybe next time. */
- end
- otherwise say 'don''t know how to handle 'cmd
- end
- end
- end
-
- exit 0
-
- addnewgroup: procedure
- /* The groupend ist necessary because of main-groups. */
- /* For example if you search for 'comp.sys.amiga' and */
- /* comp.sys.amiga.programmer already exists you will */
- /* find the string comp.sys.amiga. */
- /* Because the separation char need not to be ' ' it */
- /* is passed by argument. */
-
- group = arg(1)
- filename = arg(2)
- groupend = arg(3)
- extension = arg(4)
-
- success = open( infile, filename, "read")
- if (~success) then
- do
- say 'Can''t access to' filename
- exit
- end
-
- ok = 0
- do while (~eof(infile) & (ok = 0))
- inline = readln(infile)
- ok = index(inline, group||groupend)
- end
- close(infile)
-
- if (ok = 1) then return 0 /* this group already exists */
-
- address COMMAND 'copy 'filename' to 'filename'.old' /* for safetiness */
- address COMMAND 'copy 'filename' to t:news.work'
-
- success = open( outfile, 't:news.work', "append")
- if (~success) then
- do
- say 'Can''t access to t:news.work'
- exit
- end
-
- writeln( outfile, group || extension)
- close(outfile)
-
- address COMMAND 'sort t:news.work to 'filename
- address COMMAND 'delete t:news.work quiet'
-
- return 0
-
- removegroup: procedure
- /* Here is groupend also necessary ... see addnewgroup */
- group = arg(1)
- filename = arg(2)
- groupend = arg(3)
-
- address COMMAND 'copy 'filename' to 'filename'.old' /* for saftiness */
-
- success = open( infile, filename, "read")
- if (~success) then
- do
- say 'Can''t access to' filename
- exit
- end
-
- success = open( outfile, 't:news.work', "write")
- if (~success) then
- do
- say 'Can''t access to t:news.work'
- exit
- end
-
- do while ~eof(infile)
- inline = readln(infile)
- ok = index(inline, group||groupend)
- if ((ok ~= 1) & (inline ~= '')) then writeln(outfile,inline)
- end
- close(infile)
- close(outfile)
-
- address COMMAND 'copy t:news.work to 'filename' clone'
- address COMMAND 'delete t:news.work quiet'
-
- return 0
-
- /* end */
-
-
-