增加dup_func。
This commit is contained in:
@@ -243,13 +243,18 @@ void Maat_clean_status(scan_status_t* mid);
|
||||
typedef void* MAAT_RULE_EX_DATA;
|
||||
// The idx parameter is the index: this will be the same value returned by Maat_rule_get_ex_new_index() when the functions were initially registered.
|
||||
// Finally the argl and argp parameters are the values originally passed to the same corresponding parameters when Maat_rule_get_ex_new_index() was called.
|
||||
typedef void Maat_rule_EX_new_func_t(int idx, const struct Maat_rule_t* rule, const char* srv_def_large, MAAT_RULE_EX_DATA* ad, long argl, void *argp);
|
||||
typedef void Maat_rule_EX_free_func_t(int idx, const struct Maat_rule_t* rule, const char* srv_def_large, MAAT_RULE_EX_DATA* ad, long argl, void *argp);
|
||||
typedef void Maat_rule_EX_new_func_t(int idx, const struct Maat_rule_t* rule, const char* srv_def_large,
|
||||
MAAT_RULE_EX_DATA* ad, long argl, void *argp);
|
||||
typedef void Maat_rule_EX_free_func_t(int idx, const struct Maat_rule_t* rule, const char* srv_def_large,
|
||||
MAAT_RULE_EX_DATA* ad, long argl, void *argp);
|
||||
typedef void Maat_rule_EX_dup_func_t(int idx, MAAT_RULE_EX_DATA *to, MAAT_RULE_EX_DATA *from, long argl, void *argp);
|
||||
|
||||
int Maat_rule_get_ex_new_index(Maat_feather_t feather, const char* compile_table_name,
|
||||
Maat_rule_EX_new_func_t* new_func,
|
||||
Maat_rule_EX_free_func_t* free_func,
|
||||
Maat_rule_EX_dup_func_t* dup_func,
|
||||
long argl, void *argp);
|
||||
//returned data is duplicated by dup_func of Maat_rule_get_ex_new_index, caller is responsible to free the data.
|
||||
MAAT_RULE_EX_DATA Maat_rule_get_ex_data(Maat_feather_t feather, const struct Maat_rule_t* rule, int idx);
|
||||
|
||||
|
||||
|
||||
@@ -980,6 +980,7 @@ void rule_ex_data_new_cb(const uchar * key, uint size, void * data, void * user)
|
||||
int Maat_rule_get_ex_new_index(Maat_feather_t feather, const char* compile_table_name,
|
||||
Maat_rule_EX_new_func_t *new_func,
|
||||
Maat_rule_EX_free_func_t* free_func,
|
||||
Maat_rule_EX_dup_func_t* dup_func,
|
||||
long argl, void *argp)
|
||||
{
|
||||
struct _Maat_feather_t *_feather=(struct _Maat_feather_t *)feather;
|
||||
@@ -1008,6 +1009,8 @@ int Maat_rule_get_ex_new_index(Maat_feather_t feather, const char* compile_table
|
||||
p_table->ex_desc[idx].argp=argp;
|
||||
p_table->ex_desc[idx].new_func=new_func;
|
||||
p_table->ex_desc[idx].free_func=free_func;
|
||||
p_table->ex_desc[idx].dup_func=dup_func;
|
||||
|
||||
p_table->ex_data_num++;
|
||||
MESA_htable_iterate(_feather->scanner->compile_hash, rule_ex_data_new_cb, p_table->ex_desc+idx);
|
||||
failed:
|
||||
@@ -1019,7 +1022,9 @@ MAAT_RULE_EX_DATA Maat_rule_get_ex_data(Maat_feather_t feather, const struct Maa
|
||||
{
|
||||
struct _Maat_feather_t *_feather=(struct _Maat_feather_t *)feather;
|
||||
struct _Maat_compile_inner_t *compile_inner=NULL;
|
||||
const struct compile_ex_data_idx* ex_desc=NULL;
|
||||
MAAT_RULE_EX_DATA ad=NULL;
|
||||
|
||||
compile_inner=(struct _Maat_compile_inner_t *)HASH_fetch_by_id(_feather->scanner->compile_hash, rule->config_id);
|
||||
if(compile_inner==NULL)
|
||||
{
|
||||
@@ -1027,7 +1032,8 @@ MAAT_RULE_EX_DATA Maat_rule_get_ex_data(Maat_feather_t feather, const struct Maa
|
||||
}
|
||||
pthread_rwlock_rdlock(&(compile_inner->rwlock));
|
||||
assert(idx<compile_inner->ref_table->ex_data_num);
|
||||
ad=compile_inner->ads[idx];
|
||||
ex_desc=compile_inner->ref_table->ex_desc+idx;
|
||||
ex_desc->dup_func(ex_desc->idx, &ad, compile_inner->ads+idx, ex_desc->argl,ex_desc->argp);
|
||||
pthread_rwlock_unlock(&(compile_inner->rwlock));
|
||||
return ad;
|
||||
}
|
||||
|
||||
@@ -94,6 +94,7 @@ struct compile_ex_data_idx
|
||||
{
|
||||
Maat_rule_EX_new_func_t *new_func;
|
||||
Maat_rule_EX_free_func_t* free_func;
|
||||
Maat_rule_EX_dup_func_t* dup_func;
|
||||
long argl;
|
||||
void *argp;
|
||||
int idx;
|
||||
|
||||
Reference in New Issue
Block a user