1 /* Copyright (c) 2012-2017. The SimGrid Team.
2 * All rights reserved. */
4 /* This program is free software; you can redistribute it and/or modify it
5 * under the terms of the license (GNU LGPL) which comes with this package. */
7 #include "bittorrent.h"
8 #include "bittorrent-peer.h"
10 #include <simgrid/msg.h>
11 #include <xbt/RngStream.h>
13 /** Bittorrent example launcher */
14 int main(int argc, char* argv[])
19 MSG_init(&argc, argv);
21 /* Check the arguments */
22 xbt_assert(argc > 2, "Usage: %s platform_file deployment_file", argv[0]);
24 MSG_create_environment(argv[1]);
26 xbt_dynar_t host_list = MSG_hosts_as_dynar();
27 xbt_dynar_foreach (host_list, i, host) {
29 snprintf(descr, sizeof descr, "RngSream<%s>", MSG_host_get_name(host));
30 RngStream stream = RngStream_CreateStream(descr);
31 MSG_host_set_data(host, stream);
34 MSG_function_register("tracker", tracker);
35 MSG_function_register("peer", peer);
37 MSG_launch_application(argv[2]);
41 xbt_dynar_foreach (host_list, i, host) {
42 RngStream stream = (RngStream)MSG_host_get_data(host);
43 RngStream_DeleteStream(&stream);
44 MSG_host_set_data(host, NULL);
46 xbt_dynar_free(&host_list);