about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2022-03-29 18:23:12 -0400
committerJune McEnroe <june@causal.agency>2022-03-29 18:23:12 -0400
commit057fe476c800d7a8e86af3bc49bd5efff8eba28d (patch)
tree167b6d0799b429a78324725b0a7bf9ebb7213a23
parentSet clientOrigin from bindHost, add dot if necessary (diff)
downloadpounce-057fe476c800d7a8e86af3bc49bd5efff8eba28d.tar.gz
pounce-057fe476c800d7a8e86af3bc49bd5efff8eba28d.zip
Track account name from 900 numeric
-rw-r--r--bounce.h1
-rw-r--r--state.c16
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);