summary refs log tree commit diff
path: root/state.c
diff options
context:
space:
mode:
Diffstat (limited to 'state.c')
-rw-r--r--state.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/state.c b/state.c
index 161fd90..48f7185 100644
--- a/state.c
+++ b/state.c
@@ -66,46 +66,46 @@ static void supportSet(const char *token) {
 	set(&support.tokens[support.len++], token);
 }
 
-typedef void Handler(struct Command);
+typedef void Handler(struct Message);
 
-static void handleCap(struct Command cmd) {
-	bool ack = cmd.params[1] && !strcmp(cmd.params[1], "ACK");
-	bool sasl = cmd.params[2] && !strcmp(cmd.params[2], "sasl");
+static void handleCap(struct Message msg) {
+	bool ack = msg.params[1] && !strcmp(msg.params[1], "ACK");
+	bool sasl = msg.params[2] && !strcmp(msg.params[2], "sasl");
 	if (!ack || !sasl) errx(EX_CONFIG, "server does not support SASL");
 	serverAuth();
 }
 
-static void handleReplyWelcome(struct Command cmd) {
-	if (!cmd.params[1]) errx(EX_PROTOCOL, "RPL_WELCOME without message");
-	set(&intro.origin, cmd.origin);
-	set(&nick, cmd.params[0]);
-	set(&intro.welcome, cmd.params[1]);
+static void handleReplyWelcome(struct Message msg) {
+	if (!msg.params[1]) errx(EX_PROTOCOL, "RPL_WELCOME without message");
+	set(&intro.origin, msg.origin);
+	set(&nick, msg.params[0]);
+	set(&intro.welcome, msg.params[1]);
 }
-static void handleReplyYourHost(struct Command cmd) {
-	if (!cmd.params[1]) errx(EX_PROTOCOL, "RPL_YOURHOST without message");
-	set(&intro.yourHost, cmd.params[1]);
+static void handleReplyYourHost(struct Message msg) {
+	if (!msg.params[1]) errx(EX_PROTOCOL, "RPL_YOURHOST without message");
+	set(&intro.yourHost, msg.params[1]);
 }
-static void handleReplyCreated(struct Command cmd) {
-	if (!cmd.params[1]) errx(EX_PROTOCOL, "RPL_CREATED without message");
-	set(&intro.created, cmd.params[1]);
+static void handleReplyCreated(struct Message msg) {
+	if (!msg.params[1]) errx(EX_PROTOCOL, "RPL_CREATED without message");
+	set(&intro.created, msg.params[1]);
 }
-static void handleReplyMyInfo(struct Command cmd) {
-	if (!cmd.params[4]) errx(EX_PROTOCOL, "RPL_MYINFO without 4 parameters");
-	set(&intro.myInfo[0], cmd.params[1]);
-	set(&intro.myInfo[1], cmd.params[2]);
-	set(&intro.myInfo[2], cmd.params[3]);
-	set(&intro.myInfo[3], cmd.params[4]);
+static void handleReplyMyInfo(struct Message msg) {
+	if (!msg.params[4]) errx(EX_PROTOCOL, "RPL_MYINFO without 4 parameters");
+	set(&intro.myInfo[0], msg.params[1]);
+	set(&intro.myInfo[1], msg.params[2]);
+	set(&intro.myInfo[2], msg.params[3]);
+	set(&intro.myInfo[3], msg.params[4]);
 }
 
-static void handleReplyISupport(struct Command cmd) {
+static void handleReplyISupport(struct Message msg) {
 	for (size_t i = 1; i < ParamCap; ++i) {
-		if (!cmd.params[i] || strchr(cmd.params[i], ' ')) break;
-		supportSet(cmd.params[i]);
+		if (!msg.params[i] || strchr(msg.params[i], ' ')) break;
+		supportSet(msg.params[i]);
 	}
 }
 
-static void handleError(struct Command cmd) {
-	errx(EX_UNAVAILABLE, "%s", cmd.params[0]);
+static void handleError(struct Message msg) {
+	errx(EX_UNAVAILABLE, "%s", msg.params[0]);
 }
 
 static const struct {
@@ -122,11 +122,11 @@ static const struct {
 };
 
 void stateParse(char *line) {
-	struct Command cmd = parse(line);
-	if (!cmd.name) errx(EX_PROTOCOL, "no command");
+	struct Message msg = parse(line);
+	if (!msg.cmd) errx(EX_PROTOCOL, "no command");
 	for (size_t i = 0; i < ARRAY_LEN(Handlers); ++i) {
-		if (strcmp(cmd.name, Handlers[i].cmd)) continue;
-		Handlers[i].fn(cmd);
+		if (strcmp(msg.cmd, Handlers[i].cmd)) continue;
+		Handlers[i].fn(msg);
 		break;
 	}
 }