FTNManager v0.4.2a
By Perry Lorier

*WARNING* *WARNING* *WARNING* *WARNING* *WARNING* *WARNING* *WARNING* *WARNING*
*WARNING*                                                             *WARNING*
*WARNING* This is Alpha software, I've hardly tested it. Expect it to *WARNING*
*WARNING* Do weird things: Grunge message bases,  kill messages etc   *WARNING*
*WARNING*                                                             *WARNING*
*WARNING*           DON'T BLAME ME IF ANY OF THIS HAPPENS!            *WARNING*
*WARNING*                                                             *WARNING*
*WARNING* *WARNING* *WARNING* *WARNING* *WARNING* *WARNING* *WARNING* *WARNING*

You use this software at your own risk.  It MAY decide to damage your computer
although I doubt it will.  It MAY grunge entire message bases, although again,
I doubt it will.  It probably WILL grunge the occasional message :)

It MAY decide to match messages which it shouldn't, and it MAY decide not to
match messages which it shouldn't.  Again, don't blame me.  I won't be held
responsable for ANYTHING that this software decides to do...

However: if any of this weird antisocial behaviour appears: TELL ME!  I must
know so I can fix it!

You should also read the history at the end of this document, a lot of usefull
information goes in there.  You should ESPECIALLY read that section if your
upgrading, it gives a blow by blow account of whats changed.  (And it tends
to be a bit more accurate than the rest of the docs)

When testing this software: All ways remember to mount a scratch monkey.

Ok, now that I've got That out of the way so you just CAN'T miss it... Onto
the real thing.

Read and modify "ftnmgr.cfg" to suit your system, everything you need to know
about it should be in comments in the file.  If you can't figure it out then
why are you running this software? :)

Read and modify the rules file.  ftnmgr.rul contains a few examples of what
you can do.

The first command you should know is "IF...THEN...[ELSE]...END", you use
this as you'd expect.  Whitespace doesn't matter, you can put it anywhere in
the file where you'd expect, The rule file doesn't require CR's anywhere, you
can put the entire file on one line if you really want, or spread it out to
make it readable.  Spreading it out makes a bit more sense because it will
tell you the line number on which an error occured.

Possible conditions are:
 string comparisons, these are all case iNSeNSiTiVe. :)
   = == EQUALS  if the strings are equal.
   ~= CONTAINS  if the first string contains the second string.
   != <>        if the strings are not equal.
   IN           if the first string is found on a line by itself in
                the file named by the second string.
 string variables:
   SUBJECT,
   FROM,        These are reasonably obvious IMHO.
   TO
   %<envvar>, $<envvar>  These are taken from the environment.  For example
                         %PATH and $COMSPEC.  Also $CMDLINE/%CMDLINE for
                         command line options (See command line options
                         for more info)
 Address variables:
   ORIG, DEST   These are the ORIGinating and DESTination system respectively

 Address types:
   @ME@         If it is any of my AKA's as defined in the .cfg file.
   a:b/c.d      For the address.  Any component can be "*", and the .d can
                be left off to default to .0,  a "*" can replace all fields
                after that field, eg 3:* for all of Zone 3.  You can also
                specify a range for any of the elements, eg 1-6:* for all of
                fidonet.

 Flags:
   ISCRASH, ISLOCAL etc... Returns TRUE if the current message has the
                specified flag.
   ISECHOMAIL, ISNETMAIL, ISBADAREA, ISDUPEAREA
                Returns TRUE if the current message area is of the specified
                type.
 Files:
   EXISTS <filename>  Returns true, if the specifed file exists.

You can use Brackets ( '(' and ')' ), conjunctions (like AND, OR, XOR), and
NOT.  This lets you create really complicated matches, beyond the
comprehension of NetMgr.

