diff options
| -rw-r--r-- | include/gensvm_util.h | 1 | ||||
| -rw-r--r-- | src/gensvm_util.c | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/include/gensvm_util.h b/include/gensvm_util.h index 18aa553..2fd60e7 100644 --- a/include/gensvm_util.h +++ b/include/gensvm_util.h @@ -23,5 +23,6 @@ int gensvm_check_argv(int argc, char **argv, char *str); int gensvm_check_argv_eq(int argc, char **argv, char *str); void note(const char *fmt,...); +void err(const char *fmt,...); #endif diff --git a/src/gensvm_util.c b/src/gensvm_util.c index db99e21..4353b40 100644 --- a/src/gensvm_util.c +++ b/src/gensvm_util.c @@ -126,3 +126,23 @@ void note(const char *fmt,...) va_end(ap); (*gensvm_print_string)(buf); } + +/** + * @brief Parse a formatted string and write it to standard error + * + * @details + * Shorthand for fprintf(stderr, ...) + * + * @param[in] fmt string format + * @param[in] ... variable argument list for the string format + */ +void err(const char *fmt, ...) +{ + char buf[BUFSIZ]; + va_list ap; + va_start(ap, fmt); + vsprintf(buf, fmt, ap); + va_end(ap); + fputs(buf, stderr); + fflush(stderr); +} |
