X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e7f673d15e75da1cf81d9d02186fbc936a21ffad..8c6c3df11271d62be278361a12113ee9a4849b95:/src/surf/surfxml_parseplatf.c diff --git a/src/surf/surfxml_parseplatf.c b/src/surf/surfxml_parseplatf.c index 23865b4a37..1a5965d43c 100644 --- a/src/surf/surfxml_parseplatf.c +++ b/src/surf/surfxml_parseplatf.c @@ -8,6 +8,7 @@ #include "xbt/log.h" #include "xbt/str.h" #include "xbt/dict.h" +#include "simgrid/platf.h" #include "surf/surfxml_parse_private.h" #include "surf/surf_private.h" @@ -52,12 +53,7 @@ void surfxml_bufferstack_pop(int new) * Pass arguments to parsing callback as structures to save some time (and allow callbacks to ignore some) */ -hostSG_t struct_host = NULL; -router_t struct_router = NULL; -cluster_t struct_cluster = NULL; -peer_t struct_peer = NULL; -link_t struct_lnk = NULL; - +surf_parsing_cluster_arg_t struct_cluster = NULL; /* * Trace related stuff @@ -76,10 +72,9 @@ static char *trace_id = NULL; static void parse_Stag_trace(void) { - surf_parse_models_setup(); /* ensure that the models are created after the last tag. See comment in simgrid.dtd */ 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); + trace_periodicity = surf_parse_get_double(A_surfxml_trace_periodicity); } static void parse_Etag_trace(void) @@ -104,8 +99,6 @@ static void parse_Etag_trace(void) static void parse_Stag_trace_connect(void) { - surf_parse_models_setup(); /* ensure that the models are created after the last tag. See comment in simgrid.dtd */ - xbt_assert(xbt_dict_get_or_null (traces_set_list, A_surfxml_trace_connect_trace), "Cannot connect trace %s to %s: trace unknown", @@ -143,11 +136,24 @@ static void parse_Stag_trace_connect(void) } } +/* This function acts as a main in the parsing area. */ +void parse_platform_file(const char *file) +{ + int parse_status; + + surf_parse_reset_callbacks(); -/* Init and free parse data */ + /* Register classical callbacks */ + surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties_XML); + routing_register_callbacks(); -static void init_data(void) -{ + /* init the flex parser */ + surfxml_buffer_stack_stack_ptr = 1; + surfxml_buffer_stack_stack[0] = 0; + + surf_parse_open(file); + + /* Init my data */ if (!surfxml_bufferstack_stack) surfxml_bufferstack_stack = xbt_dynar_new(sizeof(char *), NULL); @@ -162,10 +168,16 @@ static void init_data(void) surfxml_add_callback(ETag_surfxml_trace_cb_list, &parse_Etag_trace); surfxml_add_callback(STag_surfxml_trace_connect_cb_list, &parse_Stag_trace_connect); -} -static void free_data(void) -{ + /* we care about the ASes while parsing the platf. Incredible, isnt it? */ + sg_platf_AS_end_add_cb(routing_AS_end); + sg_platf_AS_begin_add_cb(routing_AS_begin); + + + /* Do the actual parsing */ + parse_status = surf_parse(); + + /* Free my data */ xbt_dict_free(&trace_connect_list_host_avail); xbt_dict_free(&trace_connect_list_power); xbt_dict_free(&trace_connect_list_link_avail); @@ -174,27 +186,10 @@ static void free_data(void) xbt_dict_free(&traces_set_list); xbt_dict_free(&random_data_list); xbt_dynar_free(&surfxml_bufferstack_stack); -} - -/* This function acts as a main in the parsing area. */ -void parse_platform_file(const char *file) -{ - int parse_status; - surf_parse_reset_callbacks(); - surf_parse_add_callback_config(); - - surfxml_buffer_stack_stack_ptr = 1; - surfxml_buffer_stack_stack[0] = 0; - - surf_parse_open(file); - init_data(); - parse_status = surf_parse(); - free_data(); + /* Stop the flex parser */ surf_parse_close(); if (parse_status) xbt_die("Parse error in %s", file); - - surf_config_models_create_elms(); }