From 2a78ad2f5792d6aba6b9959a14ff3ce4db6fd266 Mon Sep 17 00:00:00 2001 From: SJ Date: Sun, 4 May 2014 10:34:00 +0200 Subject: [PATCH] restrict imap import to the given folder --- src/pilerimport.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/pilerimport.c b/src/pilerimport.c index ac1d5b45..1c0e09a9 100644 --- a/src/pilerimport.c +++ b/src/pilerimport.c @@ -32,7 +32,7 @@ extern int optind; int dryrun=0; int import_from_gui=0; - +char *folder_imap=NULL; int connect_to_imap_server(int sd, int *seq, char *username, char *password, int port, struct __data *data, int use_ssl); int list_folders(int sd, int *seq, int use_ssl, struct __data *data); @@ -313,6 +313,10 @@ int import_from_imap_server(char *server, char *username, char *password, int po if(strstr(skiplist, q->str)) skipmatch = 1; } + if(folder_imap && strstr(q->str, folder_imap) == NULL){ + skipmatch = 1; + } + if(skipmatch == 1){ if(data->quiet == 0) printf("SKIPPING FOLDER: %s\n", (char *)q->str); } @@ -505,6 +509,7 @@ int main(int argc, char **argv){ {"port", required_argument, 0, 'P' }, {"skiplist", required_argument, 0, 'x' }, {"folder", required_argument, 0, 'F' }, + {"folder_imap", required_argument, 0, 'f' }, {"quiet", required_argument, 0, 'q' }, {"recursive", required_argument, 0, 'R' }, {"remove-after-import", required_argument, 0, 'r' }, @@ -516,9 +521,9 @@ int main(int argc, char **argv){ int option_index = 0; - c = getopt_long(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:GDRrqh?", long_options, &option_index); + c = getopt_long(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:GDRrqh?", long_options, &option_index); #else - c = getopt(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:GDRrqh?"); + c = getopt(argc, argv, "c:m:M:e:d:i:K:u:p:P:x:F:f:GDRrqh?"); #endif if(c == -1) break; @@ -579,6 +584,10 @@ int main(int argc, char **argv){ folder = optarg; break; + case 'f' : + folder_imap = optarg; + break; + case 'R' : data.recursive_folder_names = 1; break;