196 Iteration Checker

By Benjamin Despres

07/26/2002



I have distributed this program under the terms of
the GPL v2.0, the text of which appears at the end
of the source file "checker.c".  The text of the
GPL MUST remain with all versions of this program,
including any derivative works.  Moving it to its
own file (usually named "copying") satisfies this
requirement.



To use this program, simple open a command prompt, and
type in its name.  It will pop open a file selection
dialog, from which the user can pick the file they wish
to verify.

Optionally, it will accept the name of the file to
check on the command line (like "checker.exe file.in").



The program expects input files in Istvan's now-standard
file format.  This looks like:

    Automatic save #64092
    Initial value:    196
    Iteration:        576
    Number of digits: 250
    1317191308531864933984790618882481229220015136660428664605037127912503
    2908245249128187716660217798067107920633256226930087604051578993071265
    2345920791751898711956628780830853531909220620983074050635693395772151
    0913021293287826998380439369026893191722

With each line starting at column 0 (I indented the above
block-quote for clarity).

This save started from "196" as iteration #0 (IMPORTANT!
If the user expects the MOD-9 checksum to not always
fail, the iteration must start at 0 for the number
listed under "Initial Value").  It contains the result
from iteration #576, consisting of a 250 digit number,
given starting on the fifth line.

The most important features:

The first line has the actual number (not counting the
octothorpe) starting in column 17 (from 1).  Incidentally,
I use this line to store the CRC-16, since it doesn't do
anything for the integrity of the file and I could change
it at will without affecting backward compatibility.  I
believe Istvan used it to record an increasing save number,
though starting from when (196?  Last restart?  Current
digit length?) I do not know.  In any case, just make
sure this line five digits starting in the 17th column,
and the checker program won't choke.

The next three lines should all have their number starting
in column 19 (again, from 1).

The actual stored number should have a line break every
70 digits (My program will deal with other lengths; I do
not know how much flexibility Istvan's original program
had, so I used exactly the same length for output).

The last line of the stored number can have any length
(up to 70), but should include a line break at the end.



If all goes well, the program should have output like
the following (I named the file "iter_576.txt", but the
actual name does not matter):

    Checking Istvan-formatted 196 file "iter_576.txt"...

    File has the correct CRC-16, FA5C

    Reported length (250) equals actual length.

    MOD-9 checksum (0) passed.

If something *doesn't* pass the check, the line will
start with "Error" (for critical failures that prevent
the program from attempting to continue), or "Warning"
(for problems that mean something doesn't quite fit, but
the program can continue it's task).

As of this writing, only my own 196 iteration program will
write a valid CRC-16 in the output file.  For that reason,
the user needn't worry if it gives an error something like
"Warning: Incorrect CRC-16 (0002) in file, should have FA5C".



Finally, a warning.  Although this program will deal
gracefully with bad numbers, it will crash badly on
actual format violations.  While this shouldn't cause
any damage, I generally encourage people to avoid
antagonizing programs that have open file handles.
Basically, just make sure the file's header looks
like the one I quoted above, and all will go well.



Enjoy.
