Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove commented code from surf_routing_cluster
[simgrid.git] / examples / msg / bittorrent / bittorrent.c
1 /* Copyright (c) 2012. The SimGrid Team.
2  * All rights reserved.                                                     */
3
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. */
6 #include "bittorrent.h"
7 #include "peer.h"
8 #include "tracker.h"
9 #include <msg/msg.h>
10 #include <xbt/RngStream.h>
11
12 /**
13  * Bittorrent example launcher
14  */
15 int main(int argc, char *argv[])
16 {
17   xbt_dynar_t host_list;
18   msg_host_t host;
19   unsigned i;
20
21   MSG_init(&argc, argv);
22
23   /* Check the arguments */
24   if (argc < 3) {
25     printf("Usage: %s platform_file deployment_file \n", argv[0]);
26     return -1;
27   }
28
29   const char *platform_file = argv[1];
30   const char *deployment_file = argv[2];
31
32   MSG_create_environment(platform_file);
33
34   host_list = MSG_hosts_as_dynar();
35   xbt_dynar_foreach(host_list, i, host) {
36     char descr[512];
37     RngStream stream;
38     snprintf(descr, sizeof descr, "RngSream<%s>", MSG_host_get_name(host));
39     stream = RngStream_CreateStream(descr);
40     MSG_host_set_data(host, stream);
41   }
42
43   MSG_function_register("tracker", tracker);
44   MSG_function_register("peer", peer);
45
46   MSG_launch_application(deployment_file);
47
48   MSG_main();
49
50   xbt_dynar_foreach(host_list, i, host) {
51     RngStream stream = MSG_host_get_data(host);
52     RngStream_DeleteStream(&stream);
53   }
54   xbt_dynar_free(&host_list);
55
56   return 0;
57 }