gnome-mud r698 - in trunk: . src



Author: lharris
Date: Sat Jul 26 05:59:22 2008
New Revision: 698
URL: http://svn.gnome.org/viewvc/gnome-mud?rev=698&view=rev

Log:
Experimental MCCP Support

Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/src/Makefile.am
   trunk/src/mud-connection-view.c
   trunk/src/mud-connection-view.h
   trunk/src/mud-telnet-handlers.c
   trunk/src/mud-telnet-handlers.h
   trunk/src/mud-telnet.c
   trunk/src/mud-telnet.h

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Sat Jul 26 05:59:22 2008
@@ -93,23 +93,23 @@
 #fi
 
 dnl Check whether to include MCCP code or not
-#AC_ARG_ENABLE(mccp,
-#	AC_HELP_STRING([--enable-mccp],
-#		       [Enable MCCP (MUD Client Compression Protocol)]),,
-#		enable_mccp=auto)
-#if test "x$enable_mccp" != "xno"; then
-#	AC_CHECK_HEADER(zlib.h, have_zlib=yes, have_zlib=no)
-#	if test "x$have_zlib" = "xno" -a "x$enable_mccp" = "xyes"; then
-#	  AC_MSG_ERROR([MCCP support explicitly requested but zlib was not found])
-#	fi
-#	if test "x$have_zlib" = "xyes"; then
-#	  AC_DEFINE(ENABLE_MCCP, 1, [Define if MCCP should be enabled])
-#	  enable_mccp=yes
-#	  Z_LIBS="-lz"
-#	fi
-#fi
-#AM_CONDITIONAL(USE_MCCP, test "x$enable_mccp" = xyes)
-#AC_SUBST(Z_LIBS)
+AC_ARG_ENABLE(mccp,
+	AC_HELP_STRING([--enable-mccp],
+		       [Enable MCCP (MUD Client Compression Protocol)]),,
+		enable_mccp=auto)
+if test "x$enable_mccp" != "xno"; then
+	AC_CHECK_HEADER(zlib.h, have_zlib=yes, have_zlib=no)
+	if test "x$have_zlib" = "xno" -a "x$enable_mccp" = "xyes"; then
+	  AC_MSG_ERROR([MCCP support explicitly requested but zlib was not found])
+	fi
+	if test "x$have_zlib" = "xyes"; then
+	  AC_DEFINE(ENABLE_MCCP, 1, [Define if MCCP should be enabled])
+	  enable_mccp=yes
+	  Z_LIBS="-lz"
+	fi
+fi
+AM_CONDITIONAL(USE_MCCP, test "x$enable_mccp" = xyes)
+AC_SUBST(Z_LIBS)
 
 dnl Check whether to include GStreamer code or not
 AC_ARG_ENABLE(gstreamer,
@@ -158,12 +158,12 @@
 
 AC_MSG_NOTICE([GNOME-Mud has been configured with the following options:])
 
-#if test "x$enable_mccp" = xyes; then
-#	AC_MSG_NOTICE([    * MCCP support is enabled])
-#else
-#	AC_MSG_NOTICE([    * MCCP support is disabled])
-#fi
-#
+if test "x$enable_mccp" = xyes; then
+	AC_MSG_NOTICE([    * MCCP support is enabled])
+else
+	AC_MSG_NOTICE([    * MCCP support is disabled])
+fi
+
 #if test "x$enable_mapper" = xyes; then
 #	AC_MSG_NOTICE([    * Mapper support is enabled])
 #else

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Sat Jul 26 05:59:22 2008
@@ -47,6 +47,8 @@
 	mud-telnet.h                \
 	mud-telnet-handlers.c		\
 	mud-telnet-handlers.h		\
+	mud-telnet-mccp.c			\
+	mud-telnet-mccp.h			\
 	mud-telnet-msp.c			\
 	mud-telnet-msp.h			\
 	mud-telnet-zmp.c			\

Modified: trunk/src/mud-connection-view.c
==============================================================================
--- trunk/src/mud-connection-view.c	(original)
+++ trunk/src/mud-connection-view.c	Sat Jul 26 05:59:22 2008
@@ -41,6 +41,14 @@
 #include "mud-telnet-zmp.h"
 #include "mud-telnet-msp.h"
 
+#ifdef ENABLE_MCCP
+    #include "mud-telnet-mccp.h"
+#endif
+
+#ifdef ENABLE_GST
+    #include "mud-telnet-msp.h"
+#endif
+
 /* Hack, will refactor with plugin rewrite -lh */
 extern gboolean PluginGag;
 
@@ -368,7 +376,6 @@
 
 	connection_view->priv->terminal = vte_terminal_new();
 	vte_terminal_set_encoding(VTE_TERMINAL(connection_view->priv->terminal), "ISO-8859-1");
-	vte_terminal_set_emulation(VTE_TERMINAL(connection_view->priv->terminal), "xterm");
 
 	gtk_box_pack_start(GTK_BOX(term_box), connection_view->priv->terminal, TRUE, TRUE, 0);
 	g_signal_connect(G_OBJECT(connection_view->priv->terminal),
@@ -434,15 +441,20 @@
 
 	connection_view = MUD_CONNECTION_VIEW(object);
 
-    while((history_item = (gchar *)g_queue_pop_head(connection_view->priv->history)) != NULL)
-		g_free(history_item);
+    if(connection_view->priv->history && !g_queue_is_empty(connection_view->priv->history))
+        while((history_item = (gchar *)g_queue_pop_head(connection_view->priv->history)) != NULL)
+		    g_free(history_item);
 
 	if(connection_view->priv->history)
 		g_queue_free(connection_view->priv->history);
 
 #ifdef ENABLE_GST
-	while((item = (MudMSPDownloadItem *)g_queue_pop_head(connection_view->priv->download_queue)) != NULL)
-		mud_telnet_msp_download_item_free(item);
+    if(connection_view->priv->download_queue
+        && !g_queue_is_empty(connection_view->priv->download_queue))
+        	while(
+        	    (item = (MudMSPDownloadItem *)g_queue_pop_head(
+        	    connection_view->priv->download_queue)) != NULL)
+        		    mud_telnet_msp_download_item_free(item);
 
 	if(connection_view->priv->download_queue)
         g_queue_free(connection_view->priv->download_queue);
@@ -477,8 +489,9 @@
 	g_assert(view != NULL);
 
 #ifdef ENABLE_GST
-	while((item = (MudMSPDownloadItem *)g_queue_pop_head(view->priv->download_queue)) != NULL)
-		mud_telnet_msp_download_item_free(item);
+    if(view->priv->download_queue)
+	    while((item = (MudMSPDownloadItem *)g_queue_pop_head(view->priv->download_queue)) != NULL)
+		    mud_telnet_msp_download_item_free(item);
 
 	if(view->priv->download_queue)
         	g_queue_free(view->priv->download_queue);
@@ -997,8 +1010,8 @@
 		      mud_tray_update_icon(view->priv->tray, online);
 	       }
 
-	       view->priv->processed = mud_telnet_process(view->priv->telnet,
-	       				(guchar *)event->buffer, event->length, &length);
+	       mud_telnet_process(view->priv->telnet, (guchar *)event->buffer,
+	        event->length, &length, &(view->priv->processed));
 
 	       if(view->priv->processed != NULL)
 	       {
@@ -1102,6 +1115,8 @@
 	view->priv->dl_conn = gnet_conn_http_new();
 	gnet_conn_http_set_uri(view->priv->dl_conn, item->url);
 	gnet_conn_http_set_user_agent (view->priv->dl_conn, "gnome-mud");
+	// 30 minute timeout, if the file didn't download in 30 minutes, its not going to happen.
+	gnet_conn_http_set_timeout(view->priv->dl_conn, 1800000);
 
 	view->priv->downloading = TRUE;
 
@@ -1188,8 +1203,7 @@
 			g_file_set_contents(item->file, event_data->buffer,
 				event_data->buffer_length, NULL);
 
-			mud_telnet_msp_download_item_free(item);
-
+            mud_telnet_msp_download_item_free(item);
 			view->priv->downloading = FALSE;
 
 			if(!g_queue_is_empty(view->priv->download_queue))

Modified: trunk/src/mud-connection-view.h
==============================================================================
--- trunk/src/mud-connection-view.h	(original)
+++ trunk/src/mud-connection-view.h	Sat Jul 26 05:59:22 2008
@@ -69,7 +69,10 @@
 void mud_connection_view_get_term_size(MudConnectionView *view, gint *w, gint *h);
 void mud_connection_view_set_naws(MudConnectionView *view, gint enabled);
 void mud_connection_view_send_naws(MudConnectionView *view);
+
+#ifdef ENABLE_GST
 void mud_connection_view_queue_download(MudConnectionView *view, gchar *url, gchar *file);
+#endif
 
 #include "mud-profile.h"
 void mud_connection_view_set_profile(MudConnectionView *view, MudProfile *profile);

Modified: trunk/src/mud-telnet-handlers.c
==============================================================================
--- trunk/src/mud-telnet-handlers.c	(original)
+++ trunk/src/mud-telnet-handlers.c	Sat Jul 26 05:59:22 2008
@@ -38,6 +38,12 @@
 	#include "mud-telnet-msp.h"
 #endif
 
+#ifdef ENABLE_MCCP
+    #include <zlib.h>
+    #include <stdlib.h>
+	#include "mud-telnet-mccp.h"
+#endif
+
 /* TTYPE */
 
 void
@@ -324,3 +330,56 @@
     return;
 }
 #endif
+
+#ifdef ENABLE_MCCP
+/* MCCP */
+void
+MudHandler_MCCP_Enable(MudTelnet *telnet, MudTelnetHandler *handler)
+{
+	handler->enabled = TRUE;
+	telnet->mccp = FALSE;
+}
+
+void
+MudHandler_MCCP_Disable(MudTelnet *telnet, MudTelnetHandler *handler)
+{
+	handler->enabled = FALSE;
+	telnet->mccp = FALSE;
+
+	if (telnet->compress_out != NULL)
+	{
+		inflateEnd(telnet->compress_out);
+
+		g_free(telnet->compress_out);
+		g_free(telnet->compress_out_buf);
+
+		telnet->compress_out = NULL;
+	}
+}
+
+void
+MudHandler_MCCP_HandleSubNeg(MudTelnet *telnet, guchar *buf,
+    guint len, MudTelnetHandler *handler)
+{
+    telnet->mccp = TRUE;
+    telnet->mccp_new = TRUE;
+
+	telnet->compress_out = (z_stream *) calloc(1, sizeof(z_stream));
+	telnet->compress_out_buf = (guchar *) calloc(4096, sizeof(guchar));
+
+	telnet->compress_out->next_out = telnet->compress_out_buf;
+	telnet->compress_out->avail_out = 4096;
+
+	if (inflateInit(telnet->compress_out) != Z_OK)
+	{
+	    g_critical("Failed to initialize compression.");
+
+		g_free(telnet->compress_out);
+		g_free(telnet->compress_out_buf);
+		telnet->compress_out = NULL;
+		telnet->compress_out_buf = NULL;
+
+		mud_connection_view_disconnect (telnet->parent);
+	}
+}
+#endif

Modified: trunk/src/mud-telnet-handlers.h
==============================================================================
--- trunk/src/mud-telnet-handlers.h	(original)
+++ trunk/src/mud-telnet-handlers.h	Sat Jul 26 05:59:22 2008
@@ -70,4 +70,12 @@
     guint len, MudTelnetHandler *handler);
 #endif
 
