


                                  L   L  L   L
                                  LL LL  LL LL
                                  L L L  L L L
                                  L   L  L   L
                                  L   L  L   L


     LLL  L   L  LLLL    LLL   LLLL   LLLLL       LLLL   L     L   L   LLL
      L   LL LL  L   L  L   L  L   L    L         L   L  L     L   L  L
      L   L L L  LLLL   L   L  LLLL     L         LLLL   L     L   L   LLL
      L   L   L  L      L   L  L  L     L         L      L     L   L      L
     LLL  L   L  L       LLL   L   L    L         L      LLLL   LLL    LLL


                             L   L  LL    LLLL  LL
                             L   L L  L      L L  L
                             L   L L  L     L  L  L
                              L L  L  L    L   L  L
                               L    LL  L  L    LL




                          (C)  1994-96  Robert Hofmann





 1. Introduction
 ===============

  1.1 Legal stuff
  ---------------

   MM_ImportPlus is an enhanced  import-script for Mail Manager by Pino Aliberti
   to launch certain commands  if new net- and/or  echomail arrived. In addition
   that, it directly supports MM_AreaManager by Frank Schnittger and offers also
   many other useful features.

   The programs and files in this distribution are freely distributable, but are
   also Copyright (c) Robert Hofmann.  They may be freely distributed as long as
   no more than a nominal fee is charged to cover time and copying costs.

   No commercial usage is  permitted without  written permission from the author
   Everything in this distribution must be kept together, in original unmodified
   form.


   MM_ImportPlus  is mailware :-). This means if  you use it,  please write me a
   short mail. You know,  it is frustrating  to write programs  and there are no
   responses from the users if they like it or not...


   Accepting these few points is the only condition for using MM_ImportPlus...



   ============================================================================
   The author is not responsible for any problems caused by using this program!
   ============================================================================



   ****************************************************************************
   WARNING: DO NEVER MODIFY  THE SCRIPT!  THIS  COULD END IN  THE LOOSE OF NET-
            MAILS IF YOU DON'T EXACTLY KNOW WHAT YOU ARE DOING!!!
            IF THERE IS A  PROBLEM, PLEASE  REPORT IT  TO *ME*, SO THAT *I* CAN
            FIX IT!
   ****************************************************************************



  1.2 General stuff
  -----------------

   I am not the best in  writing doc, but quiet good  in coding I think :-) This
   docs are a bit  short I have to  appolognize, but I hope you'll understand it
   anyway... Especially my English and the typo's ;-)


   If there is  anybody out there  who is able to &  wants translate the docs to
   his own language, please do so and send them to me! I'll add them to the next
   release. Also translators always will get the newest betas! ;-)

   Unfortunatly I don't have the will & time to translate my docs even to German
   - my time is better used for coding :-)





  1.3 Author
  ----------

   If  you  have  suggestions  or remarks about this program, or if you find any
   bugs, please let me know.


   Contacting the author:

     Internet .. :  robert@next.amistep.osn.de (soon!)
     FidoNet ... :  2:2490/1015.0   (may change soon!)
     AmigaNet .. :  39:171/101.0

     Snail-mail  :  Robert Hofmann
                    Volkmannstr. 35
                    D-90443 Nürnberg
                    Tel. +49-(0)-911-9941680 (18-20h German time only!!!)
                    Germany

     Bank-Account:  Account-holder:  Robert Hofmann
                    Account-number:  67920
                    Bank-ID ..... :  76090000
                    Bank-name ... :  Volksbank Nuernberg e.G.





 2. Features
 ===========

  MM_ImportPlus...

     ... does only import, if an import is necessary
     ... offers free-memory-sensitive import (even CHIP/FAST-sensitive)
     ... offers security-check of received bundles
     ... is able to execute commands BEFORE an import
     ... is able to execute commands when new NETMAIL arrived
     ... is able to execute commands when new ECHOMAIL arrived
     ... is able to execute commands when BOTH of the above arrived
     ... is able to execute commands when TICKs arrived
     ... is able to execute commands when nothing was to do
     ... directly supports MM_Areamanager >= v0.50
     ... directly imports ticks (of course only if you want ;-)
     ... is protected against running more than once at the same time
     ... is able to sort the bundles for a correct import-order
     ... can be dis/enabled by the user
     ... can be suspend/resume importing of bundles & tics
     ... has an enhanced "Wait-For-Areas-Window"-Requester
     ... has an advanced & fast cfg-reading mechanism





 3. Installation
 ===============

  Just copy  the files  to the  corresponding  MM:*/-directories  and adjust the
  config to your own needs.


  IMPORTANT: MM_ImportPlus.rexx  *MUST*  be  placed  in  "MM:Rexx/"!!!  This  is
             necessary  because  MM_ImportPlus  appends  its  cfg  to the script
             itself for a *VERY* fast cfg-reading.
                              *** NEVER TOUCH ITS FILENOTE!!! ***

  NOTE:      You must have the original "list",  "avail" &  "setdate"-command in
             c:!


  As you may have seen, there's a second  script called "MM_ImportPlus.rexx.cmp"
  included. This  is a exacltly the same script  as "MM_ImportPlus.rexx" itself,
  except that it was compressed with "CompressRexx v2.1".

  On slow machines, it  might be useful to  replace the uncompressed script with
  the  compressed one because it is slightly faster... But  please test it first
  with the uncompressed  version, because if an error occurs,  finding the error
  due to error-reports of the compressed script is nearly impossible!

  If you really want to use  the compressed script, you  have to REPLACE the un-
  compressed script with the compressed  one! The used script MUST exactly named
  "MM:Rexx/MM_ImportPlus.rexx", otherwise it will not work!





 4. Usage
 ========

  [RX] MM_ImportPlus[.rexx]  CPLCFG/S,FORCEIMPORT/S,DISABLE/S,ENABLE/S,
                             SUSPEND/S,SUSPEND/K/N,RESUME/S,TICKIMPORT/S,
                             NOTICKIMPORT/S

    CPLCFG       Force MM_ImportPlus to compile its cfg again. This is necessary
                 if you have added  or deleted a node  from MM.cfg, because this
                 is not automatically checked...

    FORCEIMPORT  Start import  disregarding  #MINRECEIVED,  #MINFREEMEM, inbound
                 check, #SECURITY & multiple running-protection...

    DISABLE      Disable (see 5.1) MM_ImportPlus until you
    ENABLE       enable  (see 5.2) it again.

    SUSPEND      Suspend (see 5.3) bundles & tics from being imported.
    RESUME       Resume  (see 5.4) it again & import all waiting mail.

    TICKIMPORT   Override cfg: #NOTICKIMPORT (see also 7.16)
    NOTICKIMPORT Override cfg: #TICKIMPORT   (     -"-     )



  Return-codes:
  -------------

   RC = 0:  All ok.
   RC = 1:  Bundles were moved to #BADDIR (see 5. )
   RC = 5:  No files to import
   RC = 6:  Size of files < #MINRECEIVED  (see 7.8)
   RC = 7:  Memory-sizes  < #MINFREEMEM   (see 7.7)
   RC = 8:  Execution disabled/aborted by user
   RC = 9:  another MM_ImportPlus is already running...

   RC>=10:  Error, script-execution  failed! See MM.log for a more detailed info
            about the error...





 5. Anvanced command-line-options
 ================================

  The functions  described  here are controlled by setting  and deleting its own
  env-variable "ENV:MM_ImportPlus".

  These switches are  like flip-flops. Once set, it keeps set until you reset it
  again.



  5.1 DISABLE
  -----------

   If you disable  MM_ImportPlus, it will  not do  anything until you  enable it
   again.



  5.2 ENABLE
  ----------

   Enable MM_ImportPlus again and import all waiting mail.



  5.3 SUSPEND
  -----------

   Suspend  bundles and  tick-files  from being  imported, import only  *.PKT's.

   To prevent  MM from importing  these files, MM_ImportPlus  just renames them.
   E.g. "12345678.MO0" will be "Wait.12345678_MO0" and so on...

   If you set a limit in kB, smaller files  than {kB} will not be suspended (see
   also 7.14).



  5.4 RESUME
  ----------

   Resume importing of all waiting files. This just means all waiting files will
   be renamed back to the original names, so that they can be imported again.

   MM_ImportPlus  will check for  waiting files at every  import, even if it was
   not suspended. This was done to prevent your system from not importing mail,
   e.g. due to a crash while importing or something like that...





 6. Security-Check
 =================

  MM_ImportPlus  also  offers  a security-check (see 7.12) of  received bundles.
  This  means before  starting  the import, it  will look  for received  bundles
  (pattern:  ((????????|#?.#?.#?.#?).(MO|TU|WE|TH|FR|SA|SU)([0-9]|[a-z]|[A-Z]) )
  and check if

   1. the sender is listed in MM.cfg or in #NODES (see 7.10) and
   2. the bundle was received during a password-protected session.

  Otherwise the bundle will be moved to MM's #BADDIR.

  This feature was added because some idiots still try to send mail-bombs and MM
  itself has no security-check to prevent such things.





 7. Configuration
 ================

  MM_ImportPlus has an advanced config-reading-mechanism,  which implements your
  config directly to the  script itself. This means once the config is compiled,
  it will need less than one second (A3000 50/50MHz) to read its config!

  Only if you change the  config, it will need a while until all checks are done
  and the config is compiled.



  7.1 AREAFIXCMD <command>  *** Only needed for MM_AreaManager!!! ***
  --------------

   Execute these  commands,  when no netmails were  imported but  when new areas
   were  created  during  the last import. This  is used  for  the Autolink  and
   Announce functions of MM_Areamanager.


   Usage:
   ------

   #AREAFIXCMD   rx mm:rexx/MM_AreaManager NOFORCEEXPORT



  7.2 BADDIR <directory>
  ----------

   If you want to ovverride MM's #BADDIR, you can set an optional dir here.


   Example:
   --------

   #BADDIR Bad:



  7.3 BEFORECMD <command>
  -------------

   Execute these commands, always before importing mail.


   Examples:
   ---------

   #BEFORECMD  rx MM:Rexx/MM_Upload



  7.4 BOTHCMD <command>
  -----------

   Execute these commands, when net- and/or echomails were imported.


   Examples:
   ---------

   #BOTHCMD    rx MM:Rexx/MM_ExportPlus QUEUED
   #BOTHCMD    c:move SPOOL:MM/Tmp/* in: quiet clone buffer 1000
   #BOTHCMD    delete backup:*,* quiet noreq



  7.5 ECHOMAILCMD <command>
  ---------------

   Execute these commands, when echomails were imported.


   Examples:
   ---------

   #ECHOMAILCMD  echo "Echomail was imported..."



  7.6 (NO)ICONIFY
  ---------------

   Auto-iconify MM before importing mail.


   Example:
   --------

   #ICONIFY



  7.7 MINFREEMEM CHIP <size in kB> FAST <size in kB>
  --------------

   Only start the import if you  have more chip/fast-ram  left than you have set
   here. Strip this entry if you want to disable this feature.

   If there was not enough memory left MM_ImportPlus will return with RC=6.

   NOTE: this has NOTHING to to with MM's #MINFREEMEM!!!


   Example:
   --------

   #MINFREEMEM CHIP 500 FAST 2500



  7.8 MINRECEIVED <size in kB>
  ---------------

   Only start the import if more mail arrived than you have set here. Strip this
   entry if you want to disable this feature.

   NOTE: a *.TIC-file will be counted with 100k.


   Example:
   --------

   #MINRECEIVED 10



  7.9 NETMAILCMD <command>
  --------------

   Execute these commands, when netmails were imported.


   Examples:
   ---------

   #NETMAILCMD   rx mm:rexx/MM_StarTrack
   #NETMAILCMD   rx mm:rexx/MM_AreaManager



  7.10 NODES <nodes ... ... ...>
  ----------

   If  a node  is not  listed in  MM.cfg,  you can add  it also here  instead of
   creating a new  node in  MM itself. This is especially  usefull if the sender
   uses a different aka in his mailer than configured in MM.cfg.


   Examples:
   ---------

   #NODES 2:2437/901.0@FidoNet 2:2437/902.0@FidoNet 2:2437/903.0@FidoNet
   #NODES 2:2437/905.0@FidoNet 2:2437/906.0@FidoNet 2:2437/907.0@FidoNet
   #NODES 2:2490/1371.0@FidoNet 2:2490/1372.0@FidoNet 2:2490/1373.0@FidoNet



  7.11 NTDCMD <command>
  -----------

   Execute these commands, when no net- & echomail was to import.


   Examples:
   ---------

   #NTDCMD   echo "There was noting to import..."



  7.12 (NO)SECURITY
  -----------------

   Turn security on or off (see also 5.)

   Default: #NOSECURITY



  7.13 (NO)SORTBUNDLES
  --------------------

   MM imports the arced mail by its  timestamp, so if you receive a *.TU0 before
   a *.MO0 of *.SU0, it will be imported first. 8^(
   If you set #SORTBUNDLES, MM_ImportPlus will set the timestamp of the received
   bundles to a proper  order relativ to the  current day, so that the mail will
   be imported as it should.

   Default: #NOSORTBUNDLES



  7.14 (NO)SUSPEND [{kB}]
  -----------------------

   If (a value in kB is) given, all  bundles (>= kB) will be suspended until you
   start MM_ImportPlus with option RESUME.

   This is e.g. useful if  you want to import all  small bundles but not the big
   bundles from your uplink.

   If set and you start MM_ImportPlus  with the command-line-option SUSPEND (see
   6.3), the new value will only be vaild for one import.

   Default: #NOSUSPEND



  7.15 TICKCMD <command>
  ------------

   Execute these commands, when ticks were imported.


   Examples:
   ---------

   #TICKCMD   b:FFRSindex FORCE NODIRS



  7.16 (NO)TICKIMPORT
  -------------------

   Turns the tickimport-function on or off.

   Default: #TICKIMPORT





 8. Developpers note
 ===================

  If your program/script will be  started via MM_ImportPlus  it would be nice if
  you'd  also  support  the log-tracking, so that  you easily can  find out what
  output is from what script.

  Until MM_LogPre was inmplemented into MM itself, we (Frank & me) decided to do
  it using a ARexx-clip for storing the prefix.


  You should do it like

  Startup:
  --------
   system.mm.logpre  = getclip('MM_LogPre')
	 system.prg.logpre = system.mm.logpre'|'
	 call                setclip('MM_LogPre', system.prg.logpre)


  Logging:
  --------

   call Log(<text>[, optional prefix])

   Log: procedure Expose system.

    parse arg text, pre

    tmp  = word('PRG MM', (pre~='')+1)
    text = system.tmp.logpre || pre' 'text

    MM_WriteLog 'text' '2'
   return


  End:
  ----
   call setclip('MM_LogPre', system.mm.logpre)





 9. Acknowledgements
 ===================

  Pino Aliberti     For his EXCELLENT Mail Manager! For  implementing nearly all
                    I wanted (this was much work I think and delayed the release
                    of MM for  some month ;-)) For our  hard but fair  fights in
                    MMBETA and at least  for the nice note  about me in the docs
                    8^))))


  Frank Schnittger  For MM_AreaManager, testing  MM_ImportPlus  and all the bug-
                    reports ;-)









  _  o    Robert Hofmann            2:2490/1015@FidoNet   16:168/9024@ZyxelNet
 |<)_/#                            39:171/101@AmigaNet   107:1805/230@TrekNet
 TT  <T   AMINET<->AmigaNet-Gate   56:63/201@XNet        213:314/9127@XCessNet


