Commit 089d3b1a authored by deuce's avatar deuce
Browse files

Remove hack introduced in r1.12 of conn_telnet.c by breaking the dependency

on cterm.
parent 93614865
......@@ -1963,3 +1963,22 @@ struct bbslist *show_bbslist(char *current, int connected)
}
}
}
cterm_emulation_t
get_emulation(struct bbslist *bbs)
{
if (bbs == NULL)
return CTERM_EMULATION_ANSI_BBS;
switch(bbs->screen_mode) {
case SCREEN_MODE_C64:
case SCREEN_MODE_C128_40:
case SCREEN_MODE_C128_80:
return CTERM_EMULATION_PETASCII;
case SCREEN_MODE_ATARI:
case SCREEN_MODE_ATARI_XEP80:
return CTERM_EMULATION_ATASCII;
default:
return CTERM_EMULATION_ANSI_BBS;
}
}
......@@ -15,6 +15,8 @@
#include <malloc.h> /* alloca() on Win32 */
#endif
#include <cterm.h>
#define LIST_NAME_MAX 30
#define LIST_ADDR_MAX 64
#define MAX_USER_LEN 30
......@@ -103,5 +105,6 @@ void free_list(struct bbslist **list, int listcount);
void add_bbs(char *listpath, struct bbslist *bbs);
int edit_list(struct bbslist **list, struct bbslist *item,char *listpath,int isdefault);
int get_rate_num(int rate);
cterm_emulation_t get_emulation(struct bbslist *bbs);
#endif
......@@ -30,11 +30,11 @@ void telnet_input_thread(void *args)
size_t buffer;
char rbuf[BUFFER_SIZE];
char *buf;
cterm_emulation_t emu = *(cterm_emulation_t *)args;
SetThreadName("Telnet Input");
conn_api.input_thread_running=1;
while(cterm == NULL) // telnet_interpret needs to dereference cterm (to get emulation type)
SLEEP(1);
free(args);
while(telnet_sock != INVALID_SOCKET && !conn_api.terminate) {
FD_ZERO(&rds);
FD_SET(telnet_sock, &rds);
......@@ -59,7 +59,7 @@ void telnet_input_thread(void *args)
break;
}
if(rd>0)
buf=(char *)telnet_interpret(conn_api.rd_buf, rd, (BYTE *)rbuf, &rd);
buf=(char *)telnet_interpret(conn_api.rd_buf, rd, (BYTE *)rbuf, &rd, emu);
buffered=0;
while(buffered < rd) {
pthread_mutex_lock(&(conn_inbuf.mutex));
......@@ -130,6 +130,8 @@ void telnet_output_thread(void *args)
int telnet_connect(struct bbslist *bbs)
{
cterm_emulation_t *emu;
init_uifc(TRUE, TRUE);
telnet_log_level = bbs->telnet_loglevel;
......@@ -163,8 +165,10 @@ int telnet_connect(struct bbslist *bbs)
memset(telnet_local_option,0,sizeof(telnet_local_option));
memset(telnet_remote_option,0,sizeof(telnet_remote_option));
emu = malloc(sizeof(cterm_emulation_t));
*emu = get_emulation(bbs);
_beginthread(telnet_output_thread, 0, NULL);
_beginthread(telnet_input_thread, 0, NULL);
_beginthread(telnet_input_thread, 0, emu);
uifc.pop(NULL);
......
......@@ -6,7 +6,6 @@
#include <string.h>
#include "term.h"
#include "cterm.h"
#include "genwrap.h"
#include "sockwrap.h"
......@@ -91,7 +90,7 @@ void request_telnet_opt(uchar cmd, uchar opt)
send_telnet_cmd(cmd,opt);
}
BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen)
BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen, cterm_emulation_t emu)
{
BYTE command;
BYTE option;
......@@ -160,7 +159,7 @@ BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen)
if(option==TELNET_TERM_TYPE && telnet_cmd[3]==TELNET_TERM_SEND) {
char buf[32];
const char *termtype;
switch(cterm->emulation) {
switch(emu) {
case CTERM_EMULATION_PETASCII:
termtype = "PETSCII";
break;
......
......@@ -8,12 +8,13 @@
#ifndef TELNET_NO_DLL
#define TELNET_NO_DLL
#endif
#include <cterm.h>
#include "telnet.h"
extern uchar telnet_local_option[0x100];
extern uchar telnet_remote_option[0x100];
BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen);
BYTE* telnet_interpret(BYTE* inbuf, int inlen, BYTE* outbuf, int *outlen, cterm_emulation_t emu);
BYTE* telnet_expand(BYTE* inbuf, size_t inlen, BYTE* outbuf, size_t *newlen);
void request_telnet_opt(uchar cmd, uchar opt);
......
......@@ -2235,7 +2235,6 @@ BOOL doterm(struct bbslist *bbs)
int oldmc;
int updated=FALSE;
BOOL sleep;
int emulation=CTERM_EMULATION_ANSI_BBS;
size_t remain;
struct text_info txtinfo;
#ifndef WITHOUT_OOII
......@@ -2263,18 +2262,7 @@ BOOL doterm(struct bbslist *bbs)
FREE_AND_NULL(scrollback_buf);
scrollback_lines=0;
scrollback_mode=txtinfo.currmode;
switch(bbs->screen_mode) {
case SCREEN_MODE_C64:
case SCREEN_MODE_C128_40:
case SCREEN_MODE_C128_80:
emulation = CTERM_EMULATION_PETASCII;
break;
case SCREEN_MODE_ATARI:
case SCREEN_MODE_ATARI_XEP80:
emulation = CTERM_EMULATION_ATASCII;
break;
}
cterm=cterm_init(term.height,term.width,term.x-1,term.y-1,settings.backlines,scrollback_buf, emulation);
cterm=cterm_init(term.height,term.width,term.x-1,term.y-1,settings.backlines,scrollback_buf, get_emulation(bbs));
if(!cterm) {
return FALSE;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment