+ sg_platf_trace_connect(&trace_connect);
+}
+
+void STag_surfxml_AS(void){
+ AS_TAG = 1;
+ s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
+ AS.id = A_surfxml_AS_id;
+ AS.routing = (int)A_surfxml_AS_routing;
+
+ as_current_property_set = NULL;
+
+ sg_platf_new_AS_begin(&AS);
+}
+void ETag_surfxml_AS(void){
+ if(as_prop_nb){
+ char *name = as_name_tab[as_prop_nb-1];
+ xbt_dict_t dict = as_dict_tab[as_prop_nb-1];
+ as_prop_nb--;
+ XBT_DEBUG("POP prop %p for AS '%s'",dict,name);
+ xbt_lib_set(as_router_lib,
+ name,
+ ROUTING_PROP_ASR_LEVEL,
+ dict);
+ xbt_free(name);
+ }
+ sg_platf_new_AS_end();
+}
+
+extern int _sg_init_status; /* FIXME: find a proper way to export this at some point */
+
+void STag_surfxml_config(void){
+ AS_TAG = 0;
+ xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
+ XBT_DEBUG("START configuration name = %s",A_surfxml_config_id);
+ if (_sg_init_status == 2) {
+ surf_parse_error("All <config> tags must be given before any platform elements (such as <AS>, <host>, <cluster>, <link>, etc).");
+ }
+}
+void ETag_surfxml_config(void){
+ xbt_dict_cursor_t cursor = NULL;
+ char *key;
+ char *elem;
+ char *cfg;
+ xbt_dict_foreach(current_property_set, cursor, key, elem) {
+ cfg = bprintf("%s:%s",key,elem);
+ if(xbt_cfg_is_default_value(_sg_cfg_set, key))
+ xbt_cfg_set_parse(_sg_cfg_set, cfg);
+ else
+ XBT_INFO("The custom configuration '%s' is already defined by user!",key);
+ free(cfg);
+ }
+ XBT_DEBUG("End configuration name = %s",A_surfxml_config_id);
+ xbt_dict_free(¤t_property_set);
+ current_property_set = NULL;
+}
+
+static int argc;
+static char **argv;
+
+void STag_surfxml_process(void){
+ AS_TAG = 0;
+ argc = 1;
+ argv = xbt_new(char *, 1);
+ argv[0] = xbt_strdup(A_surfxml_process_function);
+ xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
+}
+
+void ETag_surfxml_process(void){
+ s_sg_platf_process_cbarg_t process;
+ memset(&process,0,sizeof(process));
+
+ process.argc = argc;
+ process.argv = (const char **)argv;
+ process.properties = current_property_set;
+ process.host = A_surfxml_process_host;
+ process.function = A_surfxml_process_function;
+ process.start_time = surf_parse_get_double(A_surfxml_process_start___time);
+ process.kill_time = surf_parse_get_double(A_surfxml_process_kill___time);
+
+ switch (A_surfxml_process_on___failure) {
+ case AU_surfxml_process_on___failure:
+ case A_surfxml_process_on___failure_DIE:
+ process.on_failure = SURF_PROCESS_ON_FAILURE_DIE;
+ break;
+ case A_surfxml_process_on___failure_RESTART:
+ process.on_failure = SURF_PROCESS_ON_FAILURE_RESTART;
+ break;
+ }
+
+ sg_platf_new_process(&process);
+ current_property_set = NULL;
+}
+
+void STag_surfxml_argument(void){
+ argc++;
+ argv = xbt_realloc(argv, (argc) * sizeof(char *));
+ argv[(argc) - 1] = xbt_strdup(A_surfxml_argument_value);
+}
+
+/* ***************************************** */
+/* TUTORIAL: New TAG */
+void STag_surfxml_gpu(void)
+{
+ XBT_DEBUG("STag_surfxml_gpu");
+}
+void ETag_surfxml_gpu(void)
+{
+ s_sg_platf_gpu_cbarg_t gpu;
+ memset(&gpu,0,sizeof(gpu));
+
+ gpu.name = A_surfxml_gpu_name;
+
+ sg_platf_new_gpu(&gpu);
+}
+/* ***************************************** */
+
+/* nothing to do in those functions */
+void ETag_surfxml_prop(void){}
+void STag_surfxml_random(void){}
+void ETag_surfxml_random(void){}
+void ETag_surfxml_trace___connect(void){}
+void STag_surfxml_trace(void){}
+void ETag_surfxml_router(void){}
+void ETag_surfxml_host___link(void){}
+void ETag_surfxml_cluster(void){}
+void ETag_surfxml_cabinet(void){}
+void ETag_surfxml_peer(void){}
+void STag_surfxml_backbone(void){}
+void ETag_surfxml_link___ctn(void){}
+void ETag_surfxml_argument(void){}
+
+/* Open and Close parse file */
+
+void surf_parse_open(const char *file)
+{
+ static int warned = 0; /* warn only once */
+ if (!file) {
+ if (!warned) {
+ XBT_WARN
+ ("Bypassing the XML parser since surf_parse_open received a NULL pointer. "
+ "If it is not what you want, go fix your code.");
+ warned = 1;
+ }
+ 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);
+
+ if (!surf_parsed_filename_stack)
+ surf_parsed_filename_stack = xbt_dynar_new(sizeof(char *), &xbt_free_ref);
+ surf_parsed_filename = xbt_strdup(file);
+
+ surf_file_to_parse = surf_fopen(file, "r");
+ 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;