<commit_before>/*

Copyright(c) 2007. <NAME> [<EMAIL>].

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

*/

#include <string.h>
#include <stdio.h>

#include "filemap.h"
#include "mem.h"
#include "eval.h"
#include "lex.h"
#include "weight.h"
#include "proc.h"
#include "exe.h"
#include "regex.h"
#include "yara.h"

#ifdef WIN32
#define snprintf _snprintf
#endif

void yr_init()
{
    yr_heap_alloc();
}


YARA_CONTEXT* yr_create_context()
{
    YARA_CONTEXT* context = (YARA_CONTEXT*) yr_malloc(sizeof(YARA_CONTEXT));
    
    context->rule_list.head = NULL;
    context->rule_list.tail = NULL;
    context->hash_table.non_hashed_strings = NULL;
    context->hash_table.populated = FALSE;
    context->errors = 0;
    context->error_report_function = NULL;
    context->last_error = ERROR_SUCCESS;
    context->last_error_line = 0;
    context->last_result = ERROR_SUCCESS;
    context->file_name_stack_ptr = 0;
    context->current_rule_strings = NULL;
    context->current_rule_flags = 0;
    context->inside_for = 0;
	context->namespaces = NULL;
	context->variables = NULL;
    context->allow_includes = TRUE;
	context->current_namespace = yr_create_namespace(context, "default");
	context->fast_match = FALSE;
    context->scanning_process_memory = FALSE;

    memset(context->rule_list.hash_table, 0, sizeof(context->rule_list.hash_table));
    memset(context->hash_table.hashed_strings_2b, 0, sizeof(context->hash_table.hashed_strings_2b));
    memset(context->hash_table.hashed_strings_1b, 0, sizeof(context->hash_table.hashed_strings_1b));
    
    return context;
    
}

void yr_destroy_context(YARA_CONTEXT* context)
{
    RULE* rule;
    RULE* next_rule;
    STRING* string;
    STRING* next_string;
    META* meta;
    META* next_meta;
    MATCH* match;<commit_msg>Fix uninitialized variable<commit_after>/*

Copyright(c) 2007. <NAME> [<EMAIL>].

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

*/

#include <string.h>
#include <stdio.h>

#include "filemap.h"
#include "mem.h"
#include "eval.h"
#include "lex.h"
#include "weight.h"
#include "proc.h"
#include "exe.h"
#include "regex.h"
#include "yara.h"

#ifdef WIN32
#define snprintf _snprintf
#endif

void yr_init()
{
    yr_heap_alloc();
}


YARA_CONTEXT* yr_create_context()
{
    YARA_CONTEXT* context = (YARA_CONTEXT*) yr_malloc(sizeof(YARA_CONTEXT));
    
    context->rule_list.head = NULL;
    context->rule_list.tail = NULL;
    context->hash_table.non_hashed_strings = NULL;
    context->hash_table.populated = FALSE;
    context->errors = 0;
    context->error_report_function = NULL;
    context->last_error = ERROR_SUCCESS;
    context->last_error_line = 0;
    context->last_result = ERROR_SUCCESS;
    context->file_stack_ptr = 0;
    context->file_name_stack_ptr = 0;
    context->current_rule_strings = NULL;
    context->current_rule_flags = 0;
    context->inside_for = 0;
	context->namespaces = NULL;
	context->variables = NULL;
    context->allow_includes = TRUE;
	context->current_namespace = yr_create_namespace(context, "default");
	context->fast_match = FALSE;
    context->scanning_process_memory = FALSE;

    memset(context->rule_list.hash_table, 0, sizeof(context->rule_list.hash_table));
    memset(context->hash_table.hashed_strings_2b, 0, sizeof(context->hash_table.hashed_strings_2b));
    memset(context->hash_table.hashed_strings_1b, 0, sizeof(context->hash_table.hashed_strings_1b));
    
    return context;
    
}

void yr_destroy_context(YARA_CONTEXT* context)
{
    RULE* rule;
    RULE* next_rule;
    STRING* string;
    STRING* next_string;
    META* meta;
    META* next_meta;
    MATCH* match;
{'fraction_non_alphanumeric': 0.1093044263775971, 'fraction_numerical': 0.008807588075880758, 'mean_word_length': 4.355501813784764, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 62, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7202628', 'n_tokens_mistral': 1511, 'n_tokens_neox': 1445, 'n_words': 373}