Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Update tag include
[simgrid.git] / src / surf / surfxml_parse.c
index 01d41de..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;
@@ -125,6 +127,7 @@ void STag_surfxml_include(void)
   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);
@@ -136,6 +139,7 @@ void ETag_surfxml_include(void)
   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);
 }
 
@@ -454,7 +458,8 @@ void surfxml_del_callback(xbt_dynar_t cb_list, void_f_void_t function)
 
   TRY {
     it = xbt_dynar_search(cb_list,&function);
-  } CATCH(e) {
+  }
+  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");
@@ -524,25 +529,41 @@ void parse_platform_file(const char *file)
 
 /* Prop tag functions */
 
-void parse_properties(void)
-{
-  char *value = NULL;
-  if (!current_property_set)
-    current_property_set = xbt_dict_new();      // Maybe, it should be make a error
-  if(!strcmp(A_surfxml_prop_id,"coordinates")){
-         if(!strcmp(A_surfxml_prop_value,"yes") && !COORD_HOST_LEVEL)
-         {
-                   XBT_INFO("Configuration change: Set '%s' to '%s'", A_surfxml_prop_id, A_surfxml_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);
+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\"");
          }
-         if(strcmp(A_surfxml_prop_value,"yes"))
-                 xbt_die("Setting XML prop coordinates must be \"yes\"");
-  }
-  else{
-         value = xbt_strdup(A_surfxml_prop_value);
-         xbt_dict_set(current_property_set, A_surfxml_prop_id, value, free);
-  }
+       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)
+{
+        parse_properties(prop_id, prop_value);
 }
 
 /* Trace management functions */