From 0e93d96733cb9561b7235de2550bddf73c40109b Mon Sep 17 00:00:00 2001
From: deuce <>
Date: Fri, 9 Sep 2011 23:58:03 +0000
Subject: [PATCH] Fix for CTerm updates

---
 src/sbbs3/umonitor/spyon.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/sbbs3/umonitor/spyon.c b/src/sbbs3/umonitor/spyon.c
index be93a36746..6497e9dc33 100644
--- a/src/sbbs3/umonitor/spyon.c
+++ b/src/sbbs3/umonitor/spyon.c
@@ -43,8 +43,10 @@
 #include <string.h>
 #include "sockwrap.h"
 #include "spyon.h"
-#include "cterm.h"
 #include "ciolib.h"
+#include "cterm.h"
+
+struct cterminal *cterm;
 
 int spyon(char *sockname)  {
 	SOCKET		spy_sock=INVALID_SOCKET;
@@ -91,8 +93,8 @@ int spyon(char *sockname)  {
 	gotoxy(1,ti.screenheight);
 	cputs("Local spy mode... press CTRL-C to return to monitor");
 	clreol();
-	cterm_init(ti.screenheight-1,ti.screenwidth,1,1,0,NULL,CTERM_EMULATION_ANSI_BBS);
-	while(spy_sock!=INVALID_SOCKET)  {
+	cterm=cterm_init(ti.screenheight-1,ti.screenwidth,1,1,0,NULL,CTERM_EMULATION_ANSI_BBS);
+	while(spy_sock!=INVALID_SOCKET && cterm != NULL)  {
 		struct timeval tv;
 		tv.tv_sec=0;
 		tv.tv_usec=100;
@@ -116,7 +118,7 @@ int spyon(char *sockname)  {
 					telnet_strip++;
 					if(buf==255 && telnet_strip==2) {
 						telnet_strip=0;
-						cterm_write(&buf,1,NULL,0,NULL);
+						cterm_write(cterm, &buf,1,NULL,0,NULL);
 					}
 					if(telnet_strip==3)
 						telnet_strip=0;
@@ -125,7 +127,7 @@ int spyon(char *sockname)  {
 					if(buf==255)
 						telnet_strip=1;
 					else
-						cterm_write(&buf,1,NULL,0,NULL);
+						cterm_write(cterm, &buf,1,NULL,0,NULL);
 			}
 			else if(i<0) {
 				close(spy_sock);
@@ -152,6 +154,7 @@ int spyon(char *sockname)  {
 			}
 		}
 	}
+	cterm_end(cterm);
 	puttext(1,1,ti.screenwidth,ti.screenheight,scrn);
 	window(ti.winleft,ti.wintop,ti.winright,ti.winbottom);
 	textattr(ti.attribute);
-- 
GitLab