+#ifdef ENABLE_MCCP
+/* MCCP */
+void MudHandler_MCCP_Enable(MudTelnet *telnet, MudTelnetHandler *handler);
+void MudHandler_MCCP_Disable(MudTelnet *telnet, MudTelnetHandler *handler);
+void MudHandler_MCCP_HandleSubNeg(MudTelnet *telnet, guchar *buf,
+    guint len, MudTelnetHandler *handler);
+#endif
+
 #endif // MUD_TELNET_HANDLERS_H

Modified: trunk/src/mud-telnet.c
==============================================================================
--- trunk/src/mud-telnet.c	(original)
+++ trunk/src/mud-telnet.c	Sat Jul 26 05:59:22 2008
@@ -35,9 +35,12 @@
 #include "mud-telnet-handlers.h"
 #include "mud-telnet-zmp.h"
 
+#ifdef ENABLE_MCCP
+    #include "mud-telnet-mccp.h"
+#endif
+
 struct _MudTelnetPrivate
 {
-	GString *processed;
 };
 
 GType mud_telnet_get_type (void);
@@ -104,11 +107,7 @@
 {
 	telnet->priv = g_new0(MudTelnetPrivate, 1);
 
-#ifdef ENABLE_GST
-	telnet->msp_parser.enabled = FALSE;
-#endif
-
-	telnet->priv->processed = g_string_new(NULL);
+	telnet->processed = g_string_new(NULL);
 	telnet->prev_buffer = NULL;
 }
 
