
                       FDChk - The FAST DMS Checker
                               Adder 'n Remover!

                                Version 2.1b


                         Programmed by SiNTAX/TsL


1. Introdution
--------------

Well it was bound to happen someday.. a nasty little bug slipped into the
68020 version, which caused it to crash when using the %-sequences. That
has been fixed now, so it should work 100% (hmm well I wouldn't bet my life
on it tho... haven't seen any program that is really 100%)


2. But first
------------

CHECK The files in this archive to avoid nasty backdoored patches of this
production, although this is no 100% guarantee, it sure is safer than just
COPY 'n RUN...
Now let's put it more formal:

The utility 'CRC' (included in this archive) calculates a so-called
`WRAP' checksum. For all the files in this distribution, this checksum
MUST be zero. If this is not correct then delete the file immediately
because then you know that it has been modified!

         FDChk21_68000  (CRC = $1377410D, Size =  4836 Bytes)
         FDChk21_68010  (CRC = $B5B1BCE3, Size =  4836 Bytes)
         FDChk21_68020  (CRC = $835A40AA, Size =  4828 Bytes)
         CRC            (CRC = $4F5177B9, Size =  4104 Bytes)
         FDChk.DOC                       (Size = 21869 Bytes)
         InfoScreen.FDC                  (Size =   394 Bytes)
         AddText.FDC                     (Size =  2620 Bytes)
         DMS                             (Size =    18 Bytes)
         UL_MSG.REXX                     (Size =  1805 Bytes)
         LUser.REXX                      (Size =   467 Bytes)
         SetEnv                          (Size =   448 Bytes)
         GetEnv                          (Size =   336 Bytes)

Although I included an internal check to see if somebody has tempered
with my programs, you better check out these values to be 100% sure that
the programs are in their original form!


3. The USe
----------

o Novice-Level

First of all make sure you have the ARP.LIBRARY in your LIBS: directory,
otherwise you won't even be able to start the program! Secondly, ENV: must
be assigned, else you'll get a nice requester asking you to insert volume
ENV... That's about all you HAVE to do to start.

o Profi-Level

Now I'll describe why this isn't just another DMS Checker, Adder 'n Remover.

- Adding DMS texts

        FDChk will look for a text file called 'S:AddText.FDC' and will append
        it to the end of a DMS file. This file may include some special
        %-sequences to instruct the program to insert some information about
        the dms file itself. These %-sequences will be described later on.
        NOTE: The text file will be truncated if it's larger than 20.000 bytes

- Adding a customized look

        You are able to add an InfoScreen to the program. Just create a file
        called 'S:InfoScreen.FDC' and include all the stuff you want, ofcourse
        you are also able to use the same %-sequences in this text.
        This info screen will be shown to the standard output channel, so you
        can use it as some kind of info-feedback to the user.

- Configurating FDChk

        The program is guided by means of Environment strings. So it's fairly
        easy to change the fucntions of the program. All you need are 2 cli
        programs called 'SetEnv' and 'GetEnv' although you don't really need
        the last one. To change an option just issue the following in your cli

        1> SetEnv FD_<ENV> <parameter>

        The available environment strings are:
               FD_BUF   : Defines the Max amount of memory FDChk should use
                          as buffer to read in the DMS File
                          Default: '901120' (880Kb)
               FD_CFG   : Configuration for FDChk (described below)
               FD_UNAME : Name of the user who uploaded the file
                          Use this to be able to include the name of the
                          uploader in your text. I selected this methode
                          of getting the uploader name, rather than scanning
                          the logfile because it is a hell of a lot faster!
                          Default: 'UNKNOWN'
               FD_UMSG  : A message from the user that can be included in
                          the InfoScreen and AddText! Max size 70 chars, if
                          the text is longer then the default will be used.
                          Default: 'UNKNOWN'
               FD_DATF  : Define date format (see further down for more info)
                          Default: 'DOS'

        FD_UNAME and FD_UMSG both end in '.X' where X is the node they are
        used for.. so FD_UNAME.0 is for node 0.. etc..

        FD_CFG can contain the following switches:
                'A'   : Add DMS Text Ad
                'D'   : Disable DMS Texts that are present in the source file
                'R'   : Remove DMS Texts (slower than disabling)
                        The difference between disabling and removing is that
                        remove will REALLY remove the text ads from the DMS
                        file where disable will only disable the displaying of
                        the texts
        So if you want to add your text and Remove the other texts, you should
        write SETENV FD_CFG "AR"

        FD_DATF can be set to the following strings:
                'DOS' : AmigaDOS format (dd-mmm-yy)
                'INT' : International format (yy-mmm-dd)
                'USA' : American format (mm-dd-yy)
                'CDN' : Canadian format (dd-mm-yy)

4. Control sequences
--------------------

The format of the control sequence is:

             %[flag][width.limit][option]
  
        Where:
              [flag]   can be a '-' to use left alignment
              [width]  field width. If the first char is a '0', the field
                       will be padded with leading 0's
                .      must follow the width if you want to use the limit
                       option
              [limit]  maximum number of chars to output from a string
              [option] the actual option to use, ranges from 'A' to 'O'
                       using a char out of this range, will just result
                       in the text after the % being displayed
                       See below.

If you want to use a '%' in your texts you need to type '%%' so that the
program will know you don't want to use a control sequence.

FDChk knows the following options:

        A - Name of the day when file was UL'ed  (e.g. Monday)
        B - Date when the file was UL'ed
        C - Time when the file was UL'ed
        D - Low track used in archive (as in information given by DMS when
            using the VIEW option)
        E - High track
        F - Packed Bytes
        G - Unpacked Bytes
        H - Serial No. of creator
        I - CPU of the creator
            (68000, 68010, 68020, 68030, 68040, 68050, 8086, 8088, 80188,
             80186, 80286, 80386, 80386SX, 80486, 80586)
        J - CO Processor of the creator
            (68881, 68882, 8087, 80287, 80387SX, 80387)
        K - Computer Type of the creator
            (AMIGA, PC/CLONE, ATARI ST, MACINTOSH)
        L - Compression mode used to make the archive
            (NOCOMP, SIMPLE, QUICK, MEDIUM, DEEP, HEAVY1 - HEAVY5)
        M - Filesystem
            (AMIGA OFS, AMIGA FFS, MSDOS, AMAX, MAC)
        N - Name of user who uploaded the file (should be used in conjunction
            with the ARexx Door)
        O - Message from the uploader (dito)


5. A word about Multi-Nodes
---------------------------

Finding a suitable way to get the node number on a multi node system needed
some thinking, because it had to be a fast and memory friendly way. So I
decided to do the following: FDChk will scan it's parameter for the word
'NodeX' in the pathname. If the scan is succesful, it will use the node number
found in the path. This way you will be able to use the external file checker
protocol from AmiX, without having to do some patch work! Just add the
supplied (in this archive) DMS FCheck entry to your BBS:FCheck dir and off you
go.
Now this methode works fine as long as you use the external file check
protocol of AmiX, but when you have some 3rd party util, it won't always be so
easy to use this methode... so I included another way to pass the node number
to FDChk. Just enter a -X to the parameter, where X is the actual node number
for which FDChk is doing the checking. This will allow you to use the util in
conjuntion with utils like OffLine Checker etc. All you need to do, is make
seperate logoff scripts for the nodes. For the Pseudo-ops OffLine Checker you
would for instance create a library file for each node, in which you put the
program name and the parameter, which is then -<node nr>
Here's an example of my LibFile for the OffLine Checker:

00000000|444D5321|FDChk -0|%s|

                    ^    ^
                    |    Node number
                    Program name


6. Available version
--------------------

FDChk comes in 3 versions, each optimised for their processor, and I mean
REALLY optimised NOT some Lame-C like optimising! So be smart and use the
version for your CPU! Ohwell you'll have to do that anyway, coz' they will
only work 100% on the CPU they were developped for! This has something to
do with priviledged instructions and shit, but then WHO CARES?!?
'030 users should use the '020 version, which is actually also made for '030
processors. BUT as I don't have an '030 or even an '020, I was unable to test
them thoroughly. (HINT: accelerator card is very welcome! hoho)


7. Speed Comparison
-------------------

File 'EDK-POWE.DMS' size 906493

           HSCHK V4.19B     |  DMS V1.11      | FDChk V1.2 (68000 version) 
        ---------------------------------------------------------------------
Checking|  13.160 seconds   | 34.680 seconds  | 12.120 seconds (BUF=300000) |
        |                   |                 | 12.380 seconds (BUF=100000) |
        |                   |                 | 11.820 seconds (BUF=901120) |
Disable | not possible      | not possible    | 12.000 seconds (BUF=901120) |
Remove  | not possible      | not possible    | 14.880 seconds (BUF=901120) |
        ---------------------------------------------------------------------

Well as you can see FDChk beats the shit out of the others! Even with a small
buffer, FDChk is able to archive high speeds! Ofcourse the lower the buffer,
the more diskaccess you get. So with a small buffer, the speed much depends on
how fast your HD is.


8. The ARexx doors
------------------

If you want to use the %N (UploaderName) and/or %O (UserMsg) option, then you
have to install the supplied ARexx Doors.
The first door 'LUser.REXX' sets the FD_UNAME.x environment with the name of
the user who just called. You need at least version 2 of AmiX to use the door,
because the door should be called just after the user logged in. This can be
done with BULL.AXM (AmiX V2.05) or with the MCI Commands (AmiX V2.08+). For
AmiX V2.05 you should add the following to your BULL.AXM file:

*LU       RM030DOORS:FDChk/LUser.rexx

The name of the door itself may be changed to something else. It doesn't
matter what it's called.
In AmiX V2.08+ the BULL.AXM has been replaced by the MCI Commands, so you
should make a file called BBS:BULL.TXT and put the following in it:

~CC_LU|

The door definition has to be present in your CustomCommands file, and it
should be defined as above (*LU       RM030DOORS:FDChk/LUser.rexx). Now
when a user log's in, the door will be executed and the user name will be
saved to the right environment string.

The second door is used to set the User Message. To install it, add the
following line to your CustomCommands file:

*U        RM030DOORS:FDChk/UL_MSG.rexx

Now when a user selects 'U' to upload, he will be asked if he wants to add
a one-liner to the DMS Text Ad. After that, the FD_UMSG.x environment will
be set and the normal 'U' command will be executed.
(NOTE: the UL_MSG door accepts a commandline parameter 'N' or 'Y' 
       'Y' for adding a one-liner and 'N' for no one-liner)

You can also change the minimum access level a user needs to be able to set a
one-liner. To change this, load the door and change the MINSEC variable to the
level you want.


9. History
----------

Version 1.0

o First release of this wonderful DMS checker and text adder
  (NOTE: This version was released accidently due to a human error, mine)


Version 1.1

o Improved commandline handling
o FULL PC-Relative code
o Removed the EGO-TRIP message (you know, the one that sticked to all your
  dms files)
o Bug fixed (Crashed when not enough memory was available!)
o The 68020 version now really works! There was a bug in the processor
  identification routine that caused the program to think you only had an
  MC68000!
  (sorry about this one.. but I don't have a turbo card so...)
o Internal checksum added, to stop some lame name changers! (note to those
  lamers: I have put time and effort in this program, so I think I deserve
  some credits for it.. and if you don't agree then go and code your own
  tool!!!!!!)
  NOTE to the honest users: check the CRC value of your version, because the
                            program won't tell you if a lamer has tempered
                            with it.. so DO it, OR suffer the consequences!
o Now really worx with Ami Express V1.1V !!!!! All faulty DMS's will go to
  the HOLD dir !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
o Just received Ami-Exp V1.1w... I guess the previous improvement doesn't
  matter that much anymore coz' you can now configure AE yourself. There's
  also an example AE-Checker file included, to make it easier to install
  the tool. NOTE: you don't have to change AE with NEWZAP anymore from 1.1W
  on, just use the external checker ability
o Also included an 68010 version (read 4. for more info)
  NOTE: I didn't have a chance to test this, but it SHOULD work OK. It's
        practically the same as the 68000 version, only 2 instructions
        are different SO what can go wrong?!?!?!


Version 1.2

o Added MaxMem to limit the size of the buffer for the checking
o Added ability to check a dms file even if there isn't enough
  memory available to read it totally in
o Added a VERY Fast methode to kill the existing DMS Texts
o Bug fixed: Length of text now set correctly in DMS File
             (Copied the upper word, instead of the lower word!)
o Some peephole optimising done
o Added new % options:
          %xxN - The user who uploaded the file
          %xxO - Message from a user (Max. 70 chars long!)
  (NOTE: Requires the arexx door to be installed!)
o Added Environment support. If the environment isn't found then the
  defaults will be used. Current environment vars are:
         FD_BUF   : Defines the Max amount of memory FDChk should use
                    as buffer to read in the DMS File
                    Default: '901120' (880Kb)
         FD_CFG   : Configuration for FDChk (described below)
         FD_UNAME : Name of the user who uploaded the file
                    Use this to be able to include the name of the
                    uploader in your text. I selected this methode
                    of getting the uploader name, rather than scanning
                    the logfile because it is a hell of a lot faster!
                    Default: 'UNKNOWN'
         FD_UMSG  : A message from the user that can be included in
                    the InfoScreen and AddText! Max size 70 chars, if
                    the text is longer then the default will be used.
                    Default: 'UNKNOWN'
         FD_DATF  : Define date format (see further down for more info)
                    Default: 'DOS'
o Fixed a bug (wrote 4 bytes to a var that was only 3 bytes long!)
o Rewrote the sloppy % format routine. The new routine is more user-
  friendly! The routine offers:
              - an OPTIONAL length indicator, so you don't have to add
                the 00 anymore. If you need to align something, then
                just put the size indicator between the % and the option
                No need to make it 2 digits.
                NOTE: don't use extreme values!! (Like 80+)
              - right aligning!! Mucho nicer!
              - an error detection routine, so a %Z won't crash the
                computer anymore
              - a possibility to put a % in the text, just enter %%
              - with digits you can also fill up with zeros, just
                enter a 0 before the size
                (e.g. if %6F would give '  7834' then
                        %06F would give '007834'  nice hey!)
              - optional left aligning by adding a - after the %
              - text limiting by entering a .limit after the size
                where limit is the max amount of chars to copy
                NOTE: This is only valid for text!! When Adding it
                      to a number option, the routine will just skip
                      it. This to be able to use it with the Serial No.
                      option which can be a number or a string.
  So in short:
       %[flag][width.limit][option]
     Where:
        [flag]   can be a '-' to use left alignment
        [width]  field width. If the first char is a '0', the field
                 will be padded with leading 0's
          .      must follow the width if you want to use the limit
                 option
        [limit]  maximum number of chars to output from a string
        [option] the actual option to use, ranges from 'A' to 'O'
                 using a char out of this range, will just result
                 in the text after the % being displayed
o Improved speed of slow scan (removed the _LVOSeek)
o Available strings for FD_DATF environment: (case-insensitive)
       'DOS' : AmigaDOS format (dd-mmm-yy)
       'INT' : International format (yy-mmm-dd)
       'USA' : American format (mm-dd-yy)
       'CDN' : Canadian format (dd-mm-yy)
  The default is 'DOS'. The default will also be used when there is an
  invalid string in FD_DATF.
o Configuration setup for FD_CFG:
       'A' : Add text to DMS file
       'D' : Disable other DMS Texts
  e.g. if you want to Add & Remove text ads then set FD_CFG to 'AD'
o Speeded up slow scan a bit more (faster move routine)
o Made the util multi-node compatible. The environment strings changed a
  bit to make it possible:
       FD_UNAME  ->  FD_UNAME.<node>
       FD_UMSG   ->  FD_UMSG.<node>
  Where <node> is ofcourse the node number ranging from 0 to 9. I used the
  following methode to determin from which node the util was started:
  FDChk will scan the parameter for '/NodeX/' or ':NodeX/' if this string
  is present in the program parameter then FDChk will use the X char as
  node number. This methode is the fastest and simplest way, and it will
  work with the way AmiX checks files (using the BBS:FCheck dir)
o Added another methode to determin the node number, just add '-X' before
  the DMS filename. X must be in range 0-9. Using this way, you are also
  able to use FDChk with the pseudo-ops OffLine Checker, just create a
  library file for each node.
  (This methode overrides the previous one!)
o Bug fixed in slow scan (odd address error in fastcopy routine)
o New config option 'R'  When set, the existing text ads will be removed
  from the source file. NOTE: This requires creation of a temporary file
  and thus results in slower speed! So it's up to you to determin whether
  you wanna trade in speed for a few bytes diskspace
  This option overrides the 'D' option.
o Speeded up the checking routine a bit more!


Version 1.2b

o Fixed bug in the 68020 version, which caused it to crash... here's why:
  I accidently optimized a JSR Tab(PC,d1.w) instruction to JSR Tab(PC,d1.w*2)
  where it was not needed to Multiply D1! Ohwell nobody's perfect!
o Some minor adjustments to the source (you won't notice anything)



10. Planned Improvements
------------------------

o Re-entrant code, so that the program can be made resident!!!
  (Already implemented in the next update!)
  (NOTE to Joseph: What about making Ami-X support Resident file-checkers
                   by using the AddSegment(), FindSegment(), RemoveSegment()
                   routines! This has as an advantage that you can have a more
                   extended way of telling Ami-X what in hell went wrong
                   (pre-defined resultcodes)... I think this is better than
                   Execute() and then scanning the file output... don't ya think
                   so?)

o Smart Read routine that detects a read at and odd address and make it
  even. This is useful for some HD's that have difficulties to read at full
  speed on odd addresses (like mine!)
o New %-sequences (like the dms creation date, ...)
o ... (let's not tell everything, otherwise there is no suprise!)



11. Words of thank
------------------

To all people who motivated me to make this new release, to all people who
brought me some useful ideas to incorporated in this update, and to all my
friends!
And also thanks to Maddy for informing me about the bugged 68020 version,
and to Mike for letting me test the new 68020 on his TurboAmiga.




                  For more details contact me at my board

                Sin City - The Silents Belgian HeadQuarters (AMIGA ONLY!)
                           Home of the SiLENTS Trainers!

                           Node 0: +323-825-2274 (DUAL STANDARD)
                           Node 1: SOOOON aaargggh I hate these cliches!


              >X<>X<>X<>X<>X<>X<>X<>X<>X<>X<>X<>X<>X<>X<>X<
              >X< End of this LOOOONG BOOORING DOC File >X<
              >X<>X<>X<>X<>X<>X<>X<>X<>X<>X<>X<>X<>X<>X<>X<

