YR_RULES* compile_rule( char* string) { YR_COMPILER* compiler = NULL; YR_RULES* rules = NULL; compile_error[0] = '\0'; if (yr_compiler_create(&compiler) != ERROR_SUCCESS) { perror("yr_compiler_create"); goto _exit; } yr_compiler_set_callback(compiler, callback_function, NULL); if (yr_compiler_add_string(compiler, string, NULL) != 0) { goto _exit; } if (yr_compiler_get_rules(compiler, &rules) != ERROR_SUCCESS) { goto _exit; } _exit: yr_compiler_destroy(compiler); return rules; }
int compile_rule( char* string, YR_RULES** rules) { YR_COMPILER* compiler = NULL; int result = ERROR_SUCCESS; compile_error[0] = '\0'; if (yr_compiler_create(&compiler) != ERROR_SUCCESS) { perror("yr_compiler_create"); goto _exit; } yr_compiler_set_callback(compiler, callback_function, NULL); if (yr_compiler_add_string(compiler, string, NULL) != 0) { result = compiler->last_error; goto _exit; } result = yr_compiler_get_rules(compiler, rules); _exit: yr_compiler_destroy(compiler); return result; }