From 6d6603dad94ebf79d6fdd90465b963e3b57a4094 Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan.bosch@open-xchange.com>
Date: Sun, 20 Oct 2019 13:57:32 +0200
Subject: [PATCH] managesieve: Reformat cmd-setactive.c.

---
 src/managesieve/cmd-setactive.c | 69 +++++++++++++++++----------------
 1 file changed, 36 insertions(+), 33 deletions(-)

diff --git a/src/managesieve/cmd-setactive.c b/src/managesieve/cmd-setactive.c
index c4873a197..6a8bb6e7f 100644
--- a/src/managesieve/cmd-setactive.c
+++ b/src/managesieve/cmd-setactive.c
@@ -20,45 +20,45 @@ bool cmd_setactive(struct client_command_context *cmd)
 	int ret;
 
 	/* <scriptname> */
-	if ( !client_read_string_args(cmd, TRUE, 1, &scriptname) )
+	if (!client_read_string_args(cmd, TRUE, 1, &scriptname))
 		return FALSE;
 
 	/* Activate, or .. */
-	if ( *scriptname != '\0' ) {
+	if (*scriptname != '\0') {
 		string_t *errors = NULL;
 		const char *errormsg = NULL;
 		bool warnings = FALSE;
 		bool success = TRUE;
 
-		script = sieve_storage_open_script
-			(storage, scriptname, NULL);
-		if ( script == NULL ) {
+		script = sieve_storage_open_script(storage, scriptname, NULL);
+		if (script == NULL) {
 			client_send_storage_error(client, storage);
 			return TRUE;
 		}
 
-		if ( sieve_script_is_active(script) <= 0 ) {
-			/* Script is first being activated; compile it again without the UPLOAD
-			 * flag.
-			 */
+		if (sieve_script_is_active(script) <= 0) {
+			/* Script is first being activated; compile it again
+			   without the UPLOAD flag. */
 			T_BEGIN {
 				struct sieve_error_handler *ehandler;
 				enum sieve_compile_flags cpflags =
-					SIEVE_COMPILE_FLAG_NOGLOBAL | SIEVE_COMPILE_FLAG_ACTIVATED;
+					SIEVE_COMPILE_FLAG_NOGLOBAL |
+					SIEVE_COMPILE_FLAG_ACTIVATED;
 				struct sieve_binary *sbin;
 				enum sieve_error error;
 
 				/* Prepare error handler */
 				errors = str_new(default_pool, 1024);
-				ehandler = sieve_strbuf_ehandler_create(client->svinst, errors, TRUE,
+				ehandler = sieve_strbuf_ehandler_create(
+					client->svinst, errors, TRUE,
 					client->set->managesieve_max_compile_errors);
 
 				/* Compile */
-				if ( (sbin=sieve_compile_script
-					(script, ehandler, cpflags, &error)) == NULL ) {
+				if ((sbin = sieve_compile_script(
+					script, ehandler, cpflags, &error)) == NULL) {
 					if (error != SIEVE_ERROR_NOT_VALID) {
 						errormsg = sieve_script_get_last_error(script, &error);
-						if ( error == SIEVE_ERROR_NONE )
+						if (error == SIEVE_ERROR_NONE)
 							errormsg = NULL;
 					}
 					success = FALSE;
@@ -66,48 +66,51 @@ bool cmd_setactive(struct client_command_context *cmd)
 					sieve_close(&sbin);
 				}
 
-				warnings = ( sieve_get_warnings(ehandler) > 0 );
+				warnings = (sieve_get_warnings(ehandler) > 0);
 				sieve_error_handler_unref(&ehandler);
 			} T_END;
 		}
 
 		/* Activate only when script is valid (or already active) */
-		if ( success ) {
-			/* Refresh activation no matter what; this can also resolve some erroneous
-			 * situations.
-			 */
+		if (success) {
+			/* Refresh activation no matter what; this can also
+			   resolve some erroneous situations. */
 			ret = sieve_script_activate(script, (time_t)-1);
-			if ( ret < 0 ) {
+			if (ret < 0) {
 				client_send_storage_error(client, storage);
 			} else {
-				if ( warnings ) {
-					client_send_okresp(client, "WARNINGS", str_c(errors));
+				if (warnings) {
+					client_send_okresp(
+						client, "WARNINGS",
+						str_c(errors));
 				} else {
-					client_send_ok(client, ( ret > 0 ?
-						"Setactive completed." :
-						"Script is already active." ));
+					client_send_ok(client,
+						(ret > 0 ?
+						 "Setactive completed." :
+						 "Script is already active."));
 				}
 			}
-		} else if ( errormsg == NULL ) {
+		} else if (errormsg == NULL) {
 			client_send_no(client, str_c(errors));
 		} else {
 			client_send_no(client, errormsg);
 		}
 
-		if ( errors != NULL )
+		if (errors != NULL)
 			str_free(&errors);
 		sieve_script_unref(&script);
-
 	/* ... deactivate */
 	} else {
 		ret = sieve_storage_deactivate(storage, (time_t)-1);
 
-		if ( ret < 0 )
+		if (ret < 0)
 			client_send_storage_error(client, storage);
-		else
-			client_send_ok(client, ( ret > 0 ?
- 				"Active script is now deactivated." :
-				"No scripts currently active." ));
+		else {
+			client_send_ok(client,
+				       (ret > 0 ?
+				        "Active script is now deactivated." :
+				        "No scripts currently active."));
+		}
 	}
 
 	return TRUE;
-- 
GitLab