[DGD] Diferences between telnet and binary connections

pete at ana.sk pete at ana.sk
Tue Oct 30 15:35:39 CET 2001


On 30 Oct 2001, at 8:01, Erwin Harte wrote:

> On Tue, Oct 30, 2001 at 09:39:02AM +0100, pete at ana.sk wrote:
> [...]
> > 
> > You can also implement some other usefull telnet codes easily 
> > with adding few lines of code to dgd sorces, i personaly find 
> > negotiate-about-window-size very good. Btw, are there plans to do 
> > more telnet codes into stock dgd? At east naws and maybe non-
> > linemode operations would be good.
> 
> Not that I'm aware of, but you're more than welcome to turn your own
> code in a package and make it available for others to share and enjoy!

Well take a look at this, maybe its even good (working for me), it 
handles NAWS notifications by calling set_window in telnet.c.

Pete



-------------- next part --------------
diff -urN dgd/mud/kernel/lib/connection.c dgd-my/mud/kernel/lib/connection.c
--- dgd/mud/kernel/lib/connection.c	Wed Nov  1 00:44:53 2000
+++ dgd-my/mud/kernel/lib/connection.c	Sat Jul 21 10:58:14 2001
@@ -7,6 +7,7 @@
 private int mode;		/* connection mode */
 private int blocked;		/* connection blocked? */
 private string buffer;		/* buffered output string */
+private int window_size;	/* telnet window size, low word is width, high word is heigh */
 
 /*
  * NAME:	create()
@@ -17,6 +18,7 @@
     userd = find_object(USERD);
     conntype = type;
     mode = MODE_ECHO;	/* same as MODE_LINE for binary connection */
+    window_size = 80 + 25 * 0x10000;	/* default window is 80x25 */
 }
 
 
@@ -287,3 +289,23 @@
     }
 }
 # endif
+
+/*
+ * NAME:	set_window()
+ * DESCRIPTION:	set size of telnet window
+ */
+static void set_window(mixed *tls, int width, int height)
+{
+    if(width > 0 && height > 0) {
+	window_size = height * 0x10000 + width % 0x10000;
+    }
+}
+
+/*
+ * NAME:	query_window()
+ * DESCRIPTION:	return size of telnet window as int, low word is width, high word is heigh
+ */
+int query_window()
+{
+    return window_size;
+}
diff -urN dgd/mud/kernel/obj/telnet.c dgd-my/mud/kernel/obj/telnet.c
--- dgd/mud/kernel/obj/telnet.c	Tue Nov 16 15:56:46 1999
+++ dgd-my/mud/kernel/obj/telnet.c	Sat Jul 21 10:24:41 2001
@@ -72,3 +72,12 @@
 {
     ::message_done(allocate(driver->query_tls_size()));
 }
+
+/*
+ * NAME:	set_window()
+ * DESCRIPTION:	set telnet window size
+ */
+static void set_window(int width, int height)
+{
+    ::set_window(allocate(driver->query_tls_size()), width, height);
+}
diff -urN dgd/src/comm.c dgd-my/src/comm.c
--- dgd/src/comm.c	Sat Jul 21 11:20:39 2001
+++ dgd-my/src/comm.c	Sat Jul 21 10:17:49 2001
@@ -138,7 +138,8 @@
 bool telnet;
 {
     static char init[] = { (char) IAC, (char) WONT, (char) TELOPT_ECHO,
-			   (char) IAC, (char) DO,   (char) TELOPT_LINEMODE };
+			   (char) IAC, (char) DO,   (char) TELOPT_LINEMODE,
+			   (char) IAC, (char) DO,   (char) TELOPT_NAWS };
     register user *usr;
     dataspace *data;
     array *arr;
@@ -914,6 +915,18 @@
 			break;
 
 		    case TS_SB:
+			if (UCHAR(*p) == TELOPT_NAWS && n >= 5) {
+			    PUSH_INTVAL(f, p[1] * 256 + p[2]);
+			    PUSH_INTVAL(f, p[3] * 256 + p[4]);
+			    this_user = obj->index;
+			    if (i_call(f, obj, (array *) NULL, "set_window", 10, TRUE, 2)) {
+				i_del_value(f->sp++);
+				endthread();
+			    }
+			    this_user = OBJ_NONE;
+			    p += 5;
+			    n -= 5;
+			}
 			/* skip to the end */
 			if (UCHAR(*p) == IAC) {
 			    state = TS_SE;
diff -urN dgd/src/host/telnet.h dgd-my/src/host/telnet.h
--- dgd/src/host/telnet.h	Mon Nov 13 04:44:48 1995
+++ dgd-my/src/host/telnet.h	Fri Jul 20 18:30:31 2001
@@ -18,3 +18,4 @@
 # define TELOPT_ECHO	1	/* echo */
 # define TELOPT_SGA	3	/* suppress go ahead */
 # define TELOPT_TM	6	/* timing mark */
+# define TELOPT_NAWS	31	/* window size */
 


More information about the DGD mailing list