Beispiel #1
0
int run(LOGGER log, struct config config) {
	sqlite3* db = sqlite_service_connect(log, config.dbpath);

	curl_global_init(CURL_GLOBAL_SSL);

	if (!db) {
		return 1;
	}

	if (config.single) {
		QUIT = 1;
	}
	if (prepare_statements(log, db)) {
		return 2;
	}
	spider(log, db, config.hash, config.tree);
	while(!QUIT) {
		begin_transaction(log, db);
		spider(log, db, config.hash, config.tree);
		commit_transaction(log, db);
		sleep(config.sleep);
	}
	finalize_statements(log);
	sqlite_service_close(log, db);

	curl_global_cleanup();
	return 0;
}
Beispiel #2
0
int main(int argc, char **argv)
{
	int ret;
	struct hash_tree tree;

	init_filerec();
	init_hash_tree(&tree);

	if (parse_options(argc, argv)) {
		usage(argv[0]);
		return EINVAL;
	}

	if (init_csum_module(DEFAULT_HASH_STR))
		return ENOMEM;

	ret = dbfile_open(serialize_fname);
	if (ret)
		return ret;

	ret = dbfile_get_config(&disk_blocksize, &disk_hashes, &disk_files,
				&major, &minor);
	if (ret)
		return ret;

	blocksize = disk_blocksize;

	ret = prepare_statements();
	if (ret)
		return ret;

	print_file_info();

	if (num_to_print || print_all_hashes)
		print_by_size();

	if (print_file_list)
		print_filerecs();

	finalize_statements();

	dbfile_close();

	return ret;
}