diff --git a/include/maat.h b/include/maat.h index 733a424..190d0ea 100644 --- a/include/maat.h +++ b/include/maat.h @@ -74,7 +74,8 @@ typedef void maat_start_callback_t(int update_type, void *u_param); typedef void maat_update_callback_t(int table_id, const char *table_line, void *u_para); typedef void maat_finish_callback_t(void *u_para); -typedef void maat_ex_new_func_t(int table_id, const char *key, const char *table_line, void **ad, long argl, void *argp); +typedef void maat_ex_new_func_t(int table_id, const char *key, const char *table_line, + void **ad, long argl, void *argp); typedef void maat_ex_free_func_t(int table_id, void **ad, long argl, void *argp); typedef void maat_ex_dup_func_t(int table_id, void **to, void **from, long argl, void *argp); @@ -90,15 +91,23 @@ int maat_options_set_rule_update_checking_interval_ms(struct maat_options *opts, int maat_options_set_gc_timeout_ms(struct maat_options *opts, int interval_ms); int maat_options_set_instance_name(struct maat_options *opts, const char *instance_name, size_t name_len); int maat_options_set_deferred_load_on(struct maat_options *opts); -int maat_options_set_iris(struct maat_options *opts, const char *full_directory, const char *increment_directory); + +int maat_options_set_iris(struct maat_options *opts, const char *full_directory, + const char *increment_directory); int maat_options_set_json_file(struct maat_options *opts, const char *json_filename); -int maat_options_set_redis(struct maat_options *opts, const char *redis_ip, uint16_t redis_port, int redis_db); +int maat_options_set_redis(struct maat_options *opts, const char *redis_ip, + uint16_t redis_port, int redis_db); + int maat_options_set_logger(struct maat_options *opts, void *logger); /* maat_instance API */ struct maat *maat_new(struct maat_options *opts, const char *table_info_path); void maat_free(struct maat *instance); +/* maat helper API */ +int maat_helper_read_column(const char *table_line, int Nth_column, + size_t *column_offset, size_t *column_len); + /* maat table API */ int maat_get_table_id(struct maat *instance, const char *table_name); diff --git a/src/maat_api.c b/src/maat_api.c index b26b8fd..deb4935 100644 --- a/src/maat_api.c +++ b/src/maat_api.c @@ -387,6 +387,12 @@ void maat_free(struct maat *maat_instance) pthread_join(maat_instance->cfg_mon_thread, &ret); } +int maat_helper_read_column(const char *table_line, int Nth_column, + size_t *column_offset, size_t *column_len) +{ + return get_column_pos(table_line, Nth_column, column_offset, column_len); +} + int maat_get_table_id(struct maat *maat_instance, const char *table_name) { int table_id = -1; diff --git a/src/maat_compile.c b/src/maat_compile.c index 163700d..29e078f 100644 --- a/src/maat_compile.c +++ b/src/maat_compile.c @@ -722,14 +722,18 @@ int maat_compile_hash_add(struct maat_compile **compile_hash, long long compile_ HASH_ADD(hh, *compile_hash, compile_id, sizeof(long long), compile); //TODO:mytest need to delete #if 0 - size_t compile_cnt = HASH_COUNT(*compile_hash); - struct maat_compile *compile1 = NULL, *tmp_compile1 = NULL; - HASH_ITER (hh, *compile_hash, compile1, tmp_compile1) { - printf(" compile_id:%lu, compile_cnt:%zu\n", - compile1->compile_id, compile_cnt); - } + if (compile_id == 141) + { + size_t compile_cnt = HASH_COUNT(*compile_hash); + struct maat_compile *compile1 = NULL, *tmp_compile1 = NULL; + HASH_ITER(hh, *compile_hash, compile1, tmp_compile1) + { + printf(" compile_id:%lld, compile_cnt:%zu\n", + compile1->compile_id, compile_cnt); + } + } #endif - return ret; + return ret; } void maat_compile_hash_set(struct maat_compile **compile_hash, long long compile_id, diff --git a/test/maat_framework_gtest.cpp b/test/maat_framework_gtest.cpp index f03e661..f9527f9 100644 --- a/test/maat_framework_gtest.cpp +++ b/test/maat_framework_gtest.cpp @@ -1259,7 +1259,7 @@ void compile_ex_param_dup(int table_id, void **to, void **from, long argl, void pthread_mutex_unlock(&(from_param->lock)); *((struct rule_ex_param**)to) = from_param; } -#if 0 + TEST_F(CompileTable, CompileEXData) { long long results[ARRAY_SIZE] = {0}; size_t n_hit_result = 0; @@ -1301,7 +1301,7 @@ TEST_F(CompileTable, CompileEXData) { maat_state_free(&state); } -#endif + TEST_F(CompileTable, CompileRuleUpdate) { //9999 0 0 0 0 0 anything 1 1 0.0 const char *compile_table_name = "COMPILE"; diff --git a/test/table_info.conf b/test/table_info.conf index 4bf2522..732d215 100644 --- a/test/table_info.conf +++ b/test/table_info.conf @@ -47,7 +47,7 @@ "table_id":3, "table_name":"GROUP2COMPILE_ALIAS", "table_type":"group2compile", - "associated_compile_table_id":0, + "associated_compile_table_id":2, "valid_column":3, "custom": { "group_id":1,