Fixes in 1998/tomtorfs

Format fixes.

Use Internet Wayback Machine as the link was dead. This was done in
winners.html and winners.csv as well.

Add crc.txt - a file the author referred to. Found it at
https://opensource.apple.com/source/tcl/tcl-20/tcl_ext/trf/trf/doc/painless-guide-to-crc.txt.

This should complete format fixes in 1998.
This commit is contained in:
Cody Boone Ferguson committed 2023-04-19 11:51:06 -07:00
1 parent 2ea5a8af0e
commit 4b235c9c3b
4 files changed
+2176 -76

No files matched your search

+105 -74
View File
@@ -1,105 +1,136 @@
# Best Self-Documenting
Tom Torfs
De Nayer Instituut
Cuperuslei 12 (home address)
2220 Heist-op-den-Berg
Belgium
http://members.xoom.com/tomtorfs
Tom Torfs
De Nayer Instituut
Cuperuslei 12 (home address)
2220 Heist-op-den-Berg
Belgium
<https://web.archive.org/web/20010520021948/http://members.nbci.com/tomtorfs/>
## To build:
make all
```sh
make all
```
## To run:
./tomtorfs tomtorfs.c 32 04C11DB7 1 FFFFFFFF FFFFFFFF
```sh
./tomtorfs tomtorfs.c 32 04C11DB7 1 FFFFFFFF FFFFFFFF
```
## Judges' remarks
## Try:
Also try:
```sh
echo "abscond conferrable" > file.A
echo "adorn condolence" > file.B
echo "adorn condolence too" > file.C
./tomtorfs file.A 32 04C11DB7 1 FFFFFFFF FFFFFFFF
./tomtorfs file.B 32 04C11DB7 1 FFFFFFFF FFFFFFFF
./tomtorfs file.C 32 04C11DB7 1 FFFFFFFF FFFFFFFF
```
echo "abscond conferrable" > file.A
echo "adorn condolence" > file.B
echo "adorn condolence too" > file.C
./tomtorfs file.A 32 04C11DB7 1 FFFFFFFF FFFFFFFF
./tomtorfs file.B 32 04C11DB7 1 FFFFFFFF FFFFFFFF
./tomtorfs file.C 32 04C11DB7 1 FFFFFFFF FFFFFFFF
## Judges' remarks:
If you don't believe the program is correct, try and compare the output
of the program with the value of CRC computed by PKZIP or any other
archiver that uses the CRC-32 algorithm.
If you don't believe the program is correct, try and compare the output
of the program with the value of CRC computed by PKZIP or any other
archiver that uses the CRC-32 algorithm.
## Author's remarks
## Author's remarks:
Usage:
crc filename bitwidth polynom reflected init xor
```
Usage:
./tomtorfs filename bitwidth polynom reflected init xor
filename : file to calculate the CRC of
bitwidth : width of the CRC in bits (decimal)
polynom : polynomial used for the CRC (hexadecimal)
reflected : 0 if the CRC is not reflected, 1 if it is
init : initial value for the CRC (hexadecimal)
xor : value to xor the final CRC with (hexadecimal)
filename : file to calculate the CRC of
bitwidth : width of the CRC in bits (decimal)
polynom : polynomial used for the CRC (hexadecimal)
reflected : 0 if the CRC is not reflected, 1 if it is
init : initial value for the CRC (hexadecimal)
xor : value to xor the final CRC with (hexadecimal)
```
Examples:
### Examples
CRC-16: crc filename 16 1021 0 FFFF 0000
CRC-32: crc filename 32 04C11DB7 1 FFFFFFFF FFFFFFFF
XMODEM: crc filename 16 8408 1 0000 0000
ARC: crc filename 16 8005 1 0000 0000
#### CRC-16:
Portability notes:
```sh
./tomtorfs filename 16 1021 0 FFFF 0000
```
The program assumes CHAR_BIT==8. Results are undefined if
bitwidth > sizeof(unsigned long) * 8. It is also assumed
that EOF is -1 and 1 is a valid exit value to indicate
failure (replace them with EOF resp. EXIT_FAILURE if the
assumptions are false). Otherwise ANSI/ISO C.
No special build options required.
#### CRC-32:
Special notes:
Count the number of non-whitespace characters in the source
file to find out what dark force drove me to write this ;-).
```sh
./tomtorfs filename 32 04C11DB7 1 FFFFFFFF FFFFFFFF
```
Spoiler:
#### XMODEM:
First of all, if you run a C beautifier on the program
(thereby of course losing the nice code shape I worked
so hard on ;-) the code will become a bit more readable.
```sh
./tomtorfs filename 16 8408 1 0000 0000
The variable names are not very descriptive. They have the
following meanings:
a = argc
A = argv
b = array of unsigned long variables
b[0] = bit-width of the CRC (argv[2])
b[1] = CRC polynomial (argv[3])
b[2] = nonzero if CRC is reflected (argv[4])
b[3] = initial value of CRC (argv[5])
b[4] = value final CRC is XORed with (argv[6])
b[5] = CRC value
b[6] = byte from file
b[7] = counter
B = FILE * through which the file argv[1] is opened
C = typedef for unsigned long
```
The first for loop simply reads the command-line arguments
in the b[] array. The third parameter to strtoul() causes
all arguments to be in base-16 (hex) except the first one,
which will be in base-10 (decimal).
#### ARC:
The rest of the program "simply" calculates the crc in b[5]
and then prints it to stdout. The bit reflection loops may
appear a bit tricky at first, but if you have a good look
at them they should become obvious also.
```sh
./tomtorfs filename 16 8005 1 0000 0000
```
Acknowledgments:
### Portability notes
Ross N. Williams, whose CRC guide was very useful to me
for writing this. You can find it as CRC.TXT in Snippets.
The program assumes `CHAR_BIT==8`. Results are undefined if `bitwidth >
sizeof(unsigned long) * 8`. It is also assumed that `EOF` is `-1` and `1` is a
valid exit value to indicate failure (replace them with `EOF` resp.
`EXIT_FAILURE` if the assumptions are false). Otherwise ANSI/ISO C.
No special build options required.
### Special notes
Count the number of non-whitespace characters in the source
file to find out what dark force drove me to write this ;-).
### Spoiler
First of all, if you run a C beautifier on the program (thereby of course losing
the nice code shape I worked so hard on ;-) ) the code will become a bit more
readable.
The variable names are not very descriptive. They have the
following meanings:
```
a = argc
A = argv
b = array of unsigned long variables
b[0] = bit-width of the CRC (argv[2])
b[1] = CRC polynomial (argv[3])
b[2] = nonzero if CRC is reflected (argv[4])
b[3] = initial value of CRC (argv[5])
b[4] = value final CRC is XORed with (argv[6])
b[5] = CRC value
b[6] = byte from file
b[7] = counter
B = FILE * through which the file argv[1] is opened
C = typedef for unsigned long
```
The first for loop simply reads the command-line arguments
in the `b[]` array. The third parameter to `strtoul()` causes
all arguments to be in base-16 (hex) except the first one,
which will be in base-10 (decimal).
The rest of the program "simply" calculates the CRC in `b[5]`
and then prints it to stdout. The bit reflection loops may
appear a bit tricky at first, but if you have a good look
at them they should become obvious also.
### Acknowledgments:
Ross N. Williams, whose CRC guide was very useful to me
for writing this. You can find it in [crc.txt](crc.txt).
## Copyright and CC BY-SA 4.0 License:
File diff suppressed because it is too large. Load diff
+1 -1
View File
@@ -183,7 +183,7 @@ Thomas P John,Thomas_P_John,http://tomx.tripod.com/,null,thomaspjohn@hotmail.com
Thomas Stewart,Thomas_Stewart,null,null,null,US,null);
Thor Eldby,Thor_Eldby,null,null,null,null,null);
Timo Poikola,Timo_Poikola,https://ig.fi/other/ioccc,null,timo@ig.fi,null,@timpoiko);
Tom Torfs,Tom Torfs,http://members.xoom.com/tomtorfs,null,null,null,null);
Tom Torfs,Tom_Torfs,https://web.archive.org/web/20010520021948/http://members.nbci.com/tomtorfs/,null,null,null);
Tony Finch,Tony_Finch,http://dotat.at/,null,dot@dotat.at,null,null);
Tsukasa Hamano,Tsukasa_Hamano,null,null,hamano@cuspy.org,null,null);
Uri Goren,Uri_Goren,null,goren.uri@gmail.com,null,null);
Can't render this file because it contains an unexpected character in line 23 and column 6.
+1 -1
View File
@@ -1174,7 +1174,7 @@ Contest </I></FONT></CENTER><BR>
<LI TYPE=square>Best non-chess game (<A HREF="years.html#2011_toledo">2011 toledo</A>)
</UL><BR>
<LI TYPE=none><A NAME="Tom Torfs"></A><B>Tom Torfs</B> -- <A HREF="http://members.xoom.com/tomtorfs">http://members.xoom.com/tomtorfs</a>
<LI TYPE=none><A NAME="Tom Torfs"></A><B>Tom Torfs</B> -- <A HREF="https://web.archive.org/web/20010520021948/http://members.nbci.com/tomtorfs/">https://web.archive.org/web/20010520021948/http://members.nbci.com/tomtorfs/</a>
<UL>
<LI TYPE=square>Best Self-Documenting (<A HREF="years.html#1998_tomtorfs">1998 tomtorfs</A>)
</UL><BR>