code cleanup

This commit is contained in:
SJ 2016-01-02 08:16:38 +01:00
parent b05ddbf571
commit 8acee556d1
11 changed files with 26 additions and 17 deletions

View File

@ -13,7 +13,7 @@
#define VERSION "1.2.0-master"
#define BUILD 934
#define BUILD 935
#define HOSTID "mailarchiver"

View File

@ -94,7 +94,7 @@ void update_counters(struct session_data *sdata, struct __data *data, struct __c
//if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "%s: update counters: %s", sdata->ttmpfile, buf);
p_query(sdata, buf, cfg);
p_query(sdata, buf);
}
}
@ -119,7 +119,7 @@ void update_counters(struct session_data *sdata, struct __data *data, struct __c
if(counters->c_virus + counters->c_duplicate + counters->c_ignore + counters->c_size + counters->c_stored_size <= 0) return;
snprintf(buf, SMALLBUFSIZE-1, "UPDATE `%s` SET `rcvd`=`rcvd`+%llu, `virus`=`virus`+%llu, `duplicate`=`duplicate`+%llu, `ignore`=`ignore`+%llu, `size`=`size`+%llu, `stored_size`=`stored_size`+%llu", SQL_COUNTER_TABLE, counters->c_rcvd, counters->c_virus, counters->c_duplicate, counters->c_ignore, counters->c_size, counters->c_stored_size);
p_query(sdata, buf, cfg);
p_query(sdata, buf);
#ifdef HAVE_MEMCACHED
}

View File

@ -183,7 +183,7 @@ void update_import_job_stat(struct session_data *sdata, struct __data *data, str
snprintf(buf, sizeof(buf)-1, "update import set status=%d, started=%ld, updated=%ld, finished=%ld, total=%d, imported=%d where id=%d", data->import->status, data->import->started, data->import->updated, data->import->finished, data->import->total_messages, data->import->processed_messages, data->import->import_job_id);
p_query(sdata, buf, cfg);
p_query(sdata, buf);
}

View File

@ -47,7 +47,7 @@ void p_bind_init(struct __data *data){
}
void p_query(struct session_data *sdata, char *s, struct __config *cfg){
void p_query(struct session_data *sdata, char *s){
mysql_real_query(&(sdata->mysql), s, strlen(s));
}

View File

@ -451,7 +451,7 @@ void fixupBase64EncodedLine(char *buf, struct parser_state *state){
if(strlen(state->miscbuf) > 0){
memset(puf, 0, sizeof(puf));
strncpy(puf, state->miscbuf, sizeof(puf)-1);
strncpy(puf, state->miscbuf, sizeof(puf)-strlen(puf)-1);
strncat(puf, buf, sizeof(puf)-strlen(puf)-1);
memset(buf, 0, MAXBUFSIZE);
@ -750,7 +750,7 @@ void fixURL(char *buf, int buflen){
fixed_url[len-1] = '\0';
}
snprintf(buf, buflen, "%s", fixed_url);
snprintf(buf, buflen, "%s", fixed_url);
}

View File

@ -92,7 +92,7 @@ int remove_message_frame_files(char *s, char *update_meta_sql, struct session_da
if(dryrun == 1){
printf("running sql query: *%s*\n\n", update_meta_sql);
} else {
p_query(sdata, update_meta_sql, cfg);
p_query(sdata, update_meta_sql);
}
@ -191,7 +191,7 @@ int remove_attachments(char *in, struct session_data *sdata, struct __data *data
if(dryrun == 1){
printf("delete sql: *%s*\n", delete_attachment_stmt);
} else {
p_query(sdata, delete_attachment_stmt, cfg);
p_query(sdata, delete_attachment_stmt);
}
}
@ -224,7 +224,7 @@ int remove_attachments(char *in, struct session_data *sdata, struct __data *data
if(dryrun == 1){
printf("delete sql: *%s*\n", delete_attachment_stmt);
} else {
p_query(sdata, delete_attachment_stmt, cfg);
p_query(sdata, delete_attachment_stmt);
}
}
@ -404,7 +404,7 @@ int main(int argc, char **argv){
if(purged_size > 100){
snprintf(buf, sizeof(buf)-1, "UPDATE `%s` SET size = size - %ld", SQL_COUNTER_TABLE, purged_size);
if(dryrun == 0) p_query(&sdata, buf, &cfg);
if(dryrun == 0) p_query(&sdata, buf);
}

View File

@ -27,7 +27,7 @@ void process_command_ehlo_lhlo(struct session_data *sdata, struct __data *data,
if(sdata->tls == 0) snprintf(tmpbuf, sizeof(tmpbuf)-1, SMTP_RESP_250_EXTENSIONS, cfg->hostid, data->starttls);
else snprintf(tmpbuf, sizeof(tmpbuf)-1, SMTP_RESP_250_EXTENSIONS, cfg->hostid, "");
strncat(resp, tmpbuf, resplen);
strncat(resp, tmpbuf, resplen-strlen(resp));
}

View File

@ -9,7 +9,7 @@
int open_database(struct session_data *sdata, struct __config *cfg);
void close_database(struct session_data *sdata);
int prepare_sql_statement(struct session_data *sdata, MYSQL_STMT **stmt, char *s, struct __config *cfg);
void p_query(struct session_data *sdata, char *s, struct __config *cfg);
void p_query(struct session_data *sdata, char *s);
int p_exec_query(struct session_data *sdata, MYSQL_STMT *stmt, struct __data *data);
int p_store_results(struct session_data *sdata, MYSQL_STMT *stmt, struct __data *data);
int p_fetch_results(MYSQL_STMT *stmt);

View File

@ -42,7 +42,7 @@ static void fill_domain_table(struct __config *cfg){
for(i=0; i<sizeof(domains)/sizeof(char*); i++){
snprintf(buf, sizeof(buf)-1, "insert into domain (domain, mapped) values('%s', '%s')", domains[i], domains[i]);
p_query(&sdata, buf, cfg);
p_query(&sdata, buf);
}
close_database(&sdata);
@ -63,7 +63,7 @@ static void restore_domain_table(struct __config *cfg){
for(i=0; i<sizeof(domains)/sizeof(char*); i++){
snprintf(buf, sizeof(buf)-1, "delete from domain where domain='%s'", domains[i]);
p_query(&sdata, buf, cfg);
p_query(&sdata, buf);
}
close_database(&sdata);

View File

@ -46,7 +46,7 @@ static void fill_rule_table(struct __config *cfg){
printf("adding testing rules...\n");
for(i=0; i<sizeof(rules)/sizeof(struct rule_query); i++){
p_query(&sdata, rules[i].query, cfg);
p_query(&sdata, rules[i].query);
rules[i].id = mysql_insert_id(&(sdata.mysql));
}
@ -68,7 +68,7 @@ static void restore_rule_table(struct __config *cfg){
for(i=0; i<sizeof(rules)/sizeof(struct rule_query); i++){
snprintf(buf, sizeof(buf)-1, "delete from archiving_rule where id=%llu", rules[i].id);
p_query(&sdata, buf, cfg);
p_query(&sdata, buf);
}
close_database(&sdata);

9
unit_tests/run.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
LD_LIBRARY_PATH=../src ./check_parser_utils
LD_LIBRARY_PATH=../src ./check_parser
LD_LIBRARY_PATH=../src ./check_rules
LD_LIBRARY_PATH=../src ./check_digest
LD_LIBRARY_PATH=../src ./check_mydomains