Removed unused data parameter from several functions

Signed-off-by: Janos SUTO <sj@acts.hu>
This commit is contained in:
Janos SUTO 2018-09-29 08:43:50 +02:00
parent 2128ac8b8a
commit 084d578273
18 changed files with 64 additions and 68 deletions

View File

@ -234,7 +234,7 @@ CLEANUP:
}
int retrieve_email_from_archive(struct session_data *sdata, struct data *data, FILE *dest, struct config *cfg){
int retrieve_email_from_archive(struct session_data *sdata, FILE *dest, struct config *cfg){
int i, attachments;
char *buffer=NULL, *saved_buffer, *p, filename[SMALLBUFSIZE], pointer[SMALLBUFSIZE];
struct ptr_array ptr_arr[MAX_ATTACHMENTS];
@ -247,7 +247,7 @@ int retrieve_email_from_archive(struct session_data *sdata, struct data *data, F
return 1;
}
attachments = query_attachments(sdata, data, &ptr_arr[0]);
attachments = query_attachments(sdata, &ptr_arr[0]);
if(attachments == -1){
printf("problem querying the attachment of %s\n", sdata->ttmpfile);

View File

@ -16,7 +16,7 @@
#include <piler.h>
int store_attachments(struct session_data *sdata, struct parser_state *state, struct data *data, struct config *cfg){
int store_attachments(struct session_data *sdata, struct parser_state *state, struct config *cfg){
uint64 id=0;
int i, rc=1, found, affected_rows;
struct sql sql, sql2;
@ -91,7 +91,7 @@ CLOSE:
}
int query_attachment_pointers(struct session_data *sdata, struct data *data, uint64 ptr, char *piler_id, int *id){
int query_attachment_pointers(struct session_data *sdata, uint64 ptr, char *piler_id, int *id){
int rc=0;
struct sql sql;
@ -120,7 +120,7 @@ int query_attachment_pointers(struct session_data *sdata, struct data *data, uin
}
int query_attachments(struct session_data *sdata, struct data *data, struct ptr_array *ptr_arr){
int query_attachments(struct session_data *sdata, struct ptr_array *ptr_arr){
int i, rc, id, attachments=0;
uint64 ptr;
struct sql sql;
@ -147,7 +147,7 @@ int query_attachments(struct session_data *sdata, struct data *data, struct ptr_
if(id > 0 && id < MAX_ATTACHMENTS){
if(ptr > 0){
ptr_arr[id].ptr = ptr;
rc = query_attachment_pointers(sdata, data, ptr, &(ptr_arr[id].piler_id[0]), &(ptr_arr[id].attachment_id));
rc = query_attachment_pointers(sdata, ptr, &(ptr_arr[id].piler_id[0]), &(ptr_arr[id].attachment_id));
if(!rc){
attachments = -1;
goto CLOSE;

View File

@ -11,7 +11,7 @@
#include <piler.h>
struct counters load_counters(struct session_data *sdata, struct data *data){
struct counters load_counters(struct session_data *sdata){
char buf[SMALLBUFSIZE];
struct counters counters;
struct sql sql;
@ -48,7 +48,7 @@ struct counters load_counters(struct session_data *sdata, struct data *data){
}
void update_counters(struct session_data *sdata, struct data *data, struct counters *counters, struct config *cfg){
void update_counters(struct session_data *sdata, struct counters *counters, struct config *cfg){
char buf[MAXBUFSIZE];
#ifdef HAVE_MEMCACHED
unsigned long long mc, rcvd;
@ -102,7 +102,7 @@ void update_counters(struct session_data *sdata, struct data *data, struct count
}
else {
c = load_counters(sdata, data);
c = load_counters(sdata);
snprintf(buf, SMALLBUFSIZE-1, "%ld", sdata->now); memcached_add(&(data->memc), MEMCACHED_COUNTERS_LAST_UPDATE, strlen(MEMCACHED_COUNTERS_LAST_UPDATE), buf, strlen(buf), 0, 0);
@ -127,5 +127,3 @@ void update_counters(struct session_data *sdata, struct data *data, struct count
#endif
}

View File

@ -356,8 +356,8 @@ int process_imap_folder(char *folder, struct session_data *sdata, struct data *d
if(messages <= 0) return OK;
if(data->recursive_folder_names == 1){
data->folder = get_folder_id(sdata, data, folder, 0);
if(data->folder == ERR_FOLDER) data->folder = add_new_folder(sdata, data, folder, 0);
data->folder = get_folder_id(sdata, folder, 0);
if(data->folder == ERR_FOLDER) data->folder = add_new_folder(sdata, folder, 0);
}
for(i=data->import->start_position; i<=messages; i++){

View File

@ -110,7 +110,7 @@ int import_message(struct session_data *sdata, struct data *data, struct config
counters.c_rcvd = 1;
counters.c_size += sdata->tot_len;
counters.c_stored_size = sdata->stored_len;
update_counters(sdata, data, &counters, cfg);
update_counters(sdata, &counters, cfg);
break;
@ -119,7 +119,7 @@ int import_message(struct session_data *sdata, struct data *data, struct config
bzero(&counters, sizeof(counters));
counters.c_duplicate = 1;
update_counters(sdata, data, &counters, cfg);
update_counters(sdata, &counters, cfg);
if(data->quiet == 0) printf("duplicate: %s (duplicate id: %llu)\n", data->import->filename, sdata->duplicate_id);
break;
@ -146,7 +146,7 @@ int import_message(struct session_data *sdata, struct data *data, struct config
}
int get_folder_id(struct session_data *sdata, struct data *data, char *foldername, int parent_id){
int get_folder_id(struct session_data *sdata, char *foldername, int parent_id){
int id=ERR_FOLDER;
struct sql sql;
@ -174,7 +174,7 @@ int get_folder_id(struct session_data *sdata, struct data *data, char *foldernam
}
int add_new_folder(struct session_data *sdata, struct data *data, char *foldername, int parent_id){
int add_new_folder(struct session_data *sdata, char *foldername, int parent_id){
int id=ERR_FOLDER;
struct sql sql;

View File

@ -111,9 +111,9 @@ int import_mbox_from_dir(char *directory, struct session_data *sdata, struct dat
if(S_ISREG(st.st_mode)){
if(i == 0 && data->recursive_folder_names == 1){
folder = get_folder_id(sdata, data, fname, data->folder);
folder = get_folder_id(sdata, fname, data->folder);
if(folder == ERR_FOLDER){
folder = add_new_folder(sdata, data, fname, data->folder);
folder = add_new_folder(sdata, fname, data->folder);
if(folder == ERR_FOLDER){
printf("error: cannot get/add folder '%s' to parent id: %d\n", fname, data->folder);

View File

@ -61,9 +61,9 @@ int import_from_maildir(struct session_data *sdata, struct data *data, char *dir
return ERR;
}
folder = get_folder_id(sdata, data, p, data->folder);
folder = get_folder_id(sdata, p, data->folder);
if(folder == ERR_FOLDER){
folder = add_new_folder(sdata, data, p, data->folder);
folder = add_new_folder(sdata, p, data->folder);
if(folder == ERR_FOLDER){
printf("error: cannot get/add folder '%s' to parent id: %d\n", p, data->folder);

View File

@ -65,7 +65,7 @@ int store_index_data(struct session_data *sdata, struct parser_state *state, str
}
uint64 get_metaid_by_messageid(struct session_data *sdata, struct data *data, char *message_id, char *piler_id){
uint64 get_metaid_by_messageid(struct session_data *sdata, char *message_id, char *piler_id){
uint64 id=0;
struct sql sql;
@ -94,7 +94,7 @@ uint64 get_metaid_by_messageid(struct session_data *sdata, struct data *data, ch
}
int store_recipients(struct session_data *sdata, struct data *data, char *to, uint64 id, struct config *cfg){
int store_recipients(struct session_data *sdata, char *to, uint64 id, struct config *cfg){
int rc=OK, n=0;
char *p, *q, puf[SMALLBUFSIZE];
struct sql sql;
@ -166,7 +166,7 @@ int store_folder_id(struct session_data *sdata, struct data *data, uint64 id, st
}
int update_metadata_reference(struct session_data *sdata, struct parser_state *state, struct data *data, char *ref, struct config *cfg){
int update_metadata_reference(struct session_data *sdata, struct parser_state *state, char *ref, struct config *cfg){
int ret = ERR;
struct sql sql;
@ -203,7 +203,7 @@ int store_meta_data(struct session_data *sdata, struct parser_state *state, stru
memset(ref, 0, sizeof(ref));
if(strlen(state->reference) > 10){
digest_string(state->reference, &ref[0]);
update_metadata_reference(sdata, state, data, &ref[0], cfg);
update_metadata_reference(sdata, state, &ref[0], cfg);
}
@ -250,7 +250,7 @@ int store_meta_data(struct session_data *sdata, struct parser_state *state, stru
if(p_exec_stmt(sdata, &sql) == OK){
id = p_get_insert_id(&sql);
if(store_recipients(sdata, data, state->b_to, id, cfg) == OK){
if(store_recipients(sdata, state->b_to, id, cfg) == OK){
if(store_index_data(sdata, state, data, id, cfg) == OK) rc = OK;
@ -319,14 +319,14 @@ int process_message(struct session_data *sdata, struct parser_state *state, stru
/* discard if existing message_id */
sdata->duplicate_id = get_metaid_by_messageid(sdata, data, state->message_id, piler_id);
sdata->duplicate_id = get_metaid_by_messageid(sdata, state->message_id, piler_id);
if(sdata->duplicate_id > 0){
remove_stripped_attachments(state);
if(strlen(state->b_journal_to) > 0){
if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: trying to add journal rcpt (%s) to id=%llu for message-id: '%s'", sdata->ttmpfile, state->b_journal_to, sdata->duplicate_id, state->message_id);
store_recipients(sdata, data, state->b_journal_to, sdata->duplicate_id, cfg);
store_recipients(sdata, state->b_journal_to, sdata->duplicate_id, cfg);
}
return ERR_EXISTS;
@ -361,7 +361,7 @@ int process_message(struct session_data *sdata, struct parser_state *state, stru
sdata->retained += query_retain_period(data, state, sdata->tot_len, sdata->spam_message, cfg);
if(state->n_attachments > 0 && store_attachments(sdata, state, data, cfg) == ERR) return ERR;
if(state->n_attachments > 0 && store_attachments(sdata, state, cfg) == ERR) return ERR;
if(store_file(sdata, sdata->tmpframe, 0, cfg) == 0){

View File

@ -205,7 +205,7 @@ int process_email(char *filename, struct session_data *sdata, struct data *data,
if(rc != ERR) unlink(filename);
update_counters(sdata, data, &counters, cfg);
update_counters(sdata, &counters, cfg);
gettimeofday(&tv2, &tz);
@ -447,9 +447,9 @@ void initialise_configuration(){
return;
}
load_rules(&sdata, &data, data.archiving_rules, SQL_ARCHIVING_RULE_TABLE);
load_rules(&sdata, &data, data.retention_rules, SQL_RETENTION_RULE_TABLE);
load_rules(&sdata, &data, data.folder_rules, SQL_FOLDER_RULE_TABLE);
load_rules(&sdata, data.archiving_rules, SQL_ARCHIVING_RULE_TABLE);
load_rules(&sdata, data.retention_rules, SQL_RETENTION_RULE_TABLE);
load_rules(&sdata, data.folder_rules, SQL_FOLDER_RULE_TABLE);
load_mydomains(&sdata, &data, &cfg);

View File

@ -44,20 +44,20 @@ void rollback(struct session_data *sdata, struct parser_state *state, uint64 id,
int reimport_message(struct session_data *sdata, struct parser_state *state, struct data *data, struct config *cfg);
int store_file(struct session_data *sdata, char *filename, int len, struct config *cfg);
int remove_stored_message_files(struct session_data *sdata, struct parser_state *state, struct config *cfg);
int store_attachments(struct session_data *sdata, struct parser_state *state, struct data *data, struct config *cfg);
int query_attachments(struct session_data *sdata, struct data *data, struct ptr_array *ptr_arr);
int store_attachments(struct session_data *sdata, struct parser_state *state, struct config *cfg);
int query_attachments(struct session_data *sdata, struct ptr_array *ptr_arr);
struct config read_config(char *configfile);
void check_and_create_directories(struct config *cfg, uid_t uid, gid_t gid);
void update_counters(struct session_data *sdata, struct data *data, struct counters *counters, struct config *cfg);
void update_counters(struct session_data *sdata, struct counters *counters, struct config *cfg);
int retrieve_email_from_archive(struct session_data *sdata, struct data *data, FILE *dest, struct config *cfg);
int retrieve_email_from_archive(struct session_data *sdata, FILE *dest, struct config *cfg);
int file_from_archive_to_network(char *filename, int sd, int tls_enable, struct data *data, struct config *cfg);
int get_folder_id(struct session_data *sdata, struct data *data, char *foldername, int parent_id);
int add_new_folder(struct session_data *sdata, struct data *data, char *foldername, int parent_id);
int get_folder_id(struct session_data *sdata, char *foldername, int parent_id);
int add_new_folder(struct session_data *sdata, char *foldername, int parent_id);
int store_index_data(struct session_data *sdata, struct parser_state *state, struct data *data, uint64 id, struct config *cfg);

View File

@ -30,7 +30,7 @@ char *index_list = "main1,dailydelta1,delta1";
regex_t regexp;
int export_emails_matching_to_query(struct session_data *sdata, struct data *data, char *s, struct config *cfg);
int export_emails_matching_to_query(struct session_data *sdata, char *s, struct config *cfg);
void usage(){
@ -151,7 +151,7 @@ int append_string_to_buffer(char **buffer, char *str){
}
uint64 run_query(struct session_data *sdata, struct session_data *sdata2, struct data *data, char *where_condition, uint64 last_id, int *num, struct config *cfg){
uint64 run_query(struct session_data *sdata, struct session_data *sdata2, char *where_condition, uint64 last_id, int *num, struct config *cfg){
MYSQL_RES *res;
MYSQL_ROW row;
int rc=0;
@ -183,7 +183,7 @@ uint64 run_query(struct session_data *sdata, struct session_data *sdata2, struct
}
}
if(!rc) export_emails_matching_to_query(sdata, data, query, cfg);
if(!rc) export_emails_matching_to_query(sdata, query, cfg);
free(query);
query = NULL;
@ -212,17 +212,17 @@ uint64 get_total_found(struct session_data *sdata){
}
void export_emails_matching_id_list(struct session_data *sdata, struct session_data *sdata2, struct data *data, char *where_condition, struct config *cfg){
void export_emails_matching_id_list(struct session_data *sdata, struct session_data *sdata2, char *where_condition, struct config *cfg){
int n;
uint64 count=0, last_id=0, total_found=0;
last_id = run_query(sdata, sdata2, data, where_condition, last_id, &n, cfg);
last_id = run_query(sdata, sdata2, where_condition, last_id, &n, cfg);
count += n;
total_found = get_total_found(sdata2);
while(count < total_found){
last_id = run_query(sdata, sdata2, data, where_condition, last_id, &n, cfg);
last_id = run_query(sdata, sdata2, where_condition, last_id, &n, cfg);
count += n;
}
@ -335,7 +335,7 @@ int build_query_from_args(char *from, char *to, char *fromdomain, char *todomain
}
int export_emails_matching_to_query(struct session_data *sdata, struct data *data, char *s, struct config *cfg){
int export_emails_matching_to_query(struct session_data *sdata, char *s, struct config *cfg){
FILE *f;
uint64 id, n=0;
char digest[SMALLBUFSIZE], bodydigest[SMALLBUFSIZE];
@ -371,7 +371,7 @@ int export_emails_matching_to_query(struct session_data *sdata, struct data *dat
f = fopen(filename, "w");
if(f){
rc = retrieve_email_from_archive(sdata, data, f, cfg);
rc = retrieve_email_from_archive(sdata, f, cfg);
fclose(f);
n++;
@ -416,7 +416,6 @@ int main(int argc, char **argv){
char *configfile=CONFIG_FILE;
char *to=NULL, *from=NULL, *todomain=NULL, *fromdomain=NULL, *where_condition=NULL;
struct session_data sdata, sdata2;
struct data data;
struct config cfg;
@ -591,13 +590,13 @@ int main(int argc, char **argv){
p_clean_exit("cannot connect to 127.0.0.1:9306", 1);
}
export_emails_matching_id_list(&sdata, &sdata2, &data, where_condition, &cfg);
export_emails_matching_id_list(&sdata, &sdata2, where_condition, &cfg);
close_database(&sdata2);
}
else {
if(build_query_from_args(from, to, fromdomain, todomain, minsize, maxsize, startdate, stopdate) > 0) p_clean_exit("malloc problem building query", 1);
export_emails_matching_to_query(&sdata, &data, query, &cfg);
export_emails_matching_to_query(&sdata, query, &cfg);
free(query);
}

View File

@ -19,7 +19,6 @@
int main(int argc, char **argv){
int readkey=1;
struct session_data sdata;
struct data data;
struct config cfg;
@ -48,7 +47,7 @@ int main(int argc, char **argv){
snprintf(sdata.ttmpfile, SMALLBUFSIZE-1, "%s", argv[1]);
snprintf(sdata.filename, SMALLBUFSIZE-1, "%s", sdata.ttmpfile);
retrieve_email_from_archive(&sdata, &data, stdout, &cfg);
retrieve_email_from_archive(&sdata, stdout, &cfg);
close_database(&sdata);

View File

@ -315,10 +315,10 @@ int main(int argc, char **argv){
#endif
if(data.import->folder){
data.folder = get_folder_id(&sdata, &data, data.import->folder, 0);
data.folder = get_folder_id(&sdata, data.import->folder, 0);
if(data.folder == ERR_FOLDER){
data.folder = add_new_folder(&sdata, &data, data.import->folder, 0);
data.folder = add_new_folder(&sdata, data.import->folder, 0);
}
if(data.folder == ERR_FOLDER){
@ -329,9 +329,9 @@ int main(int argc, char **argv){
}
load_rules(&sdata, &data, data.archiving_rules, SQL_ARCHIVING_RULE_TABLE);
load_rules(&sdata, &data, data.retention_rules, SQL_RETENTION_RULE_TABLE);
load_rules(&sdata, &data, data.folder_rules, SQL_FOLDER_RULE_TABLE);
load_rules(&sdata, data.archiving_rules, SQL_ARCHIVING_RULE_TABLE);
load_rules(&sdata, data.retention_rules, SQL_RETENTION_RULE_TABLE);
load_rules(&sdata, data.folder_rules, SQL_FOLDER_RULE_TABLE);
load_mydomains(&sdata, &data, &cfg);

View File

@ -42,7 +42,7 @@ void p_clean_exit(char *msg, int rc){
}
uint64 get_max_meta_id(struct session_data *sdata, struct data *data){
uint64 get_max_meta_id(struct session_data *sdata){
char s[SMALLBUFSIZE];
uint64 id=0;
struct sql sql;
@ -116,7 +116,7 @@ uint64 retrieve_email_by_metadata_id(struct session_data *sdata, struct data *da
f = fopen(filename, "w");
if(f){
rc = retrieve_email_from_archive(sdata, data, f, cfg);
rc = retrieve_email_from_archive(sdata, f, cfg);
fclose(f);
if(rc){
@ -241,10 +241,10 @@ int main(int argc, char **argv){
p_clean_exit("cannot connect to mysql server", 1);
}
load_rules(&sdata, &data, data.folder_rules, SQL_FOLDER_RULE_TABLE);
load_rules(&sdata, data.folder_rules, SQL_FOLDER_RULE_TABLE);
if(folder){
data.folder = get_folder_id(&sdata, &data, folder, 0);
data.folder = get_folder_id(&sdata, folder, 0);
if(data.folder == 0){
printf("error: could not get folder id for '%s'\n", folder);
return 0;
@ -256,7 +256,7 @@ int main(int argc, char **argv){
if(all == 1){
from_id = 1;
to_id = get_max_meta_id(&sdata, &data);
to_id = get_max_meta_id(&sdata);
}
n = retrieve_email_by_metadata_id(&sdata, &data, from_id, to_id, &cfg);

View File

@ -10,7 +10,7 @@
#include "rules.h"
void load_rules(struct session_data *sdata, struct data *data, struct node *xhash[], char *table){
void load_rules(struct session_data *sdata, struct node *xhash[], char *table){
char s[SMALLBUFSIZE];
struct rule_cond rule_cond;
struct sql sql;

View File

@ -7,7 +7,7 @@
#include "defs.h"
void load_rules(struct session_data *sdata, struct data *data, struct node *xhash[], char *table);
void load_rules(struct session_data *sdata, struct node *xhash[], char *table);
int append_rule(struct node *xhash[], struct rule_cond *rule_cond);
struct rule *create_rule_item(struct rule_cond *rule_cond);
char *check_againt_ruleset(struct node *xhash[], struct parser_state *state, int size, int spam);

View File

@ -222,7 +222,7 @@ void print_json_results(struct stats *stats){
}
int main(int argc, char **argv){
int main(){
struct session_data sdata;
struct stats stats;
struct config cfg;

View File

@ -126,9 +126,9 @@ int main(int argc, char **argv){
load_mydomains(&sdata, &data, &cfg);
load_rules(&sdata, &data, data.archiving_rules, SQL_ARCHIVING_RULE_TABLE);
load_rules(&sdata, &data, data.retention_rules, SQL_RETENTION_RULE_TABLE);
load_rules(&sdata, &data, data.folder_rules, SQL_FOLDER_RULE_TABLE);
load_rules(&sdata, data.archiving_rules, SQL_ARCHIVING_RULE_TABLE);
load_rules(&sdata, data.retention_rules, SQL_RETENTION_RULE_TABLE);
load_rules(&sdata, data.folder_rules, SQL_FOLDER_RULE_TABLE);
init_session_data(&sdata, &cfg);