mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-12-24 19:30:12 +01:00
iconv fix, pilerimport can handle up to 1024 mbox files
This commit is contained in:
parent
a3d0b399c1
commit
d763892f3e
@ -13,7 +13,7 @@
|
||||
|
||||
#define VERSION "0.1.20"
|
||||
|
||||
#define BUILD 681
|
||||
#define BUILD 684
|
||||
|
||||
#define HOSTID "mailarchiver"
|
||||
|
||||
|
@ -276,17 +276,19 @@ void fixupEncodedHeaderLine(char *buf){
|
||||
|
||||
if(strlen(encoding) > 2 && strcasecmp(encoding, "utf-8")){
|
||||
need_encoding = 1;
|
||||
memset(tmpbuf, 0, sizeof(tmpbuf));
|
||||
|
||||
cd = iconv_open("utf-8", encoding);
|
||||
|
||||
memset(tmpbuf, 0, sizeof(tmpbuf));
|
||||
|
||||
inbuf = s+3;
|
||||
outbuf = &tmpbuf[0];
|
||||
inbytesleft = strlen(s+3);
|
||||
outbytesleft = sizeof(tmpbuf)-1;
|
||||
size = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
|
||||
iconv_close(cd);
|
||||
if(cd != (iconv_t)-1){
|
||||
inbuf = s+3;
|
||||
outbuf = &tmpbuf[0];
|
||||
inbytesleft = strlen(s+3);
|
||||
outbytesleft = sizeof(tmpbuf)-1;
|
||||
size = iconv(cd, &inbuf, &inbytesleft, &outbuf, &outbytesleft);
|
||||
iconv_close(cd);
|
||||
}
|
||||
else { syslog(LOG_PRIORITY, "unsupported encoding: '%s'", encoding); }
|
||||
}
|
||||
|
||||
if(need_encoding == 1 && size >= 0)
|
||||
|
@ -20,13 +20,14 @@
|
||||
#include <piler.h>
|
||||
|
||||
|
||||
#define SKIPLIST "junk,trash,spam,draft"
|
||||
#define MBOX_ARGS 1024
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
|
||||
int quiet=0;
|
||||
|
||||
#define SKIPLIST "junk,trash,spam,draft"
|
||||
|
||||
int connect_to_imap_server(int sd, int *seq, char *imapserver, char *username, char *password);
|
||||
int list_folders(int sd, int *seq, char *folders, int foldersize);
|
||||
int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sdata, struct __data *data, struct __config *cfg);
|
||||
@ -206,14 +207,14 @@ void usage(){
|
||||
|
||||
|
||||
int main(int argc, char **argv){
|
||||
int i, rc=0;
|
||||
int tot_msgs=0;
|
||||
char *configfile=CONFIG_FILE, *mailbox=NULL, *emlfile=NULL, *directory=NULL;
|
||||
int i, rc=0, n_mbox=0, tot_msgs=0;
|
||||
char *configfile=CONFIG_FILE, *emlfile=NULL, *mbox[MBOX_ARGS], *directory=NULL;
|
||||
char *imapserver=NULL, *username=NULL, *password=NULL, *skiplist=SKIPLIST;
|
||||
struct session_data sdata;
|
||||
struct __config cfg;
|
||||
struct __data data;
|
||||
|
||||
for(i=0; i<MBOX_ARGS; i++) mbox[i] = NULL;
|
||||
|
||||
while((i = getopt(argc, argv, "c:m:e:d:i:u:p:x:h?")) > 0){
|
||||
switch(i){
|
||||
@ -231,7 +232,12 @@ int main(int argc, char **argv){
|
||||
break;
|
||||
|
||||
case 'm' :
|
||||
mailbox = optarg;
|
||||
if(n_mbox < MBOX_ARGS){
|
||||
mbox[n_mbox++] = optarg;
|
||||
} else {
|
||||
printf("too many -m <mailbox> arguments: %s\n", optarg);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'i' :
|
||||
@ -263,7 +269,7 @@ int main(int argc, char **argv){
|
||||
|
||||
|
||||
|
||||
if(!mailbox && !emlfile && !directory && !imapserver) usage();
|
||||
if(!mbox[0] && !emlfile && !directory && !imapserver) usage();
|
||||
|
||||
|
||||
cfg = read_config(configfile);
|
||||
@ -294,7 +300,11 @@ int main(int argc, char **argv){
|
||||
load_rules(&sdata, &(data.retention_rules), SQL_RETENTION_RULE_TABLE);
|
||||
|
||||
if(emlfile) rc = import_message(emlfile, &sdata, &data, &cfg);
|
||||
if(mailbox) rc = import_from_mailbox(mailbox, &sdata, &data, &cfg);
|
||||
if(mbox[0]){
|
||||
for(i=0; i<n_mbox; i++){
|
||||
rc = import_from_mailbox(mbox[i], &sdata, &data, &cfg);
|
||||
}
|
||||
}
|
||||
if(directory) rc = import_from_maildir(directory, &sdata, &data, &tot_msgs, &cfg);
|
||||
if(imapserver && username && password) rc = import_from_imap_server(imapserver, username, password, &sdata, &data, skiplist, &cfg);
|
||||
|
||||
|
@ -51,6 +51,8 @@ int main(int argc, char **argv){
|
||||
printf("locale: %s\n", setlocale(LC_MESSAGES, cfg.locale));
|
||||
setlocale(LC_CTYPE, cfg.locale);
|
||||
|
||||
printf("build: %d\n", get_build());
|
||||
|
||||
data.archiving_rules = NULL;
|
||||
data.retention_rules = NULL;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user