diff options
author | Kevin Lange <k@dakko.us> | 2011-12-03 19:57:59 -0600 |
---|---|---|
committer | Kevin Lange <k@dakko.us> | 2011-12-03 19:57:59 -0600 |
commit | db216877b89f61e936fb2c94fee6c3f07bfd4ba1 (patch) | |
tree | 513b653a8a5a50d1203e528941469ec75fd48404 /src/nyancat.c | |
parent | cedbee69a2f2a647c01ef3fcec946decd4f24959 (diff) | |
download | nyancat-db216877b89f61e936fb2c94fee6c3f07bfd4ba1.tar.gz |
Fix linefeeds
Diffstat (limited to 'src/nyancat.c')
-rw-r--r-- | src/nyancat.c | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/src/nyancat.c b/src/nyancat.c index 5fa8825..39e3796 100644 --- a/src/nyancat.c +++ b/src/nyancat.c @@ -58,6 +58,9 @@ char * colors[256] = {NULL}; */ char * output = " "; +/* Telnet mode? */ +int telnet = 0; + /* * These values crop the animation, as we have a full 64x64 stored, * but we only want to display 80x24. @@ -76,6 +79,19 @@ void SIGINT_handler(int sig){ exit(0); } +void newline(int n) { + int i = 0; + for (i = 0; i < n; ++i) { + if (telnet) { + putc('\r', stdout); + putc(0, stdout); + putc('\n', stdout); + } else { + putc('\n', stdout); + } + } +} + /* * These are the options we want to use as * a telnet server. These are set in set_options() @@ -155,6 +171,7 @@ int main(int argc, char ** argv) { if (argc > 1) { if (!strcmp(argv[1], "-t")) { /* Yes, I know, lame way to get arguments, whatever, we only want one of them. */ + telnet = 1; /* Set the default options */ set_options(); @@ -391,19 +408,23 @@ ready: /* Display the MOTD */ int countdown_clock = 5; 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"); + newline(3); + printf(" Nyancat Telnet Server"); + newline(2); + printf(" written and run by \033[1;32mKevin Lange\033[1;34m @kevinlange\033[0m"); + newline(2); + printf(" If things don't look right, try:"); + newline(1); + printf(" TERM=fallback telnet ..."); + newline(1); + printf(" Or on Windows:"); + newline(1); + printf(" telnet -t vtnt ..."); + newline(2); + printf(" Problems? I am also a webserver:"); + newline(1); + printf(" \033[1;34mhttp://miku.acm.uiuc.edu\033[0m"); + newline(2); printf(" Starting in %d... \n", countdown_clock-k); fflush(stdout); @@ -438,7 +459,7 @@ ready: } /* End of row, send newline */ if (y != MAX_ROW - 1) - printf("\n"); + newline(1); } /* Update frame crount */ ++i; |