From cbca6b3c9c69346c1c80fea9db5cd29fbbe4160a Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Mon, 14 Jul 2008 15:35:33 +0200
Subject: [PATCH] Removed various printf()s.

---
 TODO                                          |  2 +-
 .../plugins/include/ext-include-binary.c      |  2 --
 .../plugins/include/ext-include-variables.c   |  2 --
 .../variables/ext-variables-arguments.c       | 15 -----------
 src/lib-sieve/sieve-interpreter.c             |  2 +-
 src/lib-sieve/sieve-lexer.c                   |  8 ------
 src/lib-sieve/sieve-result.c                  | 27 +++++++------------
 src/sieve-bin/sieve-exec.c                    | 15 ++++++++---
 8 files changed, 24 insertions(+), 49 deletions(-)

diff --git a/TODO b/TODO
index 8e5750f3a..4aa084eff 100644
--- a/TODO
+++ b/TODO
@@ -17,6 +17,7 @@ Next (in order of descending priority/precedence):
 
 * ## MAKE A FIRST RELEASE ##
 
+* Implement notify extension with sole support for mailto mechanism. 
 * Make this implementation conform section 2.7.2 of RFC3028 (Comparisons Across
   Character Sets). 
 * Verify outgoing mail addresses at runtime when necessary (e.g. after variables 
@@ -35,7 +36,6 @@ Next (in order of descending priority/precedence):
   the binary and byte-code format. 
 * Make the engine and its extensions much more configurable. Possibly this can 
   be merged with Dovecot's new master config implementation.
-* Implement notify extension with sole support for mailto mechanism. 
 * Implement editheader extension
 * Implement mimeloop extension
 * Give the byte code format some more thought, it is currently quite rough and
diff --git a/src/lib-sieve/plugins/include/ext-include-binary.c b/src/lib-sieve/plugins/include/ext-include-binary.c
index a49549a11..c651dd9c6 100644
--- a/src/lib-sieve/plugins/include/ext-include-binary.c
+++ b/src/lib-sieve/plugins/include/ext-include-binary.c
@@ -202,8 +202,6 @@ static bool ext_include_binary_open(struct sieve_binary *sbin)
 			return FALSE;
 		}
 		
-		printf("SCRIPT: %d %d %s\n", block_id, location, str_c(script_name));
-	
 		if ( location >= EXT_INCLUDE_LOCATION_INVALID ) {
 			/* Binary is corrupt, recompile */
 			i_error("sieve: include: dependency block %d of binary %s "
diff --git a/src/lib-sieve/plugins/include/ext-include-variables.c b/src/lib-sieve/plugins/include/ext-include-variables.c
index 59f66279a..2d89d979e 100644
--- a/src/lib-sieve/plugins/include/ext-include-variables.c
+++ b/src/lib-sieve/plugins/include/ext-include-variables.c
@@ -84,7 +84,6 @@ bool ext_include_variable_import_global
 			ctx->global_vars = sieve_variable_scope_create(pool, ext_include_my_id);
 		}
 		
-		printf("VAR EXPORT: %s\n", variable);
 		var = sieve_variable_scope_get_variable(ctx->global_vars, variable, TRUE);
 		
 	} else {
@@ -101,7 +100,6 @@ bool ext_include_variable_import_global
 			return FALSE;
 		}
 		
-		printf("VAR IMPORT: %s\n", variable);
 		(void)sieve_variable_scope_declare(ctx->import_vars, variable);
 	}
 
diff --git a/src/lib-sieve/plugins/variables/ext-variables-arguments.c b/src/lib-sieve/plugins/variables/ext-variables-arguments.c
index 1455847b2..4a65b0ddf 100644
--- a/src/lib-sieve/plugins/variables/ext-variables-arguments.c
+++ b/src/lib-sieve/plugins/variables/ext-variables-arguments.c
@@ -295,22 +295,7 @@ static bool arg_variable_string_validate
 							sieve_ast_arg_list_add(arglist, strarg);
 					}
 				} else {
-					int i;
 					/* FIXME: Namespaces are not supported. */
-					/* DEBUG: Just print the variable substitution: */
-					
-					printf("NS_VARIABLE: ");
-					for ( i = 0; i < nelements; i++ ) {
-						const struct ext_variable_name *cur_element = 
-							array_idx(&substitution, (unsigned int) i);
-							
-						if ( cur_element->num_variable == -1 ) {
-							printf("%s.", str_c(cur_element->identifier));
-						} else {
-							printf("%d.", cur_element->num_variable);
-						}
-					}
-					printf("\n");
 				}
 				
 				strstart = p + 1;
diff --git a/src/lib-sieve/sieve-interpreter.c b/src/lib-sieve/sieve-interpreter.c
index 15e3b43d9..8b0c7e9ff 100644
--- a/src/lib-sieve/sieve-interpreter.c
+++ b/src/lib-sieve/sieve-interpreter.c
@@ -332,7 +332,7 @@ int sieve_interpreter_continue
 		interp->pc < sieve_binary_get_code_size(interp->runenv.sbin) ) {
 		
 		if ( !sieve_interpreter_execute_operation(interp) ) {
-			printf("Execution aborted.\n");
+			sieve_runtime_trace(&interp->runenv, "[[EXECUTION ABORTED]]");
 			ret = -1;
 		}
 	}