@@ -128,8 +127,20 @@
 
     telnet = MUD_TELNET(object);
 
+    if(telnet->processed)
+        g_string_free(telnet->processed, TRUE);
 	g_free(telnet->priv);
 
+#ifdef ENABLE_MCCP
+	if (telnet->compress_out != NULL)
+	{
+		inflateEnd(telnet->compress_out);
+
+		g_free(telnet->compress_out);
+		g_free(telnet->compress_out_buf);
+	}
+#endif
+
 	parent_class = g_type_class_peek_parent(G_OBJECT_GET_CLASS(object));
 	parent_class->finalize(object);
 }
@@ -157,6 +168,8 @@
 	telnet->eor_enabled = FALSE;
 
 	telnet->mud_name = g_strdup(mud_name);
+    telnet->buffer = NULL;
+	telnet->pos = 0;
 
 #ifdef ENABLE_GST
 	telnet->sound[0].files = NULL;
@@ -170,6 +183,11 @@
 	telnet->sound[1].files_len = 0;
 
 	telnet->base_url = NULL;
+	telnet->msp_parser.enabled = FALSE;
+#endif
+
+#ifdef ENABLE_MCCP
+	telnet->mccp_new = TRUE;
 #endif
 
 	return telnet;
@@ -248,6 +266,16 @@
     telnet->handlers[6].handle_sub_neg = MudHandler_MSP_HandleSubNeg;
 #endif
 
