Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update tag include
[simgrid.git] / src / surf / surfxml_parse.c
index e73a76c..240b07a 100644 (file)
@@ -16,6 +16,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_parse, surf,
 #undef CLEANUP
 #include "simgrid_dtd.c"
 
+char *platform_filename;
+
 /* Initialize the parsing globals */
 xbt_dict_t traces_set_list = NULL;
 xbt_dict_t trace_connect_list_host_avail = NULL;
@@ -76,6 +78,8 @@ xbt_dynar_t STag_surfxml_prop_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_prop_cb_list = NULL;
 xbt_dynar_t STag_surfxml_cluster_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_cluster_cb_list = NULL;
+xbt_dynar_t STag_surfxml_peer_cb_list = NULL;
+xbt_dynar_t ETag_surfxml_peer_cb_list = NULL;
 xbt_dynar_t STag_surfxml_trace_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_trace_cb_list = NULL;
 xbt_dynar_t STag_surfxml_trace_connect_cb_list = NULL;
@@ -90,6 +94,8 @@ xbt_dynar_t STag_surfxml_bypassRoute_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_bypassRoute_cb_list = NULL;
 xbt_dynar_t STag_surfxml_config_cb_list = NULL;
 xbt_dynar_t ETag_surfxml_config_cb_list = NULL;
+xbt_dynar_t STag_surfxml_include_cb_list = NULL;
+xbt_dynar_t ETag_surfxml_include_cb_list = NULL;
 
 /* store the current property set for any tag */
 xbt_dict_t current_property_set = NULL;
@@ -110,6 +116,148 @@ static void parse_Stag_trace_connect(void);
 static void init_randomness(void);
 static void add_randomness(void);
 
+static xbt_dynar_t surf_input_buffer_stack = NULL;
+static xbt_dynar_t surf_file_to_parse_stack = NULL;
+
+void STag_surfxml_include(void)
+{
+  XBT_INFO("STag_surfxml_include '%s'",A_surfxml_include_file);
+  xbt_dynar_push(surf_file_to_parse_stack, &surf_file_to_parse);
+
+  surf_file_to_parse = surf_fopen(A_surfxml_include_file, "r");
+  xbt_assert((surf_file_to_parse), "Unable to open \"%s\"\n",
+              A_surfxml_include_file);
+  xbt_dynar_push_as(surf_input_buffer_stack,YY_BUFFER_STATE,surf_input_buffer);
+  surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
+  surf_parse_push_buffer_state(surf_input_buffer);
+  fflush(NULL);
+}
+
+void ETag_surfxml_include(void)
+{
+  fflush(NULL);
+  fclose(surf_file_to_parse);
+  xbt_dynar_pop(surf_file_to_parse_stack, &surf_file_to_parse);
+  surf_parse_pop_buffer_state();
+  surf_input_buffer = xbt_dynar_pop_as(surf_input_buffer_stack,YY_BUFFER_STATE);
+  XBT_INFO("ETag_surfxml_include '%s'",A_surfxml_include_file);
+}
+
+/*
+ * This function return 0 or 1 if callbacks are empty or not.
+ */
+int surf_parse_no_callbacks(void)
+{
+       return  xbt_dynar_is_empty(STag_surfxml_platform_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_platform_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_host_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_host_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_router_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_router_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_link_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_link_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_route_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_route_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_link_ctn_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_link_ctn_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_process_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_process_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_argument_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_argument_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_prop_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_prop_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_trace_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_trace_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_trace_connect_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_trace_connect_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_random_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_random_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_AS_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_AS_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_ASroute_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_ASroute_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_bypassRoute_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_bypassRoute_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_cluster_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_cluster_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_peer_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_peer_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_config_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_config_cb_list) &&
+         xbt_dynar_is_empty(STag_surfxml_include_cb_list) &&
+         xbt_dynar_is_empty(ETag_surfxml_include_cb_list);
+}
+
+void surf_parse_init_callbacks(void)
+{
+         STag_surfxml_platform_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_platform_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_link_ctn_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_link_ctn_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_process_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_process_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_argument_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_argument_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_trace_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_trace_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_trace_connect_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_trace_connect_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_AS_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_AS_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_ASroute_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_ASroute_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_bypassRoute_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_bypassRoute_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_cluster_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_cluster_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_peer_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_peer_cb_list =
+             xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_config_cb_list =
+                         xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_config_cb_list =
+                         xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         STag_surfxml_include_cb_list =
+                         xbt_dynar_new(sizeof(void_f_void_t), NULL);
+         ETag_surfxml_include_cb_list =
+                         xbt_dynar_new(sizeof(void_f_void_t), NULL);
+}
+
+void surf_parse_reset_callbacks(void)
+{
+       surf_parse_free_callbacks();
+       surf_parse_init_callbacks();
+}
+
 void surf_parse_free_callbacks(void)
 {
   xbt_dynar_free(&STag_surfxml_platform_cb_list);
@@ -144,63 +292,12 @@ void surf_parse_free_callbacks(void)
   xbt_dynar_free(&ETag_surfxml_bypassRoute_cb_list);
   xbt_dynar_free(&STag_surfxml_cluster_cb_list);
   xbt_dynar_free(&ETag_surfxml_cluster_cb_list);
+  xbt_dynar_free(&STag_surfxml_peer_cb_list);
+  xbt_dynar_free(&ETag_surfxml_peer_cb_list);
   xbt_dynar_free(&STag_surfxml_config_cb_list);
   xbt_dynar_free(&ETag_surfxml_config_cb_list);
-}
-
-void surf_parse_reset_parser(void)
-{
-  surf_parse_free_callbacks();
-  STag_surfxml_platform_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_platform_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_link_ctn_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_link_ctn_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_process_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_process_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_argument_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_argument_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_trace_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_trace_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_trace_connect_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_trace_connect_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_AS_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_AS_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_ASroute_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_ASroute_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_bypassRoute_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_bypassRoute_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_cluster_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_cluster_cb_list =
-      xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  STag_surfxml_config_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  ETag_surfxml_config_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
+  xbt_dynar_free(&STag_surfxml_include_cb_list);
+  xbt_dynar_free(&ETag_surfxml_include_cb_list);
 }
 
 /* Stag and Etag parse functions */
