sc_result search_full_pattern(sc_addr pattern, sc_addr answer, sc_bool sys_off)
{
    sc_type_result params;
    sc_addr addr2, arc;
    sc_type_result_vector result;
    sc_type_result::iterator it;
    sc_uint i;
    sc_result res = SC_RESULT_OK;
    GHashTable *table;

    if (SC_RESULT_OK != system_sys_search_only_full(pattern, params, &result))
    {
        return SC_RESULT_ERROR;
    }
    if (result.size() > 0)
    {
        res = SC_RESULT_OK;
    }
    else
    {
        free_result_vector(&result);
        return SC_RESULT_ERROR;
    }

    table = g_hash_table_new(NULL, NULL);

    for (i = 0; i < result.size(); i++)
    {
        for (it = result[i]->begin() ; it != result[i]->end(); it++)
        {
            addr2 = (*it).second;
            if (FALSE == g_hash_table_contains(table, GINT_TO_POINTER(SC_ADDR_LOCAL_TO_INT(addr2))))
            {
                g_hash_table_add(table, GINT_TO_POINTER(SC_ADDR_LOCAL_TO_INT(addr2)));
                if (sys_off == SC_TRUE && IS_SYSTEM_ELEMENT(addr2))
                    continue;

                arc = sc_memory_arc_new(s_default_ctx, sc_type_arc_pos_const_perm, answer, addr2);
                SYSTEM_ELEMENT(arc);
            }
        }
    }

    free_result_vector(&result);
    g_hash_table_destroy(table);
    return res;
}
extern "C" scp_result sys_search(scp_operand *param1, scp_operand *param2, scp_operand_pair *parameters, sc_uint32 param_count, scp_operand *param4, scp_bool full_only)
{
    sc_type_result params;
    sc_addr curr_result_node, addr1, addr2, arc;
    sc_type_result_vector result;
    sc_type_result::iterator it;
    sc_uint i;
    scp_result res = SCP_RESULT_FALSE;
    GHashTable *table;

    for (i = 0; i < param_count; i++)
    {
        params.insert(sc_addr_pair(parameters[i].operand1->addr, parameters[i].operand2->addr));
    }
    if (SCP_TRUE == full_only)
    {
        if (SC_RESULT_OK != system_sys_search_only_full(param1->addr, params, &result))
        {
            return SCP_RESULT_ERROR;
        }
    }
    else
    {
        if (SC_RESULT_OK != system_sys_search(param1->addr, params, &result))
        {
            return SCP_RESULT_ERROR;
        }
    }
    if (result.size() > 0)
    {
        res = SCP_RESULT_TRUE;
    }
    else
    {
        free_result_vector(&result);
        return SCP_RESULT_FALSE;
    }
    if (param4 != nullptr)
    {
        table = g_hash_table_new(NULL, NULL);
    }
    for (i = 0; i < result.size(); i++)
    {
        curr_result_node = sc_memory_node_new(sc_type_const);
        for (it = result[i]->begin() ; it != result[i]->end(); it++)
        {
            addr1 = (*it).first;
            addr2 = (*it).second;
            arc = sc_memory_arc_new(sc_type_arc_common | sc_type_const, addr1, addr2);
            sc_memory_arc_new(sc_type_arc_pos_const_perm, curr_result_node, arc);
            if (param4 != nullptr)
            {
                if (FALSE == g_hash_table_contains(table, MAKE_SC_ADDR_HASH(addr2)))
                {
                    sc_memory_arc_new(sc_type_arc_pos_const_perm, param4->addr, addr2);
                    g_hash_table_add(table, MAKE_SC_ADDR_HASH(addr2));
                }

            }
        }
        sc_memory_arc_new(sc_type_arc_pos_const_perm, param2->addr, curr_result_node);
    }
    free_result_vector(&result);
    if (param4 != nullptr)
    {
        g_hash_table_destroy(table);
    }
    return res;
}