Exemplo n.º 1
0
int WikiManage::wiki_init()
{
	struct timeval now;

	if (LOG_INIT(LOG_MIN, BASE_DIR, "fastwiki.log") == -1)
		LOG_INIT(LOG_MIN, "/data/local/tmp", "fastwiki.log");

	gettimeofday(&now, NULL);
	srand(now.tv_sec | now.tv_usec);

	memset(&m_search_buf, 0, sizeof(m_search_buf));
	m_search_buf.page_idx = (int *)calloc(MAX_PAGE_IDX_TOTAL, sizeof(int));

	m_buf = (char *)malloc(_MAX_ONE_PAGE_SIZE + 1024);
	m_trans_buf = (char *)malloc(MAX_TRANS_BUF_SIZE);

	m_curr_content = (char *)malloc(_MAX_ONE_PAGE_SIZE + 1024);
	m_curr_page = (char *)malloc(_MAX_ONE_PAGE_SIZE + 1024);

	memset(&m_all_lang[0], 0, sizeof(struct one_lang));

	m_match_title = (wiki_title_t *)calloc(MAX_MATCH_TITLE_TOTAL + 1, sizeof(wiki_title_t));
	memset(m_match_title, 0, (MAX_MATCH_TITLE_TOTAL + 1) * sizeof(wiki_title_t));

	for (int i = 0; i < MAX_PTHREAD_TOTAL; i++) {
		m_math_data[i] = (char *)malloc(_MAX_MATH_SIZE + 1024);
	}

	m_wiki_config = new WikiConfig();
	m_wiki_config->wc_init();

	m_wiki_socket = new WikiSocket();
	m_wiki_socket->ws_init(NULL, _wiki_do_url, (void *)this);

	pthread_t id;
	pthread_create(&id, NULL, wiki_manage_start_socket_thread, m_wiki_socket);
	usleep(10000);

	m_wiki_history = new WikiHistory();
	m_wiki_history->wh_init();
	m_history = (struct tmp_history *)calloc(MAX_TMP_HISTORY_TOTAL + 10, sizeof(struct tmp_history));

	m_wiki_favorite = new WikiFavorite();
	m_wiki_favorite->wf_init();
	m_favorite = (struct tmp_favorite *)calloc(MAX_TMP_FAVORITE_TOTAL + 10, sizeof(struct tmp_favorite));

	m_wiki_audio = new WikiAudio();
	m_wiki_audio->wa_init(m_wiki_config->wc_get_audio_path());

	INIT_CURR_LANG();

	pthread_mutex_init(&m_mutex, NULL);

	if (wiki_lang_init() == -1)
		return -1;

	m_init_flag = 1;

	return 0;
}
Exemplo n.º 2
0
int WikiManage::wiki_reinit()
{
	struct one_lang *p;
	
	m_init_flag = 0;

	for (int i = 0; i < m_all_lang_total; i++) {
		p = &m_all_lang[i];
		if (p->flag == 0)
			continue;

		if (p->data)
			delete p->data;

		if (p->index)
			delete p->index;

		if (p->math)
			delete p->math;

		if (p->image)
			delete p->image;
	}

	INIT_CURR_LANG();

	m_wiki_config->wc_init();
	if (wiki_lang_init() == -1)
		return -1;

	m_init_flag = 1;

	return 0;
}
Exemplo n.º 3
0
int WikiManage::wiki_scan_sdcard()
{
	m_wiki_config->wc_scan_all();
	wiki_lang_init();

	if (m_select_lang_total > 0)
		m_init_flag = 1;

	return 0;
}
Exemplo n.º 4
0
int WikiManage::wiki_scan_data_path()
{
	memset(m_search_buf.key, 0, sizeof(m_search_buf.key));

	m_wiki_config->wc_scan_all();
	wiki_lang_init();

	if (m_select_lang_total > 0)
		m_init_flag = 1;

	return 0;
}
Exemplo n.º 5
0
int WikiManage::wiki_init()
{

	struct timeval now;

	gettimeofday(&now, NULL);
	srand(now.tv_sec | now.tv_usec);

	m_buf = (char *)malloc(32*1024);
	m_trans_buf = (char *)malloc(MAX_TRANS_BUF_SIZE);

	m_curr_content = (char *)malloc(2*1024*1024);
	m_curr_page = (char *)malloc(2*1024*1024);

	memset(&m_all_lang[0], 0, sizeof(struct one_lang));

	m_match_title = (wiki_title_t *)calloc(MAX_MATCH_TITLE_TOTAL + 1, sizeof(wiki_title_t));
	memset(m_match_title, 0, (MAX_MATCH_TITLE_TOTAL + 1) * sizeof(wiki_title_t));

	for (int i = 0; i < MAX_PTHREAD_TOTAL; i++) {
		m_math_data[i] = (char *)malloc(512*1024);
	}

	m_wiki_config = new WikiConfig();
	m_wiki_config->wc_init();

	m_wiki_socket = new WikiSocket();
	m_wiki_socket->ws_init(NULL, _wiki_do_url, (void *)this);

	pthread_t id;
	pthread_create(&id, NULL, wiki_manage_start_socket_thread, m_wiki_socket);
	usleep(10000);

	m_wiki_history = new WikiHistory();
	m_wiki_history->wh_init();
	m_history = (struct tmp_history *)calloc(MAX_TMP_HISTORY_TOTAL + 10, sizeof(struct tmp_history));

	m_wiki_favorite = new WikiFavorite();
	m_wiki_favorite->wf_init();
	m_favorite = (struct tmp_favorite *)calloc(MAX_TMP_FAVORITE_TOTAL + 10, sizeof(struct tmp_favorite));

	INIT_CURR_LANG();

	pthread_mutex_init(&m_mutex, NULL);

	if (wiki_lang_init() == -1)
		return -1;

	m_init_flag = 1;

	return 0;
}