+#ifdef ENABLE_MCCP
+    /* MCCP */
+    telnet->handlers[7].type = HANDLER_MCCP2;
+    telnet->handlers[7].option_number = (guchar)TELOPT_MCCP2;
+    telnet->handlers[7].enabled = TRUE;
+    telnet->handlers[7].enable = MudHandler_MCCP_Enable;
+    telnet->handlers[7].disable = MudHandler_MCCP_Disable;
+    telnet->handlers[7].handle_sub_neg = MudHandler_MCCP_HandleSubNeg;
+#endif
+
 }
 
 gint
@@ -306,35 +334,129 @@
     mud_telnet_send_sub_req(telnet, 5, (guchar)TELOPT_NAWS, w1, w0, h1, h0);
 }
 
-GString *
-mud_telnet_process(MudTelnet *telnet, guchar * buf, guint32 count, gint *len)
+void
+mud_telnet_process(MudTelnet *telnet, guchar * buf, guint32 c, gint *len, GString **out_buf)
 {
-	size_t pos = 0;
 	guint32 i;
+	guint32 count;
 	g_assert(telnet != NULL);
-	GString *ret = NULL;
-	GString *buffer = g_string_new_len((gchar *)buf, count);
 
-	for (i = 0;i < count;++i)
+    telnet->buffer = g_string_new(NULL);
+
+#ifdef ENABLE_MCCP
+    if(telnet->mccp)
+    {
+        GString *ret;
+        gchar *str;
+
+        // decompress the buffer.
+        ret = mud_mccp_decompress(telnet, buf, c);
+
+        if(ret == NULL)
+            return;
+        else
+        {
+            str = g_strdup(ret->str);
+            g_string_append(telnet->buffer, str);
+            g_string_free(ret, TRUE);
+            g_free(str);
+        }
+    }
+    else
+#endif
+	g_string_append_len(telnet->buffer, (gchar *)buf, c);
+
+    count = telnet->buffer->len;
+
+	for (i = 0; i < count; ++i)
 	{
 		switch (telnet->tel_state)
 		{
 			case TEL_STATE_TEXT:
-				if (buf[i] == (guchar)TEL_IAC)
+#ifdef ENABLE_MCCP
+                /* The following is only done when compressing is first
+                   enabled in order to decompress any part of the buffer
+                   that remains after the subnegotation takes place */
+                if(telnet->mccp && telnet->mccp_new)
+                {
+                    GString *ret;
+                    telnet->mccp_new = FALSE;
+
+                    // decompress the rest of the buffer.
+                    ret = mud_mccp_decompress(telnet, &buf[i], c - i);
+
+                    if(ret == NULL)
+                    {
+                        if(*out_buf != NULL) g_string_free(*out_buf, TRUE);
+                        *out_buf = g_string_new_len(telnet->processed->str, telnet->pos);
+                        *len = telnet->pos;
+
+                        telnet->pos= 0;
+
+                        if(telnet->processed)
+                        {
+                            g_string_free(telnet->processed, TRUE);
+                            telnet->processed = g_string_new(NULL);
+                        }
+
+                        if(telnet->buffer)
+                        {
+                            g_string_free(telnet->buffer, TRUE);
+                            telnet->buffer = NULL;
+                        }
+
+                        return;
+                    }
+
+                    if(telnet->buffer)
+                    {
+                        g_string_free(telnet->buffer, TRUE);
+                        telnet->buffer = NULL;
+                    }
+
+                    telnet->buffer = g_string_new(ret->str);
+
+                    if(telnet->buffer->len == 0)
+                    {
+                        if(*out_buf != NULL) g_string_free(*out_buf, TRUE);
+                        *out_buf = g_string_new_len(telnet->processed->str, telnet->pos);
+                        *len = telnet->pos;
+
+                        telnet->pos= 0;
+
+                        if(telnet->processed)
+                        {
+                            g_string_free(telnet->processed, TRUE);
+                            telnet->processed = g_string_new(NULL);
+                        }
+
+                        if(telnet->buffer)
+                        {
+                            g_string_free(telnet->buffer, TRUE);
+                            telnet->buffer = NULL;
+                        }
+                        return;
+                    }
+
+                    i = 0;
+                    count = telnet->buffer->len;
+                }
+#endif
+				if ((guchar)telnet->buffer->str[i] == (guchar)TEL_IAC)
 					telnet->tel_state = TEL_STATE_IAC;
 				else
 				{
-					g_string_append_c(telnet->priv->processed, buffer->str[i]);
-					pos++;
+					g_string_append_c(telnet->processed, telnet->buffer->str[i]);
+					telnet->pos++;
 				}
 				break;
 
 			case TEL_STATE_IAC:
-				switch ((guchar)buffer->str[i])
+				switch ((guchar)telnet->buffer->str[i])
 				{
 					case (guchar)TEL_IAC:
-						pos++;
-						g_string_append_c(telnet->priv->processed, buffer->str[i]);
+						telnet->pos++;
+						g_string_append_c(telnet->processed, telnet->buffer->str[i]);
 						telnet->tel_state = TEL_STATE_TEXT;
 						break;
 
@@ -372,37 +494,37 @@
 						break;
 
 					default:
-						g_warning("Illegal IAC command %d received", buffer->str[i]);
+						g_warning("Illegal IAC command %d received", telnet->buffer->str[i]);
 						telnet->tel_state = TEL_STATE_TEXT;
 						break;
 				}
 				break;
 
 			case TEL_STATE_DO:
-				mud_telnet_handle_positive_nego(telnet, (guchar)buffer->str[i],
+				mud_telnet_handle_positive_nego(telnet, (guchar)telnet->buffer->str[i],
 				    (guchar)TEL_WILL, (guchar)TEL_WONT, FALSE);
 				telnet->tel_state = TEL_STATE_TEXT;
 
 			case TEL_STATE_WILL:
-				mud_telnet_handle_positive_nego(telnet, (guchar)buffer->str[i],
+				mud_telnet_handle_positive_nego(telnet, (guchar)telnet->buffer->str[i],
 				    (guchar)TEL_DO, (guchar)TEL_DONT, TRUE);
 				telnet->tel_state = TEL_STATE_TEXT;
 				break;
 
 			case TEL_STATE_DONT:
 				mud_telnet_handle_negative_nego(telnet,
-				    (guchar)buffer->str[i], (guchar)TEL_WILL, (guchar)TEL_WONT, FALSE);
+				    (guchar)telnet->buffer->str[i], (guchar)TEL_WILL, (guchar)TEL_WONT, FALSE);
 				telnet->tel_state = TEL_STATE_TEXT;
 				break;
 
 			case TEL_STATE_WONT:
 				mud_telnet_handle_negative_nego(telnet,
-				    (guchar)buffer->str[i], (guchar)TEL_DO, (guchar)TEL_DONT, TRUE);
+				    (guchar)telnet->buffer->str[i], (guchar)TEL_DO, (guchar)TEL_DONT, TRUE);
 				telnet->tel_state = TEL_STATE_TEXT;
 				break;
 
 			case TEL_STATE_SB:
-				if (buf[i] == (guchar)TEL_IAC)
+				if ((guchar)telnet->buffer->str[i] == (guchar)TEL_IAC)
 					telnet->tel_state = TEL_STATE_SB_IAC;
 				else
 				{
@@ -414,12 +536,12 @@
 						telnet->tel_state = TEL_STATE_TEXT;
 					}
 					else
-						telnet->subreq_buffer[telnet->subreq_pos++] = (guchar)buffer->str[i];
+						telnet->subreq_buffer[telnet->subreq_pos++] = (guchar)telnet->buffer->str[i];
 				}
 				break;
 
 			case TEL_STATE_SB_IAC:
-				if (buf[i] == (guchar)TEL_IAC)
+				if ((guchar)telnet->buffer->str[i] == (guchar)TEL_IAC)
 				{
 					if (telnet->subreq_pos >= TEL_SUBREQ_BUFFER_SIZE)
 					{
@@ -428,17 +550,17 @@
 						telnet->tel_state = TEL_STATE_TEXT;
 					}
 					else
-						telnet->subreq_buffer[telnet->subreq_pos++] = (guchar)buffer->str[i];
+						telnet->subreq_buffer[telnet->subreq_pos++] = (guchar)telnet->buffer->str[i];
 
 					telnet->tel_state = TEL_STATE_SB;
 				}
-				else if (buf[i] == (guchar)TEL_SE)
+				else if ((guchar)telnet->buffer->str[i] == (guchar)TEL_SE)
 				{
-				    telnet->subreq_buffer[telnet->subreq_pos++] = (guchar)buffer->str[i];
+				    telnet->subreq_buffer[telnet->subreq_pos++] = (guchar)telnet->buffer->str[i];
 					mud_telnet_on_handle_subnego(telnet);
-					telnet->tel_state = TEL_STATE_TEXT;
+                    telnet->tel_state = TEL_STATE_TEXT;
 				} else {
-					g_warning("Erronous byte %d after an IAC inside a subrequest", buffer->str[i]);
+					g_warning("Erronous byte %d after an IAC inside a subrequest", telnet->buffer->str[i]);
 					telnet->subreq_pos = 0;
 					telnet->tel_state = TEL_STATE_TEXT;
 				}
@@ -448,14 +570,26 @@
 
 	if(telnet->tel_state == TEL_STATE_TEXT)
 	{
-		ret = g_string_new_len(g_strdup(telnet->priv->processed->str), pos);
-		g_string_free(telnet->priv->processed, TRUE);
-		telnet->priv->processed = g_string_new(NULL);
-		*len = pos;
+	    if(*out_buf != NULL) g_string_free(*out_buf, TRUE);
+		*out_buf = g_string_new_len(g_strdup(telnet->processed->str), telnet->pos);
+		*len = telnet->pos;
+
+        telnet->pos= 0;
+
+        if(telnet->processed)
+        {
+		    g_string_free(telnet->processed, TRUE);
+		    telnet->processed = g_string_new(NULL);
+	    }
 	}
+	else
+	    *out_buf = NULL;
 
-
-	return ret;
+	if(telnet->buffer)
+    {
+        g_string_free(telnet->buffer, TRUE);
+        telnet->buffer = NULL;
+    }
 }
 
 gchar*
@@ -504,9 +638,9 @@
 		case TELOPT_CHARSET:
 			g_string_append(string, "CHARSET");
 		case TELOPT_MCCP:
-			g_string_append(string, "MCCP");
+			g_string_append(string, "COMPRESS");
 		case TELOPT_MCCP2:
-			g_string_append(string, "MCCPv2");
+			g_string_append(string, "COMPRESS2");
 		case TELOPT_CLIENT:
 			g_string_append(string, "CLIENT");
 		case TELOPT_CLIENTVER:
@@ -521,8 +655,6 @@
 			g_string_append_c(string, ch);
 	}
 
