Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
move some XML specific code from surf_routing.c to surfxml_parse.c
[simgrid.git] / src / surf / surfxml_parse.c
index 7a7383c..ec8eac6 100644 (file)
@@ -21,7 +21,7 @@ int ETag_surfxml_include_state(void);
 /*
  * Helping functions
  */
-void surf_parse_error(char *msg) {
+void surf_parse_error(const char *msg) {
   xbt_die("Parse error on line %d: %s\n", surf_parse_lineno, msg);
 }
 
@@ -86,10 +86,6 @@ static XBT_INLINE void surfxml_call_cb_functions(xbt_dynar_t);
 YY_BUFFER_STATE surf_input_buffer;
 FILE *surf_file_to_parse = NULL;
 
-static void parse_Stag_trace(void);
-static void parse_Etag_trace(void);
-static void parse_Stag_trace_connect(void);
-
 static void init_randomness(void);
 static void add_randomness(void);
 
@@ -258,10 +254,10 @@ void STag_surfxml_platform(void) {
       "This program is installed automatically with SimGrid, or "
       "available in the tools/ directory of the source archive.");
 
-  sg_platf_open();
+  sg_platf_begin();
 }
 void ETag_surfxml_platform(void){
-  sg_platf_close();
+  sg_platf_end();
 }
 
 void STag_surfxml_host(void){
@@ -317,8 +313,35 @@ void STag_surfxml_cluster(void){
          struct_cluster->bb_lat = surf_parse_get_double(A_surfxml_cluster_bb_lat);
        struct_cluster->router_id = A_surfxml_cluster_router_id;
 
-       struct_cluster->sharing_policy = AX_surfxml_cluster_sharing_policy;
-       struct_cluster->bb_sharing_policy = AX_surfxml_cluster_bb_sharing_policy;
+  switch (AX_surfxml_cluster_sharing_policy) {
+  case A_surfxml_cluster_sharing_policy_SHARED:
+    struct_cluster->sharing_policy = SURF_LINK_SHARED;
+    break;
+  case A_surfxml_cluster_sharing_policy_FULLDUPLEX:
+    struct_cluster->sharing_policy = SURF_LINK_FULLDUPLEX;
+    break;
+  case A_surfxml_cluster_sharing_policy_FATPIPE:
+    struct_cluster->sharing_policy = SURF_LINK_FATPIPE;
+    break;
+  default:
+    surf_parse_error(bprintf
+                     ("Invalid cluster sharing policy for cluster %s",
+                      struct_cluster->id));
+    break;
+  }
+  switch (AX_surfxml_cluster_bb_sharing_policy) {
+  case A_surfxml_cluster_bb_sharing_policy_FATPIPE:
+    struct_cluster->bb_sharing_policy = SURF_LINK_FATPIPE;
+    break;
+  case A_surfxml_cluster_bb_sharing_policy_SHARED:
+    struct_cluster->bb_sharing_policy = SURF_LINK_SHARED;
+    break;
+  default:
+    surf_parse_error(bprintf
+                     ("Invalid bb sharing policy in cluster %s",
+                      struct_cluster->id));
+    break;
+  }
 
        struct_cluster->availability_trace = A_surfxml_cluster_availability_file;
        struct_cluster->state_trace = A_surfxml_cluster_state_file;
@@ -331,7 +354,7 @@ void ETag_surfxml_cluster(void){
 }
 
 void STag_surfxml_peer(void){
-  s_surf_parsing_peer_arg_t peer;
+  s_sg_platf_peer_cbarg_t peer;
   memset(&peer,0,sizeof(peer));
        peer.id = A_surfxml_peer_id;
        peer.power = surf_parse_get_double(A_surfxml_peer_power);
@@ -415,10 +438,10 @@ void STag_surfxml_trace_connect(void){
        surfxml_call_cb_functions(STag_surfxml_trace_connect_cb_list);
 }
 void STag_surfxml_AS(void){
-  sg_platf_new_AS_open(A_surfxml_AS_id,A_surfxml_AS_routing);
+  sg_platf_new_AS_begin(A_surfxml_AS_id,A_surfxml_AS_routing);
 }
 void ETag_surfxml_AS(void){
-  sg_platf_new_AS_close();
+  sg_platf_new_AS_end();
 }
 void STag_surfxml_ASroute(void){
        surfxml_call_cb_functions(STag_surfxml_ASroute_cb_list);
@@ -495,10 +518,8 @@ void surf_parse_open(const char *file)
 
 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);
+  xbt_dynar_free(&surf_input_buffer_stack);
+  xbt_dynar_free(&surf_file_to_parse_stack);
 
   if (surf_file_to_parse) {
     surf_parse__delete_buffer(surf_input_buffer);
@@ -547,7 +568,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) {
-    if (fun) (*fun) ();
+    if (fun) fun();
   }
 }