X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ae943ce975f323351c52acbfa5045ff064fae451..6e4502cc095f2eca8335a00ebc3d626b5c192211:/src/surf/surfxml_parse.c diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 250ee7e448..01d41de6a3 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -92,6 +92,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; @@ -112,6 +114,31 @@ 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); + 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(); + XBT_INFO("ETag_surfxml_include '%s'",A_surfxml_include_file); +} + /* * This function return 0 or 1 if callbacks are empty or not. */ @@ -152,7 +179,9 @@ int surf_parse_no_callbacks(void) 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(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) @@ -213,6 +242,10 @@ void surf_parse_init_callbacks(void) 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) @@ -259,6 +292,8 @@ void surf_parse_free_callbacks(void) xbt_dynar_free(&ETag_surfxml_peer_cb_list); xbt_dynar_free(&STag_surfxml_config_cb_list); xbt_dynar_free(&ETag_surfxml_config_cb_list); + xbt_dynar_free(&STag_surfxml_include_cb_list); + xbt_dynar_free(&ETag_surfxml_include_cb_list); } /* Stag and Etag parse functions */ @@ -269,7 +304,7 @@ void STag_surfxml_platform(void) sscanf(A_surfxml_platform_version, "%lg", &version); - xbt_assert0((version >= 1.0), "******* BIG FAT WARNING *********\n " + 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" @@ -283,7 +318,7 @@ void STag_surfxml_platform(void) "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 " + 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 " @@ -346,15 +381,26 @@ void surf_parse_open(const char *file) } 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); @@ -473,7 +519,7 @@ 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 */ @@ -483,8 +529,20 @@ void parse_properties(void) 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); + 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); + } + 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); + } } /* Trace management functions */ @@ -522,7 +580,7 @@ static void parse_Etag_trace(void) 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, @@ -573,9 +631,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 { @@ -694,6 +751,46 @@ void surf_wsL07_link_create_resource(char *name, properties); } +/** + * + *init new routing model component + */ + +void surf_AS_new(const char *AS_id, const char *AS_mode) +{ + routing_AS_init(AS_id, AS_mode); +} + +void surf_AS_finalize(const char *AS_id) +{ + routing_AS_end(AS_id); +} + +/* + * add host to the network element list + */ +void surf_route_add_host(const char *host_id) +{ + routing_add_host(host_id); +} + +/** + * set route + */ +void surf_routing_add_route(const char *src_id, const char *dst_id, + xbt_dynar_t links_id) +{ + unsigned int i; + const char *link_id; + routing_set_route(src_id, dst_id); + xbt_dynar_foreach(links_id, i, link_id) { + routing_add_link(link_id); + } + + //store the route + routing_store_route(); +} + /** * Add Traces */