예제 #1
0
파일: compiler.c 프로젝트: c4nc/yara
YR_API int yr_compiler_add_file(
    YR_COMPILER* compiler,
    FILE* rules_file,
    const char* namespace_,
    const char* file_name)
{
  // Don't allow yr_compiler_add_file() after
  // yr_compiler_get_rules() has been called.

  assert(compiler->compiled_rules_arena == NULL);

  if (file_name != NULL)
    _yr_compiler_push_file_name(compiler, file_name);

  if (namespace_ != NULL)
    compiler->last_result = _yr_compiler_set_namespace(compiler, namespace_);
  else
    compiler->last_result = _yr_compiler_set_namespace(compiler, "default");

  if (compiler->last_result == ERROR_SUCCESS)
  {
    return yr_lex_parse_rules_file(rules_file, compiler);
  }
  else
  {
    compiler->errors++;
    return compiler->errors;
  }

}
예제 #2
0
파일: compiler.c 프로젝트: nonmoun/yara
int yr_compiler_add_file(
    YR_COMPILER* compiler,
    FILE* rules_file,
    const char* namespace_,
    const char* file_name)
{
  // Don't allow yr_compiler_add_file() after
  // yr_compiler_get_rules() has been called.

  assert(compiler->compiled_rules_arena == NULL);

  if (file_name != NULL)
    _yr_compiler_push_file_name(compiler, file_name);

  if (namespace_ != NULL)
    _yr_compiler_set_namespace(compiler, namespace_);
  else
    _yr_compiler_set_namespace(compiler, "default");

  return yr_lex_parse_rules_file(rules_file, compiler);
}