Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
10b02fe4131fb0262d5e151f6fc07aa0e5744729
[simgrid.git] / tools / simgrid_update_xml_v2_to_v3.pl
1 #! /usr/bin/perl
2
3 # This script updates the simgrid XML file passed as argument (modification in place)
4 # It is built to do the conversion from a XML platfrom version 2 to a version 3
5
6 # Copyright (C) 2006-2010. The SimGrid team. All rights reserved.
7 #
8 # This file is part of the SimGrid project. This is free software:
9 # You can redistribute and/or modify it under the terms of the
10 # GNU LGPL (v2.1) licence.
11
12 use strict;
13
14 my($line);
15 my($command);
16 my($Filecount)=1;
17 my($file);
18 my($filename_old);
19 my($AScount);
20
21 if($#ARGV!=0) {
22     die "Error:  Wrong number of parameters\nUsage:\tperl transform_platform.perl [platform_v2.xml]\n";
23 }
24
25 my($file)=$ARGV[0];
26
27 open FILE, "$file" or die "Error:  Unable to open file: \"$file\".\n$!\n";
28 while(defined($line=<FILE>))
29
30           $AScount=0;
31           if($line =~ /^(.*)<platform version=\"2\"(.*)$/) 
32           {
33                   print "<platform version=\"3\">\n";
34                   print "<AS  id=\"AS$AScount\"  routing=\"Full\">\n";
35                   $AScount++;
36           }
37           else
38           {
39                   if($line =~ /^(.*)<\/platform(.*)$/) 
40                   {
41                         print "<\/AS>\n";
42                         print "$line";
43                   }
44                   else
45                   {
46                         print "$line";
47                   }
48           }
49 }
50 close(FILE);