From badedb4624482d9c8013b4253a67d00c85563c5f Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Mon, 25 Aug 2008 12:15:46 +0200 Subject: [PATCH] Cleaned up Sieve tools. --- src/sieve-bin/bin-common.c | 5 ++++- src/sieve-bin/bin-common.h | 5 ++++- src/sieve-bin/mail-raw.c | 17 +++++++++++++---- src/sieve-bin/mail-raw.h | 3 +++ src/sieve-bin/namespaces.c | 13 ++++++++----- src/sieve-bin/namespaces.h | 2 +- src/sieve-bin/sieve-exec.c | 22 ++++++++++++++++++++-- src/sieve-bin/sieve-test.c | 15 ++++++++++++++- src/sieve-bin/sievec.c | 10 +++++++++- src/sieve-bin/sieved.c | 11 ++++++++++- 10 files changed, 86 insertions(+), 17 deletions(-) diff --git a/src/sieve-bin/bin-common.c b/src/sieve-bin/bin-common.c index 47f9622b4..7deb5dd6a 100644 --- a/src/sieve-bin/bin-common.c +++ b/src/sieve-bin/bin-common.c @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #include "lib.h" #include "lib-signals.h" #include "ioloop.h" @@ -14,7 +17,7 @@ #include <fcntl.h> #include <pwd.h> -/* Functionality common to all sieve test binaries */ +/* Functionality common to all sieve test tools */ /* FIXME: this file is currently very messy */ diff --git a/src/sieve-bin/bin-common.h b/src/sieve-bin/bin-common.h index 0457b4b6c..0d7076110 100644 --- a/src/sieve-bin/bin-common.h +++ b/src/sieve-bin/bin-common.h @@ -1,9 +1,12 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #ifndef __BIN_COMMON_H #define __BIN_COMMON_H #include "sieve.h" -/* Functionality common to all sieve test binaries */ +/* Functionality common to all sieve test tools */ void bin_init(void); void bin_deinit(void); diff --git a/src/sieve-bin/mail-raw.c b/src/sieve-bin/mail-raw.c index 693ad63c7..9dbb4878b 100644 --- a/src/sieve-bin/mail-raw.c +++ b/src/sieve-bin/mail-raw.c @@ -1,10 +1,11 @@ -/* Copyright (c) 2005-2007 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ /* This file was gratefully stolen from dovecot/src/deliver/deliver.c and altered * to suit our needs. So, this contains lots and lots of duplicated code. - * The sieve_test program needs to read an email message from stdin and it needs - * to build a struct mail (to be fed to the sieve library). Deliver does something - * similar already, so that source was a basis for this test binary. + * The sieve-test and sieve-exec programs need to read an email message from stdin + * and needs to build a struct mail (to be fed to the sieve library). Deliver does + * something similar already, so that source was a basis for these test tools. */ #include "lib.h" @@ -26,12 +27,20 @@ #include <fcntl.h> #include <pwd.h> +/* + * Configuration + */ + #define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON" /* After buffer grows larger than this, create a temporary file to /tmp where to read the mail. */ #define MAIL_MAX_MEMORY_BUFFER (1024*128) +/* + * Raw mail implementation + */ + static struct istream *create_raw_stream(int fd) { struct istream *input, *input2, *input_list[2]; diff --git a/src/sieve-bin/mail-raw.h b/src/sieve-bin/mail-raw.h index 47e149f8f..050174047 100644 --- a/src/sieve-bin/mail-raw.h +++ b/src/sieve-bin/mail-raw.h @@ -1,3 +1,6 @@ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ + #ifndef __MAIL_RAW_H #define __MAIL_RAW_H diff --git a/src/sieve-bin/namespaces.c b/src/sieve-bin/namespaces.c index f032b3e85..660f50a99 100644 --- a/src/sieve-bin/namespaces.c +++ b/src/sieve-bin/namespaces.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2005-2007 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ #include "lib.h" #include "istream.h" @@ -23,7 +24,9 @@ #define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON" -/* Hideous .... */ +/* Initialization of available mail storage and mailbox list + * formats. + */ extern struct mail_storage raw_storage; extern struct mail_storage maildir_storage; @@ -38,9 +41,9 @@ extern struct mailbox_list maildir_mailbox_list; extern struct mailbox_list fs_mailbox_list; void index_mailbox_list_init(void); void mailbox_list_register_all(void) { -mailbox_list_register(&maildir_mailbox_list); -mailbox_list_register(&fs_mailbox_list); -index_mailbox_list_init(); + mailbox_list_register(&maildir_mailbox_list); + mailbox_list_register(&fs_mailbox_list); + index_mailbox_list_init(); } void namespaces_init(void) diff --git a/src/sieve-bin/namespaces.h b/src/sieve-bin/namespaces.h index 81e9fc030..572127f20 100644 --- a/src/sieve-bin/namespaces.h +++ b/src/sieve-bin/namespaces.h @@ -4,4 +4,4 @@ void namespaces_init(void); void namespaces_deinit(void); -#endif /* __MAIL_RAW_H */ +#endif /* __NAMESPACES_H */ diff --git a/src/sieve-bin/sieve-exec.c b/src/sieve-bin/sieve-exec.c index aad34b088..193635220 100644 --- a/src/sieve-bin/sieve-exec.c +++ b/src/sieve-bin/sieve-exec.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2005-2007 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ #include "lib.h" #include "ostream.h" @@ -18,10 +19,13 @@ #include <fcntl.h> #include <pwd.h> - #define DEFAULT_SENDMAIL_PATH "/usr/lib/sendmail" #define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON" +/* + * Dummy SMTP session + */ + static void *sieve_smtp_open(const char *destination, const char *return_path, FILE **file_r) { @@ -41,6 +45,10 @@ static bool sieve_smtp_close(void *handle ATTR_UNUSED) return TRUE; } +/* + * Dummy duplicate check implementation + */ + static int duplicate_check(const void *id ATTR_UNUSED, size_t id_size ATTR_UNUSED, const char *user) { @@ -55,6 +63,10 @@ static void duplicate_mark i_info("marked duplicate for user %s.\n", user); } +/* + * Print help + */ + static void print_help(void) { printf( @@ -64,6 +76,10 @@ static void print_help(void) ); } +/* + * Tool implementation + */ + int main(int argc, char **argv) { const char *scriptfile, *recipient, *sender, *mailbox, *dumpfile, *mailfile; @@ -147,6 +163,7 @@ int main(int argc, char **argv) namespaces_init(); + /* Obtain mail namespaces from -l argument */ if ( mailloc != NULL ) { struct mail_user *mail_user; @@ -165,6 +182,7 @@ int main(int argc, char **argv) ns = NULL; } + /* Open text file as mail message */ mail_raw_init(user); mailr = mail_raw_open(mfd); diff --git a/src/sieve-bin/sieve-test.c b/src/sieve-bin/sieve-test.c index 7af2d36bd..f6656d168 100644 --- a/src/sieve-bin/sieve-test.c +++ b/src/sieve-bin/sieve-test.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2005-2007 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ #include "lib.h" #include "ostream.h" @@ -16,9 +17,17 @@ #include <fcntl.h> #include <pwd.h> +/* + * Configuration + */ + #define DEFAULT_SENDMAIL_PATH "/usr/lib/sendmail" #define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON" +/* + * Print help + */ + static void print_help(void) { #ifdef SIEVE_RUNTIME_TRACE @@ -33,6 +42,10 @@ static void print_help(void) ); } +/* + * Tool implementation + */ + int main(int argc, char **argv) { const char *scriptfile, *recipient, *sender, *mailbox, *dumpfile, *mailfile; diff --git a/src/sieve-bin/sievec.c b/src/sieve-bin/sievec.c index adae16554..66d7cd51c 100644 --- a/src/sieve-bin/sievec.c +++ b/src/sieve-bin/sievec.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2002-2007 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ #include <stdio.h> #include <sys/types.h> @@ -13,6 +14,9 @@ #include "bin-common.h" +/* + * Print help + */ static void print_help(void) { printf( @@ -20,6 +24,10 @@ static void print_help(void) ); } +/* + * Tool implementation + */ + int main(int argc, char **argv) { int i; struct sieve_binary *sbin; diff --git a/src/sieve-bin/sieved.c b/src/sieve-bin/sieved.c index 12e5f3177..ab6458cf3 100644 --- a/src/sieve-bin/sieved.c +++ b/src/sieve-bin/sieved.c @@ -1,4 +1,5 @@ -/* Copyright (c) 2002-2007 Dovecot authors, see the included COPYING file */ +/* Copyright (c) 2002-2008 Dovecot Sieve authors, see the included COPYING file + */ #include <stdio.h> #include <sys/types.h> @@ -14,6 +15,10 @@ #include "bin-common.h" +/* + * Print help + */ + static void print_help(void) { printf( @@ -21,6 +26,10 @@ static void print_help(void) ); } +/* + * Tool implementation + */ + int main(int argc, char **argv) { int i; struct sieve_binary *sbin; -- GitLab