Add unobfuscated code from @SirWumpus
The entries 2004/hibachi and 2005/mynx have unobfuscated code now. 2004/hibachi has a configure script that is used along the lines of the original entry (with some adjustments and fixes) and the hibachi.alt.c had to have ctype.h included too. The directory src/localhost was copied to src-alt/localhost but the rest of src/ was from Anthony. The Makefile had to be updated to build this version. 2005/mynx does have a configure script but it is, just like the original entry, unused and so the unobfuscated (in source-alt/) is also unused. The mynx.alt.c was changed to mynx.alt2.c and the unobfuscated code was made mynx.alt.c. Updated manifest, rebuilt .entry.json and index.html files. After a question is answered and taken care of (in one of 199[1-3]/ant - not sure which one) issue #2513 can possibly be closed as complete (though the manifest updates will have to be looked at more when 2004 and 2005 are reviewed).
No files matched your search
@@ -9,6 +9,14 @@
|
||||
{ "author_handle" : "Anthony_C_Howe" }
|
||||
],
|
||||
"manifest" : [
|
||||
{
|
||||
"file_path" : "hibachi.alt.c",
|
||||
"inventory_order" : 20,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "c",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "author provided unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "hibachi.c",
|
||||
"inventory_order" : 20,
|
||||
@@ -33,6 +41,22 @@
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "original source code"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/configure",
|
||||
"inventory_order" : 100,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "GNU Autoconf script for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/index.html",
|
||||
"inventory_order" : 100,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "html",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "home page of alt HIBACHI web server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src/configure",
|
||||
"inventory_order" : 100,
|
||||
@@ -47,7 +71,63 @@
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "html",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "home page of HIBACHI web server"
|
||||
"entry_text" : "home page of alt HIBACHI web server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/IOCCC-2004/mkentry.c",
|
||||
"inventory_order" : 120,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "c",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "IOCCC tool of 2004 to package entries"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/ioccc.c",
|
||||
"inventory_order" : 120,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "c",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "IOCCC size tool"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/reference/rfc2616.html",
|
||||
"inventory_order" : 125,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "html",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "RFC 2616 - Hypertext Transfer Protocol - alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/perl/index.html",
|
||||
"inventory_order" : 125,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "html",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "perl test page of alt HIBACHI server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/php/index.php",
|
||||
"inventory_order" : 125,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "php",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "PHP making an ISO 8601:2000 calendar for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/ruby/index.rb",
|
||||
"inventory_order" : 125,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "ruby",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "ruby home page for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/shell/test0.sh",
|
||||
"inventory_order" : 125,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "POSIX shell CGI home page for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src/localhost/CHANGES-OBFUSCATED.TXT",
|
||||
@@ -97,6 +177,30 @@
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "POSIX shell CGI home page"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/transform.sed",
|
||||
"inventory_order" : 130,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "sed",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "sed(1) script for building unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/hibachi-start.sh",
|
||||
"inventory_order" : 150,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "start the alt web server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/perl/yahoo-ticker.pl",
|
||||
"inventory_order" : 150,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "perl",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "stock price fetch example in Perl for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src/hibachi-start.sh",
|
||||
"inventory_order" : 150,
|
||||
@@ -113,6 +217,30 @@
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "stock price fetch example in Perl"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/configure.in",
|
||||
"inventory_order" : 200,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "GNU Autoconf script for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/hibachi-start.sh.in",
|
||||
"inventory_order" : 200,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "hibachi-start.sh declarations for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/CHANGELOG.TXT",
|
||||
"inventory_order" : 200,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "text",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "obfuscation change log for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src/configure.in",
|
||||
"inventory_order" : 200,
|
||||
@@ -177,6 +305,206 @@
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "markdown source for this web page"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/Img/cygwin-icon.gif",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "image",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "image for home page for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/Img/freebsd.gif",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "image",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "image for home page for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/Img/hibachi-256-oc-nc-300x150.gif",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "image",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "image for home page for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/Img/hot-coal-edge-110-indent.png",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "image",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "image for home page for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/Img/logosml.256.png",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "image",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "image for home page for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/Img/php-small-trans-light.gif",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "image",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "image for home page for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/Img/powered-by-hibachi-150x75.png",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "image",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "image for home page for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/Img/rectangle_power_perl.gif",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "image",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "image for home page for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/Img/sun_logo.gif",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "image",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "image for home page for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/Img/win.gif",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "image",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "image for home page for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/style.css",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "css",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "CSS for home page for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/perl/yahoo-ticker.pl.in",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "perl",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "stock price fetch declarations for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/php/Date.php",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "php",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "PHP example page support file for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/php/index_php.in",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "php",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "PHP example page support file for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/php/info.php",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "php",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "PHP example support file for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/php/info.php.in",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "php",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "PHP example page support file for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/php/sendform.html",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "html",
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "php example page support file for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/php/sendform.php",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "php",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "PHP example page support file for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/php/sendform.php.in",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "php",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "PHP example page support file for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/ruby/LUHN.rb",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "ruby",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "ruby example page support file for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/ruby/index_rb.in",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "ruby",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "ruby example page support file for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/shell/dump.sh",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "POSIX shell script support file for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/shell/test1.sh",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "POSIX shell script support file for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/localhost/test/shell/test2.sh",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "POSIX shell script support file for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src-alt/makefile.in",
|
||||
"inventory_order" : 4000000000,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "man",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "makefile template for alt server"
|
||||
},
|
||||
{
|
||||
"file_path" : "src/localhost/Img/cygwin-icon.gif",
|
||||
"inventory_order" : 4000000000,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
# sort with: ../../bin/sgi.sh
|
||||
*.dSYM
|
||||
build
|
||||
build-alt
|
||||
hibachi.orig
|
||||
indent
|
||||
indent.c
|
||||
@@ -12,3 +13,9 @@ src/config.status
|
||||
src/hibachi
|
||||
src/hibachi.c
|
||||
src/makefile
|
||||
src-alt/config.log
|
||||
src-alt/config.status
|
||||
src-alt/hibachi
|
||||
src-alt/hibachi.alt
|
||||
src-alt/hibachi.alt.c
|
||||
src-alt/makefile
|
||||
@@ -116,8 +116,8 @@ OBJ= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= build/${PROG}
|
||||
#
|
||||
ALT_OBJ=
|
||||
ALT_TARGET=
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= build-alt/${PROG}.alt
|
||||
|
||||
|
||||
#################
|
||||
@@ -150,6 +150,20 @@ src/hibachi.c: hibachi.c
|
||||
alt: data ${ALT_TARGET}
|
||||
@${TRUE}
|
||||
|
||||
build-alt/${PROG}.alt: src-alt/hibachi.alt.c src-alt
|
||||
${RM} -rf build-alt
|
||||
${CP} -v -r src-alt build-alt
|
||||
@echo "This next step may take some time to complete:"
|
||||
cd build-alt; CFLAGS="${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT}" \
|
||||
LDFLAGS="${LDFLAGS}" \
|
||||
CC="${CC}" \
|
||||
${SHELL} ./configure
|
||||
cd build-alt; ${MAKE}
|
||||
|
||||
src-alt/hibachi.alt.c: hibachi.alt.c
|
||||
${CP} -f -v $? $@
|
||||
|
||||
|
||||
# data files
|
||||
#
|
||||
data: ${DATA}
|
||||
@@ -216,9 +230,9 @@ clean:
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${TARGET} ${ALT_TARGET}
|
||||
${RM} -f src/hibachi.c src/config.log
|
||||
${RM} -f src/hibachi.c src/config.log src-alt/hibachi.c src-alt/hibachi.c
|
||||
${RM} -rf *.dSYM
|
||||
${RM} -rf build
|
||||
${RM} -rf build build-alt
|
||||
@-if [ -e sandwich ]; then \
|
||||
${RM} -f sandwich; \
|
||||
echo 'ate sandwich'; \
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
make
|
||||
```
|
||||
|
||||
There is an alternate version that is unobfuscated, provided by the author in
|
||||
2024\. See [Alternate code](#alternate-code) below.
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
@@ -18,6 +21,32 @@ NOTE: you must be in the `build` directory when running `hibachi-start.sh` for
|
||||
this to work right.
|
||||
|
||||
|
||||
## Alternate code:
|
||||
|
||||
This version, contained in `src-alt/`, is an unobfuscated version provided by
|
||||
the author in 2024.
|
||||
|
||||
|
||||
### Alternate build:
|
||||
|
||||
``` <!---sh-->
|
||||
make alt
|
||||
```
|
||||
|
||||
This will run the `configure` script and then compile and link in (in
|
||||
`build-alt/`) the binary `hibachi`.
|
||||
|
||||
|
||||
### Alternate use:
|
||||
|
||||
``` <!---sh-->
|
||||
cd build-alt ; ./hibachi-start.sh &
|
||||
```
|
||||
|
||||
Then with your browser do the same as for the original source.
|
||||
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
This entry violates the [guidelines](../../2004/guidelines.txt) in so many ways! We
|
||||
|
||||
@@ -0,0 +1,458 @@
|
||||
/*
|
||||
* hibachi.c
|
||||
*
|
||||
* Limited implementation of RFC 2616 & CGI/1.1 specification.
|
||||
*
|
||||
* Public Domain 2002, 2004 by Anthony Howe.
|
||||
*
|
||||
* From http://eat.epicurious.com/dictionary/food/index.ssf?DEF_ID=2150
|
||||
*
|
||||
* [hih-BAH-chee]
|
||||
*
|
||||
* Japanese for "fire bowl", a hibachi is just that - a small
|
||||
* (generally cast-iron) container made for holding fuel
|
||||
* (usually charcoal). A grill that sits on top of the bowl
|
||||
* is used to cook various foods. Hibachis come in square,
|
||||
* oblong and round models. Because of their compact size,
|
||||
* they're completely portable.
|
||||
*
|
||||
* Usage: SERVER_PORT=<port> DOCUMENT_ROOT=<path> hibachi
|
||||
*/
|
||||
|
||||
#define NDEBUG
|
||||
|
||||
/***********************************************************************
|
||||
*** No configuration below this point.
|
||||
***********************************************************************/
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
/* #include <signal.h> */
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define Z 8192
|
||||
|
||||
FILE *LOG;
|
||||
|
||||
char request[Z], query[Z], path[Z], droot[Z], *headers, *notfound = "404 Not Found", *error = "500 Error";
|
||||
|
||||
void
|
||||
status(int client, char *u, long j)
|
||||
{
|
||||
j = snprintf(
|
||||
query, Z,
|
||||
/* "HTTP/1.0 %s\r\nConnection: close\r\nContent-Length: %ld\r\n\r\n%s", */
|
||||
"HTTP/1.0 %s\r\nContent-Length: %ld\r\n\r\n%s",
|
||||
u, j != 0 ? j : strcspn(u, ""), j != 0 ? "" : u
|
||||
);
|
||||
(void) fprintf(LOG, "[%d] status length=%ld\n%s\n", getpid(), j, query);
|
||||
send(client, query, j, 0);
|
||||
}
|
||||
|
||||
void
|
||||
findAndSet(char *i, char *j)
|
||||
{
|
||||
char *u;
|
||||
|
||||
/* `i' is both a header name and an environment variable. Add +5
|
||||
* to `i' in order to skip over `HTTP_' metavariable prefix. This
|
||||
* doesn't interfer with the search for other headers that don't
|
||||
* have an `HTTP_' prefix like `CONTENT_TYPE' and `CONTENT_LENGTH',
|
||||
* because there is sufficiently enough of the header string left
|
||||
* that is unique for the purpose of searching.
|
||||
*/
|
||||
if ((u = strstr(headers, i + 5)) != (char *) 0)
|
||||
sscanf(u + strcspn(u, ":") + 1, j, getenv(i));
|
||||
(void) fprintf(LOG, "[%d] %s=%s\n", getpid(), i, getenv(i));
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int fd, client, i;
|
||||
struct stat finfo;
|
||||
struct sockaddr_in addr;
|
||||
char *value, *uri;
|
||||
|
||||
if ((LOG = fopen("hibachi.log", "a")) == (FILE *) 0)
|
||||
return 1;
|
||||
|
||||
if ((value = getenv("SERVER_PORT")) == (char *) 0) {
|
||||
(void) fprintf(LOG, "[%d] SERVER_PORT not defined in environment\n", getpid());
|
||||
return 4;
|
||||
}
|
||||
|
||||
i = (int) strtol(value, NULL, 10);
|
||||
addr.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
addr.sin_port = htons((unsigned short) i);
|
||||
addr.sin_family = AF_INET;
|
||||
|
||||
if ((fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0) {
|
||||
(void) fprintf(LOG, "[%d] failed to create socket\n", getpid());
|
||||
return 5;
|
||||
}
|
||||
|
||||
if (0 > bind(fd, /*(const struct sockaddr *) */ (void *) &addr, sizeof addr)) {
|
||||
(void) fprintf(LOG, "[%d] failed to bind to port\n", getpid());
|
||||
return 6;
|
||||
}
|
||||
|
||||
if (0 > listen(fd, 10)) {
|
||||
(void) fprintf(LOG, "[%d] failed to listen on port\n", getpid());
|
||||
return 7;
|
||||
}
|
||||
|
||||
(void) fprintf(LOG, "[%d] listening on port %s\n", getpid(), value);
|
||||
|
||||
/* Use "kill" to terminate the parent server process. */
|
||||
for ( ; ; close(client)) {
|
||||
/* Reap zombie child processes. */
|
||||
for ( ; waitpid(0, NULL, WNOHANG) > 0; )
|
||||
;
|
||||
|
||||
i = sizeof addr;
|
||||
if ((client = accept(fd, /*(const struct sockaddr *) */ (void *) &addr, &i)) < 0)
|
||||
continue;
|
||||
|
||||
#ifdef NDEBUG
|
||||
/* SunOS technique to avoid zombie processes. */
|
||||
/* signal(SIGCHLD, SIG_IGN); */
|
||||
|
||||
if (fork() != 0)
|
||||
/* The parent can close the client connection on
|
||||
* success to avoid leaking file handles and on
|
||||
* error to refuse the client connection.
|
||||
*
|
||||
* Refuse the connection, RFC 2616 section 10.5.4
|
||||
----
|
||||
10.5.4 503 Service Unavailable
|
||||
|
||||
The server is currently unable to handle the request due to a
|
||||
temporary overloading or maintenance of the server. The implication
|
||||
is that this is a temporary condition which will be alleviated after
|
||||
some delay. If known, the length of the delay MAY be indicated in a
|
||||
Retry-After header. If no Retry-After is given, the client SHOULD
|
||||
handle the response as it would for a 500 response.
|
||||
|
||||
Note: The existence of the 503 status code does not imply that a
|
||||
server must use it when becoming overloaded. Some servers may wish
|
||||
to simply refuse the connection.
|
||||
----
|
||||
* Here we interpret "refuse the connection" as
|
||||
* drop it without giving a reason. Amounts to
|
||||
* the same.
|
||||
*/
|
||||
continue;
|
||||
|
||||
/******************************************************
|
||||
*** Child process.
|
||||
******************************************************/
|
||||
|
||||
/* The child doesn't need a copy of the server port. */
|
||||
/* close(fd); */
|
||||
#endif
|
||||
|
||||
/* Read request and headers. Stop if we see two newlines. */
|
||||
for (fd = i = 0; fd < 2 && i < Z; i++) {
|
||||
if (recv(client, request + i, 1, 0) <= 0)
|
||||
/* On error, drop the connection hard. */
|
||||
return 1;
|
||||
|
||||
/* The HTTP protocol states that the header names
|
||||
* are case insensitive. Most browsers send them
|
||||
* exactly as shown in RFC 2616 (capitial letters
|
||||
* for first letter of each word), but Lynx doesn't
|
||||
* For example "Content-Length" is sent by Lynx as
|
||||
* "Content-length". This section of code converts
|
||||
* the header names to one case for matching.
|
||||
*/
|
||||
if (request[i] == '\n')
|
||||
/* Count newlines AND lower case of header. */
|
||||
fd++;
|
||||
if (request[i] == ':')
|
||||
/* Don't touch header value. Doesn't work
|
||||
* for headers spanning multiple lines. Rare.
|
||||
*/
|
||||
fd = 0;
|
||||
if (fd != 0)
|
||||
/* RFC 2616 BNF grammar for header field-name
|
||||
* is defined to use the US-ASCII character set.
|
||||
* However, we can't do "request[i] | 0x20" to
|
||||
* fold uppper to lower case without testing
|
||||
* to see if it is an alpha character.
|
||||
*/
|
||||
request[i] = request[i] == '-' ? '_' : toupper(request[i]);
|
||||
}
|
||||
|
||||
if (Z <= i)
|
||||
/* Request buffer overflow, drop the connection.
|
||||
* The request buffer should be large enough to
|
||||
* hold all the headers and one full size Cookie.
|
||||
* Cookies have a max. length of 4096 bytes.
|
||||
*
|
||||
* We really should return a 413, 500, or 503 error
|
||||
* here. The fact that the buffer is full is like an
|
||||
* "overloaded" server, so we take the shortcut
|
||||
* offered by RFC 2616 section 10.5.4 paragraph 2.
|
||||
*/
|
||||
break;
|
||||
|
||||
request[i] = '\0';
|
||||
(void) fprintf(LOG, "[%d] %s\n", getpid(), request);
|
||||
|
||||
/* Identify the method by testing just one
|
||||
* character position of the method name:
|
||||
*
|
||||
* OPTIONS O
|
||||
* GET G
|
||||
* HEAD H
|
||||
* POST S
|
||||
* PUT U
|
||||
* DELETE D
|
||||
* TRACE T
|
||||
* CONNECT C
|
||||
*
|
||||
* Also make sure the request is NOT a
|
||||
* proxy request.
|
||||
*/
|
||||
if (request[0] != 'G' && request[0] != 'H' && request[2] != 'S') {
|
||||
(void) fprintf(LOG, "[%d] 501 Method not implemented\n", getpid());
|
||||
status(client, "501 Unsupported", 0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* Determine document root for the virtual host. */
|
||||
*path = '\0';
|
||||
if ((value = strstr(request, "HOST:")) != (char *) 0)
|
||||
sscanf(value+5, " %255[^:\r\n]", path);
|
||||
|
||||
snprintf(droot, Z, "DOCUMENT_ROOT" "=%s/%s", getenv("DOCUMENT_ROOT"), path);
|
||||
(void) fprintf(LOG, "[%d] %s\n", getpid(), droot);
|
||||
putenv(droot);
|
||||
/* chdir(droot+14); */
|
||||
|
||||
/* Parse the request "METHOD /uri/pathinfo?query HTTP/1.1" */
|
||||
uri = request + 4 + (request[0] != 'G');
|
||||
|
||||
/* Disallow relative paths. A chroot() would be more
|
||||
* effective, but that requires root privileges and is
|
||||
* against IOCCC contest rules.
|
||||
*
|
||||
* NOTE that URI decoding of the path has NOT been
|
||||
* performed, so paths with sequences like "%2e%2e%2f"
|
||||
* won't be caught, but will fail below on the stat()
|
||||
* and return a 404.
|
||||
*
|
||||
* We do not decode the URI path partly because of contest
|
||||
* space issues, but there really is no good reason to
|
||||
* encode characters that don't need an encoding, like dot
|
||||
* and slash. Sites that use stupid characters in file paths
|
||||
* and names like spaces, special punctuation, and accented
|
||||
* characters deserve the trouble they get from such practices.
|
||||
*/
|
||||
if (*uri != '/' || strstr(uri, "../") != (char *) 0) {
|
||||
(void) fprintf(LOG, "[%d] 403 Relative pathes and proxy requests forbidden [%s]\n", getpid(), uri);
|
||||
/* RFC 2616 section 10.4.4 403 Forbidden:
|
||||
----
|
||||
10.4.4 403 Forbidden
|
||||
|
||||
The server understood the request, but is refusing to fulfill it.
|
||||
Authorization will not help and the request SHOULD NOT be repeated.
|
||||
If the request method was not HEAD and the server wishes to make
|
||||
public why the request has not been fulfilled, it SHOULD describe the
|
||||
reason for the refusal in the entity. If the server does not wish to
|
||||
make this information available to the client, the status code 404
|
||||
(Not Found) can be used instead.
|
||||
----
|
||||
* The last sentence is significant here.
|
||||
*/
|
||||
status(client, notfound, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* End of request URI on space delimiter. */
|
||||
uri[i = strcspn(uri, " ")] = '\0';
|
||||
headers = uri + i + 1;
|
||||
|
||||
/* Find end of URI or query delimiter. */
|
||||
i = strcspn(uri, "?");
|
||||
if (uri[i] != '\0') {
|
||||
snprintf(query, Z, "QUERY_STRING=%s", uri+i+1);
|
||||
(void) fprintf(LOG, "[%d] %s\n", getpid(), query);
|
||||
putenv(query);
|
||||
uri[i] = '\0';
|
||||
}
|
||||
|
||||
/* Prepare SCRIPT_FILENAME. This variable is required by
|
||||
* PHP/CGI in order to find the input file. PHP/CLI does
|
||||
* not require it and is more like nph-CGI behaviour, but
|
||||
* is sufficiently different from typical web usage to
|
||||
* confuse webmasters.
|
||||
*
|
||||
* Use the value after the equals sign to test for file
|
||||
* or directory existance (path+16).
|
||||
*/
|
||||
snprintf(path, Z, "SCRIPT_FILENAME=%s%s", droot+14, uri);
|
||||
(void) fprintf(LOG, "[%d] %s\n", getpid(), path);
|
||||
value = path+16;
|
||||
(void) fprintf(LOG, "[%d] %s\n", getpid(), value);
|
||||
|
||||
if (stat(value, &finfo) < 0) {
|
||||
(void) fprintf(LOG, "[%d] 404 File or directory %s does exist\n", getpid(), value);
|
||||
status(client, notfound, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* When a directory, look for the "index" file. */
|
||||
if (S_ISDIR(finfo.st_mode)) {
|
||||
struct dirent *d;
|
||||
DIR *D = opendir(value);
|
||||
for ( ; (d = readdir(D)) != (struct dirent *) 0; ) {
|
||||
if (0 == strncmp(d->d_name, "index.", 6)) {
|
||||
strncat(value, d->d_name, Z-16);
|
||||
stat(value, &finfo);
|
||||
break;
|
||||
}
|
||||
}
|
||||
closedir(D);
|
||||
|
||||
if (d == (struct dirent *) 0) {
|
||||
/* We don't print directory listings. */
|
||||
(void) fprintf(LOG, "[%d] 404 Directory listing forbidden\n", getpid());
|
||||
/* RFC 2616 section 10.4.4 403 Forbidden, last sentence. */
|
||||
status(client, notfound, 0);
|
||||
break;
|
||||
}
|
||||
(void) fprintf(LOG, "[%d] path=%s\n", getpid(), value);
|
||||
}
|
||||
|
||||
if (request[0] != 'H') {
|
||||
(void) fprintf(LOG, "[%d] mode=%o\n", getpid(), finfo.st_mode);
|
||||
if (finfo.st_mode & 0111) {
|
||||
/* Execute CGI, which is responsible for sending
|
||||
* back the HTTP response line and headers (see
|
||||
* CGI/1.1 specification "nph" prefix).
|
||||
*/
|
||||
|
||||
/* Pass some of the request headers to the CGI.
|
||||
* Overwrite in place the environment variables
|
||||
* preallocated in the environment (see
|
||||
* hibachi-start.sh).
|
||||
*/
|
||||
|
||||
putenv(path);
|
||||
|
||||
/* Need this to identify type of request. */
|
||||
sscanf(request, "%4s", getenv("REQUEST_METHOD"));
|
||||
(void) fprintf(LOG, "[%d] REQUEST_METHOD='%s'\n", getpid(), getenv("REQUEST_METHOD"));
|
||||
|
||||
/* Not sure we need this for most CGIs. */
|
||||
sscanf(inet_ntoa(addr.sin_addr), "%15s", getenv("REMOTE_ADDR"));
|
||||
(void) fprintf(LOG, "[%d] REMOTE_ADDR=%s\n", getpid(), getenv("REMOTE_ADDR"));
|
||||
|
||||
/* These are needed if the CGI is to do anything
|
||||
* useful.
|
||||
*/
|
||||
findAndSet("HTTP_COOKIE", "%*[ \t]%80[^\r\n]");
|
||||
findAndSet("CONTENT_LENGTH", "%20s");
|
||||
findAndSet("CONTENT_TYPE", "%60s");
|
||||
|
||||
/* Redirect standard I/O for the CGI. */
|
||||
dup2(client, 0);
|
||||
dup2(client, 1);
|
||||
|
||||
/* Call system() instead of execl() so that
|
||||
* we come back here after the CGI call to
|
||||
* properly close the connection. We don't
|
||||
* need to escape shell meta characters,
|
||||
* since the stat() above would have failed
|
||||
* to find a file that did contained them.
|
||||
*
|
||||
* Of course anyone stupid enough to use
|
||||
* shell meta characters for an executable
|
||||
* filename should be shot.
|
||||
*/
|
||||
|
||||
/* Note that Cygwin appears to have a bogus
|
||||
* initial \r\n waiting on stdin, which was
|
||||
* never sent by the client. I've seen this
|
||||
* in other programs under Cygwin.
|
||||
*/
|
||||
if (system(value) != 0)
|
||||
status(client, error, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
if ((fd = open(value, O_RDONLY)) < 0) {
|
||||
(void) fprintf(LOG, "[%d] 500 Internal server error\n", getpid());
|
||||
status(client, error, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* RFC 2616 section 7.2.1 paragraph 3 allows the Content-Type
|
||||
* to be optional leaving the client to figure it out.
|
||||
----
|
||||
Any HTTP/1.1 message containing an entity-body SHOULD include a
|
||||
Content-Type header field defining the media type of that body. If
|
||||
and only if the media type is not given by a Content-Type field, the
|
||||
recipient MAY attempt to guess the media type via inspection of its
|
||||
content and/or the name extension(s) of the URI used to identify the
|
||||
resource. If the media type remains unknown, the recipient SHOULD
|
||||
treat it as type "application/octet-stream".
|
||||
----
|
||||
* RFC 2119 defines SHOULD as strongly recommended, but not
|
||||
* absolutely required given sufficient reason. I treat it
|
||||
* more like OPTIONAL.
|
||||
*/
|
||||
|
||||
status(client, "200 OK", finfo.st_size);
|
||||
(void) fprintf(LOG, "[%d] %s\n", getpid(), query);
|
||||
|
||||
if (request[0] != 'H') {
|
||||
/* Send back a static file for GET or POST request.
|
||||
*
|
||||
* There may be input ready for a POST request, but
|
||||
* it doesn't make any sense to read input and waste
|
||||
* bandwidth for a non-CGI.
|
||||
*
|
||||
* Also RFC 2616 section 4.3 paragraph 4 makes reading
|
||||
* a message body optional:
|
||||
----
|
||||
The presence of a message-body in a request is signaled by the
|
||||
inclusion of a Content-Length or Transfer-Encoding header field in
|
||||
the request's message-headers. A message-body MUST NOT be included in
|
||||
a request if the specification of the request method (section 5.1.1)
|
||||
does not allow sending an entity-body in requests. A server SHOULD
|
||||
read and forward a message-body on any request; if the request method
|
||||
does not include defined semantics for an entity-body, then the
|
||||
message-body SHOULD be ignored when handling the request.
|
||||
----
|
||||
* RFC 2119 defines SHOULD as strongly recommended, but not
|
||||
* absolutely required given sufficient reason. I treat it
|
||||
* more like OPTIONAL.
|
||||
*/
|
||||
for ( ; 0 < (i = read(fd, request, Z)); )
|
||||
send(client, request, i, 0);
|
||||
}
|
||||
/* close(fd); */
|
||||
break;
|
||||
}
|
||||
|
||||
/* Clean termination of the TCP connection from our end. */
|
||||
shutdown(client, SHUT_WR);
|
||||
/* close(client); */
|
||||
|
||||
(void) fprintf(LOG, "[%d] end child\n\n", getpid());
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -10,13 +10,13 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <ctype.h>
|
||||
#define Z 8192
|
||||
char r[Z], q[Z], l[Z], w[Z], *o, *m = "404 Not Found", *e = "500 Error";
|
||||
void
|
||||
@@ -43,6 +43,7 @@ main(int c, char **p)
|
||||
struct stat g;
|
||||
struct sockaddr_in a;
|
||||
char *v, *u;
|
||||
R 1;
|
||||
Q (v = V "SERVER_PORT")) == 0) {
|
||||
R 4;
|
||||
}
|
||||
|
||||
@@ -403,12 +403,24 @@ Location: <a href="../../location.html#CA">CA</a> - <em>Canada</em></li>
|
||||
<!-- BEFORE: 1st line of markdown file: 2004/hibachi/README.md -->
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<pre><code> make</code></pre>
|
||||
<p>There is an alternate version that is unobfuscated, provided by the author in
|
||||
2024. See <a href="#alternate-code">Alternate code</a> below.</p>
|
||||
<h2 id="to-use">To use:</h2>
|
||||
<pre><code> cd build; ./hibachi-start.sh &</code></pre>
|
||||
<p>Then use your web browser to visit <code>http://localhost:8008/</code>. When you’re
|
||||
finished make sure to kill <code>hibachi</code>.</p>
|
||||
<p>NOTE: you must be in the <code>build</code> directory when running <code>hibachi-start.sh</code> for
|
||||
this to work right.</p>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>This version, contained in <code>src-alt/</code>, is an unobfuscated version provided by
|
||||
the author in 2024.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<pre><code> make alt</code></pre>
|
||||
<p>This will run the <code>configure</code> script and then compile and link in (in
|
||||
<code>build-alt/</code>) the binary <code>hibachi</code>.</p>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<pre><code> cd build-alt ; ./hibachi-start.sh &</code></pre>
|
||||
<p>Then with your browser do the same as for the original source.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
<p>This entry violates the <a href="../../2004/guidelines.txt">guidelines</a> in so many ways! We
|
||||
are not exactly sure how many organisations will be upset with this entry, but
|
||||
@@ -534,19 +546,35 @@ just try to understand the program via the source.</p>
|
||||
</div>
|
||||
<h2 id="primary-files">Primary files</h2>
|
||||
<ul>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/hibachi.alt.c">hibachi.alt.c</a> - author provided unobfuscated code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/hibachi.c">hibachi.c</a> - entry source code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/hibachi.orig.c">hibachi.orig.c</a> - original source code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/configure">src-alt/configure</a> - GNU Autoconf script for alt server</li>
|
||||
<li><a href="src-alt/localhost/index.html">src-alt/localhost/index.html</a> - home page of alt HIBACHI web server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src/configure">src/configure</a> - GNU Autoconf script</li>
|
||||
<li><a href="src/localhost/index.html">src/localhost/index.html</a> - home page of HIBACHI web server</li>
|
||||
<li><a href="src/localhost/index.html">src/localhost/index.html</a> - home page of alt HIBACHI web server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/IOCCC-2004/mkentry.c">src-alt/IOCCC-2004/mkentry.c</a> - IOCCC tool of 2004 to package entries</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/ioccc.c">src-alt/ioccc.c</a> - IOCCC size tool</li>
|
||||
<li><a href="src-alt/localhost/reference/rfc2616.html">src-alt/localhost/reference/rfc2616.html</a> - RFC 2616 - Hypertext Transfer Protocol - alt server</li>
|
||||
<li><a href="src-alt/localhost/test/perl/index.html">src-alt/localhost/test/perl/index.html</a> - perl test page of alt HIBACHI server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/php/index.php">src-alt/localhost/test/php/index.php</a> - PHP making an ISO 8601:2000 calendar for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/ruby/index.rb">src-alt/localhost/test/ruby/index.rb</a> - ruby home page for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/shell/test0.sh">src-alt/localhost/test/shell/test0.sh</a> - POSIX shell CGI home page for alt server</li>
|
||||
<li><a href="src/localhost/CHANGES-OBFUSCATED.TXT">src/localhost/CHANGES-OBFUSCATED.TXT</a> - obfuscated changelog for code</li>
|
||||
<li><a href="src/localhost/reference/rfc2616.html">src/localhost/reference/rfc2616.html</a> - RFC 2616 - Hypertext Transfer Protocol</li>
|
||||
<li><a href="src/localhost/test/perl/index.html">src/localhost/test/perl/index.html</a> - perl test page of HIBACHI server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src/localhost/test/php/index.php">src/localhost/test/php/index.php</a> - PHP making an ISO 8601:2000 calendar</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src/localhost/test/ruby/index.rb">src/localhost/test/ruby/index.rb</a> - ruby home page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src/localhost/test/shell/test0.sh">src/localhost/test/shell/test0.sh</a> - POSIX shell CGI home page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/transform.sed">src-alt/transform.sed</a> - sed(1) script for building unobfuscated code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/hibachi-start.sh">src-alt/hibachi-start.sh</a> - start the alt web server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/perl/yahoo-ticker.pl">src-alt/localhost/test/perl/yahoo-ticker.pl</a> - stock price fetch example in Perl for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src/hibachi-start.sh">src/hibachi-start.sh</a> - start the web server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src/localhost/test/perl/yahoo-ticker.pl">src/localhost/test/perl/yahoo-ticker.pl</a> - stock price fetch example in Perl</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/configure.in">src-alt/configure.in</a> - GNU Autoconf script for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/hibachi-start.sh.in">src-alt/hibachi-start.sh.in</a> - hibachi-start.sh declarations for alt server</li>
|
||||
<li><a href="src-alt/localhost/CHANGELOG.TXT">src-alt/localhost/CHANGELOG.TXT</a> - obfuscation change log for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src/configure.in">src/configure.in</a> - GNU Autoconf script</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src/hibachi-start.sh.in">src/hibachi-start.sh.in</a> - hibachi-start.sh declarations</li>
|
||||
<li><a href="src/localhost/CHANGELOG.TXT">src/localhost/CHANGELOG.TXT</a> - obfuscation change log</li>
|
||||
@@ -558,6 +586,31 @@ just try to understand the program via the source.</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/.entry.json">.entry.json</a> - entry summary and manifest in JSON</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/.gitignore">.gitignore</a> - list of files that should not be committed under git</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/.path">.path</a> - directory path from top level directory</li>
|
||||
<li><a href="src-alt/localhost/Img/cygwin-icon.gif">src-alt/localhost/Img/cygwin-icon.gif</a> - image for home page for alt server</li>
|
||||
<li><a href="src-alt/localhost/Img/freebsd.gif">src-alt/localhost/Img/freebsd.gif</a> - image for home page for alt server</li>
|
||||
<li><a href="src-alt/localhost/Img/hibachi-256-oc-nc-300x150.gif">src-alt/localhost/Img/hibachi-256-oc-nc-300x150.gif</a> - image for home page for alt server</li>
|
||||
<li><a href="src-alt/localhost/Img/hot-coal-edge-110-indent.png">src-alt/localhost/Img/hot-coal-edge-110-indent.png</a> - image for home page for alt server</li>
|
||||
<li><a href="src-alt/localhost/Img/logosml.256.png">src-alt/localhost/Img/logosml.256.png</a> - image for home page for alt server</li>
|
||||
<li><a href="src-alt/localhost/Img/php-small-trans-light.gif">src-alt/localhost/Img/php-small-trans-light.gif</a> - image for home page for alt server</li>
|
||||
<li><a href="src-alt/localhost/Img/powered-by-hibachi-150x75.png">src-alt/localhost/Img/powered-by-hibachi-150x75.png</a> - image for home page for alt server</li>
|
||||
<li><a href="src-alt/localhost/Img/rectangle_power_perl.gif">src-alt/localhost/Img/rectangle_power_perl.gif</a> - image for home page for alt server</li>
|
||||
<li><a href="src-alt/localhost/Img/sun_logo.gif">src-alt/localhost/Img/sun_logo.gif</a> - image for home page for alt server</li>
|
||||
<li><a href="src-alt/localhost/Img/win.gif">src-alt/localhost/Img/win.gif</a> - image for home page for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/style.css">src-alt/localhost/style.css</a> - CSS for home page for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/perl/yahoo-ticker.pl.in">src-alt/localhost/test/perl/yahoo-ticker.pl.in</a> - stock price fetch declarations for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/php/Date.php">src-alt/localhost/test/php/Date.php</a> - PHP example page support file for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/php/index_php.in">src-alt/localhost/test/php/index_php.in</a> - PHP example page support file for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/php/info.php">src-alt/localhost/test/php/info.php</a> - PHP example support file for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/php/info.php.in">src-alt/localhost/test/php/info.php.in</a> - PHP example page support file for alt server</li>
|
||||
<li><a href="src-alt/localhost/test/php/sendform.html">src-alt/localhost/test/php/sendform.html</a> - php example page support file for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/php/sendform.php">src-alt/localhost/test/php/sendform.php</a> - PHP example page support file for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/php/sendform.php.in">src-alt/localhost/test/php/sendform.php.in</a> - PHP example page support file for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/ruby/LUHN.rb">src-alt/localhost/test/ruby/LUHN.rb</a> - ruby example page support file for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/ruby/index_rb.in">src-alt/localhost/test/ruby/index_rb.in</a> - ruby example page support file for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/shell/dump.sh">src-alt/localhost/test/shell/dump.sh</a> - POSIX shell script support file for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/shell/test1.sh">src-alt/localhost/test/shell/test1.sh</a> - POSIX shell script support file for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/localhost/test/shell/test2.sh">src-alt/localhost/test/shell/test2.sh</a> - POSIX shell script support file for alt server</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hibachi/src-alt/makefile.in">src-alt/makefile.in</a> - makefile template for alt server</li>
|
||||
<li><a href="src/localhost/Img/cygwin-icon.gif">src/localhost/Img/cygwin-icon.gif</a> - image for home page</li>
|
||||
<li><a href="src/localhost/Img/freebsd.gif">src/localhost/Img/freebsd.gif</a> - image for home page</li>
|
||||
<li><a href="src/localhost/Img/hibachi-256-oc-nc-300x150.gif">src/localhost/Img/hibachi-256-oc-nc-300x150.gif</a> - image for home page</li>
|
||||
|
||||
@@ -0,0 +1,138 @@
|
||||
#######################################################################
|
||||
# Thus it begins...
|
||||
#######################################################################
|
||||
|
||||
AC_INIT(hibachi, 1.0, [Anthony Howe <achowe@snert.com>])
|
||||
|
||||
dnl The autoconf version I learned to deal with.
|
||||
AC_PREREQ(2.57)
|
||||
|
||||
dnl Yes I wrote this mess.
|
||||
AC_COPYRIGHT([Public Domain 2004 by Anthony Howe.])
|
||||
|
||||
AC_SUBST(package_copyright, ['Public Domain 2004 by Anthony Howe.'])
|
||||
|
||||
AC_SUBST(package_major, [[`echo $PACKAGE_VERSION | sed -e 's/^\([0-9]*\)\.\([0-9]*\)/\1/'`]])
|
||||
AC_SUBST(package_minor, [[`echo $PACKAGE_VERSION | sed -e 's/^\([0-9]*\)\.\([0-9]*\)/\2/'`]])
|
||||
AC_SUBST(package_author, $PACKAGE_BUGREPORT)
|
||||
|
||||
AC_DEFINE_UNQUOTED(_NAME, ["$PACKAGE_NAME"])
|
||||
AC_DEFINE_UNQUOTED(_MAJOR, $package_major)
|
||||
AC_DEFINE_UNQUOTED(_MINOR, $package_minor)
|
||||
AC_DEFINE_UNQUOTED(_AUTHOR, ["$package_author"])
|
||||
AC_DEFINE_UNQUOTED(_VERSION, ["$PACKAGE_NAME/$PACKAGE_VERSION"])
|
||||
AC_DEFINE_UNQUOTED(_COPYRIGHT, ["$package_copyright"])
|
||||
|
||||
OS=`uname -s`
|
||||
|
||||
#######################################################################
|
||||
# Setup paths
|
||||
#######################################################################
|
||||
|
||||
# The total perspective vortex "You are here..."
|
||||
AC_CONFIG_SRCDIR($PACKAGE_NAME.alt.c)
|
||||
|
||||
dnl AC_SUBST(srcdir)
|
||||
dnl AC_SUBST(top_srcdir)
|
||||
dnl AC_SUBST(abs_srcdir)
|
||||
dnl AC_SUBST(abs_top_srcdir)
|
||||
dnl
|
||||
dnl AC_SUBST(builddir)
|
||||
dnl AC_SUBST(top_builddir)
|
||||
dnl AC_SUBST(abs_builddir)
|
||||
dnl AC_SUBST(abs_top_builddir)
|
||||
|
||||
# If localstatedir still has its original value, then use our prefered default.
|
||||
if test "$localstatedir" = '${prefix}/var'; then
|
||||
if test "$OS" = 'Linux'; then
|
||||
localstatedir='/var/lib'
|
||||
elif test "$OS" = 'FreeBSD'; then
|
||||
localstatedir='/var/state'
|
||||
elif test "$OS" = 'SunOS'; then
|
||||
localstatedir='/var/opt'
|
||||
else
|
||||
localstatedir='/var'
|
||||
fi
|
||||
fi
|
||||
|
||||
#######################################################################
|
||||
# Auxliary files to be modified later
|
||||
#######################################################################
|
||||
|
||||
AC_CONFIG_FILES(makefile)
|
||||
AC_CONFIG_FILES(hibachi-start.sh, [find . -name '*.sh' -exec chmod 755 \{\} \;])
|
||||
|
||||
#######################################################################
|
||||
# Configuration options
|
||||
#######################################################################
|
||||
|
||||
AC_ARG_ENABLE(port,
|
||||
[AC_HELP_STRING([--enable-port=number],[specifiy the server port number, default is 8008])],
|
||||
[], [enable_port=8008]
|
||||
)
|
||||
AC_SUBST(enable_port)
|
||||
|
||||
#######################################################################
|
||||
# Setup compiler predefines and exceptions.
|
||||
#######################################################################
|
||||
|
||||
# Tradional cc options.
|
||||
AC_SUBST(CC_E, '-o')
|
||||
AC_SUBST(CC_E_NAME, '-o $@')
|
||||
AC_SUBST(CC_O, '-o')
|
||||
AC_SUBST(CC_O_NAME, '-o $*$O')
|
||||
|
||||
AC_PROG_CC
|
||||
AC_PROG_LN_S
|
||||
dnl AC_PROG_MAKE_SET
|
||||
|
||||
dnl AC_CHECK_TOOL(RANLIB, ranlib, true)
|
||||
|
||||
#######################################################################
|
||||
# Check for libraries.
|
||||
#######################################################################
|
||||
|
||||
AC_SEARCH_LIBS(socket, [socket nsl],[AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_SOCKET])])])
|
||||
AC_SEARCH_LIBS(inet_ntoa, [socket nsl resolv],[AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_INET_NTOA])])])
|
||||
|
||||
#######################################################################
|
||||
# Check for headers.
|
||||
#######################################################################
|
||||
|
||||
# Need this ANSI C headers.
|
||||
AC_CHECK_HEADERS(
|
||||
[stdio.h stdlib.h string.h],
|
||||
[], [AC_MSG_FAILURE([Missing required ANSI C header.], 1)]
|
||||
)
|
||||
|
||||
# Need these I/O headers.
|
||||
AC_CHECK_HEADERS(
|
||||
[arpa/inet.h dirent.h fcntl.h netinet/in.h sys/socket.h sys/stat.h sys/wait.h unistd.h],
|
||||
[], [AC_MSG_FAILURE([Missing required I/O header.], 1)]
|
||||
)
|
||||
|
||||
#######################################################################
|
||||
# Check for functions.
|
||||
#######################################################################
|
||||
|
||||
AC_CHECK_FUNCS(
|
||||
[ accept bind close closedir dup2 fork getenv inet_ntoa listen open opendir putenv read readdir recv send shutdown snprintf socket sscanf stat strcspn strncat strncmp strstr strtol system tolower waitpid],
|
||||
[], [AC_MSG_FAILURE([Missing required function.], 1)]
|
||||
)
|
||||
|
||||
#######################################################################
|
||||
# Generate output.
|
||||
#######################################################################
|
||||
|
||||
AC_OUTPUT()
|
||||
|
||||
echo
|
||||
echo $PACKAGE_NAME/$package_major.$package_minor
|
||||
echo $package_copyright
|
||||
echo
|
||||
AC_MSG_RESULT([ prefix..................: $prefix])
|
||||
AC_MSG_RESULT([ datadir.................: $datadir])
|
||||
AC_MSG_RESULT([ CFLAGS..................: $CFLAGS])
|
||||
AC_MSG_RESULT([ LDFLAGS.................: $LDFLAGS])
|
||||
AC_MSG_RESULT([ LIBS....................: $LIBS])
|
||||
echo
|
||||
@@ -0,0 +1,185 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env -i /bin/sh
|
||||
#!/bin/ksh
|
||||
#!/bin/sh
|
||||
#
|
||||
# hibachi-start.sh
|
||||
#
|
||||
# Limited implementation of RFC 2616 and CGI/1.1.
|
||||
#
|
||||
# Public Domain 2002, 2004 by Anthony Howe. All rights released.
|
||||
#
|
||||
# usage:
|
||||
#
|
||||
# hibachi-start.sh &
|
||||
#
|
||||
|
||||
#######################################################################
|
||||
# Do NOT modify the following section if you are security conscious.
|
||||
#######################################################################
|
||||
|
||||
#
|
||||
# Reset internal field separator to space, tab, newline.
|
||||
# Not 100% effective if the environment we inherited has
|
||||
# already played silly buggers with IFS like "IFS='S'".
|
||||
#
|
||||
# Use #!/usr/bin/env -i /bin/sh on shells that support
|
||||
# option passing and #! lines longer than 32 bytes to
|
||||
# guarantee a clean environment.
|
||||
#
|
||||
IFS='
|
||||
'
|
||||
|
||||
SED=$(which sed)
|
||||
|
||||
#
|
||||
# Get a clean environment to work with. This works for all
|
||||
# Bourne like shells under Linux and Cygwin environments.
|
||||
#
|
||||
unset $(env | $SED -e 's/^\([^=]*\).*/\1/')
|
||||
|
||||
#
|
||||
# Path of safe executables.
|
||||
#
|
||||
export PATH='/usr/local/bin:/usr/bin:/bin'
|
||||
|
||||
#
|
||||
# Disable any environment file.
|
||||
#
|
||||
unset ENV
|
||||
|
||||
#
|
||||
# Disable cd shortcuts.
|
||||
#
|
||||
unset CDPATH
|
||||
|
||||
#######################################################################
|
||||
# Minimum required for serving static files.
|
||||
#######################################################################
|
||||
|
||||
prefix=/usr/local
|
||||
exec_prefix=${prefix}
|
||||
|
||||
datadir=${prefix}/share
|
||||
sysconfdir=${prefix}/etc
|
||||
sharedstatedir=${prefix}/com
|
||||
localstatedir=/var
|
||||
sbindir=${exec_prefix}/sbin
|
||||
bindir=${exec_prefix}/bin
|
||||
|
||||
#
|
||||
# The port to be used by the Hibachi web server.
|
||||
#
|
||||
# This is NOT normally a server parameter, but information about the
|
||||
# client connection, but since Hibachi only listens on one port, we
|
||||
# assume to know what the incoming port is and listen on that. Also
|
||||
# for the purpose of demonstration, we can't bind to a privileged
|
||||
# port.
|
||||
#
|
||||
export SERVER_PORT=8008
|
||||
|
||||
#
|
||||
# The root of the Hibachi document tree. Virtual hosts
|
||||
# are implemented as subdirectories from this location.
|
||||
#
|
||||
# For example, to setup virtual hosts by name or IP:
|
||||
#
|
||||
# /usr/local/share/hibachi/
|
||||
# localhost/
|
||||
# index.html
|
||||
# ...
|
||||
# 127.0.0.1 -> localhost/
|
||||
#
|
||||
# www.ioccc.org/
|
||||
# index.html
|
||||
# ...
|
||||
# 64.81.251.233 -> www.ioccc.org/
|
||||
#
|
||||
#export DOCUMENT_ROOT=${datadir}/hibachi
|
||||
export DOCUMENT_ROOT=$(pwd)
|
||||
|
||||
#
|
||||
# The executable.
|
||||
#
|
||||
#hibachi=${sbindir}/hibachi
|
||||
hibachi=`dirname $0`/hibachi
|
||||
|
||||
#######################################################################
|
||||
# Required for most CGI scripts.
|
||||
#######################################################################
|
||||
|
||||
#
|
||||
# Your host name or IP address. Ideally this should be the server-name
|
||||
# used in self-referencing URLs.
|
||||
#
|
||||
export SERVER_NAME=127.0.0.1
|
||||
|
||||
#
|
||||
# My web server name and version
|
||||
#
|
||||
export SERVER_SOFTWARE='hibachi/1.0'
|
||||
|
||||
#
|
||||
# Predefined environment space for the request method.
|
||||
#
|
||||
export REQUEST_METHOD='1234'
|
||||
|
||||
#
|
||||
# Predefined environment space for remote address of a request.
|
||||
#
|
||||
export REMOTE_ADDR='123.123.123.123'
|
||||
|
||||
#
|
||||
# Predefined environment space for upload Content-Length.
|
||||
#
|
||||
export CONTENT_LENGTH='123456789.123456789.'
|
||||
|
||||
#
|
||||
# Predefined environment space for upload Content-Type.
|
||||
# Look at the Apache mime.types file, there are some long ones.
|
||||
#
|
||||
export CONTENT_TYPE='123456789.123456789.123456789.123456789.123456789.123456789.'
|
||||
|
||||
#
|
||||
# Predefined environment space for cookies. A single cookie can actually
|
||||
# be a maximum of 4096 bytes in size, but here we only handle shorter ones.
|
||||
#
|
||||
export HTTP_COOKIE='123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.'
|
||||
|
||||
#
|
||||
# Predefined environment space for the absolute path of the script
|
||||
# to be processed. Required by PHP/CGI in order to find the script.
|
||||
# This variable is not part of the CGI/1.1 Specification.
|
||||
#
|
||||
export SCRIPT_FILENAME='123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.'
|
||||
|
||||
#
|
||||
# Hibachi does support the entire CGI/1.1 specification.
|
||||
#
|
||||
export GATEWAY_INTERFACE='CGI/0.0'
|
||||
|
||||
#
|
||||
# We cannot support the following common CGI environment variables
|
||||
# as specified in the draft 3 of a proposed Internet Standard
|
||||
# due to space limitations, but since the draft has expired and
|
||||
# on hold, there is a lot of lee way:
|
||||
#
|
||||
# AUTH_TYPE (MUST) HTTP_ACCEPT (MAY)
|
||||
# HTTP_REFERER (MAY) PATH_INFO (MUST)
|
||||
# PATH_TRANSLATED (SHOULD) REMOTE_HOST (SHOULD)
|
||||
# REMOTE_IDENT (MAY) REMOTE_USER (SHOULD)
|
||||
# SCRIPT_NAME (MUST) SERVER_PROTOCOL (MUST)
|
||||
#
|
||||
|
||||
#######################################################################
|
||||
# Nothing to configure below this point.
|
||||
#######################################################################
|
||||
|
||||
#
|
||||
# Start the web server.
|
||||
#
|
||||
exec ${hibachi}
|
||||
|
||||
#######################################################################
|
||||
# Beyond here be dragons...
|
||||
#######################################################################
|
||||
@@ -0,0 +1,185 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env -i /bin/sh
|
||||
#!/bin/ksh
|
||||
#!/bin/sh
|
||||
#
|
||||
# hibachi-start.sh
|
||||
#
|
||||
# Limited implementation of RFC 2616 and CGI/1.1.
|
||||
#
|
||||
# Public Domain 2002, 2004 by Anthony Howe. All rights released.
|
||||
#
|
||||
# usage:
|
||||
#
|
||||
# hibachi-start.sh &
|
||||
#
|
||||
|
||||
#######################################################################
|
||||
# Do NOT modify the following section if you are security conscious.
|
||||
#######################################################################
|
||||
|
||||
#
|
||||
# Reset internal field separator to space, tab, newline.
|
||||
# Not 100% effective if the environment we inherited has
|
||||
# already played silly buggers with IFS like "IFS='S'".
|
||||
#
|
||||
# Use #!/usr/bin/env -i /bin/sh on shells that support
|
||||
# option passing and #! lines longer than 32 bytes to
|
||||
# guarantee a clean environment.
|
||||
#
|
||||
IFS='
|
||||
'
|
||||
|
||||
SED=$(which sed)
|
||||
|
||||
#
|
||||
# Get a clean environment to work with. This works for all
|
||||
# Bourne like shells under Linux and Cygwin environments.
|
||||
#
|
||||
unset $(env | $SED -e 's/^\([^=]*\).*/\1/')
|
||||
|
||||
#
|
||||
# Path of safe executables.
|
||||
#
|
||||
export PATH='/usr/local/bin:/usr/bin:/bin'
|
||||
|
||||
#
|
||||
# Disable any environment file.
|
||||
#
|
||||
unset ENV
|
||||
|
||||
#
|
||||
# Disable cd shortcuts.
|
||||
#
|
||||
unset CDPATH
|
||||
|
||||
#######################################################################
|
||||
# Minimum required for serving static files.
|
||||
#######################################################################
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
|
||||
datadir=@datadir@
|
||||
sysconfdir=@sysconfdir@
|
||||
sharedstatedir=@sharedstatedir@
|
||||
localstatedir=@localstatedir@
|
||||
sbindir=@sbindir@
|
||||
bindir=@bindir@
|
||||
|
||||
#
|
||||
# The port to be used by the Hibachi web server.
|
||||
#
|
||||
# This is NOT normally a server parameter, but information about the
|
||||
# client connection, but since Hibachi only listens on one port, we
|
||||
# assume to know what the incoming port is and listen on that. Also
|
||||
# for the purpose of demonstration, we can't bind to a privileged
|
||||
# port.
|
||||
#
|
||||
export SERVER_PORT=@enable_port@
|
||||
|
||||
#
|
||||
# The root of the Hibachi document tree. Virtual hosts
|
||||
# are implemented as subdirectories from this location.
|
||||
#
|
||||
# For example, to setup virtual hosts by name or IP:
|
||||
#
|
||||
# /usr/local/share/hibachi/
|
||||
# localhost/
|
||||
# index.html
|
||||
# ...
|
||||
# 127.0.0.1 -> localhost/
|
||||
#
|
||||
# www.ioccc.org/
|
||||
# index.html
|
||||
# ...
|
||||
# 64.81.251.233 -> www.ioccc.org/
|
||||
#
|
||||
#export DOCUMENT_ROOT=${datadir}/hibachi
|
||||
export DOCUMENT_ROOT=$(pwd)
|
||||
|
||||
#
|
||||
# The executable.
|
||||
#
|
||||
#hibachi=${sbindir}/@PACKAGE_NAME@
|
||||
hibachi=`dirname $0`/@PACKAGE_NAME@
|
||||
|
||||
#######################################################################
|
||||
# Required for most CGI scripts.
|
||||
#######################################################################
|
||||
|
||||
#
|
||||
# Your host name or IP address. Ideally this should be the server-name
|
||||
# used in self-referencing URLs.
|
||||
#
|
||||
export SERVER_NAME=127.0.0.1
|
||||
|
||||
#
|
||||
# My web server name and version
|
||||
#
|
||||
export SERVER_SOFTWARE='@PACKAGE_NAME@/@PACKAGE_VERSION@'
|
||||
|
||||
#
|
||||
# Predefined environment space for the request method.
|
||||
#
|
||||
export REQUEST_METHOD='1234'
|
||||
|
||||
#
|
||||
# Predefined environment space for remote address of a request.
|
||||
#
|
||||
export REMOTE_ADDR='123.123.123.123'
|
||||
|
||||
#
|
||||
# Predefined environment space for upload Content-Length.
|
||||
#
|
||||
export CONTENT_LENGTH='123456789.123456789.'
|
||||
|
||||
#
|
||||
# Predefined environment space for upload Content-Type.
|
||||
# Look at the Apache mime.types file, there are some long ones.
|
||||
#
|
||||
export CONTENT_TYPE='123456789.123456789.123456789.123456789.123456789.123456789.'
|
||||
|
||||
#
|
||||
# Predefined environment space for cookies. A single cookie can actually
|
||||
# be a maximum of 4096 bytes in size, but here we only handle shorter ones.
|
||||
#
|
||||
export HTTP_COOKIE='123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.'
|
||||
|
||||
#
|
||||
# Predefined environment space for the absolute path of the script
|
||||
# to be processed. Required by PHP/CGI in order to find the script.
|
||||
# This variable is not part of the CGI/1.1 Specification.
|
||||
#
|
||||
export SCRIPT_FILENAME='123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.'
|
||||
|
||||
#
|
||||
# Hibachi does support the entire CGI/1.1 specification.
|
||||
#
|
||||
export GATEWAY_INTERFACE='CGI/0.0'
|
||||
|
||||
#
|
||||
# We cannot support the following common CGI environment variables
|
||||
# as specified in the draft 3 of a proposed Internet Standard
|
||||
# due to space limitations, but since the draft has expired and
|
||||
# on hold, there is a lot of lee way:
|
||||
#
|
||||
# AUTH_TYPE (MUST) HTTP_ACCEPT (MAY)
|
||||
# HTTP_REFERER (MAY) PATH_INFO (MUST)
|
||||
# PATH_TRANSLATED (SHOULD) REMOTE_HOST (SHOULD)
|
||||
# REMOTE_IDENT (MAY) REMOTE_USER (SHOULD)
|
||||
# SCRIPT_NAME (MUST) SERVER_PROTOCOL (MUST)
|
||||
#
|
||||
|
||||
#######################################################################
|
||||
# Nothing to configure below this point.
|
||||
#######################################################################
|
||||
|
||||
#
|
||||
# Start the web server.
|
||||
#
|
||||
exec ${hibachi}
|
||||
|
||||
#######################################################################
|
||||
# Beyond here be dragons...
|
||||
#######################################################################
|
||||
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* ioccc.c IOCCC 2001 Source Size Rule
|
||||
*
|
||||
* Public Domain 1992 by Anthony Howe. All rights released.
|
||||
*
|
||||
*
|
||||
* SYNOPSIS
|
||||
*
|
||||
* ioccc [-s]
|
||||
*
|
||||
* DESCRIPION
|
||||
*
|
||||
* Taking input from standard input, apply the IOCCC Source Size
|
||||
* Rule for 2001. The program's offical length is written to
|
||||
* standard error. Also filter out C comment blocks sending the
|
||||
* modified source to standard output.
|
||||
*
|
||||
* The 2001 Source Size Rule is:
|
||||
*
|
||||
* Your entry must be <= 4096 bytes in length. The number of characters
|
||||
* excluding whitespace (tab, space, newline, formfeed, return), and
|
||||
* excluding any ';', '{' or '}' followed by whitespace or end of file,
|
||||
* must be <= 2048.
|
||||
*
|
||||
* The -s option siliences standard output.
|
||||
*
|
||||
* NOTE the overall length is not counted since this can be checked
|
||||
* with "ls -l".
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
char usage_err[] = "usage: ioccc [-s]\n";
|
||||
|
||||
int count(int silience);
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
char *ap;
|
||||
int silence = 0;
|
||||
for (--argc, ++argv; 0 < argc && **argv == '-'; --argc, ++argv) {
|
||||
ap = &argv[0][1];
|
||||
if (*ap == '-' && ap[1] == '\0') {
|
||||
--argc;
|
||||
++argv;
|
||||
break;
|
||||
}
|
||||
while (*ap != '\0') {
|
||||
switch (*ap++) {
|
||||
case 's':
|
||||
silence = 1;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, usage_err);
|
||||
return (2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
(void) count(silence);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Count chacacters and strip comments. The stripped input is
|
||||
* sent to standard output. The count of character is sent to
|
||||
* to standard error.
|
||||
*
|
||||
* If silence is true, then do not print anything to standard output.
|
||||
*/
|
||||
int
|
||||
count(int silence)
|
||||
{
|
||||
int i, j, k;
|
||||
char *p, buf[256];
|
||||
|
||||
for (i = k = 0; fgets(buf, 256, stdin) != NULL;) {
|
||||
for (p = buf; *p != '\0'; ++p) {
|
||||
if (k == 1) {
|
||||
if (*p == '*' && p[1] == '/') {
|
||||
/* End of comment. */
|
||||
k = 0;
|
||||
++p;
|
||||
}
|
||||
/* Skip characters in comment block. */
|
||||
continue;
|
||||
}
|
||||
if (*p == '/' && p[1] == '*') {
|
||||
/* Begin comment block. */
|
||||
k = 1;
|
||||
++p;
|
||||
continue;
|
||||
}
|
||||
/* Everything above here is stripped from the input. */
|
||||
if (!silence)
|
||||
putchar(*p);
|
||||
/* Ignore all whitespace. */
|
||||
if (isspace(*p))
|
||||
continue;
|
||||
/* Ignore curly braces and semicolons when followed
|
||||
* by any whitspace or EOF.
|
||||
*/
|
||||
if (strchr("{;}", *p) != NULL
|
||||
&& (isspace(p[1]) || p[1] == '\0'))
|
||||
continue;
|
||||
/* Count this character. */
|
||||
++i;
|
||||
}
|
||||
}
|
||||
fprintf(stderr, "%d\n", i);
|
||||
return (i);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
CHANGES
|
||||
-------
|
||||
|
||||
The major number changes for such things as code rewrites, changes in
|
||||
syntax, and/or dramatic changes in functionality. The minor number
|
||||
changes for corrections, enhancements, etc. made to the code. There
|
||||
is no set schedule for releases.
|
||||
|
||||
--TODO--
|
||||
|
||||
+ Figure out why Links browser doesn't work.
|
||||
|
||||
--1.0--
|
||||
|
||||
Initial release. Submission to the IOCCC 2004.
|
||||
|
||||
--0.8--
|
||||
|
||||
+ Add support for SCRIPT_FILENAME for PHP/CGI.
|
||||
|
||||
+ Restructured directories.
|
||||
|
||||
+ Added autoconf configure.in script and friends.
|
||||
|
||||
--0.7--
|
||||
|
||||
! Replaced print() macro by expansion in status(). Only used in one
|
||||
place. This also fixes a macro expansion bug in status().
|
||||
|
||||
! status() now correctly passes the size of the status response
|
||||
headers to send().
|
||||
|
||||
! Fixed transform.sed which incorrectly transform Host: header string
|
||||
into h:.
|
||||
|
||||
+ Experimented with configure.in and makefile.in. Not really necessary
|
||||
and the macros tests required in the source exceed the size limit.
|
||||
|
||||
|
||||
--0.6--
|
||||
|
||||
! Renamed error() to status(). Set content-length to that of the
|
||||
response message or static file.
|
||||
|
||||
+ Added more details comments with citiations of relavent paragraphs
|
||||
from RFC 2616 and the CGI/1.1 specification.
|
||||
|
||||
! Enlarged header parsing buffer from 4KB to 8KB.
|
||||
|
||||
! Changed parsing of request CRLF to allow for just LF.
|
||||
|
||||
+ Fold case of request headers to lower case, because of problem with
|
||||
Lynx not specifying headers as they appear in RFC 2616.
|
||||
|
||||
--0.5--
|
||||
|
||||
+ First attempt static file web server, with virtual host support.
|
||||
|
||||
+ Added support for CGI/1.1 specification, in particular "nph" CGIs
|
||||
with a selected set of necessary environment variables.
|
||||
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 132 B |
|
After Width: | Height: | Size: 2.3 KiB |
|
After Width: | Height: | Size: 222 KiB |
|
After Width: | Height: | Size: 6.4 KiB |
|
After Width: | Height: | Size: 2.4 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 909 B |
|
After Width: | Height: | Size: 1.0 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,438 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Snert . Com - Software - Hibachi
|
||||
</title>
|
||||
<meta name="keywords" content="hibachi IOCCC International Obfuscated C Code Contest HTTP web server RFC 2616 Apache Unix Linux Cygwin Windows">
|
||||
<meta name="description" content="A small and simple web server with CGI support. It is a limited implementation of RFC 2616. Works for unix boxen, Cygwin, and Windows.">
|
||||
<script language="JavaScript" type="text/javascript" src="./mailto.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="./style.css">
|
||||
</head>
|
||||
<body class="normal" background="Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<!-- MARGINS -->
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td rowspan="2">
|
||||
<img alt="" src="Img/mrpixel.gif" width="130" height="1">
|
||||
<!--
|
||||
</td><td>
|
||||
<img alt="Snert . Com" src="Img/sun.gif" width="105" height="103">
|
||||
-->
|
||||
</td><td align="center" style="padding-left: 30px; text-align: center;">
|
||||
<img alt="HIBACHI/1.0 Web Server" src="Img/hibachi-256-oc-nc-300x150.gif" width="300" height="150" border="0">
|
||||
|
||||
<!-- <span class="title hibachi">HIBACHI/1.0</span> -->
|
||||
<!--
|
||||
<br>
|
||||
<span class="plain">from</span>
|
||||
<span class="snert">Snert</span>
|
||||
-->
|
||||
</td>
|
||||
</tr><tr>
|
||||
<td colspan="2" style="padding: 0 50 0 0;">
|
||||
|
||||
<!-- PAGE BODY -->
|
||||
|
||||
<br>
|
||||
<blockquote class="normal big" style="font-weight: bold; margin: 30px 50px 30px 50px;">
|
||||
[hih-BAH-chee]
|
||||
<br>
|
||||
<br>
|
||||
Japanese for "fire bowl", a hibachi is just that - a small
|
||||
(generally cast-iron) container made for holding fuel
|
||||
(usually charcoal). A grill that sits on top of the bowl
|
||||
is used to cook various foods. Hibachis come in square,
|
||||
oblong and round models. Because of their compact size,
|
||||
they're completely portable.
|
||||
|
||||
<p class="small">-
|
||||
<a href="https://www.epicurious.com/?DEF_ID=2150">
|
||||
epicurious.com food dictionary</a>
|
||||
</p>
|
||||
</blockquote>
|
||||
|
||||
<a name="Description"></a>
|
||||
<h2>Description</h2>
|
||||
|
||||
<p>
|
||||
<span class="hibachi">HIBACHI</span> is a simple, small, and secure web server with virtual
|
||||
host and CGI support. It is a limited implementation of <a href="reference/rfc2616.html">RFC 2616</a>
|
||||
and the <a href="https://www.w3.org/CGI/">CGI/1.1 Specification</a>.
|
||||
<span class="hibachi">HIBACHI</span> was written as an entry for the
|
||||
<a href="https://www.ioccc.org/">International Obfuscated C Code Contest</a> and works
|
||||
for any Unix variant including the <a href="https://www.cygwin.com">Cygwin</a>
|
||||
environment for Windows.
|
||||
</p>
|
||||
<p>
|
||||
<span class="hibachi">HIBACHI</span> supports dynamic web content through the use of the
|
||||
<a href="https://www.w3.org/CGI/">Common Gateway Interface (CGI)</a> specification.
|
||||
Just about any scripting or programming language can be used, such as a POSIX shell,
|
||||
<a href="https://www.perl.com/">Perl</a>,
|
||||
<a href="https://www.php.net/">PHP</a>,
|
||||
<a href="https://www.python.org/">Python</a>, and/or
|
||||
<a href="https://www.ruby-lang.org/">Ruby</a>.
|
||||
Existing CGI scripts can be used with little or no modification.
|
||||
Hibachi executes all CGI scripts as though they were "nph" prefixed, which is to say that it is
|
||||
the script's responsibility to send the HTTP status line and necessary headers direct to the client.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Virtual host support is implemented as subdirectories of the <span class="hibachi">HIBACHI</span>
|
||||
document tree, where the directory name is the domain name publish in a URL. For example to setup
|
||||
a virtual host by name or IP for https://www.ioccc.org/, assuming the <span class="hibachi">HIBACHI</span>
|
||||
document tree is rooted at /usr/local/share/hibachi, then:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
/usr/local/share/hibachi/
|
||||
www.ioccc.org/
|
||||
index.html
|
||||
...
|
||||
64.81.251.233 -> www.ioccc.org/
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
<span class="hibachi">HIBACHI</span> is ideal
|
||||
for special floppy-Linux distributions, like
|
||||
<a href="https://web.archive.org/web/20040727072140/http://leka.muumilaakso.org/">Leka</a>, which can be used for rescue, firewall,
|
||||
demo, or dedicated servers. In theory, with some modifications,
|
||||
<span class="hibachi">HIBACHI</span> and a script interpreter, like <a
|
||||
href="https://www.php.net/">PHP</a>, could also be
|
||||
bundled with CDROMS that require a means of presenting dynamic web pages.
|
||||
</p>
|
||||
|
||||
<a name="Features"></a>
|
||||
<h2>Features</h2>
|
||||
|
||||
<ul>
|
||||
<li>Supports virtual hosts.</li>
|
||||
<li>Supports all MIME types.</li>
|
||||
<li>Supports Common Gateway Interface (<a href="https://www.w3.org/CGI/">CGI</a>) scripts and programs.</li>
|
||||
<li>Supports multiple index.* file types, ie. index.html, index.php, index.pl</li>
|
||||
<li>Supports subset of <a href="reference/rfc2616.html">RFC 2616</a> HTTP/1.1 methods GET, HEAD, and POST.</li>
|
||||
<li>Simple & straight forward configuration using environment variables.</li>
|
||||
<li>Portability across Unix-like environments, ie. <a
|
||||
href="https://www.cygwin.com">Cygwin</a>, <a href="https://www.freebsd.org/">FreeBSD</a>, Linux, SunOS.</li>
|
||||
<li>Known to work with <a href="https://lynx.invisible-island.net">Lynx</a>, <a
|
||||
href="https://www.mozilla.org/">Mozilla</a>, <a href="https://www.opera.com/">Opera</a>, and Internet Explorer web browsers.</li>
|
||||
<li>Is a dedicated process-forking server that does not use inetd.</li>
|
||||
<li>Is secure against relative path file snooping.</li>
|
||||
<li>Is secure against directory searches.</li>
|
||||
<li>~155 lines of source, 1940 bytes long by <a href="https://www.ioccc.org/">IOCCC</a> 2004 rules, ~6KB compiled & stripped on FreeBSD.</li>
|
||||
<li>Superior & smaller than <a
|
||||
href="https://www.acme.com/software/micro_httpd/">micro_httpd</a>
|
||||
from <a href="https://www.acme.com/">ACME</a>.</li>
|
||||
<li>And has a really cool animated logo too.</li>
|
||||
</ul>
|
||||
|
||||
<!--
|
||||
<a href="https://web.archive.org/web/20041231023050/http://www.borland.com/products/downloads/download_cbuilder.html">Borland C++ 5.5</a> free command-line compiler and debugger
|
||||
-->
|
||||
|
||||
<a name="Installation"></a>
|
||||
<h2>Installation</h2>
|
||||
<ol>
|
||||
<li><p>
|
||||
Download:
|
||||
</p>
|
||||
|
||||
<blockquote>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<tr>
|
||||
<td class="normal hline" style="padding: 0 30 5 0;"><a href="http://hibachi.snert.org:8008/hibachi-1.0.tar.gz">Hibachi-1.0 Obfuscated</a></td>
|
||||
<td class="normal hline" style="padding: 0 30 5 0;"><a href="http://hibachi.snert.org:8008/hibachi.md5">md5sum</a></td>
|
||||
<td class="normal hline" style="padding: 0 0 5 0;"><a href="http://hibachi.snert.org:8008/CHANGES-OBFUSCATED.TXT">Change Log</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="padding: 5 30 0 0;"><a href="http://hibachi.snert.org:8008/hibachi-spoiler-1.0.tar.gz">Hibachi-1.0 Spoiler</a></td>
|
||||
<td style="padding: 5 30 0 0;"><a href="http://hibachi.snert.org:8008/hibachi-spoiler.md5">md5sum</a></td>
|
||||
<td style="padding: 5 0 0 0;"><a href="http://hibachi.snert.org:8008/CHANGES-SPOILER.TXT">Change Log</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</blockquote>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<p>
|
||||
Unpack and build the executable:
|
||||
</p>
|
||||
|
||||
<blockquote><tt>
|
||||
tar -zxf hibachi-1.0.tgz<br>
|
||||
cd hibachi-1.0<br>
|
||||
./configure<br>
|
||||
make
|
||||
</tt></blockquote>
|
||||
</li>
|
||||
|
||||
</ol>
|
||||
|
||||
<a name="Usage"></a>
|
||||
<h2>Usage</h2>
|
||||
|
||||
<p>
|
||||
First read and configure the file <code>hibachi-start.sh</code>. In most cases the
|
||||
defaults settings should be fine for testing. Start the server in
|
||||
the background, and perform the initial test (assuming that SERVER_PORT was
|
||||
not altered in <code>hibachi-start.sh</code>):
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
./hibachi-start.sh &
|
||||
lynx http://localhost:8008/
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
To stop the server:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
kill %1
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
To access this documentation and examples from the Internet, create symbolic links for the
|
||||
host name and/or IP pointing to the «localhost» directory. For example, replace the IP and host
|
||||
name addresses below with that of the machine running
|
||||
<span class="hibachi">HIBACHI</span>:
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
ln -s localhost 64.81.251.233
|
||||
ln -s localhost www.ioccc.org
|
||||
</pre></blockquote>
|
||||
|
||||
<p>
|
||||
<span class="hibachi">HIBACHI</span> can server multiple
|
||||
websites from the same machine simply by creating content directories with the same
|
||||
name as the URL domain names within the document root tree. Domain and/or IP aliases are simply symbolic links
|
||||
to content directories. There is never any need to restart <span class="hibachi">HIBACHI</span>
|
||||
when websites are published or aliases added.
|
||||
|
||||
Assuming the server is running and that port 8008 is not blocked by any firewall,
|
||||
you should be able to access the server from the Internet using an IP or host name URL similar to:</p>
|
||||
</p>
|
||||
|
||||
<blockquote><pre>
|
||||
https://185.199.111.153
|
||||
https://www.ioccc.org:8008/
|
||||
</pre></blockquote>
|
||||
|
||||
|
||||
<p>
|
||||
Port 8008 (http-alt) was chosen as the default port for demonstration purposes,
|
||||
since its an alternative HTTP port that does not require special privileges and
|
||||
is rarely in use.
|
||||
Of course, <span class="hibachi">HIBACHI</span> could be run as a standard
|
||||
web server on port 80, but this would require that it be installed by
|
||||
the system administrator, contrary to IOCCC rules.
|
||||
</p>
|
||||
|
||||
<a name="Test"></a>
|
||||
<h2>CGI Examples</h2>
|
||||
|
||||
<p>
|
||||
The following tests and examples are available to demonstrate various
|
||||
aspects of the CGI support:
|
||||
</p>
|
||||
|
||||
<dl>
|
||||
<dt><a href="test/shell/test0.sh">POSIX Shell Example</a></dt>
|
||||
<dd>
|
||||
These CGI scripts perform some basic tests on the handling of GET and POST requests,
|
||||
cookies, and the passing of environment variables to CGI scripts. These CGI scripts
|
||||
assume that <span class="path">/bin/sh</span> is a POSIX compliant shell and the
|
||||
standard set of POSIX utilities are available. Should work for all Unix variants
|
||||
and <a href="https://www.cygwin.com">Cygwin</a>.
|
||||
|
||||
</dd>
|
||||
|
||||
<dt><a href="test/perl/">Perl Example</a></dt>
|
||||
<dd>
|
||||
<a href="https://www.perl.com/"><img alt="Powered by Perl" src="Img/rectangle_power_perl.gif" width="88" height="31" border="0" hspace="20" align="right"></a>
|
||||
This example queries the Yahoo website for a stock quote to insert into a web page.
|
||||
<u><i>This example requires a browser with JavaScript support </i></u> and
|
||||
should work for all Unix variants and <a href="https://www.cygwin.com">Cygwin</a>, when Perl is installed.
|
||||
</dd>
|
||||
|
||||
<dt><a href="test/php/">PHP Example</a></dt>
|
||||
<dd>
|
||||
<a href="https://www.php.net/"><img alt="Powered by PHP" src="Img/php-small-trans-light.gif" width="88" height="31" border="0" hspace="20" align="right"></a>
|
||||
This PHP example generates a calendar complete with ISO 8601:2000 week numbers.
|
||||
<!--
|
||||
This example shows how PHP might be used to format the result of a web form into
|
||||
something human readable suitable for sending by email.
|
||||
-->
|
||||
|
||||
<p>
|
||||
The Windows PHP CGI binary distribution from the
|
||||
<a href="https://www.php.net/">PHP</a> website does not work within the <a href="https://www.cygwin.com">Cygwin</a>
|
||||
environment. Instead, download the source distribution and build the PHP CGI and CLI versions from scratch
|
||||
from within Cygwin. <!-- The CLI is desired, since it behaves more like an nph-CGI. -->
|
||||
The following commands were used to build:
|
||||
|
||||
<blockquote><pre>
|
||||
# Without this link, the configure script has problems with Cygwin.
|
||||
ln -s /bin/gcc /bin/cc
|
||||
|
||||
CFLAGS=-O ./configure \
|
||||
--with-config-file-path=/usr/local/etc:/etc \<!--
|
||||
--enable-calendar \
|
||||
--enable-shared \
|
||||
--disable-cgi \
|
||||
--enable-cli \ -->
|
||||
--enable-discard-path \
|
||||
--disable-xml \
|
||||
--without-pear \
|
||||
--enable-sockets \
|
||||
--enable-bcmath \
|
||||
--enable-ftp \
|
||||
--enable-dba \
|
||||
--with-inifile
|
||||
|
||||
make
|
||||
make install
|
||||
|
||||
# Install both the CGI and CLI (though the CLI is not used here).
|
||||
mv /usr/local/bin/php /usr/local/bin/php.cgi.exe
|
||||
make install-cli
|
||||
mv /usr/local/bin/php /usr/local/bin/php.exe
|
||||
|
||||
cp php.ini-recommended /etc/php.ini
|
||||
</pre>
|
||||
</blockquote>
|
||||
<p>
|
||||
The php.ini file should specify "output_buffering = 4096" so that PHP scripts have a chance to
|
||||
modify the response status and headers before the body is sent. Also set "cgi.rfc2616_headers = 1".
|
||||
Click here to display the <a href="test/php/info.php">PHP Info</a> configuration.
|
||||
</p>
|
||||
</dd>
|
||||
<!--
|
||||
-->
|
||||
|
||||
<dt><a href="test/ruby/">Ruby Example</a></dt>
|
||||
<dd>
|
||||
This example validates and/or generates Luhn check-digits.
|
||||
Should work for all Unix variants and <a href="https://www.cygwin.com/">Cygwin</a>,
|
||||
when Ruby is installed.
|
||||
</dd>
|
||||
</dl>
|
||||
|
||||
<a name="Portability"></a>
|
||||
<h2>Portability</h2>
|
||||
|
||||
<blockquote>
|
||||
<table border="0" cellspacing="4" cellpadding="0">
|
||||
<tr valign="middle">
|
||||
<td align="right">
|
||||
<a href="https://www.freebsd.org/"><img alt="FreeBSD" src="Img/freebsd.gif" width="94" height="39" border="0" hspace="20" border="0"></a>
|
||||
</td>
|
||||
<td rowspan="4"> </td>
|
||||
<td>
|
||||
4.8
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="middle">
|
||||
<td align="right">
|
||||
<img alt="Linux" src="Img/logosml.256.png" width="92" height="39" border="0" hspace="20">
|
||||
</td>
|
||||
<td>
|
||||
Cobalt Qube 1, RedHat Linux 5.1, gcc 2.7.2
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="middle">
|
||||
<td bgcolor="#594FBF" align="right">
|
||||
<a href="https://www.oracle.com/it-infrastructure/"><img src="Img/sun_logo.gif" width="94" height="39" border="0" alt="Sun Microsystems Logo" vspace="0" hspace="20"></a>
|
||||
</td>
|
||||
<td>
|
||||
5.8
|
||||
</td>
|
||||
</tr>
|
||||
<tr valign="middle">
|
||||
<td align="right">
|
||||
<!-- <span class="large" style="position: relative; top:
|
||||
-8px">+</span> --><a href="https://www.cygwin.com"><img alt="Cygwin Unix Emulation" src="Img/cygwin-icon.gif" width="28" height="28" border="0" hspace="20" vspace="8" align="right"></a>
|
||||
<img alt="Microsoft Windows" src="Img/win.gif" width="40" height="40" border="0" style="padding: 3px 6px 0 0;" align="right">
|
||||
</td>
|
||||
<td>
|
||||
Windows 2000 SP4, Windows XP Pro SP1
|
||||
<br>with <a href="https://www.cygwin.com">Cygwin</a>, gcc 2.95.3-5
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</blockquote>
|
||||
|
||||
|
||||
<a name="License"></a>
|
||||
<h2>License</h2>
|
||||
|
||||
<p>
|
||||
In accordance with the
|
||||
<a href="https://www.ioccc.org/">International Obfuscated C Code Contest</a>
|
||||
this is an original work and placed in the public domain.
|
||||
</p>
|
||||
|
||||
<!--
|
||||
<p>
|
||||
In all cases a monetary donation and/or <a href="https://www.amazon.com/">Amazon</a>
|
||||
wishlist gifts to the author are welcomed, but not required, for the continued
|
||||
encouragment, moral support, and ego pumping needed to work in foriegn non-english
|
||||
speaking lands.
|
||||
</p>
|
||||
-->
|
||||
|
||||
<a name="Disclaimer"></a>
|
||||
<h2>Disclaimer</h2>
|
||||
<p>
|
||||
THIS SOFTWARE IS PROVIDE "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO WAY SHALL THE
|
||||
AUTHOR OR LICENSEE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
</p>
|
||||
|
||||
|
||||
<a name="Support"></a>
|
||||
<h2>Support</h2>
|
||||
<p>
|
||||
Free support is limited, based on the author's availability, though
|
||||
enhancements requests and problem reports are welcome (see logo above).
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div align="center">
|
||||
<a href="https://hibachi.snert.org:8008/">
|
||||
<img alt="Powered by Hibachi" src="Img/powered-by-hibachi-150x75.png" width="150" height="75" border="1" style="color: #000000"></a>
|
||||
</div>
|
||||
|
||||
<!-- copyright -->
|
||||
<div align="center" class="copyright">
|
||||
<nobr>Public Domain 2004 by
|
||||
<a href="javascript:achowe()">
|
||||
Anthony C Howe</a>.</nobr>
|
||||
</div>
|
||||
<!--end copyright-->
|
||||
|
||||
<br/>
|
||||
|
||||
<!-- END PAGE BODY -->
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- END MARGINS -->
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<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>Hypertext Transfer Protocol -- HTTP/1.</title>
|
||||
<meta name="description" content="RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1">
|
||||
<meta name="keywords" content="IOCCC, RFC 2616, HTTP/1.1">
|
||||
<meta http-equiv="Refresh" content="0; url=https://www.rfc-editor.org/rfc/rfc2616">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Your browser did not refresh to the <a
|
||||
href="https://www.rfc-editor.org/rfc/rfc2616">RFC 2616: Hypertext
|
||||
Transfer Protocol -- HTTP/1.1</a> web page.
|
||||
|
||||
Please visit <a href="https://www.rfc-editor.org/rfc/rfc2616">https://www.rfc-editor.org/rfc/rfc2616</a>.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,110 @@
|
||||
body {
|
||||
padding: 0px 60px 0px 10px;
|
||||
}
|
||||
|
||||
.normal, p, ul {
|
||||
font-family: Arial, Verdana, Helvetica, sans-serif;
|
||||
font-size: 12pt;
|
||||
color: #000000;
|
||||
text-align: justify;
|
||||
}
|
||||
.title {
|
||||
/* font-family: serif; */
|
||||
font-weight: bold;
|
||||
font-size: 24pt;
|
||||
color: #3099ff;
|
||||
}
|
||||
.hibachi {
|
||||
color: #b50000;
|
||||
font-style: italic;
|
||||
}
|
||||
.small {
|
||||
font-family: Arial, Verdana, Helvetica, sans-serif;
|
||||
font-size: 8pt;
|
||||
color: #000000;
|
||||
}
|
||||
.copyright {
|
||||
font-family: Arial, Verdana, Helvetica, sans-serif;
|
||||
font-size: 9pt;
|
||||
color: #000000;
|
||||
}
|
||||
.big, h3 {
|
||||
font-family: Arial, Verdana, Helvetica, sans-serif;
|
||||
font-size: 12pt;
|
||||
color: #000000;
|
||||
}
|
||||
.large, h2 {
|
||||
font-family: Arial, Verdana, Helvetica, sans-serif;
|
||||
font-weight: normal;
|
||||
font-size: 16pt;
|
||||
color: #000000;
|
||||
}
|
||||
.huge, h1 {
|
||||
font-family: Arial, Verdana, Helvetica, sans-serif;
|
||||
font-size: 26pt;
|
||||
}
|
||||
.project {
|
||||
text-decoration: none;
|
||||
font-weight: bold;
|
||||
# color: #3099ff;
|
||||
}
|
||||
.plain {
|
||||
font-family: serif;
|
||||
font-size: 14pt;
|
||||
color: #000000;
|
||||
}
|
||||
.snert {
|
||||
font-family: serif;
|
||||
font-weight: bold;
|
||||
font-size: 16pt;
|
||||
color: #000000;
|
||||
z-index: 10;
|
||||
}
|
||||
.serif {
|
||||
font-family: serif;
|
||||
}
|
||||
a {
|
||||
font-family: Arial, Verdana, Helvetica, sans-serif;
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:link {
|
||||
/* color: #0000ff; */
|
||||
color: #aa0000;
|
||||
}
|
||||
a:hover {
|
||||
/* color: #000080; */
|
||||
color: #dd0000;
|
||||
text-decoration: underline;
|
||||
}
|
||||
a:visited {
|
||||
/* color: #000080; */
|
||||
color: #800000;
|
||||
}
|
||||
.syntax {
|
||||
font-family: Arial, Verdana, Helvetica, sans-serif;
|
||||
font-weight: normal;
|
||||
font-size: 11pt;
|
||||
color:#000080;
|
||||
}
|
||||
.param {
|
||||
color:#0000cc;
|
||||
font-style: italic;
|
||||
font-weight: normal
|
||||
}
|
||||
|
||||
dd {
|
||||
margin: 0 20px 20px 30px;
|
||||
}
|
||||
|
||||
.path {
|
||||
font-family: monospace;
|
||||
font-weight: bold;
|
||||
font-size: 10pt;
|
||||
}
|
||||
|
||||
.hline {
|
||||
border-collapse: collapse;
|
||||
border-bottom: 1px solid;
|
||||
border-color: #000000;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - Stock Price Example in Perl
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
<script language="JavaScript" type="text/javascript" src="yahoo-ticker.pl?DIR.V"></script>
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<h2>Stock Price Fetch Example in Perl</h2>
|
||||
<p>
|
||||
(This example requires JavaScript.)
|
||||
</p>
|
||||
|
||||
<table border="0" style="margin: 30 20 30 0;">
|
||||
<tr>
|
||||
<td rowspan="7">
|
||||
|
||||
</td>
|
||||
<th style="text-align: right;">Exchange : </th><td>CDNX</td>
|
||||
</tr><tr>
|
||||
<th style="text-align: right;">Symbol : </th><td>DIR</td>
|
||||
</tr><tr>
|
||||
<th style="text-align: right;">Share Price : </th>
|
||||
<td>
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
document.write(ticker['price']);
|
||||
</script>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="text-align: right;">Volume : </th>
|
||||
<td>
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
document.write(ticker['volume']);
|
||||
</script>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th style="text-align: right;">Last Trade : </th>
|
||||
<td>
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
document.write(ticker['last']);
|
||||
</script>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<hr/>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,77 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# yahoo-ticker.pl
|
||||
#
|
||||
# Copyright 1998 by Anthony Howe. All rights reserved.
|
||||
#
|
||||
# Usage: yahoo-ticker.pl?<symbol>
|
||||
#
|
||||
|
||||
##########################################################################
|
||||
# Nothing to be configured below this point.
|
||||
##########################################################################
|
||||
|
||||
use Socket;
|
||||
|
||||
# WORK-AROUND 1.
|
||||
# BAH! Some Perl implementations (for Windows) are not created equal.
|
||||
# Force I/O flushes after each read/write operation.
|
||||
|
||||
$| = 1;
|
||||
|
||||
#########################################################################
|
||||
# Open connection to URL.
|
||||
#########################################################################
|
||||
|
||||
my ($symbol) = $ENV{'QUERY_STRING'} =~ /\??(.*)/;
|
||||
|
||||
# Figure out who we have to call.
|
||||
#($host, $port, $path) = ($url =~ m!http://([^:/]+)(?:\:(\d*))?(/.*)!);
|
||||
|
||||
$host = "finance.yahoo.com";
|
||||
$port = 80 unless defined $port;
|
||||
$path = "/q?s=$symbol";
|
||||
|
||||
# Get a socket...
|
||||
unless (socket(HTTP, PF_INET, SOCK_STREAM, getprotobyname('tcp'))) {
|
||||
print("[CGI failed ($!)]\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
# ...set socket to be line buffered...
|
||||
select( (select(HTTP), $| = 1)[0] );
|
||||
|
||||
# .. make the connection.
|
||||
unless (connect(HTTP, sockaddr_in($port, inet_aton("$host")))) {
|
||||
print("[CGI failed ($!)]\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
print HTTP "GET $path HTTP/1.0\nHost: $host\n\n";
|
||||
|
||||
while (<HTTP>) {
|
||||
# Last trade price line.
|
||||
if (m!>Last Trade:<!) {
|
||||
($price) = (m!Last Trade:</td><td class="yfnc_tabledata1"><big><b>(\d+\.\d+)</b></big></td>!);
|
||||
}
|
||||
|
||||
if (m!>Trade Time:<!) {
|
||||
($last) = (m!Trade Time:</td><td class="yfnc_tabledata1">([^<]+)</td>!);
|
||||
}
|
||||
|
||||
if (m!>Volume:<!) {
|
||||
($volume) = (m!Volume:</td><td class="yfnc_tabledata1">([^<]+)</td>!);
|
||||
}
|
||||
}
|
||||
|
||||
close(HTTP);
|
||||
|
||||
print "HTTP/1.0 200 OK\n";
|
||||
print "Content-Type: text/javascript\n\n";
|
||||
|
||||
print "var ticker = new Array();\n";
|
||||
print "ticker['price'] = $price;\n";
|
||||
print "ticker['volume'] = \"$volume\";\n";
|
||||
print "ticker['last'] = \"$last\";\n";
|
||||
|
||||
exit 0;
|
||||
@@ -0,0 +1,77 @@
|
||||
#!@perl_exe@
|
||||
#
|
||||
# yahoo-ticker.pl
|
||||
#
|
||||
# Copyright 1998 by Anthony Howe. All rights reserved.
|
||||
#
|
||||
# Usage: yahoo-ticker.pl?<symbol>
|
||||
#
|
||||
|
||||
##########################################################################
|
||||
# Nothing to be configured below this point.
|
||||
##########################################################################
|
||||
|
||||
use Socket;
|
||||
|
||||
# WORK-AROUND 1.
|
||||
# BAH! Some Perl implementations (for Windows) are not created equal.
|
||||
# Force I/O flushes after each read/write operation.
|
||||
|
||||
$| = 1;
|
||||
|
||||
#########################################################################
|
||||
# Open connection to URL.
|
||||
#########################################################################
|
||||
|
||||
my ($symbol) = $ENV{'QUERY_STRING'} =~ /\??(.*)/;
|
||||
|
||||
# Figure out who we have to call.
|
||||
#($host, $port, $path) = ($url =~ m!http://([^:/]+)(?:\:(\d*))?(/.*)!);
|
||||
|
||||
$host = "finance.yahoo.com";
|
||||
$port = 80 unless defined $port;
|
||||
$path = "/q?s=$symbol";
|
||||
|
||||
# Get a socket...
|
||||
unless (socket(HTTP, PF_INET, SOCK_STREAM, getprotobyname('tcp'))) {
|
||||
print("[CGI failed ($!)]\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
# ...set socket to be line buffered...
|
||||
select( (select(HTTP), $| = 1)[0] );
|
||||
|
||||
# .. make the connection.
|
||||
unless (connect(HTTP, sockaddr_in($port, inet_aton("$host")))) {
|
||||
print("[CGI failed ($!)]\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
print HTTP "GET $path HTTP/1.0\nHost: $host\n\n";
|
||||
|
||||
while (<HTTP>) {
|
||||
# Last trade price line.
|
||||
if (m!>Last Trade:<!) {
|
||||
($price) = (m!Last Trade:</td><td class="yfnc_tabledata1"><big><b>(\d+\.\d+)</b></big></td>!);
|
||||
}
|
||||
|
||||
if (m!>Trade Time:<!) {
|
||||
($last) = (m!Trade Time:</td><td class="yfnc_tabledata1">([^<]+)</td>!);
|
||||
}
|
||||
|
||||
if (m!>Volume:<!) {
|
||||
($volume) = (m!Volume:</td><td class="yfnc_tabledata1">([^<]+)</td>!);
|
||||
}
|
||||
}
|
||||
|
||||
close(HTTP);
|
||||
|
||||
print "HTTP/1.0 200 OK\n";
|
||||
print "Content-Type: text/javascript\n\n";
|
||||
|
||||
print "var ticker = new Array();\n";
|
||||
print "ticker['price'] = $price;\n";
|
||||
print "ticker['volume'] = \"$volume\";\n";
|
||||
print "ticker['last'] = \"$last\";\n";
|
||||
|
||||
exit 0;
|
||||
@@ -0,0 +1,557 @@
|
||||
<?
|
||||
class Date
|
||||
{
|
||||
var $date;
|
||||
var $time;
|
||||
|
||||
//
|
||||
// Create a new date object set to the time now.
|
||||
//
|
||||
function Date()
|
||||
{
|
||||
$this->setTime(time());
|
||||
}
|
||||
|
||||
function isLeapYear(/* year */)
|
||||
{
|
||||
if (func_num_args() == 1)
|
||||
$year = func_get_arg(0);
|
||||
else
|
||||
$year = $this->date['year'];
|
||||
|
||||
if ($year % 4000 == 0)
|
||||
return false;
|
||||
if ($year % 400 == 0)
|
||||
return true;
|
||||
if ($year % 100 == 0)
|
||||
return false;
|
||||
if ($year % 4 == 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the number of seconds since system epoch.
|
||||
//
|
||||
function getTime()
|
||||
{
|
||||
return $this->time;
|
||||
}
|
||||
|
||||
//
|
||||
// Set the date / time in seconds for the object.
|
||||
//
|
||||
function setTime($t)
|
||||
{
|
||||
$this->time = $t;
|
||||
$this->date = getdate($t);
|
||||
}
|
||||
|
||||
function getHour()
|
||||
{
|
||||
return $this->date['hour'];
|
||||
}
|
||||
|
||||
function getMinute()
|
||||
{
|
||||
return $this->date['minutes'];
|
||||
}
|
||||
|
||||
function getSecond()
|
||||
{
|
||||
return $this->date['seconds'];
|
||||
}
|
||||
|
||||
function getMonth()
|
||||
{
|
||||
return $this->date['mon'];
|
||||
}
|
||||
|
||||
function getYear()
|
||||
{
|
||||
return $this->date['year'];
|
||||
}
|
||||
|
||||
function getDayOfWeek()
|
||||
{
|
||||
return $this->date['wday'];
|
||||
}
|
||||
|
||||
function getDayOfMonth()
|
||||
{
|
||||
return $this->date['mday'];
|
||||
}
|
||||
|
||||
function getDayOfYear()
|
||||
{
|
||||
return $this->date['yday'];
|
||||
}
|
||||
|
||||
function getDaysInMonth(/* year, month */)
|
||||
{
|
||||
if (func_num_args() == 2) {
|
||||
$year = func_get_arg(0);
|
||||
$month = func_get_arg(1);
|
||||
} else {
|
||||
$year = $this->date['year'];
|
||||
$month = $this->date['mon'];
|
||||
}
|
||||
|
||||
$endOfMonth = Array(
|
||||
31,
|
||||
28 + Date::isLeapYear($year),
|
||||
31,
|
||||
30,
|
||||
31,
|
||||
30,
|
||||
31,
|
||||
31,
|
||||
30,
|
||||
31,
|
||||
30,
|
||||
31
|
||||
);
|
||||
|
||||
return $endOfMonth[$month-1];
|
||||
}
|
||||
|
||||
function getPreviousMonth()
|
||||
{
|
||||
if ($this->date['mon'] <= 1)
|
||||
return 12;
|
||||
|
||||
return $this->date['mon']-1;
|
||||
}
|
||||
|
||||
function getNextMonth()
|
||||
{
|
||||
if (12 <= $this->date['mon'])
|
||||
return 1;
|
||||
|
||||
return $this->date['mon']+1;
|
||||
}
|
||||
|
||||
function getFirstWeekDayOfMonth(/* year, month */)
|
||||
{
|
||||
if (func_num_args() == 2) {
|
||||
$y = func_get_arg(0);
|
||||
$m = func_get_arg(1);
|
||||
} else {
|
||||
$y = $this->date['year'];
|
||||
$m = $this->date['mon'];
|
||||
}
|
||||
|
||||
// Day of the week 0..6 (Sunday..Saturday).
|
||||
$weekDay = strftime("%w", mktime(0, 0, 0, $m, 1, $y));
|
||||
|
||||
// Day of the week 1..7 (Monday..Sunday).
|
||||
return $weekDay == 0 ? 7 : $weekDay;
|
||||
}
|
||||
|
||||
function getNumberOfWeeks(/* year */)
|
||||
{
|
||||
if (func_num_args() == 1)
|
||||
$year = func_get_arg(0);
|
||||
else
|
||||
$year = $this->date['year'];
|
||||
|
||||
/* An ISO calendar year y is long (contains 53 weeks) if:
|
||||
*
|
||||
* p(y) modulo 7 = 4
|
||||
*
|
||||
* or if:
|
||||
*
|
||||
* p(y-1) modulo 7 = 3
|
||||
*
|
||||
* with:
|
||||
*
|
||||
* p(y) = y + floor(y/4) - floor(y/100) + floor(y/400)
|
||||
*
|
||||
* http://www.phys.uu.nl/~vgent/calendar/isocalendar.htm
|
||||
*/
|
||||
|
||||
if (($year + floor($year/4) - floor($year/100) + floor($year/400)) % 7 == 4)
|
||||
return 53;
|
||||
|
||||
if ((--$year + floor($year/4) - floor($year/100) + floor($year/400)) % 7 == 3)
|
||||
return 53;
|
||||
|
||||
return 52;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return ISO 8601:2000(E) week number. This is a work around for
|
||||
* Windows, which does not support a working strftime %V format.
|
||||
*/
|
||||
function getWeekNumber(/* year, month, day */)
|
||||
{
|
||||
if (func_num_args() == 3) {
|
||||
$year = func_get_arg(0);
|
||||
$month = func_get_arg(1);
|
||||
$day = func_get_arg(2);
|
||||
} else {
|
||||
$year = $this->date['year'];
|
||||
$month = $this->date['mon'];
|
||||
$day = $this->date['mday'];
|
||||
}
|
||||
|
||||
/* The week number of the current year as a decimal number, range
|
||||
* 00 to 53, starting with the first Monday as the first day of
|
||||
* week 01.
|
||||
*/
|
||||
$week = strftime("%W", mktime(0, 0, 0, $month, $day, $year));
|
||||
|
||||
/* Week days numbered 0 (Sunday) to 6 (Saturday). */
|
||||
$firstWeekDayThisYear = strftime("%w", mktime(0, 0, 0, 1, 1, $year));
|
||||
$firstWeekDayNextYear = strftime("%w", mktime(0, 0, 0, 1, 1, $year+1));
|
||||
|
||||
/* The first ISO calendar week of a year is the one that includes the
|
||||
* first Thursday of that year. In other words, the first week of the
|
||||
* ISO calendar year is the earliest week that contains at least four
|
||||
* days of the month of January.
|
||||
*/
|
||||
if (1 < $firstWeekDayThisYear && $firstWeekDayThisYear < 5) {
|
||||
/* The first Thursday of the current ISO year was in week zero. */
|
||||
$week++;
|
||||
}
|
||||
|
||||
if ($week == 53 && 1 < $firstWeekDayNextYear && $firstWeekDayNextYear < 5) {
|
||||
/* The first Thursday of the following ISO year is this week. */
|
||||
$week = 1;
|
||||
}
|
||||
|
||||
if ($week == 0) {
|
||||
/* Number of weeks last year. */
|
||||
$week = Date::getNumberOfWeeks($year-1);
|
||||
}
|
||||
|
||||
return $week+0;
|
||||
}
|
||||
|
||||
//
|
||||
// Return the number seconds as of zero hour today.
|
||||
//
|
||||
function getDate()
|
||||
{
|
||||
return mktime(0, 0, 0, $this->date['mon'], $this->date['mday'], $this->date['year']);
|
||||
}
|
||||
|
||||
//
|
||||
// Set date as of zero hour that day.
|
||||
//
|
||||
function setDate($year, $month, $day)
|
||||
{
|
||||
$this->setDateTime($year, $month, $day, 0, 0, 0);
|
||||
}
|
||||
|
||||
//
|
||||
// Return the date / time array.
|
||||
//
|
||||
function getDateTime()
|
||||
{
|
||||
return $this->date;
|
||||
}
|
||||
|
||||
//
|
||||
// Set the date / time for the object.
|
||||
//
|
||||
function setDateTime($year, $month, $day, $hour, $minute, $second)
|
||||
{
|
||||
$time = mktime($hour, $minute, $second, $month, $day, $year, 0);
|
||||
$this->setTime($time);
|
||||
}
|
||||
|
||||
//
|
||||
// Adjust the date / time of the object.
|
||||
//
|
||||
function addDateTime($year, $month, $day, $hour, $minute, $second)
|
||||
{
|
||||
$t = mktime(
|
||||
$this->date['hour'] + $hour,
|
||||
$this->date['minutes'] + $minute,
|
||||
$this->date['seconds'] + $second,
|
||||
$this->date['mon'] + $month,
|
||||
$this->date['mday'] + $day,
|
||||
$this->date['year'] + $year
|
||||
);
|
||||
$this->setTime($t);
|
||||
}
|
||||
|
||||
//
|
||||
// Return the date / time as an ISO date string.
|
||||
//
|
||||
function getDateISO()
|
||||
{
|
||||
return strftime("%Y-%m-%d %H:%M:%S", $this->time);
|
||||
}
|
||||
|
||||
//
|
||||
// Set the date / time of the object using an ISO date string.
|
||||
//
|
||||
function setDateISO($str)
|
||||
{
|
||||
if (!ereg('([0-9]+)-([0-9]+)-([0-9]+)', $str, $ymd))
|
||||
$ymd = array('','0','0','0');
|
||||
if (!ereg('([0-9]+):([0-9]+):([0-9]+)\+([0-9]+)', $str, $hms))
|
||||
$hms = array('','0','0','0');
|
||||
|
||||
// Assume local time, ignore timezone.
|
||||
$this->setDateTime(
|
||||
intval($ymd[1]),
|
||||
intval($ymd[2]),
|
||||
intval($ymd[3]),
|
||||
intval($hms[1]),
|
||||
intval($hms[2]),
|
||||
intval($hms[3])
|
||||
);
|
||||
}
|
||||
|
||||
function setDateMySQL($str)
|
||||
{
|
||||
$n = sscanf($str, "%4d%2d%2d%2d%2d%2d", $y, $m, $d, $H, $M, $S);
|
||||
$this->setDateTime($y, $m, $d, $H, $M, $S);
|
||||
}
|
||||
|
||||
//
|
||||
// Relational operations between Date vs time or Date vs Date.
|
||||
//
|
||||
function eq($t)
|
||||
{
|
||||
if (is_object($t)) $t = $t->getTime();
|
||||
return $this->time == $t;
|
||||
}
|
||||
|
||||
function ne($t)
|
||||
{
|
||||
if (is_object($t)) $t = $t->getTime();
|
||||
return $this->time != $t;
|
||||
}
|
||||
|
||||
function lt($t)
|
||||
{
|
||||
if (is_object($t)) $t = $t->getTime();
|
||||
return $this->time < $t;
|
||||
}
|
||||
|
||||
function le($t)
|
||||
{
|
||||
if (is_object($t)) $t = $t->getTime();
|
||||
return $this->time <= $t;
|
||||
}
|
||||
|
||||
function gt($t)
|
||||
{
|
||||
if (is_object($t)) $t = $t->getTime();
|
||||
return $this->time > $t;
|
||||
}
|
||||
|
||||
function ge($t)
|
||||
{
|
||||
if (is_object($t)) $t = $t->getTime();
|
||||
return $this->time >= $t;
|
||||
}
|
||||
|
||||
/*
|
||||
* $obj->getSmallCalendar()
|
||||
* Date::getSmallCalendar($year, $month)
|
||||
*/
|
||||
function getSmallCalendar(/* [$year, $month] */)
|
||||
{
|
||||
if (func_num_args() == 2) {
|
||||
$year = func_get_arg(0);
|
||||
$month = func_get_arg(1);
|
||||
} else {
|
||||
$year = $this->date['year'];
|
||||
$month = $this->date['mon'];
|
||||
}
|
||||
|
||||
$name = date('F', mktime(0,0,0,$month,1,$year));
|
||||
$weekNumber = Date::getWeekNumber($year, $month, 1);
|
||||
$daysInMonth = Date::getDaysInMonth($year, $month);
|
||||
$weekDay = Date::getFirstWeekDayOfMonth($year, $month) - 1;
|
||||
|
||||
$thisDate = getdate(time());
|
||||
$thisDay = mktime(0, 0, 0, $thisDate['mon'], $thisDate['mday'], $thisDate['year']);
|
||||
$thisWeek = Date::getWeekNumber($thisDate['year'], $thisDate['mon'], $thisDate['mday']);
|
||||
|
||||
if ($year != $thisDate['year']) {
|
||||
$thisWeek = 0;
|
||||
}
|
||||
|
||||
$rc = <<<EOT
|
||||
<table class="smCalendarTable">
|
||||
<tr>
|
||||
<td class="smCalendarCell smCalendarMonthTitle" colspan="8" align="center">{$name} {$year}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="smCalendarCell smCalendarDayTitle"> </td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">Mo</td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">Tu</td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">We</td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">Th</td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">Fr</td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">Sa</td>
|
||||
<td class="smCalendarCell smCalendarDayTitle">Su</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="smCalendarCell smCalendarWeekNumber" valign='top'>{$weekNumber}</td>
|
||||
|
||||
EOT;
|
||||
|
||||
if ($weekNumber == $thisWeek) {
|
||||
$style = "smCalendarThisWeek";
|
||||
$thisDayStyle = "smCalendarThisWeek smCalendarThisDay";
|
||||
} else {
|
||||
$style = $thisDayStyle = "smCalendarDay";
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $weekDay; $i++) {
|
||||
$rc .= sprintf(
|
||||
"\t<td class='smCalendarCell %s%s'> </td>\n",
|
||||
$i == $thisDate['wday'] ? $thisDayStyle : $style,
|
||||
$i < 5 ? "" : " smCalendarWeekend"
|
||||
);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $daysInMonth; $i++, $weekDay = ($weekDay + 1) % 7) {
|
||||
if (1 < $i && $weekDay == 0) {
|
||||
$weekNumber = Date::getWeekNumber($year, $month, $i);
|
||||
|
||||
$week = $weekNumber < 10 ? " {$weekNumber}" : $weekNumber;
|
||||
$rc .= "</tr>\n<tr>\n\t<td class='smCalendarCell smCalendarWeekNumber' valign='top'>{$week}</td>\n";
|
||||
if ($weekNumber == $thisWeek) {
|
||||
$style = "smCalendarThisWeek";
|
||||
$thisDayStyle = "smCalendarThisWeek smCalendarThisDay";
|
||||
} else {
|
||||
$style = $thisDayStyle = "smCalendarDay";
|
||||
}
|
||||
}
|
||||
|
||||
$key = sprintf("%04d-02d-02d", $year, $month, $i);
|
||||
|
||||
$rc .= sprintf(
|
||||
"\t<td class='smCalendarCell %s%s' valign='top'><span class='smCalendarNumber'>%d</span></td>\n",
|
||||
$i == $thisDate['mday'] ? $thisDayStyle : $style,
|
||||
$weekDay < 5 ? "" : " smCalendarWeekend", $i
|
||||
);
|
||||
}
|
||||
|
||||
for ( ; $weekDay != 0; $weekDay = ($weekDay + 1) % 7) {
|
||||
$rc .= sprintf(
|
||||
"\t<td class='smCalendarCell %s'> </td>\n",
|
||||
$weekDay < 5 ? "smCalendarDay" : "smCalendarWeekend"
|
||||
);
|
||||
}
|
||||
|
||||
$rc .= "</tr>\n</table>\n";
|
||||
|
||||
return $rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* $obj->getLargeCalendar($notes)
|
||||
* Date::getLargeCalendar($notes, $year, $month)
|
||||
*/
|
||||
function getLargeCalendar(/* $notes [, $year, $month] */)
|
||||
{
|
||||
switch (func_num_args()) {
|
||||
case 3:
|
||||
$notes = func_get_arg(0);
|
||||
$year = func_get_arg(1);
|
||||
$month = func_get_arg(2);
|
||||
break;
|
||||
case 1:
|
||||
$notes = func_get_arg(0);
|
||||
$year = $this->date['year'];
|
||||
$month = $this->date['mon'];
|
||||
break;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
$name = date('F', mktime(0,0,0,$month,1,$year));
|
||||
$weekNumber = Date::getWeekNumber($year, $month, 1);
|
||||
$daysInMonth = Date::getDaysInMonth($year, $month);
|
||||
$weekDay = Date::getFirstWeekDayOfMonth($year, $month) - 1;
|
||||
|
||||
$thisDate = getdate(time());
|
||||
$thisDay = mktime(0, 0, 0, $thisDate['mon'], $thisDate['mday'], $thisDate['year']);
|
||||
$thisWeek = Date::getWeekNumber($thisDate['year'], $thisDate['mon'], $thisDate['mday']);
|
||||
|
||||
if ($year != $thisDate['year']) {
|
||||
$thisWeek = 0;
|
||||
}
|
||||
|
||||
$rc = <<<EOT
|
||||
<table class="lgCalendarTable">
|
||||
<tr>
|
||||
<td class="lgCalendarCell lgCalendarMonthTitle" colspan="8" align="center">{$name} {$year}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="2%">W</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">Mo</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">Tu</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">We</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">Th</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">Fr</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">Sa</td>
|
||||
<td class="lgCalendarCell lgCalendarDayTitle" width="14%">Su</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="lgCalendarCell lgCalendarWeekNumber" valign='top' style='padding-left: 0; padding-right: 1;'><img align='left' width='1' height='80' src='pixel.gif'>{$weekNumber}</td>
|
||||
|
||||
EOT;
|
||||
|
||||
if ($weekNumber == $thisWeek) {
|
||||
$style = "lgCalendarThisWeek";
|
||||
$thisDayStyle = "lgCalendarThisWeek lgCalendarThisDay";
|
||||
} else {
|
||||
$style = $thisDayStyle = "lgCalendarDay";
|
||||
}
|
||||
|
||||
for ($i = 0; $i < $weekDay; $i++) {
|
||||
$rc .= sprintf(
|
||||
"\t<td class='lgCalendarCell %s%s'> </td>\n",
|
||||
$i == $thisDate['wday'] ? $thisDayStyle : $style,
|
||||
$i < 5 ? "" : " lgCalendarWeekend"
|
||||
);
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= $daysInMonth; $i++, $weekDay = ($weekDay + 1) % 7) {
|
||||
if (1 < $i && $weekDay == 0) {
|
||||
$weekNumber = Date::getWeekNumber($year, $month, $i);
|
||||
|
||||
$week = $weekNumber < 10 ? " {$weekNumber}" : $weekNumber;
|
||||
$rc .= "</tr>\n<tr>\n\t<td class='lgCalendarCell lgCalendarWeekNumber' valign='top' style='padding-left: 0; padding-right: 1;'><img align='left' width='1' height='80' src='pixel.gif'>{$week}</td>\n";
|
||||
if ($weekNumber == $thisWeek) {
|
||||
$style = "lgCalendarThisWeek";
|
||||
$thisDayStyle = "lgCalendarThisWeek lgCalendarThisDay";
|
||||
} else {
|
||||
$style = $thisDayStyle = "lgCalendarDay";
|
||||
}
|
||||
}
|
||||
|
||||
$key = sprintf("%04d-%02d-%02d", $year, $month, $i);
|
||||
|
||||
$rc .= sprintf(
|
||||
"\t<td class='lgCalendarCell %s%s' valign='top' style='text-align: left;'><span class='lgCalendarNumber'>%d </span>%s</td>\n",
|
||||
$i == $thisDate['mday'] ? $thisDayStyle : $style,
|
||||
$weekDay < 5 ? "" : " lgCalendarWeekend",
|
||||
$i, isset($notes[$key]) ? $notes[$key] : ''
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
for ( ; $weekDay != 0; $weekDay = ($weekDay + 1) % 7) {
|
||||
$rc .= sprintf(
|
||||
"\t<td class='lgCalendarCell %s'> </td>\n",
|
||||
$weekDay < 5 ? "lgCalendarDay" : "lgCalendarWeekend"
|
||||
);
|
||||
}
|
||||
|
||||
$rc .= "</tr>\n</table>\n";
|
||||
|
||||
return $rc;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/php
|
||||
<?
|
||||
header("HTTP/1.0 299 OK");
|
||||
header("Content-Type: text/html");
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - A Calendar Generator in PHP
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
<style>
|
||||
<!--
|
||||
.smCalendarTable {
|
||||
font-family: Arial, Verdana, Helvetica, sans-serif;
|
||||
font-size: 9pt;
|
||||
border-spacing: 0;
|
||||
border-width: 1;
|
||||
border-style: groove;
|
||||
}
|
||||
.smCalendarCell {
|
||||
padding: 3;
|
||||
text-align: right;
|
||||
}
|
||||
.smCalendarMonthTitle {
|
||||
color: #ff0000;
|
||||
text-align: center;
|
||||
border-collapse: collapse;
|
||||
border-color: #000000;
|
||||
border-width: 2 0 0 0;
|
||||
border-style: solid;
|
||||
}
|
||||
.smCalendarDayTitle {
|
||||
color: #0000cc;
|
||||
text-align: center;
|
||||
border-collapse: collapse;
|
||||
border-color: #000000;
|
||||
border-width: 1 0 1 0;
|
||||
border-style: solid;
|
||||
}
|
||||
.smCalendarWeekNumber {
|
||||
color: #cc00cc;
|
||||
font-weight: bold;
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
.smCalendarDay {
|
||||
color: #0000cc;
|
||||
}
|
||||
.smCalendarWeekend {
|
||||
color: #0000cc;
|
||||
background-color: #cae4ff;
|
||||
}
|
||||
.smCalendarThisWeek {
|
||||
color: #0000cc;
|
||||
background-color: #ffcccc;
|
||||
}
|
||||
.smCalendarThisDay {
|
||||
padding: 1;
|
||||
border-color: #ff0000;
|
||||
border-width: 2;
|
||||
border-style: solid;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<div align="center">
|
||||
<table border="0" cellspacing="0" cellpadding="5">
|
||||
<h2>A Calendar Generator in PHP</h2>
|
||||
<?
|
||||
include('Date.php');
|
||||
$date = new Date();
|
||||
|
||||
for ($i = 0; $i < 12; $i++) {
|
||||
if ($i % 4 == 0)
|
||||
print("<tr valign='top'>\n");
|
||||
|
||||
print("<td>");
|
||||
print Date::getSmallCalendar($date->getYear(), $i+1);
|
||||
print("</td>\n");
|
||||
|
||||
if ($i % 4 == 3)
|
||||
print("</tr>\n");
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,106 @@
|
||||
#!@php_exe@
|
||||
<?
|
||||
header("HTTP/1.0 299 OK");
|
||||
header("Content-Type: text/html");
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - A Calendar Generator in PHP
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
<style>
|
||||
<!--
|
||||
.smCalendarTable {
|
||||
font-family: Arial, Verdana, Helvetica, sans-serif;
|
||||
font-size: 9pt;
|
||||
border-spacing: 0;
|
||||
border-width: 1;
|
||||
border-style: groove;
|
||||
}
|
||||
.smCalendarCell {
|
||||
padding: 3;
|
||||
text-align: right;
|
||||
}
|
||||
.smCalendarMonthTitle {
|
||||
color: #ff0000;
|
||||
text-align: center;
|
||||
border-collapse: collapse;
|
||||
border-color: #000000;
|
||||
border-width: 2 0 0 0;
|
||||
border-style: solid;
|
||||
}
|
||||
.smCalendarDayTitle {
|
||||
color: #0000cc;
|
||||
text-align: center;
|
||||
border-collapse: collapse;
|
||||
border-color: #000000;
|
||||
border-width: 1 0 1 0;
|
||||
border-style: solid;
|
||||
}
|
||||
.smCalendarWeekNumber {
|
||||
color: #cc00cc;
|
||||
font-weight: bold;
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
.smCalendarDay {
|
||||
color: #0000cc;
|
||||
}
|
||||
.smCalendarWeekend {
|
||||
color: #0000cc;
|
||||
background-color: #cae4ff;
|
||||
}
|
||||
.smCalendarThisWeek {
|
||||
color: #0000cc;
|
||||
background-color: #ffcccc;
|
||||
}
|
||||
.smCalendarThisDay {
|
||||
padding: 1;
|
||||
border-color: #ff0000;
|
||||
border-width: 2;
|
||||
border-style: solid;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<div align="center">
|
||||
<table border="0" cellspacing="0" cellpadding="5">
|
||||
<h2>A Calendar Generator in PHP</h2>
|
||||
<?
|
||||
include('Date.php');
|
||||
$date = new Date();
|
||||
|
||||
for ($i = 0; $i < 12; $i++) {
|
||||
if ($i % 4 == 0)
|
||||
print("<tr valign='top'>\n");
|
||||
|
||||
print("<td>");
|
||||
print Date::getSmallCalendar($date->getYear(), $i+1);
|
||||
print("</td>\n");
|
||||
|
||||
if ($i % 4 == 3)
|
||||
print("</tr>\n");
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,15 @@
|
||||
#!/usr/bin/php
|
||||
<?
|
||||
// Bug #27026: header('HTTP/1.0 200 OK') never sent when explicitly
|
||||
// requested.
|
||||
//
|
||||
// Send a 2xx status code not defined by RFC 2616. A 200 value would
|
||||
// be the correct value, but PHP/CGI refuses to send it when explicitly
|
||||
// set.
|
||||
//
|
||||
// This works for Opera 7, Mozilla 1.6, and IE 6.0 SP1.
|
||||
//
|
||||
header("HTTP/1.0 299 OK");
|
||||
phpinfo();
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
#!@php_exe@
|
||||
<?
|
||||
// Bug #27026: header('HTTP/1.0 200 OK') never sent when explicitly
|
||||
// requested.
|
||||
//
|
||||
// Send a 2xx status code not defined by RFC 2616. A 200 value would
|
||||
// be the correct value, but PHP/CGI refuses to send it when explicitly
|
||||
// set.
|
||||
//
|
||||
// This works for Opera 7, Mozilla 1.6, and IE 6.0 SP1.
|
||||
//
|
||||
header("HTTP/1.0 299 OK");
|
||||
phpinfo();
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
Hibachi - Form Processing Example in PHP
|
||||
</title>
|
||||
<meta name="description" content="Form Processing Example in PHP">
|
||||
<meta name="keywords" content="IOCCC, 2004/hibachi, from, PHP">
|
||||
</head>
|
||||
<body style="background-image: url(../../Img/hot-coal-edge-110-indent.png); padding: 0 0 0 10%;">
|
||||
|
||||
<h2>Form Processing Example in PHP</h2>
|
||||
|
||||
<p>This example takes the output of a form POST and reformats it from
|
||||
its encoded format into human readable output suitable for sending
|
||||
by email.
|
||||
</p>
|
||||
|
||||
<hr style="width:10%;text-align:left;margin-left:0">
|
||||
|
||||
<form method="POST" action="sendform.php">
|
||||
<table style="border-spacing: 0; padding: 0; margin-right:auto;">
|
||||
<tr style="vertical-align: top;">
|
||||
<td style="text-align: right;">
|
||||
Who am I?
|
||||
</td>
|
||||
<td>
|
||||
<input name="who" value="Snert" size="24">
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="vertical-align: top;">
|
||||
<td style="text-align: right;">
|
||||
What am I?
|
||||
</td>
|
||||
<td>
|
||||
<input name="what" value="A sick puppy" size="24">
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="vertical-align: top;">
|
||||
<td style="text-align: right;">
|
||||
Where am I?
|
||||
</td>
|
||||
<td>
|
||||
<textarea rows="4" cols="20" name="where" wrap="hard">I live in the south of France now.</textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="vertical-align: top;">
|
||||
<td>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<input type="submit" value="SEND">
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<hr style="width:10%;text-align:left;margin-left:0">
|
||||
|
||||
<h3>The above PHP will NOT work on on www.ioccc.org, Sorry!</h3>
|
||||
|
||||
<hr style="width:10%;text-align:left;margin-left:0">
|
||||
|
||||
<a href="../../../../index.html">Return to 2004/hibachi</a>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/php
|
||||
<?
|
||||
header("HTTP/1.0 299 OK");
|
||||
header("Content-Type: text/html");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CHANGE THE VALUES BELOW HERE
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
$SEND_TO = 'achowe@snert.com';
|
||||
$SUBJECT = 'From the web form...';
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CHANGE THE VALUES ABOVE HERE
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
$maxWidth = 0;
|
||||
|
||||
foreach ($_GET as $name => $value) {
|
||||
if ($maxWidth < strlen($name))
|
||||
$maxWidth = strlen($name);
|
||||
}
|
||||
|
||||
foreach ($_POST as $name => $value) {
|
||||
if ($maxWidth < strlen($name))
|
||||
$maxWidth = strlen($name);
|
||||
}
|
||||
|
||||
$body = '';
|
||||
$fmt = "%{$maxWidth}s: %s\n";
|
||||
|
||||
foreach ($_GET as $name => $value) {
|
||||
$body .= sprintf($fmt, $name, $value);
|
||||
}
|
||||
|
||||
foreach ($_POST as $name => $value) {
|
||||
$body .= sprintf($fmt, $name, $value);
|
||||
}
|
||||
|
||||
//mail($SEND_TO, $SUBJECT, $body);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - Form Processing Example in PHP
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<h2>Form Processing Example in PHP</h2>
|
||||
|
||||
<p>Formatted output of web form as would be seen in an email message (without decorations).
|
||||
This example does not send any actual email, though it could with some minor changes.
|
||||
</p>
|
||||
<pre>
|
||||
<?= $body; ?>
|
||||
</pre>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
#!@php_exe@
|
||||
<?
|
||||
header("HTTP/1.0 299 OK");
|
||||
header("Content-Type: text/html");
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CHANGE THE VALUES BELOW HERE
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
$SEND_TO = 'achowe@snert.com';
|
||||
$SUBJECT = 'From the web form...';
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// CHANGE THE VALUES ABOVE HERE
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
$maxWidth = 0;
|
||||
|
||||
foreach ($_GET as $name => $value) {
|
||||
if ($maxWidth < strlen($name))
|
||||
$maxWidth = strlen($name);
|
||||
}
|
||||
|
||||
foreach ($_POST as $name => $value) {
|
||||
if ($maxWidth < strlen($name))
|
||||
$maxWidth = strlen($name);
|
||||
}
|
||||
|
||||
$body = '';
|
||||
$fmt = "%{$maxWidth}s: %s\n";
|
||||
|
||||
foreach ($_GET as $name => $value) {
|
||||
$body .= sprintf($fmt, $name, $value);
|
||||
}
|
||||
|
||||
foreach ($_POST as $name => $value) {
|
||||
$body .= sprintf($fmt, $name, $value);
|
||||
}
|
||||
|
||||
//mail($SEND_TO, $SUBJECT, $body);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - Form Processing Example in PHP
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<h2>Form Processing Example in PHP</h2>
|
||||
|
||||
<p>Formatted output of web form as would be seen in an email message (without decorations).
|
||||
This example does not send any actual email, though it could with some minor changes.
|
||||
</p>
|
||||
<pre>
|
||||
<?= $body; ?>
|
||||
</pre>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
#
|
||||
# LUHN.rb
|
||||
#
|
||||
# Copyright 2000, 2004 by Anthony Howe. All rights reserved.
|
||||
#
|
||||
|
||||
class LUHN
|
||||
def LUHN.base(str, radix)
|
||||
if radix < 2 then
|
||||
return nil
|
||||
end
|
||||
|
||||
num = 0
|
||||
str.downcase!
|
||||
str.each_byte do |byte|
|
||||
i = "0123456789abcdefghijklmnopqrstuvwxyz".index(byte)
|
||||
if i.nil? || radix <= i then
|
||||
return nil
|
||||
end
|
||||
num = num * radix + i
|
||||
end
|
||||
|
||||
return num
|
||||
end
|
||||
|
||||
#
|
||||
# Internal routine that computes the LUHN sum.
|
||||
#
|
||||
# The LUHN Algorithm ("mod 10 Double-Add-Double"):
|
||||
#
|
||||
# 1. Position from right 8 7 6 5 4 3 2 1
|
||||
# ------------------------------
|
||||
# Number string 4 8 9 5 1 3 1 3
|
||||
# x2 even positions 2 1 2 1 2 1 2 1
|
||||
# ------------------------------
|
||||
# Add odd positions & 8 +8 +1+8 +5 +2 +3 +2 +3
|
||||
# add digits of doubled
|
||||
# positions
|
||||
#
|
||||
# Sum 40
|
||||
#
|
||||
# Number is valid if sum is a multiple of 10.
|
||||
#
|
||||
#
|
||||
# 2. Alpha-numeric ISIN U S 3 8 3 8 8 3 1 0 5 1
|
||||
# (ISO 6166) -----------------------------------------
|
||||
# base 36 digits 30 28 3 8 3 8 8 3 1 0 5 1
|
||||
# -----------------------------------------
|
||||
# consider digit string 3 0 2 8 3 8 3 8 8 3 1 0 5 1
|
||||
# & x2 even digits from 2 1 2 1 2 1 2 1 2 1 2 1 2 1
|
||||
# -----------------------------------------
|
||||
# 6 0 4 8 6 8 6 8 16 3 2 0 10 1
|
||||
# -----------------------------------------
|
||||
# sum the digits of 6 +0 +4 +8 +6 +8 +6 +8+1+6+3 +2 +0+1+0+1
|
||||
#
|
||||
# Sum 60
|
||||
#
|
||||
# Number is valid if sum is a multiple of 10.
|
||||
#
|
||||
def LUHN.sum(str)
|
||||
if ! str.instance_of?(String) || str.length < 1 then
|
||||
return nil
|
||||
end
|
||||
|
||||
total = 0
|
||||
even = false
|
||||
str = str.reverse.downcase
|
||||
|
||||
# Working right to left...
|
||||
str.each_byte do |byte|
|
||||
# Convert base36 digit to a base10 value.
|
||||
digit36 = base(byte.chr, 36)
|
||||
if digit36.nil? then
|
||||
return nil
|
||||
end
|
||||
|
||||
# For each base10 digit of a base36 digit...
|
||||
begin
|
||||
digit10 = digit36 % 10
|
||||
|
||||
if even then
|
||||
# Multiply even digits by 2.
|
||||
digit10 <<= 1
|
||||
|
||||
# Sum digits of product.
|
||||
if 10 <= digit10 then
|
||||
digit10 -= 9
|
||||
end
|
||||
end
|
||||
|
||||
# Add digits of product to total.
|
||||
total += digit10
|
||||
|
||||
# Next digit.
|
||||
digit36 = (digit36 / 10).floor
|
||||
|
||||
# Toggle from digit to digit.
|
||||
even = !even
|
||||
end while 0 < digit36
|
||||
end
|
||||
|
||||
return total
|
||||
end
|
||||
|
||||
#
|
||||
# Return true if the string of digits is valid.
|
||||
# Assumes LUHN check digit is right most digit.
|
||||
#
|
||||
def LUHN.valid?(str)
|
||||
if ! str.instance_of?(String) || str.length < 2 then
|
||||
return false
|
||||
end
|
||||
|
||||
total = sum(str)
|
||||
|
||||
return total.nil? ? false : (total % 10) == 0
|
||||
end
|
||||
|
||||
#
|
||||
# Return the LUHN check digit (mod 10) for the
|
||||
# given string of digits; otherwise nil on error.
|
||||
#
|
||||
def LUHN.generate(str)
|
||||
if ! str.instance_of?(String) || str.length < 1 then
|
||||
return nil
|
||||
end
|
||||
|
||||
total = sum(str + '0')
|
||||
|
||||
return total.nil? ? nil : (10 - (total % 10)) % 10
|
||||
end
|
||||
end
|
||||
|
||||
if $DEBUG && $0 == 'LUHN.rb' then
|
||||
def generate(str, expect)
|
||||
digit = LUHN.generate(str)
|
||||
puts(str + "-" + digit.to_s + ' ' + (digit == expect).to_s)
|
||||
end
|
||||
def validate(str)
|
||||
puts(str + ' ' + LUHN.valid?(str).to_s)
|
||||
end
|
||||
|
||||
generate('1', 8)
|
||||
generate('12', 5)
|
||||
generate('123', 0)
|
||||
generate('A', 9)
|
||||
generate('AB', 6)
|
||||
|
||||
validate('AB6')
|
||||
end
|
||||
@@ -0,0 +1,80 @@
|
||||
#!/usr/bin/ruby
|
||||
|
||||
require 'cgi'
|
||||
require ENV['DOCUMENT_ROOT'] + '/test/ruby/LUHN'
|
||||
|
||||
if ENV['QUERY_STRING'].nil? then
|
||||
answer = ''
|
||||
numebr = ''
|
||||
else
|
||||
query = CGI.parse(ENV['QUERY_STRING'])
|
||||
number = query['number'].to_s
|
||||
|
||||
case query['action'].to_s
|
||||
when 'Validate'
|
||||
is_valid = LUHN.valid?(number)
|
||||
answer = number
|
||||
when 'Generate'
|
||||
digit = LUHN.generate(number)
|
||||
answer = "#{number}" + digit.to_s
|
||||
is_valid = ! digit.nil?
|
||||
end
|
||||
end
|
||||
|
||||
puts <<"EOT"
|
||||
HTTP/1.0 200 OK
|
||||
Content-Type: text/html
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - Playing with LUHN checksums in Ruby
|
||||
</title>
|
||||
</head>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="500">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<h2>Playing with LUHN checksums in Ruby<br/>"mod 10 Double-Add-Double"</h2>
|
||||
<p>Enter an alpha-numeric string like a credit card number or International Securities Identification Number (ISO 6166).
|
||||
Click validate to test if the entered string is correct. Click generate to append the check digit to the string.
|
||||
</p>
|
||||
<form name="luhn" method="GET" action="index.rb">
|
||||
<textarea name="number" wrap="virtual" rows="2" cols="30">#{answer}</textarea>
|
||||
<br/><b>#{ is_valid ? "Is valid." : "Is NOT valid." }</b>
|
||||
<br/>
|
||||
<br/>
|
||||
<input type="submit" name="action" value="Validate">
|
||||
|
||||
<input type="submit" name="action" value="Generate">
|
||||
|
||||
<input type="button" value="Clear" onclick="this.form.number.value = ''">
|
||||
</form>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
EOT
|
||||
|
||||
exit(0)
|
||||
@@ -0,0 +1,80 @@
|
||||
#!@ruby_exe@
|
||||
|
||||
require 'cgi'
|
||||
require ENV['DOCUMENT_ROOT'] + '/test/ruby/LUHN'
|
||||
|
||||
if ENV['QUERY_STRING'].nil? then
|
||||
answer = ''
|
||||
numebr = ''
|
||||
else
|
||||
query = CGI.parse(ENV['QUERY_STRING'])
|
||||
number = query['number'].to_s
|
||||
|
||||
case query['action'].to_s
|
||||
when 'Validate'
|
||||
is_valid = LUHN.valid?(number)
|
||||
answer = number
|
||||
when 'Generate'
|
||||
digit = LUHN.generate(number)
|
||||
answer = "#{number}" + digit.to_s
|
||||
is_valid = ! digit.nil?
|
||||
end
|
||||
end
|
||||
|
||||
puts <<"EOT"
|
||||
HTTP/1.0 200 OK
|
||||
Content-Type: text/html
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi - Playing with LUHN checksums in Ruby
|
||||
</title>
|
||||
</head>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td>
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="500">
|
||||
<tr>
|
||||
<td>
|
||||
|
||||
<h2>Playing with LUHN checksums in Ruby<br/>"mod 10 Double-Add-Double"</h2>
|
||||
<p>Enter an alpha-numeric string like a credit card number or International Securities Identification Number (ISO 6166).
|
||||
Click validate to test if the entered string is correct. Click generate to append the check digit to the string.
|
||||
</p>
|
||||
<form name="luhn" method="GET" action="index.rb">
|
||||
<textarea name="number" wrap="virtual" rows="2" cols="30">#{answer}</textarea>
|
||||
<br/><b>#{ is_valid ? "Is valid." : "Is NOT valid." }</b>
|
||||
<br/>
|
||||
<br/>
|
||||
<input type="submit" name="action" value="Validate">
|
||||
|
||||
<input type="submit" name="action" value="Generate">
|
||||
|
||||
<input type="button" value="Clear" onclick="this.form.number.value = ''">
|
||||
</form>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
EOT
|
||||
|
||||
exit(0)
|
||||
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cat <<'EOT'
|
||||
<table border="1" cellspacing="0" cellpadding="0">
|
||||
<caption><h3>Environment Variables</h3></caption>
|
||||
EOT
|
||||
|
||||
env | sed -e 's/^\(.[^\=]*\)=\(.*\)$/<tr><td class="normal">\1<\/td><td class="normal">\2\ <\/td><\/tr>/'
|
||||
|
||||
echo "</table>"
|
||||
|
||||
if [[ -z $REQUEST_METHOD ]]; then REQUEST_METHOD=''; fi
|
||||
if [[ $REQUEST_METHOD == "POST" && -n $CONTENT_LENGTH ]]; then
|
||||
STUFF=$(dd bs=1 count="$CONTENT_LENGTH" 2>/dev/null)
|
||||
COUNT=$(printf "%s" "$STUFF" | wc -c)
|
||||
|
||||
cat <<EOT
|
||||
<table border="1" cellspacing="0" cellpadding="0">
|
||||
<caption><h3>Standard Input</h3></caption>
|
||||
<tr><td class="normal"><pre>Length: $COUNT</pre></td></tr>
|
||||
<tr><td class="normal"><pre>$STUFF</pre></td></tr>
|
||||
</table>
|
||||
EOT
|
||||
|
||||
if [[ $CONTENT_LENGTH -eq $COUNT ]]; then
|
||||
echo "[ OK ] CONTENT_LENGTH = bytes read"
|
||||
else
|
||||
echo "[ BAD ] CONTENT_LENGTH != bytes read"
|
||||
fi
|
||||
|
||||
fi
|
||||
@@ -0,0 +1,117 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cat <<'-EOT-'
|
||||
HTTP/1.0 200 OK
|
||||
Content-Type: text/html
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi/1.0 Shell Test 0 - Display Enviroment
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td class="normal">
|
||||
|
||||
<div align="center">
|
||||
<h3>Results from Simple GET request</h3>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<caption><h3>Assertions</h3></caption>
|
||||
-EOT-
|
||||
|
||||
if [[ "$PATH" == '/usr/local/bin:/usr/bin:/bin' ]]; then
|
||||
|
||||
echo "<tr><td>[ OK ] PATH</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] PATH</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $ENV ]]; then
|
||||
echo "<tr><td>[ OK ] ENV</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] ENV</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $CDPATH ]]; then
|
||||
echo "<tr><td>[ OK ] CDPATH</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] CDPATH</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $REQUEST_METHOD ]]; then REQUEST_METHOD=''; fi
|
||||
if [[ $REQUEST_METHOD == 'GET' ]]; then
|
||||
echo "<tr><td>[ OK ] REQUEST_METHOD</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] REQUEST_METHOD</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $DOCUMENT_ROOT ]]; then
|
||||
echo "<tr><td>[ OK ] DOCUMENT_ROOT</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] DOCUMENT_ROOT</td></tr>"
|
||||
fi
|
||||
|
||||
# Test for existence only, since the location changes.
|
||||
if [[ -z $SCRIPT_FILENAME ]]; then
|
||||
echo "<tr><td>[ BAD ] SCRIPT_FILENAME</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ OK ] SCRIPT_FILENAME</td></tr>"
|
||||
fi
|
||||
|
||||
# Test for existence only, since the default value might change.
|
||||
if [[ -z $SERVER_PORT ]]; then
|
||||
echo "<tr><td>[ BAD ] SERVER_PORT</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ OK ] SERVER_PORT</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $SERVER_SOFTWARE ]]; then SERVER_SOFTWARE=''; fi
|
||||
if [[ $SERVER_SOFTWARE == 'hibachi/1.0' ]]; then
|
||||
echo "<tr><td>[ OK ] SERVER_SOFTWARE</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] SERVER_SOFTWARE</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $GATEWAY_INTERFACE ]]; then GATEWAY_INTERFACE=''; fi
|
||||
if [[ $GATEWAY_INTERFACE == 'CGI/0.0' ]]; then
|
||||
echo "<tr><td>[ OK ] GATEWAY_INTERFACE</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] GATEWAY_INTERFACE</td></tr>"
|
||||
fi
|
||||
|
||||
echo "</table>"
|
||||
|
||||
if [[ -z $DOCUMENT_ROOT ]]; then DOCUMENT_ROOT='.'; fi
|
||||
# We want to source the file, but for SC1091 the file is not available at the time of this edit.
|
||||
#
|
||||
# SC1091 (info): Not following: ./test/shell/dump.sh was not specified as input (see shellcheck -x).
|
||||
# https://www.shellcheck.net/wiki/SC1091
|
||||
# shellcheck disable=SC1091
|
||||
source "$DOCUMENT_ROOT/test/shell/dump.sh"
|
||||
|
||||
cat <<'-EOT-'
|
||||
<br>
|
||||
<form method="GET" action="test1.sh">
|
||||
<b>Next Test: <input type="submit" name="example" value="GET REQUEST WITH QUERY-STRING">
|
||||
<input type="hidden" name="garibaldi" value="peek-a-boo"></b>
|
||||
</form>
|
||||
</div>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
-EOT-
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cat <<'-EOT-'
|
||||
HTTP/1.0 200 OK
|
||||
Content-Type: text/html
|
||||
Set-Cookie: cookie1=test1.sh; path=/
|
||||
Set-Cookie: cookie2=test1.sh; path=/
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi/1.0 Shell Test 1
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td class="normal">
|
||||
|
||||
<div align="center">
|
||||
<h2>Results of Form GET request</h2>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<caption><h3>Assertions</h3></caption>
|
||||
-EOT-
|
||||
|
||||
if [[ $PATH == '/usr/local/bin:/usr/bin:/bin' ]]; then
|
||||
echo "<tr><td>[ OK ] PATH</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] PATH</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $ENV ]]; then
|
||||
echo "<tr><td>[ OK ] ENV</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] ENV</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $CDPATH ]]; then
|
||||
echo "<tr><td>[ OK ] CDPATH</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] CDPATH</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $REQUEST_METHOD ]]; then REQUEST_METHOD=''; fi
|
||||
if [[ $REQUEST_METHOD == 'GET' ]]; then
|
||||
echo "<tr><td>[ OK ] REQUEST_METHOD</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] REQUEST_METHOD</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $QUERY_STRING ]]; then QUERY_STRING=''; fi
|
||||
if [[ $QUERY_STRING == 'example=GET+REQUEST+WITH+QUERY-STRING&garibaldi=peek-a-boo' ]]; then
|
||||
echo "<tr><td>[ OK ] QUERY_STRING</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] QUERY_STRING</td></tr>"
|
||||
fi
|
||||
|
||||
echo "</table>"
|
||||
|
||||
if [[ -z $DOCUMENT_ROOT ]]; then DOCUMENT_ROOT='.'; fi
|
||||
# We want to source the file, but for SC1091 the file is not available at the time of this edit.
|
||||
#
|
||||
# SC1091 (info): Not following: ./test/shell/dump.sh was not specified as input (see shellcheck -x).
|
||||
# https://www.shellcheck.net/wiki/SC1091
|
||||
# shellcheck disable=SC1091
|
||||
source "$DOCUMENT_ROOT/test/shell/dump.sh"
|
||||
|
||||
cat <<'-EOT-'
|
||||
<br>
|
||||
<form method="POST" action="test2.sh">
|
||||
<b>Next Test:</b> <input type="submit" name="example" value="POST REQUEST WITH COOKIES">
|
||||
<input type="hidden" name="hibachi" value="is not Apache">
|
||||
<input type="hidden" name="garibaldi" value="peek-a-boo">
|
||||
</form>
|
||||
</div>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
-EOT-
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
cat <<'-EOT-'
|
||||
HTTP/1.0 200 OK
|
||||
Content-Type: text/html
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>
|
||||
Hibachi/1.0 Shell Test 2
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../style.css">
|
||||
</head>
|
||||
<body background="../../Img/hot-coal-edge-110-indent.png" style="margins: 0 0 0 0; padding: 0 0 0 0;">
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
<td width="130">
|
||||
<img alt="" src="../../Img/mrpixel.gif" width="130" height="1">
|
||||
</td>
|
||||
<td class="normal">
|
||||
|
||||
<div align="center">
|
||||
<h2>Results of Form POST request</h2>
|
||||
<table border="0" cellspacing="0" cellpadding="0">
|
||||
<caption><h3>Assertions</h3></caption>
|
||||
-EOT-
|
||||
|
||||
if [[ "$PATH" = '/usr/local/bin:/usr/bin:/bin' ]]; then
|
||||
|
||||
echo "<tr><td>[ OK ] PATH</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] PATH</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z "$ENV" ]]; then
|
||||
echo "<tr><td>[ OK ] ENV</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] ENV</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z "$CDPATH" ]]; then
|
||||
echo "<tr><td>[ OK ] CDPATH</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] CDPATH</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $REQUEST_METHOD ]]; then REQUEST_METHOD=''; fi
|
||||
if [[ "$REQUEST_METHOD" = 'POST' ]]; then
|
||||
echo "<tr><td>[ OK ] REQUEST_METHOD</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] REQUEST_METHOD</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z "$QUERY_STRING" ]]; then
|
||||
echo "<tr><td>[ OK ] QUERY_STRING</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] QUERY_STRING</td></tr>"
|
||||
fi
|
||||
|
||||
if [[ -z $HTTP_COOKIE ]]; then HTTP_COOKIE=''; fi
|
||||
if [[ "$HTTP_COOKIE" == 'cookie1=test1.sh; cookie2=test1.sh' || "$HTTP_COOKIE" == 'cookie2=test1.sh; cookie1=test1.sh' ]]; then
|
||||
echo "<tr><td>[ OK ] HTTP_COOKIE</td></tr>"
|
||||
else
|
||||
echo "<tr><td>[ BAD ] HTTP_COOKIE</td></tr>"
|
||||
fi
|
||||
|
||||
echo "</table>"
|
||||
|
||||
if [[ -z $DOCUMENT_ROOT ]]; then DOCUMENT_ROOT='.'; fi
|
||||
# We want to source the file, but for SC1091 the file is not available at the time of this edit.
|
||||
#
|
||||
# SC1091 (info): Not following: ./test/shell/dump.sh was not specified as input (see shellcheck -x).
|
||||
# https://www.shellcheck.net/wiki/SC1091
|
||||
# shellcheck disable=SC1091
|
||||
source "$DOCUMENT_ROOT/test/shell/dump.sh"
|
||||
|
||||
cat <<'-EOT-'
|
||||
</div>
|
||||
<hr>
|
||||
<a href="../../#Test">Return to HIBACHI</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
-EOT-
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,184 @@
|
||||
#
|
||||
# @package_copyright@
|
||||
#
|
||||
# @configure_input@
|
||||
#
|
||||
|
||||
.POSIX :
|
||||
|
||||
########################################################################
|
||||
### Pick one that best suits your system.
|
||||
########################################################################
|
||||
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
PACKAGE = @PACKAGE_NAME@
|
||||
VERSION = @PACKAGE_VERSION@
|
||||
TARNAME = @PACKAGE_TARNAME@
|
||||
TARDIR = ../../
|
||||
SRCDIR = ./
|
||||
PKGDIR = ${PACKAGE}-${VERSION}
|
||||
|
||||
CC = @CC@
|
||||
CC_E = @CC_E@
|
||||
CC_O = @CC_O@
|
||||
CFLAGS = @CFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
|
||||
########################################################################
|
||||
### No further configuration beyond this point.
|
||||
########################################################################
|
||||
|
||||
.SUFFIXES :
|
||||
O = .@OBJEXT@
|
||||
E = @EXEEXT@
|
||||
.SUFFIXES : .c $O $E
|
||||
|
||||
TARBALL = ${TARNAME}-${VERSION}.tar
|
||||
SPOILER = ${TARNAME}.alt-${VERSION}.tar
|
||||
|
||||
#######################################################################
|
||||
|
||||
all: build
|
||||
|
||||
build : ${PACKAGE}$E ${SRCDIR}${PACKAGE}-start.sh.in mkentry$E prepare-source
|
||||
@echo
|
||||
@echo '***************************************************************'
|
||||
@echo Build ${PACKAGE}/${VERSION} DONE
|
||||
@echo '***************************************************************'
|
||||
@echo
|
||||
|
||||
clean :
|
||||
-rm -f *.o *.obj *.i *.map *.tds *.TR2 *.ilc *.ild *.ilf *.ils *.log
|
||||
-rm ${PACKAGE}$E ioccc$E mkentry$E
|
||||
@echo
|
||||
@echo '***************************************************************'
|
||||
@echo Clean ${PACKAGE}/${VERSION} DONE
|
||||
@echo '***************************************************************'
|
||||
@echo
|
||||
|
||||
distclean: clean
|
||||
-cd ${SRCDIR}; make distclean
|
||||
@echo '---------------------------------------------------------------'
|
||||
-rm -rf autom4te.cache config.status config.log ${PACKAGE}-start.sh makefile
|
||||
-rm -f $(TARDIR)$(TARBALL).gz $(TARDIR)$(SPOILER).gz ${SRCDIR}supplement.tar.gz
|
||||
@echo
|
||||
@echo '***************************************************************'
|
||||
@echo Distribution Clean ${PACKAGE}/${VERSION} DONE
|
||||
@echo '***************************************************************'
|
||||
@echo
|
||||
|
||||
nuke: distclean
|
||||
-rm -f configure ${SRCDIR}${PACKAGE}.c ${SRCDIR}configure
|
||||
@echo
|
||||
@echo '***************************************************************'
|
||||
@echo Nuke ${PACKAGE}/${VERSION} DONE
|
||||
@echo '***************************************************************'
|
||||
@echo
|
||||
|
||||
${PACKAGE}$E: ${PACKAGE}.alt.c
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) $(CC_E)${PACKAGE}$E ${PACKAGE}.alt.c $(LIBS)
|
||||
|
||||
${PACKAGE}-start.sh: ${PACKAGE}-start.sh.in config.status
|
||||
./config.status
|
||||
|
||||
${SRCDIR}${PACKAGE}.c: ${PACKAGE}.alt.c transform.sed ioccc$E
|
||||
@echo '***************************************************************'
|
||||
@sed -f transform.sed ${PACKAGE}.alt.c | ./ioccc$E | sed -e '/^[ ]*$$/d' >${SRCDIR}${PACKAGE}.c
|
||||
@echo '***************************************************************'
|
||||
|
||||
${SRCDIR}configure: ${SRCDIR}configure.in
|
||||
cd ${SRCDIR}; autoconf; chmod 755 ./configure
|
||||
|
||||
${SRCDIR}${PACKAGE}-start.sh.in: ${PACKAGE}-start.sh.in
|
||||
sed -e 's/.alt//' ${PACKAGE}-start.sh.in >${SRCDIR}${PACKAGE}-start.sh.in
|
||||
|
||||
ioccc$E: ioccc.c
|
||||
$(CC) $(CC_E)ioccc$E ioccc.c
|
||||
|
||||
mkentry$E: ${SRCDIR}IOCCC-2004/mkentry.c
|
||||
$(CC) $(CC_E)mkentry$E ${SRCDIR}IOCCC-2004/mkentry.c
|
||||
|
||||
entry: mkentry$E supplement.tar.gz ${SRCDIR}entry.0.sh
|
||||
-cd ${SRCDIR}; make distclean; sh entry.0.sh
|
||||
|
||||
supplement.tar.gz:
|
||||
-cd ${SRCDIR}; make distclean
|
||||
chmod 755 ${SRCDIR}configure
|
||||
find ${SRCDIR} -type d -exec chmod 755 \{\} \;
|
||||
find ${SRCDIR} -type f ! \( -name mkentry -o -name ioccc -o -name hibachi -o -name '*.exe' \) -exec chmod 644 \{\} \;
|
||||
find ${SRCDIR} -name '*.php' -name '*.pl' -name '*.rb' -name '*.sh' -exec chmod 755 \{\} \;
|
||||
tar -zcf ${SRCDIR}supplement.tar.gz -C ${SRCDIR} \
|
||||
configure \
|
||||
configure.in \
|
||||
makefile.in \
|
||||
${PACKAGE}-start.sh.in \
|
||||
localhost/style.css \
|
||||
localhost/index.html \
|
||||
localhost/CHANGES-OBFUSCATED.TXT \
|
||||
localhost/CHANGES-SPOILER.TXT \
|
||||
localhost/reference/rfc2616.html \
|
||||
localhost/test \
|
||||
localhost/Img/hot-coal-edge-110-indent.png \
|
||||
localhost/Img/cygwin-icon.gif \
|
||||
localhost/Img/freebsd.gif \
|
||||
localhost/Img/hibachi-256-oc-nc-300x150.gif \
|
||||
localhost/Img/logosml.256.png \
|
||||
localhost/Img/php-small-trans-light.gif \
|
||||
localhost/Img/powered-by-hibachi-150x75.png \
|
||||
localhost/Img/rectangle_power_perl.gif \
|
||||
localhost/Img/sun_logo.gif \
|
||||
localhost/Img/win.gif
|
||||
@echo
|
||||
@echo '***************************************************************'
|
||||
@ls -l ${SRCDIR}supplement.tar.gz
|
||||
@echo '***************************************************************'
|
||||
@echo
|
||||
|
||||
prepare-source: ${SRCDIR}${PACKAGE}.c ${SRCDIR}${PACKAGE}-start.sh.in ${SRCDIR}configure
|
||||
|
||||
tarball: prepare-source supplement.tar.gz
|
||||
chmod 755 ${SRCDIR}configure
|
||||
tar -cf $(TARDIR)$(TARBALL) -C $(TARDIR) \
|
||||
${PACKAGE}/configure \
|
||||
${PACKAGE}/build.txt \
|
||||
${PACKAGE}/README.TXT \
|
||||
${PACKAGE}/${PACKAGE}.c \
|
||||
${PACKAGE}/supplement.tar.gz
|
||||
@echo
|
||||
@echo '***************************************************************'
|
||||
@ls -l $(TARDIR)$(TARBALL)
|
||||
@echo '***************************************************************'
|
||||
@echo
|
||||
|
||||
pack.alt: tarball
|
||||
cp $(TARDIR)$(TARBALL) $(TARDIR)$(SPOILER)
|
||||
chmod 755 configure
|
||||
tar -rf $(TARDIR)$(SPOILER) -C $(TARDIR) \
|
||||
${PACKAGE}/IOCCC-2004 \
|
||||
${PACKAGE}/src-alt/ioccc.c \
|
||||
${PACKAGE}/src-alt/configure \
|
||||
${PACKAGE}/src-alt/configure.in \
|
||||
${PACKAGE}/src-alt/makefile.in \
|
||||
${PACKAGE}/src-alt/transform.sed \
|
||||
${PACKAGE}/src-alt/${PACKAGE}.alt.c \
|
||||
${PACKAGE}/src-alt/${PACKAGE}-start.sh.in
|
||||
cd $(TARDIR); gzip $(SPOILER); md5sum $(SPOILER).gz >${PACKAGE}/localhost/${PACKAGE}.alt.md5
|
||||
@echo
|
||||
@echo '***************************************************************'
|
||||
@ls -l $(TARDIR)$(SPOILER).gz
|
||||
@echo '***************************************************************'
|
||||
@echo
|
||||
|
||||
pack-obfuscated: tarball
|
||||
cd $(TARDIR); gzip $(TARBALL); md5sum $(TARBALL).gz >${PACKAGE}/localhost/${PACKAGE}.md5
|
||||
@echo
|
||||
@echo '***************************************************************'
|
||||
@ls -l $(TARDIR)$(TARBALL).gz
|
||||
@echo '***************************************************************'
|
||||
@echo
|
||||
|
||||
|
||||
pack: pack.alt pack-obfuscated
|
||||
@@ -0,0 +1,142 @@
|
||||
#
|
||||
# Keywords & Phrases
|
||||
#
|
||||
/LOG/d
|
||||
/NDEBUG/d
|
||||
/^#if/d
|
||||
/^#endif/d
|
||||
|
||||
#s/fprintf(stderr,/G/
|
||||
#1i\
|
||||
##define G fprintf(stderr,
|
||||
|
||||
s/break;/B/
|
||||
1i\
|
||||
#define B break;
|
||||
|
||||
##s/else if (/E Q (/
|
||||
|
||||
s/if (/Q /
|
||||
1i\
|
||||
#define Q if(
|
||||
|
||||
##s/ else / E /
|
||||
##1i\
|
||||
###define E else
|
||||
|
||||
s/return/R/
|
||||
1i\
|
||||
#define R return
|
||||
|
||||
s/getenv(/V /
|
||||
1i\
|
||||
#define V getenv(
|
||||
|
||||
s/"DOCUMENT_ROOT"/T/g
|
||||
1i\
|
||||
#define T "DOCUMENT_ROOT"
|
||||
|
||||
#s/"404 Not Found"/N/g
|
||||
#1i\
|
||||
##define N "404 Not Found"
|
||||
|
||||
##s/for (/F(/
|
||||
##1i\
|
||||
###define F for
|
||||
|
||||
##s/while (/W(/
|
||||
##1i\
|
||||
###define W while
|
||||
|
||||
##s/BUFSIZ/Z/g
|
||||
##1i\
|
||||
###define Z BUFSIZ
|
||||
|
||||
s/snprintf(/S /
|
||||
1i\
|
||||
#define S snprintf(
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Constant expansion
|
||||
#
|
||||
s/NULL/0/g
|
||||
s/'\\0'/0/g
|
||||
|
||||
#
|
||||
# Functions & Types
|
||||
#
|
||||
s/print(/P(/
|
||||
s/findAndSet(/A(/
|
||||
s/status(/X(/
|
||||
|
||||
#
|
||||
# Variables
|
||||
#
|
||||
# p, c, i, j, k are used for parameters and local variables.
|
||||
#
|
||||
s/fd\([^a-z]\)/f\1/g
|
||||
s/finfo/g/g
|
||||
s/\([^a-z_]\)addr/\1a/g
|
||||
s/droot/w/g
|
||||
s/query/q/g
|
||||
s/pathtranslated/y/g
|
||||
s/pathinfo/x/g
|
||||
s/path/l/g
|
||||
s/request\[0]/*r/g
|
||||
s/request/r/g
|
||||
s/uri/u/g
|
||||
s/value/v/g
|
||||
s/client/t/g
|
||||
s/headers/o/g
|
||||
s/notfound/m/g
|
||||
s/error/e/g
|
||||
/^main/,/^}/s/argc/c/g
|
||||
/^main/,/^}/s/argv/p/g
|
||||
|
||||
s/strcspn(u,/C/
|
||||
1i\
|
||||
#define C strcspn(u,
|
||||
|
||||
#
|
||||
# Expressions
|
||||
#
|
||||
s/([a-z ]*\*) 0/0/g
|
||||
s/0 == /!/g
|
||||
#s/(0 < /(/g
|
||||
s/ != 0//g
|
||||
s/0 > //g
|
||||
#s/ < 0)/)/g
|
||||
#%s/(\([^ ][^ ]* \)== 0/(!\1/g
|
||||
# %s/ \([^ ][^ ]* \)== 0/ !\1/g
|
||||
#%s/ )/)/g
|
||||
# %s/ ;/;/g
|
||||
#%s/CHAR(\(.*\)))/\1)/g
|
||||
#%s/CHAR(\(.*\))/\1)/g
|
||||
s/R (\(.*\))/R \1/
|
||||
|
||||
|
||||
#
|
||||
# Braces
|
||||
#
|
||||
|
||||
#/[ ]{/ {
|
||||
#h
|
||||
#s/[ ]{//
|
||||
#a\
|
||||
#{
|
||||
#
|
||||
#}
|
||||
#
|
||||
|
||||
##s/^[ ]*//
|
||||
#s/^[ ]*}/}/
|
||||
#
|
||||
##/^[ ]*$/d
|
||||
|
||||
# Expand tabs...
|
||||
s/ /&&&&/g
|
||||
|
||||
# Compress tabs...
|
||||
#s/ / /g
|
||||
@@ -31,6 +31,14 @@
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "c",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "author provided unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "mynx.alt2.c",
|
||||
"inventory_order" : 40,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "c",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "alternate source code"
|
||||
},
|
||||
{
|
||||
@@ -57,6 +65,38 @@
|
||||
"display_via_github" : false,
|
||||
"entry_text" : "ISO 8859-1 entitles"
|
||||
},
|
||||
{
|
||||
"file_path" : "source-alt/transform.sed",
|
||||
"inventory_order" : 130,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "sed",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "sed(1) script for building unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "source-alt/configure",
|
||||
"inventory_order" : 150,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "pre-built configure script for unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "source-alt/configure.in",
|
||||
"inventory_order" : 150,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "GNU Autoconf script for unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "source-alt/makefile.in",
|
||||
"inventory_order" : 150,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "GNU Automake script for unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "source/configure",
|
||||
"inventory_order" : 150,
|
||||
|
||||
@@ -6,7 +6,10 @@ indent.c
|
||||
indent.o
|
||||
mynx
|
||||
mynx.alt
|
||||
mynx.alt2
|
||||
mynx.orig
|
||||
prog.orig
|
||||
source/config.*
|
||||
source/makefile
|
||||
source-alt/config.*
|
||||
source-alt/makefile
|
||||
@@ -116,8 +116,8 @@ OBJ= ${PROG}.o
|
||||
DATA= source/configure source/configure.in entities.txt source/makefile.in
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
ALT_OBJ= ${PROG}.alt.o ${PROG}.alt
|
||||
ALT_TARGET= ${PROG}.alt ${PROG}.alt2
|
||||
|
||||
|
||||
#################
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
make
|
||||
```
|
||||
|
||||
There is an alternate version that scans for (_ONLY_ scans) the string `https`
|
||||
as a starting point in case anyone wishes to add support or come up with a
|
||||
pipeline to let it work, as many websites no longer work with `http`.
|
||||
See [alternate code](#alternate-code) below.
|
||||
The author provided us with an unobfuscated version. There is also a version
|
||||
that scans (**ONLY** scans) the string `https` as a starting point in case
|
||||
anyone wishes to add support or come up with a pipeline to make it work, as many
|
||||
websites no longer work with `http`. See [alternate code](#alternate-code)
|
||||
below.
|
||||
|
||||
|
||||
### Bugs and (Mis)features:
|
||||
@@ -42,20 +43,28 @@ the issue of https.
|
||||
|
||||
## Alternate code:
|
||||
|
||||
Obviously this will not work with `https` as it only scans for `http` in the URL
|
||||
(if not specified it tries to open it as a local file). But even if it scanned
|
||||
The author's provided unobfuscated code,
|
||||
[mynx.alt.c](%%REPO_URL%%/2005/mynx/mynx.alt.c) can be compiled and evaluated if
|
||||
you wish to not try and decipher the original entry.
|
||||
|
||||
The other version, [mynx.alt2.c](%%REPO_URL%%/2005/mynx/mynx.alt2.c) is a
|
||||
starting point for anyone who wishes to come up with a version (or pipeline)
|
||||
that works with `https`.
|
||||
|
||||
Obviously this will not work with `https` without so easily as it only scans for `http` in the URL
|
||||
(if not specified it tries to open it as a local file). But even though it scans
|
||||
for `https` one would need to do more work as it would have to set up a secure
|
||||
connection before http commands could be sent. Fortunately or unfortunately
|
||||
many more websites use https so this entry will not work as well as it used to.
|
||||
many more websites use https so this entry will not work as well as it used to.
|
||||
If one were to try and connect to <https://ioccc.org> with this entry they'll
|
||||
just get a 301 error.
|
||||
|
||||
The alternate code is a starting point that scans for `https` too (note you have
|
||||
to specify the port in this case) but that is all it does. It will not work with
|
||||
https websites as it does not set up a secure connection. But should anyone wish
|
||||
to either come up with a pipeline (or some other command line) that allows it to
|
||||
work with https or to update the code to support https they may. Otherwise you
|
||||
must just appreciate the entry for what it once was.
|
||||
This alternate code is a starting point that scans for `https` too (note you
|
||||
have to specify the port in this case) but that is all it does. It will not work
|
||||
with https websites as it stands as it does not set up a secure connection. But
|
||||
should anyone wish to either come up with a pipeline (or some other command
|
||||
line) that allows it to work with https or to update the code to support https
|
||||
they may. Otherwise you must just appreciate the entry for what it once was.
|
||||
|
||||
|
||||
### Alternate build:
|
||||
@@ -67,11 +76,14 @@ must just appreciate the entry for what it once was.
|
||||
|
||||
### Alternate use:
|
||||
|
||||
Use `mynx.alt` as you would `mynx`. You'd have to specify a port at the end of
|
||||
the URL like:
|
||||
Use `mynx.alt` as you would `mynx`.
|
||||
|
||||
For the version that also scans for `https` you'll have to specify a port at the
|
||||
end of the URL like:
|
||||
|
||||
|
||||
``` <!---sh-->
|
||||
./mynx.alt https://www.ioccc.org:443
|
||||
./mynx.alt2 https://www.ioccc.org:443
|
||||
```
|
||||
|
||||
but again unless you have a clever workaround or hack to the problem, this sadly
|
||||
|
||||
@@ -403,10 +403,11 @@ Location: <a href="../../location.html#CA">CA</a> - <em>Canada</em></li>
|
||||
<!-- BEFORE: 1st line of markdown file: 2005/mynx/README.md -->
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<pre><code> make</code></pre>
|
||||
<p>There is an alternate version that scans for (<em>ONLY</em> scans) the string <code>https</code>
|
||||
as a starting point in case anyone wishes to add support or come up with a
|
||||
pipeline to let it work, as many websites no longer work with <code>http</code>.
|
||||
See <a href="#alternate-code">alternate code</a> below.</p>
|
||||
<p>The author provided us with an unobfuscated version. There is also a version
|
||||
that scans (<strong>ONLY</strong> scans) the string <code>https</code> as a starting point in case
|
||||
anyone wishes to add support or come up with a pipeline to make it work, as many
|
||||
websites no longer work with <code>http</code>. See <a href="#alternate-code">alternate code</a>
|
||||
below.</p>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
<pre><code> STATUS: INABIAF - please DO NOT fix</code></pre>
|
||||
@@ -420,25 +421,32 @@ the issue of https.</p>
|
||||
|
||||
./mynx manual.html</code></pre>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>Obviously this will not work with <code>https</code> as it only scans for <code>http</code> in the URL
|
||||
(if not specified it tries to open it as a local file). But even if it scanned
|
||||
<p>The author’s provided unobfuscated code,
|
||||
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/mynx.alt.c">mynx.alt.c</a> can be compiled and evaluated if
|
||||
you wish to not try and decipher the original entry.</p>
|
||||
<p>The other version, <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/mynx.alt2.c">mynx.alt2.c</a> is a
|
||||
starting point for anyone who wishes to come up with a version (or pipeline)
|
||||
that works with <code>https</code>.</p>
|
||||
<p>Obviously this will not work with <code>https</code> without so easily as it only scans for <code>http</code> in the URL
|
||||
(if not specified it tries to open it as a local file). But even though it scans
|
||||
for <code>https</code> one would need to do more work as it would have to set up a secure
|
||||
connection before http commands could be sent. Fortunately or unfortunately
|
||||
many more websites use https so this entry will not work as well as it used to.
|
||||
If one were to try and connect to <a href="https://ioccc.org" class="uri">https://ioccc.org</a> with this entry they’ll
|
||||
just get a 301 error.</p>
|
||||
<p>The alternate code is a starting point that scans for <code>https</code> too (note you have
|
||||
to specify the port in this case) but that is all it does. It will not work with
|
||||
https websites as it does not set up a secure connection. But should anyone wish
|
||||
to either come up with a pipeline (or some other command line) that allows it to
|
||||
work with https or to update the code to support https they may. Otherwise you
|
||||
must just appreciate the entry for what it once was.</p>
|
||||
<p>This alternate code is a starting point that scans for <code>https</code> too (note you
|
||||
have to specify the port in this case) but that is all it does. It will not work
|
||||
with https websites as it stands as it does not set up a secure connection. But
|
||||
should anyone wish to either come up with a pipeline (or some other command
|
||||
line) that allows it to work with https or to update the code to support https
|
||||
they may. Otherwise you must just appreciate the entry for what it once was.</p>
|
||||
<h3 id="alternate-build">Alternate build:</h3>
|
||||
<pre><code> make alt</code></pre>
|
||||
<h3 id="alternate-use">Alternate use:</h3>
|
||||
<p>Use <code>mynx.alt</code> as you would <code>mynx</code>. You’d have to specify a port at the end of
|
||||
the URL like:</p>
|
||||
<pre><code> ./mynx.alt https://www.ioccc.org:443</code></pre>
|
||||
<p>Use <code>mynx.alt</code> as you would <code>mynx</code>.</p>
|
||||
<p>For the version that also scans for <code>https</code> you’ll have to specify a port at the
|
||||
end of the URL like:</p>
|
||||
<pre><code> ./mynx.alt2 https://www.ioccc.org:443</code></pre>
|
||||
<p>but again unless you have a clever workaround or hack to the problem, this sadly
|
||||
won’t work.</p>
|
||||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||||
@@ -488,10 +496,15 @@ command sequence would be:</p>
|
||||
<ul>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/mynx.c">mynx.c</a> - entry source code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/Makefile">Makefile</a> - entry Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/mynx.alt.c">mynx.alt.c</a> - alternate source code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/mynx.alt2.c">mynx.alt2.c</a> - alternate source code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/mynx.alt.c">mynx.alt.c</a> - author provided unobfuscated code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/mynx.orig.c">mynx.orig.c</a> - original source code</li>
|
||||
<li><a href="manual.html">manual.html</a> - manual for the Mynx web browser</li>
|
||||
<li><a href="entities.txt">entities.txt</a> - ISO 8859-1 entitles</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/source-alt/transform.sed">source-alt/transform.sed</a> - sed(1) script for building unobfuscated code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/source-alt/configure">source-alt/configure</a> - pre-built configure script for unobfuscated code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/source-alt/configure.in">source-alt/configure.in</a> - GNU Autoconf script for unobfuscated code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/source-alt/makefile.in">source-alt/makefile.in</a> - GNU Automake script for unobfuscated code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/source/configure">source/configure</a> - pre-built configure script</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/source/configure.in">source/configure.in</a> - GNU Autoconf script</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/source/makefile.in">source/makefile.in</a> - GNU Automake script</li>
|
||||
|
||||
@@ -1,224 +1,400 @@
|
||||
#define I int
|
||||
#define c char *
|
||||
#define G fscanf(f,
|
||||
#define W while(
|
||||
#define k return
|
||||
#define Q if(
|
||||
#define Z 512
|
||||
/*
|
||||
* mynx.c
|
||||
*
|
||||
* Copyright 2005 by Anthony Howe. All rights reserved.
|
||||
*/
|
||||
|
||||
#define LENGTH 512
|
||||
|
||||
/***********************************************************************
|
||||
*** No configuration below this point.
|
||||
***********************************************************************/
|
||||
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__WIN32__) || defined(__CYGWIN__)
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#ifdef ORIGINAL_VERSION
|
||||
#define EISCONN WSAEISCONN
|
||||
#define EINPROGRESS WSAEINPROGRESS
|
||||
#define UPDATE_ERRNO if (errno == 0) errno = WSAGetLastError()
|
||||
#endif
|
||||
#else
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#define UPDATE_ERRNO
|
||||
#define SOCKET int
|
||||
#define closesocket close
|
||||
|
||||
/* The ioctl() TIOCGWINSZ call return the same information in the same
|
||||
* order for Linux, System V, abd *BSD, but for some stupid reason they
|
||||
* can't agree on a standard structure name. Fuck'em.
|
||||
*
|
||||
* Linux, System V:
|
||||
*
|
||||
* struct winsize {
|
||||
* unsigned short ws_row;
|
||||
* unsigned short ws_col;
|
||||
* unsigned short ws_xpixel;
|
||||
* unsigned short ws_ypixel;
|
||||
* };
|
||||
*
|
||||
*
|
||||
* OpenBSD
|
||||
*
|
||||
* struct ttysize {
|
||||
* unsigned short ts_lines;
|
||||
* unsigned short ts_cols;
|
||||
* unsigned short ts_xxx;
|
||||
* unsigned short ts_yyy;
|
||||
* };
|
||||
*/
|
||||
#include <sys/ioctl.h>
|
||||
FILE *f;
|
||||
short w[4] = { 24, 80 };
|
||||
I L, B, r, H;
|
||||
c l[Z], b[Z], s[Z], S[Z][10], T[Z], h[Z];
|
||||
I
|
||||
e(c s)
|
||||
#endif
|
||||
|
||||
#define peek(f) ungetc(fgetc(f), f)
|
||||
|
||||
FILE *fp;
|
||||
|
||||
short winsz[4] = { 24, 80 };
|
||||
int linksLength, bufferLength, row, port;
|
||||
char *links[LENGTH], buffer[BUFSIZ], fmtbuf[BUFSIZ], entities[LENGTH][10], text[LENGTH], host[LENGTH];
|
||||
|
||||
int
|
||||
entity(char *s)
|
||||
{
|
||||
I n = 0;
|
||||
Q *s == '#')
|
||||
k (I) strtol(s+1, 0, 0);
|
||||
W n < Z) {
|
||||
Q *S[n] && !strcmp(s, S[n]+1))
|
||||
k *S[n];
|
||||
int n = 0;
|
||||
|
||||
if (*s == '#')
|
||||
return (int) strtol(s+1, NULL, 0);
|
||||
|
||||
while (n < LENGTH) {
|
||||
if (*entities[n] != '\0' && strcmp(s, entities[n]+1) == 0)
|
||||
return *entities[n];
|
||||
n++;
|
||||
}
|
||||
k '?';
|
||||
|
||||
return '?';
|
||||
}
|
||||
|
||||
/*
|
||||
* Line wrap print controller.
|
||||
*/
|
||||
void
|
||||
P(I x)
|
||||
printc(int ch)
|
||||
{
|
||||
Q x == '\n' || w[1] - 3 < B) {
|
||||
b[B] = 0;
|
||||
b[B+1] = 0;
|
||||
B = printf("%s", b);
|
||||
B = snprintf(
|
||||
b, Z,
|
||||
"\n %s",
|
||||
b + B + 1
|
||||
/* Flush current line buffer. */
|
||||
if (ch == '\n' || winsz[1] - 3 < bufferLength) {
|
||||
buffer[bufferLength] = '\0';
|
||||
buffer[bufferLength+1] = '\0';
|
||||
bufferLength = printf("%s", buffer);
|
||||
bufferLength = snprintf(
|
||||
buffer, BUFSIZ,
|
||||
"\n %s",
|
||||
buffer + bufferLength + 1
|
||||
);
|
||||
r++;
|
||||
row++;
|
||||
}
|
||||
Q b[B-1] != ' ' || !isspace(x)) {
|
||||
b[B++] = isspace(x) ? ' ' : x;
|
||||
Q w[1] - 3 < B)
|
||||
*strrchr(b, ' ') = 0;
|
||||
|
||||
/* Compact whitespace. */
|
||||
if (buffer[bufferLength-1] != ' ' || !isspace(ch)) {
|
||||
/* Append character to line wrap buffer. */
|
||||
buffer[bufferLength++] = isspace(ch) ? ' ' : ch;
|
||||
|
||||
/* If we've exceed the screen width, wrap just before previous word. */
|
||||
if (winsz[1] - 3 < bufferLength)
|
||||
*strrchr(buffer, ' ') = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
p(c t, ...)
|
||||
prints(char *fmt, ...)
|
||||
{
|
||||
va_list x;
|
||||
va_start(x, t);
|
||||
vsnprintf(s, Z, t, x);
|
||||
t = s;
|
||||
W *t)
|
||||
P(*t++);
|
||||
va_end(x);
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(fmtbuf, LENGTH, fmt, args);
|
||||
fmt = fmtbuf;
|
||||
while (*fmt != '\0')
|
||||
printc(*fmt++);
|
||||
va_end(args);
|
||||
}
|
||||
I
|
||||
X(c s)
|
||||
|
||||
/*
|
||||
* Find the next occurence of string. If the string is not found.
|
||||
* rewind to the file pointer to its starting point.
|
||||
*
|
||||
* @param fp
|
||||
* File pointer to scan through.
|
||||
*
|
||||
* @param s
|
||||
* The string to match. An astrisk '*' acts as wildcard,
|
||||
* scanning over zero or more bytes:
|
||||
*
|
||||
* "abc" match "abc" at the current offset
|
||||
*
|
||||
* "*abc" find "abc" from the current offset.
|
||||
*
|
||||
* "abc*def" match "abc", then find "def".
|
||||
*
|
||||
* "*abc*def" find "abc", then find "def"
|
||||
*
|
||||
* @return
|
||||
* True on a successful match.
|
||||
*/
|
||||
int
|
||||
fnext(char *s)
|
||||
{
|
||||
I x;
|
||||
c t = s;
|
||||
long m = ftell(f);
|
||||
W *t && (x = fgetc(f)) != EOF) {
|
||||
Q *t == '*')
|
||||
int ch;
|
||||
char *t = s;
|
||||
long mark = ftell(fp);
|
||||
|
||||
while (*t != '\0' && (ch = fgetc(fp)) != EOF) {
|
||||
if (*t == '*')
|
||||
s = t++;
|
||||
Q tolower(x) != *t) {
|
||||
Q *s != '*')
|
||||
if (tolower(ch) != *t) {
|
||||
if (*s != '*')
|
||||
break;
|
||||
t = s;
|
||||
}
|
||||
|
||||
t++;
|
||||
}
|
||||
Q *t)
|
||||
fseek(f, m, SEEK_SET);
|
||||
k !*t;
|
||||
|
||||
if (*t != '\0')
|
||||
fseek(fp, mark, SEEK_SET);
|
||||
|
||||
return *t == '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush the line wrap buffer and outdent the heading that
|
||||
* is to follow.
|
||||
*/
|
||||
void
|
||||
d(c s)
|
||||
head(char *s)
|
||||
{
|
||||
Q 4 < B)
|
||||
P('\n');
|
||||
P('\n');
|
||||
Q *s == 'h')
|
||||
B = 1;
|
||||
if (4 < bufferLength)
|
||||
printc('\n');
|
||||
printc('\n');
|
||||
if (*s == 'h')
|
||||
bufferLength = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* This used to be two functions. It handles the parsing of
|
||||
* <a href="URL">, <img alt="text", and <frame src="URL"> to
|
||||
* add links to the link table. It also handles line separation
|
||||
* for text formatting tags like </p>, <hr/>, <br/>, and some
|
||||
* some others (see tablep[] below).
|
||||
*/
|
||||
void
|
||||
a(c s)
|
||||
link(char *s)
|
||||
{
|
||||
*T = 0;
|
||||
G
|
||||
ungetc(fgetc(f), f) == '"'
|
||||
? "\"%511[^\"]"
|
||||
: "'%511[^']",
|
||||
T
|
||||
text[0] = '\0';
|
||||
fscanf(fp,
|
||||
peek(fp) == '"'
|
||||
? "\"%511[^\"]"
|
||||
: "'%511[^']",
|
||||
text
|
||||
);
|
||||
Q *s == 'a' || *s == 'f' || s[1] == 'f') {
|
||||
free(l[++L]);
|
||||
l[L] = strdup(T);
|
||||
p(" [%d] ", L);
|
||||
}
|
||||
Q *s != 'a')
|
||||
p("%s%s\n", T, *s == 'b' || s[1] == 'h' ? "" : "\n");
|
||||
X("*>");
|
||||
if (*s == 'a' || *s == 'f' || s[1] == 'f') {
|
||||
free(links[++linksLength]);
|
||||
links[linksLength] = strdup(text);
|
||||
prints(" [%d] ", linksLength);
|
||||
}
|
||||
|
||||
if (*s != 'a')
|
||||
prints("%s%s\n", text, *s == 'b' || s[1] == 'h' ? "" : "\n");
|
||||
fnext("*>");
|
||||
}
|
||||
void *Y[] = {
|
||||
"!--*-->" , 0 ,
|
||||
"a *href=" , a ,
|
||||
"ifr*src=" , a ,
|
||||
"fra*src=" , a ,
|
||||
"img*src=" , a ,
|
||||
"p*>" , d ,
|
||||
"bl*>" , d ,
|
||||
"br" , a ,
|
||||
"hr" , a ,
|
||||
"h*>" , d ,
|
||||
"/h" , a ,
|
||||
"/tr" , a ,
|
||||
"/dt" , a ,
|
||||
"/dd" , a ,
|
||||
"li*>" , d ,
|
||||
"*>" , 0 ,
|
||||
0 , 0
|
||||
|
||||
void *table[] = {
|
||||
"!--*-->" , NULL ,
|
||||
"a *href=" , link , /* Assumes space after tag name */
|
||||
"ifr*src=" , link ,
|
||||
"fra*src=" , link ,
|
||||
/* If we search for "img*alt=" and the current tag has no alt
|
||||
* attribute, then we could end up scanning over lots of text
|
||||
* and tags until we find one. An <img> can only be assured to
|
||||
* have a src attribute.
|
||||
*/
|
||||
"img*src=" , link ,
|
||||
"p*>" , head , /* Closing tag not certain. */
|
||||
"bl*>" , head ,
|
||||
"br" , link ,
|
||||
"hr" , link ,
|
||||
"h*>" , head ,
|
||||
"/h" , link ,
|
||||
"/tr" , link ,
|
||||
"/dt" , link ,
|
||||
"/dd" , link ,
|
||||
"li*>" , head , /* Closing tag not certain. */
|
||||
"*>" , NULL , /* Skip other tags. */
|
||||
NULL , NULL
|
||||
};
|
||||
I
|
||||
main(I V, c *v)
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
I x, n = 0;
|
||||
c t = v[1];
|
||||
ioctl(0, TIOCGWINSZ, w);
|
||||
f = fopen("entities.txt", "r");
|
||||
Q f) {
|
||||
W G "%s %d", S[n]+1, &x) == 2)
|
||||
*S[n++] = x;
|
||||
fclose(f);
|
||||
int ch, n = 0;
|
||||
char *url = argv[1];
|
||||
|
||||
#if defined(__WIN32__) || defined(__CYGWIN__)
|
||||
WORD version;
|
||||
WSADATA wsaData;
|
||||
|
||||
version = MAKEWORD(2, 2);
|
||||
if (WSAStartup(version, &wsaData) != 0)
|
||||
return 1;
|
||||
#else
|
||||
# ifdef TIOCGWINSZ
|
||||
ioctl(0, TIOCGWINSZ, winsz);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
fp = fopen("entities.txt", "r");
|
||||
if (fp != NULL) {
|
||||
while (fscanf(fp, "%s %d", entities[n]+1, &ch) == 2)
|
||||
*entities[n++] = ch;
|
||||
fclose(fp);
|
||||
n = 0;
|
||||
}
|
||||
W t) {
|
||||
I m = 0;
|
||||
struct hostent *y;
|
||||
struct sockaddr_in A;
|
||||
L = 0;
|
||||
B = 1;
|
||||
Q (!sscanf(t, "http://%255[^/]%n", h, &n)&&!sscanf(t,"https://%255[^/]%n",h, &n) && !*h)) {
|
||||
Q !(f = fopen(t, "rb")))
|
||||
k 1;
|
||||
goto e;
|
||||
}
|
||||
|
||||
while (url != NULL) {
|
||||
SOCKET fd = 0;
|
||||
struct hostent *he;
|
||||
struct sockaddr_in addr;
|
||||
|
||||
linksLength = 0;
|
||||
bufferLength = 1;
|
||||
|
||||
if (sscanf(url, "http://%255[^/]%n", host, &n) == 0 && *host == '\0') {
|
||||
/* Assume local file. */
|
||||
if ((fp = fopen(url, "rb")) == NULL)
|
||||
return 1;
|
||||
goto nextpage;
|
||||
}
|
||||
Q 0 < sscanf(h, "%*[^:]%n:%d", &x, &H))
|
||||
h[x] = 0;
|
||||
|
||||
/* Parse the URL into host, port, URI. */
|
||||
if (0 < sscanf(host, "%*[^:]%n:%d", &ch, &port))
|
||||
host[ch] = '\0';
|
||||
else
|
||||
H = 80;
|
||||
y = gethostbyname(h);
|
||||
Q !y)
|
||||
k 1;
|
||||
memcpy(&A.sin_addr.s_addr, y->h_addr, y->h_length);
|
||||
A.sin_port = htons( (short) H);
|
||||
A.sin_family = y->h_addrtype;
|
||||
f = tmpfile();
|
||||
Q !f)
|
||||
k 1;
|
||||
W
|
||||
port = 80;
|
||||
|
||||
/* Build the web site address. */
|
||||
he = gethostbyname(host);
|
||||
if (he == NULL)
|
||||
/* NOTE that Win32 does not handle IP address for the
|
||||
* host name and so must be handled separately, before
|
||||
* considering this a true error.
|
||||
*/
|
||||
return 1;
|
||||
|
||||
memcpy(&addr.sin_addr.s_addr, he->h_addr, he->h_length);
|
||||
addr.sin_port = htons(/* (unsigned short) */ (short) port);
|
||||
addr.sin_family = he->h_addrtype;
|
||||
|
||||
/* Create a really short lived cache file. */
|
||||
fp = tmpfile();
|
||||
if (fp == NULL)
|
||||
return 1;
|
||||
|
||||
#ifdef ORIGINAL_VERSION
|
||||
while (connect(fd = socket(addr.sin_family, SOCK_STREAM, 0),/* (struct sockaddr *) */ (void *) &addr, sizeof addr) != 0) {
|
||||
UPDATE_ERRNO;
|
||||
if (errno == EISCONN)
|
||||
break;
|
||||
if (errno != EINTR)
|
||||
goto error1;
|
||||
}
|
||||
#else
|
||||
while (
|
||||
connect(
|
||||
m = socket(
|
||||
A.sin_family, SOCK_STREAM, 0
|
||||
), (void *) &A, sizeof A
|
||||
)
|
||||
fd = socket(
|
||||
addr.sin_family, SOCK_STREAM, 0
|
||||
),/* (struct sockaddr *) */ (void *) &addr, sizeof addr
|
||||
) != 0
|
||||
|| errno == EINTR
|
||||
)
|
||||
;
|
||||
|
||||
/* This should work, because for EISCONN we break the loop
|
||||
* and proceed to send the request. For other errors, we
|
||||
* break the loop and generate another error for the send(),
|
||||
* which by passes the response and closes the socket.
|
||||
*/
|
||||
#endif
|
||||
|
||||
n = snprintf(
|
||||
b, Z,
|
||||
"GET %s%s HTTP/1.0\r\nHost: %s:%d\r\n\r\n",
|
||||
t[n] == '/' ? "" : "/", t+n, h, H
|
||||
buffer, BUFSIZ,
|
||||
"GET %s%s HTTP/1.0\r\nHost: %s:%d\r\n\r\n",
|
||||
url[n] == '/' ? "" : "/", url+n, host, port
|
||||
);
|
||||
Q send(m, b, n, 0) == n) {
|
||||
W 0 < (n = recv(m, b, Z, 0)))
|
||||
fwrite(b, 1, n, f);
|
||||
if (send(fd, buffer, n, 0) == n) {
|
||||
/* Cache the response. */
|
||||
while (0 < (n = recv(fd, buffer, BUFSIZ, 0)))
|
||||
fwrite(buffer, 1, n, fp);
|
||||
}
|
||||
close(m);
|
||||
rewind(f);
|
||||
X("*\r\n\r\n");
|
||||
e:
|
||||
r = 3;
|
||||
*b = ' ';
|
||||
W r < *w && (x = fgetc(f)) != EOF) {
|
||||
Q x == '<') {
|
||||
void **p = Y;
|
||||
W *p) {
|
||||
Q X(*p)) {
|
||||
Q p[1])
|
||||
(* (void (*)(c ))
|
||||
#ifdef ORIGINAL_VERSION
|
||||
error1:
|
||||
#else
|
||||
#endif
|
||||
closesocket(fd);
|
||||
rewind(fp);
|
||||
|
||||
/* We don't parse the response status or handle redirection,
|
||||
* since RFC 2616 stipulates for most error responses SHOULD
|
||||
* provide content explaining the error or a hypertext link
|
||||
* for the user to follow for pre HTTP/1.1 software.
|
||||
*/
|
||||
|
||||
(void) fnext("*\r\n\r\n");
|
||||
nextpage:
|
||||
row = 3;
|
||||
|
||||
/* The start of the buffer must contain a sentinel space,
|
||||
* else the printc() line wrapping can seg.fault.
|
||||
*/
|
||||
buffer[0] = ' ';
|
||||
|
||||
while (row < winsz[0] && (ch = fgetc(fp)) != EOF) {
|
||||
if (ch == '<') {
|
||||
void **p = table;
|
||||
while (*p != NULL) {
|
||||
if (fnext(*p)) {
|
||||
if (p[1] != NULL)
|
||||
(* (void (*)(char *))
|
||||
p[1])(*p);
|
||||
break;
|
||||
}
|
||||
p += 2;
|
||||
}
|
||||
} else {
|
||||
Q x == '&') {
|
||||
G "%9[^;];", T);
|
||||
x = e(T);
|
||||
}
|
||||
P(isspace(x) ? ' ' : x);
|
||||
} else {
|
||||
if (ch == '&') {
|
||||
fscanf(fp, "%9[^;];", text);
|
||||
ch = entity(text);
|
||||
}
|
||||
|
||||
printc(isspace(ch) ? ' ' : ch);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n? ");
|
||||
fflush(stdout);
|
||||
fgets(T, Z, stdin);
|
||||
Q *T == '\n')
|
||||
goto e;
|
||||
t = l[strtol(T, 0, 0)];
|
||||
fclose(f);
|
||||
|
||||
fgets(text, LENGTH, stdin);
|
||||
if (*text == '\n')
|
||||
goto nextpage;
|
||||
|
||||
url = links[strtol(text, NULL, 0)];
|
||||
fclose(fp);
|
||||
}
|
||||
k 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,400 @@
|
||||
/*
|
||||
* mynx.c
|
||||
*
|
||||
* Copyright 2005 by Anthony Howe. All rights reserved.
|
||||
*/
|
||||
|
||||
#define LENGTH 512
|
||||
|
||||
/***********************************************************************
|
||||
*** No configuration below this point.
|
||||
***********************************************************************/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__WIN32__) || defined(__CYGWIN__)
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#ifdef ORIGINAL_VERSION
|
||||
#define EISCONN WSAEISCONN
|
||||
#define EINPROGRESS WSAEINPROGRESS
|
||||
#define UPDATE_ERRNO if (errno == 0) errno = WSAGetLastError()
|
||||
#endif
|
||||
#else
|
||||
#include <netdb.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#define UPDATE_ERRNO
|
||||
#define SOCKET int
|
||||
#define closesocket close
|
||||
|
||||
/* The ioctl() TIOCGWINSZ call return the same information in the same
|
||||
* order for Linux, System V, abd *BSD, but for some stupid reason they
|
||||
* can't agree on a standard structure name. Fuck'em.
|
||||
*
|
||||
* Linux, System V:
|
||||
*
|
||||
* struct winsize {
|
||||
* unsigned short ws_row;
|
||||
* unsigned short ws_col;
|
||||
* unsigned short ws_xpixel;
|
||||
* unsigned short ws_ypixel;
|
||||
* };
|
||||
*
|
||||
*
|
||||
* OpenBSD
|
||||
*
|
||||
* struct ttysize {
|
||||
* unsigned short ts_lines;
|
||||
* unsigned short ts_cols;
|
||||
* unsigned short ts_xxx;
|
||||
* unsigned short ts_yyy;
|
||||
* };
|
||||
*/
|
||||
#include <sys/ioctl.h>
|
||||
#endif
|
||||
|
||||
#define peek(f) ungetc(fgetc(f), f)
|
||||
|
||||
FILE *fp;
|
||||
|
||||
short winsz[4] = { 24, 80 };
|
||||
int linksLength, bufferLength, row, port;
|
||||
char *links[LENGTH], buffer[BUFSIZ], fmtbuf[BUFSIZ], entities[LENGTH][10], text[LENGTH], host[LENGTH];
|
||||
|
||||
int
|
||||
entity(char *s)
|
||||
{
|
||||
int n = 0;
|
||||
|
||||
if (*s == '#')
|
||||
return (int) strtol(s+1, NULL, 0);
|
||||
|
||||
while (n < LENGTH) {
|
||||
if (*entities[n] != '\0' && strcmp(s, entities[n]+1) == 0)
|
||||
return *entities[n];
|
||||
n++;
|
||||
}
|
||||
|
||||
return '?';
|
||||
}
|
||||
|
||||
/*
|
||||
* Line wrap print controller.
|
||||
*/
|
||||
void
|
||||
printc(int ch)
|
||||
{
|
||||
/* Flush current line buffer. */
|
||||
if (ch == '\n' || winsz[1] - 3 < bufferLength) {
|
||||
buffer[bufferLength] = '\0';
|
||||
buffer[bufferLength+1] = '\0';
|
||||
bufferLength = printf("%s", buffer);
|
||||
bufferLength = snprintf(
|
||||
buffer, BUFSIZ,
|
||||
"\n %s",
|
||||
buffer + bufferLength + 1
|
||||
);
|
||||
row++;
|
||||
}
|
||||
|
||||
/* Compact whitespace. */
|
||||
if (buffer[bufferLength-1] != ' ' || !isspace(ch)) {
|
||||
/* Append character to line wrap buffer. */
|
||||
buffer[bufferLength++] = isspace(ch) ? ' ' : ch;
|
||||
|
||||
/* If we've exceed the screen width, wrap just before previous word. */
|
||||
if (winsz[1] - 3 < bufferLength)
|
||||
*strrchr(buffer, ' ') = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
prints(char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(fmtbuf, LENGTH, fmt, args);
|
||||
fmt = fmtbuf;
|
||||
while (*fmt != '\0')
|
||||
printc(*fmt++);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the next occurence of string. If the string is not found.
|
||||
* rewind to the file pointer to its starting point.
|
||||
*
|
||||
* @param fp
|
||||
* File pointer to scan through.
|
||||
*
|
||||
* @param s
|
||||
* The string to match. An astrisk '*' acts as wildcard,
|
||||
* scanning over zero or more bytes:
|
||||
*
|
||||
* "abc" match "abc" at the current offset
|
||||
*
|
||||
* "*abc" find "abc" from the current offset.
|
||||
*
|
||||
* "abc*def" match "abc", then find "def".
|
||||
*
|
||||
* "*abc*def" find "abc", then find "def"
|
||||
*
|
||||
* @return
|
||||
* True on a successful match.
|
||||
*/
|
||||
int
|
||||
fnext(char *s)
|
||||
{
|
||||
int ch;
|
||||
char *t = s;
|
||||
long mark = ftell(fp);
|
||||
|
||||
while (*t != '\0' && (ch = fgetc(fp)) != EOF) {
|
||||
if (*t == '*')
|
||||
s = t++;
|
||||
if (tolower(ch) != *t) {
|
||||
if (*s != '*')
|
||||
break;
|
||||
t = s;
|
||||
}
|
||||
|
||||
t++;
|
||||
}
|
||||
|
||||
if (*t != '\0')
|
||||
fseek(fp, mark, SEEK_SET);
|
||||
|
||||
return *t == '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* Flush the line wrap buffer and outdent the heading that
|
||||
* is to follow.
|
||||
*/
|
||||
void
|
||||
head(char *s)
|
||||
{
|
||||
if (4 < bufferLength)
|
||||
printc('\n');
|
||||
printc('\n');
|
||||
if (*s == 'h')
|
||||
bufferLength = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* This used to be two functions. It handles the parsing of
|
||||
* <a href="URL">, <img alt="text", and <frame src="URL"> to
|
||||
* add links to the link table. It also handles line separation
|
||||
* for text formatting tags like </p>, <hr/>, <br/>, and some
|
||||
* some others (see tablep[] below).
|
||||
*/
|
||||
void
|
||||
link(char *s)
|
||||
{
|
||||
text[0] = '\0';
|
||||
fscanf(fp,
|
||||
peek(fp) == '"'
|
||||
? "\"%511[^\"]"
|
||||
: "'%511[^']",
|
||||
text
|
||||
);
|
||||
if (*s == 'a' || *s == 'f' || s[1] == 'f') {
|
||||
free(links[++linksLength]);
|
||||
links[linksLength] = strdup(text);
|
||||
prints(" [%d] ", linksLength);
|
||||
}
|
||||
|
||||
if (*s != 'a')
|
||||
prints("%s%s\n", text, *s == 'b' || s[1] == 'h' ? "" : "\n");
|
||||
fnext("*>");
|
||||
}
|
||||
|
||||
void *table[] = {
|
||||
"!--*-->" , NULL ,
|
||||
"a *href=" , link , /* Assumes space after tag name */
|
||||
"ifr*src=" , link ,
|
||||
"fra*src=" , link ,
|
||||
/* If we search for "img*alt=" and the current tag has no alt
|
||||
* attribute, then we could end up scanning over lots of text
|
||||
* and tags until we find one. An <img> can only be assured to
|
||||
* have a src attribute.
|
||||
*/
|
||||
"img*src=" , link ,
|
||||
"p*>" , head , /* Closing tag not certain. */
|
||||
"bl*>" , head ,
|
||||
"br" , link ,
|
||||
"hr" , link ,
|
||||
"h*>" , head ,
|
||||
"/h" , link ,
|
||||
"/tr" , link ,
|
||||
"/dt" , link ,
|
||||
"/dd" , link ,
|
||||
"li*>" , head , /* Closing tag not certain. */
|
||||
"*>" , NULL , /* Skip other tags. */
|
||||
NULL , NULL
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
int ch, n = 0;
|
||||
char *url = argv[1];
|
||||
|
||||
#if defined(__WIN32__) || defined(__CYGWIN__)
|
||||
WORD version;
|
||||
WSADATA wsaData;
|
||||
|
||||
version = MAKEWORD(2, 2);
|
||||
if (WSAStartup(version, &wsaData) != 0)
|
||||
return 1;
|
||||
#else
|
||||
# ifdef TIOCGWINSZ
|
||||
ioctl(0, TIOCGWINSZ, winsz);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
fp = fopen("entities.txt", "r");
|
||||
if (fp != NULL) {
|
||||
while (fscanf(fp, "%s %d", entities[n]+1, &ch) == 2)
|
||||
*entities[n++] = ch;
|
||||
fclose(fp);
|
||||
n = 0;
|
||||
}
|
||||
|
||||
while (url != NULL) {
|
||||
SOCKET fd = 0;
|
||||
struct hostent *he;
|
||||
struct sockaddr_in addr;
|
||||
|
||||
linksLength = 0;
|
||||
bufferLength = 1;
|
||||
|
||||
if (sscanf(url, "http://%255[^/]%n", host, &n) == 0 && *host == '\0') {
|
||||
/* Assume local file. */
|
||||
if ((fp = fopen(url, "rb")) == NULL)
|
||||
return 1;
|
||||
goto nextpage;
|
||||
}
|
||||
|
||||
/* Parse the URL into host, port, URI. */
|
||||
if (0 < sscanf(host, "%*[^:]%n:%d", &ch, &port))
|
||||
host[ch] = '\0';
|
||||
else
|
||||
port = 80;
|
||||
|
||||
/* Build the web site address. */
|
||||
he = gethostbyname(host);
|
||||
if (he == NULL)
|
||||
/* NOTE that Win32 does not handle IP address for the
|
||||
* host name and so must be handled separately, before
|
||||
* considering this a true error.
|
||||
*/
|
||||
return 1;
|
||||
|
||||
memcpy(&addr.sin_addr.s_addr, he->h_addr, he->h_length);
|
||||
addr.sin_port = htons(/* (unsigned short) */ (short) port);
|
||||
addr.sin_family = he->h_addrtype;
|
||||
|
||||
/* Create a really short lived cache file. */
|
||||
fp = tmpfile();
|
||||
if (fp == NULL)
|
||||
return 1;
|
||||
|
||||
#ifdef ORIGINAL_VERSION
|
||||
while (connect(fd = socket(addr.sin_family, SOCK_STREAM, 0),/* (struct sockaddr *) */ (void *) &addr, sizeof addr) != 0) {
|
||||
UPDATE_ERRNO;
|
||||
if (errno == EISCONN)
|
||||
break;
|
||||
if (errno != EINTR)
|
||||
goto error1;
|
||||
}
|
||||
#else
|
||||
while (
|
||||
connect(
|
||||
fd = socket(
|
||||
addr.sin_family, SOCK_STREAM, 0
|
||||
),/* (struct sockaddr *) */ (void *) &addr, sizeof addr
|
||||
) != 0
|
||||
|| errno == EINTR
|
||||
)
|
||||
;
|
||||
|
||||
/* This should work, because for EISCONN we break the loop
|
||||
* and proceed to send the request. For other errors, we
|
||||
* break the loop and generate another error for the send(),
|
||||
* which by passes the response and closes the socket.
|
||||
*/
|
||||
#endif
|
||||
|
||||
n = snprintf(
|
||||
buffer, BUFSIZ,
|
||||
"GET %s%s HTTP/1.0\r\nHost: %s:%d\r\n\r\n",
|
||||
url[n] == '/' ? "" : "/", url+n, host, port
|
||||
);
|
||||
if (send(fd, buffer, n, 0) == n) {
|
||||
/* Cache the response. */
|
||||
while (0 < (n = recv(fd, buffer, BUFSIZ, 0)))
|
||||
fwrite(buffer, 1, n, fp);
|
||||
}
|
||||
#ifdef ORIGINAL_VERSION
|
||||
error1:
|
||||
#else
|
||||
#endif
|
||||
closesocket(fd);
|
||||
rewind(fp);
|
||||
|
||||
/* We don't parse the response status or handle redirection,
|
||||
* since RFC 2616 stipulates for most error responses SHOULD
|
||||
* provide content explaining the error or a hypertext link
|
||||
* for the user to follow for pre HTTP/1.1 software.
|
||||
*/
|
||||
|
||||
(void) fnext("*\r\n\r\n");
|
||||
nextpage:
|
||||
row = 3;
|
||||
|
||||
/* The start of the buffer must contain a sentinel space,
|
||||
* else the printc() line wrapping can seg.fault.
|
||||
*/
|
||||
buffer[0] = ' ';
|
||||
|
||||
while (row < winsz[0] && (ch = fgetc(fp)) != EOF) {
|
||||
if (ch == '<') {
|
||||
void **p = table;
|
||||
while (*p != NULL) {
|
||||
if (fnext(*p)) {
|
||||
if (p[1] != NULL)
|
||||
(* (void (*)(char *))
|
||||
p[1])(*p);
|
||||
break;
|
||||
}
|
||||
p += 2;
|
||||
}
|
||||
} else {
|
||||
if (ch == '&') {
|
||||
fscanf(fp, "%9[^;];", text);
|
||||
ch = entity(text);
|
||||
}
|
||||
|
||||
printc(isspace(ch) ? ' ' : ch);
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n? ");
|
||||
fflush(stdout);
|
||||
|
||||
fgets(text, LENGTH, stdin);
|
||||
if (*text == '\n')
|
||||
goto nextpage;
|
||||
|
||||
url = links[strtol(text, NULL, 0)];
|
||||
fclose(fp);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
#######################################################################
|
||||
# Thus it begins...
|
||||
#######################################################################
|
||||
|
||||
AC_PREREQ(2.59)
|
||||
AC_INIT(mynx, 1.0, [Public Domain 2005 by Anthony Howe.])
|
||||
|
||||
platform=`uname -s|sed -e 's/^\([[a-zA-Z0-9]]*\)[[^a-zA-Z0-9]].*/\1/'`
|
||||
echo "platform is... $platform"
|
||||
my_configure_command="$[]0 $[]@"
|
||||
|
||||
AC_CHECK_TOOL(autoconf_tool, autoconf)
|
||||
if test ${autoconf_tool:-no} != 'no' -a \( aclocal.m4 -nt configure -o configure.in -nt configure \); then
|
||||
echo 'Rebuilding the configure script first...'
|
||||
autoconf -f
|
||||
echo 'Restarting configure script...'
|
||||
echo $my_configure_command
|
||||
exec $my_configure_command
|
||||
fi
|
||||
AC_SUBST(platform, $platform)
|
||||
|
||||
#######################################################################
|
||||
# Auxliary files to be modified later
|
||||
#######################################################################
|
||||
|
||||
AC_CONFIG_SRCDIR($PACKAGE_NAME.c)
|
||||
AC_CONFIG_FILES(makefile)
|
||||
|
||||
#######################################################################
|
||||
# Configuration options
|
||||
#######################################################################
|
||||
|
||||
AC_ARG_ENABLE(w32,
|
||||
[AC_HELP_STRING([--disable-w32],[generate Cygwin binary in Cygwin environment])]
|
||||
)
|
||||
|
||||
#######################################################################
|
||||
# Setup defaults
|
||||
#######################################################################
|
||||
|
||||
if test $platform = 'CYGWIN' -a ${enable_w32:-yes} != 'no' ; then
|
||||
CFLAGS="-mno-cygwin ${CFLAGS}"
|
||||
LIBS="-lws2_32 ${LIBS}"
|
||||
fi
|
||||
|
||||
#######################################################################
|
||||
# We find things...
|
||||
#######################################################################
|
||||
|
||||
AC_PROG_CC
|
||||
|
||||
AC_HEADER_STDC
|
||||
|
||||
AC_SEARCH_LIBS(socket, [socket nsl],[AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_SOCKET])])])
|
||||
|
||||
AC_CHECK_HEADERS(
|
||||
[arpa/inet.h netdb.h netinet/in.h sys/socket.h sys/ioctl.h],
|
||||
[], [AC_MSG_FAILURE([Missing required network I/O header.], 1)]
|
||||
)
|
||||
|
||||
AC_CHECK_HEADERS([windows.h winsock2.h])
|
||||
|
||||
#######################################################################
|
||||
# Generate output.
|
||||
#######################################################################
|
||||
|
||||
AC_OUTPUT()
|
||||
|
||||
echo
|
||||
echo $PACKAGE_STRING
|
||||
echo
|
||||
AC_MSG_RESULT([ platform...: $platform])
|
||||
AC_MSG_RESULT([ prefix.....: $prefix])
|
||||
AC_MSG_RESULT([ CFLAGS.....: $CFLAGS])
|
||||
AC_MSG_RESULT([ LDFLAGS....: $LDFLAGS])
|
||||
AC_MSG_RESULT([ LIBS.......: $LIBS])
|
||||
echo
|
||||
@@ -0,0 +1,52 @@
|
||||
#
|
||||
# Public Domain 2005 by Anthony Howe.
|
||||
#
|
||||
|
||||
.POSIX :
|
||||
|
||||
########################################################################
|
||||
### No further configuration beyond this point.
|
||||
########################################################################
|
||||
|
||||
top_srcdir = ..
|
||||
PACKAGE = @PACKAGE_NAME@
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
E = @EXEEXT@
|
||||
|
||||
#######################################################################
|
||||
|
||||
build: ${PACKAGE}$E
|
||||
|
||||
clean:
|
||||
-rm ${PACKAGE}$E
|
||||
|
||||
distclean: clean
|
||||
-rm config.status configure.lineno config.log makefile
|
||||
-rm -rf autom4te.cache
|
||||
-rm ioccc$E right$E
|
||||
|
||||
${PACKAGE}$E: ${PACKAGE}.c
|
||||
${CC} ${CFLAGS} ${LDFLAGS} -o${PACKAGE} ${PACKAGE}.c ${LIBS}
|
||||
|
||||
${top_srcdir}/${PACKAGE}.c: ${PACKAGE}.c transform.sed ioccc$E ${top_srcdir}/entities.txt
|
||||
@echo '***************************************************************'
|
||||
@sed -f transform.sed ${PACKAGE}.c | ioccc$E | sed -e '/^[ ]*$$/d' >${top_srcdir}/${PACKAGE}.c
|
||||
@echo '***************************************************************'
|
||||
|
||||
${top_srcdir}/${PACKAGE}-alt.c: ${top_srcdir}/${PACKAGE}.c right$E
|
||||
right <${top_srcdir}/${PACKAGE}.c >${top_srcdir}/${PACKAGE}-alt.c
|
||||
|
||||
${top_srcdir}/entities.txt: entities.txt
|
||||
cp entities.txt ${top_srcdir}/entities.txt
|
||||
|
||||
ioccc$E: ioccc.c
|
||||
$(CC) -oioccc$E ioccc.c
|
||||
|
||||
right$E: right.c
|
||||
$(CC) -oright$E right.c
|
||||
|
||||
tar: ${top_srcdir}/entities.txt ${top_srcdir}/${PACKAGE}.c ${top_srcdir}/${PACKAGE}-alt.c
|
||||
|
||||
@@ -0,0 +1,184 @@
|
||||
#
|
||||
# Keywords & Phrases
|
||||
#
|
||||
#/LOG/d
|
||||
#/NDEBUG/d
|
||||
|
||||
/^#if/,/^#else/d
|
||||
/^#endif/d
|
||||
/UPDATE_ERRNO/d
|
||||
|
||||
#
|
||||
# Replace macros.
|
||||
#
|
||||
/^#define peek/d
|
||||
s/peek(fp)/ungetc(fgetc(fp), fp)/
|
||||
|
||||
/^#.*define closesocket/d
|
||||
s/closesocket/close/
|
||||
|
||||
/^#.*define SOCKET/d
|
||||
s/SOCKET/int/
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
s/\<int\>/I/
|
||||
1i\
|
||||
#define I int
|
||||
|
||||
s/char \*/c /
|
||||
1i\
|
||||
#define c char *
|
||||
|
||||
s/fscanf(fp,/G/
|
||||
1i\
|
||||
#define G fscanf(f,
|
||||
|
||||
#s/break;/B/
|
||||
#1i\
|
||||
##define B break;
|
||||
|
||||
#s/goto/j/
|
||||
#1i\
|
||||
##define j goto
|
||||
|
||||
s/while (/W /
|
||||
1i\
|
||||
#define W while(
|
||||
|
||||
s/return/k/
|
||||
1i\
|
||||
#define k return
|
||||
|
||||
s/if (/Q /
|
||||
1i\
|
||||
#define Q if(
|
||||
|
||||
#s/ else / E /
|
||||
#1i\
|
||||
##define E else
|
||||
|
||||
#s/fgetc(stdin)/G/
|
||||
#1i\
|
||||
##define G fgetc(stdin)
|
||||
#
|
||||
#s/fputc(\(.*\), stdout);/p(\1)/
|
||||
#1i\
|
||||
##define p(c) fputc(c, stdout);
|
||||
#
|
||||
#s/ungetc(\(.*\), stdin)/u(\1)/
|
||||
#1i\
|
||||
##define u(c) ungetc(c, stdin)
|
||||
|
||||
#
|
||||
# Constant expansion
|
||||
#
|
||||
s/LENGTH/Z/g
|
||||
s/BUFSIZ/Z/g
|
||||
s/NULL/0/g
|
||||
s/(void)//g
|
||||
s/'\\0'/0/g
|
||||
|
||||
s/bufferLength/B/g
|
||||
s/buffer/b/g
|
||||
s/\<host\>/h/g
|
||||
s/\<port\>/H/g
|
||||
s/linksLength/L/g
|
||||
s/links/l/g
|
||||
|
||||
#
|
||||
# Functions & Types
|
||||
#
|
||||
s/printc(/P(/
|
||||
s/prints(/p(/
|
||||
s/mynx(/M(/
|
||||
s/head/d/
|
||||
s/spit/D/
|
||||
s/link/a/
|
||||
s/fnext(/X(/
|
||||
s/entity(/e(/
|
||||
|
||||
#
|
||||
# Labels
|
||||
#
|
||||
s/error0/a/
|
||||
s/error1/b/
|
||||
s/error2/c/
|
||||
s/display/d/
|
||||
s/nextpage/e/
|
||||
|
||||
#
|
||||
# Variables
|
||||
#
|
||||
# n, m, *s, *t, x, y are used for parameters and local variables.
|
||||
#
|
||||
s/fmtbuf/s/g
|
||||
s/fmt/t/g
|
||||
s/args/x/g
|
||||
|
||||
s/url/t/g
|
||||
s/mark/m/g
|
||||
s/rows/R/g
|
||||
s/row/r/g
|
||||
s/cols/C/g
|
||||
s/fp/f/g
|
||||
s/fd/m/g
|
||||
s/table/Y/g
|
||||
s/text/T/g
|
||||
s/entities\[/S[/g
|
||||
s/lastspace/q/g
|
||||
s/next/N/g
|
||||
s/argc/V/g
|
||||
s/argv/v/g
|
||||
s/winsz/w/g
|
||||
|
||||
s/\<addr\>/A/g
|
||||
s/\([^t]\)ch\([^ar]\)/\1x\2/g
|
||||
s/\([^t]\)he\([^a]\)/\1y\2/g
|
||||
|
||||
#
|
||||
# Expressions
|
||||
#
|
||||
#s/([a-z ]*\*) 0/0/g
|
||||
#s/0 == /!/g
|
||||
#s/0 == /!/g
|
||||
|
||||
s/\([^ ]*[^)]\) == 0/!\1/g
|
||||
s/\([a-z]*(.*)\) == 0/!\1/g
|
||||
#s/\((.*)\) == 0/!\1/g
|
||||
|
||||
#s/0 < sscanf/sscanf/
|
||||
s/(0 < /(/g
|
||||
s/ != 0//g
|
||||
s/\([^ ]*[^[]\)\[0\]/*\1/g
|
||||
|
||||
#s/0 > //g
|
||||
#s/ < 0)/)/g
|
||||
#s/R (\(.*\))/R \1/
|
||||
|
||||
|
||||
#
|
||||
# Braces
|
||||
#
|
||||
|
||||
#/[ ]{/ {
|
||||
#h
|
||||
#s/[ ]{//
|
||||
#a\
|
||||
#{
|
||||
#
|
||||
#}
|
||||
#
|
||||
|
||||
##s/^[ ]*//
|
||||
#s/^[ ]*}/}/
|
||||
#
|
||||
##/^[ ]*$/d
|
||||
|
||||
# Expand tabs...
|
||||
#s/ /&&&&/g
|
||||
|
||||
# Compress tabs...
|
||||
#s/ / /g
|
||||
@@ -3034,6 +3034,13 @@ files and causing <code>make clobber</code> to wipe some of them out.</p>
|
||||
instead of <code>http</code> for instance). In most cases a new link or change to https was
|
||||
all that was necessary but at least one or two URLs required the Internet
|
||||
Wayback Machine.</p>
|
||||
<p>It is believed that a slight fix in the code had to be done too, possibly an
|
||||
inclusion of <code>ctype.h</code>.</p>
|
||||
<p>The author, <a href="authors.html#Anthony_C_Howe">Anthony C Howe</a>, provided an
|
||||
unobfuscated version that Cody added in, with thanks to Anthony! This also
|
||||
required a minor fix in the inclusion of <code>ctype.h</code> and various other fixes as
|
||||
well, namely to get the program to work as <code>alt</code> rather than <code>-spoiler</code> (it is
|
||||
not even known if it would work otherwise).</p>
|
||||
<div id="2004_hoyle">
|
||||
<h2 id="winning-entry-2004hoyle">Winning entry: <a href="2004/hoyle/index.html">2004/hoyle</a></h2>
|
||||
<h3 id="winning-entry-source-code-hoyle.c">Winning entry source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2004/hoyle//hoyle.c">hoyle.c</a></h3>
|
||||
@@ -3293,14 +3300,17 @@ also show correct output though.</p>
|
||||
<h2 id="winning-entry-2005mynx">Winning entry: <a href="2005/mynx/index.html">2005/mynx</a></h2>
|
||||
<h3 id="winning-entry-source-code-mynx.c">Winning entry source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx//mynx.c">mynx.c</a></h3>
|
||||
</div>
|
||||
<p><a href="#cody">Cody</a> fixed this so that the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/source/configure">configure</a> script (which is not
|
||||
needed but part of the entry) would work with compilers that have by default
|
||||
<code>-Werror</code> like <code>clang</code> in macOS.</p>
|
||||
<p>Cody also added the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/mynx.alt.c">alternate code</a> which
|
||||
<p><a href="#cody">Cody</a> fixed this so that the
|
||||
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/source/configure">configure</a> script (which is not needed
|
||||
but part of the entry) would work with compilers that have by default <code>-Werror</code>
|
||||
like <code>clang</code> in macOS.</p>
|
||||
<p>The author, <a href="authors.html#Anthony_C_Howe">Anthony C Howe</a>, provided an
|
||||
unobfuscated version that Cody added in, with thanks to Anthony!</p>
|
||||
<p>Cody also added the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/mynx/mynx.alt2.c">second alternate code</a> which
|
||||
does scan for <code>https</code>. Futile, maybe, based on how <code>https</code> is set up, in which
|
||||
case just enjoy it for what it was, without it working with websites that do not
|
||||
support <code>http</code>. But there might be some command line that will let it work that
|
||||
way or perhaps someone wants to add the necessary code.</p>
|
||||
way or perhaps someone wants to add the necessary code, updating the file.</p>
|
||||
<div id="2005_persano">
|
||||
<h2 id="winning-entry-2005persano">Winning entry: <a href="2005/persano/index.html">2005/persano</a></h2>
|
||||
<h3 id="winning-entry-source-code-persano.c">Winning entry source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2005/persano//persano.c">persano.c</a></h3>
|
||||
|
||||
@@ -3740,6 +3740,15 @@ instead of `http` for instance). In most cases a new link or change to https was
|
||||
all that was necessary but at least one or two URLs required the Internet
|
||||
Wayback Machine.
|
||||
|
||||
It is believed that a slight fix in the code had to be done too, possibly an
|
||||
inclusion of `ctype.h`.
|
||||
|
||||
The author, [Anthony C Howe](authors.html#Anthony_C_Howe), provided an
|
||||
unobfuscated version that Cody added in, with thanks to Anthony! This also
|
||||
required a minor fix in the inclusion of `ctype.h` and various other fixes as
|
||||
well, namely to get the program to work as `alt` rather than `-spoiler` (it is
|
||||
not even known if it would work otherwise).
|
||||
|
||||
|
||||
<div id="2004_hoyle">
|
||||
## Winning entry: [2004/hoyle](2004/hoyle/index.html)
|
||||
@@ -4105,15 +4114,19 @@ Cody also added the [try.sh](%%REPO_URL%%/2005/mikeash/try.sh) script.
|
||||
### Winning entry source code: [mynx.c](%%REPO_URL%%/2005/mynx//mynx.c)
|
||||
</div>
|
||||
|
||||
[Cody](#cody) fixed this so that the [configure](%%REPO_URL%%/2005/mynx/source/configure) script (which is not
|
||||
needed but part of the entry) would work with compilers that have by default
|
||||
`-Werror` like `clang` in macOS.
|
||||
[Cody](#cody) fixed this so that the
|
||||
[configure](%%REPO_URL%%/2005/mynx/source/configure) script (which is not needed
|
||||
but part of the entry) would work with compilers that have by default `-Werror`
|
||||
like `clang` in macOS.
|
||||
|
||||
Cody also added the [alternate code](%%REPO_URL%%/2005/mynx/mynx.alt.c) which
|
||||
The author, [Anthony C Howe](authors.html#Anthony_C_Howe), provided an
|
||||
unobfuscated version that Cody added in, with thanks to Anthony!
|
||||
|
||||
Cody also added the [second alternate code](%%REPO_URL%%/2005/mynx/mynx.alt2.c) which
|
||||
does scan for `https`. Futile, maybe, based on how `https` is set up, in which
|
||||
case just enjoy it for what it was, without it working with websites that do not
|
||||
support `http`. But there might be some command line that will let it work that
|
||||
way or perhaps someone wants to add the necessary code.
|
||||
way or perhaps someone wants to add the necessary code, updating the file.
|
||||
|
||||
|
||||
<div id="2005_persano">
|
||||
|
||||
@@ -1885,19 +1885,35 @@
|
||||
2004,gavin,.gitignore,4000000000,true,gitignore,true,list of files that should not be committed under git
|
||||
2004,gavin,.path,4000000000,false,path,true,directory path from top level directory
|
||||
2004,gavin,index.html,4294967295,false,html,false,this web page
|
||||
2004,hibachi,hibachi.alt.c,20,true,c,true,author provided unobfuscated code
|
||||
2004,hibachi,hibachi.c,20,true,c,true,entry source code
|
||||
2004,hibachi,Makefile,30,true,makefile,true,entry Makefile
|
||||
2004,hibachi,hibachi.orig.c,50,false,c,true,original source code
|
||||
2004,hibachi,src-alt/configure,100,true,shellscript,true,GNU Autoconf script for alt server
|
||||
2004,hibachi,src-alt/localhost/index.html,100,true,html,false,home page of alt HIBACHI web server
|
||||
2004,hibachi,src/configure,100,true,shellscript,true,GNU Autoconf script
|
||||
2004,hibachi,src/localhost/index.html,100,true,html,false,home page of HIBACHI web server
|
||||
2004,hibachi,src/localhost/index.html,100,true,html,false,home page of alt HIBACHI web server
|
||||
2004,hibachi,src-alt/IOCCC-2004/mkentry.c,120,true,c,true,IOCCC tool of 2004 to package entries
|
||||
2004,hibachi,src-alt/ioccc.c,120,true,c,true,IOCCC size tool
|
||||
2004,hibachi,src-alt/localhost/reference/rfc2616.html,125,true,html,false,RFC 2616 - Hypertext Transfer Protocol - alt server
|
||||
2004,hibachi,src-alt/localhost/test/perl/index.html,125,true,html,false,perl test page of alt HIBACHI server
|
||||
2004,hibachi,src-alt/localhost/test/php/index.php,125,true,php,true,PHP making an ISO 8601:2000 calendar for alt server
|
||||
2004,hibachi,src-alt/localhost/test/ruby/index.rb,125,true,ruby,true,ruby home page for alt server
|
||||
2004,hibachi,src-alt/localhost/test/shell/test0.sh,125,true,shellscript,true,POSIX shell CGI home page for alt server
|
||||
2004,hibachi,src/localhost/CHANGES-OBFUSCATED.TXT,125,true,text,false,obfuscated changelog for code
|
||||
2004,hibachi,src/localhost/reference/rfc2616.html,125,true,html,false,RFC 2616 - Hypertext Transfer Protocol
|
||||
2004,hibachi,src/localhost/test/perl/index.html,125,true,html,false,perl test page of HIBACHI server
|
||||
2004,hibachi,src/localhost/test/php/index.php,125,true,php,true,PHP making an ISO 8601:2000 calendar
|
||||
2004,hibachi,src/localhost/test/ruby/index.rb,125,true,ruby,true,ruby home page
|
||||
2004,hibachi,src/localhost/test/shell/test0.sh,125,true,shellscript,true,POSIX shell CGI home page
|
||||
2004,hibachi,src-alt/transform.sed,130,true,sed,true,sed(1) script for building unobfuscated code
|
||||
2004,hibachi,src-alt/hibachi-start.sh,150,true,shellscript,true,start the alt web server
|
||||
2004,hibachi,src-alt/localhost/test/perl/yahoo-ticker.pl,150,true,perl,true,stock price fetch example in Perl for alt server
|
||||
2004,hibachi,src/hibachi-start.sh,150,true,shellscript,true,start the web server
|
||||
2004,hibachi,src/localhost/test/perl/yahoo-ticker.pl,150,true,perl,true,stock price fetch example in Perl
|
||||
2004,hibachi,src-alt/configure.in,200,true,shellscript,true,GNU Autoconf script for alt server
|
||||
2004,hibachi,src-alt/hibachi-start.sh.in,200,true,shellscript,true,hibachi-start.sh declarations for alt server
|
||||
2004,hibachi,src-alt/localhost/CHANGELOG.TXT,200,true,text,false,obfuscation change log for alt server
|
||||
2004,hibachi,src/configure.in,200,true,shellscript,true,GNU Autoconf script
|
||||
2004,hibachi,src/hibachi-start.sh.in,200,true,shellscript,true,hibachi-start.sh declarations
|
||||
2004,hibachi,src/localhost/CHANGELOG.TXT,200,true,text,false,obfuscation change log
|
||||
@@ -1906,6 +1922,31 @@
|
||||
2004,hibachi,.entry.json,4000000000,true,json,true,entry summary and manifest in JSON
|
||||
2004,hibachi,.gitignore,4000000000,true,gitignore,true,list of files that should not be committed under git
|
||||
2004,hibachi,.path,4000000000,false,path,true,directory path from top level directory
|
||||
2004,hibachi,src-alt/localhost/Img/cygwin-icon.gif,4000000000,true,image,false,image for home page for alt server
|
||||
2004,hibachi,src-alt/localhost/Img/freebsd.gif,4000000000,true,image,false,image for home page for alt server
|
||||
2004,hibachi,src-alt/localhost/Img/hibachi-256-oc-nc-300x150.gif,4000000000,true,image,false,image for home page for alt server
|
||||
2004,hibachi,src-alt/localhost/Img/hot-coal-edge-110-indent.png,4000000000,true,image,false,image for home page for alt server
|
||||
2004,hibachi,src-alt/localhost/Img/logosml.256.png,4000000000,true,image,false,image for home page for alt server
|
||||
2004,hibachi,src-alt/localhost/Img/php-small-trans-light.gif,4000000000,true,image,false,image for home page for alt server
|
||||
2004,hibachi,src-alt/localhost/Img/powered-by-hibachi-150x75.png,4000000000,true,image,false,image for home page for alt server
|
||||
2004,hibachi,src-alt/localhost/Img/rectangle_power_perl.gif,4000000000,true,image,false,image for home page for alt server
|
||||
2004,hibachi,src-alt/localhost/Img/sun_logo.gif,4000000000,true,image,false,image for home page for alt server
|
||||
2004,hibachi,src-alt/localhost/Img/win.gif,4000000000,true,image,false,image for home page for alt server
|
||||
2004,hibachi,src-alt/localhost/style.css,4000000000,true,css,true,CSS for home page for alt server
|
||||
2004,hibachi,src-alt/localhost/test/perl/yahoo-ticker.pl.in,4000000000,true,perl,true,stock price fetch declarations for alt server
|
||||
2004,hibachi,src-alt/localhost/test/php/Date.php,4000000000,true,php,true,PHP example page support file for alt server
|
||||
2004,hibachi,src-alt/localhost/test/php/index_php.in,4000000000,true,php,true,PHP example page support file for alt server
|
||||
2004,hibachi,src-alt/localhost/test/php/info.php,4000000000,true,php,true,PHP example support file for alt server
|
||||
2004,hibachi,src-alt/localhost/test/php/info.php.in,4000000000,true,php,true,PHP example page support file for alt server
|
||||
2004,hibachi,src-alt/localhost/test/php/sendform.html,4000000000,true,html,false,php example page support file for alt server
|
||||
2004,hibachi,src-alt/localhost/test/php/sendform.php,4000000000,true,php,true,PHP example page support file for alt server
|
||||
2004,hibachi,src-alt/localhost/test/php/sendform.php.in,4000000000,true,php,true,PHP example page support file for alt server
|
||||
2004,hibachi,src-alt/localhost/test/ruby/LUHN.rb,4000000000,true,ruby,true,ruby example page support file for alt server
|
||||
2004,hibachi,src-alt/localhost/test/ruby/index_rb.in,4000000000,true,ruby,true,ruby example page support file for alt server
|
||||
2004,hibachi,src-alt/localhost/test/shell/dump.sh,4000000000,true,shellscript,true,POSIX shell script support file for alt server
|
||||
2004,hibachi,src-alt/localhost/test/shell/test1.sh,4000000000,true,shellscript,true,POSIX shell script support file for alt server
|
||||
2004,hibachi,src-alt/localhost/test/shell/test2.sh,4000000000,true,shellscript,true,POSIX shell script support file for alt server
|
||||
2004,hibachi,src-alt/makefile.in,4000000000,true,man,true,makefile template for alt server
|
||||
2004,hibachi,src/localhost/Img/cygwin-icon.gif,4000000000,true,image,false,image for home page
|
||||
2004,hibachi,src/localhost/Img/freebsd.gif,4000000000,true,image,false,image for home page
|
||||
2004,hibachi,src/localhost/Img/hibachi-256-oc-nc-300x150.gif,4000000000,true,image,false,image for home page
|
||||
@@ -2139,10 +2180,15 @@
|
||||
2005,mikeash,index.html,4294967295,false,html,false,this web page
|
||||
2005,mynx,mynx.c,20,true,c,true,entry source code
|
||||
2005,mynx,Makefile,30,true,makefile,true,entry Makefile
|
||||
2005,mynx,mynx.alt.c,40,true,c,true,alternate source code
|
||||
2005,mynx,mynx.alt2.c,40,true,c,true,alternate source code
|
||||
2005,mynx,mynx.alt.c,40,true,c,true,author provided unobfuscated code
|
||||
2005,mynx,mynx.orig.c,50,false,c,true,original source code
|
||||
2005,mynx,manual.html,100,true,html,false,manual for the Mynx web browser
|
||||
2005,mynx,entities.txt,120,true,text,false,ISO 8859-1 entitles
|
||||
2005,mynx,source-alt/transform.sed,130,true,sed,true,sed(1) script for building unobfuscated code
|
||||
2005,mynx,source-alt/configure,150,true,shellscript,true,pre-built configure script for unobfuscated code
|
||||
2005,mynx,source-alt/configure.in,150,true,shellscript,true,GNU Autoconf script for unobfuscated code
|
||||
2005,mynx,source-alt/makefile.in,150,true,shellscript,true,GNU Automake script for unobfuscated code
|
||||
2005,mynx,source/configure,150,true,shellscript,true,pre-built configure script
|
||||
2005,mynx,source/configure.in,150,true,shellscript,true,GNU Autoconf script
|
||||
2005,mynx,source/makefile.in,150,true,shellscript,true,GNU Automake script
|
||||
|
||||
|
@@ -1890,9 +1890,50 @@
|
||||
2004/hibachi/2004_hibachi.tar.bz2
|
||||
2004/hibachi/Makefile
|
||||
2004/hibachi/README.md
|
||||
2004/hibachi/hibachi.alt.c
|
||||
2004/hibachi/hibachi.c
|
||||
2004/hibachi/hibachi.orig.c
|
||||
2004/hibachi/index.html
|
||||
2004/hibachi/src-alt/IOCCC-2004/mkentry.c
|
||||
2004/hibachi/src-alt/configure
|
||||
2004/hibachi/src-alt/configure.in
|
||||
2004/hibachi/src-alt/hibachi-start.sh
|
||||
2004/hibachi/src-alt/hibachi-start.sh.in
|
||||
2004/hibachi/src-alt/ioccc.c
|
||||
2004/hibachi/src-alt/localhost/CHANGELOG.TXT
|
||||
2004/hibachi/src-alt/localhost/Img/cygwin-icon.gif
|
||||
2004/hibachi/src-alt/localhost/Img/freebsd.gif
|
||||
2004/hibachi/src-alt/localhost/Img/hibachi-256-oc-nc-300x150.gif
|
||||
2004/hibachi/src-alt/localhost/Img/hot-coal-edge-110-indent.png
|
||||
2004/hibachi/src-alt/localhost/Img/logosml.256.png
|
||||
2004/hibachi/src-alt/localhost/Img/php-small-trans-light.gif
|
||||
2004/hibachi/src-alt/localhost/Img/powered-by-hibachi-150x75.png
|
||||
2004/hibachi/src-alt/localhost/Img/rectangle_power_perl.gif
|
||||
2004/hibachi/src-alt/localhost/Img/sun_logo.gif
|
||||
2004/hibachi/src-alt/localhost/Img/win.gif
|
||||
2004/hibachi/src-alt/localhost/index.html
|
||||
2004/hibachi/src-alt/localhost/reference/rfc2616.html
|
||||
2004/hibachi/src-alt/localhost/style.css
|
||||
2004/hibachi/src-alt/localhost/test/perl/index.html
|
||||
2004/hibachi/src-alt/localhost/test/perl/yahoo-ticker.pl
|
||||
2004/hibachi/src-alt/localhost/test/perl/yahoo-ticker.pl.in
|
||||
2004/hibachi/src-alt/localhost/test/php/Date.php
|
||||
2004/hibachi/src-alt/localhost/test/php/index.php
|
||||
2004/hibachi/src-alt/localhost/test/php/index_php.in
|
||||
2004/hibachi/src-alt/localhost/test/php/info.php
|
||||
2004/hibachi/src-alt/localhost/test/php/info.php.in
|
||||
2004/hibachi/src-alt/localhost/test/php/sendform.html
|
||||
2004/hibachi/src-alt/localhost/test/php/sendform.php
|
||||
2004/hibachi/src-alt/localhost/test/php/sendform.php.in
|
||||
2004/hibachi/src-alt/localhost/test/ruby/LUHN.rb
|
||||
2004/hibachi/src-alt/localhost/test/ruby/index.rb
|
||||
2004/hibachi/src-alt/localhost/test/ruby/index_rb.in
|
||||
2004/hibachi/src-alt/localhost/test/shell/dump.sh
|
||||
2004/hibachi/src-alt/localhost/test/shell/test0.sh
|
||||
2004/hibachi/src-alt/localhost/test/shell/test1.sh
|
||||
2004/hibachi/src-alt/localhost/test/shell/test2.sh
|
||||
2004/hibachi/src-alt/makefile.in
|
||||
2004/hibachi/src-alt/transform.sed
|
||||
2004/hibachi/src/configure
|
||||
2004/hibachi/src/configure.in
|
||||
2004/hibachi/src/hibachi-start.sh
|
||||
@@ -2146,8 +2187,13 @@
|
||||
2005/mynx/index.html
|
||||
2005/mynx/manual.html
|
||||
2005/mynx/mynx.alt.c
|
||||
2005/mynx/mynx.alt2.c
|
||||
2005/mynx/mynx.c
|
||||
2005/mynx/mynx.orig.c
|
||||
2005/mynx/source-alt/configure
|
||||
2005/mynx/source-alt/configure.in
|
||||
2005/mynx/source-alt/makefile.in
|
||||
2005/mynx/source-alt/transform.sed
|
||||
2005/mynx/source/configure
|
||||
2005/mynx/source/configure.in
|
||||
2005/mynx/source/makefile.in
|
||||
|
||||
@@ -1890,9 +1890,50 @@
|
||||
2004/hibachi/2004_hibachi.tar.bz2
|
||||
2004/hibachi/Makefile
|
||||
2004/hibachi/README.md
|
||||
2004/hibachi/hibachi.alt.c
|
||||
2004/hibachi/hibachi.c
|
||||
2004/hibachi/hibachi.orig.c
|
||||
2004/hibachi/index.html
|
||||
2004/hibachi/src-alt/IOCCC-2004/mkentry.c
|
||||
2004/hibachi/src-alt/configure
|
||||
2004/hibachi/src-alt/configure.in
|
||||
2004/hibachi/src-alt/hibachi-start.sh
|
||||
2004/hibachi/src-alt/hibachi-start.sh.in
|
||||
2004/hibachi/src-alt/ioccc.c
|
||||
2004/hibachi/src-alt/localhost/CHANGELOG.TXT
|
||||
2004/hibachi/src-alt/localhost/Img/cygwin-icon.gif
|
||||
2004/hibachi/src-alt/localhost/Img/freebsd.gif
|
||||
2004/hibachi/src-alt/localhost/Img/hibachi-256-oc-nc-300x150.gif
|
||||
2004/hibachi/src-alt/localhost/Img/hot-coal-edge-110-indent.png
|
||||
2004/hibachi/src-alt/localhost/Img/logosml.256.png
|
||||
2004/hibachi/src-alt/localhost/Img/php-small-trans-light.gif
|
||||
2004/hibachi/src-alt/localhost/Img/powered-by-hibachi-150x75.png
|
||||
2004/hibachi/src-alt/localhost/Img/rectangle_power_perl.gif
|
||||
2004/hibachi/src-alt/localhost/Img/sun_logo.gif
|
||||
2004/hibachi/src-alt/localhost/Img/win.gif
|
||||
2004/hibachi/src-alt/localhost/index.html
|
||||
2004/hibachi/src-alt/localhost/reference/rfc2616.html
|
||||
2004/hibachi/src-alt/localhost/style.css
|
||||
2004/hibachi/src-alt/localhost/test/perl/index.html
|
||||
2004/hibachi/src-alt/localhost/test/perl/yahoo-ticker.pl
|
||||
2004/hibachi/src-alt/localhost/test/perl/yahoo-ticker.pl.in
|
||||
2004/hibachi/src-alt/localhost/test/php/Date.php
|
||||
2004/hibachi/src-alt/localhost/test/php/index.php
|
||||
2004/hibachi/src-alt/localhost/test/php/index_php.in
|
||||
2004/hibachi/src-alt/localhost/test/php/info.php
|
||||
2004/hibachi/src-alt/localhost/test/php/info.php.in
|
||||
2004/hibachi/src-alt/localhost/test/php/sendform.html
|
||||
2004/hibachi/src-alt/localhost/test/php/sendform.php
|
||||
2004/hibachi/src-alt/localhost/test/php/sendform.php.in
|
||||
2004/hibachi/src-alt/localhost/test/ruby/LUHN.rb
|
||||
2004/hibachi/src-alt/localhost/test/ruby/index.rb
|
||||
2004/hibachi/src-alt/localhost/test/ruby/index_rb.in
|
||||
2004/hibachi/src-alt/localhost/test/shell/dump.sh
|
||||
2004/hibachi/src-alt/localhost/test/shell/test0.sh
|
||||
2004/hibachi/src-alt/localhost/test/shell/test1.sh
|
||||
2004/hibachi/src-alt/localhost/test/shell/test2.sh
|
||||
2004/hibachi/src-alt/makefile.in
|
||||
2004/hibachi/src-alt/transform.sed
|
||||
2004/hibachi/src/configure
|
||||
2004/hibachi/src/configure.in
|
||||
2004/hibachi/src/hibachi-start.sh
|
||||
@@ -2146,8 +2187,13 @@
|
||||
2005/mynx/index.html
|
||||
2005/mynx/manual.html
|
||||
2005/mynx/mynx.alt.c
|
||||
2005/mynx/mynx.alt2.c
|
||||
2005/mynx/mynx.c
|
||||
2005/mynx/mynx.orig.c
|
||||
2005/mynx/source-alt/configure
|
||||
2005/mynx/source-alt/configure.in
|
||||
2005/mynx/source-alt/makefile.in
|
||||
2005/mynx/source-alt/transform.sed
|
||||
2005/mynx/source/configure
|
||||
2005/mynx/source/configure.in
|
||||
2005/mynx/source/makefile.in
|
||||
|
||||
@@ -1249,7 +1249,48 @@
|
||||
2004/hibachi/.gitignore
|
||||
2004/hibachi/Makefile
|
||||
2004/hibachi/README.md
|
||||
2004/hibachi/hibachi.alt.c
|
||||
2004/hibachi/hibachi.c
|
||||
2004/hibachi/src-alt/IOCCC-2004/mkentry.c
|
||||
2004/hibachi/src-alt/configure
|
||||
2004/hibachi/src-alt/configure.in
|
||||
2004/hibachi/src-alt/hibachi-start.sh
|
||||
2004/hibachi/src-alt/hibachi-start.sh.in
|
||||
2004/hibachi/src-alt/ioccc.c
|
||||
2004/hibachi/src-alt/localhost/CHANGELOG.TXT
|
||||
2004/hibachi/src-alt/localhost/Img/cygwin-icon.gif
|
||||
2004/hibachi/src-alt/localhost/Img/freebsd.gif
|
||||
2004/hibachi/src-alt/localhost/Img/hibachi-256-oc-nc-300x150.gif
|
||||
2004/hibachi/src-alt/localhost/Img/hot-coal-edge-110-indent.png
|
||||
2004/hibachi/src-alt/localhost/Img/logosml.256.png
|
||||
2004/hibachi/src-alt/localhost/Img/php-small-trans-light.gif
|
||||
2004/hibachi/src-alt/localhost/Img/powered-by-hibachi-150x75.png
|
||||
2004/hibachi/src-alt/localhost/Img/rectangle_power_perl.gif
|
||||
2004/hibachi/src-alt/localhost/Img/sun_logo.gif
|
||||
2004/hibachi/src-alt/localhost/Img/win.gif
|
||||
2004/hibachi/src-alt/localhost/index.html
|
||||
2004/hibachi/src-alt/localhost/reference/rfc2616.html
|
||||
2004/hibachi/src-alt/localhost/style.css
|
||||
2004/hibachi/src-alt/localhost/test/perl/index.html
|
||||
2004/hibachi/src-alt/localhost/test/perl/yahoo-ticker.pl
|
||||
2004/hibachi/src-alt/localhost/test/perl/yahoo-ticker.pl.in
|
||||
2004/hibachi/src-alt/localhost/test/php/Date.php
|
||||
2004/hibachi/src-alt/localhost/test/php/index.php
|
||||
2004/hibachi/src-alt/localhost/test/php/index_php.in
|
||||
2004/hibachi/src-alt/localhost/test/php/info.php
|
||||
2004/hibachi/src-alt/localhost/test/php/info.php.in
|
||||
2004/hibachi/src-alt/localhost/test/php/sendform.html
|
||||
2004/hibachi/src-alt/localhost/test/php/sendform.php
|
||||
2004/hibachi/src-alt/localhost/test/php/sendform.php.in
|
||||
2004/hibachi/src-alt/localhost/test/ruby/LUHN.rb
|
||||
2004/hibachi/src-alt/localhost/test/ruby/index.rb
|
||||
2004/hibachi/src-alt/localhost/test/ruby/index_rb.in
|
||||
2004/hibachi/src-alt/localhost/test/shell/dump.sh
|
||||
2004/hibachi/src-alt/localhost/test/shell/test0.sh
|
||||
2004/hibachi/src-alt/localhost/test/shell/test1.sh
|
||||
2004/hibachi/src-alt/localhost/test/shell/test2.sh
|
||||
2004/hibachi/src-alt/makefile.in
|
||||
2004/hibachi/src-alt/transform.sed
|
||||
2004/hibachi/src/configure
|
||||
2004/hibachi/src/configure.in
|
||||
2004/hibachi/src/hibachi-start.sh
|
||||
@@ -1436,7 +1477,12 @@
|
||||
2005/mynx/entities.txt
|
||||
2005/mynx/manual.html
|
||||
2005/mynx/mynx.alt.c
|
||||
2005/mynx/mynx.alt2.c
|
||||
2005/mynx/mynx.c
|
||||
2005/mynx/source-alt/configure
|
||||
2005/mynx/source-alt/configure.in
|
||||
2005/mynx/source-alt/makefile.in
|
||||
2005/mynx/source-alt/transform.sed
|
||||
2005/mynx/source/configure
|
||||
2005/mynx/source/configure.in
|
||||
2005/mynx/source/makefile.in
|
||||
|
||||