code refactoring

This commit is contained in:
SJ 2015-12-18 22:38:52 +01:00
parent c31b13d77b
commit d203ee63d4
9 changed files with 177 additions and 203 deletions

View File

@ -36,18 +36,16 @@ int store_attachments(struct session_data *sdata, struct parser_state *state, st
data->sql[data->pos] = state->attachments[i].digest; data->type[data->pos] = TYPE_STRING; data->pos++;
data->sql[data->pos] = (char *)&(state->attachments[i].size); data->type[data->pos] = TYPE_LONG; data->pos++;
if(p_exec_query(sdata, data->stmt_get_attachment_id_by_signature, data) == ERR) goto NOT_FOUND;
if(p_exec_query(sdata, data->stmt_get_attachment_id_by_signature, data) == OK){
p_bind_init(data);
p_bind_init(data);
data->sql[data->pos] = (char *)&id; data->type[data->pos] = TYPE_LONGLONG; data->len[data->pos] = sizeof(uint64); data->pos++;
data->sql[data->pos] = (char *)&id; data->type[data->pos] = TYPE_LONGLONG; data->len[data->pos] = sizeof(uint64); data->pos++;
p_store_results(sdata, data->stmt_get_attachment_id_by_signature, data);
if(p_fetch_results(data->stmt_get_attachment_id_by_signature) == OK) found = 1;
p_free_results(data->stmt_get_attachment_id_by_signature);
NOT_FOUND:
p_store_results(sdata, data->stmt_get_attachment_id_by_signature, data);
if(p_fetch_results(data->stmt_get_attachment_id_by_signature) == OK) found = 1;
p_free_results(data->stmt_get_attachment_id_by_signature);
}
if(found == 0){
if(store_file(sdata, state->attachments[i].internalname, 0, 0, cfg) == 0){
@ -103,21 +101,19 @@ int query_attachment_pointers(struct session_data *sdata, struct __data *data, u
data->sql[data->pos] = (char *)&ptr; data->type[data->pos] = TYPE_LONGLONG; data->pos++;
if(p_exec_query(sdata, data->stmt_get_attachment_pointer, data) == ERR) goto ENDE;
if(p_exec_query(sdata, data->stmt_get_attachment_pointer, data) == OK){
p_bind_init(data);
data->sql[data->pos] = piler_id; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = RND_STR_LEN; data->pos++;
data->sql[data->pos] = (char *)id; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
p_bind_init(data);
p_store_results(sdata, data->stmt_get_attachment_pointer, data);
data->sql[data->pos] = piler_id; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = RND_STR_LEN; data->pos++;
data->sql[data->pos] = (char *)id; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
if(p_fetch_results(data->stmt_get_attachment_pointer) == OK) rc = 1;
p_free_results(data->stmt_get_attachment_pointer);
}
p_store_results(sdata, data->stmt_get_attachment_pointer, data);
if(p_fetch_results(data->stmt_get_attachment_pointer) == OK) rc = 1;
p_free_results(data->stmt_get_attachment_pointer);
ENDE:
close_prepared_statement(data->stmt_get_attachment_pointer);
return rc;
@ -130,7 +126,7 @@ int query_attachments(struct session_data *sdata, struct __data *data, struct pt
for(i=0; i<MAX_ATTACHMENTS; i++) memset((char*)&ptr_arr[i], 0, sizeof(struct ptr_array));
if(prepare_sql_statement(sdata, &(data->stmt_query_attachment), SQL_PREPARED_STMT_QUERY_ATTACHMENT, cfg) == ERR) goto ENDE;
if(prepare_sql_statement(sdata, &(data->stmt_query_attachment), SQL_PREPARED_STMT_QUERY_ATTACHMENT, cfg) == ERR) return attachments;
p_bind_init(data);
@ -170,8 +166,6 @@ int query_attachments(struct session_data *sdata, struct __data *data, struct pt
CLOSE:
close_prepared_statement(data->stmt_query_attachment);
ENDE:
return attachments;
}

View File

@ -13,7 +13,7 @@
#define VERSION "1.2.0-master"
#define BUILD 931
#define BUILD 932
#define HOSTID "mailarchiver"

View File

@ -72,19 +72,18 @@ uint64 get_metaid_by_messageid(struct session_data *sdata, struct __data *data,
p_bind_init(data);
data->sql[data->pos] = message_id; data->type[data->pos] = TYPE_STRING; data->pos++;
if(p_exec_query(sdata, data->stmt_get_meta_id_by_message_id, data) == ERR) goto CLOSE;
if(p_exec_query(sdata, data->stmt_get_meta_id_by_message_id, data) == OK){
p_bind_init(data);
data->sql[data->pos] = (char *)&id; data->type[data->pos] = TYPE_LONGLONG; data->len[data->pos] = sizeof(uint64); data->pos++;
p_bind_init(data);
data->sql[data->pos] = (char *)&id; data->type[data->pos] = TYPE_LONGLONG; data->len[data->pos] = sizeof(uint64); data->pos++;
p_store_results(sdata, data->stmt_get_meta_id_by_message_id, data);
p_store_results(sdata, data->stmt_get_meta_id_by_message_id, data);
p_fetch_results(data->stmt_get_meta_id_by_message_id);
p_fetch_results(data->stmt_get_meta_id_by_message_id);
p_free_results(data->stmt_get_meta_id_by_message_id);
}
p_free_results(data->stmt_get_meta_id_by_message_id);
CLOSE:
mysql_stmt_close(data->stmt_get_meta_id_by_message_id);
return id;

View File

@ -22,28 +22,26 @@ void load_mydomains(struct session_data *sdata, struct __data *data, struct __co
p_bind_init(data);
if(p_exec_query(sdata, data->stmt_generic, data) == ERR) goto ENDE;
if(p_exec_query(sdata, data->stmt_generic, data) == OK){
p_bind_init(data);
data->sql[data->pos] = &s[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s)-2; data->pos++;
p_bind_init(data);
p_store_results(sdata, data->stmt_generic, data);
data->sql[data->pos] = &s[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s)-2; data->pos++;
while(p_fetch_results(data->stmt_generic) == OK){
rc = addnode(data->mydomains, s);
p_store_results(sdata, data->stmt_generic, data);
if(rc == 0) syslog(LOG_PRIORITY, "failed to append mydomain: '%s'", s);
else if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "added mydomain: '%s'", s);
while(p_fetch_results(data->stmt_generic) == OK){
rc = addnode(data->mydomains, s);
memset(s, 0, sizeof(s));
}
if(rc == 0) syslog(LOG_PRIORITY, "failed to append mydomain: '%s'", s);
else if(cfg->verbosity >= _LOG_DEBUG) syslog(LOG_PRIORITY, "added mydomain: '%s'", s);
memset(s, 0, sizeof(s));
p_free_results(data->stmt_generic);
}
p_free_results(data->stmt_generic);
ENDE:
close_prepared_statement(data->stmt_generic);
}

View File

@ -108,18 +108,17 @@ int p_exec_query(struct session_data *sdata, MYSQL_STMT *stmt, struct __data *da
if(mysql_stmt_bind_param(stmt, bind)){
sdata->sql_errno = mysql_stmt_errno(stmt);
syslog(LOG_PRIORITY, "%s: mysql_stmt_bind_param() error: %s (errno: %d)", sdata->ttmpfile, mysql_stmt_error(stmt), sdata->sql_errno);
goto CLOSE;
return ret;
}
if(mysql_stmt_execute(stmt)){
sdata->sql_errno = mysql_stmt_errno(stmt);
syslog(LOG_PRIORITY, "%s: mysql_stmt_execute error: *%s* (errno: %d)", sdata->ttmpfile, mysql_error(&(sdata->mysql)), sdata->sql_errno);
goto CLOSE;
return ret;
}
ret = OK;
CLOSE:
return ret;
}
@ -169,18 +168,16 @@ int p_store_results(struct session_data *sdata, MYSQL_STMT *stmt, struct __data
}
if(mysql_stmt_bind_result(stmt, bind)){
goto CLOSE;
return ret;
}
if(mysql_stmt_store_result(stmt)){
goto CLOSE;
return ret;
}
ret = OK;
CLOSE:
return ret;
}

View File

@ -419,27 +419,23 @@ int read_gui_import_data(struct session_data *sdata, struct __data *data, char *
p_bind_init(data);
if(p_exec_query(sdata, data->stmt_generic, data) == ERR) goto ENDE;
if(p_exec_query(sdata, data->stmt_generic, data) == OK){
p_bind_init(data);
data->sql[data->pos] = (char *)&(data->import->import_job_id); data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
data->sql[data->pos] = &s_type[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_type)-2; data->pos++;
data->sql[data->pos] = &s_username[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_username)-2; data->pos++;
data->sql[data->pos] = &s_password[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_password)-2; data->pos++;
data->sql[data->pos] = &s_server[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_server)-2; data->pos++;
p_bind_init(data);
p_store_results(sdata, data->stmt_generic, data);
data->sql[data->pos] = (char *)&(data->import->import_job_id); data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
data->sql[data->pos] = &s_type[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_type)-2; data->pos++;
data->sql[data->pos] = &s_username[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_username)-2; data->pos++;
data->sql[data->pos] = &s_password[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_password)-2; data->pos++;
data->sql[data->pos] = &s_server[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s_server)-2; data->pos++;
if(p_fetch_results(data->stmt_generic) == OK) rc = OK;
p_store_results(sdata, data->stmt_generic, data);
p_free_results(data->stmt_generic);
}
if(p_fetch_results(data->stmt_generic) == OK) rc = OK;
p_free_results(data->stmt_generic);
ENDE:
close_prepared_statement(data->stmt_generic);
data->import->processed_messages = 0;

View File

@ -38,19 +38,17 @@ int is_purge_allowed(struct session_data *sdata, struct __data *data, struct __c
p_bind_init(data);
if(p_exec_query(sdata, data->stmt_generic, data) == ERR) goto ENDE;
if(p_exec_query(sdata, data->stmt_generic, data) == OK){
p_bind_init(data);
data->sql[data->pos] = (char *)&rc; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
p_bind_init(data);
p_store_results(sdata, data->stmt_generic, data);
p_fetch_results(data->stmt_generic);
p_free_results(data->stmt_generic);
}
data->sql[data->pos] = (char *)&rc; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
p_store_results(sdata, data->stmt_generic, data);
p_fetch_results(data->stmt_generic);
p_free_results(data->stmt_generic);
ENDE:
close_prepared_statement(data->stmt_generic);
return rc;
@ -252,46 +250,46 @@ int purge_messages_round1(struct session_data *sdata, struct __data *data, char
p_bind_init(data);
if(p_exec_query(sdata, data->stmt_select_from_meta_table, data) == ERR) goto ENDE;
if(p_exec_query(sdata, data->stmt_select_from_meta_table, data) == OK){
p_bind_init(data);
p_bind_init(data);
data->sql[data->pos] = &id[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(id)-2; data->pos++;
data->sql[data->pos] = &s[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s)-2; data->pos++;
data->sql[data->pos] = (char *)&size; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
data->sql[data->pos] = &id[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(id)-2; data->pos++;
data->sql[data->pos] = &s[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s)-2; data->pos++;
data->sql[data->pos] = (char *)&size; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
p_store_results(sdata, data->stmt_select_from_meta_table, data);
p_store_results(sdata, data->stmt_select_from_meta_table, data);
while(p_fetch_results(data->stmt_select_from_meta_table) == OK){
while(p_fetch_results(data->stmt_select_from_meta_table) == OK){
memcpy(&update_meta_sql[strlen(update_meta_sql)], id, strlen(id));
memcpy(&update_meta_sql[strlen(update_meta_sql)], ",", 1);
memcpy(&update_meta_sql[strlen(update_meta_sql)], id, strlen(id));
memcpy(&update_meta_sql[strlen(update_meta_sql)], ",", 1);
purged_size += size;
purged_size += size;
if(strlen(buf) >= sizeof(buf)-RND_STR_LEN-2-1){
if(strlen(buf) >= sizeof(buf)-RND_STR_LEN-2-1){
purged += remove_message_frame_files(buf, update_meta_sql, sdata, cfg);
purged += remove_message_frame_files(buf, update_meta_sql, sdata, cfg);
memset(buf, 0, sizeof(buf));
memset(update_meta_sql, 0, sizeof(update_meta_sql));
memset(buf, 0, sizeof(buf));
memset(update_meta_sql, 0, sizeof(update_meta_sql));
snprintf(update_meta_sql, sizeof(update_meta_sql)-1, "%s", SQL_STMT_DELETE_FROM_META_TABLE);
}
memcpy(&buf[strlen(buf)], s, strlen(s));
memcpy(&buf[strlen(buf)], " ", 1);
snprintf(update_meta_sql, sizeof(update_meta_sql)-1, "%s", SQL_STMT_DELETE_FROM_META_TABLE);
}
memcpy(&buf[strlen(buf)], s, strlen(s));
memcpy(&buf[strlen(buf)], " ", 1);
p_free_results(data->stmt_select_from_meta_table);
if(strlen(buf) > 5 && strlen(update_meta_sql) > strlen(SQL_STMT_DELETE_FROM_META_TABLE)+5){
purged += remove_message_frame_files(buf, update_meta_sql, sdata, cfg);
}
}
p_free_results(data->stmt_select_from_meta_table);
if(strlen(buf) > 5 && strlen(update_meta_sql) > strlen(SQL_STMT_DELETE_FROM_META_TABLE)+5){
purged += remove_message_frame_files(buf, update_meta_sql, sdata, cfg);
}
ENDE:
close_prepared_statement(data->stmt_select_from_meta_table);
return purged;
@ -311,37 +309,36 @@ int purge_messages_with_attachments(struct session_data *sdata, struct __data *d
if(prepare_sql_statement(sdata, &(data->stmt_select_from_meta_table), s, cfg) == ERR) return purged;
p_bind_init(data);
if(p_exec_query(sdata, data->stmt_select_from_meta_table, data) == ERR) goto ENDE;
if(p_exec_query(sdata, data->stmt_select_from_meta_table, data) == OK){
p_bind_init(data);
p_bind_init(data);
data->sql[data->pos] = &s[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s)-2; data->pos++;
data->sql[data->pos] = (char *)&size; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
data->sql[data->pos] = &s[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = sizeof(s)-2; data->pos++;
data->sql[data->pos] = (char *)&size; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
p_store_results(sdata, data->stmt_select_from_meta_table, data);
p_store_results(sdata, data->stmt_select_from_meta_table, data);
while(p_fetch_results(data->stmt_select_from_meta_table) == OK){
memcpy(&idlist[strlen(idlist)], s, strlen(s));
memcpy(&idlist[strlen(idlist)], "','", 3);
while(p_fetch_results(data->stmt_select_from_meta_table) == OK){
memcpy(&idlist[strlen(idlist)], s, strlen(s));
memcpy(&idlist[strlen(idlist)], "','", 3);
purged_size += size;
purged_size += size;
if(strlen(idlist) >= sizeof(idlist)-2*RND_STR_LEN){
purged += remove_attachments(idlist, sdata, data, cfg);
if(strlen(idlist) >= sizeof(idlist)-2*RND_STR_LEN){
purged += remove_attachments(idlist, sdata, data, cfg);
memset(idlist, 0, sizeof(idlist));
memset(idlist, 0, sizeof(idlist));
}
}
p_free_results(data->stmt_select_from_meta_table);
if(strlen(idlist) > 5){
purged += remove_attachments(idlist, sdata, data, cfg);
}
}
p_free_results(data->stmt_select_from_meta_table);
if(strlen(idlist) > 5){
purged += remove_attachments(idlist, sdata, data, cfg);
}
ENDE:
close_prepared_statement(data->stmt_select_from_meta_table);
return purged;

View File

@ -54,19 +54,17 @@ uint64 get_max_meta_id(struct session_data *sdata, struct __data *data, struct _
p_bind_init(data);
if(p_exec_query(sdata, data->stmt_generic, data) == ERR) goto ENDE;
if(p_exec_query(sdata, data->stmt_generic, data) == OK){
p_bind_init(data);
data->sql[data->pos] = (char *)&id; data->type[data->pos] = TYPE_LONGLONG; data->len[data->pos] = sizeof(uint64); data->pos++;
p_bind_init(data);
p_store_results(sdata, data->stmt_generic, data);
p_fetch_results(data->stmt_generic);
p_free_results(data->stmt_generic);
}
data->sql[data->pos] = (char *)&id; data->type[data->pos] = TYPE_LONGLONG; data->len[data->pos] = sizeof(uint64); data->pos++;
p_store_results(sdata, data->stmt_generic, data);
p_fetch_results(data->stmt_generic);
p_free_results(data->stmt_generic);
ENDE:
close_prepared_statement(data->stmt_generic);
@ -90,63 +88,61 @@ uint64 retrieve_email_by_metadata_id(struct session_data *sdata, struct __data *
p_bind_init(data);
if(p_exec_query(sdata, data->stmt_generic, data) == ERR) goto ENDE;
if(p_exec_query(sdata, data->stmt_generic, data) == OK){
p_bind_init(data);
p_bind_init(data);
data->sql[data->pos] = (char *)&stored_id; data->type[data->pos] = TYPE_LONGLONG; data->len[data->pos] = sizeof(uint64); data->pos++;
data->sql[data->pos] = sdata->ttmpfile; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = RND_STR_LEN+2; data->pos++;
data->sql[data->pos] = (char *)&(sdata->now); data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(unsigned long); data->pos++;
data->sql[data->pos] = (char *)&(sdata->sent); data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(unsigned long); data->pos++;
data->sql[data->pos] = (char *)&stored_id; data->type[data->pos] = TYPE_LONGLONG; data->len[data->pos] = sizeof(uint64); data->pos++;
data->sql[data->pos] = sdata->ttmpfile; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = RND_STR_LEN+2; data->pos++;
data->sql[data->pos] = (char *)&(sdata->now); data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(unsigned long); data->pos++;
data->sql[data->pos] = (char *)&(sdata->sent); data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(unsigned long); data->pos++;
p_store_results(sdata, data->stmt_generic, data);
p_store_results(sdata, data->stmt_generic, data);
while(p_fetch_results(data->stmt_generic) == OK){
while(p_fetch_results(data->stmt_generic) == OK){
if(stored_id > 0){
if(stored_id > 0){
snprintf(filename, sizeof(filename)-1, "%llu.eml", stored_id);
snprintf(filename, sizeof(filename)-1, "%llu.eml", stored_id);
f = fopen(filename, "w");
if(f){
rc = retrieve_email_from_archive(sdata, data, f, cfg);
fclose(f);
f = fopen(filename, "w");
if(f){
rc = retrieve_email_from_archive(sdata, data, f, cfg);
fclose(f);
if(rc){
printf("cannot retrieve: %s\n", filename);
unlink(filename);
continue;
}
snprintf(sdata->filename, SMALLBUFSIZE-1, "%s", filename);
state = parse_message(sdata, 0, data, cfg);
post_parse(sdata, &state, cfg);
rc = store_index_data(sdata, &state, data, stored_id, cfg);
if(rc == OK) reindexed++;
else printf("failed to add to %s table: %s\n", SQL_SPHINX_TABLE, filename);
if(rc){
printf("cannot retrieve: %s\n", filename);
unlink(filename);
continue;
}
snprintf(sdata->filename, SMALLBUFSIZE-1, "%s", filename);
state = parse_message(sdata, 0, data, cfg);
post_parse(sdata, &state, cfg);
rc = store_index_data(sdata, &state, data, stored_id, cfg);
if(rc == OK) reindexed++;
else printf("failed to add to %s table: %s\n", SQL_SPHINX_TABLE, filename);
unlink(filename);
if(progressbar){
printf("processed: %8llu [%3d%%]\r", reindexed, (int)(100*reindexed/delta));
fflush(stdout);
if(progressbar){
printf("processed: %8llu [%3d%%]\r", reindexed, (int)(100*reindexed/delta));
fflush(stdout);
}
}
else printf("cannot open: %s\n", filename);
}
else printf("cannot open: %s\n", filename);
}
p_free_results(data->stmt_generic);
}
p_free_results(data->stmt_generic);
ENDE:
close_prepared_statement(data->stmt_generic);

View File

@ -33,50 +33,47 @@ void load_rules(struct session_data *sdata, struct __data *data, struct node *xh
p_bind_init(data);
if(p_exec_query(sdata, data->stmt_generic, data) == ERR) goto ENDE;
if(p_exec_query(sdata, data->stmt_generic, data) == OK){
p_bind_init(data);
data->sql[data->pos] = &rule_cond.domain[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond.from[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond.to[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond.subject[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond.body[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond._size[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = (char *)&rule_cond.size; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
data->sql[data->pos] = &rule_cond.attachment_name[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond.attachment_type[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond._attachment_size[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = (char *)&rule_cond.attachment_size; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
data->sql[data->pos] = (char *)&rule_cond.spam; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
data->sql[data->pos] = (char *)&rule_cond.days; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
data->sql[data->pos] = (char *)&rule_cond.folder_id; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
p_bind_init(data);
p_store_results(sdata, data->stmt_generic, data);
data->sql[data->pos] = &rule_cond.domain[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond.from[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond.to[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond.subject[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond.body[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond._size[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = (char *)&rule_cond.size; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
data->sql[data->pos] = &rule_cond.attachment_name[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond.attachment_type[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = &rule_cond._attachment_size[0]; data->type[data->pos] = TYPE_STRING; data->len[data->pos] = SMALLBUFSIZE-2; data->pos++;
data->sql[data->pos] = (char *)&rule_cond.attachment_size; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
data->sql[data->pos] = (char *)&rule_cond.spam; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
data->sql[data->pos] = (char *)&rule_cond.days; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
data->sql[data->pos] = (char *)&rule_cond.folder_id; data->type[data->pos] = TYPE_LONG; data->len[data->pos] = sizeof(int); data->pos++;
while(p_fetch_results(data->stmt_generic) == OK){
append_rule(xhash, &rule_cond, data);
memset(rule_cond.domain, 0, SMALLBUFSIZE);
memset(rule_cond.from, 0, SMALLBUFSIZE);
memset(rule_cond.to, 0, SMALLBUFSIZE);
memset(rule_cond.subject, 0, SMALLBUFSIZE);
memset(rule_cond.body, 0, SMALLBUFSIZE);
memset(rule_cond._size, 0, SMALLBUFSIZE);
memset(rule_cond.attachment_name, 0, SMALLBUFSIZE);
memset(rule_cond.attachment_type, 0, SMALLBUFSIZE);
memset(rule_cond._attachment_size, 0, SMALLBUFSIZE);
rule_cond.size = rule_cond.attachment_size = rule_cond.spam = rule_cond.days = rule_cond.folder_id = 0;
}
p_store_results(sdata, data->stmt_generic, data);
p_free_results(data->stmt_generic);
while(p_fetch_results(data->stmt_generic) == OK){
append_rule(xhash, &rule_cond, data);
memset(rule_cond.domain, 0, SMALLBUFSIZE);
memset(rule_cond.from, 0, SMALLBUFSIZE);
memset(rule_cond.to, 0, SMALLBUFSIZE);
memset(rule_cond.subject, 0, SMALLBUFSIZE);
memset(rule_cond.body, 0, SMALLBUFSIZE);
memset(rule_cond._size, 0, SMALLBUFSIZE);
memset(rule_cond.attachment_name, 0, SMALLBUFSIZE);
memset(rule_cond.attachment_type, 0, SMALLBUFSIZE);
memset(rule_cond._attachment_size, 0, SMALLBUFSIZE);
rule_cond.size = rule_cond.attachment_size = rule_cond.spam = rule_cond.days = rule_cond.folder_id = 0;
}
p_free_results(data->stmt_generic);
ENDE:
close_prepared_statement(data->stmt_generic);
}