Files
ioccc/1994/shapiro/shapiro.html
T
Landon Curt Noll ffb738af07 create new status.json model
Changed the model of `status.json` model.

Updated `status.json` IOCCC_status_version from  "0.2 2023-05-22"
to "1.0 2024-03-09".

Updated FAQ 2.6, improving how IOCCC entries announced.

Moved `bin/ioccc-status.sh` to `tmp/ioccc-status.sh`
now that we have a new status.json model for
which this tool no longer fits (sorry tm Canada 🇨🇦).

Added `status.md` markdown to explain the `status.json` model.

Added `status.html` to both display the contents of `status.json`
and render the contents of `status.md` as HTML.

Added `bin/status2html.sh` to convert `status.json`
into HTML for the `status.html` file.

Added `bin/gen-status.sh` to form `status.json`
and `status.html` files.

Added `make gen_status` to top level Makefile.

Performed `make www` to complete all of the above.
2024-03-10 10:05:08 -07:00

265 lines
11 KiB
HTML

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- START: two lines up starts content from: inc/top.default.html -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- END: this line ends content from: inc/top.default.html -->
<!-- -->
<!-- This web page was formed via the tool: bin/gen-other-html.sh -->
<!-- -->
<!-- The content of main section of this web page came from: 1994/shapiro/shapiro.md -->
<!-- -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- !!! Do not modify this web page, instead modify the file: 1994/shapiro/shapiro.md -->
<!-- !!! Do not modify this web page, instead modify the file: 1994/shapiro/shapiro.md -->
<!-- !!! Do not modify this web page, instead modify the file: 1994/shapiro/shapiro.md -->
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
<!-- -->
<!-- Markdown content was converted into HTML via the tool: bin/md2html.sh -->
<!-- -->
<!-- START: this line starts content from: inc/head.default.html -->
<head>
<link rel="stylesheet" href="../../ioccc.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<title>The International Obfuscated C Code Contest</title>
<meta name="description" content="shapiro.md for 1994/shapiro">
<meta name="keywords" content="IOCCC, 1994/shapiro, shapiro.md">
</head>
<!-- END: this line ends content from: inc/head.default.html -->
<!-- START: this line starts content from: inc/body.default.html -->
<body>
<!-- END: this line ends content from: inc/body.default.html -->
<!-- START: this line starts content from: inc/header.default.html -->
<div class="header">
<img src="../../png/ioccc.png" alt="IOCCC image by Matt Zucker" width=300 height=110>
<h1>The International Obfuscated C Code Contest</h1>
<h2>shapiro.md for 1994/shapiro</h2>
</div>
<!-- END: this line ends content from: inc/header.default.html -->
<!-- START: this line starts content from: inc/topnav.up2index.html -->
<div class="topnav">
<a class="Left" href="index.html">&uarr; jump to index.html &uarr;</a>
</div>
<!-- END: this line ends content from: inc/topnav.up2index.html -->
<!-- START: this line starts content from: inc/begin-row.default.html -->
<div class="row">
<!-- END: this line ends content from: inc/begin-row.default.html -->
<!-- START: this line starts content from: inc/begin-leftcolumn.default.html -->
<div class="leftcolumn">
<!-- END: this line ends content from: inc/begin-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/sidenav.default.html -->
<div class="sidenav">
<a href="#content">Jump to contents</a>
</div>
<hr>
<div class="sidenav">
<a href="../../index.html">IOCCC Home</a>
<a href="../../years.html">Winning Entries</a>
<a href="../../authors.html">People who have won</a>
<a href="../../location.html">Location of authors</a>
</div>
<hr>
<div class="sidenav">
<a href="../../news.html">IOCCC News</a>
<a href="../../status.html">Contest status</a>
<a href="../../faq.html#submit">How to enter the IOCCC</a>
<a href="../../faq.html">FAQ</a>
</div>
<hr>
<div class="sidenav">
<a href="../../bugs.html">Bugs &amp; (mis)features</a>
<a href="../../faq.html#fix_an_entry">Fixing IOCCC entries</a>
<a href="../../faq.html#fix_web_site">Fixing the web site</a>
<a href="../../faq.html#fix_author">Fixing author info</a>
<a href="../../thanks-for-help.html">Thanks for the help</a>
</div>
<hr>
<div class="sidenav">
<a href="../../judges.html">The IOCCC Judges</a>
<a href="../../contact.html">Contacting the IOCCC</a>
</div>
<hr>
<div class="sidenav">
<a href="#top">Jump to top</a>
</div>
<!-- END: this line ends content from: inc/sidenav.default.html -->
<!-- START: this line starts content from: inc/end-leftcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-leftcolumn.default.html -->
<!-- START: this line starts content from: inc/begin-rightcolumn.default.html -->
<div class="rightcolumn">
<!-- END: this line ends content from: inc/begin-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/before-content.default.html -->
<a name="content"></a>
<!-- END: this line ends content from: inc/before-content.default.html -->
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<h1 id="hints">HINTS</h1>
<p>For the first program (<a href="shapiro.c">shapiro.c</a>):</p>
<p>This is a very simple program:</p>
<pre><code> 1. #include &lt;stdio.h&gt;
2. main()
3. {
4. int K,L,M=0;
5. FILE *J;
6. J=fopen(__FILE__,&quot;r&quot;);
7. for(;
8. (L=getc(J))&gt;=0;
9. L&gt;=&#39;J&#39;&amp;&amp;L&lt;=&#39;J&#39;+15 &amp;&amp;
10. ((M=!M)?K=L:putchar(K-&#39;J&#39;|(L-&#39;J&#39;&lt;&lt;4)))
11. );
12. exit(0);}</code></pre>
<p>Lines 1-5 are basic stuff. Line 6 opens the source code for input.
Line 7 is the loop. Line 8 reads in each character in the file (placed
in <code>L</code>) while not &gt;= 0. Line 9 is an <code>if</code>
expression which filters out all characters not between <code>J</code>
and <code>J + 15</code>. Line 10 uses <code>M</code> to execute two
different paths; the first just stores the character in <code>K</code>
and the second path combines the last two characters read in as high and
low nibbles of a byte and outputs them. In effect this is a very poor
ASCII to binary decoder. The last line is necessary so that make will
not stop when it executes this program.</p>
<p>The second program is encoded into this format and then included
(mostly) as a comment.</p>
<p>Notice that it is impossible to write this program while leaving 16
contiguous ASCII characters free for the encoding. Because of this the
second program is mostly included as a comment. However, some of the
characters of the encoded program are also source code for the
decoder.</p>
<h3 id="for-the-second-program-with-time.h">For the second program (with
time.h):</h3>
<pre><code> 1 #include &lt;stdio.h&gt;
2 #include &lt;time.h&gt;
3 #define o(j,k,m,n,l) {fprintf(j,a[k],m,n,a[l]);fflush(j);}
4 char *a[]={&quot;%c+------------+\n&quot;,&quot;%c+%3d %-8s+\n&quot;,&quot;seconds&quot;,&quot;minutes&quot;,
5 &quot;hours&quot;,&quot;%s\n&quot;,&quot;\0337\033[%d;65;H%s\0338&quot;};
6 int b[]={0,0,17,14,11,0};
7 main(v,c)
8 int v;
9 char ** c;
10 {
11 char d[40],*e,f=6;
12 time_t g;
13 FILE *h,*i;
14 while (--f &amp;&amp; !pipe(d) &amp;&amp; !fork());
15 h=fdopen(6-f&lt;&lt;1,&quot;a&quot;);
16 i=fdopen((6-f&lt;&lt;1)+1,&quot;r&quot;);
17 for(;;){
18 if(f){
19 fgets(d,40,i);
20 d[strlen(d)-1]=&#39;\0&#39;;
21 if(*d==&#39;0&#39;+f){ sprintf(*c,&quot;%s\n&quot;,d+1); o(stdout,6,6-f,d+1,0) }
22 if(*d&gt;&#39;0&#39;+f) o(h,5,d,0,0)
23 }else{
24 time(&amp;g);
25 e=asctime(localtime(&amp;g));
26 for(v=1;v&lt;6;v++) o(h,v!=1&amp;&amp;v!=6-1,v+&#39;0&#39;,atoi(e+b[v]),v)
27 sleep(1);
28 }}}
</code></pre>
<p>Lines 1 and 2 have to be there. Think of <code>o</code> in line 3 as
send message with <code>j</code>,<code>k</code> and <code>m</code> as
where, format and what. Lines 4 and 5 are all the text strings. Line 6
is the offsets into the time string for the hours, minutes and seconds.
Lines 7-13 are basic stuff. Line 14 is the crux of the biscuit. 14 forks
off <code>f</code> (6) processes each of which is connected to the ones
above and below it with a Unix pipe. It was too difficult to recover the
actual FD numbers for the pipe ends in line 14 so I regenerate them and
<code>fdopen()</code> them (for use with the standard C library
functions) on lines 15 and 16. Now we have six almost identical
processes each of which has two files open, <code>h</code> and
<code>i</code> (up and down). The only difference in each process is the
value of <code>f</code> (<code>0 &lt;= f &lt; 6</code>). The five
processes where <code>f !=0</code> are the slave processes and
<code>f == 0</code> is the master. Line 17 says we are going to do this
forever. Lines 18 and 23 differentiate between the master and the
slaves.</p>
<p>Lines 19 to 22 are the slave code. Here we read in a line of text
from <code>i</code> (down, line 19) and remove the newline char (line
20). On line 21 if this message is for us (if the first character is our
number, <code>f</code>, in ASCII) we do two things:</p>
<ol type="1">
<li>We copy the text of the message to <code>*c</code> which is really
<code>argv[0]</code>. If you are on the correct flavor of Unix this will
change the output of the <code>ps(1)</code> command to the string we
just put there.</li>
<li>We send the message (not including the number) to
<code>stdout</code> with format number 6
(<code>"\0337\033[%d;65;H%s\0338"</code>) If you can read VTxxx (and I
read books printed as ANSI/VTxxx codes for fun :-) ) you know this is
the sequence for:</li>
</ol>
<pre><code>remember where we are,
go somewhere else,
print the message,
and return to where we started.</code></pre>
<p>Line 22 says if this message is not for us (the number is bigger than
ours) send it to <code>h</code> (up).</p>
<p>Lines 24 to 27 are the master code. Here we get the time and convert
it to an ASCII format (lines 24 and 25). Then on line 26 we build and
send each of the messages for the slaves. The message uses a different
control string for the different slaves. For the first and last slave
the message text is just <code>"%c+------------+\n"</code> (slave
number, text, newline.) For the other slaves it is
<code>"%c+%3d %-8s+\n"</code> (slave number, number, units, newline).
The slave number is <code>v+'0'</code>. The number (if used) is
<code>atoi(e+b[v])</code> and the units are just the string in the slave
number position.</p>
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
<!-- START: this line starts content from: inc/after-content.default.html -->
<!-- END: this line ends content from: inc/after-content.default.html -->
<!-- START: this line starts content from: inc/end-rightcolumn.default.html -->
</div>
<!-- END: this line ends content from: inc/end-rightcolumn.default.html -->
<!-- START: this line starts content from: inc/end-row.default.html -->
</div>
<!-- END: this line ends content from: inc/end-row.default.html -->
<!-- START: this line starts content from: inc/footer.default.html -->
<div class="footer">
<hr>
<h2>Coda</h2>
<p><a href="https://validator.w3.org/nu/?doc=#">Nu HTML check this web page</a></p>
<p><a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a></p>
</div>
<!-- END: this line ends content from: inc/footer.default.html -->
<!-- START: this line starts content from: inc/bottom.default.html -->
</body>
</html>
<!-- END: this line ends content from: inc/bottom.default.html -->