#include <errno.h>
#include <math.h>
#include <stdarg.h> /* va_arg */
+#include <libgen.h>
#include "xbt/misc.h"
#include "xbt/log.h"
char* surf_parsed_filename = NULL; // to locate parse error messages
xbt_dynar_t parsed_link_list = NULL; /* temporary store of current list link of a route */
-extern AS_t current_routing;
/*
* Helping functions
*/
YY_BUFFER_STATE surf_input_buffer;
FILE *surf_file_to_parse = NULL;
-static void init_randomness(void);
-static void add_randomness(void);
-
/*
* Stuff relative to storage
*/
void STag_surfxml_include(void)
{
+ parse_after_config();
XBT_DEBUG("STag_surfxml_include '%s'",A_surfxml_include_file);
xbt_dynar_push(surf_parsed_filename_stack,&surf_parsed_filename); // save old file name
surf_parsed_filename = xbt_strdup(A_surfxml_include_file);
}
else{
if (!current_property_set)
- current_property_set = xbt_dict_new_homogeneous(xbt_free_f); // Maybe, it should raise an error
- xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), NULL);
+ current_property_set = xbt_dict_new(); // Maybe, it should raise an error
+ xbt_dict_set(current_property_set, A_surfxml_prop_id, xbt_strdup(A_surfxml_prop_value), xbt_free_f);
}
}
case A_surfxml_cluster_topology_TORUS:
cluster.topology= SURF_CLUSTER_TORUS ;
break;
+ case A_surfxml_cluster_topology_FAT___TREE:
+ cluster.topology = SURF_CLUSTER_FAT_TREE;
+ break;
default:
surf_parse_error("Invalid cluster topology for cluster %s",
cluster.id);
cluster.availability_trace = A_surfxml_cluster_availability___file;
cluster.state_trace = A_surfxml_cluster_state___file;
sg_platf_new_cluster(&cluster);
-
+
current_property_set = NULL;
}
-void STag_surfxml_cluster(void){
+void STag_surfxml_cluster(void){
+ parse_after_config();
xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
}
void STag_surfxml_cabinet(void){
+ parse_after_config();
s_sg_platf_cabinet_cbarg_t cabinet;
memset(&cabinet,0,sizeof(cabinet));
cabinet.id = A_surfxml_cabinet_id;
}
void STag_surfxml_peer(void){
+ parse_after_config();
s_sg_platf_peer_cbarg_t peer;
memset(&peer,0,sizeof(peer));
peer.id = A_surfxml_peer_id;
}
void STag_surfxml_trace___connect(void){
+ parse_after_config();
s_sg_platf_trace_connect_cbarg_t trace_connect;
memset(&trace_connect,0,sizeof(trace_connect));
}
void STag_surfxml_AS(void){
+ parse_after_config();
AS_TAG = 1;
s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
AS.id = A_surfxml_AS_id;
free(cfg);
}
XBT_DEBUG("End configuration name = %s",A_surfxml_config_id);
+
xbt_dict_free(¤t_property_set);
current_property_set = NULL;
}
void STag_surfxml_random(void){}
void ETag_surfxml_random(void){}
void ETag_surfxml_trace___connect(void){}
-void STag_surfxml_trace(void){}
+void STag_surfxml_trace(void){parse_after_config();}
void ETag_surfxml_router(void){}
void ETag_surfxml_host___link(void){}
void ETag_surfxml_cabinet(void){}
if (!surf_parsed_filename_stack)
surf_parsed_filename_stack = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
surf_parsed_filename = xbt_strdup(file);
+ char *dir = dirname(surf_parsed_filename);
+ xbt_dynar_push(surf_path, &dir);
surf_file_to_parse = surf_fopen(file, "r");
xbt_assert((surf_file_to_parse), "Unable to open \"%s\"\n", file);
xbt_dynar_free(&surf_input_buffer_stack);
xbt_dynar_free(&surf_file_to_parse_stack);
xbt_dynar_free(&surf_parsed_filename_stack);
+ if (surf_parsed_filename) {
+ char *dir = NULL;
+ xbt_dynar_pop(surf_path, dir);
+ free(dir);
+ }
free(surf_parsed_filename);
surf_parsed_filename = NULL;
* With XML parser
*/
-/* Random tag functions */
-
double get_cpu_power(const char *power)
{
double power_scale = 0.0;
e_random_generator_t random_generator;
char *random_id;
-static void init_randomness(void)
-{
- random_id = A_surfxml_random_id;
- random_min = surf_parse_get_double(A_surfxml_random_min);
- random_max = surf_parse_get_double(A_surfxml_random_max);
- random_mean = surf_parse_get_double(A_surfxml_random_mean);
- random_std_deviation = surf_parse_get_double(A_surfxml_random_std___deviation);
- switch (A_surfxml_random_generator) {
- case AU_surfxml_random_generator:
- case A_surfxml_random_generator_NONE:
- random_generator = NONE;
- break;
- case A_surfxml_random_generator_DRAND48:
- random_generator = DRAND48;
- break;
- case A_surfxml_random_generator_RAND:
- random_generator = RAND;
- break;
- case A_surfxml_random_generator_RNGSTREAM:
- random_generator = RNGSTREAM;
- break;
- default:
- surf_parse_error("Invalid random generator");
- break;
- }
-}
-
-static void add_randomness(void)
-{
- /* If needed, additional properties can be added by using the prop tag */
- random_data_t random =
- random_new(random_generator, 0, random_min, random_max, random_mean,
- random_std_deviation);
- xbt_dict_set(random_data_list, random_id, (void *) random,
- &xbt_free_ref);
-}
-
-
xbt_dict_t get_as_router_properties(const char* name)
{
return xbt_lib_get_or_null(as_router_lib, name, ROUTING_PROP_ASR_LEVEL);