X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/6e4502cc095f2eca8335a00ebc3d626b5c192211..8a159c865ab3fc94969f9c4cc727fa4800b7d445:/src/surf/surfxml_parse.c diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 01d41de6a3..92004540e8 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -14,8 +14,12 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_parse, surf, "Logging specific to the SURF parsing module"); #undef CLEANUP +int ETag_surfxml_include_state(void); + #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; @@ -120,69 +124,43 @@ 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); + xbt_dynar_push(surf_file_to_parse_stack, &surf_file_to_parse); //save old filename - surf_file_to_parse = surf_fopen(A_surfxml_include_file, "r"); + surf_file_to_parse = surf_fopen(A_surfxml_include_file, "r"); // read new filename xbt_assert((surf_file_to_parse), "Unable to open \"%s\"\n", A_surfxml_include_file); + xbt_dynar_push(surf_input_buffer_stack,&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) +{ +// XBT_INFO("ETag_surfxml_include '%s'",A_surfxml_include_file); +// fflush(NULL); +// fclose(surf_file_to_parse); +// xbt_dynar_pop(surf_file_to_parse_stack, &surf_file_to_parse); // restore old filename +// surf_parse_pop_buffer_state(); +// xbt_dynar_pop(surf_input_buffer_stack,&surf_input_buffer); +} + +/* + * Return 1 if tag include is opened + */ +int ETag_surfxml_include_state(void) { fflush(NULL); + XBT_INFO("ETag_surfxml_include_state '%s'",A_surfxml_include_file); + if(xbt_dynar_length(surf_input_buffer_stack)!= 0) + return 1; 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); + xbt_dynar_pop(surf_input_buffer_stack,surf_input_buffer); + return 0; } -/* - * 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) { @@ -454,7 +432,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 +503,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 */