diff options
Diffstat (limited to '')
-rw-r--r-- | bounce.h | 1 | ||||
-rw-r--r-- | 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); |