diff --git a/.hgignore b/.hgignore index ab593f7d6bd763f1d650ad916ea2289b505c4795..a893372fe5a8afd902af2524e252a68dee544029 100644 --- a/.hgignore +++ b/.hgignore @@ -47,4 +47,5 @@ Makefile.in **/Makefile **/Makefile.in -src/lib-sieve/sievec +src/sieve-bin/sievec +src/sieve-bin/sieve_test diff --git a/src/lib-sieve/Makefile.am b/src/lib-sieve/Makefile.am index 78c2a189deb975ea50d49c4f72152946fc8d1f26..2af9df205f102bb88c3c8d3696aeddeeba89c559 100644 --- a/src/lib-sieve/Makefile.am +++ b/src/lib-sieve/Makefile.am @@ -42,7 +42,8 @@ libsieve_a_SOURCES = \ $(tsts) \ $(cmds) \ sieve-extensions.c \ - $(exts) + $(exts) \ + sieve.c noinst_HEADERS = \ sieve-lexer.h \ @@ -55,5 +56,6 @@ noinst_HEADERS = \ sieve-result.h sieve-error.h \ sieve-commands.h \ - sieve-code.h - sieve-extensions.h + sieve-code.h \ + sieve-extensions.h \ + sieve.h diff --git a/src/lib-sieve/sieve-ast.c b/src/lib-sieve/sieve-ast.c index bf2a19294568cd205def016532b5e5aa4cca5e31..ab1e45e2e6a51651092888838216c63b9c664f71 100644 --- a/src/lib-sieve/sieve-ast.c +++ b/src/lib-sieve/sieve-ast.c @@ -252,7 +252,7 @@ void sieve_ast_ref(struct sieve_ast *ast) { } void sieve_ast_unref(struct sieve_ast **ast) { - if ( ast != NULL ) { + if ( ast != NULL && *ast != NULL ) { pool_unref(&((*ast)->pool)); *ast = NULL; } diff --git a/src/lib-sieve/sieve-generator.c b/src/lib-sieve/sieve-generator.c index 50601f7b3d75096dc905a66a8eadefc3479cec1f..a8e0a932f9480fe1ab1a71454e023c90f00a7b7f 100644 --- a/src/lib-sieve/sieve-generator.c +++ b/src/lib-sieve/sieve-generator.c @@ -321,7 +321,7 @@ bool sieve_generate_block(struct sieve_generator *generator, struct sieve_ast_no return TRUE; } -struct sieve_binary *sieve_generate(struct sieve_generator *generator) { +struct sieve_binary *sieve_generator_run(struct sieve_generator *generator) { if ( sieve_generate_block(generator, sieve_ast_root(generator->ast)) ) { return generator->binary; } diff --git a/src/lib-sieve/sieve-generator.h b/src/lib-sieve/sieve-generator.h index 189629af5cd27982e52b1958866396587d5956d8..cffaf058018f8331455630d689e2edce0e664b7b 100644 --- a/src/lib-sieve/sieve-generator.h +++ b/src/lib-sieve/sieve-generator.h @@ -57,7 +57,7 @@ bool sieve_generator_emit_stringlist_argument bool sieve_generate_block(struct sieve_generator *generator, struct sieve_ast_node *block); bool sieve_generate_test(struct sieve_generator *generator, struct sieve_ast_node *tst_node, struct sieve_jumplist *jlist, bool jump_true); -struct sieve_binary *sieve_generate(struct sieve_generator *genarator); +struct sieve_binary *sieve_generator_run(struct sieve_generator *genarator); #endif diff --git a/src/lib-sieve/sieve-parser.c b/src/lib-sieve/sieve-parser.c index 2f9ac59c54737eb23e6a7bb13f1c1a8e2d0329dc..77253862509cd18aa048544ba08580144338b784 100644 --- a/src/lib-sieve/sieve-parser.c +++ b/src/lib-sieve/sieve-parser.c @@ -340,7 +340,7 @@ static bool sieve_parse_commands return result; } -bool sieve_parse(struct sieve_parser *parser) +bool sieve_parser_run(struct sieve_parser *parser) { /* Scan first token */ sieve_lexer_skip_token(parser->lexer); diff --git a/src/lib-sieve/sieve-parser.h b/src/lib-sieve/sieve-parser.h index 7a6b6db8c15b9a4ec890e0f09e9ee84d140ed25b..3d94f9564efb4ad60de3b2122f37617004d2638c 100644 --- a/src/lib-sieve/sieve-parser.h +++ b/src/lib-sieve/sieve-parser.h @@ -9,6 +9,6 @@ struct sieve_parser; struct sieve_parser *sieve_parser_create(int fd, struct sieve_ast *ast, struct sieve_error_handler *ehandler); void sieve_parser_free(struct sieve_parser *parser); -bool sieve_parse(struct sieve_parser *parser); +bool sieve_parser_run(struct sieve_parser *parser); #endif /* __SIEVE_PARSER_H__ */ diff --git a/src/lib-sieve/sieve-validator.c b/src/lib-sieve/sieve-validator.c index d6e00558a44c95a68e2eaa989eba218217bdb4d3..8da75647c361af350aa4290dacc9318a1f25cf70 100644 --- a/src/lib-sieve/sieve-validator.c +++ b/src/lib-sieve/sieve-validator.c @@ -597,7 +597,7 @@ static bool sieve_validate_block(struct sieve_validator *validator, struct sieve return TRUE; } -bool sieve_validate(struct sieve_validator *validator) { +bool sieve_validator_run(struct sieve_validator *validator) { return sieve_validate_block(validator, sieve_ast_root(validator->ast)); } diff --git a/src/lib-sieve/sieve-validator.h b/src/lib-sieve/sieve-validator.h index f00ee5c1e018c33becc6ee93c719ddccdee34132..a1bd69f18f25188481874d6fb9e46748579fbfa9 100644 --- a/src/lib-sieve/sieve-validator.h +++ b/src/lib-sieve/sieve-validator.h @@ -12,7 +12,7 @@ struct sieve_command_registration; struct sieve_validator *sieve_validator_create(struct sieve_ast *ast, struct sieve_error_handler *ehandler); void sieve_validator_free(struct sieve_validator *validator); -bool sieve_validate(struct sieve_validator *validator); +bool sieve_validator_run(struct sieve_validator *validator); void sieve_validator_warning (struct sieve_validator *validator, struct sieve_ast_node *node, const char *fmt, ...); diff --git a/src/lib-sieve/sieve.c b/src/lib-sieve/sieve.c new file mode 100644 index 0000000000000000000000000000000000000000..05d9d902d9467f41cf6c60a923ce741c9ce210f6 --- /dev/null +++ b/src/lib-sieve/sieve.c @@ -0,0 +1,150 @@ +#include "lib.h" +#include "str.h" +#include "istream.h" +#include "buffer.h" + +#include "sieve-parser.h" +#include "sieve-ast.h" +#include "sieve-validator.h" +#include "sieve-generator.h" +#include "sieve-interpreter.h" + +#include "sieve.h" + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdlib.h> +#include <unistd.h> +#include <stdio.h> + +static struct sieve_ast *sieve_parse(int fd, struct sieve_error_handler *ehandler) +{ + struct sieve_parser *parser; + struct sieve_ast *ast; + + /* Construct ast */ + ast = sieve_ast_create(); + + /* Parse */ + parser = sieve_parser_create(fd, ast, ehandler); + + if ( !sieve_parser_run(parser) || sieve_get_errors(ehandler) > 0 ) { + /* Failed */ + sieve_ast_unref(&ast); + ast = NULL; /* Explicit */ + } else + + sieve_parser_free(parser); + + return ast; +} + +static bool sieve_validate(struct sieve_ast *ast, struct sieve_error_handler *ehandler) +{ + bool result = TRUE; + struct sieve_validator *validator = sieve_validator_create(ast, ehandler); + + if ( !sieve_validator_run(validator) || sieve_get_errors(ehandler) > 0 ) + result = FALSE; + + sieve_validator_free(validator); + + return result; +} + +static struct sieve_binary *sieve_generate(struct sieve_ast *ast) +{ + struct sieve_generator *generator = sieve_generator_create(ast); + struct sieve_binary *result; + + result = sieve_generator_run(generator); + + sieve_generator_free(generator); + + return result; +} + +struct sieve_binary *sieve_compile(int fd) +{ + struct sieve_binary *result; + struct sieve_error_handler *ehandler; + struct sieve_ast *ast; + + /* Construct error handler */ + ehandler = sieve_error_handler_create(); + + /* Parse */ + + printf("Parsing sieve script...\n"); + + if ( (ast = sieve_parse(fd, ehandler)) == NULL ) { + printf("Parse failed.\n"); + return NULL; + } + + printf("Parse successful.\n"); + sieve_ast_unparse(ast); + + /* Validate */ + + printf("Validating script...\n"); + + if ( !sieve_validate(ast, ehandler) ) { + printf("Validation failed.\n"); + + sieve_ast_unref(&ast); + return NULL; + } + + printf("Validation successful.\n"); + + /* Generate */ + + printf("Generating script...\n"); + + if ( (result=sieve_generate(ast)) == NULL ) { + printf("Script generation failed.\n"); + + sieve_ast_unref(&ast); + return NULL; + } + + printf("Script generation successful.\n"); + + /* Cleanup */ + sieve_ast_unref(&ast); + + return result; +} + +void sieve_dump(struct sieve_binary *binary) +{ + struct sieve_interpreter *interpreter = sieve_interpreter_create(binary); + + printf("Code Dump:\n\n"); + sieve_interpreter_dump_code(interpreter); + + sieve_interpreter_free(interpreter); +} + +bool sieve_execute(struct sieve_binary *binary) +{ + bool result = TRUE; + struct sieve_interpreter *interpreter; + + printf("Code Dump:\n\n"); + interpreter = sieve_interpreter_create(binary); + + sieve_interpreter_dump_code(interpreter); + + printf("Code Execute:\n\n"); + if ( sieve_interpreter_run(interpreter) == NULL ) { + result = FALSE; + } + + sieve_interpreter_free(interpreter); + + return result; +} + diff --git a/src/lib-sieve/sieve.h b/src/lib-sieve/sieve.h new file mode 100644 index 0000000000000000000000000000000000000000..29dff8791288792e9d0e6c3621618a701769c390 --- /dev/null +++ b/src/lib-sieve/sieve.h @@ -0,0 +1,10 @@ +#ifndef __SIEVE_H +#define __SIEVE_H + +#include "sieve-binary.h" + +struct sieve_binary *sieve_compile(int fd); +void sieve_dump(struct sieve_binary *binary); +bool sieve_execute(struct sieve_binary *binary); + +#endif diff --git a/src/sieve-bin/Makefile b/src/sieve-bin/Makefile deleted file mode 100644 index 935e219d7c654f96c3e4a3189633f848f60d1eac..0000000000000000000000000000000000000000 --- a/src/sieve-bin/Makefile +++ /dev/null @@ -1,500 +0,0 @@ -# Makefile.in generated by automake 1.9.6 from Makefile.am. -# src/sieve-bin/Makefile. Generated from Makefile.in by configure. - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - - - -srcdir = . -top_srcdir = ../.. - -pkgdatadir = $(datadir)/dovecot-libsieve -pkglibdir = $(libdir)/dovecot-libsieve -pkgincludedir = $(includedir)/dovecot-libsieve -top_builddir = ../.. -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = /usr/bin/install -c -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = i686-pc-linux-gnu -host_triplet = i686-pc-linux-gnu -bin_PROGRAMS = sievec$(EXEEXT) -subdir = src/sieve-bin -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libsieve-config.h -CONFIG_CLEAN_FILES = -am__installdirs = "$(DESTDIR)$(bindir)" -binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) -PROGRAMS = $(bin_PROGRAMS) -am_sievec_OBJECTS = sievec.$(OBJEXT) -sievec_OBJECTS = $(am_sievec_OBJECTS) -am__DEPENDENCIES_1 = $(top_srcdir)/src/lib-sieve/libsieve.a \ - $(dovecot_incdir)/src/lib/liblib.a -am__DEPENDENCIES_2 = $(plugin_dir)/vacation/lib_ext_vacation.a -am__DEPENDENCIES_3 = -am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ - $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_3) \ - $(am__DEPENDENCIES_3) -DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(sievec_SOURCES) -DIST_SOURCES = $(sievec_SOURCES) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = ${SHELL} /home/stephan/src/dovecot-libsieve/missing --run aclocal-1.9 -AMDEP_FALSE = # -AMDEP_TRUE = -AMTAR = ${SHELL} /home/stephan/src/dovecot-libsieve/missing --run tar -AR = ar -AUTOCONF = ${SHELL} /home/stephan/src/dovecot-libsieve/missing --run autoconf -AUTOHEADER = ${SHELL} /home/stephan/src/dovecot-libsieve/missing --run autoheader -AUTOMAKE = ${SHELL} /home/stephan/src/dovecot-libsieve/missing --run automake-1.9 -AWK = gawk -CC = gcc -CCDEPMODE = depmode=gcc3 -CFLAGS = -std=gnu99 -g -O2 -Wall -W -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wformat=2 -Wbad-function-cast -Wstrict-aliasing=2 -CPP = gcc -E -CPPFLAGS = -CXX = g++ -CXXCPP = g++ -E -CXXDEPMODE = depmode=gcc3 -CXXFLAGS = -g -O2 -CYGPATH_W = echo -DEFS = -DHAVE_CONFIG_H -DEPDIR = .deps -ECHO = echo -ECHO_C = -ECHO_N = -n -ECHO_T = -EGREP = /bin/grep -E -EXEEXT = -F77 = -FFLAGS = -GREP = /bin/grep -HAVE_DOVECOT_LIBS_FALSE = # -HAVE_DOVECOT_LIBS_TRUE = -INSTALL_DATA = ${INSTALL} -m 644 -INSTALL_PROGRAM = ${INSTALL} -INSTALL_SCRIPT = ${INSTALL} -INSTALL_STRIP_PROGRAM = ${SHELL} $(install_sh) -c -s -LDFLAGS = -LIBICONV = -LIBOBJS = -LIBS = -LIBTOOL = $(SHELL) $(top_builddir)/libtool -LN_S = ln -s -LTLIBOBJS = -MAINT = # -MAINTAINER_MODE_FALSE = -MAINTAINER_MODE_TRUE = # -MAKEINFO = ${SHELL} /home/stephan/src/dovecot-libsieve/missing --run makeinfo -MODULE_LIBS = -export-dynamic -ldl -OBJEXT = o -PACKAGE = dovecot-libsieve -PACKAGE_BUGREPORT = stephan@rename-it.nl -PACKAGE_NAME = dovecot-libsieve -PACKAGE_STRING = dovecot-libsieve 1.0.2 -PACKAGE_TARNAME = dovecot-libsieve -PACKAGE_VERSION = 1.0.2 -PATH_SEPARATOR = : -RAND_LIBS = -RANLIB = ranlib -SET_MAKE = -SHELL = /bin/bash -STORAGE_LIBS = /home/stephan/src/release/dovecot/src/lib-storage/index/maildir/libstorage_maildir.a /home/stephan/src/release/dovecot/src/lib-storage/index/mbox/libstorage_mbox.a /home/stephan/src/release/dovecot/src/lib-storage/index/dbox/libstorage_dbox.a /home/stephan/src/release/dovecot/src/lib-storage/index/cydir/libstorage_cydir.a /home/stephan/src/release/dovecot/src/lib-storage/index/libstorage_index.a /home/stephan/src/release/dovecot/src/lib-index/libindex.a -STRIP = strip -VERSION = 1.0.2 -ac_ct_CC = gcc -ac_ct_CXX = g++ -ac_ct_F77 = -am__fastdepCC_FALSE = # -am__fastdepCC_TRUE = -am__fastdepCXX_FALSE = # -am__fastdepCXX_TRUE = -am__include = include -am__leading_dot = . -am__quote = -am__tar = ${AMTAR} chof - "$$tardir" -am__untar = ${AMTAR} xf - -bindir = ${exec_prefix}/bin -build = i686-pc-linux-gnu -build_alias = -build_cpu = i686 -build_os = linux-gnu -build_vendor = pc -datadir = ${datarootdir} -datarootdir = ${prefix}/share -docdir = ${datarootdir}/doc/${PACKAGE_TARNAME} -dovecot_incdir = /home/stephan/src/release/dovecot -dovecotdir = /home/stephan/src/release/dovecot -dvidir = ${docdir} -exec_prefix = ${prefix} -host = i686-pc-linux-gnu -host_alias = -host_cpu = i686 -host_os = linux-gnu -host_vendor = pc -htmldir = ${docdir} -includedir = ${prefix}/include -infodir = ${datarootdir}/info -install_sh = /home/stephan/src/dovecot-libsieve/install-sh -libdir = ${exec_prefix}/lib -libexecdir = ${exec_prefix}/libexec -localedir = ${datarootdir}/locale -localstatedir = ${prefix}/var -mandir = ${datarootdir}/man -mkdir_p = mkdir -p -- -moduledir = /usr/local/lib/dovecot -oldincludedir = /usr/include -pdfdir = ${docdir} -prefix = /usr/local -program_transform_name = s,x,x, -psdir = ${docdir} -sbindir = ${exec_prefix}/sbin -sharedstatedir = ${prefix}/com -sysconfdir = ${prefix}/etc -target_alias = -AM_CPPFLAGS = \ - -I$(top_srcdir)/src/lib-sieve \ - -I$(dovecot_incdir) \ - -I$(dovecot_incdir)/src/lib \ - -I$(dovecot_incdir)/src/lib-mail \ - -I$(dovecot_incdir)/src/lib-storage - -plugin_dir = \ - $(top_srcdir)/src/lib-sieve/plugins - -plugins = \ - $(plugin_dir)/vacation/lib_ext_vacation.a - -sievec_LDFLAGS = -export-dynamic -sieve_test_LDFLAGS = -export-dynamic -libs = \ - $(top_srcdir)/src/lib-sieve/libsieve.a \ - $(dovecot_incdir)/src/lib/liblib.a - -ldadd = \ - $(libs) \ - $(plugins) \ - $(LIBICONV) \ - $(RAND_LIBS) \ - $(MODULE_LIBS) - -sievec_LDADD = $(ldadd) -sieve_test_LDADD = $(ldadd) -sievec_DEPENDENCIES = $(libs) -sieve_test_DEPENDENCIES = $(libs) -sievec_SOURCES = \ - sievec.c - -sieve_test_SOURCES = \ - sieve_test.c - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: # $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/sieve-bin/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/sieve-bin/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: # $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): # $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -install-binPROGRAMS: $(bin_PROGRAMS) - @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - if test -f $$p \ - || test -f $$p1 \ - ; then \ - f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ - else :; fi; \ - done - -uninstall-binPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ - rm -f "$(DESTDIR)$(bindir)/$$f"; \ - done - -clean-binPROGRAMS: - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f $$p $$f"; \ - rm -f $$p $$f ; \ - done -sievec$(EXEEXT): $(sievec_OBJECTS) $(sievec_DEPENDENCIES) - @rm -f sievec$(EXEEXT) - $(LINK) $(sievec_LDFLAGS) $(sievec_OBJECTS) $(sievec_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -include ./$(DEPDIR)/sievec.Po - -.c.o: - if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ - then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -# source='$<' object='$@' libtool=no \ -# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ -# $(COMPILE) -c $< - -.c.obj: - if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ - then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -# source='$<' object='$@' libtool=no \ -# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ -# $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.c.lo: - if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ - then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -# source='$<' object='$@' libtool=yes \ -# DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \ -# $(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool -uninstall-info-am: - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: - for dir in "$(DESTDIR)$(bindir)"; do \ - test -z "$$dir" || $(mkdir_p) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-libtool distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-exec-am: install-binPROGRAMS - -install-info: install-info-am - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-binPROGRAMS uninstall-info-am - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ - clean-generic clean-libtool ctags distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-binPROGRAMS install-data install-data-am install-exec \ - install-exec-am install-info install-info-am install-man \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am \ - uninstall-binPROGRAMS uninstall-info-am - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/sieve-bin/Makefile.am b/src/sieve-bin/Makefile.am index 6ddde06ea5b09f08cf7073c0f39e1fc63bb60975..2aa0b524315ee91ab885e9db2845b633e1297c75 100644 --- a/src/sieve-bin/Makefile.am +++ b/src/sieve-bin/Makefile.am @@ -1,11 +1,14 @@ -bin_PROGRAMS = sievec +bin_PROGRAMS = sievec sieve_test AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib-sieve \ -I$(dovecot_incdir) \ -I$(dovecot_incdir)/src/lib \ -I$(dovecot_incdir)/src/lib-mail \ - -I$(dovecot_incdir)/src/lib-storage + -I$(dovecot_incdir)/src/lib-index \ + -I$(dovecot_incdir)/src/lib-storage \ + -I$(dovecot_incdir)/src/lib-storage/index \ + -I$(dovecot_incdir)/src/lib-storage/index/mbox plugin_dir = \ $(top_srcdir)/src/lib-sieve/plugins @@ -18,6 +21,14 @@ sieve_test_LDFLAGS = -export-dynamic libs = \ $(top_srcdir)/src/lib-sieve/libsieve.a \ + $(dovecot_incdir)/src/lib-storage/list/libstorage_list.a \ + $(dovecot_incdir)/src/lib-storage/index/mbox/libstorage_mbox.a \ + $(dovecot_incdir)/src/lib-storage/index/libstorage_index.a \ + $(dovecot_incdir)/src/lib-storage/libstorage.a \ + $(dovecot_incdir)/src/lib-index/libindex.a \ + $(dovecot_incdir)/src/lib-imap/libimap.a \ + $(dovecot_incdir)/src/lib-mail/libmail.a \ + $(dovecot_incdir)/src/lib-charset/libcharset.a \ $(dovecot_incdir)/src/lib/liblib.a ldadd = \ diff --git a/src/sieve-bin/Makefile.in b/src/sieve-bin/Makefile.in deleted file mode 100644 index 5cd9fe58e8ff6d63bd8fd21fa89ec620b5ea5619..0000000000000000000000000000000000000000 --- a/src/sieve-bin/Makefile.in +++ /dev/null @@ -1,500 +0,0 @@ -# Makefile.in generated by automake 1.9.6 from Makefile.am. -# @configure_input@ - -# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -# 2003, 2004, 2005 Free Software Foundation, Inc. -# This Makefile.in is free software; the Free Software Foundation -# gives unlimited permission to copy and/or distribute it, -# with or without modifications, as long as this notice is preserved. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY, to the extent permitted by law; without -# even the implied warranty of MERCHANTABILITY or FITNESS FOR A -# PARTICULAR PURPOSE. - -@SET_MAKE@ - -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -VPATH = @srcdir@ -pkgdatadir = $(datadir)/@PACKAGE@ -pkglibdir = $(libdir)/@PACKAGE@ -pkgincludedir = $(includedir)/@PACKAGE@ -top_builddir = ../.. -am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd -INSTALL = @INSTALL@ -install_sh_DATA = $(install_sh) -c -m 644 -install_sh_PROGRAM = $(install_sh) -c -install_sh_SCRIPT = $(install_sh) -c -INSTALL_HEADER = $(INSTALL_DATA) -transform = $(program_transform_name) -NORMAL_INSTALL = : -PRE_INSTALL = : -POST_INSTALL = : -NORMAL_UNINSTALL = : -PRE_UNINSTALL = : -POST_UNINSTALL = : -build_triplet = @build@ -host_triplet = @host@ -bin_PROGRAMS = sievec$(EXEEXT) -subdir = src/sieve-bin -DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in -ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/configure.in -am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ - $(ACLOCAL_M4) -mkinstalldirs = $(install_sh) -d -CONFIG_HEADER = $(top_builddir)/libsieve-config.h -CONFIG_CLEAN_FILES = -am__installdirs = "$(DESTDIR)$(bindir)" -binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) -PROGRAMS = $(bin_PROGRAMS) -am_sievec_OBJECTS = sievec.$(OBJEXT) -sievec_OBJECTS = $(am_sievec_OBJECTS) -am__DEPENDENCIES_1 = $(top_srcdir)/src/lib-sieve/libsieve.a \ - $(dovecot_incdir)/src/lib/liblib.a -am__DEPENDENCIES_2 = $(plugin_dir)/vacation/lib_ext_vacation.a -am__DEPENDENCIES_3 = -am__DEPENDENCIES_4 = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ - $(am__DEPENDENCIES_3) $(am__DEPENDENCIES_3) \ - $(am__DEPENDENCIES_3) -DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) -depcomp = $(SHELL) $(top_srcdir)/depcomp -am__depfiles_maybe = depfiles -COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ - $(AM_CFLAGS) $(CFLAGS) -CCLD = $(CC) -LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ - $(AM_LDFLAGS) $(LDFLAGS) -o $@ -SOURCES = $(sievec_SOURCES) -DIST_SOURCES = $(sievec_SOURCES) -ETAGS = etags -CTAGS = ctags -DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -ACLOCAL = @ACLOCAL@ -AMDEP_FALSE = @AMDEP_FALSE@ -AMDEP_TRUE = @AMDEP_TRUE@ -AMTAR = @AMTAR@ -AR = @AR@ -AUTOCONF = @AUTOCONF@ -AUTOHEADER = @AUTOHEADER@ -AUTOMAKE = @AUTOMAKE@ -AWK = @AWK@ -CC = @CC@ -CCDEPMODE = @CCDEPMODE@ -CFLAGS = @CFLAGS@ -CPP = @CPP@ -CPPFLAGS = @CPPFLAGS@ -CXX = @CXX@ -CXXCPP = @CXXCPP@ -CXXDEPMODE = @CXXDEPMODE@ -CXXFLAGS = @CXXFLAGS@ -CYGPATH_W = @CYGPATH_W@ -DEFS = @DEFS@ -DEPDIR = @DEPDIR@ -ECHO = @ECHO@ -ECHO_C = @ECHO_C@ -ECHO_N = @ECHO_N@ -ECHO_T = @ECHO_T@ -EGREP = @EGREP@ -EXEEXT = @EXEEXT@ -F77 = @F77@ -FFLAGS = @FFLAGS@ -GREP = @GREP@ -HAVE_DOVECOT_LIBS_FALSE = @HAVE_DOVECOT_LIBS_FALSE@ -HAVE_DOVECOT_LIBS_TRUE = @HAVE_DOVECOT_LIBS_TRUE@ -INSTALL_DATA = @INSTALL_DATA@ -INSTALL_PROGRAM = @INSTALL_PROGRAM@ -INSTALL_SCRIPT = @INSTALL_SCRIPT@ -INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ -LDFLAGS = @LDFLAGS@ -LIBICONV = @LIBICONV@ -LIBOBJS = @LIBOBJS@ -LIBS = @LIBS@ -LIBTOOL = @LIBTOOL@ -LN_S = @LN_S@ -LTLIBOBJS = @LTLIBOBJS@ -MAINT = @MAINT@ -MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@ -MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@ -MAKEINFO = @MAKEINFO@ -MODULE_LIBS = @MODULE_LIBS@ -OBJEXT = @OBJEXT@ -PACKAGE = @PACKAGE@ -PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ -PACKAGE_NAME = @PACKAGE_NAME@ -PACKAGE_STRING = @PACKAGE_STRING@ -PACKAGE_TARNAME = @PACKAGE_TARNAME@ -PACKAGE_VERSION = @PACKAGE_VERSION@ -PATH_SEPARATOR = @PATH_SEPARATOR@ -RAND_LIBS = @RAND_LIBS@ -RANLIB = @RANLIB@ -SET_MAKE = @SET_MAKE@ -SHELL = @SHELL@ -STORAGE_LIBS = @STORAGE_LIBS@ -STRIP = @STRIP@ -VERSION = @VERSION@ -ac_ct_CC = @ac_ct_CC@ -ac_ct_CXX = @ac_ct_CXX@ -ac_ct_F77 = @ac_ct_F77@ -am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ -am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ -am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ -am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ -am__include = @am__include@ -am__leading_dot = @am__leading_dot@ -am__quote = @am__quote@ -am__tar = @am__tar@ -am__untar = @am__untar@ -bindir = @bindir@ -build = @build@ -build_alias = @build_alias@ -build_cpu = @build_cpu@ -build_os = @build_os@ -build_vendor = @build_vendor@ -datadir = @datadir@ -datarootdir = @datarootdir@ -docdir = @docdir@ -dovecot_incdir = @dovecot_incdir@ -dovecotdir = @dovecotdir@ -dvidir = @dvidir@ -exec_prefix = @exec_prefix@ -host = @host@ -host_alias = @host_alias@ -host_cpu = @host_cpu@ -host_os = @host_os@ -host_vendor = @host_vendor@ -htmldir = @htmldir@ -includedir = @includedir@ -infodir = @infodir@ -install_sh = @install_sh@ -libdir = @libdir@ -libexecdir = @libexecdir@ -localedir = @localedir@ -localstatedir = @localstatedir@ -mandir = @mandir@ -mkdir_p = @mkdir_p@ -moduledir = @moduledir@ -oldincludedir = @oldincludedir@ -pdfdir = @pdfdir@ -prefix = @prefix@ -program_transform_name = @program_transform_name@ -psdir = @psdir@ -sbindir = @sbindir@ -sharedstatedir = @sharedstatedir@ -sysconfdir = @sysconfdir@ -target_alias = @target_alias@ -AM_CPPFLAGS = \ - -I$(top_srcdir)/src/lib-sieve \ - -I$(dovecot_incdir) \ - -I$(dovecot_incdir)/src/lib \ - -I$(dovecot_incdir)/src/lib-mail \ - -I$(dovecot_incdir)/src/lib-storage - -plugin_dir = \ - $(top_srcdir)/src/lib-sieve/plugins - -plugins = \ - $(plugin_dir)/vacation/lib_ext_vacation.a - -sievec_LDFLAGS = -export-dynamic -sieve_test_LDFLAGS = -export-dynamic -libs = \ - $(top_srcdir)/src/lib-sieve/libsieve.a \ - $(dovecot_incdir)/src/lib/liblib.a - -ldadd = \ - $(libs) \ - $(plugins) \ - $(LIBICONV) \ - $(RAND_LIBS) \ - $(MODULE_LIBS) - -sievec_LDADD = $(ldadd) -sieve_test_LDADD = $(ldadd) -sievec_DEPENDENCIES = $(libs) -sieve_test_DEPENDENCIES = $(libs) -sievec_SOURCES = \ - sievec.c - -sieve_test_SOURCES = \ - sieve_test.c - -all: all-am - -.SUFFIXES: -.SUFFIXES: .c .lo .o .obj -$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps) - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ - && exit 0; \ - exit 1;; \ - esac; \ - done; \ - echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/sieve-bin/Makefile'; \ - cd $(top_srcdir) && \ - $(AUTOMAKE) --gnu src/sieve-bin/Makefile -.PRECIOUS: Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status - @case '$?' in \ - *config.status*) \ - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ - *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ - esac; - -$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh - -$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) - cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh -install-binPROGRAMS: $(bin_PROGRAMS) - @$(NORMAL_INSTALL) - test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - if test -f $$p \ - || test -f $$p1 \ - ; then \ - f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ - $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ - else :; fi; \ - done - -uninstall-binPROGRAMS: - @$(NORMAL_UNINSTALL) - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ - echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ - rm -f "$(DESTDIR)$(bindir)/$$f"; \ - done - -clean-binPROGRAMS: - @list='$(bin_PROGRAMS)'; for p in $$list; do \ - f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ - echo " rm -f $$p $$f"; \ - rm -f $$p $$f ; \ - done -sievec$(EXEEXT): $(sievec_OBJECTS) $(sievec_DEPENDENCIES) - @rm -f sievec$(EXEEXT) - $(LINK) $(sievec_LDFLAGS) $(sievec_OBJECTS) $(sievec_LDADD) $(LIBS) - -mostlyclean-compile: - -rm -f *.$(OBJEXT) - -distclean-compile: - -rm -f *.tab.c - -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sievec.Po@am__quote@ - -.c.o: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c $< - -.c.obj: -@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` - -.c.lo: -@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ -@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi -@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< - -mostlyclean-libtool: - -rm -f *.lo - -clean-libtool: - -rm -rf .libs _libs - -distclean-libtool: - -rm -f libtool -uninstall-info-am: - -ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - mkid -fID $$unique -tags: TAGS - -TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ - test -n "$$unique" || unique=$$empty_fix; \ - $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ - $$tags $$unique; \ - fi -ctags: CTAGS -CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ - $(TAGS_FILES) $(LISP) - tags=; \ - here=`pwd`; \ - list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ - unique=`for i in $$list; do \ - if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ - done | \ - $(AWK) ' { files[$$0] = 1; } \ - END { for (i in files) print i; }'`; \ - test -z "$(CTAGS_ARGS)$$tags$$unique" \ - || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ - $$tags $$unique - -GTAGS: - here=`$(am__cd) $(top_builddir) && pwd` \ - && cd $(top_srcdir) \ - && gtags -i $(GTAGS_ARGS) $$here - -distclean-tags: - -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags - -distdir: $(DISTFILES) - @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ - topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ - list='$(DISTFILES)'; for file in $$list; do \ - case $$file in \ - $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ - $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ - esac; \ - if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ - dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ - if test "$$dir" != "$$file" && test "$$dir" != "."; then \ - dir="/$$dir"; \ - $(mkdir_p) "$(distdir)$$dir"; \ - else \ - dir=''; \ - fi; \ - if test -d $$d/$$file; then \ - if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ - cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ - fi; \ - cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ - else \ - test -f $(distdir)/$$file \ - || cp -p $$d/$$file $(distdir)/$$file \ - || exit 1; \ - fi; \ - done -check-am: all-am -check: check-am -all-am: Makefile $(PROGRAMS) -installdirs: - for dir in "$(DESTDIR)$(bindir)"; do \ - test -z "$$dir" || $(mkdir_p) "$$dir"; \ - done -install: install-am -install-exec: install-exec-am -install-data: install-data-am -uninstall: uninstall-am - -install-am: all-am - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -installcheck: installcheck-am -install-strip: - $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ - `test -z '$(STRIP)' || \ - echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install -mostlyclean-generic: - -clean-generic: - -distclean-generic: - -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) - -maintainer-clean-generic: - @echo "This command is intended for maintainers to use" - @echo "it deletes files that may require special tools to rebuild." -clean: clean-am - -clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am - -distclean: distclean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -distclean-am: clean-am distclean-compile distclean-generic \ - distclean-libtool distclean-tags - -dvi: dvi-am - -dvi-am: - -html: html-am - -info: info-am - -info-am: - -install-data-am: - -install-exec-am: install-binPROGRAMS - -install-info: install-info-am - -install-man: - -installcheck-am: - -maintainer-clean: maintainer-clean-am - -rm -rf ./$(DEPDIR) - -rm -f Makefile -maintainer-clean-am: distclean-am maintainer-clean-generic - -mostlyclean: mostlyclean-am - -mostlyclean-am: mostlyclean-compile mostlyclean-generic \ - mostlyclean-libtool - -pdf: pdf-am - -pdf-am: - -ps: ps-am - -ps-am: - -uninstall-am: uninstall-binPROGRAMS uninstall-info-am - -.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ - clean-generic clean-libtool ctags distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-binPROGRAMS install-data install-data-am install-exec \ - install-exec-am install-info install-info-am install-man \ - install-strip installcheck installcheck-am installdirs \ - maintainer-clean maintainer-clean-generic mostlyclean \ - mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ - pdf pdf-am ps ps-am tags uninstall uninstall-am \ - uninstall-binPROGRAMS uninstall-info-am - -# Tell versions [3.59,3.63) of GNU make to not export all variables. -# Otherwise a system limit (for SysV at least) may be exceeded. -.NOEXPORT: diff --git a/src/sieve-bin/sieve_test.c b/src/sieve-bin/sieve_test.c new file mode 100644 index 0000000000000000000000000000000000000000..367609f998ad0fee99119801d445142e61894d03 --- /dev/null +++ b/src/sieve-bin/sieve_test.c @@ -0,0 +1,287 @@ +/* Copyright (c) 2005-2007 Dovecot 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. + */ + +#include "lib.h" +#include "lib-signals.h" +#include "file-lock.h" +#include "array.h" +#include "ioloop.h" +#include "hostpid.h" +#include "home-expand.h" +#include "env-util.h" +#include "fd-set-nonblock.h" +#include "istream.h" +#include "istream-seekable.h" +#include "str.h" +#include "str-sanitize.h" +#include "strescape.h" +#include "message-address.h" +#include "message-header-parser.h" +#include "istream-header-filter.h" +#include "mbox-storage.h" +#include "mail-namespace.h" +#include "mbox-from.h" + +#include "sieve.h" + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <fcntl.h> +#include <pwd.h> +#include <syslog.h> + +#define DEFAULT_AUTH_SOCKET_PATH PKG_RUNDIR"/auth-master" +#define DEFAULT_SENDMAIL_PATH "/usr/lib/sendmail" +#define DEFAULT_ENVELOPE_SENDER "MAILER-DAEMON" + +/* Hideous .... */ + +extern struct mail_storage mbox_storage; +void mail_storage_register_all(void) { + mail_storage_class_register(&mbox_storage); +} + +extern struct mailbox_list fs_mailbox_list; +void index_mailbox_list_init(void); +void mailbox_list_register_all(void) { + mailbox_list_register(&fs_mailbox_list); + index_mailbox_list_init(); +} + +/* After buffer grows larger than this, create a temporary file to /tmp + where to read the mail. */ +#define MAIL_MAX_MEMORY_BUFFER (1024*128) + +/* FIXME: these two should be in some context struct instead of as globals.. */ +static const char *default_mailbox_name = NULL; +static const char *explicit_envelope_sender = NULL; + +static struct ioloop *ioloop; + +static void sig_die(int signo, void *context ATTR_UNUSED) +{ + /* warn about being killed because of some signal, except SIGINT (^C) + which is too common at least while testing :) */ + if (signo != SIGINT) + i_warning("Killed with signal %d", signo); + io_loop_stop(ioloop); +} + +static int sync_quick(struct mailbox *box) +{ + struct mailbox_sync_context *ctx; + struct mailbox_sync_rec sync_rec; + + ctx = mailbox_sync_init(box, 0); + while (mailbox_sync_next(ctx, &sync_rec)) + ; + return mailbox_sync_deinit(&ctx, 0, NULL); +} + +const char *deliver_get_return_address(struct mail *mail) +{ + struct message_address *addr; + const char *str; + + if (explicit_envelope_sender != NULL) + return explicit_envelope_sender; + + if (mail_get_first_header(mail, "Return-Path", &str) <= 0) + return NULL; + addr = message_address_parse(pool_datastack_create(), + (const unsigned char *)str, + strlen(str), 1, FALSE); + return addr == NULL || addr->mailbox == NULL || addr->domain == NULL || + *addr->mailbox == '\0' || *addr->domain == '\0' ? + NULL : t_strconcat(addr->mailbox, "@", addr->domain, NULL); +} + +const char *deliver_get_new_message_id(void) +{ + static int count = 0; + + return t_strdup_printf("<dovecot-%s-%s-%d@%s>", + dec2str(ioloop_timeval.tv_sec), + dec2str(ioloop_timeval.tv_usec), + count++, "localhost"); +} + +static const char *address_sanitize(const char *address) +{ + struct message_address *addr; + const char *ret; + pool_t pool; + + pool = pool_alloconly_create("address sanitizer", 256); + addr = message_address_parse(pool, (const unsigned char *)address, + strlen(address), 1, FALSE); + + if (addr == NULL || addr->mailbox == NULL || addr->domain == NULL || + *addr->mailbox == '\0') + ret = DEFAULT_ENVELOPE_SENDER; + else if (*addr->domain == '\0') + ret = t_strdup(addr->mailbox); + else + ret = t_strdup_printf("%s@%s", addr->mailbox, addr->domain); + pool_unref(&pool); + return ret; +} + + +static void save_header_callback(struct message_header_line *hdr, + bool *matched, bool *first) +{ + if (*first) { + *first = FALSE; + if (hdr != NULL && strncmp(hdr->name, "From ", 5) == 0) + *matched = TRUE; + } +} + +static struct istream * +create_mbox_stream(int fd, const char *envelope_sender, bool **first_r) +{ + const char *mbox_hdr; + struct istream *input_list[4], *input, *input_filter; + + fd_set_nonblock(fd, FALSE); + + envelope_sender = address_sanitize(envelope_sender); + mbox_hdr = mbox_from_create(envelope_sender, ioloop_time); + + /* kind of kludgy to allocate memory just for this, but since this + has to live as long as the input stream itself, this is the safest + way to do it without it breaking accidentally. */ + *first_r = i_new(bool, 1); + **first_r = TRUE; + input = i_stream_create_fd(fd, 4096, FALSE); + input_filter = + i_stream_create_header_filter(input, + HEADER_FILTER_EXCLUDE | + HEADER_FILTER_NO_CR, + mbox_hide_headers, + mbox_hide_headers_count, + save_header_callback, + *first_r); + i_stream_unref(&input); + + input_list[0] = i_stream_create_from_data(mbox_hdr, strlen(mbox_hdr)); + input_list[1] = input_filter; + input_list[2] = i_stream_create_from_data("\n", 1); + input_list[3] = NULL; + + input = i_stream_create_seekable(input_list, MAIL_MAX_MEMORY_BUFFER, + "/tmp/dovecot.deliver."); + i_stream_unref(&input_list[0]); + i_stream_unref(&input_list[1]); + i_stream_unref(&input_list[2]); + return input; +} + +void mail_test(struct mail *mail) +{ + const char *const *headers; + + printf("HEADERS\n"); + if (mail_get_headers_utf8(mail, "from", &headers) >= 0) + { + printf("HEADERS FOUND\n"); + int i; + for ( i = 0; headers[i] != NULL; i++ ) { + printf("HEADER: From: %s\n", headers[i]); + } + } +} + +int main(void) +{ + const char *envelope_sender = DEFAULT_ENVELOPE_SENDER; + const char *mailbox = "INBOX"; + const char *user, *error; + struct mail_namespace *mbox_ns; + struct mail_storage *storage; + struct mailbox *box; + struct istream *input; + struct mailbox_transaction_context *t; + struct mail *mail; + struct passwd *pw; + uid_t process_euid; + pool_t namespace_pool; + bool *input_first; + + lib_init(); + ioloop = io_loop_create(); + + lib_signals_init(); + lib_signals_set_handler(SIGINT, TRUE, sig_die, NULL); + lib_signals_set_handler(SIGTERM, TRUE, sig_die, NULL); + lib_signals_ignore(SIGPIPE, TRUE); + lib_signals_ignore(SIGALRM, FALSE); + + /* we're non-root. get our username and possibly our home. */ + process_euid = geteuid(); + pw = getpwuid(process_euid); + if (pw != NULL) { + user = t_strdup(pw->pw_name); + } else { + i_fatal("Couldn't lookup our username (uid=%s)", + dec2str(process_euid)); + } + + mail_storage_init(); + mail_storage_register_all(); + mailbox_list_register_all(); + + namespace_pool = pool_alloconly_create("namespaces", 1024); + + mbox_ns = mail_namespaces_init_empty(namespace_pool); + mbox_ns->flags |= NAMESPACE_FLAG_INTERNAL; + if (mail_storage_create(mbox_ns, "mbox", "/tmp", user, + 0, FILE_LOCK_METHOD_FCNTL, &error) < 0) + i_fatal("Couldn't create internal mbox storage: %s", error); + input = create_mbox_stream(0, envelope_sender, &input_first); + box = mailbox_open(mbox_ns->storage, "Dovecot Delivery Mail", input, + MAILBOX_OPEN_NO_INDEX_FILES | + MAILBOX_OPEN_MBOX_ONE_MSG_ONLY); + if (box == NULL) + i_fatal("Can't open delivery mail as mbox"); + if (sync_quick(box) < 0) + i_fatal("Can't sync delivery mail"); + + t = mailbox_transaction_begin(box, 0); + mail = mail_alloc(t, 0, NULL); + mail_set_seq(mail, 1); + + storage = NULL; + default_mailbox_name = mailbox; + + /* */ + i_stream_seek(input, 0); + mail_test(mail); + //ret = deliver_save(ns, &storage, mailbox, mail, 0, NULL); + + i_stream_unref(&input); + i_free(input_first); + + mail_free(&mail); + mailbox_transaction_rollback(&t); + mailbox_close(&box); + + mail_namespaces_deinit(&mbox_ns); + + mail_storage_deinit(); + + lib_signals_deinit(); + + io_loop_destroy(&ioloop); + lib_deinit(); + + return 0; +} diff --git a/src/sieve-bin/sievec b/src/sieve-bin/sievec deleted file mode 100755 index 7432608d8a6ae5b36779c092a61f8ea0263fc204..0000000000000000000000000000000000000000 Binary files a/src/sieve-bin/sievec and /dev/null differ diff --git a/src/sieve-bin/sievec.c b/src/sieve-bin/sievec.c index 50d5981bd5a392fe16c5cae31b6616ffd8e8b1cb..a4e01dbb734c8783ce601a274ea71e6c1be9b9fa 100644 --- a/src/sieve-bin/sievec.c +++ b/src/sieve-bin/sievec.c @@ -11,11 +11,7 @@ #include "istream.h" #include "buffer.h" -#include "sieve-parser.h" -#include "sieve-ast.h" -#include "sieve-validator.h" -#include "sieve-generator.h" -#include "sieve-interpreter.h" +#include "sieve.h" static int _open_fd(const char *path) { @@ -24,14 +20,7 @@ static int _open_fd(const char *path) int main(int argc, char **argv) { int fd; - struct sieve_error_handler *ehandler; - - struct sieve_ast *ast; - struct sieve_parser *parser; - struct sieve_validator *validator; - struct sieve_generator *generator; - struct sieve_interpreter *interpreter; - struct sieve_binary *binary; + struct sieve_binary *sbin; if ( argc < 2 ) { printf( "Usage: sievec <filename>\n"); @@ -45,57 +34,8 @@ int main(int argc, char **argv) { printf("Parsing sieve script '%s'...\n", argv[1]); - /* Construct ast */ - ast = sieve_ast_create(); - - /* Construct error handler */ - ehandler = sieve_error_handler_create(); - - /* Construct parser */ - parser = sieve_parser_create(fd, ast, ehandler); - - if ( !sieve_parse(parser) || sieve_get_errors(ehandler) > 0 ) - printf("Parse failed.\n"); - else { - printf("Parse successful.\n"); - - sieve_ast_unparse(ast); - - printf("Validating script...\n"); - validator = sieve_validator_create(ast, ehandler); - - if ( !sieve_validate(validator) || sieve_get_errors(ehandler) > 0 ) { - printf("Validation failed.\n"); - } else { - printf("Validation successful.\n"); - - printf("Generating script...\n"); - generator = sieve_generator_create(ast); - - binary = sieve_generate(generator); - if ( sieve_get_errors(ehandler) > 0 || (binary == NULL) ) { - printf("Script generation failed.\n"); - } else { - printf("Script generation successful.\n"); - - printf("Code Dump:\n\n"); - interpreter = sieve_interpreter_create(binary); - - sieve_interpreter_dump_code(interpreter); - - printf("Code Execute:\n\n"); - (void) sieve_interpreter_run(interpreter); - - sieve_interpreter_free(interpreter); - } - - sieve_generator_free(generator); - } - - sieve_validator_free(validator); - } - - sieve_parser_free(parser); - sieve_ast_unref(&ast); - close(fd); + sbin = sieve_compile(fd); + (void) sieve_dump(sbin); + + close(fd); } diff --git a/src/sieve-bin/sievec.o b/src/sieve-bin/sievec.o deleted file mode 100644 index de1ab936962b969d9b5c49f4a6ee51b55788845e..0000000000000000000000000000000000000000 Binary files a/src/sieve-bin/sievec.o and /dev/null differ