Ejemplo n.º 1
0
int main(int argc, char **argv) {
    install_segfault_handler();

    assert(CUE_SUCCESS == CU_initialize_registry());

    add_stomp_parse_suite();
    add_stomp_create_suite();
    topic_add_topic_suite();
    topic_add_list_suite();
    socket_test_suite();
    broker_test_suite();
    distributor_test_suite();
    gc_test_suite();

    CU_basic_run_tests();
    CU_cleanup_registry();

    return 0;
}
Ejemplo n.º 2
0
int mymain(int argc, char** argv)
{
    install_segfault_handler();

    Sint16 piece_size = 16;
    std::string path;
    std::vector<std::string> webseeds;

    po::options_description desc("Usage", 80, 40);
    desc.add_options()
	    ("path,I", po::value<std::string > (&path)->required(), "")
	    ("piece-size,s", po::value<Sint16 > (&piece_size)->default_value(16), "In KiB")
	    ("webseed,w", po::value<std::vector<std::string> > (&webseeds)->required(), "")
	    ("help,h", "produce help message")
	    ;

    po::positional_options_description pos;
    pos.add("path", 1);
    pos.add("webseed", -1);

    po::variables_map vm;
    po::store(po::command_line_parser(argc, argv).options(desc).positional(pos).run(), vm);

    if (vm.count("help")) {
	cout << desc << "\n";
	return 1;
    }

    try {
	po::notify(vm);

	for (int i = 0; i < cubic_coords::NR_OF_FACES; ++i) {

	    std::string face = cubic_coords::face_to_string((cubic_coords::FACE)i);
	    std::string face_path = path + PATHSEPARATOR + face + PATHSEPARATOR;
	    std::string torrent_path = path + PATHSEPARATOR + face + ".torrent";

	    std::cout << face << " face..." << std::flush;

	    lt::file_storage files;
	    lt::add_files(files, face_path);

	    lt::create_torrent torrent(files, piece_size*1024, -1, lt::create_torrent::merkle);
	    for(std::vector<std::string>::iterator it = webseeds.begin(); it!=webseeds.end(); ++it) {
		torrent.add_http_seed(*it);
	    }
	    
	    lt::set_piece_hashes(torrent, path);

	    std::ofstream out(torrent_path, std::ios_base::out | std::ios_base::trunc | std::ios_base::binary);
	    lt::bencode(std::ostream_iterator<char>(out), torrent.generate());
	    if (!out.is_open() || !out.good()) {
		throw file_write_error(torrent_path);
	    }
	    out.close();

	    std::cout << "done" << std::endl;
	}

    } catch (const po::required_option& ex) {
	std::cout << "Missing option: " << ex.get_option_name() << std::endl;
    }

    log::destroy_instance();
    return 0;
}