changeset 21725:685240c1a19b

pop3-login: Remove usage of client.common.proxy_state
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 09 Mar 2017 10:48:33 -0500
parents dce69a67f3b2
children 995399a962cc
files src/pop3-login/client.h src/pop3-login/pop3-proxy.c
diffstat 2 files changed, 15 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/pop3-login/client.h	Thu Mar 09 10:46:36 2017 -0500
+++ b/src/pop3-login/client.h	Thu Mar 09 10:48:33 2017 -0500
@@ -21,6 +21,7 @@
 	char *last_user;
 	char *apop_challenge;
 	unsigned int apop_server_pid, apop_connect_uid;
+	enum pop3_proxy_state proxy_state;
 	bool proxy_xclient;
 };
 
--- a/src/pop3-login/pop3-proxy.c	Thu Mar 09 10:46:36 2017 -0500
+++ b/src/pop3-login/pop3-proxy.c	Thu Mar 09 10:48:33 2017 -0500
@@ -43,9 +43,9 @@
 			client->common.remote_port,
 			client_get_session_id(&client->common),
 			client->common.proxy_ttl - 1));
-		client->common.proxy_state = POP3_PROXY_XCLIENT;
+		client->proxy_state = POP3_PROXY_XCLIENT;
 	} else {
-		client->common.proxy_state = POP3_PROXY_LOGIN1;
+		client->proxy_state = POP3_PROXY_LOGIN1;
 	}
 
 	str = t_str_new(128);
@@ -84,8 +84,8 @@
 	o_stream_nsend(output, str_data(str), str_len(str));
 
 	proxy_free_password(&client->common);
-	if (client->common.proxy_state != POP3_PROXY_XCLIENT)
-		client->common.proxy_state = POP3_PROXY_LOGIN2;
+	if (client->proxy_state != POP3_PROXY_XCLIENT)
+		client->proxy_state = POP3_PROXY_LOGIN2;
 	return 0;
 }
 
@@ -135,7 +135,7 @@
 	i_assert(!client->destroyed);
 
 	output = login_proxy_get_ostream(client->login_proxy);
-	switch (client->proxy_state) {
+	switch (pop3_client->proxy_state) {
 	case POP3_PROXY_BANNER:
 		/* this is a banner */
 		if (strncmp(line, "+OK", 3) != 0) {
@@ -156,7 +156,7 @@
 			}
 		} else {
 			o_stream_nsend_str(output, "STLS\r\n");
-			client->proxy_state = POP3_PROXY_STARTTLS;
+			pop3_client->proxy_state = POP3_PROXY_STARTTLS;
 		}
 		return 0;
 	case POP3_PROXY_STARTTLS:
@@ -186,7 +186,7 @@
 			client_proxy_failed(client, TRUE);
 			return -1;
 		}
-		client->proxy_state = client->proxy_sasl_client == NULL ?
+		pop3_client->proxy_state = client->proxy_sasl_client == NULL ?
 			POP3_PROXY_LOGIN1 : POP3_PROXY_LOGIN2;
 		return 0;
 	case POP3_PROXY_LOGIN1:
@@ -198,7 +198,7 @@
 		o_stream_nsend_str(output, t_strdup_printf(
 			"PASS %s\r\n", client->proxy_password));
 		proxy_free_password(client);
-		client->proxy_state = POP3_PROXY_LOGIN2;
+		pop3_client->proxy_state = POP3_PROXY_LOGIN2;
 		return 0;
 	case POP3_PROXY_LOGIN2:
 		if (strncmp(line, "+ ", 2) == 0 &&
@@ -258,7 +258,9 @@
 
 void pop3_proxy_reset(struct client *client)
 {
-	client->proxy_state = POP3_PROXY_BANNER;
+	struct pop3_client *pop3_client = (struct pop3_client *)client;
+
+	pop3_client->proxy_state = POP3_PROXY_BANNER;
 }
 
 void pop3_proxy_error(struct client *client, const char *text)
@@ -268,5 +270,7 @@
 
 const char *pop3_proxy_get_state(struct client *client)
 {
-	return pop3_proxy_state_names[client->proxy_state];
+	struct pop3_client *pop3_client = (struct pop3_client *)client;
+
+	return pop3_proxy_state_names[pop3_client->proxy_state];
 }