@@ -211,23 +308,25 @@ void STag_surfxml_platform(void)
 
   sscanf(A_surfxml_platform_version, "%lg", &version);
 
-  xbt_assert0((version >= 1.0), "******* BIG FAT WARNING *********\n "
-              "You're using an ancient XML file. "
-              "Since SimGrid 3.1, units are Bytes, Flops, and seconds "
-              "instead of MBytes, MFlops and seconds. "
-              "A script (surfxml_update.pl) to help you convert your old "
-              "platform files "
-              "is available in the contrib/platform_generation directory "
-              "of the simgrid repository. Please check also out the "
-              "SURF section of the ChangeLog for the 3.1 version. "
-              "Last, do not forget to also update your values for "
-              "the calls to MSG_task_create (if any).");
-  xbt_assert0((version >= 3.0), "******* BIG FAT WARNING *********\n "
-              "You're using an old XML file. "
-              "A script (surfxml_update.pl) to help you convert your old "
-              "platform files "
-              "is available in the contrib/platform_generation directory "
-              "of the simgrid repository.");
+  xbt_assert((version >= 1.0), "******* BIG FAT WARNING *********\n "
+      "You're using an ancient XML file.\n"
+      "Since SimGrid 3.1, units are Bytes, Flops, and seconds "
+      "instead of MBytes, MFlops and seconds.\n"
+
+      "Use simgrid_update_xml to update your file automatically. "
+      "This program is installed automatically with SimGrid, or "
+      "available in the tools/ directory of the source archive.\n"
+
+      "Please check also out the SURF section of the ChangeLog for "
+      "the 3.1 version for more information. \n"
+
+      "Last, do not forget to also update your values for "
+      "the calls to MSG_task_create (if any).");
+  xbt_assert((version >= 3.0), "******* BIG FAT WARNING *********\n "
+      "You're using an old XML file.\n"
+      "Use simgrid_update_xml to update your file automatically. "
+      "This program is installed automatically with SimGrid, or "
+      "available in the tools/ directory of the source archive.");
 
   surfxml_call_cb_functions(STag_surfxml_platform_cb_list);
 
@@ -268,6 +367,8 @@ parse_method(S, bypassRoute);
 parse_method(E, bypassRoute);
 parse_method(S, cluster);
 parse_method(E, cluster);
+parse_method(S, peer);
+parse_method(E, peer);
 parse_method(S, config);
 parse_method(E, config);
 
@@ -278,21 +379,32 @@ void surf_parse_open(const char *file)
   static int warned = 0;        /* warn only once */
   if (!file) {
     if (!warned) {
-      WARN0
+      XBT_WARN
           ("Bypassing the XML parser since surf_parse_open received a NULL pointer. If it is not what you want, go fix your code.");
       warned = 1;
     }
     return;
   }
