在test目录增加digest_gen工具,计算摘要和信息熵。
This commit is contained in:
@@ -105,7 +105,7 @@ int region_compile(struct _scan_status_t *_mid,void* region_hit,int region_type_
|
||||
_mid->cur_hit_cnt=0;
|
||||
for(i=0;i<region_hit_num;i++)
|
||||
{
|
||||
group_rule=(struct _Maat_group_rule_t*)((char*)region_hit+region_type_size*i+group_offset);
|
||||
group_rule=*(struct _Maat_group_rule_t**)((char*)region_hit+region_type_size*i+group_offset);
|
||||
if(group_rule->group_id<0)
|
||||
{
|
||||
continue;
|
||||
@@ -359,7 +359,7 @@ Maat_feather_t Maat_summon_feather(int max_thread_num,
|
||||
{
|
||||
|
||||
_Maat_feather_t* feather=(_Maat_feather_t*)calloc(sizeof(struct _Maat_feather_t),1);
|
||||
feather->table_cnt=read_table_info(feather->p_table_info, MAX_TABLE_NUM,table_info_path);
|
||||
feather->table_cnt=read_table_info(feather->p_table_info, MAX_TABLE_NUM,table_info_path,logger);
|
||||
feather->map_tablename2id=map_create();
|
||||
int i=0;
|
||||
for(i=0;i<MAX_TABLE_NUM;i++)
|
||||
@@ -1028,7 +1028,7 @@ stream_para_t Maat_stream_scan_digest_start(Maat_feather_t feather,int table_id,
|
||||
struct _Maat_scanner_t* scanner=NULL;
|
||||
|
||||
struct _Maat_table_info_t *p_table=NULL;
|
||||
p_table=acqurie_table(_feather, table_id, TABLE_TYPE_EXPR);
|
||||
p_table=acqurie_table(_feather, table_id, TABLE_TYPE_DIGEST);
|
||||
if(p_table==NULL)
|
||||
{
|
||||
return NULL;
|
||||
|
||||
@@ -253,7 +253,7 @@ int HASH_delete_by_id(MESA_htable_handle hash,int id)
|
||||
ret=MESA_htable_del(hash,(unsigned char*)&id, sizeof(id), NULL);
|
||||
return ret;
|
||||
}
|
||||
int read_table_info(struct _Maat_table_info_t** p_table_info,int num,const char* table_info_path)
|
||||
int read_table_info(struct _Maat_table_info_t** p_table_info,int num,const char* table_info_path,void* logger)
|
||||
{
|
||||
FILE*fp=NULL;
|
||||
char line[MAX_TABLE_LINE_SIZE];
|
||||
@@ -268,6 +268,7 @@ int read_table_info(struct _Maat_table_info_t** p_table_info,int num,const char*
|
||||
map_register(string2int_map,"compile", TABLE_TYPE_COMPILE);
|
||||
map_register(string2int_map,"plugin", TABLE_TYPE_PLUGIN);
|
||||
map_register(string2int_map,"intval", TABLE_TYPE_INTVAL);
|
||||
map_register(string2int_map,"digest", TABLE_TYPE_DIGEST);
|
||||
map_register(string2int_map,"group", TABLE_TYPE_GROUP);
|
||||
map_register(string2int_map,"bin", CHARSET_NONE);
|
||||
map_register(string2int_map,"gbk", CHARSET_GBK);
|
||||
@@ -281,6 +282,8 @@ int read_table_info(struct _Maat_table_info_t** p_table_info,int num,const char*
|
||||
if(fp==NULL)
|
||||
{
|
||||
fprintf(stderr,"Maat read table info %s error.\n",table_info_path);
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL,maat_module,
|
||||
"Maat read table info %s error.\n",table_info_path);
|
||||
}
|
||||
while(NULL!=fgets(line,sizeof(line),fp))
|
||||
{
|
||||
@@ -307,6 +310,8 @@ int read_table_info(struct _Maat_table_info_t** p_table_info,int num,const char*
|
||||
if(ret[j]<0)
|
||||
{
|
||||
fprintf(stderr,"Maat read table info %s line %d error.\n",table_info_path,i);
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL,maat_module,
|
||||
"Maat read table info %s line %d error.\n",table_info_path,i);
|
||||
goto error_jump;
|
||||
}
|
||||
}
|
||||
@@ -328,6 +333,8 @@ int read_table_info(struct _Maat_table_info_t** p_table_info,int num,const char*
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"Maat read table info %s line %d error.\n",table_info_path,i);
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL,maat_module,
|
||||
"Maat read table info %s line %d error.\n",table_info_path,i);
|
||||
goto error_jump;
|
||||
}
|
||||
|
||||
@@ -335,11 +342,17 @@ int read_table_info(struct _Maat_table_info_t** p_table_info,int num,const char*
|
||||
if(p->table_id>=num)
|
||||
{
|
||||
fprintf(stderr,"Maat read table info %s line %d error: table id %uh > %d.\n",table_info_path,i,p->table_id,num);
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL,maat_module,
|
||||
"Maat read table info %s line %d error: table id %uh > %d.\n",table_info_path,i,p->table_id,num);
|
||||
|
||||
goto error_jump;
|
||||
}
|
||||
if(p_table_info[p->table_id]!=NULL)
|
||||
{
|
||||
fprintf(stderr,"Maat read table info %s line %d error:duplicated table id %d.\n",table_info_path,i,p->table_id);
|
||||
MESA_handle_runtime_log(logger, RLOG_LV_FATAL,maat_module,
|
||||
"Maat read table info %s line %d error:duplicated table id %d.\n",table_info_path,i,p->table_id);
|
||||
|
||||
goto error_jump;
|
||||
}
|
||||
if(p->table_type==TABLE_TYPE_PLUGIN)
|
||||
|
||||
@@ -321,7 +321,7 @@ struct _maat_garbage_t
|
||||
void garbage_bagging(enum maat_garbage_type type,void *p,MESA_lqueue_head garbage_q);
|
||||
void garbage_bury(MESA_lqueue_head garbage_q,void *logger);
|
||||
void make_group_set(const struct _Maat_compile_rule_t* compile_rule,universal_bool_expr_t* a_set);
|
||||
int read_table_info(struct _Maat_table_info_t** p_table_info,int num,const char* table_info_path);
|
||||
int read_table_info(struct _Maat_table_info_t** p_table_info,int num,const char* table_info_path,void*logger);
|
||||
void maat_start_cb(unsigned int new_version,int update_type,void*u_para);
|
||||
void maat_update_cb(const char* table_name,const char* line,void *u_para);
|
||||
void maat_finish_cb(void* u_para);
|
||||
|
||||
@@ -448,7 +448,7 @@ int write_digest_rule(cJSON *region_json,struct iris_description_t *p_iris,const
|
||||
cmd_cnt++;
|
||||
|
||||
json_cmd[cmd_cnt].json_string="raw_len";
|
||||
json_cmd[cmd_cnt].json_type=cJSON_String;
|
||||
json_cmd[cmd_cnt].json_type=cJSON_Number;
|
||||
cmd_cnt++;
|
||||
|
||||
json_cmd[cmd_cnt].json_string="digest";
|
||||
@@ -456,7 +456,7 @@ int write_digest_rule(cJSON *region_json,struct iris_description_t *p_iris,const
|
||||
cmd_cnt++;
|
||||
|
||||
json_cmd[cmd_cnt].json_string="cfds_level";
|
||||
json_cmd[cmd_cnt].json_type=cJSON_String;
|
||||
json_cmd[cmd_cnt].json_type=cJSON_Number;
|
||||
cmd_cnt++;
|
||||
|
||||
json_cmd[cmd_cnt].json_string="is_valid";
|
||||
|
||||
@@ -186,6 +186,10 @@ void fuzzy_destroy_handle(fuzzy_handle_t * handle)
|
||||
*/
|
||||
unsigned int fuzzy_feed(fuzzy_handle_t * handle, const char * data, unsigned int size, unsigned long long offset)
|
||||
{
|
||||
if(data==NULL||size==0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
fuzzy_node * node = (fuzzy_node *)calloc(sizeof(fuzzy_node), 1);
|
||||
node->right_status_r = (struct roll_state *)calloc(sizeof (struct roll_state), 1);
|
||||
roll_init(node->right_status_r);
|
||||
|
||||
Reference in New Issue
Block a user