summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-08-01 20:31:41 +0800
committerscw <scw@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-08-01 20:31:41 +0800
commit4da726aace2a8f50df30202238f2bc438dcbd365 (patch)
treebf9613c453503982358b122e8b7cb00111e07418
parent813fa10cb57cdafa1a1fb9fb9a70965254b7491f (diff)
downloadpttbbs-scw.telnet.tar
pttbbs-scw.telnet.tar.gz
pttbbs-scw.telnet.tar.bz2
pttbbs-scw.telnet.tar.lz
pttbbs-scw.telnet.tar.xz
pttbbs-scw.telnet.tar.zst
pttbbs-scw.telnet.zip
Ignore IAC when not using telnet.scw.telnet
Using stack buffer to enlarge screen. Response telnet command stricter. git-svn-id: http://opensvn.csie.org/pttbbs/branches/scw.telnet@2155 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/io.c18
-rw-r--r--mbbsd/term.c29
-rw-r--r--mbbsd/var.c1
3 files changed, 27 insertions, 21 deletions
diff --git a/mbbsd/io.c b/mbbsd/io.c
index 3282b041..1a623ae6 100644
--- a/mbbsd/io.c
+++ b/mbbsd/io.c
@@ -227,16 +227,18 @@ igetch()
else // here is switch for default keys
switch (ch) {
case IAC:
+ if (use_shell_login_mode)
+ return IAC;
#ifndef SKIP_TELNET_CONTROL_SIGNAL
- {
+ else {
unsigned char cmd[16];
- ch = dogetch();
- switch (ch) {
+ cmd[0] = IAC;
+ cmd[1] = ch = dogetch();
+ switch (ch) { /* switch first char after IAC */
case IAC:
return IAC; /* escaped IAC */
case DO:
- cmd[0] = IAC;
cmd[1] = WONT; /* this always work according to rfc 854 */
cmd[2] = dogetch();
if(cmd[1] != TELOPT_TTYPE && cmd[1] != TELOPT_NAWS &&
@@ -245,10 +247,12 @@ igetch()
break;
case DONT:
- cmd[0] = IAC;
cmd[1] = WONT;
cmd[2] = dogetch();
- write(1, cmd, 3);
+ if(cmd[1] == TELOPT_TTYPE || cmd[1] == TELOPT_NAWS ||
+ cmd[1] == TELOPT_ECHO || cmd[1] == TELOPT_SGA)
+ /* we don't like this, but rfc have us swallow */
+ write(1, cmd, 3);
break;
case WILL: case WONT:
@@ -266,7 +270,7 @@ igetch()
else if (ch && cmd[i] == SE)
break;
else
- mode = 0;
+ ch = 0;
}
}
if (cmd[2] == TELOPT_NAWS)
diff --git a/mbbsd/term.c b/mbbsd/term.c
index 3d9fd793..0dbe91f4 100644
--- a/mbbsd/term.c
+++ b/mbbsd/term.c
@@ -54,21 +54,23 @@ outcf(int ch)
static inline void
term_resize(int row, int col){
- screenline_t *new_picture;
/* make sure reasonable size */
row = MAX(24, MIN(100, row));
col = MAX(80, MIN(200, col));
if (big_picture != NULL && row > t_lines) {
- new_picture = (screenline_t *) calloc(row, sizeof(screenline_t));
- if (new_picture == NULL) {
+ screenline_t* buf = alloca(t_lines * sizeof(screenline_t));
+ memcpy(buf, big_picture, t_lines * sizeof(screenline_t));
+ free(big_picture);
+ big_picture = (screenline_t *) calloc(row, sizeof(screenline_t));
+ if (big_picture == NULL) {
syslog(LOG_ERR, "calloc(): %m");
+ big_picture = (screenline_t*) calloc(t_lines, sizeof(screenline_t));
+ memcpy(big_picture, buf, t_lines * sizeof(screenline_t));
return;
}
- memcpy(new_picture, big_picture, t_lines * sizeof(screenline_t));
- free(big_picture);
- big_picture = new_picture;
+ memcpy(big_picture, buf, t_lines * sizeof(screenline_t));
}
t_lines = row;
t_columns = col;
@@ -120,11 +122,11 @@ char term_buf[32];
void
do_move(int destcol, int destline)
{
- char buf[16], *p;
+ char buf[16];
- snprintf(buf, sizeof(buf), "\33[%d;%dH", destline + 1, destcol + 1);
- for (p = buf; *p; p++)
- ochar(*p);
+ output(buf,
+ snprintf(buf, sizeof(buf), "\33[%d;%dH", destline + 1,
+ destcol + 1));
}
void
@@ -144,11 +146,10 @@ restore_cursor()
void
change_scroll_range(int top, int bottom)
{
- char buf[16], *p;
+ char buf[16];
- snprintf(buf, sizeof(buf), "\33[%d;%dr", top + 1, bottom + 1);
- for (p = buf; *p; p++)
- ochar(*p);
+ output(buf,
+ snprintf(buf, sizeof(buf), "\33[%d;%dr", top + 1, bottom + 1));
}
void
diff --git a/mbbsd/var.c b/mbbsd/var.c
index 5198b45a..67bb58a7 100644
--- a/mbbsd/var.c
+++ b/mbbsd/var.c
@@ -384,6 +384,7 @@ char real_name[IDLEN + 1];
int local_article;
/* mbbsd.c */
+int use_shell_login_mode = 0;
char fromhost[STRLEN] = "\0";
char water_usies = 0;
FILE *fp_writelog = NULL;