diff --git a/src/lib-sieve/sieve-lexer.c b/src/lib-sieve/sieve-lexer.c
index a46dd339a..54aa08f0c 100644
--- a/src/lib-sieve/sieve-lexer.c
+++ b/src/lib-sieve/sieve-lexer.c
@@ -145,11 +145,6 @@ static void sieve_lexer_shift(struct sieve_lexer *lexer)
 	  	
 		lexer->buffer_pos = 0;
 	}
-
-	/*if ( lexer->buffer != NULL )	
-		printf("D %c\n", lexer->buffer[lexer->buffer_pos]);
-	else 
-  	printf("NULL!\n");*/
 }
 
 static inline int sieve_lexer_curchar(struct sieve_lexer *lexer) {	
@@ -597,9 +592,6 @@ bool sieve_lexer_skip_token(struct sieve_lexer *lexer)
 		if ( !sieve_lexer_scan_raw_token(lexer) ) return FALSE;
 	}
 	
-	//sieve_lexer_print_token(lexer);
-	//printf("\n");
-	
 	return TRUE;
 }
 
diff --git a/src/lib-sieve/sieve-result.c b/src/lib-sieve/sieve-result.c
index 3319f0c95..a27dd83f7 100644
--- a/src/lib-sieve/sieve-result.c
+++ b/src/lib-sieve/sieve-result.c
@@ -413,9 +413,9 @@ int sieve_result_execute
 	result->action_env.msgdata = msgdata;
 	result->action_env.scriptenv = senv;
 	
-	/* Transaction start */
-	
-	printf("\nTransaction start:\n"); /* REMOVEME */
+	/* 
+     * Transaction start 
+     */
 	
 	rac = result->first_action;
 	while ( success && rac != NULL ) {
@@ -429,9 +429,9 @@ int sieve_result_execute
 		rac = rac->next;	
 	}
 	
-	/* Transaction execute */
-	
-	printf("\nTransaction execute:\n"); /* REMOVEME */
+	/* 
+     * Transaction execute 
+     */
 	
 	last_attempted = rac;
 	rac = result->first_action;
@@ -471,11 +471,9 @@ int sieve_result_execute
 		rac = rac->next;	
 	}
 	
-	/* Transaction commit/rollback */
-	if ( success ) /* REMOVEME */
-		printf("\nTransaction commit:\n");
-	else
-		printf("\nTransaction rollback:\n");
+	/* 
+     * Transaction commit/rollback 
+     */
 
 	commit_ok = success;
 	rac = result->first_action;
@@ -524,9 +522,6 @@ int sieve_result_execute
 		rac = rac->next;	
 	}
 	
-	/* REMOVEME */
-	printf("\nTransaction result: %s\n", commit_ok ? "success" : "failed");
-
 	/* Return value indicates whether the caller should attempt an implicit keep 
 	 * of its own. So, if the above transaction fails, but the implicit keep below
 	 * succeeds, the return value is still true. An error is/should be logged 
@@ -536,9 +531,7 @@ int sieve_result_execute
 	/* Execute implicit keep if the transaction failed or when the implicit keep
 	 * was not canceled during transaction. 
 	 */
-	if ( !commit_ok || implicit_keep ) {
-		printf("Executing implicit keep\n");
-		
+	if ( !commit_ok || implicit_keep ) {		
 		if ( !sieve_result_implicit_keep(result, !commit_ok) ) 
 			return -1;
 			
diff --git a/src/sieve-bin/sieve-exec.c b/src/sieve-bin/sieve-exec.c
index 17754310f..e91ac5a12 100644
--- a/src/sieve-bin/sieve-exec.c
+++ b/src/sieve-bin/sieve-exec.c
@@ -189,10 +189,19 @@ int main(int argc, char **argv)
 	sieve_error_handler_accept_infolog(ehandler, TRUE);
 
 	/* Run */
-	if ( sieve_execute(sbin, &msgdata, &scriptenv, ehandler) > 0 )
+	switch ( sieve_execute(sbin, &msgdata, &scriptenv, ehandler) ) {
+	case 1:
 		i_info("Final result: success\n");
-	else
-		i_info("Final result: failed (caller please handle implicit keep!)\n");
+		break;
+	case 0:
+		i_info("Final result: failed; resolved with successful implicit keep\n");
+		break;
+	case -1:
+		i_info("Final result: utter failure (caller please handle implicit keep!)\n");
+		break;
+	default:
+		i_info("Final result: unrecognized return value?!\n");	
+	}
 
 	sieve_close(&sbin);
 	sieve_error_handler_unref(&ehandler);
-- 
GitLab