/****************************************************************/ /* Sample filter for use with Weasel */ /* */ /* This filter doesn't do anything very useful. It is */ /* intended mainly as a sample for people who want to know */ /* how to write a filter. It takes the information in the */ /* two parameters passed to it, and writes that information */ /* to a file 'samplefilter.out'. */ /* */ /* Author: Peter Moylan (peter@ee.newcastle.edu.au) */ /* Started: 12 August 2003 */ /* Last revised: 12 August 2003 */ /* */ /* Installation: */ /* Put this file in any suitable directory. */ /* Put its name in the 'Options' page in Setup. */ /* Weasel needs to be restarted to recognise the change. */ /* */ /* After a test run, use a text editor to read the contents */ /* of the file SAMPLEFILTER.OUT, to see what the filter did. */ /* */ /****************************************************************/ CALL RxFuncAdd SysLoadFuncs, rexxutil, sysloadfuncs CALL SysLoadFuncs PARSE ARG namelist messagefile outfile = 'SAMPLEFILTER.OUT' /* Report the filename of the message file. Note that the */ /* message file exists only for a final stage filter, so we */ /* have the possibility that there is no message file. */ messagefile = STRIP(messagefile) IF messagefile = '' THEN CALL LineOut outfile, 'There is no message file' ELSE CALL LineOut outfile, 'The message is in file 'messagefile /* Report the contents of the namelist file. The amount of */ /* information provided depends on the filtering stage, so we */ /* can expect some lines to be missing at some stages. */ line = LINEIN(namelist) IF line = '' THEN DO CALL LineOut outfile, 'The namelist file appears to be empty.' CALL LineOut outfile, 'This should never happen, therefore there is a software bug.' EXIT 1 END CALL LineOut outfile, 'Line 1 of the namelist file (the address of the sender) is' CALL LineOut outfile, line /* Line 2. */ line = LINEIN(namelist) IF line = '' THEN DO CALL LineOut outfile, 'There is no second line, so this must be a stage 0 filter.' EXIT 0 END CALL LineOut outfile, 'Line 2 of the namelist file (the HELO name of the sender) is' CALL LineOut outfile, line /* Line 3. */ line = LINEIN(namelist) IF line = '' THEN DO CALL LineOut outfile, 'There is no third line, so this must be a stage 1 filter.' EXIT 0 END CALL LineOut outfile, 'Line 3 of the namelist file (the sender as specified in MAIL FROM) is' CALL LineOut outfile, line /* Line 4. */ line = LINEIN(namelist) IF line = '' THEN DO CALL LineOut outfile, 'Line 4 is blank, as it is supposed to be.' END ELSE DO CALL LineOut outfile, 'Line 4 should have been blank, but in fact it has contents' CALL LineOut outfile, line END /* The list of recipients. */ CALL LineOut outfile, 'Here is the list of recipients. It might be empty if this is an early-stage filter.' CALL LineOut outfile, '====== Start of list ==========' DO WHILE LINES(namelist) > 0 line = LINEIN(namelist) IF line = '' THEN DO CALL LineOut outfile, '(empty line)' END ELSE DO CALL LineOut outfile, line END END CALL LineOut outfile, '====== End of list ==========' /* End of processing, return to Weasel with a 'success' code. */ EXIT 0