mirror of
https://bitbucket.org/jsuto/piler.git
synced 2024-11-08 05:11:59 +01:00
imap import fixes
This commit is contained in:
parent
83ce789420
commit
0a78b061d5
@ -14,7 +14,7 @@
|
||||
|
||||
#define VERSION "1.1.1-pre"
|
||||
|
||||
#define BUILD 892
|
||||
#define BUILD 893
|
||||
|
||||
#define HOSTID "mailarchiver"
|
||||
|
||||
|
@ -130,7 +130,7 @@ int process_imap_folder(int sd, int *seq, char *folder, struct session_data *sda
|
||||
|
||||
data->import->total_messages += messages;
|
||||
|
||||
for(i=1; i<=messages; i++){
|
||||
for(i=data->import->start_position; i<=messages; i++){
|
||||
data->import->processed_messages++;
|
||||
printf("processed: %7d\r", data->import->processed_messages); fflush(stdout);
|
||||
|
||||
@ -384,6 +384,7 @@ int list_folders(int sd, int *seq, int use_ssl, struct __data *data){
|
||||
|
||||
while(1){
|
||||
n = recvtimeoutssl(sd, puf, sizeof(puf), 10, use_ssl, data->ssl);
|
||||
if(n < 0) return ERR;
|
||||
|
||||
if(pos + n >= len){
|
||||
q = realloc(buf, len+MAXBUFSIZE+1);
|
||||
@ -429,7 +430,8 @@ int list_folders(int sd, int *seq, int use_ssl, struct __data *data){
|
||||
fldrlen = strtol(q, NULL, 10);
|
||||
} else {
|
||||
if(*q == '"') q++;
|
||||
|
||||
|
||||
if(q[strlen(q)-1] == ' ') q[strlen(q)-1] = '\0';
|
||||
if(q[strlen(q)-1] == '"') q[strlen(q)-1] = '\0';
|
||||
|
||||
if(fldrlen) {
|
||||
|
12
src/parser.c
12
src/parser.c
@ -190,11 +190,13 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
|
||||
}
|
||||
|
||||
if(state->is_1st_header == 1 && sdata->ms_journal == 0 && (strncmp(buf, "X-MS-Journal-Report:", strlen("X-MS-Journal-Report:")) == 0 || (sdata->import == 1 && strncmp(buf, "X-MS-Exchange-Organization-Auth", strlen("X-MS-Exchange-Organization-Auth")) == 0))){
|
||||
sdata->ms_journal = 1;
|
||||
memset(state->message_id, 0, SMALLBUFSIZE);
|
||||
if(sdata->import == 0){
|
||||
sdata->ms_journal = 1;
|
||||
memset(state->message_id, 0, SMALLBUFSIZE);
|
||||
|
||||
memset(state->b_from, 0, SMALLBUFSIZE);
|
||||
memset(state->b_from_domain, 0, SMALLBUFSIZE);
|
||||
memset(state->b_from, 0, SMALLBUFSIZE);
|
||||
memset(state->b_from_domain, 0, SMALLBUFSIZE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -636,7 +638,7 @@ int parse_line(char *buf, struct _state *state, struct session_data *sdata, int
|
||||
if(state->is_header == 1) p = strchr(buf, ' ');
|
||||
else p = buf;
|
||||
|
||||
//printf("a: %d/%d/%d/%d %s\n", state->is_1st_header, state->is_header, state->message_rfc822, state->message_state, buf);
|
||||
printf("a: %d/%d/%d/%d %s\n", state->is_1st_header, state->is_header, state->message_rfc822, state->message_state, buf);
|
||||
|
||||
do {
|
||||
memset(puf, 0, sizeof(puf));
|
||||
|
@ -297,8 +297,17 @@ int import_from_imap_server(char *server, char *username, char *password, int po
|
||||
}
|
||||
|
||||
|
||||
rc = list_folders(sd, &seq, use_ssl, data);
|
||||
if(rc == ERR) goto ENDE_IMAP;
|
||||
/*
|
||||
* if the user gives -f <foldername>, then don't iterate through the folder list
|
||||
* rather build the folderlist based on the <foldername> option, 2014.10.14, SJ
|
||||
*/
|
||||
|
||||
if(folder_imap){
|
||||
addnode(data->imapfolders, folder_imap);
|
||||
} else {
|
||||
rc = list_folders(sd, &seq, use_ssl, data);
|
||||
if(rc == ERR) goto ENDE_IMAP;
|
||||
}
|
||||
|
||||
|
||||
for(i=0;i<MAXHASH;i++){
|
||||
@ -462,7 +471,8 @@ ENDE:
|
||||
|
||||
|
||||
void usage(){
|
||||
printf("usage: pilerimport [-c <config file>] -e <eml file> | -m <mailbox file> | -d <directory> | -i <imap server> | -K <pop3 server> | -u <imap username> -p <imap password> -P <imap port> [-x <folder1,folder2,....,folderN,>] [-F <foldername>] [-R] [-r] [-q]\n");
|
||||
printf("usage: pilerimport [-c <config file>] -e <eml file> | -m <mailbox file> | -d <directory> | -i <imap server> | -K <pop3 server> | -u <imap username> -p <imap password> -P <imap port>\n");
|
||||
printf(" [-x <folder1,folder2,....,folderN,>] [-f <imap foldername>] [-F <foldername>] [-b <batchlimit>] [-s <start positiion>] [-D] [-R] [-r] [-q]\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
@ -85,7 +85,7 @@ int connect_to_pop3_server(int sd, char *username, char *password, int port, str
|
||||
snprintf(buf, sizeof(buf)-1, "PASS %s\r\n", password);
|
||||
|
||||
write1(sd, buf, strlen(buf), use_ssl, data->ssl);
|
||||
n = recvtimeoutssl(sd, buf, sizeof(buf), 10, use_ssl, data->ssl);
|
||||
n = recvtimeoutssl(sd, buf, sizeof(buf), 30, use_ssl, data->ssl);
|
||||
|
||||
if(strncmp(buf, "+OK", 3) == 0) return OK;
|
||||
|
||||
@ -106,7 +106,7 @@ int process_pop3_emails(int sd, struct session_data *sdata, struct __data *data,
|
||||
snprintf(buf, sizeof(buf)-1, "STAT\r\n");
|
||||
n = write1(sd, buf, strlen(buf), use_ssl, data->ssl);
|
||||
|
||||
n = recvtimeoutssl(sd, buf, sizeof(buf), 10, use_ssl, data->ssl);
|
||||
n = recvtimeoutssl(sd, buf, sizeof(buf), 30, use_ssl, data->ssl);
|
||||
|
||||
if(strncmp(buf, "+OK ", 4) == 0){
|
||||
p = strchr(&buf[4], ' ');
|
||||
|
Loading…
Reference in New Issue
Block a user