예제 #1
0
int main(int argc, char *argv[])
{
	fw_dir_t dir;
	WikiScanFile *wsf;
	struct file_st file[10];
	ffi_arg_t *ff = &m_ffi_arg;

	ffi_init_option(argc, argv);
	strcpy(dir.path, ff->dir);

	wsf = new WikiScanFile();
	int total = wsf->wsf_scan_file(file, sizeof(file) / sizeof(struct file_st), &dir, 1);

	if (total > 1) {
		printf("found many language data in this folder.\n");
		exit(0);
	}

	if (total == 0) {
		printf("Not found any fastwiki idx file and dat files in this folder\n");
		printf("run 'fastwiki-full-index -h'  to see help\n");
		exit(0);
	}

	m_word_hash = new SHash();
	m_word_hash->sh_set_hash_magic(get_best_hash(800*10000));
	m_word_hash->sh_init(10*10000, sizeof(struct wfi_tmp_key), 0);

	if (ff->word_file[0]) {
		if (load_word(ff->word_file) == -1) {
			printf("load file %s error\n", ff->word_file);
			return 1;
		}
	}

	start_create_index(file[0].index_file, file[0].data_file,
			file[0].data_total, ff->tmp, ff->mem_size, "gzip");

	return 0;
}
예제 #2
0
/*
 * a part copy from wiki.cpp
 */
int wiki_init(const char *dir)
{
	for (int i = 0; i < MAX_PTHREAD_TOTAL; i++) {
		m_math_data[i] = (char *)malloc(512*1024);
		m_buf_data[i] = (char *)malloc(MAX_PAGE_LEN);
		m_tmp_data[i] = (char *)malloc(MAX_PAGE_LEN);
		m_convert_data[i] = (char *)malloc(MAX_PAGE_LEN);
	}

	fw_dir_t tmp;
	int lang_total;
	struct file_st file[4];

	strcpy(tmp.path, dir);

	WikiScanFile *wsf = new WikiScanFile();
	lang_total = wsf->wsf_scan_file(file, 4, &tmp, 1);

	if (lang_total == 0) {
		LOG("Not found any data file in folder %s ?\n", dir);
		return -1;
	}

	m_file = &file[0];

	m_wiki_data = new WikiData();
	if (m_wiki_data->wd_init(m_file->data_file, m_file->data_total) == -1) {
		LOG("Not found\n");
		return -1;
	}
	m_wiki_data->wd_get_head(&m_data_head);

	m_wiki_index = new WikiIndex();
	if (m_wiki_index->wi_init(m_file->index_file) == -1) {
		LOG("Not found %s: %s\n", m_file->index_file, strerror(errno));
		return -1;
	}

	m_wiki_index->wi_set_data_func(_check_data_file);

#ifdef WIN32
	m_wiki_math = new WikiMath();
	m_wiki_math->wm_init(m_file->math_file);

	m_wiki_image = new WikiImage();
	m_wiki_image->we_init(m_file->image_file, m_file->image_total);
#endif

	m_wiki_full_text = new WikiFullIndex();
	m_wiki_full_text->wfi_init(m_file->fidx_file, m_file->fidx_file_total);

#ifdef DEBUG
	m_wiki_full_text->wfi_stat();
#endif

	m_httpd_index = new HttpdIndex();
	m_httpd_index->hi_init(m_wiki_full_text);

	m_wiki_socket = new WikiSocket();
	m_wiki_socket->ws_init(my_wait, my_do_url, NULL);
#ifndef WIN32
	m_wiki_socket->ws_start_http_server(-MAX_PTHREAD_TOTAL, false);
#else
	m_wiki_socket->ws_start_http_server(MAX_PTHREAD_TOTAL, false);
#endif

	return 0;
}