diff options
author | Jonathan McCrohan <jmccrohan@gmail.com> | 2013-03-10 00:05:39 +0000 |
---|---|---|
committer | Jonathan McCrohan <jmccrohan@gmail.com> | 2013-03-14 22:17:37 +0000 |
commit | 30ea534e61594cbe41651e8110aa5ead2e947ed6 (patch) | |
tree | 1105e1b25aecdd072e8fb9b02a4291a86ba713e6 | |
parent | af6bfbc44713ed2c19a81aac88bb0e3eb9d8aa20 (diff) | |
parent | 43097ebfc2bc9bc0f721f5f80dc1aede1f7e10d7 (diff) | |
download | nyancat-30ea534e61594cbe41651e8110aa5ead2e947ed6.tar.gz |
Merge branch 'master' of git://github.com/klange/nyancat
Conflicts:
Makefile
-rw-r--r-- | CHANGELOG | 10 | ||||
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | README.md | 29 | ||||
-rw-r--r-- | debian/patches/01-nyancat-debhelper.patch | 12 | ||||
-rw-r--r-- | src/nyancat.c | 59 |
5 files changed, 90 insertions, 22 deletions
diff --git a/CHANGELOG b/CHANGELOG new file mode 100644 index 0000000..56973f3 --- /dev/null +++ b/CHANGELOG @@ -0,0 +1,10 @@ +1.1 (tagged on 2013-01-28) + * Support the Suckless terminal + * Support building for とあるOS + * Changed color palette for 256 color modes (fixes alternate color + schemes looking wonky) + * Install the man page as part of package building + * Fix a potential bug processing extended options + +1.0 + * Initial public release for packaging @@ -1,5 +1,5 @@ package = nyancat -version = 1.0 +version = 1.1 tarname = $(package) distdir = $(tarname)-$(version) @@ -4,6 +4,16 @@ Nyancat rendered in your terminal. [![Nyancats](http://i.imgur.com/snCOQl.png)](http://i.imgur.com/snCOQ.png) +## Distributions + +Nyancat is available in the following distributions: + +- [Arch](http://aur.archlinux.org/packages.php?ID=55279) +- [Debian](http://packages.qa.debian.org/n/nyancat.html) +- [Gentoo](http://packages.gentoo.org/package/games-misc/nyancat) +- [Mandriva](http://sophie.zarb.org/rpms/928724d4aea0efdbdeda1c80cb59a7d3) +- [Ubuntu](https://launchpad.net/ubuntu/+source/nyancat) + ## Setup First build the C application: @@ -18,10 +28,23 @@ To use the telnet server, you need to add a configuration that runs: nyancat -t -... to either an `inetd` or `xinetd` server. I am using `openbsd-inetd`, which you must give *both* arguments (`nyancat` and `-t`) to, which I found odd. +We recommend `openbsd-inetd`, but `xinetd` will work as well, and you should be +able to use any other compatible `inetd` flavor. + +## Distribution Specific Information + +#### Debian/Ubuntu + +Debian and Ubuntu provide the nyancat binary through the `nyancat` package. A +`nyancat-server` package is provided to automatically setup and enable a nyancat +telnet server upon installation. I am not the maintainer of these packages; +please direct any questions or bugs to the relevant distribution's bug tracking +system. ## Licenses, References, etc. -The original source of the Nyancat animation is [prguitarman](http://www.prguitarman.com/index.php?id=348). +The original source of the Nyancat animation is +[prguitarman](http://www.prguitarman.com/index.php?id=348). -The code provided here is provided under the terms of the [NCSA license](http://en.wikipedia.org/wiki/University_of_Illinois/NCSA_Open_Source_License). +The code provided here is provided under the terms of the +[NCSA license](http://en.wikipedia.org/wiki/University_of_Illinois/NCSA_Open_Source_License). diff --git a/debian/patches/01-nyancat-debhelper.patch b/debian/patches/01-nyancat-debhelper.patch index e23f98a..4f3b38d 100644 --- a/debian/patches/01-nyancat-debhelper.patch +++ b/debian/patches/01-nyancat-debhelper.patch @@ -1,15 +1,21 @@ -Description: Add $(DESTDIR) to install path - Debhelper doesn't like hardcoded install paths. +Description: Makefile fixes + Add $(DESTDIR) to install path. Debhelper doesn't like hardcoded + install paths. + . + Debhelper already installs the manpage for us. No need for second + install in Makefile. Author: Jonathan McCrohan <jmccrohan@gmail.com> Date: Tue, 17 Apr 2012 13:32:20 +0100 +Last-Update: 2013-03-12 --- --- nyancat-0.1+git20120401.5a88b86.orig/Makefile +++ nyancat-0.1+git20120401.5a88b86/Makefile -@@ -33,6 +33,6 @@ distcheck: $(distdir).tar.gz +@@ -33,7 +33,6 @@ distcheck: $(distdir).tar.gz @echo "*** Package $(distdir).tar.gz is ready for distribution." install: all - install src/nyancat /usr/bin/${package} +- gzip -9 -c < nyancat.1 > /usr/share/man/man1/nyancat.1.gz + install -Dm 0755 src/nyancat $(DESTDIR)/usr/bin/${package} .PHONY: FORCE all clean check dist distcheck install diff --git a/src/nyancat.c b/src/nyancat.c index 234ff10..44bdf06 100644 --- a/src/nyancat.c +++ b/src/nyancat.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Kevin Lange. All rights reserved. + * Copyright (c) 2011-2013 Kevin Lange. All rights reserved. * * Developed by: Kevin Lange * http://github.com/klange/nyancat @@ -58,9 +58,22 @@ #include <signal.h> #include <time.h> #include <setjmp.h> -#include <sys/ioctl.h> #include <getopt.h> +#ifdef __toaru__ + +#include <syscall.h> + +DEFN_SYSCALL2(nanosleep, 46, unsigned long, unsigned long); + +int usleep(useconds_t time) { + syscall_nanosleep(0, time / 10000); +} + +#else +#include <sys/ioctl.h> +#endif + #ifndef TIOCGWINSZ #include <termios.h> #ifdef ECHO @@ -304,8 +317,8 @@ int main(int argc, char ** argv) { int k, ttype; uint32_t option = 0, done = 0, sb_mode = 0, do_echo = 0; /* Various pieces for the telnet communication */ - char sb[1024] = {0}; - char sb_len = 0; + char sb[1024] = {0}; + short sb_len = 0; /* Whether or not to show the MOTD intro */ char show_intro = 0; @@ -430,14 +443,14 @@ int main(int argc, char ** argv) { if (sb[0] == TTYPE) { /* This was a response to the TTYPE command, meaning * that this should be a terminal type */ - alarm(0); + alarm(2); strcpy(term, &sb[2]); done++; } else if (sb[0] == NAWS) { /* This was a response to the NAWS command, meaning * that this should be a window size */ - alarm(0); + alarm(2); terminal_width = sb[2]; done++; } @@ -483,7 +496,7 @@ int main(int argc, char ** argv) { /* Begin Extended Option Mode */ sb_mode = 1; sb_len = 0; - memset(sb, 0, 1024); + memset(sb, 0, sizeof(sb)); break; case IAC: /* IAC IAC? That's probably not right. */ @@ -494,7 +507,7 @@ int main(int argc, char ** argv) { } } else if (sb_mode) { /* Extended Option Mode -> Accept character */ - if (sb_len < 1023) { + if (sb_len < sizeof(sb) - 1) { /* Append this character to the SB string, * but only if it doesn't put us over * our limit; honestly, we shouldn't hit @@ -508,6 +521,7 @@ int main(int argc, char ** argv) { } } } + alarm(0); } else { /* We are running standalone, retrieve the * terminal type from the environment. */ @@ -517,9 +531,20 @@ int main(int argc, char ** argv) { } /* Also get the number of columns */ +#ifdef __toaru__ + if (strstr(term, "toaru")) { + printf("\033[1003z"); + fflush(stdout); + int height; + scanf("%d,%d", &terminal_width, &height); + } else { + terminal_width = 80; /* better safe than sorry */ + } +#else struct winsize w; ioctl(0, TIOCGWINSZ, &w); terminal_width = w.ws_col; +#endif } /* Convert the entire terminal string to lower case */ @@ -535,6 +560,8 @@ int main(int argc, char ** argv) { /* Do our terminal detection */ if (strstr(term, "xterm")) { ttype = 1; /* 256-color, spaces */ + } else if (strstr(term, "toaru")) { + ttype = 1; /* emulates xterm */ } else if (strstr(term, "linux")) { ttype = 3; /* Spaces and blink attribute */ } else if (strstr(term, "vtnt")) { @@ -549,6 +576,8 @@ int main(int argc, char ** argv) { ttype = 3; /* Accepts LINUX mode */ } else if (strstr(term, "vt100") && terminal_width == 40) { ttype = 7; /* No color support, only 40 columns */ + } else if (!strncmp(term, "st", 2)) { + ttype = 1; /* suckless simple terminal is xterm-256color-compatible */ } else { ttype = 2; /* Everything else */ } @@ -559,18 +588,18 @@ int main(int argc, char ** argv) { switch (ttype) { case 1: colors[','] = "\033[48;5;17m"; /* Blue background */ - colors['.'] = "\033[48;5;15m"; /* White stars */ - colors['\''] = "\033[48;5;0m"; /* Black border */ + colors['.'] = "\033[48;5;231m"; /* White stars */ + colors['\''] = "\033[48;5;16m"; /* Black border */ colors['@'] = "\033[48;5;230m"; /* Tan poptart */ colors['$'] = "\033[48;5;175m"; /* Pink poptart */ colors['-'] = "\033[48;5;162m"; /* Red poptart */ - colors['>'] = "\033[48;5;9m"; /* Red rainbow */ - colors['&'] = "\033[48;5;202m"; /* Orange rainbow */ - colors['+'] = "\033[48;5;11m"; /* Yellow Rainbow */ - colors['#'] = "\033[48;5;10m"; /* Green rainbow */ + colors['>'] = "\033[48;5;196m"; /* Red rainbow */ + colors['&'] = "\033[48;5;214m"; /* Orange rainbow */ + colors['+'] = "\033[48;5;226m"; /* Yellow Rainbow */ + colors['#'] = "\033[48;5;118m"; /* Green rainbow */ colors['='] = "\033[48;5;33m"; /* Light blue rainbow */ colors[';'] = "\033[48;5;19m"; /* Dark blue rainbow */ - colors['*'] = "\033[48;5;8m"; /* Gray cat face */ + colors['*'] = "\033[48;5;240m"; /* Gray cat face */ colors['%'] = "\033[48;5;175m"; /* Pink cheeks */ break; case 2: |