comm: added peek callback before checking is_binary

This commit is contained in:
Gabor Adam Toth 2011-05-23 00:37:54 +02:00
parent f2ad80c888
commit f38eecb344
2 changed files with 11 additions and 0 deletions

View File

@ -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;

View File

@ -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 */