diff options
Diffstat (limited to 'mbbsd')
-rw-r--r-- | mbbsd/mbbsd.c | 21 | ||||
-rw-r--r-- | mbbsd/telnet.c | 20 |
2 files changed, 30 insertions, 11 deletions
diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index a66767a9..ff9188d8 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -47,6 +47,7 @@ struct ProgramOption { bool daemon_mode; bool tunnel_mode; enum TermMode term_mode; + int term_width, term_height; int nport; int port[MAX_BINDPORT]; int flag_listenfd; @@ -1386,10 +1387,18 @@ do_aloha(const char *hello) } static void -do_term_init(enum TermMode term_mode) +do_term_init(enum TermMode term_mode, int w, int h) { term_init(); initscr(); + + // if the terminal was already determined, resize for it. + if ((w && (w != t_columns)) || + (h && (h != t_lines )) ) + { + term_resize(w, h); + } + if (term_mode == TermMode_TTY) raise(SIGWINCH); } @@ -1737,7 +1746,8 @@ main(int argc, char *argv[], char *envp[]) return 0; } - do_term_init(option->term_mode); + do_term_init(option->term_mode, + option->term_width, option->term_height); start_client(option); free_program_option(option); @@ -1867,8 +1877,9 @@ tunnel_login(char *argv0, struct ProgramOption *option) strlcpy(option->flag_user, dat.userid, sizeof(option->flag_user)); if (dat.encoding) set_converting_type(dat.encoding); - resizeterm(dat.t_lines, dat.t_cols); - telnet_init(); + option->term_width = dat.t_cols; + option->term_height = dat.t_lines; + telnet_init(0); return 1; } @@ -1996,7 +2007,7 @@ daemon_login(char *argv0, struct ProgramOption *option) sleep(10); exit(0); } - telnet_init(); + telnet_init(1); return 1; } diff --git a/mbbsd/telnet.c b/mbbsd/telnet.c index 45f000a7..f348f08c 100644 --- a/mbbsd/telnet.c +++ b/mbbsd/telnet.c @@ -6,14 +6,21 @@ static char raw_connection = 0; #ifdef DETECT_CLIENT extern void UpdateClientCode(unsigned char c); -void telnet_cb_update_client_code(void *ccctx, unsigned char c) +static void +telnet_cb_update_client_code(void *cc_arg, unsigned char c) { UpdateClientCode(c); } #endif +static void +telnet_cb_resize_term(void *resize_arg, int w, int h) +{ + term_resize(w, h); +} + const static struct TelnetCallback telnet_callback = { - term_resize, + telnet_cb_resize_term, #ifdef DETECT_CLIENT telnet_cb_update_client_code, #else @@ -22,16 +29,17 @@ const static struct TelnetCallback telnet_callback = { }; void -telnet_init(void) +telnet_init(int do_init_cmd) { int fd = 0; TelnetCtx *ctx = &telnet_ctx; raw_connection = 1; telnet_ctx_init(ctx, &telnet_callback, fd); #ifdef DETECT_CLIENT - telnet_ctx_set_ccctx(ctx, (void*)1); + telnet_ctx_set_cc_arg(ctx, (void*)1); #endif - telnet_send_init_cmds(fd); + if (do_init_cmd) + telnet_send_init_cmds(fd); } /* tty_read @@ -58,7 +66,7 @@ void telnet_turnoff_client_detect(void) { TelnetCtx *ctx = &telnet_ctx; - telnet_ctx_set_ccctx(ctx, NULL); + telnet_ctx_set_cc_arg(ctx, NULL); } // vim: sw=4 |