Example #1
0
/*	Search the list of link title for a match
*/
static void find_page(const char *search_title, void *data)
{
	size_t i;

	/* find matches where the search string is a substring of the title */
	num_found_links = 0;
	for (i=0; i<num_page_links && num_found_links<MAX_FOUND_LINKS; ++i)
		if(xmlStrcasestr((xmlChar*)page_links[i].title,(xmlChar*)search_title)!=NULL)
			found_links[num_found_links++] = i;

	/* ignore if no matches, open if one match, or display a list of the first few matches */
	if (num_found_links < 1)
		return;
	else if (num_found_links == 1)
		open_page(found_links[0]);
	else
	{
		if (cm_valid(cm_encycl_res))
			cm_destroy(cm_encycl_res);
		cm_encycl_res = cm_create(page_links[found_links[0]].title, cm_encycl_res_handler);
		cm_set_pre_show_handler(cm_encycl_res, cm_encycl_res_pre_show_handler);
		for (i=1; i<num_found_links; i++)
			cm_add(cm_encycl_res, page_links[found_links[i]].title, NULL);
		cm_show_direct(cm_encycl_res, -1, -1);
	}
}
Example #2
0
NEINT32 ne_listensrv_close(ne_listen_handle handle, NEINT32 flag) 
{
	if(handle->sub_id) {
		ne_thsrv_destroy(handle->sub_id, flag) ;
	}

	if(handle->listen_id) {
		ne_thsrv_destroy(handle->listen_id, flag) ;
	}
#ifdef SINGLE_THREAD_MOD
	if(handle->mqc.thid) {
		ne_thsrv_destroy(handle->mqc.thid, flag) ;
	}
#endif	
	if(_IS_UDT_MOD(handle->tcp.type)) {
		udt_close_srv(&handle->udt,flag) ;		
	}
	else {
		ne_tcpsrv_close(&handle->tcp ) ;
	}

	if(handle->tcp.cm_alloctor) {
		ne_cm_allocator_destroy(ne_listensrv_get_cmallocator(handle) , flag) ;
		handle->tcp.cm_alloctor = 0 ;
	}
	ne_swap_list_destroy(&handle->wait_free) ;
#ifdef USER_UPDATE_LIST
	ne_swap_list_destroy(&handle->wait_add) ;
#endif
	cm_destroy(ne_listensrv_get_cmmamager(handle)) ;
	return 0 ;
}
Example #3
0
// if we have a context menu, destroy it
void Hud_Timer::destroy_cm(void)
{
	if (cm_valid(cm_id))
	{
		cm_destroy(cm_id);
		cm_id = CM_INIT_VALUE;
	}
}
Example #4
0
int main()
{
    //daemonize();
    //process signal
    struct sigaction sa;
    sigemptyset(&sa.sa_mask);
    sa.sa_flags = 0;
    sa.sa_handler = handler;
    sigaction(SIGINT, &sa, NULL);

    json_object *jfile = json_object_from_file("config.json");
    if(!jobject_ptr_isvalid(jfile))
    {
        printf("open config.json failed!\n");
        return -1;
    }
    json_object *jlog = json_util_get(jfile,"CONFIG.log");
    if(!jlog)   return -1;
    const char *strlog = json_object_get_string(jlog);

    log_open(&log_,strlog);

    json_object *jlog_level = json_util_get(jfile,"CONFIG.log_level");
    if(jlog_level)
    {
        int log_level = json_object_get_int(jlog_level);
        log_level_set(log_,log_level);
    }

    loga(log_,"starting server!");

    json_object_put(jfile);

    int rv;
    rv = segword_init();
    if(rv < 0)
    {
        loga(log_,"segword_init failed!");
        return -1;
    }

    redis_init();

    rv = cm_start();
    if(rv < 0)
	return -1;

    struct timeval delay;
    while(!stop_daemon)
    {
        delay.tv_sec = 0;
        delay.tv_usec = 100000;

        int rv = select(0,NULL,NULL,NULL,&delay); 
        if(rv == 0)
        {
            continue;
        }
    }
    cm_stop();
    cm_destroy();
    redis_fini();
    segword_fini();

    printf("Normal exit!\n");
    return 0;
}