From 057fe476c800d7a8e86af3bc49bd5efff8eba28d Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Tue, 29 Mar 2022 18:23:12 -0400 Subject: Track account name from 900 numeric --- bounce.h | 1 + state.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/bounce.h b/bounce.h index d714f97..8987e38 100644 --- a/bounce.h +++ b/bounce.h @@ -238,6 +238,7 @@ void clientConsume(struct Client *client); extern bool stateNoNames; extern enum Cap stateCaps; +extern char *stateAccount; extern bool stateAway; void stateLogin( const char *pass, enum Cap blind, const char *plain, diff --git a/state.c b/state.c index c3fc96c..b1d5573 100644 --- a/state.c +++ b/state.c @@ -38,6 +38,7 @@ bool stateNoNames; enum Cap stateCaps; +char *stateAccount; bool stateAway; typedef void Handler(struct Message *msg); @@ -52,6 +53,12 @@ static void require(const struct Message *msg, bool origin, size_t len) { } } +static void set(char **field, const char *value) { + if (*field) free(*field); + *field = strdup(value); + if (!*field) err(EX_OSERR, "strdup"); +} + // Maximum size of one AUTHENTICATE message. enum { AuthLen = 299 }; static char plainBase64[BASE64_SIZE(AuthLen)]; @@ -127,7 +134,8 @@ static void handleAuthenticate(struct Message *msg) { } static void handleReplyLoggedIn(struct Message *msg) { - (void)msg; + require(msg, false, 3); + set(&stateAccount, msg->params[2]); serverFormat("CAP END\r\n"); } @@ -166,12 +174,6 @@ bool stateReady(void) { && intro.myInfo[0]; } -static void set(char **field, const char *value) { - if (*field) free(*field); - *field = strdup(value); - if (!*field) err(EX_OSERR, "strdup"); -} - static void handleErrorNicknameInUse(struct Message *msg) { if (self.nick) return; require(msg, false, 2); -- cgit 1.4.1