+
+  if (!surf_input_buffer_stack)
+       surf_input_buffer_stack = xbt_dynar_new(sizeof(YY_BUFFER_STATE), NULL);
+  if (!surf_file_to_parse_stack)
+       surf_file_to_parse_stack = xbt_dynar_new(sizeof(FILE *), NULL);
+
   surf_file_to_parse = surf_fopen(file, "r");
-  xbt_assert1((surf_file_to_parse), "Unable to open \"%s\"\n", file);
-  surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, 10);
+  xbt_assert((surf_file_to_parse), "Unable to open \"%s\"\n", file);
+  surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, YY_BUF_SIZE);
   surf_parse__switch_to_buffer(surf_input_buffer);
   surf_parse_lineno = 1;
 }
 
 void surf_parse_close(void)
 {
+  if (surf_input_buffer_stack)
+       xbt_dynar_free(&surf_input_buffer_stack);
+  if (surf_file_to_parse_stack)
+       xbt_dynar_free(&surf_file_to_parse_stack);
+
   if (surf_file_to_parse) {
     surf_parse__delete_buffer(surf_input_buffer);
     fclose(surf_file_to_parse);
@@ -338,17 +450,24 @@ void surfxml_add_callback(xbt_dynar_t cb_list, void_f_void_t function)
   xbt_dynar_push(cb_list, &function);
 }
 
-void surfxml_del_callback(xbt_dynar_t * p_cb_list, void_f_void_t function)
+void surfxml_del_callback(xbt_dynar_t cb_list, void_f_void_t function)
 {
-  xbt_dynar_t new_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-  unsigned int it;
-  void_f_void_t func;
-  xbt_dynar_foreach(*p_cb_list, it, func) {
-    if (func != function)
-      xbt_dynar_push(new_cb_list, &func);
+  xbt_ex_t e;
+  unsigned int it=0;
+  void_f_void_t null_f=NULL;
+
+  TRY {
+    it = xbt_dynar_search(cb_list,&function);
   }
-  xbt_dynar_free(p_cb_list);
-  *p_cb_list = new_cb_list;
+  CATCH(e) {
+    if (e.category == not_found_error) {
+      xbt_ex_free(e);
+      xbt_die("Trying to remove a callback that is not here! This should not happen");
+    }
+    RETHROW;
+  }
+
+  xbt_dynar_replace(cb_list, it,&null_f);
 }
 
 static XBT_INLINE void surfxml_call_cb_functions(xbt_dynar_t cb_list)
@@ -356,7 +475,7 @@ static XBT_INLINE void surfxml_call_cb_functions(xbt_dynar_t cb_list)
   unsigned int iterator;
   void_f_void_t fun;
   xbt_dynar_foreach(cb_list, iterator, fun) {
-    (*fun) ();
+    if (fun) (*fun) ();
   }
 }
 
@@ -367,7 +486,6 @@ static void init_data(void)
   if (!surfxml_bufferstack_stack)
     surfxml_bufferstack_stack = xbt_dynar_new(sizeof(char *), NULL);
 
-  random_data_list = xbt_dict_new();
   traces_set_list = xbt_dict_new();
   trace_connect_list_host_avail = xbt_dict_new();
   trace_connect_list_power = xbt_dict_new();
@@ -375,13 +493,10 @@ static void init_data(void)
   trace_connect_list_bandwidth = xbt_dict_new();
   trace_connect_list_latency = xbt_dict_new();
 
-  surfxml_add_callback(STag_surfxml_random_cb_list, &init_randomness);
-  surfxml_add_callback(ETag_surfxml_random_cb_list, &add_randomness);
-  surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties);
   surfxml_add_callback(STag_surfxml_trace_cb_list, &parse_Stag_trace);
   surfxml_add_callback(ETag_surfxml_trace_cb_list, &parse_Etag_trace);
   surfxml_add_callback(STag_surfxml_trace_connect_cb_list,
-                       &parse_Stag_trace_connect);
+                                          &parse_Stag_trace_connect);
 }
 
 static void free_data(void)
@@ -397,7 +512,6 @@ static void free_data(void)
 }
 
 /* Here start parse */
-
 void parse_platform_file(const char *file)
 {
   int parse_status;
@@ -410,30 +524,58 @@ void parse_platform_file(const char *file)
   parse_status = surf_parse();
   free_data();
   surf_parse_close();
-  xbt_assert1(!parse_status, "Parse error in %s", file);
+  xbt_assert(!parse_status, "Parse error in %s", file);
 }
 
 /* Prop tag functions */
 
