Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of scm.gforge.inria.fr:/gitroot/simgrid/simgrid
[simgrid.git] / src / xbt / graphxml_parse.c
index 1c9a31c..4f7605d 100644 (file)
@@ -1,6 +1,5 @@
-/*     $Id$     */
-
-/* Copyright (c) 2006 Arnaud Legrand. All rights reserved.                  */
+/* Copyright (c) 2006-2011, 2013-2014. 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. */
 #include "xbt/dynar.h"
 #include "xbt/graphxml_parse.h"
 
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(graphxml_parse, xbt ,"Logging specific to the graphxml parsing  module");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(graphxml_parse, xbt,
+                                "Logging specific to the graphxml parsing  module");
 
 #undef CLEANUP
 #include "graphxml.c"
 
-static xbt_dynar_t xbt_graph_input_buffer_stack=NULL;
-static xbt_dynar_t xbt_graph_file_to_parse_stack=NULL;
+static xbt_dynar_t xbt_graph_input_buffer_stack = NULL;
+static xbt_dynar_t xbt_graph_file_to_parse_stack = NULL;
 
 static void nil_function(void)
 {
   return;
 }
 
-void_pf_void_t STag_graphxml_graph_fun = nil_function;
-void_pf_void_t ETag_graphxml_graph_fun = nil_function;
-void_pf_void_t STag_graphxml_node_fun = nil_function;
-void_pf_void_t ETag_graphxml_node_fun = nil_function;
-void_pf_void_t STag_graphxml_edge_fun = nil_function;
-void_pf_void_t ETag_graphxml_edge_fun = nil_function;
+void_f_void_t STag_graphxml_graph_fun = nil_function;
+void_f_void_t ETag_graphxml_graph_fun = nil_function;
+void_f_void_t STag_graphxml_node_fun = nil_function;
+void_f_void_t ETag_graphxml_node_fun = nil_function;
+void_f_void_t STag_graphxml_edge_fun = nil_function;
+void_f_void_t ETag_graphxml_edge_fun = nil_function;
 
 YY_BUFFER_STATE xbt_graph_input_buffer;
 FILE *xbt_graph_file_to_parse;
@@ -80,30 +80,33 @@ void ETag_graphxml_edge(void)
 
 
 
-void  xbt_graph_parse_open(const char *file) {
-  if(!file) {
-    WARN0("I hope you know what you're doing... you just gave me a NULL pointer!");
+void xbt_graph_parse_open(const char *file)
+{
+  if (!file) {
+    XBT_WARN
+        ("I hope you know what you're doing... you just gave me a NULL pointer!");
     return;
   }
-  if(!xbt_graph_input_buffer_stack) 
-    xbt_graph_input_buffer_stack = xbt_dynar_new(sizeof(YY_BUFFER_STATE),NULL);
-  if(!xbt_graph_file_to_parse_stack) 
-    xbt_graph_file_to_parse_stack = xbt_dynar_new(sizeof(FILE*),NULL);
-
-  xbt_graph_file_to_parse = fopen(file,"r");  /* FIXME should use something like surf_fopen */
-  xbt_assert1((xbt_graph_file_to_parse), "Unable to open \"%s\"\n",file);
-  xbt_graph_input_buffer = xbt_graph_parse__create_buffer( xbt_graph_file_to_parse, 10);
+  if (!xbt_graph_input_buffer_stack)
+    xbt_graph_input_buffer_stack =
+        xbt_dynar_new(sizeof(YY_BUFFER_STATE), NULL);
+  if (!xbt_graph_file_to_parse_stack)
+    xbt_graph_file_to_parse_stack = xbt_dynar_new(sizeof(FILE *), NULL);
+
+  xbt_graph_file_to_parse = fopen(file, "r");   /* FIXME should use something like surf_fopen */
+  xbt_assert((xbt_graph_file_to_parse), "Unable to open \"%s\"\n", file);
+  xbt_graph_input_buffer =
+      xbt_graph_parse__create_buffer(xbt_graph_file_to_parse, 10);
   xbt_graph_parse__switch_to_buffer(xbt_graph_input_buffer);
   xbt_graph_parse_lineno = 1;
 }
 
-void  xbt_graph_parse_close(void) {
-  if(xbt_graph_input_buffer_stack) 
-    xbt_dynar_free(&xbt_graph_input_buffer_stack);
-  if(xbt_graph_file_to_parse_stack) 
-    xbt_dynar_free(&xbt_graph_file_to_parse_stack);
+void xbt_graph_parse_close(void)
+{
+  xbt_dynar_free(&xbt_graph_input_buffer_stack);
+  xbt_dynar_free(&xbt_graph_file_to_parse_stack);
 
-  if(xbt_graph_file_to_parse) {
+  if (xbt_graph_file_to_parse) {
     xbt_graph_parse__delete_buffer(xbt_graph_input_buffer);
     fclose(xbt_graph_file_to_parse);
   }
@@ -115,14 +118,15 @@ static int _xbt_graph_parse(void)
   return xbt_graph_parse_lex();
 }
 
-int_pf_void_t xbt_graph_parse = _xbt_graph_parse;
+int_f_void_t xbt_graph_parse = _xbt_graph_parse;
 
-void xbt_graph_parse_get_double(double *value,const char *string)
-{ 
-  int ret = 0;
+double xbt_graph_parse_get_double(const char *string)
+{
+  double result;
+  XBT_ATTRIB_UNUSED int ret = 0;
 
-  ret = sscanf(string, "%lg", value);
-  xbt_assert2((ret==1), "Parse error line %d : %s not a number", xbt_graph_parse_lineno,
-             string);
+  ret = sscanf(string, "%lg", &result);
+  xbt_assert((ret == 1), "Parse error line %d : %s not a number",
+              xbt_graph_parse_lineno, string);
+  return result;
 }
-