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
authorMartin Quinson <martin.quinson@loria.fr>
Fri, 3 Feb 2012 14:37:53 +0000 (15:37 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Fri, 3 Feb 2012 14:41:41 +0000 (15:41 +0100)
include/surf/surfxml_parse.h
src/surf/surfxml_parse.c

index 721db6e..cc8936d 100644 (file)
@@ -45,7 +45,8 @@ XBT_PUBLIC(void) surf_parse_close(void);
 XBT_PUBLIC(void) surf_parse_init_callbacks(void);
 XBT_PUBLIC(void) surf_parse_reset_callbacks(void);
 XBT_PUBLIC(void) surf_parse_free_callbacks(void);
 XBT_PUBLIC(void) surf_parse_init_callbacks(void);
 XBT_PUBLIC(void) surf_parse_reset_callbacks(void);
 XBT_PUBLIC(void) surf_parse_free_callbacks(void);
-XBT_PUBLIC(void) surf_parse_error(const char *msg) _XBT_GNUC_NORETURN;
+XBT_PUBLIC(void) surf_parse_error(const char *msg,...) _XBT_GNUC_PRINTF(1,2) _XBT_GNUC_NORETURN;
+XBT_PUBLIC(void) surf_parse_warn(const char *msg,...) _XBT_GNUC_PRINTF(1,2);
 XBT_PUBLIC(double) surf_parse_get_double(const char *string);
 XBT_PUBLIC(int) surf_parse_get_int(const char *string);
 /* Prototypes of the functions offered by flex */
 XBT_PUBLIC(double) surf_parse_get_double(const char *string);
 XBT_PUBLIC(int) surf_parse_get_int(const char *string);
 /* Prototypes of the functions offered by flex */
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) {