Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add a surf_parse_warn and get surf_parse_error() accepting variable amount of parameters
[simgrid.git] / src / surf / surfxml_parse.c
index bad20fb..ab0282a 100644 (file)
@@ -4,6 +4,8 @@
 /* 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. */
 
 /* 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 <stdarg.h> /* va_arg */
+
 #include "xbt/misc.h"
 #include "xbt/log.h"
 #include "xbt/str.h"
 #include "xbt/misc.h"
 #include "xbt/log.h"
 #include "xbt/str.h"
@@ -23,8 +25,20 @@ char* surf_parsed_filename = NULL; // to locate parse error messages
 /*
  * Helping functions
  */
 /*
  * Helping functions
  */
-void surf_parse_error(const char *msg) {
-  xbt_die("Parse error at %s:%d: %s\n", surf_parsed_filename, surf_parse_lineno, msg);
+void surf_parse_error(const char *fmt, ...) {
+       va_list va;
+       va_start(va,fmt);
+       char *msg = bvprintf(fmt,va);
+       va_end(va);
+       xbt_die("Parse error at %s:%d: %s", surf_parsed_filename, surf_parse_lineno, msg);
+}
+void surf_parse_warn(const char *fmt, ...) {
+       va_list va;
+       va_start(va,fmt);
+       char *msg = bvprintf(fmt,va);
+       va_end(va);
+    XBT_WARN("%s:%d: %s", surf_parsed_filename, surf_parse_lineno, msg);
+    free(msg);
 }
 
 double surf_parse_get_double(const char *string) {
 }
 
 double surf_parse_get_double(const char *string) {