summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-12 16:49:57 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2009-06-12 16:49:57 +0800
commitff9917405ba44a07abc4622201bbfa78c8b82137 (patch)
tree0da008d1ba37692615d9328950c228c3f2343272 /common
parent4bb43f558058ac73ad1a36d489c9deefc19eb869 (diff)
downloadpttbbs-ff9917405ba44a07abc4622201bbfa78c8b82137.tar
pttbbs-ff9917405ba44a07abc4622201bbfa78c8b82137.tar.gz
pttbbs-ff9917405ba44a07abc4622201bbfa78c8b82137.tar.bz2
pttbbs-ff9917405ba44a07abc4622201bbfa78c8b82137.tar.lz
pttbbs-ff9917405ba44a07abc4622201bbfa78c8b82137.tar.xz
pttbbs-ff9917405ba44a07abc4622201bbfa78c8b82137.tar.zst
pttbbs-ff9917405ba44a07abc4622201bbfa78c8b82137.zip
* make AYT customizable
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4571 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'common')
-rw-r--r--common/sys/telnet.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/common/sys/telnet.c b/common/sys/telnet.c
index 7c1e12c1..7d3d0eea 100644
--- a/common/sys/telnet.c
+++ b/common/sys/telnet.c
@@ -71,6 +71,11 @@ void telnet_ctx_set_resize_arg(TelnetCtx *ctx, void *resize_arg)
ctx->resize_arg = resize_arg;
}
+void telnet_ctx_set_ayt_arg(TelnetCtx *ctx, void *ayt_arg)
+{
+ ctx->ayt_arg = ayt_arg;
+}
+
/* We are the boss. We don't respect to client.
* It's client's responsibility to follow us.
* Please write these codes in i-dont-care opt handlers.
@@ -137,6 +142,23 @@ telnet_write (TelnetCtx *ctx, const void *buf, size_t nbytes)
write(ctx->fd, buf, nbytes);
}
+#ifndef _TELNET_DEFAULT_AYT_STRING
+#define _TELNET_DEFAULT_AYT_STRING "I'm still alive.\r\n"
+#endif
+static void
+telnet_send_ayt (TelnetCtx *ctx)
+{
+ if (ctx->callback->send_ayt)
+ {
+ ctx->callback->send_ayt(ctx->ayt_arg, ctx->fd);
+ }
+ else
+ {
+ /* respond as fast as we can */
+ telnet_write(ctx, _TELNET_DEFAULT_AYT_STRING, sizeof(_TELNET_DEFAULT_AYT_STRING)-1);
+ }
+}
+
/* input: raw character
* output: telnet command if c was handled, otherwise zero.
*/
@@ -221,22 +243,7 @@ telnet_handler(TelnetCtx *ctx, unsigned char c)
/* good */
case AYT: /* are you there */
- {
-#if 0
- const char *alive = " I'm still alive, loading: ";
- char buf[STRLEN];
-
- /* respond as fast as we can */
- telnet_write(ctx, alive, strlen(alive));
- cpuload(buf);
- telnet_write(ctx, buf, strlen(buf));
- telnet_write(ctx, "\r\n", 2);
-#else
- const char *alive = " I'm still alive.\r\n";
- /* respond as fast as we can */
- telnet_write(ctx, alive, strlen(alive));
-#endif
- }
+ telnet_send_ayt(ctx);
return NOP;
case DONT: /* you are not to use option */