From f38eecb344f43282ca2f77ca0d0952638bb1fcf2 Mon Sep 17 00:00:00 2001 From: Gabor Adam Toth Date: Mon, 23 May 2011 00:37:54 +0200 Subject: [PATCH] comm: added peek callback before checking is_binary --- src/comm.c | 10 ++++++++++ src/comm.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/comm.c b/src/comm.c index 2b73e90..f8e2b2a 100644 --- a/src/comm.c +++ b/src/comm.c @@ -3186,6 +3186,15 @@ get_message (char *buff, size_t *len) inet_packets_in++; inet_volume_in += l; #endif + + // If we're receiving the first bytes call a peek function + // which could enable_binary depending on the content of the buffer + if (!ip->connected) { + put_c_n_string(++inter_sp, ip->text, l); + sapply(new_tabled("peek"), ip->ob, 1); + ip->connected = MY_TRUE; + } + /* Experimental support for * binary data streams, by fippo 2008 */ @@ -4007,6 +4016,7 @@ new_player ( object_t *ob, SOCKET_T new_socket new_interactive->closing = MY_FALSE; new_interactive->tn_enabled = MY_TRUE; new_interactive->is_binary = MY_FALSE; + new_interactive->connected = MY_FALSE; new_interactive->do_close = 0; new_interactive->noecho = 0; new_interactive->gobble_char = 0; diff --git a/src/comm.h b/src/comm.h index 7e64082..3623c8e 100644 --- a/src/comm.h +++ b/src/comm.h @@ -176,6 +176,7 @@ struct interactive_s { CBool closing; /* True when closing this socket. */ CBool tn_enabled; /* True: telnet machine enabled */ CBool is_binary; /* True: socket reads binary */ + CBool connected; /* Set to true after first bytes arrived */ char do_close; /* Bitflags: Close this down; Proto-ERQ. */ char noecho; /* Input mode bitflags */