jcs
/subtext
/amendments
/92
focusable: Move code to separate file, fix a bunch of bugs here
Fix drawing on the wrong window, drawing in the wrong font, crash at
exit, etc.
jcs made amendment 92 over 2 years ago
--- console.c Mon Feb 21 15:28:46 2022
+++ console.c Thu Apr 14 15:27:27 2022
@@ -19,10 +19,13 @@
#include "subtext.h"
#include "console.h"
+#include "focusable.h"
#include "session.h"
#include "util.h"
/* for monaco 9 */
+#define TEXT_FONT monaco
+#define TEXT_SIZE 9
#define FONT_WIDTH 6
#define FONT_HEIGHT 11
@@ -95,9 +98,9 @@ console_init(void)
focusable->close = console_close;
console->focusable = focusable;
add_focusable(focusable);
- TextFont(monaco);
- TextSize(9);
-
+ TextFont(TEXT_FONT);
+ TextSize(TEXT_SIZE);
+
console->session = session_create("console", "console",
&console_node_funcs);
console->session->cookie = (void *)console;
@@ -115,11 +118,15 @@ console_idle(struct focusable *focusable, EventRecord
{
struct console *console = (struct console *)focusable->cookie;
struct session *session = console->session;
+ GrafPtr old_port;
short n, len, cursor, iac = 0;
if (session->obuflen == 0)
return;
+ GetPort(&old_port);
+ SetPort(console->win);
+
/* uncursor */
cursor = (console->cursor_line * console->ncolumns) +
console->cursor_column;
@@ -184,6 +191,7 @@ console_idle(struct focusable *focusable, EventRecord
output_done:
console_bound(console);
console_redraw(console, 0);
+ SetPort(old_port);
}
void
@@ -200,12 +208,13 @@ void
console_update(struct focusable *focusable, EventRecord *event)
{
struct console *console = (struct console *)focusable->cookie;
+ GrafPtr old_win;
Rect r;
short what = -1;
if (event != NULL)
what = event->what;
-
+
switch (what) {
case -1:
case updateEvt:
@@ -315,8 +324,7 @@ void
console_close_from_session(struct session *session)
{
struct console *console = (struct console *)session->cookie;
- close_focusable(console->focusable);
- free(console->focusable);
+ destroy_focusable(console->focusable);
free(console);
}
@@ -327,6 +335,7 @@ console_bound(struct console *console)
pxout_scroll;
RgnHandle rgn;
Rect r, r2;
+ GrafPtr old_port;
short ret = 0, n;
while (console->cursor_column > console->ncolumns) {
@@ -340,6 +349,8 @@ console_bound(struct console *console)
chars_left = (console->nlines * console->ncolumns) - shift_cols;
pxout = shift_lines * FONT_HEIGHT;
+ GetPort(&old_port);
+ SetPort(console->win);
rgn = NewRgn();
r.left = console->win->portRect.left + CONSOLE_PADDING;
r.top = console->win->portRect.top + CONSOLE_PADDING;
@@ -365,6 +376,8 @@ console_bound(struct console *console)
memset(console->chars + chars_left, ' ', shift_cols);
memset(console->attrs + chars_left, console->cur_attr, shift_cols);
+ SetPort(old_port);
+
console->cursor_line = console->nlines - 1;
ret = 1;
}
@@ -382,6 +395,9 @@ console_redraw(struct console *console, short force)
unsigned char curattr, a;
nsize = console->ncolumns * console->nlines;
+
+ TextFont(TEXT_FONT);
+ TextSize(TEXT_SIZE);
for (line = 0; line < console->nlines; line++) {
off = line * console->ncolumns;
--- db.c Thu Mar 17 15:34:14 2022
+++ db.c Sun Apr 10 09:20:09 2022
@@ -194,6 +194,7 @@ db_migrate(struct db *tdb, short is_new)
tdb->config.telnet_port = 23;
tdb->config.modem_port = 0;
sprintf(tdb->config.modem_init, "ATQ0V1S0=2");
+ tdb->config.max_idle_minutes = 5;
db_config_save(tdb);
/* create a default sysop user */
--- db.h Sat Mar 5 21:52:32 2022
+++ db.h Sun Apr 10 09:19:45 2022
@@ -57,6 +57,7 @@ struct config {
short telnet_port;
short modem_port;
char modem_init[96];
+ short max_idle_minutes;
};
struct user {
--- focusable.c Thu Apr 14 14:09:07 2022
+++ focusable.c Thu Apr 14 14:09:07 2022
@@ -0,0 +1,125 @@
+/*
+ * Copyright (c) 2021-2022 joshua stein <jcs@jcs.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <string.h>
+
+#include "focusable.h"
+#include "util.h"
+
+struct focusable **focusables = NULL;
+short nfocusables = 0;
+
+struct focusable *
+find_focusable(GrafPtr win)
+{
+ short n;
+
+ for (n = 0; n < nfocusables; n++) {
+ if (focusables[n]->win == win)
+ return focusables[n];
+ }
+
+ return NULL;
+}
+
+void
+add_focusable(struct focusable *focusable)
+{
+ short n;
+
+ nfocusables++;
+ focusables = xreallocarray(focusables, sizeof(struct focusable *),
+ nfocusables);
+
+ if (nfocusables > 1)
+ for (n = nfocusables - 1; n > 0; n--)
+ focusables[n] = focusables[n - 1];
+
+ focusables[0] = focusable;
+
+ show_focusable(focusable);
+}
+
+void
+show_focusable(struct focusable *focusable)
+{
+ struct focusable *last, *tmp;
+ short n;
+
+ if (nfocusables > 1 && focusables[0] != focusable) {
+ last = focusables[0];
+ focusables[0] = focusable;
+ for (n = 1; n < nfocusables; n++) {
+ tmp = focusables[n];
+ focusables[n] = last;
+ last = tmp;
+ if (last == focusable)
+ break;
+ }
+ }
+
+ focusable->visible = true;
+ ShowWindow(focusable->win);
+ SelectWindow(focusable->win);
+}
+
+void
+destroy_focusable(struct focusable *focusable)
+{
+ short n;
+
+ if (focusable->visible)
+ CloseWindow(focusable->win);
+
+ for (n = 0; n < nfocusables; n++) {
+ if (focusables[n] == focusable) {
+ for (; n < nfocusables - 1; n++)
+ focusables[n] = focusables[n + 1];
+ break;
+ }
+ }
+
+ nfocusables--;
+ if (nfocusables)
+ focusables = xreallocarray(focusables, sizeof(Ptr), nfocusables);
+ else {
+ free(focusables);
+ focusables = NULL;
+ }
+
+ if (nfocusables && focusables[0]->visible)
+ SelectWindow(focusables[0]->win);
+
+ /* focusable is now bogus */
+}
+
+void
+hide_focusable(struct focusable *focusable)
+{
+ short n;
+
+ HideWindow(focusable->win);
+ focusable->visible = false;
+
+ for (n = 0; n < nfocusables; n++) {
+ if (focusables[n] == focusable) {
+ for (; n < nfocusables - 1; n++)
+ focusables[n] = focusables[n + 1];
+ break;
+ }
+ }
+ focusables[nfocusables - 1] = focusable;
+}
--- focusable.h Thu Apr 14 14:09:20 2022
+++ focusable.h Thu Apr 14 14:09:20 2022
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2021-2022 joshua stein <jcs@jcs.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef __FOCUSABLE_H__
+#define __FOCUSABLE_H__
+
+#include "util.h"
+
+struct focusable {
+ WindowPtr win;
+ bool visible;
+ void *cookie;
+ short (*wait_type)(struct focusable *focusable);
+ void (*idle)(struct focusable *focusable, EventRecord *event);
+ void (*update)(struct focusable *focusable, EventRecord *event);
+ void (*key_down)(struct focusable *focusable, EventRecord *event);
+ void (*mouse_down)(struct focusable *focusable, EventRecord *event);
+ bool (*menu)(struct focusable *focusable, short menu, short item);
+ void (*close)(struct focusable *focusable, EventRecord *event);
+ void (*suspend)(struct focusable *focusable, EventRecord *event);
+ void (*resume)(struct focusable *focusable, EventRecord *event);
+ bool (*quit)(struct focusable *focusable);
+ void (*atexit)(struct focusable *focusable);
+};
+extern struct focusable **focusables;
+extern short nfocusables;
+
+struct focusable * find_focusable(GrafPtr win);
+void add_focusable(struct focusable *focusable);
+void show_focusable(struct focusable *focusable);
+void destroy_focusable(struct focusable *focusable);
+void hide_focusable(struct focusable *focusable);
+
+#endif
--- logger.c Thu Mar 31 15:59:05 2022
+++ logger.c Wed Apr 13 16:41:09 2022
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
+#include "focusable.h"
#include "logger.h"
#include "subtext.h"
#include "util.h"
@@ -134,7 +135,7 @@ logger_resume(struct focusable *focusable, EventRecord
void
logger_close(struct focusable *focusable, EventRecord *event)
{
- close_focusable(focusable);
+ destroy_focusable(focusable);
}
void
@@ -146,6 +147,7 @@ logger_update(struct focusable *focusable, EventRecord
short what = -1;
GetPort(&old_port);
+ SetPort(logger->win);
if (event != NULL)
what = event->what;
@@ -173,6 +175,8 @@ logger_update(struct focusable *focusable, EventRecord
}
break;
}
+
+ SetPort(old_port);
}
void
@@ -233,12 +237,16 @@ logger_printf(struct logger *logger, const char *forma
static char buf[600];
RgnHandle savergn;
Rect zerorect = { 0, 0, 0, 0 };
+ GrafPtr old_port;
va_list argptr;
size_t len, n;
time_t now = Time;
short line_height = 0;
bool stop_formatting = false;
+ if (!logger)
+ return 0;
+
len = 0;
if ((*(logger->messages_te))->teLength > 0) {
@@ -253,10 +261,16 @@ logger_printf(struct logger *logger, const char *forma
len += vsnprintf(buf + len, sizeof(buf) - len, format, argptr);
va_end(argptr);
+ while (buf[len - 1] == '\r')
+ len--;
+
line_height = LOGGER_FONT_SIZE + 3;
HLock(logger->messages_te);
+ GetPort(&old_port);
+ SetPort(logger->win);
+
/* check for TE overflow */
/* too many lines */
@@ -306,5 +320,7 @@ no_overflow:
logger->messages_te, false);
HUnlock(logger->messages_te);
+ SetPort(old_port);
+
return len;
}
--- main.c Thu Mar 31 15:38:50 2022
+++ main.c Thu Apr 14 15:33:17 2022
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2020-2021 joshua stein <jcs@jcs.org>
+ * Copyright (c) 2020-2022 joshua stein <jcs@jcs.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
@@ -20,6 +20,7 @@
#include "subtext.h"
#include "console.h"
#include "db.h"
+#include "focusable.h"
#include "logger.h"
#include "serial_local.h"
#include "session.h"
@@ -32,9 +33,7 @@
MenuHandle file_menu;
short quitting = 0;
struct db *db = NULL;
-struct focusable **focusables = NULL;
-short nfocusables = 0;
-struct logger *logger;
+struct logger *logger = NULL;
bool handle_menu(long menu_id);
void handle_exit(void);
@@ -52,7 +51,6 @@ main(void)
char key;
uthread_init();
- _atexit(handle_exit);
InitGraf(&thePort);
InitFonts();
@@ -90,13 +88,15 @@ main(void)
if (!db)
panic("Failed to open database");
- logger = logger_init();
+ _atexit(handle_exit);
+ logger = logger_init();
logger_printf(logger, "[db] Updating user cache");
user_update_cache_map();
if (db->config.telnet_port)
telnet_init();
+db->config.modem_port = 0;
if (db->config.modem_port)
serial_init();
@@ -112,17 +112,6 @@ main(void)
if (!GetNextEvent(everyEvent, &event))
continue;
- if (event.what != nullEvent) {
- event_in = FindWindow(event.where, &event_win);
- found_focusable = NULL;
- for (n = 0; n < nfocusables; n++) {
- if (focusables[n]->win == event_win) {
- found_focusable = focusables[n];
- break;
- }
- }
- }
-
switch (event.what) {
case nullEvent:
for (n = 0; n < nfocusables; n++) {
@@ -140,7 +129,9 @@ main(void)
focusables[0]->key_down)
focusables[0]->key_down(focusables[0], &event);
break;
- case mouseDown:
+ case mouseDown:
+ event_in = FindWindow(event.where, &event_win);
+
switch (event_in) {
case inMenuBar:
handle_menu(MenuSelect(event.where));
@@ -152,11 +143,14 @@ main(void)
DragWindow(event_win, event.where, &screenBits.bounds);
break;
case inGoAway:
- if (TrackGoAway(event_win, event.where) &&
- found_focusable && found_focusable->close)
- found_focusable->close(found_focusable, &event);
+ if (TrackGoAway(event_win, event.where)) {
+ found_focusable = find_focusable(event_win);
+ if (found_focusable && found_focusable->close)
+ found_focusable->close(found_focusable, &event);
+ }
break;
case inContent:
+ found_focusable = find_focusable(event_win);
if (event_win != FrontWindow()) {
if (found_focusable)
show_focusable(found_focusable);
@@ -167,23 +161,21 @@ main(void)
}
break;
case updateEvt:
- case activateEvt:
event_win = (WindowPtr)event.message;
- if (event.what == updateEvt) {
- GetPort(&old_port);
- SetPort(event_win);
- BeginUpdate(event_win);
- }
+ GetPort(&old_port);
+ SetPort(event_win);
+ BeginUpdate(event_win);
+ found_focusable = find_focusable(event_win);
if (found_focusable && found_focusable->update)
found_focusable->update(found_focusable, &event);
- if (event.what == updateEvt) {
- EndUpdate(event_win);
- SetPort(old_port);
- }
+ EndUpdate(event_win);
+ SetPort(old_port);
break;
+ case activateEvt:
+ break;
case app4Evt:
if (HiWord(event.message) & (1 << 8)) {
/* multifinder suspend/resume */
@@ -221,8 +213,11 @@ handle_exit(void)
focusables[n]->atexit(focusables[n]);
}
- telnet_atexit();
- serial_atexit();
+ if (db->config.telnet_port)
+ telnet_atexit();
+ if (db->config.modem_port)
+ serial_atexit();
+
db_close(db);
}
@@ -249,20 +244,33 @@ handle_menu(long menu_id)
break;
case FILE_MENU_ID:
switch (LoWord(menu_id)) {
- case FILE_MENU_QUIT_ID:
+ case FILE_MENU_QUIT_ID: {
+ int tnfocusables = nfocusables;
+ struct focusable **tfocusables;
+
ret = true;
quit = true;
- for (n = 0; n < nfocusables; n++) {
- if (focusables[n] && focusables[n]->quit &&
- !focusables[n]->quit(focusables[n])) {
+
+ /*
+ * nfocusables and focusables array will probably be modified
+ * as each focusable quits
+ */
+ tfocusables = xmalloc(sizeof(Ptr) * tnfocusables);
+ memcpy(tfocusables, focusables, sizeof(Ptr) * tnfocusables);
+
+ for (n = 0; n < tnfocusables; n++) {
+ if (tfocusables[n] && tfocusables[n]->quit &&
+ !tfocusables[n]->quit(tfocusables[n])) {
quit = false;
break;
}
}
- if (quit)
- ExitToShell();
+
+ free(tfocusables);
+ ExitToShell();
break;
}
+ }
break;
case EDIT_MENU_ID:
if (nfocusables && focusables[0]->visible && focusables[0]->menu)
@@ -298,89 +306,4 @@ handle_menu(long menu_id)
HiliteMenu(0);
return ret;
-}
-
-void
-add_focusable(struct focusable *focusable)
-{
- nfocusables++;
- focusables = xreallocarray(focusables, sizeof(Ptr), nfocusables);
-
- if (nfocusables > 1)
- memmove(focusables + sizeof(Ptr), focusables,
- sizeof(Ptr) * (nfocusables - 1));
-
- focusables[0] = focusable;
-
- show_focusable(focusable);
-}
-
-void
-show_focusable(struct focusable *focusable)
-{
- struct focusable *last, *tmp;
- short n;
-
- if (nfocusables > 1 && focusables[0] != focusable) {
- last = focusables[0];
- focusables[0] = focusable;
- for (n = 1; n < nfocusables; n++) {
- tmp = focusables[n];
- focusables[n] = last;
- last = tmp;
- if (last == focusable)
- break;
- }
- }
-
- focusable->visible = true;
- ShowWindow(focusable->win);
- SelectWindow(focusable->win);
- SetPort(focusable->win);
-}
-
-void
-close_focusable(struct focusable *focusable)
-{
- short n;
-
- if (focusable->visible)
- CloseWindow(focusable->win);
-
- for (n = 0; n < nfocusables; n++) {
- if (focusables[n] == focusable) {
- for (; n < nfocusables - 1; n++)
- focusables[n] = focusables[n + 1];
- break;
- }
- }
-
- nfocusables--;
- if (nfocusables)
- focusables = xreallocarray(focusables, sizeof(Ptr), nfocusables);
- else {
- free(focusables);
- focusables = NULL;
- }
-
- if (nfocusables && focusables[0]->visible)
- SelectWindow(focusables[0]->win);
-}
-
-void
-hide_focusable(struct focusable *focusable)
-{
- short n;
-
- HideWindow(focusable->win);
- focusable->visible = false;
-
- for (n = 0; n < nfocusables; n++) {
- if (focusables[n] == focusable) {
- for (; n < nfocusables - 1; n++)
- focusables[n] = focusables[n + 1];
- break;
- }
- }
- focusables[nfocusables - 1] = focusable;
}
--- serial.c Thu Mar 31 15:59:33 2022
+++ serial.c Thu Apr 14 15:32:59 2022
@@ -198,12 +198,6 @@ serial_printf(const char *format, ...)
pbr.ioParam.ioBuffer = (Ptr)&serial_printf_tbuf;
pbr.ioParam.ioReqCount = len;
PBWrite(&pbr, false);
-#if 0
- for (n = 0; n < len; n++) {
- one = 1;
- FSWrite(serial_out_refnum, &one, &serial_printf_tbuf[n]);
- }
-#endif
}
char *
--- session.c Thu Mar 31 15:51:48 2022
+++ session.c Tue Apr 12 16:37:50 2022
@@ -367,9 +367,14 @@ wait_for_char:
break;
if (session->obuflen != 0 && session->chatting)
return 0;
+ if (Time - session->last_input_at >
+ (db->config.max_idle_minutes * 60))
+ goto idled_out;
uthread_yield();
}
+ session->last_input_at = Time;
+
if (session->ibuf[0] == '\33') {
/* look for a VT100 escape sequence */
if (session->ibuflen == 1) {
@@ -425,6 +430,14 @@ done_consuming:
session->last_input = ret;
return ret;
+
+idled_out:
+ logger_printf(logger, "[%s] Idle too long, logging out", session->node);
+ session_output_string(session,
+ "\r\n\r\nYou have been idle too long, goodbye.\r\n\r\n");
+ session_flush(session);
+ session->ending = 1;
+ return 0;
}
/*
--- settings.c Sat Mar 5 21:43:12 2022
+++ settings.c Tue Apr 12 16:57:34 2022
@@ -19,6 +19,7 @@
#include "subtext.h"
#include "db.h"
+#include "focusable.h"
#include "settings.h"
#include "tetab.h"
#include "util.h"
@@ -36,34 +37,38 @@ struct config_field {
unsigned short max;
short ditl_id;
} config_fields[] = {
- { "BBS Name", CONFIG_TYPE_STRING,
+ { "BBS Name", CONFIG_TYPE_STRING,
offsetof(struct config, name),
1, member_size(struct config, name),
SETTINGS_BBS_NAME_ID },
- { "Phone Number", CONFIG_TYPE_STRING,
+ { "Phone Number", CONFIG_TYPE_STRING,
offsetof(struct config, phone_number),
1, member_size(struct config, phone_number),
SETTINGS_PHONE_ID },
- { "Location", CONFIG_TYPE_STRING,
+ { "Location", CONFIG_TYPE_STRING,
offsetof(struct config, location),
1, member_size(struct config, location),
SETTINGS_LOCATION_ID },
- { "Hostname", CONFIG_TYPE_STRING,
+ { "Hostname", CONFIG_TYPE_STRING,
offsetof(struct config, hostname),
1, member_size(struct config, hostname),
SETTINGS_HOSTNAME_ID },
- { "Telnet Port", CONFIG_TYPE_SHORT,
+ { "Telnet Port", CONFIG_TYPE_SHORT,
offsetof(struct config, telnet_port),
0, 65535,
SETTINGS_TELNET_PORT_ID },
- { "Modem Port", CONFIG_TYPE_SHORT,
+ { "Modem Port", CONFIG_TYPE_SHORT,
offsetof(struct config, modem_port),
0, 2,
SETTINGS_MODEM_PORT_ID },
{ "Modem Init String", CONFIG_TYPE_STRING,
offsetof(struct config, modem_init),
1, member_size(struct config, modem_init),
- SETTINGS_MODEM_INIT_ID }
+ SETTINGS_MODEM_INIT_ID },
+ { "Max Idle Minutes", CONFIG_TYPE_SHORT,
+ offsetof(struct config, max_idle_minutes),
+ 1, 65535,
+ SETTINGS_MAX_IDLE_MINS_ID },
};
struct view_editor {
@@ -412,8 +417,7 @@ view_editor_close(struct focusable *focusable, EventRe
(struct view_editor *)focusable->cookie;
TEDispose(view_editor->te);
- close_focusable(focusable);
+ destroy_focusable(focusable);
DisposeWindow(view_editor->win);
- free(focusable);
free(view_editor);
}
--- subtext.h Thu Mar 31 14:33:37 2022
+++ subtext.h Tue Apr 12 16:35:04 2022
@@ -57,6 +57,7 @@
#define SETTINGS_TELNET_PORT_ID 7
#define SETTINGS_MODEM_PORT_ID 8
#define SETTINGS_MODEM_INIT_ID 9
+#define SETTINGS_MAX_IDLE_MINS_ID 10
#define SETTINGS_EDIT_VIEW_DLOG_ID 131
@@ -66,28 +67,5 @@
extern struct db *db;
extern MenuHandle file_menu;
extern struct logger *logger;
-
-struct focusable {
- WindowPtr win;
- bool visible;
- void *cookie;
- short (*wait_type)(struct focusable *focusable);
- void (*idle)(struct focusable *focusable, EventRecord *event);
- void (*update)(struct focusable *focusable, EventRecord *event);
- void (*key_down)(struct focusable *focusable, EventRecord *event);
- void (*mouse_down)(struct focusable *focusable, EventRecord *event);
- bool (*menu)(struct focusable *focusable, short menu, short item);
- void (*close)(struct focusable *focusable, EventRecord *event);
- void (*suspend)(struct focusable *focusable, EventRecord *event);
- void (*resume)(struct focusable *focusable, EventRecord *event);
- bool (*quit)(struct focusable *focusable);
- void (*atexit)(struct focusable *focusable);
-};
-extern struct focusable **focusables;
-extern short nfocusables;
-void add_focusable(struct focusable *focusable);
-void show_focusable(struct focusable *focusable);
-void close_focusable(struct focusable *focusable);
-void hide_focusable(struct focusable *focusable);
#endif /* __SUBTEXT_H__ */
--- telnet.c Thu Mar 31 15:54:02 2022
+++ telnet.c Sun Apr 10 09:37:25 2022
@@ -230,7 +230,7 @@ telnet_idle(void)
sprintf(tty, "ttyt%d", n);
long2ip(telnet_status_pb.remoteHost, node->ip_s);
- logger_printf(logger, "[%s] New telnet connection from %s",
+ logger_printf(logger, "[telnet] [%s] New connection from %s",
tty, node->ip_s);
node->state = TELNET_PB_STATE_CONNECTED;
@@ -409,6 +409,9 @@ telnet_process_input(struct session *session)
if (node->iac_sb[sboff] == 255)
sboff++;
session->terminal_lines |= node->iac_sb[sboff++];
+ logger_printf(logger, "[telnet] [%s] IAC NAWS %d, %d",
+ session->node, session->terminal_columns,
+ session->terminal_lines);
break;
case IAC_TTYPE:
/* IAC SB TTYPE IS XTERM IAC SE */
@@ -416,9 +419,11 @@ telnet_process_input(struct session *session)
strlcpy(session->terminal_type,
(char *)&node->iac_sb + 2,
sizeof(session->terminal_type));
-
+
/* TODO: compare terminal type to list */
session->vt100 = 1;
+ logger_printf(logger, "[telnet] [%s] IAC TTYPE IS %s",
+ session->node, session->terminal_type);
break;
}
node->iac_state = TELNET_IAC_STATE_IDLE;