From ea5513105ab3bab29d98afcfdac91adefb204283 Mon Sep 17 00:00:00 2001 From: SJ Date: Wed, 4 Jun 2014 22:20:10 +0200 Subject: [PATCH] extra recipient for piler --- src/config.h | 2 +- src/defs.h | 1 + src/parser.c | 10 ++++++++++ src/pilerimport.c | 18 ++++++++++++------ src/test.c | 9 ++++++++- 5 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/config.h b/src/config.h index 23fa5a2f..44962c77 100644 --- a/src/config.h +++ b/src/config.h @@ -14,7 +14,7 @@ #define VERSION "0.1.25-rc2" -#define BUILD 873 +#define BUILD 874 #define HOSTID "mailarchiver" diff --git a/src/defs.h b/src/defs.h index af093878..e2dadb18 100644 --- a/src/defs.h +++ b/src/defs.h @@ -260,6 +260,7 @@ struct memcached_server { struct import { + char *extra_recipient; int status; int total_messages; int processed_messages; diff --git a/src/parser.c b/src/parser.c index 3c3a3d13..72e5ca67 100644 --- a/src/parser.c +++ b/src/parser.c @@ -32,6 +32,16 @@ struct _state parse_message(struct session_data *sdata, int take_into_pieces, st } + if(sdata->import == 1 && data->import->extra_recipient){ + len = strlen(data->import->extra_recipient); + memcpy(&(state.b_to[state.tolen]), data->import->extra_recipient, len); + state.tolen += len; + memcpy(&(state.b_to[state.tolen]), " ", 1); + state.tolen++; + strtolower(state.b_to); + } + + if(sdata->num_of_rcpt_to > 0){ for(i=0; inum_of_rcpt_to; i++){ extractEmail(sdata->rcptto[i], puf); diff --git a/src/pilerimport.c b/src/pilerimport.c index 3e446dd9..905cd039 100644 --- a/src/pilerimport.c +++ b/src/pilerimport.c @@ -486,6 +486,7 @@ int main(int argc, char **argv){ import.import_job_id = import.total_messages = import.processed_messages = 0; import.started = import.updated = import.finished = import.remove_after_import = 0; + import.extra_recipient = NULL; data.import = &import; @@ -511,20 +512,21 @@ int main(int argc, char **argv){ {"skiplist", required_argument, 0, 'x' }, {"folder", required_argument, 0, 'F' }, {"folder_imap", required_argument, 0, 'f' }, - {"quiet", required_argument, 0, 'q' }, + {"add-recipient",required_argument, 0, 'a' }, + {"quiet", no_argument, 0, 'q' }, {"recursive", required_argument, 0, 'R' }, - {"remove-after-import", required_argument, 0, 'r' }, - {"gui-import", required_argument, 0, 'G' }, - {"dry-run", required_argument, 0, 'D' }, + {"remove-after-import",no_argument, 0, 'r' }, + {"gui-import", no_argument, 0, 'G' }, + {"dry-run", no_argument, 0, 'D' }, {"help", no_argument, 0, 'h' }, {0,0,0,0} }; int option_index = 0; - c = getopt_long(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:GDRrqh?", long_options, &option_index); + c = getopt_long(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:a:GDRrqh?", long_options, &option_index); #else - c = getopt(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:GDRrqh?"); + c = getopt(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:a:GDRrqh?"); #endif if(c == -1) break; @@ -597,6 +599,10 @@ int main(int argc, char **argv){ data.import->remove_after_import = 1; break; + case 'a' : + data.import->extra_recipient = optarg; + break; + case 'G' : import_from_gui = 1; break; diff --git a/src/test.c b/src/test.c index fdfe6acd..f2170205 100644 --- a/src/test.c +++ b/src/test.c @@ -22,12 +22,13 @@ int main(int argc, char **argv){ struct _state state; struct __config cfg; struct __data data; + struct import import; char *rule; srand(getpid()); if(argc < 2){ - fprintf(stderr, "usage: %s \n", argv[0]); + fprintf(stderr, "usage: %s []\n", argv[0]); exit(1); } @@ -47,6 +48,12 @@ int main(int argc, char **argv){ printf("build: %d\n", get_build()); + import.extra_recipient = NULL; + + if(argc > 2) import.extra_recipient = argv[2]; + + data.import = &import; + data.folder = 0; data.recursive_folder_names = 0;