Format fix 2004/omoikane/README.md
This commit is contained in:
1 parent
1e7f12181d
commit
0f22ba90f7
1 file changed
+47
-42
+47
-42
@@ -1,11 +1,8 @@
|
|||||||
# Best Utility
|
# Best Utility
|
||||||
|
|
||||||
Don Yang
|
Don Yang
|
||||||
259 E. Bellbrook St.
|
US
|
||||||
Covina, CA 91722
|
<http://uguu.org/>
|
||||||
US
|
|
||||||
|
|
||||||
http://uguu.org/
|
|
||||||
|
|
||||||
## To build:
|
## To build:
|
||||||
|
|
||||||
@@ -34,18 +31,18 @@ is modified to have the desired checksum! This does, we suppose,
|
|||||||
solve the problem that inserting a checksum would change the file's
|
solve the problem that inserting a checksum would change the file's
|
||||||
checksum; if you have to change it, you might as well change it!
|
checksum; if you have to change it, you might as well change it!
|
||||||
|
|
||||||
This program was submitted under the name "Rinia", so the Author's
|
This program was submitted under the name `Rinia`, so the Author's
|
||||||
Comments refer to it as such.
|
Comments refer to it as such.
|
||||||
|
|
||||||
## Author's remarks:
|
## Author's remarks:
|
||||||
|
|
||||||
Rinia (1/14/04)
|
**Rinia (1/14/04)**
|
||||||
|
|
||||||
Rinia is a tool for embedding CRCs in text files. No need to assign
|
`Rinia` is a tool for embedding CRCs in text files. No need to assign
|
||||||
strange file names or package .SFVs with your files! Rinia will
|
strange file names or package .SFVs with your files! Rinia will
|
||||||
insert a human-readable checksum string in the text itself! ^_^
|
insert a human-readable checksum string in the text itself! `^_^`
|
||||||
|
|
||||||
0. Usage `
|
### Usage `
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
rinia <infile> <layout> <outfile>
|
rinia <infile> <layout> <outfile>
|
||||||
@@ -54,20 +51,20 @@ rinia <infile> <layout> <outfile>
|
|||||||
All three arguments may reference the same file. All files is
|
All three arguments may reference the same file. All files is
|
||||||
assumed to be of ASCII character set.
|
assumed to be of ASCII character set.
|
||||||
|
|
||||||
1. Input %
|
### Input %
|
||||||
|
|
||||||
Any file larger than 8 bytes is valid. Upper limit on file size is
|
Any file larger than 8 bytes is valid. Upper limit on file size is
|
||||||
limited by memory.
|
limited by memory.
|
||||||
|
|
||||||
If input file can't be loaded for any reason, Rinia will say "bad
|
If input file can't be loaded for any reason, `Rinia` will say "bad
|
||||||
input" and exit immediately.
|
input" and exit immediately.
|
||||||
|
|
||||||
2. Layout _
|
### Layout _
|
||||||
|
|
||||||
The layout file contains a map of where Rinia can patch. The
|
The layout file contains a map of where `Rinia` can patch. The
|
||||||
content consists of marker characters (where Rinia is allowed to
|
content consists of marker characters (where `Rinia` is allowed to
|
||||||
change in the original text) and other characters (where the
|
change in the original text) and other characters (where the
|
||||||
original text will stay as is). Rinia will select the marker
|
original text will stay as is). `Rinia` will select the marker
|
||||||
character using these heuristics:
|
character using these heuristics:
|
||||||
|
|
||||||
1. Ignore all space/control/extended characters.
|
1. Ignore all space/control/extended characters.
|
||||||
@@ -76,95 +73,103 @@ character using these heuristics:
|
|||||||
frequency.
|
frequency.
|
||||||
|
|
||||||
One way to create the layout file is to make a copy of the original
|
One way to create the layout file is to make a copy of the original
|
||||||
file, replace where you want Rinia to match with a rare character,
|
file, replace where you want `Rinia` to match with a rare character,
|
||||||
then replace the remaining ones with space. Often it's possible to
|
then replace the remaining ones with space. Often it's possible to
|
||||||
write the original file in such a way that it can be used as a
|
write the original file in such a way that it can be used as a
|
||||||
layout.
|
layout.
|
||||||
|
|
||||||
Example file/layout:
|
Example file/layout:
|
||||||
|
|
||||||
|
```
|
||||||
file: layout:
|
file: layout:
|
||||||
crc = ######## ... . XXXXXXXX
|
crc = ######## ... . XXXXXXXX
|
||||||
patch = ###### ..... . XXXXXX
|
patch = ###### ..... . XXXXXX
|
||||||
other text here ..... .... ....
|
other text here ..... .... ....
|
||||||
|
```
|
||||||
|
|
||||||
And Rinia may generate a file similar to this:
|
And `Rinia` may generate a file similar to this:
|
||||||
|
|
||||||
|
```
|
||||||
crc = 1bad73cf
|
crc = 1bad73cf
|
||||||
patch = #FR-QQ
|
patch = #FR-QQ
|
||||||
other text here
|
other text here
|
||||||
|
```
|
||||||
|
|
||||||
Note that the original file by itself is a valid layout file, since
|
Note that the original file by itself is a valid layout file, since
|
||||||
Rinia will recognize that only # marks enough space to hold the
|
`Rinia` will recognize that only `#` marks enough space to hold the
|
||||||
checksum, and has the lowest frequency.
|
checksum, and has the lowest frequency.
|
||||||
|
|
||||||
If layout file can't be used for any reason, Rinia will say "bad
|
If layout file can't be used for any reason, `Rinia` will say "bad
|
||||||
layout" and exit immediately.
|
layout" and exit immediately.
|
||||||
|
|
||||||
3. Output m
|
### Output m
|
||||||
|
|
||||||
If Rinia finds a usuable checksum, she will say "OK." and write to
|
If `Rinia` finds a usable checksum, she will say "OK." and write to
|
||||||
the specified output file. Otherwise the exit message is "fail"
|
the specified output file. Otherwise the exit message is "fail"
|
||||||
and nothing is written.
|
and nothing is written.
|
||||||
|
|
||||||
Chances of success and how long it takes to run to completion is
|
Chances of success and how long it takes to run to completion is
|
||||||
completely dominated by the layout file design. In general, Rinia
|
completely dominated by the layout file design. In general, `Rinia`
|
||||||
runs faster if the checksum is placed before the other marker
|
runs faster if the checksum is placed before the other marker
|
||||||
characters rather than after, e.g.:
|
characters rather than after, e.g.:
|
||||||
|
|
||||||
|
```
|
||||||
a: X X XXX b: XXXXXXXX c: XXXXXXXX
|
a: X X XXX b: XXXXXXXX c: XXXXXXXX
|
||||||
XXXXXXXX X X XXX XXXXX
|
XXXXXXXX X X XXX XXXXX
|
||||||
|
|
||||||
"a" usually takes the longest time, while "c" usually is the
|
```
|
||||||
|
|
||||||
|
`a` usually takes the longest time, while `c` usually is the
|
||||||
fastest.
|
fastest.
|
||||||
|
|
||||||
That said, each run is randomized with respect to system time, so
|
That said, each run is randomized with respect to system time, so
|
||||||
it's not always certain whether Rinia will succeed in a short time
|
it's not always certain whether `Rinia` will succeed in a short time
|
||||||
or not. In general, 5 marker characters is sufficient, and takes
|
or not. In general, 5 marker characters are sufficient, and takes
|
||||||
a few minutes.
|
a few minutes.
|
||||||
|
|
||||||
For reference, rinia.c was produced on a 1.7GHz machine (the
|
For reference, `rinia.c` was produced on a 1.7GHz machine (the
|
||||||
checksum is at line 17). Out of 25 runs, the shortest was 2
|
checksum is at line 17). Out of 25 runs, the shortest was 2
|
||||||
seconds while the longest took 5 minutes. Average was about a
|
seconds while the longest took 5 minutes. Average was about a
|
||||||
minute. Checksum for this file (b7a81524) took about 4 minutes.
|
minute. Checksum for this file (`b7a81524`) took about 4 minutes.
|
||||||
|
|
||||||
4. Algorithm 3
|
### Algorithm
|
||||||
|
|
||||||
Inserting a checksum in the file you are computing the checksum of
|
Inserting a checksum in the file you are computing the checksum of
|
||||||
isn't quite trivial, since changing the file content would change
|
isn't quite trivial, since changing the file content would change
|
||||||
the final checksum value.
|
the final checksum value.
|
||||||
|
|
||||||
To insert the checksum, Rinia first assumes a random final
|
To insert the checksum, `Rinia` first assumes a random final
|
||||||
checksum, insert that string, then modify other parts to compensate
|
checksum, insert that string, then modify other parts to compensate
|
||||||
for the change in content.
|
for the change in content.
|
||||||
|
|
||||||
The compensation bytes are very easy to compute for binary files
|
The compensation bytes are very easy to compute for binary files
|
||||||
with enough consecutive scratch areas, but for text files with
|
with enough consecutive scratch areas, but for text files with
|
||||||
non-consecutive areas and limited degrees of freedom, Rinia has to
|
non-consecutive areas and limited degrees of freedom, `Rinia` has to
|
||||||
try out all character combinations. This is done in a hierarchical
|
try out all character combinations. This is done in a hierarchical
|
||||||
fashion, computing only smallest partial checksum after each
|
fashion, computing only smallest partial checksum after each
|
||||||
change.
|
change.
|
||||||
|
|
||||||
For computers few years ago, this is probably still too slow to be
|
For computers few years ago, this is probably still too slow to be
|
||||||
acceptible... but at the speed the IOCCC judges run the contest
|
acceptable... but at the speed the IOCCC judges run the contest
|
||||||
these days, I am sure you have enough patience for it ^_^;
|
these days, I am sure you have enough patience for it `_^`
|
||||||
|
|
||||||
5. Source code =
|
### Source code
|
||||||
|
|
||||||
rinia.c should compile anywhere (but with a few warnings). I don't
|
`rinia.c` should compile anywhere (but with a few warnings). I don't
|
||||||
have a big-endian machine to test but Rinia should work there as
|
have a big-endian machine to test but `Rinia` should work there as
|
||||||
well. ASCII character set required though.
|
well. ASCII character set required though.
|
||||||
|
|
||||||
Code is formatted to the shape of "Rinia" from the anime/game
|
Code is formatted to the shape of "`Rinia`" from the anime/game
|
||||||
"Moekko Company". Of course at 90x50 it's hard to recognize anything
|
"Moekko Company". Of course at 90x50 it's hard to recognize anything
|
||||||
^_^;
|
`^_^`
|
||||||
|
|
||||||
Rinia is the slow but hardworking android. On some jobs she does
|
`Rinia` is the slow but hardworking android. On some jobs she does
|
||||||
very well, on others she would spend lots of time and effort but
|
very well, on others she would spend lots of time and effort but
|
||||||
still fail...
|
still fail...
|
||||||
|
|
||||||
(text above is also included as an info file, so that the checksum
|
NOTE: the text above is also included as an info file but in original format, so
|
||||||
would match)
|
that the checksum would match. The above was formatted in markdown for GitHub
|
||||||
|
and the IOCCC website.
|
||||||
|
|
||||||
## Copyright and CC BY-SA 4.0 License:
|
## Copyright and CC BY-SA 4.0 License:
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user