コード例 #1
0
ファイル: credentials_manager.cpp プロジェクト: AlexNk/botan
void Credentials_Manager::verify_certificate_chain(
   const std::string& type,
   const std::string& purported_hostname,
   const std::vector<X509_Certificate>& cert_chain)
   {
   if(cert_chain.empty())
      throw std::invalid_argument("Certificate chain was empty");

   auto trusted_CAs = trusted_certificate_authorities(type, purported_hostname);

   Path_Validation_Restrictions restrictions;

   auto result = x509_path_validate(cert_chain,
                                    restrictions,
                                    trusted_CAs);

   if(!result.successful_validation())
      throw std::runtime_error("Certificate validation failure: " + result.result_string());

   if(!cert_in_some_store(trusted_CAs, result.trust_root()))
      throw std::runtime_error("Certificate chain roots in unknown/untrusted CA");

   if(purported_hostname != "" && !cert_chain[0].matches_dns_name(purported_hostname))
      throw std::runtime_error("Certificate did not match hostname");
   }
コード例 #2
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_clear(GLboolean input, GLboolean output, char* buffer, int size, Clear* x) {
    if(input) {
        int flags = x->cmd.clear_flags;
        
        for (int i = 0; i < CLEAR_FLAG_MAX; i++) {
            if (!flags) {
                break;
            }
            
            const char* name = show_clear_flag(0x1 << i, flags & 0x1);
            if (i != 0) {
                strcat(buffer, " | ");
            }
            
            strcat(buffer, name);
            
            flags >>= 1;        
        }
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #3
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_shader_source(GLboolean input, GLboolean output, char* buffer, int size, ShaderSource* x) {
    if(input) {
        char sub_buffer[50];
        memset(sub_buffer, 0, 50);
        show_resource_id(sub_buffer, 50, x->cmd.id);
        
        char memory_buffer[50];
        memset(memory_buffer, 0, 50);
        show_memory_location(memory_buffer, x->cmd.source_location);
        
        char lengths_buffer[50];
        memset(lengths_buffer, 0, 50);
        
        if(x->cmd.length != NULL) {    
            for(int i = 0; i < x->cmd.count; i++) {
                char int_buff[10];
                memset(int_buff, 0, 10);
                sprintf(int_buff, "%d", x->cmd.length[i]);
                strcat(lengths_buffer, int_buff);
            }
        }
            
        sprintf(buffer, "id %s, count %d, memory_location %s, length %s", sub_buffer, x->cmd.count, memory_buffer,
                lengths_buffer);
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #4
0
result dns_selector::on_initialize()
{
    result res = result_success;
    do
    {
        res = m_ad_performancer.initialize();
        if (res != result_success)
        {
            ui::instance()->showwarning("页面可能没有正确展现[%s]", result_string(res));
            ui::instance()->show_ad(false);
        }
        res = m_ip_fetcher.initialize();
        if (res != result_success)
        {
            break;
        }
        res = m_dns_ping.initialize();
        if (res != result_success)
        {
            break;
        }
        res = m_dns_switcher.initialize();
        if (res != result_success)
        {
            break;
        }
        res = result_success;
    } while (false);
    return res;
}
コード例 #5
0
ファイル: ui.cpp プロジェクト: fishgege/LDNS-Selector-Windows
void ui::OnSwitchAdapter()
{
    int adapter_cur_sel = m_p_adapter_info_list->GetCurSel();
    if (adapter_cur_sel == -1)
    {
        ui::instance()->showwarning("ÇëÑ¡ÔñÐèÒªÇл»µÄÍø¿¨");
        return;
    }
    int dns_cur_sel = m_p_dns_info_list->GetCurSel();
    if (dns_cur_sel == -1)
    {
        ui::instance()->showwarning("Ñ¡ÔñÐèÒªÇл»µÄDNS");
        return;
    }

    unsigned int index = 0;
    {
        auto it = m_map_adapter_item_index.find(static_cast<DuiLib::CListContainerElementUI*>(m_p_adapter_info_list->GetItemAt(adapter_cur_sel)));
        Assert(it != m_map_adapter_item_index.end());
        if (it == m_map_adapter_item_index.end())
        {
            ui::instance()->showerror("ÕÒ²»µ½ËùÑ¡Íø¿¨");
            return;
        }
        index = it->second;
    }

    std::wstring str_ip;
    {
        auto it = m_map_dns_item_ip.find(static_cast<DuiLib::CListContainerElementUI*>(m_p_dns_info_list->GetItemAt(dns_cur_sel)));
        Assert(it != m_map_dns_item_ip.end());
        if (it == m_map_dns_item_ip.end())
        {
            ui::instance()->showerror("ÕÒ²»µ½ËùÑ¡DNS");
            return;
        }
        str_ip = it->second;
    }

    EnableUserOperation(false);
    std::thread(
        [this, index, str_ip]()
    {
        result res = m_p_notifyer->on_switch_dns(index, str_ip);
        if (res == result_success)
        {
            OnFreshenAdapterInfo();
            ui::instance()->showlog("Çл»Íø¿¨DNS³É¹¦");
        }
        else
        {
            ui::instance()->showerror("Çл»Íø¿¨DNSʧ°Ü-->[%s]", result_string(res));
        }
        EnableUserOperation(true);
    }
    ).detach();

}
コード例 #6
0
ファイル: ui.cpp プロジェクト: fishgege/LDNS-Selector-Windows
void ui::OnFreshenDNSInfo()
{
    m_p_last_selected_dns_item = nullptr;
    m_orgin_dns_item_color = 0xFFFFFFFF;
    m_p_dns_info_list->RemoveAll();
    m_map_dns_item_ip.clear();

    EnableUserOperation(false);
    std::thread(
        [this]()
    {
        std::shared_ptr<freshen_dns_info_result_data> sp_res_data = std::make_shared<freshen_dns_info_result_data>();
        result res = m_p_notifyer->on_freshen_dns_info(*sp_res_data.get());
        if (res != result_success)
        {
            showerror("Ë¢ÐÂDNSʧ°Ü-->[%s]", result_string(res));
            EnableUserOperation(true);
            return;
        }
        post_call(
            [this, sp_res_data]()
        {
            showlog("Ë¢ÐÂDNSÁбíºÄʱ[%ws]", sp_res_data->_str_freshen_take_time.c_str());
            for (auto it : sp_res_data->_vec_ip_dns_info)
            {
                ui_dns_info& info = it;

                DuiLib::CDialogBuilder builder;
                DuiLib::CListContainerElementUI* p_item = static_cast<DuiLib::CListContainerElementUI*>(builder.Create(_T("dns_info_item.xml"), (UINT)0, NULL, &m_PaintManager));
                Assert(p_item != nullptr);

                if (m_orgin_dns_item_color == 0xFFFFFFFF)
                {
                    m_orgin_dns_item_color = p_item->GetBkColor();
                }

                DuiLib::CLabelUI* p_dns_vip_label = static_cast<DuiLib::CLabelUI*>(p_item->FindSubControl(_T("dns_vip_label")));
                Assert(p_dns_vip_label != nullptr);
                DuiLib::CLabelUI* p_dns_uptime_label = static_cast<DuiLib::CLabelUI*>(p_item->FindSubControl(_T("dns_uptime_label")));
                Assert(p_dns_uptime_label != nullptr);
                DuiLib::CLabelUI* p_dns_ping_t_ms_label = static_cast<DuiLib::CLabelUI*>(p_item->FindSubControl(_T("dns_ping_t_ms_label")));
                Assert(p_dns_ping_t_ms_label != nullptr);

                p_dns_vip_label->SetText(info._str_vip.c_str());
                p_dns_uptime_label->SetText(info._str_uptime.c_str());
                p_dns_ping_t_ms_label->SetText(info._str_ping_t_ms.c_str());

                m_p_dns_info_list->Add(p_item);
                m_map_dns_item_ip.insert(std::make_pair(p_item, info._str_vip));
            }

            EnableUserOperation(true);
        }
        );
    }
    ).detach();
}
コード例 #7
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_use_program(GLboolean input, GLboolean output, char* buffer, int size, UseProgram* x) {
    if(input) {
        show_resource_id(buffer, size, x->cmd.id);
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #8
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_enable(GLboolean input, GLboolean output, char* buffer, int size, Enable* x) {
    if(input) {
        sprintf(buffer, "state %s", enable_type_string(x->cmd.state));    
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #9
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_enable_vertex_attrib_array(GLboolean input, GLboolean output, char* buffer, int size, EnableVertexAttribArray* x) {
    if(input) {
        sprintf(buffer, "index %d", x->cmd.index);
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #10
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_draw_arrays(GLboolean input, GLboolean output, char* buffer, int size, DrawArrays* x) {
    if(input) {
        sprintf(buffer, "component_type %s, start %d, count %d", 
            component_type_string(x->cmd.component_type), x->cmd.start, x->cmd.count);
    }
    
    if (output) {
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error); 
    }
}
コード例 #11
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_clear_color(GLboolean input, GLboolean output, char* buffer, int size, ClearColor* x) {
    if(input) {
        sprintf(buffer, "r %f, g %f, b %f, a %f", x->cmd.r, x->cmd.g, 
            x->cmd.b, x->cmd.a);
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #12
0
ファイル: ui.cpp プロジェクト: fishgege/LDNS-Selector-Windows
void ui::InitWindow()
{
    m_p_exit_btn = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("exit_btn")));
    Assert(m_p_exit_btn != nullptr);
    m_p_min_btn = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("min_btn")));
    Assert(m_p_min_btn != nullptr);
    m_p_version_label = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("version_label")));
    Assert(m_p_version_label != nullptr);
    m_p_auto_done_btn = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("auto_done_btn")));
    Assert(m_p_auto_done_btn != nullptr);
    m_p_professional_view = static_cast<DuiLib::CVerticalLayoutUI*>(m_PaintManager.FindControl(_T("professional_view")));
    Assert(m_p_professional_view != nullptr);
    m_p_adapter_info_list = static_cast<DuiLib::CListUI*>(m_PaintManager.FindControl(_T("adapter_info_list")));
    Assert(m_p_adapter_info_list != nullptr);
    m_p_dns_info_list = static_cast<DuiLib::CListUI*>(m_PaintManager.FindControl(_T("dns_info_list")));
    Assert(m_p_dns_info_list != nullptr);
    m_p_freshen_adapter_btn = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("freshen_adapter_btn")));
    Assert(m_p_freshen_adapter_btn != nullptr);
    m_p_freshen_dns_btn = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("freshen_dns_btn")));
    Assert(m_p_freshen_dns_btn != nullptr);
    m_p_switch_adapter_dns_btn = static_cast<DuiLib::CButtonUI*>(m_PaintManager.FindControl(_T("switch_adapter_dns_btn")));
    Assert(m_p_switch_adapter_dns_btn != nullptr);
    m_p_log_list = static_cast<DuiLib::CListUI*>(m_PaintManager.FindControl(_T("log_list")));
    Assert(m_p_log_list != nullptr);
    
    m_p_version_label->SetText(get_version().c_str());
    m_p_log_list->GetHeader()->SetFixedHeight(1);
    m_p_dns_info_list->GetHeader()->SetFixedHeight(1);
    m_p_adapter_info_list->GetHeader()->SetFixedHeight(1);

    EnableUserOperation(false);
    std::thread(
        [this]()
    {
        result res = m_p_notifyer->on_initialize(); 
        if (res == result_success)
        {
            post_call(
                [this]()
            {
                EnableUserOperation(true);
            }
                );
        }
        else
        {
            showerror("³õʼ»¯Ê§°Ü-->[%s]", result_string(res));
        }
    }
    ).detach();

}
コード例 #13
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_link_program(GLboolean input, GLboolean output, char* buffer, int size, LinkProgram* x) {
    if(input) {
        char sub_buffer[50];
        memset(sub_buffer, 0, 50);
        show_resource_id(sub_buffer, 50, x->cmd.id);
        sprintf(buffer, "id %s", sub_buffer);
    } 
    
    if (output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);
    }
}
コード例 #14
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_vertex_attrib_pointer(GLboolean input, GLboolean output, char* buffer, int size, VertexAttribPointer* x) {
    if(input) {
        
        
        sprintf(buffer, "index %d, size %d, type %s, normalized %d, stride %d, memory_location %d",
                x->cmd.index, x->cmd.size, vap_string(x->cmd.type), x->cmd.normalized, 
                x->cmd.stride, x->cmd.offset);
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #15
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_create_shader(GLboolean input, GLboolean output, char* buffer, int size, CreateShader* x) {
    if(input) {
        char sub_buffer[50];
        memset(sub_buffer, 0, 50);
        show_resource_mapper(sub_buffer, size, x->cmd.mapper);
        
        sprintf(buffer, "mapper %s", sub_buffer);
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #16
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_gen_vertex_arrays_oes(GLboolean input, GLboolean output, char* buffer, int size, GenVertexArraysOES* x) {
    if(input) {
        char sub_buffer[200];
        memset(sub_buffer, 0, 200);
        show_resource_mapper(sub_buffer, 200, x->cmd.mapper);
        
        sprintf(buffer, "count %d, mapper %s", x->cmd.count, sub_buffer);
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #17
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_gen_buffers(GLboolean input, GLboolean output, char* buffer, int size, GenBuffers* x) {
    if(input) {
        char sub_buffer[50];
        memset(sub_buffer, 0, 50);
        show_resource_mapper(sub_buffer, 50, x->cmd.mapper);
    
        sprintf(buffer, "count %d, resource id %s", x->cmd.count, sub_buffer);
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #18
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_delete_buffers(GLboolean input, GLboolean output, char* buffer, int size, DeleteBuffers* x) {
    if(input) {
        char sub_buffer[200];
        memset(sub_buffer, 0, 200);
        show_resource_id_array(sub_buffer, 200, x->cmd.buffers, x->cmd.count);
    
        sprintf(buffer, "count %d, ids %s", x->cmd.count, sub_buffer);
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #19
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_bind_vertex_arrays_oes(GLboolean input, GLboolean output, char* buffer, int size, BindVertexArrayOES* x) {
    if(input) {
        char sub_buffer[50];
        memset(sub_buffer, 0, 50);
        show_resource_id(sub_buffer, 50, x->cmd.id);
        
        sprintf(buffer, "id %s", sub_buffer);
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #20
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_bind_attrib_location(GLboolean input, GLboolean output, char* buffer, int size, BindAttribLocation* x) {
    if(input) {
        char program_buffer[50];
        memset(program_buffer, 0, 50);
        show_resource_id(program_buffer, 50, x->cmd.program_id);
        
        sprintf(buffer, "program_id %s, index %d, name %s", program_buffer, x->cmd.index, x->cmd.name);
    }    
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #21
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_bind_buffers(GLboolean input, GLboolean output, char* buffer, int size, BindBuffer* x) {
    if(input) {
        char sub_buffer[50];
        memset(sub_buffer, 0, 50);
        show_resource_id(sub_buffer, 50, x->cmd.id);
        
        sprintf(buffer, "target %s, id %s", buffer_target_string(x->cmd.buffer_target), 
                sub_buffer);
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #22
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_buffer_data(GLboolean input, GLboolean output, char* buffer, int size, BufferData* x) {
    if(input) {
        char sub_buffer[50];
        memset(sub_buffer, 0, 50);    
        show_memory_location(sub_buffer, x->cmd.memory_location);
        
        sprintf(buffer, "buffer target %s, size %d, memory location %s, usage %s", 
                buffer_target_string(x->cmd.buffer_target),
                x->cmd.size, sub_buffer, usage_string(x->cmd.usage));
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #23
0
ファイル: string.hpp プロジェクト: Constellation/zuse
 static IString const& es_replace_when_global_flag_is_off(
     IRegExp& regexp,
     IString& lhs_string,
     es_string_or_binded_function<stringT> const& replace_value
     ) throw()
 {
     stringT result_string(lhs_string.operator std::wstring const());
     IPrimitive& match_result = regexp.exec(lhs_string);
     return VT::Null == match_result.type__() ?
         lhs_string :
         *new es_string<stringT>(
             es_replace_helper(
                 result_string,
                 match_result,
                 regexp.lastIndex(),
                 replace_value.operator stringT const()));
 }
コード例 #24
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_get_uniform_location(GLboolean input, GLboolean output, char* buffer, int size, GetUniformLocation* x) {
    if(input) {
        char sub_buffer[50];
        memset(sub_buffer, 0, 50);
        show_resource_id(sub_buffer, 50, x->cmd.program_id);
        
        sprintf(buffer, "program_id %s, name %s", sub_buffer, x->cmd.name);
    }
    
    if(output) {
        char output_char[50];
        sprintf(buffer, "result type %s, error code %d, index %d", result_string(x->result.type),
                x->result.left.error, x->result.right.index);
        
        strcat(buffer, output_char);
    }
}
コード例 #25
0
ファイル: zz_unit_test.cpp プロジェクト: eaglescv/znzin
void zz_unit_test_function::run (bool verbose)
{
	std::string error;
	verbose_ = verbose;

	// Run the test
	if (verbose) 
		std::cout << "Running " << name_.c_str() << std::endl;
	result_ = eRunning;

	zz_elapsed_time time;
	try {
		test ();
	}
	catch (const std::exception& ex) {
		// We caught an STL exception
		error = std::string("Exception '") + ex.what() + "' caught";
		if (verbose)
			std::cout << error << " in " << name_.c_str() << std::endl;
		add_message (error);
		result_ = eFailure;
	}
	catch (...) {
		// We caught an unknown exception
		error = "Unknown exception caught";
		if (verbose)
			std::cout << error << " in " << name_.c_str() << std::endl;
		add_message (error);
		result_ = eFailure;
	}
	elapsed_ = time.msec ();

	// Make sure the test() function set a result or set eUnknown
	if (result_ != eSuccess && result_ != eFailure)
		result_ = eUnknown;

	if (verbose_) {
		std::cout << "  Result of " << name_.c_str() << " is " 
			<< result_string().c_str() << " (" << elapsed_ 
			<< " msec)" << std::endl;
		if (message_.size() > 0)
			std::cout << "  Messages: " << message_.c_str() 
			<< std::endl;
	}
}
コード例 #26
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_attack_shader(GLboolean input, GLboolean output, char* buffer, int size, AttachShader* x) {
    if(input) {
        char program_buffer[50]; 
        memset(program_buffer, 0, 50);
        show_resource_id(program_buffer, 50, x->cmd.program_id);
        
        char shader_buffer[50];
        memset(shader_buffer, 0, 50);
        show_resource_id(shader_buffer, 50, x->cmd.shader_id);
        
        sprintf(buffer, "program %s, shader %s", program_buffer, shader_buffer);
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #27
0
ファイル: Commands.c プロジェクト: jfischoff/EvalGL
void show_uniform_matrix(GLboolean input, GLboolean output, char* buffer, int size, UniformMatrix* x) {
    if(input) {
        char sub_buffer[50];
        memset(sub_buffer, 0, 50);
        show_memory_location(sub_buffer, x->cmd.memory_location);
        
        sprintf(buffer, "uniform_type %s, uniform_index %d, count %d, transpose %d, memory_location %s", 
                uniform_matrix_string(x->cmd.uniform_type), 
                x->cmd.uniform_index,
                x->cmd.count,
                x->cmd.transpose,
                sub_buffer);
    }
    
    if(output){
        sprintf(buffer, "result type %s, error code %d", result_string(x->result.type),
                x->result.left.error);        
    }
}
コード例 #28
0
ファイル: ui.cpp プロジェクト: fishgege/LDNS-Selector-Windows
void ui::OnAutoDone()
{
    EnableUserOperation(false);
    std::thread(
        [this]()
    {
        std::wstring take_time;
        result res = m_p_notifyer->on_auto_done(take_time);
        if (res == result_success)
        {
            showlog("×Ô¶¯ÓÅ»¯DNS³É¹¦£¬ºÄʱ[%ws]", take_time.c_str());
        }
        else
        {
            showerror("×Ô¶¯ÓÅ»¯DNSʧ°Ü-->[%s]", result_string(res));
        }
        EnableUserOperation(true);
    }
    ).detach();
}
コード例 #29
0
string getRefSeq(int coordinate, int size,  string ref_filename) {
	string result_string(fragment_length_, 'A');
 	FILE * pFileS;
	char * search_string;
	int  size_opt;
	int  coordinate_opt;
	int  boundary;
	int  boundary_detect = 0;
	int  read_number;

	//Initialize string size
	//result_string.resize(REF_TABLE_SIZE);

	boundary   	= coordinate-(coordinate/REF_TABLE_SIZE)*REF_TABLE_SIZE + size;	// boundary checking
	size_opt   	= size + boundary / REF_TABLE_SIZE + 2;				// size optimization
	coordinate_opt 	= coordinate+coordinate/REF_TABLE_SIZE;				// add # of new line characters
 	search_string   = (char*) malloc(sizeof(char)*size_opt);	
 	pFileS = fopen (ref_filename.c_str(), "r");
	fseek (pFileS, 0, SEEK_SET );
	read_number = fread (search_string, 1, size_opt, pFileS);
	if (search_string[0] == '\n') {
		fseek (pFileS, coordinate_opt+1, SEEK_SET );
		read_number = fread (search_string, 1, size_opt, pFileS);
	} else {
		fseek (pFileS, coordinate_opt, SEEK_SET );
		read_number = fread (search_string, 1, size_opt, pFileS);
	}
	for (int i = 0; i < size ; i++) {
		if ((search_string[i+boundary_detect] == '\n')) {
			boundary_detect = boundary_detect + 1;
		} 
		result_string[i] = search_string[i+boundary_detect];
		if (boundary_detect == 2){
//cout << " DETECTED 2 BOUNDARY " << boundary_detect << endl;
		}
	}
	fclose (pFileS);
	free(search_string);
	return result_string;
}
コード例 #30
0
int callOnRilRequest(v8::Handle<v8::Context> context, int cmd,
                   const void *buffer, RIL_Token t) {
    DBG("callOnRilRequest E: cmd=%d", cmd);

    int status;
    v8::HandleScope handle_scope;
    v8::TryCatch try_catch;

    // Get the onRilRequest Function
    v8::Handle<v8::String> name = v8::String::New("onRilRequest");
    v8::Handle<v8::Value> onRilRequestFunctionValue = context->Global()->Get(name);
    v8::Handle<v8::Function> onRilRequestFunction =
        v8::Handle<v8::Function>::Cast(onRilRequestFunctionValue);

    // Create the cmd and token
    v8::Handle<v8::Value> v8RequestValue = v8::Number::New(cmd);
    v8::Handle<v8::Value> v8TokenValue = v8::Number::New(int64_t(t));

    // Invoke onRilRequest
    const int argc = 3;
    v8::Handle<v8::Value> argv[argc] = {
            v8RequestValue, v8TokenValue, ((Buffer *)buffer)->handle_ };
    v8::Handle<v8::Value> result =
        onRilRequestFunction->Call(context->Global(), argc, argv);
    if (try_catch.HasCaught()) {
        ALOGE("callOnRilRequest error");
        ReportException(&try_catch);
        status = STATUS_ERR;
    } else {
        v8::String::Utf8Value result_string(result);
        DBG("callOnRilRequest result=%s", ToCString(result_string));
        status = STATUS_OK;
    }

    DBG("callOnRilRequest X: status=%d", status);
    return status;
}