make pilerimport quiet with -q

This commit is contained in:
SJ 2013-09-27 14:33:15 +02:00
parent e298d2b9c0
commit 187503887a
3 changed files with 11 additions and 11 deletions

View File

@ -258,7 +258,7 @@ struct import {
struct __data { struct __data {
int folder; int folder, quiet;
char recursive_folder_names; char recursive_folder_names;
char starttls[TINYBUFSIZE]; char starttls[TINYBUFSIZE];
struct node *mydomains[MAXHASH]; struct node *mydomains[MAXHASH];

View File

@ -84,7 +84,7 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da
rule = check_againt_ruleset(data->archiving_rules, &state, sdata->tot_len, sdata->spam_message); rule = check_againt_ruleset(data->archiving_rules, &state, sdata->tot_len, sdata->spam_message);
if(rule){ if(rule){
printf("discarding %s by archiving policy: %s\n", filename, rule); if(data->quiet == 0) printf("discarding %s by archiving policy: %s\n", filename, rule);
rc = OK; rc = OK;
} }
else { else {
@ -119,7 +119,7 @@ int import_message(char *filename, struct session_data *sdata, struct __data *da
counters.c_duplicate = 1; counters.c_duplicate = 1;
update_counters(sdata, data, &counters, cfg); update_counters(sdata, data, &counters, cfg);
printf("duplicate: %s (id: %s)\n", filename, sdata->ttmpfile); if(data->quiet == 0)printf("duplicate: %s (id: %s)\n", filename, sdata->ttmpfile);
break; break;
default: default:

View File

@ -30,7 +30,6 @@
extern char *optarg; extern char *optarg;
extern int optind; extern int optind;
int quiet=0;
int dryrun=0; int dryrun=0;
int remove_after_successful_import = 0; int remove_after_successful_import = 0;
int import_from_gui=0; int import_from_gui=0;
@ -76,7 +75,7 @@ int import_from_mailbox(char *mailbox, struct session_data *sdata, struct __data
} }
else unlink(fname); else unlink(fname);
if(quiet == 0) printf("processed: %7d\r", tot_msgs); fflush(stdout); if(data->quiet == 0) printf("processed: %7d\r", tot_msgs); fflush(stdout);
} }
snprintf(fname, sizeof(fname)-1, "%ld-%d", t, tot_msgs); snprintf(fname, sizeof(fname)-1, "%ld-%d", t, tot_msgs);
@ -96,7 +95,7 @@ int import_from_mailbox(char *mailbox, struct session_data *sdata, struct __data
} }
else unlink(fname); else unlink(fname);
if(quiet == 0) printf("processed: %7d\r", tot_msgs); fflush(stdout); if(data->quiet == 0) printf("processed: %7d\r", tot_msgs); fflush(stdout);
} }
fclose(F); fclose(F);
@ -238,7 +237,7 @@ int import_from_maildir(char *directory, struct session_data *sdata, struct __da
i++; i++;
if(quiet == 0) printf("processed: %7d\r", *tot_msgs); fflush(stdout); if(data->quiet == 0) printf("processed: %7d\r", *tot_msgs); fflush(stdout);
} }
else { else {
printf("%s is not a file\n", fname); printf("%s is not a file\n", fname);
@ -316,10 +315,10 @@ int import_from_imap_server(char *server, char *username, char *password, int po
} }
if(skipmatch == 1){ if(skipmatch == 1){
if(quiet == 0) printf("SKIPPING FOLDER: %s\n", (char *)q->str); if(data->quiet == 0) printf("SKIPPING FOLDER: %s\n", (char *)q->str);
} }
else { else {
if(quiet == 0) printf("processing folder: %s... ", (char *)q->str); if(data->quiet == 0) printf("processing folder: %s... ", (char *)q->str);
if(process_imap_folder(sd, &seq, q->str, sdata, data, use_ssl, dryrun, cfg) == ERR) ret = ERR; if(process_imap_folder(sd, &seq, q->str, sdata, data, use_ssl, dryrun, cfg) == ERR) ret = ERR;
} }
@ -479,6 +478,7 @@ int main(int argc, char **argv){
data.folder = 0; data.folder = 0;
data.recursive_folder_names = 0; data.recursive_folder_names = 0;
data.quiet = 0;
import.import_job_id = import.total_messages = import.processed_messages = 0; import.import_job_id = import.total_messages = import.processed_messages = 0;
import.started = import.updated = import.finished = 0; import.started = import.updated = import.finished = 0;
@ -597,7 +597,7 @@ int main(int argc, char **argv){
break; break;
case 'q' : case 'q' :
quiet = 1; data.quiet = 1;
break; break;
case 'h' : case 'h' :
@ -674,7 +674,7 @@ int main(int argc, char **argv){
close_database(&sdata); close_database(&sdata);
if(quiet == 0) printf("\n"); if(data.quiet == 0) printf("\n");
return rc; return rc;
} }