aboutsummaryrefslogtreecommitdiffstats
path: root/src/nyancat.c
diff options
context:
space:
mode:
authorKevin Lange <k@dakko.us>2011-12-04 03:47:20 -0600
committerKevin Lange <k@dakko.us>2011-12-04 03:47:20 -0600
commit24575e61ecd1ffb7ba7f19c617ad26249f7676fc (patch)
treed3e3d55f39ecc1197ba63940d4faad581afa0630 /src/nyancat.c
parentf18f1e401a8190d29a3ba2fdc8dcbb9170de2c78 (diff)
downloadnyancat-24575e61ecd1ffb7ba7f19c617ad26249f7676fc.tar.gz
comments; do not break out of options on a non-IAC
Diffstat (limited to 'src/nyancat.c')
-rw-r--r--src/nyancat.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/nyancat.c b/src/nyancat.c
index 5f5939f..46cd6c1 100644
--- a/src/nyancat.c
+++ b/src/nyancat.c
@@ -213,14 +213,21 @@ int main(int argc, char ** argv) {
}
}
+ /* Set the alarm handler to execute the longjmp */
signal(SIGALRM, SIGALRM_handler);
+
/* Negotiate options */
if (!setjmp(environment)) {
+ /* We will stop handling options after one second */
alarm(1);
+
+ /* Let's do this */
while (!feof(stdin) && !done) {
+ /* Get either IAC (start command) or a regular character (break, unless in SB mode) */
unsigned char i = getchar();
unsigned char opt = 0;
if (i == IAC) {
+ /* If IAC, get the command */
i = getchar();
switch (i) {
case SE:
@@ -286,8 +293,6 @@ int main(int argc, char ** argv) {
sb[sb_len] = i;
sb_len++;
}
- } else {
- goto ready;
}
}
}