-	g_string_free(string, FALSE);
-
 	return ret;
 }
 

Modified: trunk/src/mud-telnet.h
==============================================================================
--- trunk/src/mud-telnet.h	(original)
+++ trunk/src/mud-telnet.h	Sat Jul 26 05:59:22 2008
@@ -59,7 +59,7 @@
 #   define TEL_CHARSET_TTABLE_REJECTED      5
 #   define TEL_CHARSET_TTABLE_ACK           6
 #   define TEL_CHARSET_TTABLE_NAK           7
-#define TELOPT_MCCP			 85	// MCCP
+#define TELOPT_MCCP			 85	// MCCP is not support by GnomeMud.
 #define TELOPT_MCCP2		 86	// MCCP2
 #define TELOPT_CLIENT		 88	// Client name - from Clandestine MUD protocol
 #define TELOPT_CLIENTVER	 89	// Client version - from Clandestine MUD protocol
@@ -113,7 +113,8 @@
     HANDLER_EOR,
     HANDLER_CHARSET,
     HANDLER_ZMP,
-    HANDLER_MSP
+    HANDLER_MSP,
+    HANDLER_MCCP2
 };
 
 struct _MudTelnetClass
@@ -143,6 +144,11 @@
 	#include "mud-telnet-msp.h"
 #endif
 