Commands:
 DISPLAY <string>
  This displays (and logs) the string, used to log what your doing, and/or
  display some sort of usage stuff...   Very little logging is done to disk,
  so use this function frequently to show what your doing

 FORWARD ( <parms> )
  This is currently the work horse command.  I'll probably add a few more
  commands, that have similar functionality for move, copy, bounce etc,
  however all these commands can be currently done with this command, and
  Deletemsg.
  parms can be:
   FROM=<the from name>
   TO=<the to name>
   SUBJECT=<take a guess>
   ORIG=<the originating node>
   DEST=<the destination node>
   HEADER=<the filename of a message to include at the top of the message>
   FOOTER=<the filename of a message to include at the foot of the message>
   BODY=<bool>
    If body=false, then the original body of the message won't be included.
   MSGID=PRESERVE,REPLY,REMOVE
    Determines what should be done with the ^aMSGID on the new message,
    should it be PRESERVED, or changed to a REPLY kludge.  If This line is
    omitted, then the MSGID is preserved unless TO is the same as the
    original sender.  Remove removes the kludge.
   <flag>=<bool>
    Sets that flag to Yes or No, The default is copied from the original
    message.

 BOUNCE ( <parms> )
  This is similar in functionality to the FORWARD command, however:
   * It defaults to swapping the to/from addresses.
   * It doesn't support MSGID=
   * It DOES support QuoteKludges=<bool>
  parms can be:
   <any of the parms for forward except MSGID>
   QUOTEKLUDGES=<bool>
    If QuoteKludges is true, then kludges will be quoted as @KLUDGE in the
    body.  If BODY=FALSE and QUOTEKLUDGES=TRUE then only the kludges will
    be quoted.

 SETFLAG <flagname>
 CLEARFLAG <flagname>
  Sets and clears flags.  Valid flags are:
  LOCAL,CRASH,KILLSENT,SENT,FATTACH,REQRCT,REQAUD,FILEREQ,FREQ,RCVD,PRIV,
  DELETED,ECHOED

 TOUCH <filename>
  Touch creates a filename if it doesn't exist, or updates the timestamp on
  one that does.  This can be used to create a semaphore file to perhaps
  run a program if a message for it exists and thus speed up processing
  time by not running all your netmail scanning programs unless you have to.

 APPEND <filename> <string>
  Adds a line to a file.

 POST ( <parms> )
  TO=<touser>      DEST=<destaddr>
  FROM=<fromuser>  ORIG=<origaddr>
  FILE=<filename>
  OVERRIDE=<bool>
  If Override is true, then you can place lines from the above in the text
  file to override the options specified.  These options MUST appear at the
  beginning of the text file, left justified with no spaces, the first line
  that isn't an option marks the beginning of the file.

  Also many options can be expanded:
	   @FROM@,@TO@,@SUBJ@,@SUBJECT@,@DEST@,@ORIG@,@DATE@,@TIME@
	   @YEAR@,@MONTH@,@DAY@,@DOW@,@HOUR@,@MIN@,@SEC@,@MSGID@

 * Command line options:
   -c <configfile>   : Read the config file
   POLL              : Complain that this feature isn't yet supported.
   -- <text>         : Pass <text> to FTN Manager Scripts in the CMDLINE
				   Environmental variable.  For example:
				   ftnmgr -c mycfg.txt -- nightly
				   ...
				   if %CMDLINE contains nightly then
					display "  Doing nightly maintainance"
					.....
				   end

 * Known Bugs:
   * Crash is the only flag supported by Post.
     WorkAround: Abuse me until I add support for the other flags.
   * There was an error report of out of stackspace in 0.3.  In v0.4a that
     part of the program was completely rewritten anyway, however I feel
     that its more likely to bring the bug out, so I doubled the amount of
     stackspace.  This may cause "out of memory" errors elsewhere,
     <<shrug>> you win some, you loose some :)
   * Doesn't add MSGID.  Your tosser (hopefully) will do this.

 * Credits:
   In this program, I've made extensive use of MkMsg to do all the hard work
   of editing/modifing the message bases.

	JAM(mbp) - Copyright 1993 Joaquim Homrighausen, Andrew Milner,
						 Mats Birch, Mats Wallin.
						 ALL RIGHTS RESERVED.

	The JAM developers have requested that you include the above
	copyright notice in any JAM products that are developed.

   FTNMgr is also written in Turbo Pascal 7.

   I'd also like to thank all the people in ARTWARE, including (but not
   limited to) Ted Menks and Andre Tertling.  Also thanks to Art who, without
   bugs in NetMgr this program would have never been written :)

 * Feedback:
   Please send any feed back to me: Perry Lorier 3:774/950.42, I'd like to
   hear bug reports and success stories at this stage.

   Be sure to include the version number and the build date (the number in
   square brackets when you run the program).  I intend to update the version
   number when I make a significant change, but as I work on it, I intend to
   release little "minor" upgrades, (eg: changed the spelling of something
   etc), and these will have the same version number, but a more recent build
   date.  There maybe no "functional" differences between these minor upgrades
   they'll be something like "I rearranged the source code a lot, it should
   all work identically to the previous version, but who knows :)"

   Also send me your .RUL files.  I'd like to distribute a collection of them
   for people to get ideas from and/or just slot in and use.

 * History:
    0.1: Released an alpha, dunno how far it got, I suspect into my Bosses
         incoming directory and hasn't got much further than that :)
    0.2a: Released a second alpha: This has a few less bugs.
          * Fixed bug with "STOP" not being recognised as a command.
            (Stupid semicolons)
          * Fixed bug with error messages giving wildly inaccurate line
            numbers, also it won't give a line number into the rule file if
            its processing the .CFG file when it happens :)
          * Added checking to see if the file didn't end with a STOP and
            complain.
          * Rearranged the source a bit.
            Bugs should be more localised, changes are easier to implement,
            and the program should be more consistant.
          * Added "Include" to the config file. (not rule file)
            Include can be nested.
          * the undocumented PACK() command still doesn't work: don't expect
            it to.
          * Changes imbedded tear lines to -!- lines, embedded origin's to
            " @ Origin:", it also attempts to "clean" up 'bad' Origin's:
            " * Origin:text" -> " * Origin: text" and attempts to fix wrapped
             origins. (currently doesn't do a very good job - it tends to just
             give up and replace them with " @ Origin:")
    0.3a:
          * Added Exec command to .cfg file and example exec.rul file.
          * Fixed bugs with the dest/orig parameter in post() not allowing
               digits (no digits in an address field makes things fun :)
          * Added CRASH parameter to post (crash=yes)
          * Dropped the fsm.txt: it was getting out of date, and was reasonably
               pointless.
          * Added command line options.
                -c <configname>    : Changes the default config filename
                -- <options>       : Options to be passed to scripts in $CMDLINE
          * added TOUCH command.
                Usage: TOUCH <filename>
          * Modified the loading of scripts slightly, they should now give
               better errors when running off the end of a script file.
      0.4a:
          * Changed $CMDLINE a bit, I'm not sure if you can tell what I did
            at the mo, but if you can then you'd welcome it :)
          * Added [no]EXEC and [no]SCAN cmdline options.  (to allow for
            poll:  POLL 1:2/3.0 CRASH NOEXEC NOSCAN, to just create a poll :)
          * Added Tearline/addtear/Origin to .CFG file.  (See .cfg file for
            details)
          * Added logging (eventually)
          * Added echomail support
          * New config file format: You define your areas THEN scan them.
          * You must now use AreaTags instead of those weird paths in
            SCAN/FORWARD/POST.
          * Now that it knows what is echomail and what isn't it won't
            insist on adding Origins to everything :)
          * Now fixes a few more origins in the body, and fixes them correctly
          * Now knows about seenby's and paths.
          * Fixed a few misc bugs
          * Error handlings nicer, instead of dying horribly, it now
            announces that there is a problem, attempts to identify
            the problem, THEN dies horribly.
          * Fixed a bug in the dox, thanks to Ted Menks. :)
          * Added LogID for portal style logging (see .cfg file)
          * Fixed Logging (again)
          * Added local time/date @expandables@
	v0.4.1a [980121]:
          * Uses slightly less memory and less space in the executable
          * Reports v0.4a instead of 0.2... (whooops!)
          * Uses a larger stack (twice as large) - Thanks to Ted (again)
          * (re)Added Hudson support (should've done it earlier: It was a
            one line re-enable :)
        v0.4.2a [980203]:
          * Fixed Logging with single digits
          * Added "Portal2000" logging type: Shows 4 digits worth of year
            instead of 2.  (Hey! Thats why we're here remember?)
          * Added Bounce()
          * Added Append
          * Added "IN" string-op.
          * Fixed bug with String-Op's (ooooops!)
          * Fixed bug with first line not being able to be a comment
          * Fixed bug with "stop" literally stopping processing: half way
            through the rule file - Even if it wasn't supposed to be executed
            :)
          * Fixed bug with seen-bys
          * Fixed "bugs" in MkMsg (Squish areas skip Kludges when reading)
            This looks like a "feature", but it didn't work as expected
            (it appears to break the sample programs - so I fixed it :)
          * Fixed problems with post() command: Adding echomail support
            appear to have killed it.  (And I was ready to blame it on Ted
            too before I found it :)
          * The source (excluding MkMsg) is now larger than 2700 lines...
          * Fixed the docs (I use tab set at 5 chars, other people don't :)
          * Added rules.zip (UNZIP with directories!)

  ToDo:
    For 0.4b Release:
	Remove all the bugs that are hiding around :)
	Get confirmation that it works on other peoples systems :)
    For Version 1.0:
	Use EchoToss.Log
	Add "HUDSONPATH"
	OS/2 Version
	Shorten the ToDo List
	Parse -p<primary> options - Andre
	Add "shell <file>" - Requires swapping :(
	Implement Nodelist lookup stuff.
	Implement POLL/GET/FREQ/PUT/FATTACH command line options.
    For Version 2.0:
	Implement variables for .RUL files.
	Get PACK() working.
	Update the loading of scripts to be "smarter".
	Strip whitespace while loading, and possibly tokenise.
    When ever:
	Add JIT (Just In Time) compilation of *.RUL files. :)
	Add WITHIN <file>, which is "contains" for files.
	Add IN FIELD <n> OF <file> and @FIELD[file,2]@ and @RANDOM[low,high]
	 Eg: (to provide a anon-remailer:)
	  If To in field 1 of anon.txt and dest=@me@ then
		forward (
		 to=@field[anon.txt,2]@ dest=@field[anon.txt,3]@
		 msgid=remove
		 area=netmail
		)
		stop
	  end
	  if To equals "anonymous" and dest=@me@ then
		set name=anon@random[1,10000]@
		append anon.txt "'%name' '@from@' '@orig@'"
		forward (from=%name orig=1:2/3 area=anon)
		stop
	  end
