From 8da93e37b0b0b34598c68db51b77979191bc9234 Mon Sep 17 00:00:00 2001 From: Stephan Bosch <stephan@rename-it.nl> Date: Thu, 12 Feb 2009 01:14:14 +0100 Subject: [PATCH] Added -x parameter to sieved tool. --- doc/man/sieved.1 | 7 ++++++- src/sieve-tools/sieved.c | 24 +++++++++++++++++------- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/doc/man/sieved.1 b/doc/man/sieved.1 index 521b0b595..15d53b90d 100644 --- a/doc/man/sieved.1 +++ b/doc/man/sieved.1 @@ -2,7 +2,7 @@ .SH NAME sieved \- Sieve script binary dump tool for the Dovecot secure IMAP server .SH SYNOPSIS -sieved \fIsieve-binary\fR [\fIoutfile\fR] +sieved [\fB-x\fR "\fIextension extension ...\fR"] \fIsieve-binary\fR [\fIoutfile\fR] .br .SH DESCRIPTION .PP @@ -30,6 +30,11 @@ program. Compiled Sieve programs are represented as flat byte code and therefore the main program is a disassembly listing of the interpreter operations. Extensions can define new operations and use additional blocks. Therefore, the output of \fBsieved\fP depends greatly on the language extensions used when compiling the binary. +.SH OPTIONS +.TP +\fB-x\fP "\fIextension extension ...\fP" +Set the available extensions. The option's parameter is a space-separated list of the active +extensions. Unknown extensions are ignored, but a warning is produced. .SH AUTHOR .PP The Sieve implementation for Dovecot was written by Stephan Bosch <stephan@rename-it.nl>. diff --git a/src/sieve-tools/sieved.c b/src/sieve-tools/sieved.c index 24c4ad234..5447e3b14 100644 --- a/src/sieve-tools/sieved.c +++ b/src/sieve-tools/sieved.c @@ -33,11 +33,19 @@ static void print_help(void) int main(int argc, char **argv) { int i; struct sieve_binary *sbin; - const char *binfile, *outfile; - - binfile = outfile = NULL; + const char *binfile, *outfile, *extensions; + + sieve_tool_init(); + + binfile = outfile = extensions = NULL; for (i = 1; i < argc; i++) { - if ( binfile == NULL ) { + if (strcmp(argv[i], "-x") == 0) { + /* extensions */ + i++; + if (i == argc) + i_fatal("Missing -x argument"); + extensions = argv[i]; + } else if ( binfile == NULL ) { binfile = argv[i]; } else if ( outfile == NULL ) { outfile = argv[i]; @@ -51,9 +59,11 @@ int main(int argc, char **argv) { print_help(); i_fatal("missing <binfile> argument"); } - - sieve_tool_init(); - + + if ( extensions != NULL ) { + sieve_set_extensions(extensions); + } + sbin = sieve_binary_open(binfile, NULL); if ( sbin != NULL && !sieve_binary_load(sbin) ) { -- GitLab