-void parse_properties(void)
+void parse_properties(const char* prop_id, const char* prop_value)
+{
+    char *value = NULL;
+       if (!current_property_set)
+           current_property_set = xbt_dict_new();      // Maybe, it should be make a error
+       if(!strcmp(prop_id,"coordinates")){
+               if(!strcmp(prop_value,"yes") && !COORD_HOST_LEVEL)
+                 {
+                           XBT_INFO("Configuration change: Set '%s' to '%s'", prop_id, prop_value);
+                               COORD_HOST_LEVEL = xbt_lib_add_level(host_lib,xbt_dynar_free_voidp);
+                               COORD_ASR_LEVEL  = xbt_lib_add_level(as_router_lib,xbt_dynar_free_voidp);
+                 }
+               if(strcmp(A_surfxml_prop_value,"yes"))
+                         xbt_die("Setting XML prop coordinates must be \"yes\"");
+         }
+       else{
+                 value = xbt_strdup(prop_value);
+                 xbt_dict_set(current_property_set, prop_id, value, free);
+        }
+}
+
+/**
+ * With XML parser
+ */
+void parse_properties_XML(void)
+{
+  parse_properties(A_surfxml_prop_id, A_surfxml_prop_value);
+}
+
+/*
+ * With lua console
+ */
+void parse_properties_lua(const char* prop_id, const char* prop_value)
 {
-  char *value = NULL;
-  if (!current_property_set)
-    current_property_set = xbt_dict_new();      // Maybe, it should be make a error
-  value = xbt_strdup(A_surfxml_prop_value);
-  xbt_dict_set(current_property_set, A_surfxml_prop_id, value, free);
+        parse_properties(prop_id, prop_value);
 }
 
 /* Trace management functions */
 
 static double trace_periodicity = -1.0;
 static char *trace_file = NULL;
-static char *trace_id;
+static char *trace_id = NULL;
 
 static void parse_Stag_trace(void)
 {
-  trace_id = strdup(A_surfxml_trace_id);
-  trace_file = strdup(A_surfxml_trace_file);
+  trace_id = xbt_strdup(A_surfxml_trace_id);
+  trace_file = xbt_strdup(A_surfxml_trace_file);
   surf_parse_get_double(&trace_periodicity, A_surfxml_trace_periodicity);
 }
 
@@ -451,11 +593,15 @@ static void parse_Etag_trace(void)
                                      trace_periodicity);
   }
   xbt_dict_set(traces_set_list, trace_id, (void *) trace, NULL);
+  xbt_free(trace_file);
+  trace_file = NULL;
+  xbt_free(trace_id);
+  trace_id = NULL;
 }
 
 static void parse_Stag_trace_connect(void)
 {
-  xbt_assert2(xbt_dict_get_or_null
+  xbt_assert(xbt_dict_get_or_null
               (traces_set_list, A_surfxml_trace_connect_trace),
               "Cannot connect trace %s to %s: trace unknown",
               A_surfxml_trace_connect_trace,
@@ -486,9 +632,8 @@ static void parse_Stag_trace_connect(void)
                  xbt_strdup(A_surfxml_trace_connect_element), free);
     break;
   default:
-    xbt_die(bprintf("Cannot connect trace %s to %s: kind of trace unknown",
-                    A_surfxml_trace_connect_trace,
-                    A_surfxml_trace_connect_element));
+    xbt_die("Cannot connect trace %s to %s: kind of trace unknown",
+            A_surfxml_trace_connect_trace, A_surfxml_trace_connect_element);
   }
 }
 
@@ -507,9 +652,8 @@ double get_cpu_power(const char *power)
       generator = xbt_malloc(q - (p + 6) + 1);
       memcpy(generator, p + 6, q - (p + 6));
       generator[q - (p + 6)] = '\0';
-      xbt_assert1((random =
-                   xbt_dict_get_or_null(random_data_list, generator)),
-                  "Random generator %s undefined", generator);
+      random = xbt_dict_get_or_null(random_data_list, generator);
+      xbt_assert(random, "Random generator %s undefined", generator);
       power_scale = random_generate(random);
     }
   } else {
@@ -548,7 +692,7 @@ static void add_randomness(void)
  */
 void surf_host_create_resource(char *name, double power_peak,
                                double power_scale,
-                               tmgr_trace_t power_trace,
+                               tmgr_trace_t power_trace, int core,
                                e_surf_resource_state_t state_initial,
                                tmgr_trace_t state_trace,
                                xbt_dict_t cpu_properties)
@@ -556,6 +700,7 @@ void surf_host_create_resource(char *name, double power_peak,
   return surf_cpu_model->extension.cpu.create_resource(name, power_peak,
                                                        power_scale,
                                                        power_trace,
+                                                       core,
                                                        state_initial,
                                                        state_trace,
                                                        cpu_properties);