-static FILE *jed_file;
-
-static void get_hierarchy_list(xbt_dynar_t hier_list, jed_simgrid_container_t container) {
- xbt_assert( container != nullptr );
-
- if( container->parent != nullptr ) {
-
- if( container->parent->container_children == nullptr ) {
- // we are in the last level
- get_hierarchy_list(hier_list, container->parent);
- } else {
- unsigned int i;
- int child_nb = -1;
- jed_simgrid_container_t child_container;
-
- xbt_dynar_foreach(container->parent->container_children, i, child_container) {
- if( child_container == container ) {
- child_nb = i;
- break;
- }
- }
-
- xbt_assert( child_nb > - 1);
- xbt_dynar_insert_at(hier_list, 0, &child_nb);
-
- get_hierarchy_list(hier_list, container->parent);
- }
- } else {
- int top_level = 0;
- xbt_dynar_insert_at(hier_list, 0, &top_level);
- }
-}
-
-static void get_hierarchy_string(jed_simgrid_container_t container, char *outbuf, int bufsize) {
- char buf[STR_BUF_SIZE];
- xbt_dynar_t hier_list;
- unsigned int iter;
- int number;
- unsigned int length;
-
- outbuf[0] = '\0';
- hier_list = xbt_dynar_new(sizeof(int), nullptr);
- get_hierarchy_list(hier_list, container);
-
- length = xbt_dynar_length(hier_list);
-
- xbt_dynar_foreach(hier_list, iter, number) {
- if( iter != length-1 ) {
- snprintf(buf, STR_BUF_SIZE, "%d.", number);
- } else {
- snprintf(buf, STR_BUF_SIZE, "%d", number);
- }
- strncat(outbuf, buf, bufsize-strlen(outbuf));
- }
-
- xbt_dynar_free(&hier_list);
-}
-
-static void print_key_value_dict(xbt_dict_t key_value_dict) {
- xbt_dict_cursor_t cursor=nullptr;
- char *key,*data;
-
- if( key_value_dict != nullptr ) {
- xbt_dict_foreach(key_value_dict,cursor,key,data) {
- fprintf(jed_file, " <prop key=\"%s\" value=\"%s\" />\n",key,data);
- }
- }
-}
-
-static void print_resources(jed_simgrid_container_t resource_parent) {
- unsigned int res_nb;
- unsigned int i;
- char *res_name;
- char resid[STR_BUF_SIZE];
- xbt_assert( resource_parent->resource_list != nullptr );
-
- res_nb = xbt_dynar_length(resource_parent->resource_list);
-
- get_hierarchy_string(resource_parent, resid, STR_BUF_SIZE);
-
- fprintf(jed_file, " <rset id=\"%s\" nb=\"%d\" names=\"", resid, res_nb);
- xbt_dynar_foreach(resource_parent->resource_list, i, res_name) {
- fprintf(jed_file, "%s", res_name);
- if( i != res_nb-1 ) {
- fprintf(jed_file, "|");
- }
- }
- fprintf(jed_file, "\" />\n");
-}
-
-static void print_container(jed_simgrid_container_t container) {
- unsigned int i;
- jed_simgrid_container_t child_container;