Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove all xbt_assert.*(0,FALSE or NULL for xbt_die
[simgrid.git] / tools / gras / stub_generator.c
index 5236452..8e3caa7 100644 (file)
@@ -1,9 +1,7 @@
-/*     $Id$     */
-
 /* gras_stub_generator - creates the main() to use a GRAS program           */
 
-/* Copyright (c) 2003-2007 Martin Quinson, Arnaud Legrand, Malek Cherier.   */
-/* All rights reserved.                                                     */
+/* Copyright (c) 2005, 2006, 2007, 2009, 2010. The SimGrid Team.
+ * All rights reserved.                                                     */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
@@ -29,7 +27,7 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(stubgen, gras, "Stub generator");
 
 
-#ifdef _WIN32
+#ifdef _XBT_WIN32
 #include <windows.h>
 #endif
 
@@ -60,32 +58,37 @@ static s_process_t process;
 
 static void parse_process_init(void)
 {
-  xbt_dict_set(process_function_set, A_surfxml_process_function, NULL, NULL);
+  xbt_dict_set(process_function_set, A_surfxml_process_function, NULL,
+               NULL);
   xbt_dict_set(machine_set, A_surfxml_process_host, NULL, NULL);
   process.argc = 1;
   process.argv = xbt_new(char *, 1);
   process.argv[0] = xbt_strdup(A_surfxml_process_function);
   process.host = strdup(A_surfxml_process_host);
-  /*VERB1("Function: %s",A_surfxml_process_function); */
+  /*XBT_VERB("Function: %s",A_surfxml_process_function); */
 }
 
 static void parse_argument(void)
 {
   process.argc++;
-  process.argv = xbt_realloc(process.argv, (process.argc) * sizeof(char *));
+  process.argv =
+      xbt_realloc(process.argv, (process.argc) * sizeof(char *));
   process.argv[(process.argc) - 1] = xbt_strdup(A_surfxml_argument_value);
 }
 
 static void parse_process_finalize(void)
 {
   xbt_dynar_push(process_list, &process);
-  /*VERB1("Function: %s",process.argv[0]); */
+  /*XBT_VERB("Function: %s",process.argv[0]); */
 }
 
+/*FIXME Defined in surfxml_parse.c*/
+#ifndef WIN32
 void surfxml_add_callback(xbt_dynar_t cb_list, void_f_void_t function)
 {
   xbt_dynar_push(cb_list, &function);
 }
+#endif
 
 
 int main(int argc, char *argv[])
@@ -102,8 +105,8 @@ int main(int argc, char *argv[])
   for (i = 1; i < argc; i++) {
     int need_removal = 0;
     if (!strncmp("--extra-process=", argv[i], strlen("--extra-process="))) {
-      xbt_dict_set(process_function_set, argv[i] + strlen("--extra-process="),
-                   NULL, NULL);
+      xbt_dict_set(process_function_set,
+                   argv[i] + strlen("--extra-process="), NULL, NULL);
       need_removal = 1;
     }
 
@@ -125,17 +128,18 @@ int main(int argc, char *argv[])
 
   project_name = argv[1];
 
-  surf_parse_reset_parser();
-  DEBUG2("%p %p", parse_process_init, &parse_process_init);
+  surf_parse_reset_callbacks();
+  XBT_DEBUG("%p %p", parse_process_init, &parse_process_init);
   surfxml_add_callback(STag_surfxml_process_cb_list, &parse_process_init);
   surfxml_add_callback(ETag_surfxml_argument_cb_list, &parse_argument);
-  surfxml_add_callback(ETag_surfxml_process_cb_list, &parse_process_finalize);
+  surfxml_add_callback(ETag_surfxml_process_cb_list,
+                       &parse_process_finalize);
 
   for (i = 2; i < argc; i++) {
     deployment_file = argv[i];
     surf_parse_open(deployment_file);
     if (surf_parse())
-      xbt_assert1(0, "Parse error in %s", deployment_file);
+      xbt_die(bprintf("Parse error in %s", deployment_file));
 
     surf_parse_close();
   }
@@ -152,7 +156,7 @@ int main(int argc, char *argv[])
      for (cursor=NULL, xbt_dict_cursor_first((process_function_set),&(cursor)) ;
      xbt_dict_cursor_get_or_free(&(cursor),&(key),(void**)(&data));
      xbt_dict_cursor_step(cursor) ) {
-     DEBUG1("Function %s", key);      
+     XBT_DEBUG("Function %s", key);
      }
 
      xbt_dict_dump(process_function_set,print);
@@ -161,7 +165,7 @@ int main(int argc, char *argv[])
   generate_sim(project_name);
   generate_rl(project_name);
   generate_makefile_local(project_name, deployment_file);
-#ifdef _WIN32
+#ifdef __BORLANDC__
   generate_borland_simulation_project(project_name);
   generate_borland_real_life_project(project_name);
   generate_simulation_dsp_file(project_name);