changeset 15786:35194cf0693e

pop3: Minor code cleanup
author Timo Sirainen <tss@iki.fi>
date Sat, 16 Feb 2013 17:58:20 +0200
parents 7e292b8352d9
children 473c0389eb10
files src/pop3/main.c src/pop3/pop3-client.c src/pop3/pop3-client.h
diffstat 3 files changed, 14 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/pop3/main.c	Sat Feb 16 17:54:57 2013 +0200
+++ b/src/pop3/main.c	Sat Feb 16 17:58:20 2013 +0200
@@ -116,11 +116,9 @@
 	if (set->verbose_proctitle)
 		verbose_proctitle = TRUE;
 
-	client = client_create(fd_in, fd_out, input->session_id,
-			       mail_user, user, set);
-	if (client != NULL) T_BEGIN {
+	if (client_create(fd_in, fd_out, input->session_id,
+			  mail_user, user, set, &client) == 0)
 		client_add_input(client, input_buf);
-	} T_END;
 	return 0;
 }
 
--- a/src/pop3/pop3-client.c	Sat Feb 16 17:54:57 2013 +0200
+++ b/src/pop3/pop3-client.c	Sat Feb 16 17:58:20 2013 +0200
@@ -273,10 +273,10 @@
 	return mask;
 }
 
-struct client *client_create(int fd_in, int fd_out, const char *session_id,
-			     struct mail_user *user,
-			     struct mail_storage_service_user *service_user,
-			     const struct pop3_settings *set)
+int client_create(int fd_in, int fd_out, const char *session_id,
+		  struct mail_user *user,
+		  struct mail_storage_service_user *service_user,
+		  const struct pop3_settings *set, struct client **client_r)
 {
 	struct mail_storage *storage;
 	const char *ident;
@@ -333,14 +333,14 @@
 			mailbox_get_last_error(client->mailbox, NULL));
 		client_send_storage_error(client);
 		client_destroy(client, "Couldn't open INBOX");
-		return NULL;
+		return -1;
 	}
 	client->mail_set = mail_storage_get_settings(storage);
 
 	if (init_mailbox(client, &errmsg) < 0) {
 		i_error("Couldn't init INBOX: %s", errmsg);
 		client_destroy(client, "Mailbox init failed");
-		return NULL;
+		return -1;
 	}
 
 	client->uidl_keymask =
@@ -371,7 +371,8 @@
 		hook_client_created(&client);
 
 	pop3_refresh_proctitle();
-	return client;
+	*client_r = client;
+	return 0;
 }
 
 static const char *client_build_uidl_change_string(struct client *client)
--- a/src/pop3/pop3-client.h	Sat Feb 16 17:54:57 2013 +0200
+++ b/src/pop3/pop3-client.h	Sat Feb 16 17:58:20 2013 +0200
@@ -103,10 +103,10 @@
 
 /* Create new client with specified input/output handles. socket specifies
    if the handle is a socket. */
-struct client *client_create(int fd_in, int fd_out, const char *session_id,
-			     struct mail_user *user,
-			     struct mail_storage_service_user *service_user,
-			     const struct pop3_settings *set);
+int client_create(int fd_in, int fd_out, const char *session_id,
+		  struct mail_user *user,
+		  struct mail_storage_service_user *service_user,
+		  const struct pop3_settings *set, struct client **client_r);
 void client_destroy(struct client *client, const char *reason) ATTR_NULL(2);
 
 /* Disconnect client connection */