1 /* Copyright (c) 2012-2018. The SimGrid Team. All rights reserved. */
3 /* This program is free software; you can redistribute it and/or modify it
4 * under the terms of the license (GNU LGPL) which comes with this package. */
6 #include "bittorrent.h"
7 #include "bittorrent-peer.h"
9 #include <simgrid/msg.h>
10 #include <xbt/RngStream.h>
12 #include <stdio.h> /* snprintf */
14 /** Bittorrent example launcher */
15 int main(int argc, char* argv[])
20 MSG_init(&argc, argv);
22 /* Check the arguments */
23 xbt_assert(argc > 2, "Usage: %s platform_file deployment_file", argv[0]);
25 MSG_create_environment(argv[1]);
27 xbt_dynar_t host_list = MSG_hosts_as_dynar();
28 xbt_dynar_foreach (host_list, i, host) {
30 snprintf(descr, sizeof descr, "RngSream<%s>", MSG_host_get_name(host));
31 RngStream stream = RngStream_CreateStream(descr);
32 MSG_host_set_data(host, stream);
35 MSG_function_register("tracker", tracker);
36 MSG_function_register("peer", peer);
38 MSG_launch_application(argv[2]);
42 xbt_dynar_foreach (host_list, i, host) {
43 RngStream stream = (RngStream)MSG_host_get_data(host);
44 RngStream_DeleteStream(&stream);
45 MSG_host_set_data(host, NULL);
47 xbt_dynar_free(&host_list);