aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--README.md4
-rw-r--r--crontab1
-rw-r--r--src/nyancat.c93
-rwxr-xr-xsrc/nyancat.py6
-rwxr-xr-xsrc/reset.sh6
-rwxr-xr-xsrc/run.sh7
-rwxr-xr-xsrc/start.sh7
8 files changed, 114 insertions, 12 deletions
diff --git a/Makefile b/Makefile
index a1e89e4..1cd0530 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,8 @@ $(distdir): FORCE
cp src/nyancat.c $(distdir)/src
cp src/nyancat.py $(distdir)/src
cp src/telnetsrvlib.py $(distdir)/src
+ cp src/reset.sh $(distdir)/src
+ cp src/run.sh $(distdir)/src
FORCE:
-rm $(distdir).tar.gz >/dev/null 2>&1
diff --git a/README.md b/README.md
index 561aed6..afc1da2 100644
--- a/README.md
+++ b/README.md
@@ -8,7 +8,7 @@ Nyancat rendered in your terminal.
First build the C application:
- make
+ make && cd src
You can run the C application standalone. It will prompt you to select a color mode.
@@ -16,7 +16,7 @@ You can run the C application standalone. It will prompt you to select a color m
To run the telnet server, use:
- sudo ./nyancat.py
+ sudo ./start.sh
(The server will only try to start on port 23, so you must be root)
diff --git a/crontab b/crontab
new file mode 100644
index 0000000..f11c972
--- /dev/null
+++ b/crontab
@@ -0,0 +1 @@
+*/10 * * * * root /local/scratch/nyancat/reset.sh
diff --git a/src/nyancat.c b/src/nyancat.c
index 3bcb69d..97be2d0 100644
--- a/src/nyancat.c
+++ b/src/nyancat.c
@@ -34,6 +34,7 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
+#include <signal.h>
char * colors[256] = {NULL};
@@ -853,15 +854,24 @@ char * output = " ";
#define MIN_COL 10
#define MAX_COL 50
+void SIGINT_handler(int sig){
+ printf("\033[?25h");
+ exit(0);
+}
+
int main(int argc, char ** argv) {
printf("\033[H\033[2J");
fflush(stdout);
+ int always_escape = 0;
+ signal(SIGINT, SIGINT_handler);
try_again:
printf("Select a mode:\n");
printf(" 1 xterm 256-color compatible mode (best)\n");
printf(" 2 xterm standard-color mode (good)\n");
printf(" 3 linux + blink attribute (okay)\n");
- printf(" 4 standard ansi terminal (ugly)\n");
+ printf(" 4 unicode ansi terminal (okay)\n");
+ printf(" 5 extended ascii ansi terminal (okay)\n");
+ printf(" 6 vt220 terrible, no-color mode\n");
printf("Your selection: ");
char response[10];
fgets(response, 2, stdin);
@@ -911,21 +921,53 @@ try_again:
colors['*'] = "\033[5;40m"; /* Gray cat face */
colors['%'] = "\033[5;45m"; /* Pink cheeks */
} else if (!strcmp(response, "4")) {
- colors[','] = "\033[21;34;44m"; /* Blue background */
+ colors[','] = "\033[0;34;44m"; /* Blue background */
colors['.'] = "\033[1;37;47m"; /* White stars */
- colors['\''] = "\033[21;30;40m"; /* Black border */
+ colors['\''] = "\033[0;30;40m"; /* Black border */
colors['@'] = "\033[1;37;47m"; /* Tan poptart */
colors['$'] = "\033[1;35;45m"; /* Pink poptart */
colors['-'] = "\033[1;31;41m"; /* Red poptart */
colors['>'] = "\033[1;31;41m"; /* Red rainbow */
- colors['&'] = "\033[21;33;43m"; /* Orange rainbow */
+ colors['&'] = "\033[0;33;43m"; /* Orange rainbow */
colors['+'] = "\033[1;33;43m"; /* Yellow Rainbow */
colors['#'] = "\033[1;32;42m"; /* Green rainbow */
colors['='] = "\033[1;34;44m"; /* Light blue rainbow */
- colors[';'] = "\033[21;34;44m"; /* Dark blue rainbow */
+ colors[';'] = "\033[0;34;44m"; /* Dark blue rainbow */
colors['*'] = "\033[1;30;40m"; /* Gray cat face */
colors['%'] = "\033[1;35;45m"; /* Pink cheeks */
output = "██";
+ } else if (!strcmp(response, "5")) {
+ colors[','] = "\033[0;34;44m"; /* Blue background */
+ colors['.'] = "\033[1;37;47m"; /* White stars */
+ colors['\''] = "\033[0;30;40m"; /* Black border */
+ colors['@'] = "\033[1;37;47m"; /* Tan poptart */
+ colors['$'] = "\033[1;35;45m"; /* Pink poptart */
+ colors['-'] = "\033[1;31;41m"; /* Red poptart */
+ colors['>'] = "\033[1;31;41m"; /* Red rainbow */
+ colors['&'] = "\033[0;33;43m"; /* Orange rainbow */
+ colors['+'] = "\033[1;33;43m"; /* Yellow Rainbow */
+ colors['#'] = "\033[1;32;42m"; /* Green rainbow */
+ colors['='] = "\033[1;34;44m"; /* Light blue rainbow */
+ colors[';'] = "\033[0;34;44m"; /* Dark blue rainbow */
+ colors['*'] = "\033[1;30;40m"; /* Gray cat face */
+ colors['%'] = "\033[1;35;45m"; /* Pink cheeks */
+ output = "\333\333";
+ } else if (!strcmp(response, "6")) {
+ colors[','] = " "; /* Blue background */
+ colors['.'] = "**"; /* White stars */
+ colors['\''] = "##"; /* Black border */
+ colors['@'] = "##"; /* Tan poptart */
+ colors['$'] = "??"; /* Pink poptart */
+ colors['-'] = "<>"; /* Red poptart */
+ colors['>'] = "##"; /* Red rainbow */
+ colors['&'] = "=="; /* Orange rainbow */
+ colors['+'] = "--"; /* Yellow Rainbow */
+ colors['#'] = "++"; /* Green rainbow */
+ colors['='] = "~~"; /* Light blue rainbow */
+ colors[';'] = "$$"; /* Dark blue rainbow */
+ colors['*'] = " "; /* Gray cat face */
+ colors['%'] = "()"; /* Pink cheeks */
+ always_escape = 1;
} else {
printf("\033[H\033[2J");
printf("I'm sorry, what was that?\n");
@@ -934,6 +976,34 @@ try_again:
printf("\033[H\033[2J\033[?25l");
+
+ int countdown_clock = 1000;
+ if (always_escape) {
+ countdown_clock = 5;
+ }
+ int k;
+ for (k = 0; k < countdown_clock; ++k) {
+ printf("\n\n\n");
+ printf(" Nyancat Telnet Server\n");
+ printf("\n");
+ printf(" written and run by \033[1;32mKevin Lange\033[1;34m @kevinlange\033[0m\n");
+ printf("\n");
+ printf(" If things don't look right, try:\n");
+ printf(" TERM=fallback telnet ...\n");
+ printf(" Or on Windows:\n");
+ printf(" telnet -t vtnt ...\n");
+ printf("\n");
+ printf(" Problems? I am also a webserver:\n");
+ printf(" \033[1;34mhttp://miku.acm.uiuc.edu\033[0m\n");
+ printf("\n");
+ printf(" Starting in %d... \n", countdown_clock-k);
+
+ usleep(4000);
+ printf("\033[H");
+ }
+
+ printf("\033[H\033[2J\033[?25l");
+
int playing = 1;
size_t i = 0;
char last = 0;
@@ -941,11 +1011,15 @@ try_again:
while (playing) {
for (y = MIN_ROW; y < MAX_ROW; ++y) {
for (x = MIN_COL; x < MAX_COL; ++x) {
- if (frames[i][y][x] != last && colors[frames[i][y][x]]) {
- last = frames[i][y][x];
- printf("%s%s", colors[frames[i][y][x]], output);
+ if (always_escape) {
+ printf("%s", colors[frames[i][y][x]]);
} else {
- printf(output);
+ if (frames[i][y][x] != last && colors[frames[i][y][x]]) {
+ last = frames[i][y][x];
+ printf("%s%s", colors[frames[i][y][x]], output);
+ } else {
+ printf(output);
+ }
}
}
if (y != MAX_ROW - 1)
@@ -958,6 +1032,5 @@ try_again:
printf("\033[H");
usleep(90000);
}
-
return 0;
}
diff --git a/src/nyancat.py b/src/nyancat.py
index 039581c..0b90776 100755
--- a/src/nyancat.py
+++ b/src/nyancat.py
@@ -15,6 +15,12 @@ class TNH(TelnetHandler):
p.stdin.write("1\n")
elif (self.TERM.lower().find("linux") != -1):
p.stdin.write("3\n")
+ elif (self.TERM.lower().find("cygwin") != -1):
+ p.stdin.write("5\n")
+ elif (self.TERM.lower().find("vtnt") != -1):
+ p.stdin.write("5\n")
+ elif (self.TERM.lower().find("vt220") != -1):
+ p.stdin.write("6\n")
elif (self.TERM.lower().find("fallback") != -1):
p.stdin.write("4\n")
elif (self.TERM.lower().find("rxvt") == 0):
diff --git a/src/reset.sh b/src/reset.sh
new file mode 100755
index 0000000..f979e76
--- /dev/null
+++ b/src/reset.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+
+screen -X -p 0 stuff "= RESETTING ="
+screen -X -p 0 stuff $'\012'
+
+killall cgiserver 2>/dev/null
diff --git a/src/run.sh b/src/run.sh
new file mode 100755
index 0000000..c1b2953
--- /dev/null
+++ b/src/run.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+while [ 1 == 1 ]; do
+ killall nyancat
+ killall python
+ ./nyancat.py 2>/dev/null
+done
diff --git a/src/start.sh b/src/start.sh
new file mode 100755
index 0000000..f7635bc
--- /dev/null
+++ b/src/start.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+# Run me as root!
+
+screen -d -m
+sleep 1
+screen -X -p 0 stuff "./run.sh"
+screen -X -p 0 stuff $'\012'