From 34930adb929619f15374207ad3daa76688fa19c9 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Wed, 11 Jan 2017 22:45:29 +1000 Subject: [PATCH] * add oal_error() --- src/config.c | 10 ++++++++++ src/config.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/config.c b/src/config.c index 1990318..0c7e5af 100644 --- a/src/config.c +++ b/src/config.c @@ -3,12 +3,22 @@ #include #include #include +#include #include #include "config.h" enum { bufsize = 1024 }; +int +oal_error(oal_config_t * const c, const char *fmt, ...) { + va_list args; + va_start(args, fmt); + vsnprintf(c->error, sizeof(c->error), fmt, args); + va_end(args); + return 1; +} + int parse_config(oal_config_t * const config, const char *file) { FILE *f; unsigned short linenum = 0; diff --git a/src/config.h b/src/config.h index 5c20441..a059cee 100644 --- a/src/config.h +++ b/src/config.h @@ -12,6 +12,9 @@ typedef struct { char error[1024]; /** parser error */ } oal_config_t; +int oal_error(oal_config_t * const c, const char *fmt, ...) +__attribute__ ((format (printf, 2, 3))); + int parse_config(oal_config_t * const config, const char *file); int check_config(oal_config_t * const config);