Exemple #1
0
scp_result scp_sys_gen_for_variables(sc_memory_context *context, scp_operand *param1, scp_operand_pair *variables, sc_uint32 var_count, scp_operand_pair *parameters, sc_uint32 param_count, scp_operand *param4)
{
    sc_uint32 i;
    if (param1->param_type != SCP_FIXED)
    {
        return print_error("sys_gen_for_variables", "Parameter 1 must have FIXED modifier");
    }
    if (SC_FALSE == sc_memory_is_element(context, param1->addr))
    {
        return print_error("sys_gen_for_variables", "Parameter 1 has modifier FIXED, but has not value");
    }
    for (i = 0; i < param_count; i++)
    {
        if (parameters[i].operand1->param_type == SCP_ASSIGN || parameters[i].operand2->param_type == SCP_ASSIGN)
        {
            return print_error("sys_gen_for_variables", "All elements of parameter set must have FIXED modifier");
        }
        if (SC_FALSE == sc_memory_is_element(context, parameters[i].operand1->addr) || SC_FALSE == sc_memory_is_element(context, parameters[i].operand2->addr))
        {
            return print_error("sys_gen_for_variables", "All elements of parameter set must have value");
        }
    }
    for (i = 0; i < var_count; i++)
    {
        if (variables[i].operand1->param_type == SCP_ASSIGN)
        {
            return print_error("sys_gen_for_variables", "All variables of variable set must have FIXED modifier");
        }
        if (SC_FALSE == sc_memory_is_element(context, variables[i].operand1->addr))
        {
            return print_error("sys_gen_for_variables", "All variables of variable set must have value");
        }
        if (variables[i].operand2->param_type == SCP_FIXED)
        {
            return print_error("sys_gen_for_variables", "All variables values must have ASSIGN modifier");
        }
    }
    if (param4 != nullptr)
    {
        if (param4->param_type == SCP_FIXED)
        {
            if (SC_FALSE == sc_memory_is_element(context, param1->addr))
            {
                return print_error("scp_sys_gen_for_variables", "Parameter 4 has modifier FIXED, but has not value");
            }
        }
        else
        {
            param4->addr = sc_memory_node_new(context, scp_type_const);
        }
    }
    for (i = 0; i < var_count; i++)
    {
        if (variables[i].operand2->param_type == SCP_ASSIGN && variables[i].operand2->set == SCP_TRUE)
        {
            variables[i].operand2->addr = sc_memory_node_new(context, scp_type_const);
        }
    }
    return sys_gen_for_variables(context, param1, variables, var_count, parameters, param_count, param4);
}
Exemple #2
0
scp_result scp_sys_search(sc_memory_context *context, scp_operand *param1, scp_operand *param2, scp_operand_pair *parameters, sc_uint32 param_count, scp_operand *param4, scp_bool full_only)
{
    scp_bool flag2;
    sc_uint32 i;
    if (param1->param_type != SCP_FIXED)
    {
        return print_error("scp_sys_search", "Parameter 1 must have FIXED modifier");
    }
    if (SC_FALSE == sc_memory_is_element(context, param1->addr))
    {
        return print_error("scp_sys_search", "Parameter 1 has modifier FIXED, but has not value");
    }
    if (param2->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(context, param1->addr))
        {
            return print_error("scp_sys_search", "Parameter 2 has modifier FIXED, but has not value");
        }
    }
    else
    {
        flag2 = SCP_TRUE;
    }

    for (i = 0; i < param_count; i++)
    {
        if (parameters[i].operand1->param_type == SCP_ASSIGN || parameters[i].operand2->param_type == SCP_ASSIGN)
        {
            return print_error("scp_sys_search", "All elements of parameter set must have FIXED modifier");
        }
        if (SC_FALSE == sc_memory_is_element(context, parameters[i].operand1->addr) || SC_FALSE == sc_memory_is_element(context, parameters[i].operand2->addr))
        {
            return print_error("scp_sys_search", "All elements of parameter set must have value");
        }
    }

    if (param4 != nullptr)
    {
        if (param4->param_type == SCP_FIXED)
        {
            if (SC_FALSE == sc_memory_is_element(context, param1->addr))
            {
                return print_error("scp_sys_search", "Parameter 4 has modifier FIXED, but has not value");
            }
        }
        else
        {
            param4->addr = sc_memory_node_new(context, scp_type_const);
        }
    }

    if (flag2 == SCP_TRUE)
    {
        param2->addr = sc_memory_node_new(context, scp_type_const);
    }
    return sys_search(context, param1, param2, parameters, param_count, param4, full_only);
}
scp_result searchSetStr3(scp_operand *param1, scp_operand *param2, scp_operand *param3, scp_operand *sets)
{
    sc_uint32 fixed1 = 0;
    sc_uint32 fixed2 = 0;
    sc_uint32 fixed3 = 0;
    sc_uint32 fixed = 0;
    if (param2->param_type == SCP_FIXED)
    {
        return print_error("searchSetStr3", "Parameter 2 must have ASSIGN modifier");
    }
    if (param1->param_type == SCP_ASSIGN && param2->param_type == SCP_ASSIGN && param3->param_type == SCP_ASSIGN)
    {
        return print_error("searchSetStr3", "At least one operand must have FIXED modifier");
    }
    if (param1->param_type == SCP_FIXED)
    {
        if (SCP_TRUE == sets[0].set)
        {
            return print_error("searchSetStr3", "Parameter 1 has modifier FIXED, but marked as SET");
        }
        if (SC_FALSE == sc_memory_is_element(param1->addr))
        {
            return print_error("searchSetStr3", "Parameter 1 has modifier FIXED, but has not value");
        }
        fixed1 = 0x1;
    }
    if (param3->param_type == SCP_FIXED)
    {
        if (SCP_TRUE == sets[2].set)
        {
            return print_error("searchSetStr3", "Parameter 3 has modifier FIXED, but marked as SET");
        }
        if (SC_FALSE == sc_memory_is_element(param3->addr))
        {
            return print_error("searchSetStr3", "Parameter 3 has modifier FIXED, but has not value");
        }
        fixed3 = 0x100;
    }
    fixed = (fixed1 | fixed2 | fixed3);
    switch (fixed)
    {
        case 0x001:
            return searchSetStr3_f_a_a(param1, param2, param3, sets);
        case 0x100:
            return searchSetStr3_a_a_f(param1, param2, param3, sets);
        case 0x101:
            return searchSetStr3_f_a_f(param1, param2, param3, sets);
        default:
            return print_error("searchElStr3", "Unsupported parameter type combination");
    }

    return SCP_RESULT_ERROR;
}
scp_result resolve_numbers_1_2(const sc_char *operator_name, scp_operand *param1, scp_operand *param2, double *num1, double *num2)
{
    sc_stream *stream;
    sc_uint32 length = 0, read_length = 0;
    sc_char *data1, *data2;
    if (SCP_ASSIGN == param1->param_type || SCP_ASSIGN == param2->param_type)
    {
        return print_error(operator_name, "Both parameters must have FIXED modifier");
    }
    if (SC_FALSE == sc_memory_is_element(param1->addr))
    {
        return print_error(operator_name, "Parameter 1 has not value");
    }
    if (SC_FALSE == sc_memory_is_element(param2->addr))
    {
        return print_error(operator_name, "Parameter 2 has not value");
    }
    if (check_type(param1->addr, scp_type_link) == SCP_RESULT_FALSE || check_type(param2->addr, scp_type_link) == SCP_RESULT_FALSE)
    {
        return print_error(operator_name, "Both parameters must have link type");
    }
    if (SCP_RESULT_FALSE == check_numeric_type(param1->addr) || SCP_RESULT_FALSE == check_numeric_type(param2->addr))
    {
        return print_error(operator_name, "Both parameters must have numeric format");
    }

    if (sc_memory_get_link_content(param1->addr, &stream) != SC_RESULT_OK)
    {
        return print_error(operator_name, "Parameter 1 content reading error");
    }
    sc_stream_get_length(stream, &length);
    data1 = calloc(length, sizeof(sc_char));
    sc_stream_read_data(stream, data1, length, &read_length);
    sc_stream_free(stream);
    if (sc_memory_get_link_content(param2->addr, &stream) != SC_RESULT_OK)
    {
        return print_error(operator_name, "Parameter 2 content reading error");
    }
    sc_stream_get_length(stream, &length);
    data2 = calloc(length, sizeof(sc_char));
    sc_stream_read_data(stream, data2, length, &read_length);
    sc_stream_free(stream);

    (*num1) = atof(data1);
    (*num2) = atof(data2);
    free(data1);
    free(data2);
    return SCP_RESULT_TRUE;
}
scp_result ifCoin(scp_operand *param1, scp_operand *param2)
{
    if (SC_FALSE == sc_memory_is_element(param1->addr))
    {
        return print_error("ifCoin", "Parameter 1 has no value");
    }
    if (SC_FALSE == sc_memory_is_element(param2->addr))
    {
        return print_error("ifCoin", "Parameter 2 has no value");
    }
    if (SC_ADDR_IS_EQUAL(param1->addr, param2->addr))
        return SCP_RESULT_TRUE;
    else
        return SCP_RESULT_FALSE;
}
scp_result eraseSetStr3(scp_operand *param1, scp_operand *param2, scp_operand *param3)
{
    sc_uint32 fixed1 = 0;
    sc_uint32 fixed2 = 0;
    sc_uint32 fixed3 = 0;
    sc_uint32 fixed = 0;
    if (param1->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param1->addr))
        {
            return print_error("eraseSetStr3", "Parameter 1 has modifier FIXED, but has not value");
        }
        fixed1 = 0x1;
    }
    if (param2->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param2->addr))
        {
            return print_error("eraseSetStr3", "Parameter 2 has modifier FIXED, but has not value");
        }
        if (SCP_RESULT_TRUE == check_type(param2->addr, scp_type_node))
        {
            return print_error("eraseSetStr3", "Parameter 2 is not an arc");
        }
        fixed2 = 0x10;
    }
    if (param3->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param3->addr))
        {
            return print_error("eraseSetStr3", "Parameter 3 has modifier FIXED, but has not value");
        }
        fixed3 = 0x100;
    }
    fixed = (fixed1 | fixed2 | fixed3);
    switch (fixed)
    {
        case 0x001:
            return eraseSetStr3_f_a_a(param1, param2, param3);
        case 0x100:
            return eraseSetStr3_a_a_f(param1, param2, param3);
        case 0x101:
            return eraseSetStr3_f_a_f(param1, param2, param3);
        default:
            return print_error("eraseSetStr3", "Unsupported parameter type combination");
    }
    return SCP_RESULT_ERROR;
}
scp_result ifVarAssign(scp_operand *param)
{
    if (SC_FALSE == sc_memory_is_element(param->addr))
        return SCP_RESULT_FALSE;
    else
        return SCP_RESULT_TRUE;
}
scp_result printL(scp_operand *param, sc_bool new_line)
{
    sc_stream *stream;
    sc_uint32 length = 0, read_length = 0;
    sc_char *data;
    if (SC_FALSE == sc_memory_is_element(param->addr))
    {
        return print_error("print", "Parameter has not value");
    }
    /*if (SCP_RESULT_FALSE == check_type(param->addr, sc_type_link))
    {
        return print_error("print", "Parameter is not an sc-link");
    }*/
    if (sc_memory_get_link_content(param->addr, &stream) != SC_RESULT_OK)
    {
        return print_error("print", "Content reading error");
    }
    sc_stream_get_length(stream, &length);
    data = calloc(length + 1, sizeof(sc_char));
    sc_stream_read_data(stream, data, length, &read_length);
    data[length] = '\0';
    printf("%s", data);
    if (SC_TRUE == new_line)
    {
        printf("\n");
    }
    sc_stream_free(stream);
    free(data);
    return SCP_RESULT_TRUE;
}
scp_result contAssign(scp_operand *param1, scp_operand *param2)
{
    sc_stream *stream;
    if (SCP_ASSIGN == param2->param_type)
    {
        return print_error("contAssign", "Parameter 2 must have FIXED modifier");
    }
    if (SC_FALSE == sc_memory_is_element(param2->addr))
    {
        return print_error("contAssign", "Parameter 2 has not value");
    }
    if (check_type(param2->addr, scp_type_link) == SCP_RESULT_FALSE)
    {
        return print_error("contAssign", "Parameter 2 must have link type");
    }
    if (sc_memory_get_link_content(param2->addr, &stream) != SC_RESULT_OK)
    {
        return print_error("contAssign", "Parameter 2 content reading error");
    }
    if (SCP_RESULT_ERROR == check_link_parameter_1("contAssign", param1))
    {
        return SCP_RESULT_ERROR;
    }
    sc_memory_set_link_content(param1->addr, stream);
    sc_stream_free(stream);
    return SCP_RESULT_TRUE;
}
scp_result ifFormCont(scp_operand *param)
{
    sc_stream *stream;
    if (SCP_ASSIGN == param->param_type)
    {
        return print_error("ifFormCont", "Parameter must have FIXED modifier");
    }
    if (SC_FALSE == sc_memory_is_element(param->addr))
    {
        return print_error("ifFormCont", "Parameter has not value");
    }
    if (check_type(param->addr, scp_type_link) == SCP_RESULT_FALSE)
    {
        return print_error("ifFormCont", "Parameter must have link type");
    }
    sc_result res = sc_memory_get_link_content(param->addr, &stream);
    if (res == SC_RESULT_OK)
    {
        return SCP_RESULT_TRUE;
    }
    else
    {
        return SCP_RESULT_FALSE;
    }
    return SCP_RESULT_ERROR;
}
scp_result ifType(scp_operand *param)
{
    if (SC_FALSE == sc_memory_is_element(param->addr))
    {
        return print_error("ifType", "Parameter has no value");
    }
    return check_type(param->addr, param->element_type);
}
scp_iterator3 *scp_iterator3_new(scp_operand *param1, scp_operand *param2, scp_operand *param3)
{
    sc_uint32 fixed1 = 0;
    sc_uint32 fixed3 = 0;
    sc_uint32 fixed = 0;
    if (param2->param_type == SCP_FIXED)
    {
        print_error("SCP ITERATOR 3 NEW", "Parameter 2 must have ASSIGN modifier");
        return nullptr;
    }
    if (param1->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param1->addr))
        {
            print_error("SCP ITERATOR 3 NEW", "Parameter 1 has modifier FIXED, but has not value");
            return nullptr;
        }
        fixed1 = 0x1;
    }
    if (param3->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param3->addr))
        {
            print_error("SCP ITERATOR 3 NEW", "Parameter 3 has modifier FIXED, but has not value");
            return nullptr;
        }
        fixed3 = 0x100;
    }
    fixed = (fixed1 | fixed3);
    switch (fixed)
    {
        case 0x001:
            return (scp_iterator3 *)sc_iterator3_f_a_a_new(param1->addr, param2->element_type, param3->element_type);
        case 0x100:
            return (scp_iterator3 *)sc_iterator3_a_a_f_new(param1->element_type, param2->element_type, param3->addr);
        case 0x101:
            return (scp_iterator3 *)sc_iterator3_f_a_f_new(param1->addr, param2->element_type, param3->addr);
        default:
            print_error("SCP ITERATOR 3 NEW", "Unsupported parameter type combination");
            return nullptr;
    }
    return nullptr;
}
scp_result genElStr3(scp_operand *param1, scp_operand *param2, scp_operand *param3)
{
    sc_uint32 fixed1 = 0;
    sc_uint32 fixed3 = 0;
    sc_uint32 fixed = 0;
    if (param2->param_type == SCP_FIXED)
    {
        return print_error("genElStr3", "Parameter 2 must have ASSIGN modifier");
    }
    if (param1->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param1->addr))
        {
            return print_error("genElStr3", "Parameter 1 has modifier FIXED, but has not value");
        }
        fixed1 = 0x1;
    }
    if (param3->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param3->addr))
        {
            return print_error("genElStr3", "Parameter 3 has modifier FIXED, but has not value");
        }
        fixed3 = 0x100;
    }
    fixed = (fixed1 | fixed3);
    switch (fixed)
    {
        case 0x101:
            return genElStr3_f_a_f(param1, param2, param3);
        case 0x100:
            return genElStr3_a_a_f(param1, param2, param3);
        case 0x001:
            return genElStr3_f_a_a(param1, param2, param3);
        case 0x000:
            return genElStr3_a_a_a(param1, param2, param3);
        default:
            return print_error("genElStr3", "Unsupported parameter type combination");
    }
    return SCP_RESULT_ERROR;
}
scp_result genEl(scp_operand *param)
{
    if (param->param_type != SCP_ASSIGN)
    {
        return print_error("genEl", "Parameter must have ASSIGN modifier");
    }
    if ((param->element_type & scp_type_node) != scp_type_node)
    {
        return print_error("genEl", "Only node element can be generated. Use genElStr3 for arcs");
    }
    param->addr = sc_memory_node_new(param->element_type);
    if (SC_FALSE == sc_memory_is_element(param->addr))
    {
        return print_error("genEl", "Element cannot be generated");
    }
    return SCP_RESULT_TRUE;
}
Exemple #15
0
// ----------- process commands -------------
sctpErrorCode sctpCommand::processCheckElement(quint32 cmdFlags, quint32 cmdId, QDataStream *params, QIODevice *outDevice)
{
    sc_addr addr;
    Q_UNUSED(cmdFlags);

    Q_ASSERT(params != 0);

    // read sc-add from parameters
    READ_PARAM(addr);

    sctpResultCode resCode = sc_memory_is_element(addr) ? SCTP_RESULT_OK : SCTP_RESULT_FAIL;

    // send result
    writeResultHeader(SCTP_CMD_CHECK_ELEMENT, cmdId, resCode, 0, outDevice);

    return SCTP_ERROR_NO;
}
scp_result varAssign(scp_operand *param1, scp_operand *param2)
{
    if (SCP_FIXED == param1->param_type)
    {
        return print_error("varAssign", "Parameter 1 must have ASSIGN modifier");
    }
    if (SCP_ASSIGN == param2->param_type)
    {
        return print_error("varAssign", "Parameter 2 must have FIXED modifier");
    }
    if (SC_FALSE == sc_memory_is_element(param2->addr))
    {
        return print_error("varAssign", "Parameter 2 has not value");
    }
    param1->addr = param2->addr;
    return SCP_RESULT_TRUE;
}
scp_result eraseEl(scp_operand *param)
{
    if (param->param_type != SCP_FIXED)
    {
        return print_error("eraseEl", "Parameter must have FIXED modifier");
    }
    if (param->erase != SCP_TRUE)
    {
        return print_error("eraseEl", "Parameter must have ERASE modifier");
    }
    if (SC_FALSE == sc_memory_is_element(param->addr))
    {
        return print_error("eraseEl", "Element has not value");
    }
    sc_memory_element_free(param->addr);
    SC_ADDR_MAKE_EMPTY(param->addr);
    return SCP_RESULT_TRUE;
}
Exemple #18
0
static scp_result resolve_string(sc_memory_context *context, const sc_char *operator_name, const sc_char *parameter_name, scp_operand *param, char **str)
{
    sc_stream *stream;
    sc_uint32 length = 0, read_length = 0;
    sc_char *data;

    if (SCP_ASSIGN == param->param_type)
    {
        return print_parameter_error(operator_name, parameter_name, "must have FIXED modifier");
    }

    if (SC_FALSE == sc_memory_is_element(context, param->addr))
    {
        return print_parameter_error(operator_name, parameter_name, "has not value");
    }

    if (SCP_RESULT_FALSE == check_type(context, param->addr, scp_type_link))
    {
        return print_parameter_error(operator_name, parameter_name, "must have link type");
    }

    if (SCP_RESULT_FALSE == check_string_type(context, param->addr))
    {
        return print_parameter_error(operator_name, parameter_name, "must have string format");
    }

    if (SC_RESULT_OK != sc_memory_get_link_content(context, param->addr, &stream))
    {
        return print_parameter_error(operator_name, parameter_name, "content reading error");
    }

    sc_stream_get_length(stream, &length);
    // extra byte needed for string terminator, which is neither counted nor read from an sc_stream
    data = calloc(length + 1, sizeof(sc_char));
    sc_stream_read_data(stream, data, length, &read_length);
    sc_stream_free(stream);

    size_t str_length = strlen(data) + 1;
    *str = calloc(str_length, sizeof(sc_char));
    memcpy(*str, data, str_length);
    free(data);

    return SCP_RESULT_TRUE;
}
Exemple #19
0
scp_result check_node_parameter_1(sc_memory_context *context, const sc_char *operator_name, scp_operand *param1)
{
    if (SCP_ASSIGN == param1->param_type)
    {
        param1->addr = sc_memory_node_new(context, scp_type_node);
    }
    else
    {
        if (SC_FALSE == sc_memory_is_element(context, param1->addr))
        {
            return print_error(operator_name, "Parameter 1 has not value");
        }
        if (check_type(context, param1->addr, scp_type_node) == SCP_RESULT_FALSE)
        {
            return print_error(operator_name, "Parameter 1 isn't node");
        }
    }
    return SCP_RESULT_TRUE;
}
Exemple #20
0
scp_result check_link_parameter_1(sc_memory_context *context, const sc_char *operator_name, scp_operand *param1)
{
    if (SCP_ASSIGN == param1->param_type)
    {
        param1->addr = sc_memory_link_new(context);
        //! TODO Add numeric class for link
    }
    else
    {
        if (SC_FALSE == sc_memory_is_element(context, param1->addr))
        {
            return print_error(operator_name, "Parameter 1 has not value");
        }
        if (check_type(context, param1->addr, scp_type_link) == SCP_RESULT_FALSE)
        {
            return print_error(operator_name, "Parameter 1 must have link type");
        }
    }
    return SCP_RESULT_TRUE;
}
Exemple #21
0
scp_result resolve_number(sc_memory_context *context, const sc_char *operator_name, const sc_char *parameter_name, scp_operand *param, double *num)
{
    sc_stream *stream;
    sc_uint32 length = 0, read_length = 0;
    sc_char *data1;

    if (SCP_ASSIGN == param->param_type)
    {
        return print_parameter_error(operator_name, parameter_name, "must have FIXED modifier");
    }

    if (SC_FALSE == sc_memory_is_element(context, param->addr))
    {
        return print_parameter_error(operator_name, parameter_name, "has not value");
    }

    if (SCP_RESULT_FALSE == check_type(context, param->addr, scp_type_link))
    {
        return print_parameter_error(operator_name, parameter_name, "must have link type");
    }

    if (SCP_RESULT_FALSE == check_numeric_type(context, param->addr))
    {
        return print_parameter_error(operator_name, parameter_name, "must have numeric format");
    }

    if (SC_RESULT_OK != sc_memory_get_link_content(context, param->addr, &stream))
    {
        return print_parameter_error(operator_name, parameter_name, "content reading error");
    }

    sc_stream_get_length(stream, &length);
    data1 = calloc(length, sizeof(sc_char));
    sc_stream_read_data(stream, data1, length, &read_length);
    sc_stream_free(stream);

    *num = atof(data1);
    free(data1);

    return SCP_RESULT_TRUE;
}
Exemple #22
0
bool ScMemoryContext::isElement(ScAddr const & addr) const
{
    check_expr(isValid());
    return (sc_memory_is_element(mContext, addr.mRealAddr) == SC_TRUE);
}
Exemple #23
0
void test1()
{
    sc_uint idx = 0;
    sc_addr id, id2;
    sc_uint32 count = 0;

    printf("Element size: %d bytes\n", sizeof(sc_element));
    printf("Segment size: %d elements\n", SEGMENT_SIZE);

    timer = g_timer_new();
    print_storage_statistics();
    printf("--- Node creation ---\n");
    g_timer_start(timer);
    for (idx = 0; idx < nodes_append_count; idx++)
    {
        id = sc_memory_node_new(sc_type_const);
        //g_printf("uri: %d\t%d\n", uri.seg, uri.id);
    }
    g_timer_stop(timer);
    printf("Time: %f s\n", g_timer_elapsed(timer, 0));
    printf("Nodes per second: %f\n", (float)nodes_append_count / g_timer_elapsed(timer, 0));
    printf("Segments count: %d\n", sc_storage_get_segments_count());
    print_storage_statistics();

    g_timer_reset(timer);
    printf("--- Node segmentation ---\n");
    count = 0;

    printf("Prepare test...\n");
    for (idx = 1; idx < nodes_remove_count + 1; idx++)
    {
        if (idx % 10 < 5)
        {
            id.seg = idx / SEGMENT_SIZE;
            id.offset = idx % SEGMENT_SIZE;
            /*do
      {
    id = get_random_addr(sc_type_node);
      }
      while(!sc_storage_is_element(id) && is_sc_addr_in_segment_node_vector(id));*/
            if (sc_memory_is_element(id))
                segment_node_del.push_back(id);
        }
    }

    printf("Run test...\n");
    g_timer_start(timer);

    sc_uint32 n = segment_node_del.size();
    for (sc_uint32 i = 0; i < n; ++i)
        sc_memory_element_free(segment_node_del[i]);

    n = nodes_remove_count - n;
    for (sc_uint32 i = 0; i < n; i++)
        sc_memory_node_new(0);

    g_timer_stop(timer);

    segment_node_del.clear();

    printf("Time: %f s\n", g_timer_elapsed(timer, 0));
    printf("Elements per second: %f\n", (float)nodes_remove_count / g_timer_elapsed(timer, 0));
    printf("Segments count: %d\n", sc_storage_get_segments_count());
    printf("Element free calls: %u\n", segment_node_del.size());
    print_storage_statistics();


    g_timer_reset(timer);
    printf("--- Arcs creation ---\n");
    count = 0;

    printf("Prepare...\n");
    for (idx = 0; idx < arcs_append_count; idx++)
    {
        do
        {
            id = get_random_addr(0);
        }while (!sc_memory_is_element(id));

        do
        {
            id2 = get_random_addr(0);
        }while (!sc_memory_is_element(id2));

        arc_creation_vector.push_back(id);
        arc_creation_vector.push_back(id2);
    }

    printf("Run...\n");
    g_timer_start(timer);
    n = arc_creation_vector.size() / 2;
    for (sc_uint32 i = 0; i < n; ++i)
    {
        sc_memory_arc_new(sc_type_arc_common, arc_creation_vector[i], arc_creation_vector[i + n]);
    }

    g_timer_stop(timer);
    printf("Timer: %fs\n", g_timer_elapsed(timer, 0));
    printf("Arcs per second: %f\n", (float)n / g_timer_elapsed(timer, 0));
    printf("Segments count: %d\n", sc_storage_get_segments_count());

    print_storage_statistics();

    g_timer_destroy(timer);
}
scp_result searchElStr5(scp_operand *param1, scp_operand *param2, scp_operand *param3, scp_operand *param4, scp_operand *param5)
{
    sc_uint32 fixed1 = 0;
    sc_uint32 fixed2 = 0;
    sc_uint32 fixed3 = 0;
    sc_uint32 fixed4 = 0;
    sc_uint32 fixed5 = 0;
    sc_uint32 fixed = 0;
    if (param1->param_type == SCP_ASSIGN && param2->param_type == SCP_ASSIGN && param3->param_type == SCP_ASSIGN && param4->param_type == SCP_ASSIGN && param5->param_type == SCP_ASSIGN)
    {
        return print_error("searchElStr5", "At least one operand must have FIXED modifier");
    }
    if (param1->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param1->addr))
        {
            return print_error("searchElStr5", "Parameter 1 has modifier FIXED, but has not value");
        }
        fixed1 = 0x1;
    }
    if (param2->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param2->addr))
        {
            return print_error("searchElStr5", "Parameter 2 has modifier FIXED, but has not value");
        }
        if (SCP_RESULT_TRUE == check_type(param2->addr, scp_type_node))
        {
            return print_error("searchElStr5", "Parameter 2 is not an arc");
        }
        fixed2 = 0x10;
    }
    if (param3->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param3->addr))
        {
            return print_error("searchElStr5", "Parameter 3 has modifier FIXED, but has not value");
        }
        fixed3 = 0x100;
    }
    if (param4->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param4->addr))
        {
            return print_error("searchElStr5", "Parameter 4 has modifier FIXED, but has not value");
        }
        if (SCP_RESULT_TRUE == check_type(param4->addr, scp_type_node))
        {
            return print_error("searchElStr5", "Parameter 4 is not an arc");
        }
        fixed4 = 0x1000;
    }
    if (param5->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param5->addr))
        {
            return print_error("searchElStr5", "Parameter 5 has modifier FIXED, but has not value");
        }
        fixed5 = 0x10000;
    }
    fixed = (fixed1 | fixed2 | fixed3 | fixed4 | fixed5);
    switch (fixed)
    {
        case 0x11111:
            return searchElStr5_f_f_f_f_f(param1, param2, param3, param4, param5);
        case 0x10101:
            return searchElStr5_f_a_f_a_f(param1, param2, param3, param4, param5);
        case 0x10001:
            return searchElStr5_f_a_a_a_f(param1, param2, param3, param4, param5);
        case 0x00101:
            return searchElStr5_f_a_f_a_a(param1, param2, param3, param4, param5);
        case 0x10100:
            return searchElStr5_a_a_f_a_f(param1, param2, param3, param4, param5);
        case 0x00100:
            return searchElStr5_a_a_f_a_a(param1, param2, param3, param4, param5);
        case 0x00001:
            return searchElStr5_f_a_a_a_a(param1, param2, param3, param4, param5);
        case 0x10000:
            return searchElStr5_a_a_a_a_f(param1, param2, param3, param4, param5);
        default:
            return print_error("searchElStr5", "Unsupported parameter type combination");
    }
    return SCP_RESULT_ERROR;
}
scp_result printEl(scp_operand *param)
{
    sc_addr element = param->addr;
    sc_addr addr2, addr3;
    sc_addr idtf;
    sc_iterator3 *it = nullptr;
    sc_uint32 out_c = 0, in_c = 0;
    if (SC_FALSE == sc_memory_is_element(param->addr))
    {
        return print_error("printEl", "Parameter has not value");
    }
    if (SC_RESULT_OK == sc_helper_get_system_identifier(element, &idtf))
    {
        sc_stream *stream;
        sc_uint32 length = 0, read_length = 0;
        sc_char *data;
        sc_memory_get_link_content(idtf, &stream);
        sc_stream_get_length(stream, &length);
        data = calloc(length + 1, sizeof(sc_char));
        sc_stream_read_data(stream, data, length, &read_length);
        data[length] = '\0';
        printf("\nPrint element: %s =\n", data);
        sc_stream_free(stream);
        free(data);
    }
    else
    {
        printf("\nPrint element: %u|%u =\n", element.seg, element.offset);
    }

    it = sc_iterator3_a_a_f_new(0, 0, element);
    if (it == 0)
    {
        return SCP_RESULT_ERROR;
    }
    printf("Input arcs:\n");
    while (SC_TRUE == sc_iterator3_next(it))
    {
        in_c++;
        addr2 = sc_iterator3_value(it, 0);
        addr3 = sc_iterator3_value(it, 1);

        if (SC_RESULT_OK == sc_helper_get_system_identifier(addr3, &idtf))
        {
            sc_stream *stream;
            sc_uint32 length = 0, read_length = 0;
            sc_char *data;
            sc_memory_get_link_content(idtf, &stream);
            sc_stream_get_length(stream, &length);
            data = calloc(length + 1, sizeof(sc_char));
            sc_stream_read_data(stream, data, length, &read_length);
            data[length] = '\0';
            if (SCP_RESULT_TRUE == check_type(addr3, scp_type_arc_access))
            {
                printf("\t%s <- ", data);
            }
            else
            {
                printf("\t%s <= ", data);
            }
            sc_stream_free(stream);
            free(data);
        }
        else
        {
            if (SCP_RESULT_TRUE == check_type(addr3, scp_type_arc_access))
            {
                printf("\t%u|%u <- ", addr3.seg, addr3.offset);
            }
            else
            {
                printf("\t%u|%u <= ", addr3.seg, addr3.offset);
            }
        }
        if (SC_RESULT_OK == sc_helper_get_system_identifier(addr2, &idtf))
        {
            sc_stream *stream;
            sc_uint32 length = 0, read_length = 0;
            sc_char *data;
            sc_memory_get_link_content(idtf, &stream);
            sc_stream_get_length(stream, &length);
            data = calloc(length + 1, sizeof(sc_char));
            sc_stream_read_data(stream, data, length, &read_length);
            data[length] = '\0';
            printf("%s;\n", data);
            sc_stream_free(stream);
            free(data);
        }
        else
        {
            printf("%u|%u;\n", addr2.seg, addr2.offset);
        }
    }
    sc_iterator3_free(it);
    printf("Total input arcs: %d\n", in_c);

    it = sc_iterator3_f_a_a_new(element, 0, 0);
    if (it == 0)
    {
        return SCP_RESULT_ERROR;
    }
    printf("Output arcs:\n");
    while (SC_TRUE == sc_iterator3_next(it))
    {
        out_c++;
        addr2 = sc_iterator3_value(it, 1);
        addr3 = sc_iterator3_value(it, 2);

        if (SC_RESULT_OK == sc_helper_get_system_identifier(addr2, &idtf))
        {
            sc_stream *stream;
            sc_uint32 length = 0, read_length = 0;
            sc_char *data;
            sc_memory_get_link_content(idtf, &stream);
            sc_stream_get_length(stream, &length);
            data = calloc(length + 1, sizeof(sc_char));
            sc_stream_read_data(stream, data, length, &read_length);
            data[length] = '\0';
            if (SCP_RESULT_TRUE == check_type(addr2, scp_type_arc_access))
            {
                printf("\t%s -> ", data);
            }
            else
            {
                printf("\t%s => ", data);
            }
            sc_stream_free(stream);
            free(data);
        }
        else
        {
            if (SCP_RESULT_TRUE == check_type(addr2, scp_type_arc_access))
            {
                printf("\t%u|%u -> ", addr2.seg, addr2.offset);
            }
            else
            {
                printf("\t%u|%u => ", addr2.seg, addr2.offset);
            }

        }
        if (SC_RESULT_OK == sc_helper_get_system_identifier(addr3, &idtf))
        {
            sc_stream *stream;
            sc_uint32 length = 0, read_length = 0;
            sc_char *data;
            sc_memory_get_link_content(idtf, &stream);
            sc_stream_get_length(stream, &length);
            data = calloc(length + 1, sizeof(sc_char));
            sc_stream_read_data(stream, data, length, &read_length);
            data[length] = '\0';
            printf("%s;\n", data);
            sc_stream_free(stream);
            free(data);
        }
        else
        {
            printf("%u|%u;\n", addr3.seg, addr3.offset);
        }
    }
    sc_iterator3_free(it);
    printf("Total output arcs: %d\n", out_c);
    return SCP_RESULT_TRUE;
}
scp_result scp_iterator3_next(scp_iterator3 *iter, scp_operand *param1, scp_operand *param2, scp_operand *param3)
{
    sc_uint32 fixed1 = 0;
    sc_uint32 fixed2 = 0;
    sc_uint32 fixed3 = 0;
    sc_uint32 fixed = 0;
    if (param2->param_type == SCP_FIXED)
    {
        return print_error("SCP ITERATOR 3 NEXT", "Parameter 2 must have ASSIGN modifier");
    }
    if (param1->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param1->addr))
        {
            return print_error("SCP ITERATOR 3 NEXT", "Parameter 1 has modifier FIXED, but has not value");
        }
        fixed1 = 0x1;
    }
    if (param3->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(param3->addr))
        {
            return print_error("SCP ITERATOR 3 NEXT", "Parameter 3 has modifier FIXED, but has not value");
        }
        fixed3 = 0x100;
    }
    fixed = (fixed1 | fixed2 | fixed3);
    switch (fixed)
    {
        case 0x001:
            if (iter->type != sc_iterator3_f_a_a)
            {
                return print_error("SCP ITERATOR 3 NEXT", "Iterator type and parameter type combination doesn't match");
            }
            else
            {
                if (SC_TRUE == sc_iterator3_next(iter))
                {
                    param2->addr = sc_iterator3_value(iter, 1);
                    param3->addr = sc_iterator3_value(iter, 2);
                    return SCP_RESULT_TRUE;
                }
                else
                {
                    return SCP_RESULT_FALSE;
                }
            }
        case 0x100:
            if (iter->type != sc_iterator3_a_a_f)
            {
                return print_error("SCP ITERATOR 3 NEXT", "Iterator type and parameter type combination doesn't match");
            }
            else
            {
                if (SC_TRUE == sc_iterator3_next(iter))
                {
                    param1->addr = sc_iterator3_value(iter, 0);
                    param2->addr = sc_iterator3_value(iter, 1);
                    return SCP_RESULT_TRUE;
                }
                else
                {
                    return SCP_RESULT_FALSE;
                }
            }
        case 0x101:
            if (iter->type != sc_iterator3_f_a_f)
            {
                return print_error("SCP ITERATOR 3 NEXT", "Iterator type and parameter type combination doesn't match");
            }
            else
            {
                if (SC_TRUE == sc_iterator3_next(iter))
                {
                    param2->addr = sc_iterator3_value(iter, 1);
                    return SCP_RESULT_TRUE;
                }
                else
                {
                    return SCP_RESULT_FALSE;
                }
            }
        default:
            return print_error("SCP ITERATOR 3 NEXT", "Unsupported parameter type combination");
    }
    return SCP_RESULT_ERROR;
}
scp_iterator5 *scp_iterator5_new(sc_memory_context *context, scp_operand *param1, scp_operand *param2, scp_operand *param3, scp_operand *param4, scp_operand *param5)
{
    sc_uint32 fixed1 = 0;
    sc_uint32 fixed3 = 0;
    sc_uint32 fixed5 = 0;
    long fixed = 0;
    if (param2->param_type == SCP_FIXED)
    {
        print_error("SCP ITERATOR 5 NEW", "Parameter 2 must have ASSIGN modifier");
        return null_ptr;                ;
    }
    if (param4->param_type == SCP_FIXED)
    {
        print_error("SCP ITERATOR 5 NEW", "Parameter 4 must have ASSIGN modifier");
        return null_ptr;                ;
    }
    if (param1->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(context, param1->addr))
        {
            print_error("SCP ITERATOR 5 NEW", "Parameter 1 has modifier FIXED, but has not value");
            return null_ptr;
        }
        fixed1 = 0x1;
    }
    if (param3->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(context, param3->addr))
        {
            print_error("SCP ITERATOR 5 NEW", "Parameter 3 has modifier FIXED, but has not value");
            return null_ptr;
        }
        fixed3 = 0x100;
    }
    if (param5->param_type == SCP_FIXED)
    {
        if (SC_FALSE == sc_memory_is_element(context, param5->addr))
        {
            print_error("SCP ITERATOR 5 NEW", "Parameter 5 has modifier FIXED, but has not value");
            return null_ptr;
        }
        fixed5 = 0x10000;
    }
    fixed = (fixed1 | fixed3 | fixed5);
    switch (fixed)
    {
        case 0x00001:
            return (scp_iterator5 *)sc_iterator5_f_a_a_a_a_new(context, param1->addr, param2->element_type, param3->element_type, param4->element_type, param5->element_type);
        case 0x00100:
            return (scp_iterator5 *)sc_iterator5_a_a_f_a_a_new(context, param1->element_type, param2->element_type, param3->addr, param4->element_type, param5->element_type);
        case 0x10001:
            return (scp_iterator5 *)sc_iterator5_f_a_a_a_f_new(context, param1->addr, param2->element_type, param3->element_type, param4->element_type, param5->addr);
        case 0x10100:
            return (scp_iterator5 *)sc_iterator5_a_a_f_a_f_new(context, param1->element_type, param2->element_type, param3->addr, param4->element_type, param5->addr);
        case 0x00101:
            return (scp_iterator5 *)sc_iterator5_f_a_f_a_a_new(context, param1->addr, param2->element_type, param3->addr, param4->element_type, param5->element_type);
        case 0x10101:
            return (scp_iterator5 *)sc_iterator5_f_a_f_a_f_new(context, param1->addr, param2->element_type, param3->addr, param4->element_type, param5->addr);
        default:
            print_error("SCP ITERATOR 5 NEW", "Unsupported parameter type combination");
            return null_ptr;
    }
}