#include "xbt/misc.h"
#include "xbt/log.h"
+#include "xbt/str.h"
#include "xbt/dict.h"
#include "surf/surfxml_parse_private.h"
#include "surf/surf_private.h"
"Logging specific to the SURF parsing module");
#undef CLEANUP
-#include "surfxml.c"
+#include "simgrid_dtd.c"
/* Initialize the parsing globals */
int route_action = 0;
DEBUG1("ROUTE: %s", route_name);
if (links != NULL) {
switch (action) {
- case A_surfxml_route_c_multi_action_PREPEND: /* add existing links at the end; route_link_list + links */
+ case A_surfxml_route_action_PREPEND: /* add existing links at the end; route_link_list + links */
xbt_dynar_foreach(links, cpt, value) {
xbt_dynar_push(route_link_list,&value);
}
break;
- case A_surfxml_route_c_multi_action_POSTPEND: /* add existing links in front; links + route_link_list */
+ case A_surfxml_route_action_POSTPEND: /* add existing links in front; links + route_link_list */
xbt_dynar_foreach(route_link_list, cpt, value) {
xbt_dynar_push(links,&value);
}
route_link_list = links;
break;
- case A_surfxml_route_c_multi_action_OVERRIDE:
+ case A_surfxml_route_action_OVERRIDE:
break;
default:break;
}
unsigned int cpt, cpt2, cursor;
char *src_host_name, *dst_host_name, *key, *src, *dst, *val, *key_w, *data_w;
const char* sep="#";
+ xbt_dict_t set;
xbt_dynar_t src_names = NULL, dst_names = NULL, links;
if (!route_multi_elements) return;
+ set = cpu_set;
+ DEBUG1("%d", xbt_dict_length(workstation_set));
+ if (workstation_set != NULL && xbt_dict_length(workstation_set) > 0)
+ set = workstation_set;
+
+
old_buff = surfxml_bufferstack;
/* Get all routes in the exact order they were entered in the platform file */
xbt_dynar_foreach(route_multi_elements, cursor, key) {
src_names = xbt_dynar_new(sizeof(char *), &free_string);
val = xbt_strdup(src);
xbt_dynar_push(src_names, &val);
+ if (strcmp(val,"$*") != 0 && NULL == xbt_dict_get_or_null(set, val))
+ THROW3(unknown_error,0,"(In route:multi (%s -> %s) source %s does not exist (not a set or a host)", src, dst, src);
}
if (dst_names == NULL) {
dst_names = xbt_dynar_new(sizeof(char *), &free_string);
val = xbt_strdup(dst);
+ if (strcmp(val,"$*") != 0 && NULL == xbt_dict_get_or_null(set, val))
+ THROW3(unknown_error,0,"(In route:multi (%s -> %s) destination %s does not exist (not a set or a host)", src, dst, dst);
xbt_dynar_push(dst_names, &val);
}
+
/* Build the routes */
DEBUG2("ADDING MULTI ROUTE: %s -> %s", xbt_dynar_get_as(keys, 0, char*), xbt_dynar_get_as(keys, 1, char*));
xbt_dynar_foreach(src_names, cpt, src_host_name) {
xbt_dynar_foreach(dst_names, cpt2, dst_host_name) {
/* If dst is $* then set this route to have its dst point to all hosts */
- if (strcmp(src_host_name,"$*") != 0 && strcmp(dst_host_name,"$*") == 0){
- xbt_dict_foreach(cpu_set, cursor_w, key_w, data_w) {
+ if (strcmp(src_host_name,"$*") != 0 && strcmp(dst_host_name,"$*") == 0){
+ xbt_dict_foreach(set, cursor_w, key_w, data_w) {
//int n = xbt_dynar_member(src_names, (char*)key_w);
add_multi_links(src, dst, links, src_host_name, key_w);
}
}
/* If src is $* then set this route to have its dst point to all hosts */
if (strcmp(src_host_name,"$*") == 0 && strcmp(dst_host_name,"$*") != 0){
- xbt_dict_foreach(cpu_set, cursor_w, key_w, data_w) {
+ xbt_dict_foreach(set, cursor_w, key_w, data_w) {
// if (!symmetric || (symmetric && !contains(dst_names, key_w)))
add_multi_links(src, dst, links, key_w, dst_host_name);
}