+#ifdef ENABLE_MCCP
+    #include <zlib.h>
+    typedef struct z_stream_s z_stream;
+#endif
+
 struct _MudTelnet
 {
 	GObject parent_instance;
@@ -172,7 +178,17 @@
 	gchar *base_url;
 #endif
 
+#ifdef ENABLE_MCCP
+    z_stream * compress_out;
+	guchar * compress_out_buf;
+	gboolean mccp;
+	gboolean mccp_new;
+#endif
+
 	GString *prev_buffer;
+	GString *processed;
+	GString *buffer;
+	size_t pos;
 
 	gchar *mud_name;
 };
@@ -183,7 +199,7 @@
 
 void mud_telnet_register_handlers(MudTelnet *telnet);
 gint mud_telnet_isenabled(MudTelnet *telnet, guint8 option_number, gint him);
-GString *mud_telnet_process(MudTelnet *telnet, guchar * buf, guint32 count, gint *length);
+void mud_telnet_process(MudTelnet *telnet, guchar * buf, guint32 count, gint *length, GString **out_buf);
 void mud_telnet_send_sub_req(MudTelnet *telnet, guint32 count, ...);
 void mud_telnet_get_parent_size(MudTelnet *telnet, gint *w, gint *h);
 void mud_telnet_send_raw(MudTelnet *telnet, guint32 count, ...);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]